/* ═══════════════════════════════════════════════════════
   DESIGN SYSTEM TOKENS — "ink on paper" language
   (ported from the My Planning design references: calm base,
   one warm gold signal, hairline borders, minimal shadows)
   ═══════════════════════════════════════════════════════ */
:root {
  --text-xs: 10px;
  --text-sm: 12px;
  --text-base: 14px;
  --text-lg: 17px;
  --text-xl: 22px;
  --text-2xl: 27px;

  --leading-tight: 1.25;
  --leading-snug: 1.4;
  --leading-base: 1.55;

  --tracking-tight: -0.01em;
  --tracking-base: 0;
  --tracking-wide: 0.08em;
  --tracking-wider: 0.12em;
  --tracking-widest: 0.14em;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  --radius-sm: 6px;
  --radius-base: 8px;
  --radius-lg: 12px;
  --radius-xl: 18px;
  --radius-pill: 999px;

  --display: 'Schibsted Grotesk', system-ui, sans-serif;
  --serif:   'Inter', system-ui, sans-serif;
  --mono:    'JetBrains Mono', ui-monospace, 'SF Mono', monospace;

  --ease-out:    cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in:     cubic-bezier(0.7, 0, 0.84, 0);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --duration-fast: 120ms;
  --duration-base: 200ms;
  --duration-slow: 320ms;
}

/* ═══════════════════════════════════════════════════════
   LIGHT THEME (default) — ink on paper
   ═══════════════════════════════════════════════════════ */
:root, :root[data-theme="light"] {
  color-scheme: light;

  --bg: #F4F6F8;            /* paper */
  --bg-card: #FFFFFF;       /* surface */
  --bg-card-deep: #F4F6F8;  /* paper step inside cards */
  --bg-hover: #EEF1F5;
  --bg-sidebar: #FCFDFE;

  --border: #E5E9EE;        /* line */
  --rule: #E5E9EE;
  --rule-faint: #EEF1F5;    /* line-soft */

  --primary: #1A1D23;       /* ink — primary actions & active states */
  --primary-hover: #2D323B;
  --primary-soft: #EEF0F3;
  --primary-text: #FFFFFF;  /* text on primary surfaces */

  --gold:      #B5852A;     /* the one warm signal */
  --gold-tint: #F8F1DE;
  --gold-line: #E7D5A6;
  --teal:      #3C8A5E;     /* done / positive */
  --green-tint:#E9F3ED;
  --violet:    #7A6FB0;     /* dusty plum (data accents) */
  --coral:     #CB5A52;     /* muted rose — danger / conflict */

  --text:    #1A1D23;
  --muted-1: #2D323B;       /* body */
  --muted-2: #4A505A;
  --muted-3: #71767F;       /* labels, table headers — ≥4.5:1 on white */
  --muted-4: #A3A8B1;

  --shadow-sm: 0 1px 2px rgba(20,24,32,.05), 0 1px 3px rgba(20,24,32,.05);
  --shadow-md: 0 6px 22px rgba(20,24,32,.07), 0 2px 6px rgba(20,24,32,.04);
  --shadow-lg: 0 12px 36px rgba(20,24,32,.10), 0 2px 8px rgba(20,24,32,.05);

  --modal-backdrop: rgba(20, 24, 32, 0.32);

  /* === Compatibility aliases — existing markup/JS reference these === */
  --card:   var(--bg-card);
  --muted:  var(--muted-3);
  --accent: var(--primary);
  --accent2:var(--gold);
  --green:  var(--teal);
  --red:    var(--coral);
  --amber:  var(--gold);
  --shadow: var(--shadow-sm);
  --shadow-card: var(--shadow-sm);
  --radius: var(--radius-lg);
  --font:   var(--serif);
}

/* ═══════════════════════════════════════════════════════
   DARK THEME — same language, ink surfaces
   (derived: the references define light only)
   ═══════════════════════════════════════════════════════ */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #15171C;
  --bg-card: #1E2127;
  --bg-card-deep: #262A31;
  --bg-hover: #262A31;
  --bg-sidebar: #191C21;

  --border: #2E333B;
  --rule: #2E333B;
  --rule-faint: #262A31;

  --primary: #F2F3F5;       /* inverted ink */
  --primary-hover: #FFFFFF;
  --primary-soft: rgba(255,255,255,.07);
  --primary-text: #1A1D23;

  --gold:      #C99A45;
  --gold-tint: rgba(181,133,42,.14);
  --gold-line: rgba(201,154,69,.40);
  --teal:      #4FA97A;
  --green-tint:rgba(60,138,94,.16);
  --violet:    #9C8FD0;
  --coral:     #D96C63;

  --text:    #F2F3F5;
  --muted-1: #C6C9CE;
  --muted-2: #A8ACB3;
  --muted-3: #8A8F98;       /* ≥4.5:1 on card bg */
  --muted-4: #565B63;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.40);
  --shadow-md: 0 8px 28px rgba(0,0,0,.50), 0 2px 8px rgba(0,0,0,.35);
  --shadow-lg: 0 16px 44px rgba(0,0,0,.60);

  --modal-backdrop: rgba(0, 0, 0, 0.55);
}

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

html, body {
  background: var(--bg);
  color: var(--muted-1);
  font-family: var(--serif);
  font-size: var(--text-base);
  line-height: var(--leading-base);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body {
  position: relative;
  overflow-x: hidden;
  transition:
    background var(--duration-base) var(--ease-out),
    color      var(--duration-base) var(--ease-out);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

button {
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
  transition:
    color        var(--duration-fast) var(--ease-out),
    background   var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    opacity      var(--duration-fast) var(--ease-out),
    transform    var(--duration-fast) var(--ease-out);
}
button:active:not(:disabled) {
  transform: scale(0.97);
  transition-duration: var(--duration-fast);
}
h1 { font-family: var(--display); font-size: var(--text-xl); font-weight: 800; color: var(--text); letter-spacing: -0.02em; }
h2 { font-family: var(--display); font-size: 16px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; margin-bottom: 12px; }
h3 { font-size: 13px; font-weight: 600; color: var(--muted-3); text-transform: uppercase; letter-spacing: var(--tracking-wide); margin-bottom: 10px; }
code {
  font-family: var(--mono);
  font-size: 0.92em;
  background: var(--bg-card-deep);
  border: 1px solid var(--rule-faint);
  border-radius: 4px;
  padding: 1px 5px;
}

/* ═══════════════════════════════════════════════════════
   SHELL — sidebar + right column (no topbar)
   ═══════════════════════════════════════════════════════ */
.app-wrap {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

.left-rail {
  width: 240px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  scrollbar-width: none;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  position: relative;
  z-index: 2;
  padding: var(--space-4) 0 var(--space-5);
  overscroll-behavior: contain;
}
.left-rail::-webkit-scrollbar { display: none; }

.rail-section { padding: var(--space-3) var(--space-5); }
.rail-section + .rail-section { padding-top: var(--space-2); }
.rail-section-label {
  font-family: var(--serif);
  font-size: 11px;
  letter-spacing: var(--tracking-wider);
  color: var(--muted-3);
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: var(--space-2);
}

/* Brand */
.rail-brand { display: flex; align-items: center; gap: 9px; }
.brand-mark {
  width: 26px; height: 26px;
  border-radius: 7px;
  background: var(--primary);
  color: var(--primary-text);
  display: grid; place-items: center;
  font-family: var(--display);
  font-weight: 800; font-size: 14px;
  flex-shrink: 0;
}
.brand-name {
  font-family: var(--display);
  font-weight: 700; font-size: 15px;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* Signature card — coverage (the app's "North Star" slot) */
.northstar {
  background: linear-gradient(180deg, #FFFDF7, #FFFFFF);
  border: 1px solid var(--gold-line);
  border-radius: var(--radius-lg);
  padding: 13px 14px;
}
:root[data-theme="dark"] .northstar { background: var(--gold-tint); }
.northstar .ns-eb {
  font-size: 10px; font-weight: 600;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--gold);
}
.northstar .ns-role {
  font-family: var(--display);
  font-weight: 700; font-size: 16px;
  color: var(--text);
  margin-top: 3px; letter-spacing: -0.01em;
}
.northstar .ns-meta {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-top: 9px;
}
.northstar .ns-when { font-family: var(--mono); font-size: 10px; color: var(--muted-3); }
.northstar .ns-pct  { font-family: var(--mono); font-size: 11px; color: var(--gold); font-weight: 500; }
.ns-bar {
  height: 5px; border-radius: var(--radius-pill);
  background: var(--gold-tint);
  margin-top: 7px; overflow: hidden;
}
:root[data-theme="dark"] .ns-bar { background: rgba(201,154,69,.18); }
.ns-bar i {
  display: block; height: 100%;
  background: var(--gold);
  border-radius: var(--radius-pill);
  transition: width var(--duration-slow) var(--ease-out);
}

/* Nav — gold left-edge indicator on active */
.rail-nav { display: flex; flex-direction: column; gap: 2px; }
.rail-nav-btn {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: var(--radius-base);
  padding: 8px 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted-3);
  font-family: var(--serif);
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}
.rail-nav-btn:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); }
.rail-nav-btn.active {
  background: var(--bg-hover);
  color: var(--text);
  font-weight: 600;
}
.rail-nav-btn.active::before {
  content: '';
  position: absolute;
  left: -20px; top: 8px; bottom: 8px;
  width: 3px;
  border-radius: var(--radius-pill);
  background: var(--gold);
}
.rail-nav-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Months list */
.rail-mini-month-list { display: flex; flex-direction: column; gap: 1px; max-height: 220px; overflow-y: auto; scrollbar-width: thin; }
.rail-year-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--muted-4);
  letter-spacing: 0.10em;
  margin: 6px 6px 2px;
}
.rail-month-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 3px 6px 3px 18px;
  font-size: 12px;
  color: var(--muted-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.rail-month-row:hover { background: var(--bg-hover); color: var(--text); }
.rail-month-row.active {
  background: var(--gold-tint);
  color: var(--text);
  font-weight: 600;
}
.rail-month-row .m-name { font-family: var(--serif); }
.rail-month-row .m-total {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--muted-3);
  font-size: 11px;
  letter-spacing: 0.02em;
}
.rail-empty {
  padding: 8px 6px;
  font-size: 11px;
  color: var(--muted-4);
  font-style: italic;
}

/* Categories list */
.rail-cat-list {
  display: flex; flex-direction: column; gap: 1px;
  max-height: 44vh;
  overflow-y: auto;
  scrollbar-width: thin;
  margin-top: 6px;
}
.rail-cat-row {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--muted-2);
  min-height: 24px;
}
.rail-cat-row:hover { background: var(--bg-hover); }
.rail-cat-row .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.rail-cat-row .name {
  flex: 1; font-family: var(--serif);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rail-cat-row .count {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--muted-4);
  font-size: 11px;
  flex-shrink: 0;
}
.rail-cat-row .row-actions {
  display: inline-flex; gap: 2px;
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-out);
  flex-shrink: 0;
}
.rail-cat-row:hover .row-actions { opacity: 1; }
.rail-cat-row.editing { background: var(--bg-hover); padding: 5px 6px; }
.rail-cat-row.editing input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: var(--serif);
  padding: 3px 6px;
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  outline: none;
  min-width: 0;
}
.rail-cat-row.editing input:focus {
  border-color: var(--gold);
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

/* Rail section header / mini-buttons / collapse */
.rail-section-collapsable .rail-section-header {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer;
  margin-bottom: 4px;
  user-select: none;
  border-radius: var(--radius-sm);
  padding: 2px 4px;
  margin-left: -4px;
  margin-right: -4px;
}
.rail-section-collapsable .rail-section-header:hover { background: var(--bg-hover); }
.rail-section-collapsable .rail-section-header .rail-section-label {
  flex: 1; margin-bottom: 0;
  display: inline-flex; align-items: center; gap: 6px;
}
.rail-section-count {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--muted-3);
  background: var(--bg-hover);
  border-radius: var(--radius-pill);
  padding: 1px 6px;
  font-weight: 500;
  text-transform: none;
}
.rail-section-actions { display: inline-flex; align-items: center; gap: 2px; }
.rail-section-chevron {
  font-family: var(--serif); font-size: 10px;
  color: var(--muted-4);
  margin-left: 4px;
  transition: transform var(--duration-fast) var(--ease-out);
}
.rail-section-collapsable.collapsed .rail-section-chevron { transform: rotate(-90deg); }
.rail-section-collapsable.collapsed .rail-section-body { display: none; }

.rail-mini-btn {
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  width: 22px; height: 22px;
  font-size: 11px;
  color: var(--muted-3);
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
  cursor: pointer;
  font-family: var(--serif);
}
.rail-mini-btn:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); }
.rail-mini-btn.primary { background: var(--primary); color: var(--primary-text); font-weight: 700; }
.rail-mini-btn.primary:hover:not(:disabled) { background: var(--primary-hover); color: var(--primary-text); }
.rail-mini-btn.danger:hover:not(:disabled) { background: rgba(203,90,82,0.12); color: var(--coral); }

.rail-add-row {
  display: flex; gap: 4px; align-items: center;
  margin-top: 2px; margin-bottom: 4px;
}
.rail-add-row input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-base);
  font-size: 12px;
  font-family: var(--serif);
  padding: 4px 8px;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  outline: none;
  min-width: 0;
}
.rail-add-row input::placeholder { text-transform: none; letter-spacing: 0; color: var(--muted-4); }
.rail-add-row input:focus {
  border-color: var(--gold);
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

/* Sidebar footer — theme, settings, save status */
.rail-footer {
  margin-top: auto;
  padding-top: var(--space-3);
  border-top: 1px solid var(--rule-faint);
  margin-left: var(--space-5);
  margin-right: var(--space-5);
  padding-left: 0;
  padding-right: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.side-controls {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 2px;
}
.ctl {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted-3);
}
.toggle {
  width: 34px; height: 20px;
  border-radius: var(--radius-pill);
  background: var(--border);
  position: relative;
  border: none;
  padding: 0;
  flex-shrink: 0;
}
.toggle i {
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: var(--radius-pill);
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform var(--duration-base) var(--ease-out);
}
:root[data-theme="dark"] .toggle { background: var(--gold); }
:root[data-theme="dark"] .toggle i { transform: translateX(14px); }
.foot-link {
  font-size: 12px;
  color: var(--muted-3);
  padding: 6px 4px;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
}
.foot-link:hover { color: var(--text); background: var(--bg-hover); }

.sync-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--text-xs);
  color: var(--muted-3);
  font-family: var(--mono);
  letter-spacing: 0.04em;
}
.sync-pill::before {
  content: '';
  width: 6px; height: 6px;
  background: var(--teal); border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.sync-pill.idle::before { background: var(--muted-4); }
.sync-pill.saving::before { background: var(--gold); animation: pulse 1.2s ease-in-out infinite; }
.sync-pill.error::before { background: var(--coral); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

/* RIGHT COLUMN + PAGES */
.right-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.page { display: none; max-width: 1400px; margin: 0 auto; padding: 28px 32px 56px; width: 100%; }
.page.active { display: block; }

/* Page header — eyebrow · title · purpose (one pattern, every screen) */
.ph { margin-bottom: var(--space-6); }
.ph-eyebrow {
  font-size: 11px; font-weight: 600;
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  color: var(--gold);
}
.ph-title {
  font-family: var(--display);
  font-weight: 800;
  font-size: var(--text-2xl);
  letter-spacing: -0.022em;
  color: var(--text);
  margin-top: 5px;
}
.ph-sub {
  font-size: 14px;
  color: var(--muted-3);
  margin-top: 5px;
  max-width: 64ch;
}

/* ═══════════════════════════════════════════════════════
   CARDS — white surface, hairline border, no blur
   ═══════════════════════════════════════════════════════ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }

/* GRID */
.grid-2{display:grid;grid-template-columns:1fr 1fr;gap:16px}
.grid-3{display:grid;grid-template-columns:1fr 1fr 1fr;gap:16px}
.grid-4{display:grid;grid-template-columns:repeat(4,1fr);gap:16px}

/* ═══════════════════════════════════════════════════════
   BUTTONS — soft rectangles (r=8), ink primary
   ═══════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 15px;
  border-radius: var(--radius-base);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--serif);
  line-height: 1.2;
  white-space: nowrap;
  transition:
    color        var(--duration-fast) var(--ease-out),
    background   var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    box-shadow   var(--duration-fast) var(--ease-out);
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-sm { padding: 5px 11px; font-size: 12px; }

.btn-primary {
  background: var(--primary);
  color: var(--primary-text);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-ghost {
  background: var(--bg-card);
  color: var(--muted-2);
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) { color: var(--text); border-color: var(--muted-4); }

.btn-success {
  background: var(--green-tint);
  color: var(--teal);
  border-color: transparent;
}
.btn-success:hover:not(:disabled) { border-color: var(--teal); }

.btn-danger {
  background: transparent;
  color: var(--coral);
  border-color: rgba(203, 90, 82, 0.35);
}
.btn-danger:hover:not(:disabled) { background: rgba(203, 90, 82, 0.10); border-color: var(--coral); }

.btn-amber {
  background: var(--gold-tint);
  color: var(--gold);
  border-color: var(--gold-line);
}
.btn-amber:hover:not(:disabled) { border-color: var(--gold); }

/* ═══════════════════════════════════════════════════════
   FORMS — labels above fields, gold focus ring
   ═══════════════════════════════════════════════════════ */
input[type=text], input[type=number], input[type=date], select, textarea {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-base);
  padding: 7px 11px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  width: 100%;
  font-family: var(--serif);
  transition: border-color var(--duration-fast) var(--ease-out);
}
:root[data-theme="dark"] input[type=text],
:root[data-theme="dark"] input[type=number],
:root[data-theme="dark"] input[type=date],
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea { background: rgba(255,255,255,0.05); }
input[type=number] { font-family: var(--mono); font-variant-numeric: tabular-nums; }
input[type=text]:focus, input[type=number]:focus, input[type=date]:focus, select:focus, textarea:focus {
  border-color: var(--gold);
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}
label.form-label {
  font-size: 12px; font-weight: 600;
  color: var(--text);
  display: block;
  margin-bottom: 6px;
  font-family: var(--serif);
}
.form-row { margin-bottom: 12px; }

/* FILE UPLOAD ZONE — first-run only; collapses to .load-strip once data exists */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-8) var(--space-5);
  text-align: center;
  cursor: pointer;
  background: var(--bg-card-deep);
  transition:
    border-color var(--duration-fast) var(--ease-out),
    background   var(--duration-fast) var(--ease-out);
}
:root[data-theme="dark"] .upload-zone { background: rgba(255,255,255,0.03); }
.upload-zone:hover { border-color: var(--gold-line); background: var(--gold-tint); }
.upload-zone.loaded { border-color: var(--teal); background: var(--green-tint); }
.upload-label { font-size: 13px; font-weight: 600; color: var(--muted-2); }
.upload-status { font-size: 11px; margin-top: 4px; color: var(--muted-3); }
.upload-zone.loaded .upload-status { color: var(--teal); font-weight: 600; }

/* Slim load strip — replaces the dropzone once expenses exist */
.load-strip {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-base);
  padding: 7px 14px;
  margin-bottom: 16px;
}
.load-strip .ls-status {
  font-size: 12px; color: var(--muted-2);
  display: inline-flex; align-items: center; gap: 8px;
}
.load-strip .ls-status::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: var(--radius-pill);
  background: var(--teal);
  flex-shrink: 0;
}

/* SECTION HEADERS */
.section-title {
  font-family: var(--display);
  font-size: 15px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 14px;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* BADGES — pill, mono, quiet state palette */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 600;
  font-family: var(--mono);
  letter-spacing: 0.04em;
  vertical-align: middle;
  white-space: nowrap;
}
.badge-blue   { background: var(--bg-card-deep); color: var(--muted-2); border: 1px solid var(--border); }
.badge-green  { background: var(--green-tint); color: var(--teal); }
.badge-amber  { background: var(--gold-tint);  color: var(--gold); }
.badge-red    { background: rgba(203, 90, 82, 0.12); color: var(--coral); }
.badge-orange { background: rgba(203, 90, 82, 0.12); color: var(--coral); }

/* ═══════════════════════════════════════════════════════
   RULES — toolbar, table, kebab, drawer
   ═══════════════════════════════════════════════════════ */
.rules-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 0 0 14px;
}
.rules-toolbar-left { display: flex; align-items: center; gap: 8px; }
.rules-toolbar-left select,
.rules-toolbar-left input[type=text] { width: auto; min-width: 0; flex-shrink: 1; }
.rules-toolbar-right { display: flex; align-items: center; gap: 8px; }
.rules-search-wrap { position: relative; display: flex; align-items: center; }
.rules-search-icon {
  position: absolute; left: 8px; font-size: 12px; color: var(--muted-4); pointer-events: none;
}
.rules-search-wrap input {
  padding: 5px 10px 5px 28px; font-size: 12px; width: 180px;
  border: 1px solid var(--border); border-radius: var(--radius-base);
  background: var(--bg-card-deep); color: var(--text);
}
.rules-more-wrap { position: relative; }
.rules-more-menu {
  position: absolute; top: 100%; right: 0; z-index: 100;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-base); box-shadow: var(--shadow-md);
  min-width: 180px; padding: 4px 0;
}
.rules-more-menu button {
  display: block; width: 100%; text-align: left;
  padding: 7px 14px; font-size: 12px; color: var(--text);
  background: none; border: none; cursor: pointer;
}
.rules-more-menu button:hover { background: var(--bg-hover); }
.rules-more-menu.hidden { display: none; }

/* RULES TABLE */
.rules-table-wrap { overflow-x: auto; max-height: 640px; overflow-y: auto; position: relative; border: 1px solid var(--rule); border-radius: var(--radius-base); }
.rules-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.rules-table th {
  position: sticky; top: 0; z-index: 2;
  background: var(--bg-card-deep); color: var(--muted-3);
  font-weight: 600; font-size: 10px; text-transform: uppercase;
  letter-spacing: var(--tracking-wide); padding: 8px 10px; text-align: left;
  border-bottom: 1px solid var(--border); white-space: nowrap;
  user-select: none;
}
:root[data-theme="dark"] .rules-table th { background: var(--bg-card-deep); }
.rules-table td {
  padding: 7px 10px; border-bottom: 1px solid var(--rule-faint);
  color: var(--text); vertical-align: middle;
}
.rules-table tr:hover td { background: var(--bg-card-deep); }
:root[data-theme="dark"] .rules-table tr:hover td { background: rgba(255,255,255,0.03); }
.rules-table tr.rule-row-disabled td { opacity: 0.45; }
.rules-table tr.rule-row-conflict td { background: var(--gold-tint); }
.rules-table .rt-priority {
  width: 44px; color: var(--muted-4);
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  text-align: right;
}
.rules-table .rt-name { font-weight: 600; color: var(--text); white-space: nowrap; }
.rules-table .rt-condition {
  font-family: var(--mono); font-size: 11px; color: var(--muted-2);
  max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rules-table .rt-category { white-space: nowrap; }
.rules-table .rt-matches {
  text-align: center; font-family: var(--mono); font-size: 11px; color: var(--muted-2);
}
.rules-table .rt-status { text-align: center; white-space: nowrap; }
.rules-table .rt-actions { width: 36px; text-align: center; }

.rt-cat-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 600;
  background: var(--bg-card-deep); color: var(--text);
  border: 1px solid var(--border);
}
:root[data-theme="dark"] .rt-cat-badge { background: rgba(255,255,255,0.05); }
.rt-cat-badge .rt-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.rt-del-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 600;
  background: rgba(203,90,82,0.12); color: var(--coral);
}
.rt-status-pill {
  display: inline-block; padding: 2px 8px; border-radius: var(--radius-pill);
  font-size: 10px; font-weight: 600; font-family: var(--mono);
}
.rt-status-pill.active { background: var(--green-tint); color: var(--teal); }
.rt-status-pill.disabled { background: var(--bg-card-deep); color: var(--muted-3); border: 1px solid var(--border); }

/* THREE-DOT MENU */
.rt-kebab {
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  border: none; background: none; cursor: pointer; border-radius: var(--radius-sm);
  color: var(--muted-3); font-size: 16px; letter-spacing: 2px; line-height: 1;
  transition: background var(--duration-fast) var(--ease-out);
}
.rt-kebab:hover { background: var(--bg-hover); color: var(--text); }
.rt-kebab-menu {
  position: absolute; z-index: 10000;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-base); box-shadow: var(--shadow-md);
  min-width: 160px; padding: 4px 0;
}
.rt-kebab-menu button {
  display: block; width: 100%; text-align: left;
  padding: 7px 14px; font-size: 12px; color: var(--text);
  background: none; border: none; cursor: pointer; white-space: nowrap;
}
.rt-kebab-menu button:hover { background: var(--bg-hover); }
.rt-kebab-menu .danger { color: var(--coral); }
.rt-kebab-menu .danger:hover { background: rgba(203,90,82,0.08); }
.rt-kebab-menu .separator { height: 1px; background: var(--rule-faint); margin: 4px 0; }

/* RULE DRAWER */
.rule-drawer-overlay {
  position: fixed; inset: 0; background: var(--modal-backdrop); z-index: 5000;
  display: flex; justify-content: flex-end;
}
.rule-drawer-overlay.hidden { display: none; }
.rule-drawer {
  width: 520px; max-width: 90vw; height: 100vh; background: var(--bg-card);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
  animation: drawerSlideIn var(--duration-base) var(--ease-out);
}
@keyframes drawerSlideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.rule-drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.rule-drawer-header h3 {
  font-family: var(--display);
  font-size: 15px; font-weight: 700; margin: 0; color: var(--text);
  text-transform: none; letter-spacing: -0.01em;
}
.rule-drawer-close {
  width: 32px; height: 32px; border: none; background: none;
  font-size: 22px; color: var(--muted-3); cursor: pointer;
  border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center;
}
.rule-drawer-close:hover { background: var(--bg-hover); color: var(--text); }
.rule-drawer-body { flex: 1; overflow-y: auto; padding: 20px; }
.drawer-section { margin-bottom: 16px; }
.drawer-section label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.drawer-section input[type="text"],
.drawer-section input[type="number"],
.drawer-section select {
  width: 100%; padding: 8px 11px; font-size: 13px;
  border: 1px solid var(--border); border-radius: var(--radius-base);
  background: var(--bg-card); color: var(--text);
}
:root[data-theme="dark"] .drawer-section input[type="text"],
:root[data-theme="dark"] .drawer-section input[type="number"],
:root[data-theme="dark"] .drawer-section select { background: rgba(255,255,255,0.05); }
.drawer-toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--rule-faint);
}
.drawer-toggle-row span { font-size: 13px; font-weight: 500; color: var(--text); }
.drawer-condition-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.drawer-footer {
  display: flex; gap: 8px; padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.drawer-preview {
  background: var(--bg-card-deep); border: 1px solid var(--border);
  border-radius: var(--radius-base); padding: 10px; margin-top: 8px;
  max-height: 200px; overflow-y: auto; font-size: 12px;
}
:root[data-theme="dark"] .drawer-preview { background: rgba(255,255,255,0.03); }
.drawer-preview-header {
  font-size: 10px; font-weight: 600; color: var(--muted-3);
  text-transform: uppercase; letter-spacing: var(--tracking-wide); margin-bottom: 6px;
}
.drawer-preview-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 3px 0; font-size: 11px; color: var(--text);
  border-bottom: 1px solid var(--rule-faint);
}
.drawer-preview-row:last-child { border-bottom: none; }

/* RESULTS TABLE row state — 3px left-edge code (reference card-edge pattern),
   no full-row fills: with hundreds of pending rows a gold wash would drown
   the signal. Conflicts alone keep a faint fill — rare and serious. */
.result-row-green td:first-child    { box-shadow: inset 3px 0 0 var(--teal); }
.result-row-yellow td:first-child   { box-shadow: inset 3px 0 0 var(--gold); }
.result-row-conflict td:first-child { box-shadow: inset 3px 0 0 var(--coral); }
.result-row-conflict td { background: rgba(203, 90, 82, 0.06); }

/* ═══════════════════════════════════════════════════════
   DASHBOARD
   ═══════════════════════════════════════════════════════ */
.summary-cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: var(--space-5); }
.summary-card {
  padding: var(--space-3) var(--space-4);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius-lg);
}
.summary-card .label {
  font-size: 11px; font-weight: 600;
  color: var(--muted-3);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  margin-bottom: var(--space-2);
  font-family: var(--serif);
}
.summary-card .value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  margin: 0 0 var(--space-2);
}
.summary-card .sub { font-size: var(--text-sm); color: var(--muted-3); }
/* Left-edge accents encode meaning; values stay ink except the signal */
.summary-card.accent { border-left-color: var(--gold); }
.summary-card.red    { border-left-color: var(--coral); }
.summary-card.green  { border-left-color: var(--teal); }
.summary-card.amber  { border-left-color: var(--violet); }
.summary-card.blue   { border-left-color: var(--primary); }
.summary-card.accent .value { color: var(--gold); }
.summary-card.red    .value { color: var(--coral); }
.summary-card.green  .value { color: var(--teal); }
.summary-card.amber  .value { color: var(--violet); }

.section{margin-bottom:20px}
.filter-bar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 10px 14px;
  background: var(--bg-card-deep);
  border: 1px solid var(--rule-faint);
  border-radius: var(--radius-base);
}
:root[data-theme="dark"] .filter-bar { background: rgba(255,255,255,0.03); }
.filter-bar label {
  font-size: 11px; font-weight: 600;
  color: var(--muted-3);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}
/* Labels that wrap a checkbox are controls, not captions — keep sentence case */
.filter-bar label:has(input[type=checkbox]) {
  text-transform: none;
  letter-spacing: 0;
  font-size: 12px;
  color: var(--muted-1);
}

/* TABS — segmented control (paper track, white active thumb) */
.tabs {
  display: inline-flex;
  gap: 2px;
  background: var(--bg-card-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius-base);
  padding: 3px;
}
:root[data-theme="dark"] .tabs { background: rgba(255,255,255,0.05); }
.tab {
  padding: 5px 13px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted-3);
  background: transparent;
  font-family: var(--serif);
}
.tab:hover:not(.active) { color: var(--text); }
.tab.active {
  background: var(--bg-card);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* TABLES */
.table-wrap { overflow-x: auto; border-radius: var(--radius-base); border: 1px solid var(--rule); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  background: var(--bg-card-deep);
  padding: 9px 12px; text-align: left;
  font-weight: 600; color: var(--muted-3);
  font-size: 10px; text-transform: uppercase; letter-spacing: var(--tracking-wide);
  border-bottom: 1px solid var(--rule);
  white-space: nowrap; user-select: none;
}
:root[data-theme="dark"] th { background: rgba(255,255,255,0.04); }
th[onclick] { cursor: pointer; }
th[onclick]:hover { color: var(--text); }
th .sort-icon { margin-left: 4px; opacity: 0.5; font-family: var(--mono); }
td { padding: 8px 12px; border-bottom: 1px solid var(--rule-faint); color: var(--text); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-card-deep); }
:root[data-theme="dark"] tr:hover td { background: rgba(255,255,255,0.03); }
.amount-cell {
  font-weight: 600;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  letter-spacing: -0.01em;
}
.cat-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* MULTISELECT */
.multiselect-wrap { position: relative; display: inline-block; }
.multiselect-btn {
  border: 1px solid var(--border);
  border-radius: var(--radius-base);
  padding: 6px 12px;
  font-size: 13px;
  background: var(--bg-card);
  cursor: pointer;
  min-width: 180px;
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px;
  color: var(--text);
  font-family: var(--serif);
  transition: border-color var(--duration-fast) var(--ease-out);
}
.multiselect-btn:hover { border-color: var(--muted-4); }
.multiselect-dropdown {
  position: absolute;
  top: calc(100% + 6px); left: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  z-index: 100;
  min-width: 260px;
  max-height: 360px;
  overflow-y: auto;
  padding: 6px;
}
.multiselect-dropdown.hidden { display: none; }
.ms-option {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px;
  cursor: pointer;
  font-size: 13px;
  border-radius: var(--radius-sm);
  color: var(--text);
}
.ms-option:hover { background: var(--bg-hover); }
.ms-option input[type=checkbox] { cursor: pointer; accent-color: var(--gold); }
.ms-divider { height: 1px; background: var(--rule-faint); margin: 4px 6px; }
.ms-label {
  padding: 6px 10px 4px;
  font-size: 10px; font-weight: 600;
  color: var(--muted-3);
  text-transform: uppercase; letter-spacing: var(--tracking-wide);
}
.ms-actions { display: flex; gap: 8px; padding: 8px 10px; border-top: 1px solid var(--rule-faint); margin-top: 4px; }

/* SLIDERS */
.slider-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--rule-faint); }
.slider-row:last-child { border-bottom: none; }
.slider-cat { width: 200px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); flex-shrink: 0; }
.slider-current {
  width: 70px; text-align: right;
  font-size: 12px; font-weight: 600;
  color: var(--muted-2);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
input[type=range] { flex: 1; accent-color: var(--gold); cursor: pointer; }
.slider-target {
  width: 80px; font-size: 11px; font-weight: 700;
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.over { color: var(--coral); } .under { color: var(--teal); } .on { color: var(--gold); }

.running-total {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-card-deep);
  border: 1px solid var(--rule-faint);
  border-radius: var(--radius-base);
  color: var(--text);
  margin-top: var(--space-3);
}
:root[data-theme="dark"] .running-total { background: rgba(255,255,255,0.03); }
.running-total .rt-label { font-size: 12px; color: var(--muted-3); }
.running-total .rt-value {
  font-size: 22px; font-weight: 700;
  color: var(--text);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* AVG BARS */
.avg-bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.avg-bar-label { width: 200px; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); flex-shrink: 0; }
.avg-bar-track {
  flex: 1; height: 13px;
  background: var(--bg-card-deep);
  border-radius: var(--radius-pill); overflow: hidden; cursor: pointer;
}
:root[data-theme="dark"] .avg-bar-track { background: rgba(255,255,255,0.05); }
.avg-bar-fill {
  height: 100%; border-radius: var(--radius-pill);
  transition: width var(--duration-slow) var(--ease-out);
}
.avg-bar-val {
  width: 70px; font-size: 11px; font-weight: 600;
  color: var(--muted-2); text-align: right; flex-shrink: 0;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

/* Band label — uppercase + hairline rule (reference band pattern) */
.section-divider{display:flex;align-items:center;gap:12px;margin:24px 0 14px}
.section-divider h2{
  white-space:nowrap;
  font-family:var(--serif);
  font-size:11px;font-weight:600;
  letter-spacing:var(--tracking-wider);
  text-transform:uppercase;
  color:var(--muted-3);
  margin-bottom:0;
}
.section-divider::after{content:'';flex:1;height:1px;background:var(--rule-faint)}

/* PAGINATION */
.pagination {
  display: flex; align-items: center; gap: 4px;
  margin-top: 12px;
  justify-content: flex-end;
}
.page-btn {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  font-size: 11px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--muted-2);
  min-width: 28px;
  text-align: center;
}
.page-btn:hover { color: var(--text); border-color: var(--muted-4); }
.page-btn.active {
  background: var(--primary);
  color: var(--primary-text);
  border-color: var(--primary);
}
.page-info {
  font-size: 11px;
  color: var(--muted-3);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  margin-right: 6px;
}

/* Tag — quiet mono chip */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 500;
  background: var(--bg-card-deep);
  color: var(--muted-2);
  border: 1px solid var(--border);
  font-family: var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
:root[data-theme="dark"] .tag { background: rgba(255,255,255,0.05); }

/* Month pills (dashboard pickers) */
.month-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin-bottom: 12px; }
.month-btn {
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted-3);
  text-align: center;
  font-family: var(--serif);
  transition:
    color var(--duration-fast) var(--ease-out),
    background var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out);
}
.month-btn:hover { color: var(--text); border-color: var(--muted-4); }
.month-btn.active { background: var(--primary); color: var(--primary-text); border-color: var(--primary); font-weight: 600; }

.cat-check-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 2px; max-height: 340px; overflow-y: auto;
  border: 1px solid var(--rule-faint);
  border-radius: var(--radius-base);
  padding: 6px;
}
.cat-check-item {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  color: var(--muted-2);
}
.cat-check-item:hover { background: var(--bg-hover); color: var(--text); }
.cat-check-item input { accent-color: var(--gold); cursor: pointer; }
.cat-section-label {
  grid-column: 1/-1;
  padding: 5px 6px 2px;
  font-size: 10px; font-weight: 600;
  color: var(--muted-3);
  text-transform: uppercase; letter-spacing: var(--tracking-wide);
  border-top: 1px solid var(--rule-faint);
  margin-top: 4px;
}

/* INSIGHTS — callout cards: 3px accent edge, tinted ground */
.insight-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.insight-card {
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  background: var(--bg-card);
}
.insight-card.red    { border-left-color: var(--coral); }
.insight-card.green  { border-left-color: var(--teal); }
.insight-card.amber  { border-left-color: var(--gold);   background: var(--gold-tint); border-color: var(--gold-line); }
.insight-card.blue   { border-left-color: var(--primary); }
.insight-card.purple { border-left-color: var(--violet); }
.insight-title { font-weight: 700; font-size: 13px; margin-bottom: 5px; color: var(--text); font-family: var(--display); }
.insight-value {
  font-size: 18px;
  font-weight: 700;
  margin: 6px 0 4px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--text);
}
.insight-text { font-size: 12px; color: var(--muted-2); line-height: 1.6; }
.fixed-config-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:4px;max-height:320px;overflow-y:auto}

/* ── Spending-by-category: total summary strip ── */
.cb-summary {
  display: flex; align-items: stretch; gap: 12px; flex-wrap: wrap;
  padding: 16px; margin-bottom: 18px;
  background: var(--bg-card-deep); border: 1px solid var(--rule-faint);
  border-radius: var(--radius-lg);
}
:root[data-theme="dark"] .cb-summary { background: rgba(255,255,255,0.03); }
.cb-sum-block { flex: 1; min-width: 130px; }
.cb-sum-lbl { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: var(--tracking-wide); color: var(--muted-3); margin-bottom: 6px; }
.cb-sum-val { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); line-height: 1; }
.cb-sum-block.save .cb-sum-val { font-size: 20px; color: var(--teal); }
.cb-sum-arrow { align-self: center; color: var(--muted-4); font-size: 20px; }

/* ── Group tiles ── */
.cb-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap: 12px; }
.cat-tile {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 14px; background: var(--bg-card);
  display: flex; flex-direction: column;
}
.cat-tile.tile-all-off { opacity: 0.55; }
.tile-head { display: flex; align-items: center; gap: 8px; }
.tile-head input[type=checkbox] { accent-color: var(--gold); cursor: pointer; flex-shrink: 0; }
.tile-title { font-family: var(--display); font-weight: 700; font-size: 14px; color: var(--text); flex: 1; letter-spacing: -0.01em; }
.tile-trend { font-family: var(--mono); font-size: 11px; font-weight: 600; flex-shrink: 0; }
.tile-total { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); margin: 8px 0 10px; display: flex; align-items: baseline; gap: 8px; }
.tile-share { font-size: 11px; font-weight: 500; color: var(--muted-3); font-family: var(--serif); }
.tile-cats { display: flex; flex-direction: column; gap: 1px; border-top: 1px solid var(--rule-faint); padding-top: 8px; }
.tile-cat { display: grid; grid-template-columns: auto auto 1fr auto; align-items: center; gap: 7px; padding: 3px 4px; border-radius: var(--radius-sm); }
.tile-cat:hover { background: var(--bg-card-deep); }
.tile-cat input[type=checkbox] { accent-color: var(--gold); cursor: pointer; }
.tile-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.tile-cat-name { font-size: 12px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.tile-cat-name:hover { text-decoration: underline; }
.tile-fix { font-size: 8px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted-3); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 0 5px; margin-left: 5px; }
.tile-cat-val { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 12px; font-weight: 600; color: var(--text); text-align: right; white-space: nowrap; }
.tile-cat.off { opacity: 0.4; }
.tile-cat.off .tile-cat-val { text-decoration: line-through; }
.tile-cat.fixed .tile-cat-name { color: var(--muted-2); }

/* ── Category Manager table ── */
.cm-head, .cm-row {
  display: grid; grid-template-columns: 1fr 240px 56px; align-items: center; gap: 12px;
}
.cm-head {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: var(--tracking-wide);
  color: var(--muted-3); padding: 0 4px 8px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg-card);
}
.cm-head span:last-child { text-align: center; }
#cat-manager-body { max-height: 62vh; overflow-y: auto; }
.cm-row { padding: 5px 4px; border-bottom: 1px solid var(--rule-faint); }
.cm-row:hover { background: var(--bg-card-deep); }
.cm-cat { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; color: var(--text); }
.cm-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.cm-group { font-size: 13px; padding: 6px 9px; }
.cm-fixed { accent-color: var(--gold); cursor: pointer; justify-self: center; width: 16px; height: 16px; }

/* ── Top merchants ── */
.merch-row {
  display: grid; grid-template-columns: minmax(0,1.4fr) 1fr auto;
  align-items: center; gap: 14px;
  padding: 8px 6px; border-bottom: 1px solid var(--rule-faint); cursor: pointer;
}
.merch-row:last-child { border-bottom: none; }
.merch-row:hover { background: var(--bg-card-deep); }
.merch-main { min-width: 0; }
.merch-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.merch-meta { font-size: 11px; color: var(--muted-3); margin-top: 1px; }
.merch-bar { height: 8px; background: var(--bg-card-deep); border-radius: var(--radius-pill); overflow: hidden; }
:root[data-theme="dark"] .merch-bar { background: rgba(255,255,255,0.05); }
.merch-bar-fill { height: 100%; background: var(--muted-4); border-radius: var(--radius-pill); }
.merch-total { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 13px; font-weight: 600; color: var(--text); text-align: right; white-space: nowrap; }

/* ── Category movers ── */
.mover-row {
  display: grid; grid-template-columns: auto minmax(0,1fr) auto auto;
  align-items: center; gap: 12px;
  padding: 8px 6px; border-bottom: 1px solid var(--rule-faint); cursor: pointer;
}
.mover-row:last-child { border-bottom: none; }
.mover-row:hover { background: var(--bg-card-deep); }
.mover-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mover-base { font-family: var(--mono); font-size: 11px; color: var(--muted-3); white-space: nowrap; }
.mover-delta { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 12px; font-weight: 600; white-space: nowrap; text-align: right; }

/* ── Recurring & subscriptions ── */
.rec-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 9px 6px; border-bottom: 1px solid var(--rule-faint); cursor: pointer;
}
.rec-row:last-child { border-bottom: none; }
.rec-row:hover { background: var(--bg-card-deep); }
.rec-main { min-width: 0; }
.rec-name { font-size: 13px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-meta { font-size: 11px; color: var(--muted-3); margin-top: 1px; }
.rec-flag { font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; border-radius: var(--radius-pill); padding: 1px 6px; flex-shrink: 0; }
.rec-flag.new { background: var(--green-tint); color: var(--teal); }
.rec-flag.chg { background: var(--gold-tint); color: var(--gold); }
.rec-cost { text-align: right; flex-shrink: 0; }
.rec-mo { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 13px; font-weight: 600; color: var(--text); }
.rec-yr { font-family: var(--mono); font-size: 10px; color: var(--muted-3); }

/* ── Biggest transactions ── */
.anom-row {
  display: grid; grid-template-columns: auto minmax(0,1fr) auto auto;
  align-items: center; gap: 12px;
  padding: 8px 6px; border-bottom: 1px solid var(--rule-faint); cursor: pointer;
}
.anom-row:last-child { border-bottom: none; }
.anom-row:hover { background: var(--bg-card-deep); }
.anom-date { font-family: var(--mono); font-size: 11px; color: var(--muted-3); white-space: nowrap; }
.anom-desc { font-size: 12px; color: var(--muted-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.anom-amt { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 13px; font-weight: 600; color: var(--text); text-align: right; white-space: nowrap; }

/* ── Collapsible config ── */
.config-details { margin-top: 20px; }
.config-details > summary {
  cursor: pointer; font-size: 12px; font-weight: 600; color: var(--muted-3);
  padding: 8px 0; list-style: none; user-select: none;
}
.config-details > summary:hover { color: var(--text); }
.config-details > summary::-webkit-details-marker { display: none; }

/* ═══════════════════════════════════════════════════════
   OVERVIEW (premium sub-view)
   ═══════════════════════════════════════════════════════ */
.ov-row { display: grid; gap: 16px; margin-bottom: 16px; }
.ov-row-2 { grid-template-columns: 1fr 1fr; }
.ov-row-hero { grid-template-columns: 1.7fr 1fr; }
@media (max-width: 1000px) { .ov-row-2, .ov-row-hero { grid-template-columns: 1fr; } }

/* Hero */
.ov-hero-card { padding: 22px; }
.hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.hero-month { font-family: var(--display); font-weight: 800; font-size: 22px; letter-spacing: -0.02em; color: var(--text); margin-top: 2px; }
.hero-headline { text-align: right; }
.hero-total { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 38px; font-weight: 700; letter-spacing: -0.03em; color: var(--text); line-height: 1; }
.hero-sub { font-size: 12px; color: var(--muted-3); margin-top: 6px; display: flex; align-items: center; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.hero-spark { height: 56px; margin: 16px 0 4px; }
.hero-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px,1fr)); gap: 14px; border-top: 1px solid var(--rule-faint); padding-top: 16px; margin-top: 12px; }
.hero-stat .hs-lbl { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: var(--tracking-wide); color: var(--muted-3); margin-bottom: 5px; }
.hero-stat .hs-val { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 18px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.hero-cta-stat .btn { margin-top: 2px; }

/* Semantic chips */
.ov-chip { display: inline-block; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; padding: 2px 8px; border-radius: var(--radius-pill); white-space: nowrap; flex-shrink: 0; }
.ov-chip.danger  { background: rgba(203,90,82,0.12);  color: var(--coral); }
.ov-chip.warn    { background: var(--gold-tint);       color: var(--gold); }
.ov-chip.success { background: var(--green-tint);      color: var(--teal); }
.ov-chip.info    { background: var(--bg-card-deep);    color: var(--muted-2); border: 1px solid var(--border); }
.ov-chip.neutral { background: var(--bg-card-deep);    color: var(--muted-3); }

/* Attention / review rows */
.attn-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--rule-faint); }
.attn-row:last-child { border-bottom: none; }
.attn-text { font-size: 12.5px; color: var(--muted-1); line-height: 1.4; }
.attn-cta { border: none; background: none; color: var(--gold); font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; padding: 2px 4px; border-radius: var(--radius-sm); }
.attn-cta:hover { background: var(--gold-tint); }
.ov-empty { font-size: 13px; color: var(--muted-3); padding: 18px 4px; text-align: center; }

/* Group spend vs budget */
.ovg-row { padding: 10px 2px; border-bottom: 1px solid var(--rule-faint); }
.ovg-row:last-child { border-bottom: none; }
.ovg-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.ovg-name { font-size: 13px; font-weight: 600; color: var(--text); }
.ovg-nums { font-size: 13px; color: var(--text); font-family: var(--mono); font-variant-numeric: tabular-nums; }
.ovg-ref { color: var(--muted-3); font-size: 11px; font-family: var(--serif); }
.ovg-track { height: 8px; background: var(--bg-card-deep); border-radius: var(--radius-pill); overflow: hidden; }
:root[data-theme="dark"] .ovg-track { background: rgba(255,255,255,0.05); }
.ovg-fill { height: 100%; border-radius: var(--radius-pill); transition: width var(--duration-slow) var(--ease-out); }
.ovg-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 5px; }
.ovg-status { font-size: 11px; font-weight: 600; font-family: var(--mono); }
.ovg-budget { width: 96px; font-size: 11px; padding: 3px 7px; text-align: right; opacity: 0.5; transition: opacity var(--duration-fast); }
.ovg-row:hover .ovg-budget, .ovg-budget:focus { opacity: 1; }

/* Regular charges */
.reg-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 4px; border-bottom: 1px solid var(--rule-faint); cursor: pointer; }
.reg-row:last-child { border-bottom: none; }
.reg-row:hover { background: var(--bg-card-deep); }
.reg-name { font-size: 13px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 7px; }
.reg-meta { font-size: 11px; color: var(--muted-3); margin-top: 1px; }
.reg-amt { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; }

/* Opportunities */
.opp-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--rule-faint); }
.opp-row:last-child { border-bottom: none; }
.opp-impact { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 17px; font-weight: 700; color: var(--gold); white-space: nowrap; }
.opp-impact span { font-size: 10px; color: var(--muted-3); font-weight: 500; }
.opp-title { font-size: 13px; font-weight: 600; color: var(--text); }
.opp-reason { font-size: 11.5px; color: var(--muted-3); margin-top: 1px; }

/* ═══════════════════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: var(--modal-backdrop);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-6);
  animation: fadeIn var(--duration-fast) var(--ease-out);
}
.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  max-width: 1400px; width: 95vw;
  max-height: 92vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn var(--duration-base) var(--ease-out);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--rule-faint);
}
.modal-close {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  width: 30px; height: 30px;
  font-size: 16px; cursor: pointer; color: var(--muted-2);
  line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color var(--duration-fast) var(--ease-out), background var(--duration-fast) var(--ease-out);
}
.modal-close:hover { color: var(--text); background: var(--bg-hover); }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ═══════════════════════════════════════════════════════
   ALERTS & CALLOUTS
   ═══════════════════════════════════════════════════════ */
.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-base);
  font-size: 13px;
  margin-bottom: var(--space-3);
  border: 1px solid transparent;
}
.alert-error   { background: rgba(203, 90, 82, 0.10); color: var(--coral); border-color: rgba(203, 90, 82, 0.25); }
.alert-success { background: var(--green-tint); color: var(--teal); border-color: rgba(60, 138, 94, 0.25); }
.alert-warn    { background: var(--gold-tint); color: var(--gold); border-color: var(--gold-line); }
.alert-info    { background: var(--bg-card-deep); color: var(--muted-1); border-color: var(--border); }
.divider{height:1px;background:var(--rule-faint);margin:16px 0}
.text-muted{color:var(--muted-3);font-size:12px}

/* Warning callout — gold left edge (reference callout pattern) */
.conflict-warn{
  background:var(--gold-tint);
  border:1px solid var(--gold-line);
  border-left:3px solid var(--gold);
  border-radius:var(--radius-base);
  padding:10px 14px;font-size:12px;
  color:var(--muted-1);
  margin-bottom:12px;display:flex;align-items:center;gap:8px;
}
.banner-warn{
  background:var(--gold-tint);
  border:1px solid var(--gold-line);
  border-left:3px solid var(--gold);
  border-radius:var(--radius-lg);
  padding:14px 20px;display:flex;align-items:center;justify-content:space-between;gap:16px;
}
.banner-warn .bw-title{font-family:var(--display);font-weight:700;font-size:14px;color:var(--text)}
.banner-warn .bw-text{font-size:12px;color:var(--muted-2);margin-top:2px}

/* DESC CELL — inner horizontal-scroll for long libellés */
.desc-cell {
  max-width: 300px;
  font-size: 12px;
  color: var(--muted-2);
  padding: 0 !important;
  vertical-align: middle;
}
.desc-scroll {
  overflow-x: auto;
  white-space: nowrap;
  padding: 8px 12px;
  scrollbar-width: none;
}
.desc-scroll::-webkit-scrollbar { display: none; }

/* ═══════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════ */
@media (max-width: 1100px) {
  .left-rail { width: 216px; }
  .summary-cards { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 800px) {
  .summary-cards { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .insight-grid { grid-template-columns: 1fr; }
}
