/* ─────────────────────────────────────────────────────────────
   Spending Journal — styles
   Light neutral, restrained. One accent. Green/amber/red status.
   Mobile-first: bottom nav < 960px, sidebar ≥ 960px.
   ───────────────────────────────────────────────────────────── */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --surface-3: #f2f4f7;
  --border: #e5e7eb;
  --border-strong: #d3d7de;

  --text: #111827;
  --text-2: #4b5563;
  --text-3: #6b7280;

  --accent: #1d4ed8;
  --accent-soft: #e8effc;
  --accent-ink: #ffffff;

  --pos: #0ca30c;
  --pos-text: #15803d;
  --pos-soft: #e7f5ea;

  --near: #f59e0b;
  --near-text: #b45309;
  --near-soft: #fdf3e0;

  --over: #dc2626;
  --over-text: #b91c1c;
  --over-soft: #fdeaea;

  --neutral: #64748b;
  --neutral-soft: #eef1f5;

  /* categorical slots (validated palette) */
  --c1: #2a78d6;
  --c2: #eb6834;
  --c3: #1baf7a;
  --c4: #eda100;
  --c5: #e87ba4;
  --c6: #4a3aa7;

  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.14);

  --radius: 14px;
  --radius-sm: 9px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --sidebar-w: 236px;
  --topbar-h: 64px;
  --bottomnav-h: 60px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }

.num { font-variant-numeric: tabular-nums; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ───────────────────────── layout ───────────────────────── */

.app { display: flex; min-height: 100vh; }

.main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
}

.view {
  flex: 1;
  padding: 24px 28px 64px;
  width: 100%;
  max-width: 1180px;
}

/* ───────────────────────── sidebar ───────────────────────── */

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  z-index: 30;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 18px; }
/* brand-logo styles moved to logo.css */
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.brand-sub { font-size: 11px; color: var(--text-3); margin-top: -2px; }

.nav { flex: 1; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-group-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-3); padding: 14px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 9px; border: none; background: none;
  width: 100%; text-align: left; cursor: pointer; color: var(--text-2);
  font-size: 14px; font-weight: 500;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item svg { width: 18px; height: 18px; flex: none; }

.sidebar-footer { border-top: 1px solid var(--border); padding: 12px 8px 4px; }

.quick-add-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px; border: none; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; cursor: pointer;
}
.quick-add-btn:hover { filter: brightness(1.06); }
.quick-add-btn svg { width: 17px; height: 17px; }

.data-note { font-size: 11px; color: var(--text-3); margin-top: 10px; line-height: 1.4; }

/* ───────────────────────── topbar ───────────────────────── */

.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
  padding: 0 24px;
}
.page-title { font-size: 18px; font-weight: 650; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-btn { display: none; }

.period-wrap { position: relative; flex: none; }

.theme-toggle {
  display: grid; place-items: center; flex: none;
  width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text-2); cursor: pointer; box-shadow: var(--shadow);
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle svg { width: 18px; height: 18px; }
.period-btn {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 10px; padding: 8px 12px; cursor: pointer; font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow); color: var(--text);
}
.period-btn:hover { border-color: var(--accent); }
.period-btn svg { width: 15px; height: 15px; color: var(--text-3); }

.period-pop {
  position: absolute; right: 0; top: calc(100% + 8px); width: 272px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg); padding: 6px; z-index: 60;
  max-height: 74vh; overflow-y: auto;
}
.period-option {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 9px 10px; border: none; background: none; border-radius: 8px;
  cursor: pointer; font-size: 14px; text-align: left; color: var(--text);
}
.period-option:hover { background: var(--surface-3); }
.period-option.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.period-option .check { width: 16px; height: 16px; flex: none; visibility: hidden; }
.period-option.active .check { visibility: visible; }
.period-option .check svg { width: 16px; height: 16px; }

.custom-range { border-top: 1px solid var(--border); margin-top: 4px; padding: 10px 4px 4px; }
.custom-range .label { font-size: 12px; color: var(--text-3); margin: 6px 6px 2px; font-weight: 600; }
.custom-range input[type="date"] {
  width: 100%; padding: 8px 9px; border: 1px solid var(--border-strong);
  border-radius: 8px; background: var(--surface-2); font-size: 14px;
}
.custom-range .apply {
  width: 100%; margin-top: 8px; padding: 9px; border: none; border-radius: 8px;
  background: var(--accent); color: #fff; font-weight: 600; cursor: pointer;
}
.custom-range .apply:hover { filter: brightness(1.06); }

.period-label-inline { font-size: 13px; color: var(--text-3); }

/* ───────────────────────── buttons / forms ───────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-weight: 600; font-size: 14px;
  cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--accent); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.06); border-color: var(--accent); }
.btn-danger { background: var(--surface); color: var(--over-text); border-color: #f1c4c4; }
.btn-danger:hover { background: var(--over-soft); border-color: var(--over); }
.btn-ghost { background: none; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn-lg { padding: 12px 20px; font-size: 15px; border-radius: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.field { margin-bottom: 16px; }
.label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.label .hint { font-weight: 400; color: var(--text-3); }
.input, .textarea, .select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong);
  border-radius: 10px; background: var(--surface); font-size: 15px; color: var(--text);
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.55; }
.input:focus, .textarea:focus, .select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.input-group { display: flex; align-items: stretch; }
.input-group .prefix {
  display: flex; align-items: center; padding: 0 10px;
  background: var(--surface-3); border: 1px solid var(--border-strong);
  border-right: none; border-radius: 10px 0 0 10px;
  color: var(--text-2); font-weight: 600; font-size: 15px;
  white-space: nowrap;
}
.input-group .input {
  flex: 1; min-width: 0;
  border-top-left-radius: 0; border-bottom-left-radius: 0;
}
.input:disabled, .textarea:disabled { background: var(--surface-3); color: var(--text-3); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ───────────────────────── cards & stat tiles ───────────────────────── */

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-title { font-size: 15px; font-weight: 650; }
.card-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.stack { display: flex; flex-direction: column; gap: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.stat-label { font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; }
.stat-delta { font-size: 12.5px; margin-top: 5px; font-weight: 600; }
.stat .suffix { font-size: 13px; font-weight: 500; color: var(--text-3); }

.hero {
  font-size: 44px; font-weight: 750; letter-spacing: -0.03em; line-height: 1.05;
  font-variant-numeric: normal;
}

.over { color: var(--over-text); }
.pos { color: var(--pos-text); }
.warn { color: var(--near-text); }
.muted { color: var(--text-3); }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
}
.pill-pos { background: var(--pos-soft); color: var(--pos-text); }
.pill-neg { background: var(--over-soft); color: var(--over-text); }
.pill-warn { background: var(--near-soft); color: var(--near-text); }
.pill-neutral { background: var(--neutral-soft); color: var(--neutral); }

/* ───────────────────────── budget bars ───────────────────────── */

.budget-row { padding: 12px 0; border-bottom: 1px solid var(--border); }
.budget-row:last-child { border-bottom: none; }
.budget-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 7px; }
.budget-name { font-weight: 600; font-size: 14px; }
.budget-nums { font-size: 13px; color: var(--text-2); }
.budget-nums .num { font-weight: 600; }
.budget-track {
  position: relative; height: 10px; border-radius: 6px; background: var(--surface-3);
  overflow: hidden;
}
.budget-fill {
  position: absolute; inset: 0 auto 0 0; border-radius: 6px 4px 4px 6px;
  height: 100%; min-width: 3px;
}
.budget-fill.within { background: var(--pos); }
.budget-fill.near { background: var(--near); }
.budget-fill.over { background: var(--over); }
.budget-marker {
  position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--text-3);
  border-radius: 1px; opacity: 0.85;
}

/* dashboard monthly-budget card */
.budget-k { font-size: 11.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; }
.budget-v { font-size: 24px; font-weight: 750; letter-spacing: -0.02em; margin-top: 2px; }
.budget-s { font-size: 12px; margin-top: 2px; }

/* budget table (monthly review / history) */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.04em; padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.tbl tr:last-child td { border-bottom: none; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl th.num { text-align: right; }
.tbl .total td { font-weight: 700; border-top: 1px solid var(--border-strong); }
.tbl .cat-name { font-weight: 500; }

/* ───────────────────────── donut + legend ───────────────────────── */

.donut-wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.donut { position: relative; width: 200px; height: 200px; flex: none; }
.donut svg { width: 100%; height: 100%; display: block; }
.donut-center {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none;
}
.donut-center .v { font-size: 20px; font-weight: 750; }
.donut-center .l { font-size: 11px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }

.legend { display: grid; grid-template-columns: 1fr; gap: 2px; width: 100%; }
.legend-item {
  display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 8px;
  font-size: 13.5px;
}
.legend-item:hover { background: var(--surface-3); }
.swatch { width: 11px; height: 11px; border-radius: 3.5px; flex: none; }
.legend-item .li-name { font-weight: 500; flex: 1; min-width: 0; }
.legend-item .li-val { font-weight: 600; }
.legend-item .li-pct { color: var(--text-3); font-size: 12px; width: 44px; text-align: right; }
.legend-item .li-diff { font-size: 12px; width: 66px; text-align: right; }

/* category list rows (dashboard "Spending by Category") */
.cat-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.cat-row:last-child { border-bottom: none; }
.cat-row .swatch { width: 10px; height: 10px; }
.cat-row .cat-name { flex: 1; font-weight: 500; font-size: 14px; }
.cat-row .cat-amt { font-weight: 650; font-size: 14px; text-align: right; }
.cat-row .cat-pct { width: 48px; text-align: right; color: var(--text-3); font-size: 12.5px; }

/* ───────────────────────── charts ───────────────────────── */

.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-grid-h { stroke: var(--border); stroke-width: 1; }
.chart-axis { stroke: var(--border-strong); stroke-width: 1; }
.chart-tick { fill: var(--text-3); font-size: 11px; }
.chart-label { fill: var(--text-2); font-size: 12px; font-weight: 600; }
.chart-bar { rx: 4px; }
.bar-hit { fill: transparent; }
.plan-line { stroke: var(--text-3); stroke-width: 1.5; stroke-dasharray: 5 4; }

.chart-tip {
  position: absolute; pointer-events: none; z-index: 50;
  background: #111827; color: #fff; border-radius: 9px; padding: 8px 11px;
  font-size: 12.5px; line-height: 1.45; box-shadow: var(--shadow-lg);
  max-width: 240px;
  transform: translate(-50%, calc(-100% - 10px));
}
.chart-tip .t-title { font-weight: 600; }
.chart-tip .t-val { font-weight: 700; font-size: 13.5px; }
.chart-tip .t-row { display: flex; gap: 6px; align-items: baseline; }
.chart-tip .t-key { width: 8px; height: 8px; border-radius: 2px; display: inline-block; align-self: center; }

.chart-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; font-size: 12.5px; color: var(--text-2); }
.chart-legend .swatch { width: 12px; height: 4px; border-radius: 2px; }
.chart-legend .dot { width: 9px; height: 9px; border-radius: 50%; }

/* ───────────────────────── forms: check-ins ───────────────────────── */

.form-card { max-width: 720px; }
.form-card .card-title { font-size: 17px; }

.week-context {
  background: var(--accent-soft); border: 1px solid #c9dcf8;
  border-radius: 12px; padding: 14px 16px; margin-bottom: 18px;
  display: flex; flex-wrap: wrap; gap: 8px 22px; align-items: center;
}
.week-context .ctx { display: flex; flex-direction: column; }
.week-context .ctx .k { font-size: 11.5px; color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.week-context .ctx .v { font-size: 15px; font-weight: 650; }

.compare {
  margin-top: 18px; border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; background: var(--surface-2);
}
.compare .cmp-title { font-size: 13px; font-weight: 700; color: var(--text-2); margin-bottom: 8px; }
.compare .cmp-row { display: flex; align-items: baseline; gap: 12px; font-size: 14px; }
.compare .cmp-delta { font-weight: 700; font-size: 15px; }
.cmp-down { color: var(--pos-text); }
.cmp-up { color: var(--over-text); }

/* monthly category editor */
.cat-edit-row {
  display: grid; grid-template-columns: 1.4fr 1fr 1fr 1.1fr; gap: 10px; align-items: center;
  padding: 9px 0; border-bottom: 1px solid var(--border);
}
.cat-edit-head {
  display: grid; grid-template-columns: 1.4fr 1fr 1fr 1.1fr; gap: 10px; align-items: center;
  font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em;
  padding-bottom: 6px;
}
.cat-edit-row .num { text-align: right; }
.cat-edit-row .input { padding: 8px 10px; font-size: 14px; }
.cat-name-cell { display: flex; align-items: center; gap: 6px; min-width: 0; }
.cat-name-cell .cat-name-input { flex: 1; min-width: 0; }
.cat-edit-row .rm-btn { border: none; background: none; color: var(--text-3); cursor: pointer; padding: 6px; border-radius: 7px; flex: none; }
.cat-edit-row .rm-btn:hover { color: var(--over-text); background: var(--over-soft); }
.cat-edit-total { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1.1fr; gap: 10px; align-items: center; padding-top: 10px; font-weight: 700; }

.warn-banner {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--near-soft); border: 1px solid #f6d7a3; color: var(--near-text);
  border-radius: 10px; padding: 11px 13px; font-size: 13.5px; margin: 4px 0 14px;
}
.warn-banner svg { width: 17px; height: 17px; flex: none; margin-top: 1px; }

/* ───────────────────────── history / timeline ───────────────────────── */

.tabs { display: inline-flex; background: var(--surface-3); border-radius: 10px; padding: 3px; gap: 2px; }
.tab {
  border: none; background: none; padding: 7px 14px; border-radius: 8px;
  font-weight: 600; font-size: 13.5px; color: var(--text-2); cursor: pointer;
}
.tab.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }

.filterbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filterbar .search { position: relative; flex: 1; min-width: 180px; max-width: 320px; }
.filterbar .search input { width: 100%; padding: 9px 12px 9px 34px; }
.filterbar .search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-3); }

.timeline { position: relative; }
.entry {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.entry-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.entry-date { font-weight: 700; font-size: 15px; }
.entry-amount { font-weight: 700; font-size: 15px; }
.entry-body { margin-top: 9px; display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; color: var(--text-2); }
.entry-body .row { display: flex; gap: 8px; align-items: baseline; }
.entry-body .row .k { color: var(--text-3); font-weight: 600; flex: none; min-width: 76px; }
.entry-actions { display: flex; gap: 6px; margin-top: 12px; justify-content: flex-end; }

.chev { width: 18px; height: 18px; color: var(--text-3); transition: transform 0.15s; }
.entry.open .chev { transform: rotate(90deg); }
.entry-detail { display: none; margin-top: 12px; border-top: 1px solid var(--border); padding-top: 12px; }
.entry.open .entry-detail { display: block; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.detail-block .k { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-3); font-weight: 600; margin-bottom: 4px; }
.detail-block .v { font-size: 14px; color: var(--text); white-space: pre-wrap; }

/* ───────────────────────── insights ───────────────────────── */

.insight {
  display: flex; gap: 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
}
.insight-ic {
  width: 32px; height: 32px; border-radius: 9px; flex: none;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center;
}
.insight-ic svg { width: 16px; height: 16px; }
.insight-ic.ic-pos { background: var(--pos-soft); color: var(--pos-text); }
.insight-ic.ic-neg { background: var(--over-soft); color: var(--over-text); }
.insight-ic.ic-warn { background: var(--near-soft); color: var(--near-text); }
.insight-body { flex: 1; min-width: 0; }
.insight-title { font-weight: 650; font-size: 14px; }
.insight-body p { font-size: 13.5px; color: var(--text-2); margin-top: 2px; }
.insight-src {
  display: block; font-size: 12px; color: var(--text-3); margin-top: 6px;
}
.insight-src a { color: var(--accent); }

.pattern-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ───────────────────────── empty states ───────────────────────── */

.empty {
  text-align: center; padding: 40px 24px; color: var(--text-2);
  border: 1px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--surface-2);
}
.empty .ic {
  width: 44px; height: 44px; margin: 0 auto 12px; border-radius: 12px;
  background: var(--surface-3); color: var(--text-3); display: grid; place-items: center;
}
.empty .ic svg { width: 22px; height: 22px; }
.empty-title { font-weight: 650; font-size: 15px; color: var(--text); }
.empty-body { font-size: 13.5px; margin-top: 4px; }
.empty .btn { margin-top: 14px; }



/* ───────────────────────── settings ───────────────────────── */

.settings-cat-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border);
}
.settings-cat-row .name { flex: 1; font-weight: 500; }
.settings-cat-row .budget-input { width: 150px; }
.settings-cat-row .icon-btn { border: none; background: none; color: var(--text-3); cursor: pointer; padding: 7px; border-radius: 8px; }
.settings-cat-row .icon-btn:hover { background: var(--surface-3); color: var(--text); }
.settings-cat-row .icon-btn.danger:hover { color: var(--over-text); background: var(--over-soft); }
.settings-cat-row .icon-btn svg { width: 17px; height: 17px; }

/* ───────────────────────── bottom nav (mobile) ───────────────────────── */

.bottomnav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; height: var(--bottomnav-h);
  background: var(--surface); border-top: 1px solid var(--border);
  z-index: 40; align-items: stretch;
}
.bottomnav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: none; background: none; color: var(--text-3); font-size: 10.5px; font-weight: 600; cursor: pointer;
  padding: 4px 2px;
}
.bottomnav-item svg { width: 21px; height: 21px; }
.bottomnav-item.active { color: var(--accent); }

.fab {
  position: fixed; right: 18px; bottom: calc(var(--bottomnav-h) + 14px); z-index: 45;
  width: 54px; height: 54px; border-radius: 50%; border: none;
  background: var(--accent); color: #fff; box-shadow: 0 8px 20px rgba(29, 78, 216, 0.4);
  display: grid; place-items: center; cursor: pointer;
}
.fab svg { width: 24px; height: 24px; }

/* quick-add menu */
.qa-pop {
  position: fixed; right: 16px; bottom: calc(var(--bottomnav-h) + 80px); z-index: 70;
  width: 240px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px;
}
.qa-item {
  display: flex; align-items: center; gap: 11px; width: 100%; padding: 11px 12px;
  border: none; background: none; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: 14px; text-align: left;
}
.qa-item:hover { background: var(--surface-3); }
.qa-item svg { width: 18px; height: 18px; color: var(--accent); }

/* ───────────────────────── modal / toast ───────────────────────── */

.backdrop {
  position: fixed; inset: 0; background: rgba(17, 24, 39, 0.42); z-index: 80;
  display: grid; place-items: center; padding: 20px;
}
.modal {
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 460px; padding: 22px; max-height: 90vh; overflow-y: auto;
}
.modal-title { font-size: 17px; font-weight: 700; }
.modal-body { font-size: 14.5px; color: var(--text-2); margin: 10px 0 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

.toast-root { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: #111827; color: #fff; border-radius: 10px; padding: 11px 16px;
  font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow-lg); display: flex; gap: 9px; align-items: center;
  animation: toast-in 0.18s ease;
}
.toast svg { width: 17px; height: 17px; flex: none; }
.toast.ok svg { color: #4ade80; }
.toast.err svg { color: #f87171; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

.hidden { display: none !important; }

/* page entrance */
.page-enter { animation: page-in 0.22s ease; }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ───────────────────────── dark theme ───────────────────────── */

body[data-theme="dark"] {
  --bg: #0f1216;
  --surface: #171b21;
  --surface-2: #1b2027;
  --surface-3: #242b34;
  --border: #2a313b;
  --border-strong: #3a434f;

  --text: #e8ecf1;
  --text-2: #b7c1cd;
  --text-3: #8a96a5;

  --accent: #6ea1f0;
  --accent-soft: rgba(110, 161, 240, 0.16);
  --accent-ink: #0b1220;

  --pos: #2fc96a;
  --pos-text: #63d88a;
  --pos-soft: rgba(47, 201, 106, 0.14);

  --near: #f0a72c;
  --near-text: #f3b64e;
  --near-soft: rgba(240, 167, 44, 0.14);

  --over: #f26d6d;
  --over-text: #ff8f8f;
  --over-soft: rgba(242, 109, 109, 0.14);

  --neutral: #9aa6b5;
  --neutral-soft: #242b34;

  --c1: #3987e5;
  --c2: #f27d46;
  --c3: #2cc48b;
  --c4: #f2b13c;
  --c5: #f28ab6;
  --c6: #7a6cd6;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);
}

body[data-theme="dark"] .week-context {
  background: rgba(110, 161, 240, 0.12);
  border-color: #2a3d5f;
}
body[data-theme="dark"] .toast { background: #262e38; color: #fff; }
body[data-theme="dark"] .chart-tip { background: #262e38; color: #fff; }
body[data-theme="dark"] .budget-marker { background: var(--text-2); }

/* ───────────────────────── responsive ───────────────────────── */

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 959px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .view { padding: 16px 16px 96px; }
  .bottomnav { display: flex; }
  .menu-btn { display: grid; place-items: center; border: none; background: none; cursor: pointer; padding: 6px; color: var(--text); }
  .menu-btn svg { width: 22px; height: 22px; }
  .page-title { font-size: 16px; }
  .topbar { padding: 0 14px; gap: 8px; }
  .grid-3 { grid-template-columns: 1fr; }
  .pattern-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .form-row { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-value { font-size: 20px; }
  .hero { font-size: 34px; }
  .detail-grid { grid-template-columns: 1fr; }
  .cat-edit-head { display: none; }
  .cat-edit-row { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .cat-edit-row .cat-name-cell { grid-column: 1 / -1; }
  .cat-edit-total { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .cat-edit-total > span:first-child { grid-column: 1 / -1; }
  .period-pop { width: 258px; }
  .period-label-inline { display: none; }
  .budget-nums { font-size: 12.5px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ───────────────────────── impulse control ───────────────────────── */

.tab-bar {
  display: inline-flex;
  background: var(--surface-3);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: none;
  padding: 7px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
}
.tab-btn:hover {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow);
}
.tab-btn.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow);
}
.tab-btn svg {
  width: 16px;
  height: 16px;
}

/* ───────────────────────── product UI refresh ───────────────────────── */

:root {
  --bg: #f3f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --surface-3: #eef2f5;
  --border: #dce3e8;
  --border-strong: #c6d0d8;
  --text: #16212b;
  --text-2: #53616e;
  --text-3: #7b8995;
  --accent: #1769aa;
  --accent-soft: #e4f0fb;
  --accent-ink: #ffffff;
  --pos: #16845b;
  --pos-text: #14734f;
  --pos-soft: #e3f5ed;
  --near: #c27813;
  --near-text: #a7610b;
  --near-soft: #fff3dd;
  --over: #d05252;
  --over-text: #b64040;
  --over-soft: #fde9e9;
  --neutral: #667684;
  --neutral-soft: #edf1f4;
  --shadow: 0 1px 2px rgba(22, 33, 43, .04), 0 8px 24px rgba(22, 33, 43, .05);
  --shadow-lg: 0 18px 44px rgba(22, 33, 43, .16);
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Aptos", "Trebuchet MS", sans-serif;
  --sidebar-w: 248px;
  --topbar-h: 72px;
}

body {
  background: var(--bg);
  font-size: 14px;
  color: var(--text);
}

.app { background: var(--bg); }
.main { margin-left: var(--sidebar-w); min-width: 0; }
.view {
  max-width: 1420px;
  padding: 32px 40px 72px;
  min-width: 0;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 16px 18px;
}
.brand { padding: 0 10px 28px; gap: 11px; }
/* brand-logo v2 styles moved to logo.css */
.brand-name { font-size: 15px; letter-spacing: .01em; }
.brand-sub { font-size: 11px; }
.nav { gap: 4px; }
.nav-group-label { padding: 16px 12px 7px; font-size: 10px; letter-spacing: .12em; }
.nav-item { min-height: 42px; padding: 10px 12px; border-radius: 9px; gap: 12px; }
.nav-item.active { box-shadow: inset 3px 0 var(--accent); }
.sidebar-footer { padding: 18px 8px 4px; }
.quick-add-btn { min-height: 42px; border-radius: 9px; }

.topbar {
  height: var(--topbar-h);
  padding: 0 40px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border-bottom-color: var(--border);
}
.page-title { font-size: 20px; letter-spacing: -.02em; }
.theme-toggle, .period-btn { border-radius: 9px; box-shadow: none; }
.period-btn { min-height: 42px; padding: 9px 13px; }

.stack { gap: 20px; }
.grid { gap: 20px; }
.grid > *, .stat-grid > *, .stack > * { min-width: 0; }
.card, .stat, .entry, .insight {
  border-radius: var(--radius);
  border-color: var(--border);
  box-shadow: var(--shadow);
}
.card { padding: 24px; }
.card-head { margin-bottom: 18px; }
.card-title { font-size: 16px; letter-spacing: -.01em; }
.card-sub { font-size: 12.5px; }
.stat { padding: 18px 20px; }
.stat-value, .stat-delta { overflow-wrap: anywhere; }
.stat-label, .budget-k { font-size: 10.5px; letter-spacing: .1em; }
.stat-value, .budget-v { letter-spacing: -.035em; }
.hero { font-size: 42px; }
.stat-grid { gap: 16px; }

.btn { min-height: 38px; border-radius: 8px; padding: 9px 14px; }
.btn-lg { min-height: 48px; border-radius: 9px; }
.btn-primary, .quick-add-btn { background: var(--accent); }
.input, .textarea, .select { border-radius: 8px; background: var(--surface-2); }
.input:focus, .textarea:focus, .select:focus { box-shadow: 0 0 0 3px var(--accent-soft); }
.empty { border-radius: var(--radius); padding: 48px 24px; }
.empty .ic { border-radius: 10px; }

.week-context {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
  border-radius: var(--radius); padding: 16px 18px;
}
.budget-track { height: 11px; border-radius: 4px; }
.budget-fill { border-radius: 4px; }
.fab { width: 52px; height: 52px; right: 28px; bottom: 28px; box-shadow: 0 10px 24px rgba(23, 105, 170, .3); }
.qa-pop, .period-pop, .modal { border-radius: 12px; }

body[data-theme="dark"] {
  --bg: #0c1116;
  --surface: #151c23;
  --surface-2: #19222b;
  --surface-3: #202b35;
  --border: #293641;
  --border-strong: #3a4a57;
  --text: #edf3f7;
  --text-2: #afbec9;
  --text-3: #7f919e;
  --accent: #68a8ed;
  --accent-soft: rgba(104, 168, 237, .15);
  --accent-ink: #07111b;
  --pos: #39c889;
  --pos-text: #65d99f;
  --pos-soft: rgba(57, 200, 137, .13);
  --near: #e8a83f;
  --near-text: #f0bc63;
  --near-soft: rgba(232, 168, 63, .14);
  --over: #ef7777;
  --over-text: #ff9696;
  --over-soft: rgba(239, 119, 119, .14);
  --neutral: #9babb8;
  --neutral-soft: #202b35;
  --shadow: 0 1px 2px rgba(0, 0, 0, .38), 0 10px 26px rgba(0, 0, 0, .14);
  --shadow-lg: 0 18px 44px rgba(0, 0, 0, .5);
}
body[data-theme="dark"] .sidebar { background: #10171d; }
body[data-theme="dark"] .topbar { background: color-mix(in srgb, var(--bg) 92%, transparent); }
body[data-theme="dark"] .btn-primary, body[data-theme="dark"] .quick-add-btn { color: #07111b; }

@media (max-width: 959px) {
  .main { margin-left: 0; }
  .view { padding: 24px 20px 96px; }
  .topbar { padding: 0 20px; }
}
@media (max-width: 620px) {
  .view { padding: 20px 14px 92px; }
  .topbar { height: 64px; padding: 0 14px; }
  .period-wrap { max-width: 124px; }
  .period-btn { max-width: 124px; overflow: hidden; white-space: nowrap; }
  .card { padding: 18px; }
  .hero { font-size: 34px; }
  .fab { right: 18px; bottom: 76px; }
}
.tab-btn .badge {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
}
.tab-btn.active .badge {
  background: var(--accent);
  color: #fff;
}

.impulse-list {
  animation: page-in 0.2s ease;
}

/* ═══════════════════════════════════════════════════════════════
   IMPULSE CONTROL — Complete Redesign
   ═══════════════════════════════════════════════════════════════ */

/* Page container */
.impulse-page {
  max-width: 880px;
  gap: 12px !important;
}

/* ── Hero header card ── */
.ic-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--shadow);
}
.ic-hero-text h2 {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 0 0 2px 0;
  line-height: 1.3;
}
.ic-hero-text h2 svg {
  display: none;
}
.ic-hero-text p {
  font-size: 13px;
  color: var(--text-3);
  line-height: 1.4;
  margin: 0;
}
.ic-hero .btn {
  flex: none;
  padding: 8px 16px;
  font-size: 13px;
  min-height: auto;
}

/* ── Summary stats strip ── */
.ic-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.ic-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  text-align: center;
  transition: border-color 0.15s;
}
.ic-stat:hover {
  border-color: var(--accent);
}
.ic-stat .ic-stat-val {
  font-size: 20px;
  font-weight: 750;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.2;
}
.ic-stat .ic-stat-lbl {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
}
.ic-stat.accent .ic-stat-val { color: var(--accent); }
.ic-stat.pos .ic-stat-val { color: var(--pos-text); }
.ic-stat.warn .ic-stat-val { color: var(--near-text); }

/* ── Tab bar ── */
.ic-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.ic-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.ic-tab:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.ic-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.ic-tab.active .ic-tab-badge {
  background: rgba(255,255,255,0.25);
  color: inherit;
}
.ic-tab svg {
  width: 14px;
  height: 14px;
}
.ic-tab-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-3);
}

/* ── List section ── */
.list-section {
  margin-bottom: 20px;
}

/* ── Section header ── */
.ic-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.ic-section-title {
  font-size: 14px;
  font-weight: 650;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 8px;
}
.ic-section-title .badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

/* ── List container ── */
.ic-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Item card — horizontal layout ── */
.ic-item {
  display: flex;
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-height: 0;
}
.ic-item:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  box-shadow: var(--shadow);
}
.ic-item.resolved {
  opacity: 0.55;
}

/* Left accent strip */
.ic-item-strip {
  width: 4px;
  flex: none;
  background: var(--accent);
}
.ic-item.resolved .ic-item-strip {
  background: var(--text-3);
}

/* Days counter */
.ic-item-days {
  width: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 6px;
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  flex: none;
}
.ic-item-days .n {
  font-size: 18px;
  font-weight: 750;
  line-height: 1;
  color: var(--text);
}
.ic-item-days .l {
  font-size: 8px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
  text-align: center;
  line-height: 1.2;
}

/* Main content area */
.ic-item-body {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
}
.ic-item-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ic-item-name {
  font-weight: 600;
  font-size: 14.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.ic-item-meta {
  font-size: 12px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.ic-item-meta .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-3);
  flex: none;
}

/* Right actions area */
.ic-item-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  border-left: 1px solid var(--border);
  flex: none;
}
.ic-item-actions .btn {
  padding: 5px 7px;
  font-size: 11px;
  border-radius: 5px;
  min-height: auto;
}
.ic-item-actions .btn svg {
  width: 13px;
  height: 13px;
}

/* ── Status chips ── */
.ic-chip {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex: none;
}
.ic-chip-waiting {
  background: var(--neutral-soft);
  color: var(--neutral);
}
.ic-chip-bought {
  background: var(--accent-soft);
  color: var(--accent);
}
.ic-chip-skipped {
  background: var(--pos-soft);
  color: var(--pos-text);
}
.ic-chip-eligible {
  background: var(--near-soft);
  color: var(--near-text);
}

/* ── Empty state ── */
.ic-empty {
  text-align: center;
  padding: 32px 24px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.ic-empty svg {
  width: 28px;
  height: 28px;
  color: var(--text-3);
  margin-bottom: 10px;
}
.ic-empty-title {
  font-weight: 650;
  font-size: 13.5px;
  color: var(--text);
  margin-bottom: 3px;
}
.ic-empty-body {
  font-size: 12.5px;
  color: var(--text-3);
  max-width: 320px;
  margin: 0 auto;
  line-height: 1.4;
}

/* ── 30-Day section divider ── */
.ic-section-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 12px 0 8px;
}
.ic-section-divider::before,
.ic-section-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.ic-section-divider span {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

/* form card styles moved to impulse.css */

/* ── Footer links ── */
.ic-footer {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 4px;
}
.ic-footer .btn {
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 12.5px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .ic-hero {
    flex-direction: column;
    align-items: stretch;
    padding: 16px 18px;
    gap: 12px;
  }
  .ic-hero .btn {
    width: 100%;
  }
  .ic-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 620px) {
  .ic-item {
    flex-wrap: wrap;
  }
  .ic-item-strip {
    width: 100%;
    height: 3px;
  }
  .ic-item-days {
    width: auto;
    flex-direction: row;
    gap: 6px;
    padding: 8px 14px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .ic-item-actions {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
    justify-content: flex-end;
    padding: 8px 12px;
  }
  .ic-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
  }
}



/* ── Backward-compat classes for purchases/discards pages ── */
.status-chip { font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.04em; flex: none; }
.sc-waiting { background: var(--neutral-soft); color: var(--neutral); }
.sc-eligible { background: var(--pos-soft); color: var(--pos-text); }
.sc-bought { background: var(--accent-soft); color: var(--accent); }
.sc-skipped { background: var(--surface-3); color: var(--text-3); }
.list-badge { font-size: 10.5px; font-weight: 600; padding: 1px 6px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.03em; flex: none; }
.chip { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); margin-right: 4px; }

/* old purchase/discard styles moved to ledger.css */

.modal-form {
  max-width: 460px;
}
.modal-header {
  margin-bottom: 16px;
}
.modal-header h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
}
.modal-header .muted {
  margin-top: 6px;
  font-size: 13.5px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

@media (max-width: 620px) {
  .impulse-grid,
  .purchase-grid,
  .discard-grid {
    grid-template-columns: 1fr;
  }
  .tab-bar {
    gap: 1px;
  }
  .tab-btn {
    padding: 7px 10px;
    font-size: 12.5px;
  }
}



/* Full-canvas page composition: page views own the available width; only
   individual controls and forms stay intentionally compact. */
#view > .stack {
  width: 100%;
  max-width: none !important;
}
#view > .stack > .form-card,
#view > .stack > .card.form-card {
  max-width: 100%;
}
#view > .stack > .grid.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}
#view > .stack > .week-context {
  max-width: 820px;
}
#view > .stack > #recent,
#view > .stack > #monthsList {
  max-width: 100%;
}
.view > .stack > .card:first-child,
.view > .stack > .form-card {
  border-top: 2px solid color-mix(in srgb, var(--accent) 68%, var(--border));
}
.view > .stack > .empty {
  min-height: 180px;
  display: grid;
  place-content: center;
}

@media (max-width: 959px) {
  #view > .stack > .grid.grid-2 { grid-template-columns: 1fr; }
}

/* ───────────────────────── ledger composition ───────────────────────── */

body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: 3px;
  background: var(--accent);
  z-index: 100;
  pointer-events: none;
}
.topbar { border-bottom-color: color-mix(in srgb, var(--accent) 18%, var(--border)); }
.dashboard-page { gap: 24px; }
.dashboard-heading { padding: 4px 2px 0; }
.dashboard-heading-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.dashboard-heading-row h2 { font-size: clamp(26px, 3vw, 36px) !important; letter-spacing: -.045em; }
.dashboard-kicker {
  display: inline-flex; align-items: center; min-height: 24px; padding: 3px 9px;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
  border-radius: 999px; color: var(--accent); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .11em;
}
.dashboard-hero > .card {
  position: relative; overflow: hidden;
  background: linear-gradient(125deg, var(--surface) 0%, color-mix(in srgb, var(--surface) 78%, var(--accent-soft)) 100%);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  box-shadow: 0 14px 34px color-mix(in srgb, var(--accent) 10%, transparent);
}
.dashboard-hero > .card::after {
  content: ""; position: absolute; width: 220px; height: 220px; right: -80px; top: -100px;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-radius: 50%; pointer-events: none;
}
.dashboard-hero .card-head, .dashboard-hero .card > * { position: relative; z-index: 1; }
.dashboard-hero .budget-v { font-size: 28px; }
.dashboard-kpis { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.dashboard-kpis .stat { min-height: 126px; display: flex; flex-direction: column; justify-content: center; }
.dashboard-kpis .stat:first-child { border-left: 3px solid var(--accent); }
.dashboard-kpis .stat:nth-child(2) { border-left: 3px solid var(--over); }
.dashboard-page > .grid > .card { min-height: 260px; }
.dashboard-page > .grid > .card .empty { min-height: 124px; }
.dashboard-page > .grid > .card .card-head { padding-bottom: 14px; border-bottom: 1px solid var(--border); }

body[data-theme="dark"] {
  --bg: #0a1015;
  --surface: #121b23;
  --surface-2: #17232d;
  --surface-3: #1d2a35;
  --border: #2a3a46;
  --border-strong: #405361;
  --accent: #7dc4ff;
  --accent-soft: rgba(125, 196, 255, .14);
}
body[data-theme="dark"] .dashboard-hero > .card {
  background: linear-gradient(125deg, #15232d 0%, #132b35 100%);
}

@media (max-width: 620px) {
  .dashboard-page { gap: 18px; }
  .dashboard-heading-row h2 { font-size: 28px !important; }
  .dashboard-kicker { font-size: 9px; }
  .dashboard-kpis { grid-template-columns: 1fr; }
  .dashboard-page > .grid > .card { min-height: 0; }
}
