/* Bank Analyzer v2 */
:root {
  --primary: #1F4E79;
  --accent:  #4472C4;
  --green:   #375623;
  --green-bg:#E2EFDA;
  --red:     #C00000;
  --red-bg:  #FFE0E0;
  --warn-bg: #FFF3CD;
  --warn-border: #FFAB00;
  --gray:    #F5F5F5;
  --border:  #D0D7DE;
  --radius:  8px;
  --shadow:  0 2px 8px rgba(0,0,0,.10);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #EAEFF5;
  color: #24292F;
  line-height: 1.6;
  padding: 24px 16px;
}

.container { max-width: 1200px; margin: 0 auto; }

header { text-align: center; margin-bottom: 32px; }
header h1 { color: var(--primary); font-size: 2rem; }
header .subtitle { color: #666; margin-top: 4px; }

.badge {
  display: inline-block; background: var(--accent); color: #fff;
  border-radius: 4px; padding: 2px 8px; font-size: 0.75rem;
  vertical-align: middle; margin-left: 6px;
}

/* ── Cards ── */
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 24px;
}
.card h2 { color: var(--primary); margin-bottom: 16px; font-size: 1.2rem; }

/* ── Form ── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; }
.form-group input[type="file"],
.form-group select {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  background: var(--gray);
}

/* ── Buttons ── */
.btn {
  display: inline-block; padding: 10px 24px;
  border-radius: var(--radius); font-size: 1rem;
  font-weight: 600; cursor: pointer; border: none;
  text-decoration: none; transition: opacity .15s;
}
.btn:hover { opacity: .88; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-success  { background: #375623; color: #fff; display: inline-block; margin-top: 16px; }

/* ── Spinner ── */
.spinner { text-align: center; padding: 32px; }
.spinner-ring {
  display: inline-block; width: 48px; height: 48px;
  border: 5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Error / warn boxes ── */
.error-box {
  background: var(--red-bg); border: 1px solid var(--red);
  color: var(--red); border-radius: var(--radius);
  padding: 14px 18px; margin-bottom: 16px; font-weight: 500;
}
.warn-box {
  background: var(--warn-bg); border: 1px solid var(--warn-border);
  color: #7a5500; border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 12px; font-size: 0.875rem;
}
.detected-cols {
  background: #EBF5FB; border: 1px solid #AED6F1;
  color: #1a4f72; border-radius: var(--radius);
  padding: 8px 12px; margin-bottom: 12px; font-size: 0.85rem;
  font-family: monospace;
}

/* ── Bank badge ── */
.bank-badge {
  display: inline-block; background: #EBF5FB; color: #1a4f72;
  border-radius: 4px; padding: 2px 8px; font-size: 0.8rem;
  font-weight: 500; margin-left: 8px; vertical-align: middle;
}

/* ── Stats grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}
.stat {
  background: var(--gray); border-radius: var(--radius);
  padding: 12px 14px; text-align: center;
}
.stat-label { display: block; font-size: .78rem; color: #666; }
.stat-value { display: block; font-size: 1.25rem; font-weight: 700; margin-top: 4px; }
.income { color: var(--green); }
.expense { color: var(--red); }

/* ── Top-5 row (side by side) ── */
.top5-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 0;  /* cards have their own margin-bottom */
}
.top5-card { margin-bottom: 24px; }
@media (max-width: 700px) {
  .top5-row { grid-template-columns: 1fr; }
}

.right-col { text-align: right; white-space: nowrap; }
.cat-cell { font-size: 0.82rem; color: #555; }
.no-data { color: #999; font-style: italic; padding: 8px 0; }

/* ── Preview / generic tables ── */
.table-wrapper { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .86rem; }
th {
  background: var(--primary); color: #fff;
  padding: 8px 10px; text-align: left; white-space: nowrap;
}
td { padding: 6px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:nth-child(even) td { background: var(--gray); }
td.desc { max-width: 260px; white-space: pre-wrap; word-break: break-word; }

.cat-badge {
  background: #DEEAF1; color: var(--primary);
  border-radius: 4px; padding: 2px 6px; font-size: .78rem;
  white-space: nowrap;
}
.cat-badge-2 {
  background: #E2EFDA; color: var(--green);
}

.hidden { display: none !important; }
