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

:root {
  --brand:        #178077;  /* teal-green: links, primary buttons, active tab underline */
  --brand-dark:   #2E6367;  /* header bar background */
  --brand-light:  #EAF5F3;  /* page background */
  --brand-lighter:#F4FAF9;  /* card hover / subtle surfaces */
  --accent:       #D97706;  /* warm amber: secondary chart series, highlight badges */
  --success:      #16a34a;
  --gray-50:      #f9fafb;
  --gray-100:     #f3f4f6;
  --gray-200:     #e5e7eb;
  --gray-300:     #d1d5db;
  --gray-400:     #9ca3af;
  --gray-600:     #4b5563;
  --gray-800:     #37474F;
  --red-bg:       #fef2f2;
  --red-text:     #b91c1c;
  --orange-bg:    #fff7ed;
  --orange-text:  #c2410c;
  --green-bg:     #f0fdf4;
  --green-text:   #166534;
  --radius:       8px;
  --shadow:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--brand-light);
  color: var(--gray-800);
  min-height: 100vh;
}

/* ── Header ── */
.header {
  background: var(--brand-dark);
  color: white;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-left  { display: flex; align-items: center; gap: .5rem; }
.header-brand { font-size: .9375rem; font-weight: 700; color: white; }
.header-sep   { color: rgba(255,255,255,.4); }
.header-title { font-size: .9375rem; font-weight: 500; color: rgba(255,255,255,.85); }

/* ── Layout ── */
.main   { max-width: 1280px; margin: 0 auto; padding: 2rem; }
.hidden { display: none !important; }

/* ── Upload zone ── */
.upload-zone {
  border: 1.5px dashed var(--gray-300);
  border-radius: var(--radius);
  background: white;
  padding: 1.5rem 1.75rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  margin-bottom: 1rem;
}
.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--brand);
  background: var(--brand-lighter);
}
.upload-zone-icon {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--brand-light);
  color: var(--brand);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.upload-zone-text { font-size: .9375rem; font-weight: 600; color: var(--gray-800); }
.upload-hint { font-size: .8125rem; color: var(--gray-400); margin-top: .125rem; }

.upload-status {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem .875rem;
  border-radius: 6px;
  font-size: .8125rem;
  font-weight: 500;
  margin-bottom: .75rem;
}
.upload-status.success { background: var(--green-bg); color: var(--green-text); }
.upload-status.error   { background: var(--red-bg); color: var(--red-text); }

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 1.5rem;
  border-bottom: 1px solid var(--gray-200);
  margin-bottom: 1.5rem;
}
.tab {
  padding: .75rem .125rem;
  font-size: .9375rem;
  font-weight: 600;
  color: var(--gray-400);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.tab:hover:not(.disabled) { color: var(--brand); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab.disabled { color: var(--gray-300); cursor: not-allowed; }

/* ── Controls / month picker ── */
.controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.controls-group { display: flex; align-items: center; gap: .5rem; }
.ctrl-label { font-size: .8125rem; font-weight: 500; color: var(--gray-600); white-space: nowrap; }
.month-picker, .search-input, .gap-input {
  padding: .375rem .75rem;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: .875rem;
  outline: none;
  background: white;
  transition: border-color .15s;
}
.month-picker:focus, .search-input:focus { border-color: var(--brand); }

/* ── Buttons ── */
.btn {
  padding: .375rem .875rem;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: .875rem; font-weight: 500;
  background: white; color: var(--gray-600);
  cursor: pointer; white-space: nowrap;
  transition: all .15s;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.active { background: var(--brand); color: white; border-color: var(--brand); }
.btn-primary {
  background: var(--brand); color: white; border-color: var(--brand);
}
.btn-primary:hover { background: #146860; color: white; }

.export-bar {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  padding: .75rem 1rem;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

/* ── Stat cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.stat-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1.125rem 1.375rem;
  box-shadow: var(--shadow);
}
.stat-label { font-size: .6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--gray-400); margin-bottom: .375rem; }
.stat-value { font-size: 1.875rem; font-weight: 700; line-height: 1; color: var(--gray-800); }
.stat-sub   { font-size: .75rem; color: var(--gray-400); margin-top: .375rem; }
.stat-empty { font-size: .875rem; color: var(--gray-400); font-style: italic; }

/* ── Chart cards ── */
.chart-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.chart-card-title { font-size: .875rem; font-weight: 600; color: var(--gray-800); margin-bottom: 1rem; }
.chart-wrap { position: relative; height: 280px; }
.charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 1.25rem; }

/* ── Tables ── */
.table-wrapper {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 1.5rem;
}
table  { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead  { background: var(--gray-50); }
th {
  padding: .6875rem 1rem;
  text-align: left;
  font-size: .6875rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--gray-400);
  border-bottom: 1px solid var(--gray-200);
  cursor: pointer; user-select: none; white-space: nowrap;
}
th:hover, th.sorted { color: var(--brand); }
td { padding: .8125rem 1rem; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }
.empty-td { text-align: center; padding: 3.5rem 1rem !important; color: var(--gray-400); }
.num-cell { font-variant-numeric: tabular-nums; }

.badge {
  display: inline-flex; align-items: center;
  padding: .1875rem .5625rem; border-radius: 999px;
  font-weight: 600; font-size: .75rem;
}
.badge-recurring { background: var(--green-bg); color: var(--green-text); }
.badge-onetime   { background: var(--orange-bg); color: var(--orange-text); }

@media (max-width: 768px) {
  .main { padding: 1rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .charts-grid { grid-template-columns: 1fr; }
}
