/* =====================================================================
   Expense Command Center — style.css
   One accent (electric indigo). Green = sync. Red = delete/error only.
   ===================================================================== */

:root {
  /* Brand accent */
  --accent: #5546ff;
  --accent-ink: #ffffff;
  --accent-soft: rgba(85, 70, 255, .10);
  --accent-soft-2: rgba(85, 70, 255, .16);

  /* Status */
  --ok: #12a150;
  --ok-soft: rgba(18, 161, 80, .12);
  --warn: #b7791f;
  --warn-soft: rgba(183, 121, 31, .14);
  --danger: #e5484d;
  --danger-soft: rgba(229, 72, 77, .12);

  /* Radii / shadow / motion */
  --r-xs: 10px;
  --r-sm: 14px;
  --r-md: 18px;
  --r-lg: 24px;
  --r-xl: 30px;
  --ease: cubic-bezier(.22, .61, .36, 1);
  --dur: .28s;

  --sidebar-w: 264px;
}

/* ---- Light theme (default) ---- */
:root, [data-theme="light"] {
  --bg: #f4f4f2;
  --bg-2: #eeeeec;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --ink: #17181d;
  --ink-2: #565863;
  --ink-3: #8b8d99;
  --line: #e7e7e4;
  --line-2: #ededea;
  --shadow-sm: 0 1px 2px rgba(20, 22, 30, .04), 0 1px 3px rgba(20, 22, 30, .06);
  --shadow-md: 0 8px 26px rgba(20, 22, 30, .08);
  --shadow-lg: 0 24px 60px rgba(20, 22, 30, .16);
  --hero-bg: #17181d;
  --hero-ink: #f6f6f5;
  --hero-ink-2: #a6a7b0;
  color-scheme: light;
}

/* ---- Dark theme ---- */
[data-theme="dark"] {
  --bg: #0d0e12;
  --bg-2: #101116;
  --surface: #17181e;
  --surface-2: #1c1d25;
  --ink: #f3f3f5;
  --ink-2: #a7a9b4;
  --ink-3: #71737f;
  --line: #26272f;
  --line-2: #23242b;
  --accent-soft: rgba(120, 108, 255, .16);
  --accent-soft-2: rgba(120, 108, 255, .24);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, .45);
  --shadow-lg: 0 28px 70px rgba(0, 0, 0, .6);
  --hero-bg: #1e1f28;
  --hero-ink: #f6f6f7;
  --hero-ink-2: #9d9fab;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.money { font-family: "Space Grotesk", "Plus Jakarta Sans", sans-serif; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
::selection { background: var(--accent-soft-2); }

/* =========================== SHELL =========================== */
.app { min-height: 100dvh; display: grid; grid-template-columns: var(--sidebar-w) 1fr; }

.sidebar {
  position: sticky; top: 0; height: 100dvh;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 20px 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 18px; }
.brand__mark {
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 800; font-size: 22px;
  font-family: "Space Grotesk", sans-serif;
  box-shadow: 0 6px 16px var(--accent-soft-2);
}
.brand__text { display: flex; flex-direction: column; line-height: 1.2; }
.brand__name { font-weight: 700; font-size: 15px; }
.brand__sub { font-size: 11.5px; color: var(--ink-3); }

.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.nav__item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border: 0; background: transparent; border-radius: var(--r-sm);
  color: var(--ink-2); font-weight: 600; font-size: 14.5px; text-align: left; width: 100%;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav__item .ic { width: 20px; height: 20px; }
.nav__item:hover { background: var(--bg-2); color: var(--ink); }
.nav__item.is-active { background: var(--accent-soft); color: var(--accent); }
[data-theme="dark"] .nav__item.is-active { color: #b9b2ff; }

.btn-add {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: var(--r-sm); padding: 13px 18px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 15px;
  box-shadow: 0 10px 24px var(--accent-soft-2);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), filter var(--dur);
}
.btn-add:hover { filter: brightness(1.05); transform: translateY(-1px); box-shadow: 0 14px 30px var(--accent-soft-2); }
.btn-add:active { transform: translateY(0); }
.btn-add--rail { margin-top: auto; }
.plus { font-size: 18px; font-weight: 700; line-height: 1; }

.sidebar__foot { padding-top: 4px; }

.main { min-width: 0; display: flex; flex-direction: column; height: 100dvh; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 20px clamp(16px, 3vw, 34px) 14px;
}
.topbar__title { margin: 0; font-size: clamp(20px, 2.4vw, 26px); font-weight: 800; letter-spacing: -.02em; }
.topbar__sub { margin: 2px 0 0; color: var(--ink-3); font-size: 13px; }
.topbar__right { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 42px; height: 42px; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; color: var(--ink-2);
  transition: background var(--dur), color var(--dur), transform var(--dur);
}
.icon-btn:hover { background: var(--bg-2); color: var(--ink); }
.icon-btn:active { transform: scale(.95); }
.ic-moon { display: none; }
[data-theme="dark"] .ic-sun { display: none; }
[data-theme="dark"] .ic-moon { display: block; }

.scroll { flex: 1; overflow-y: auto; padding: 8px clamp(16px, 3vw, 34px) 120px; scroll-behavior: smooth; }

/* Sync chip */
.sync-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 13px;
  border-radius: 100px; background: var(--surface); border: 1px solid var(--line);
  font-size: 12.5px; font-weight: 600; color: var(--ink-2);
}
.sync-chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-3); }
.sync-chip[data-status="synced"] { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.sync-chip[data-status="synced"] .dot { background: var(--ok); }
.sync-chip[data-status="syncing"] { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.sync-chip[data-status="syncing"] .dot { background: var(--accent); animation: pulse 1s infinite; }
.sync-chip[data-status="pending"] { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.sync-chip[data-status="pending"] .dot { background: var(--warn); }
.sync-chip[data-status="offline"] { color: var(--ink-2); }
.sync-chip[data-status="offline"] .dot { background: var(--ink-3); }
.sync-chip[data-status="error"] { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.sync-chip[data-status="error"] .dot { background: var(--danger); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* =========================== VIEWS =========================== */
.view { display: none; animation: fade .32s var(--ease); }
.view.is-active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- KPI grid ---- */
.hero-grid {
  display: grid; gap: 14px; margin-bottom: 16px;
  grid-template-columns: repeat(3, 1fr);
}
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 18px 18px 16px; display: flex; flex-direction: column; gap: 6px;
  box-shadow: var(--shadow-sm);
}
.kpi__label { font-size: 12.5px; color: var(--ink-3); font-weight: 600; }
.kpi__value { font-size: clamp(22px, 2.6vw, 30px); font-weight: 700; line-height: 1.05; }
.kpi__foot { font-size: 12px; color: var(--ink-3); display: inline-flex; align-items: center; gap: 8px; }
.dot-sep { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .5; }

/* Hero KPI — distinct dark treatment (not the same card kit) */
.kpi--hero {
  grid-column: span 3; grid-row: span 1;
  background: var(--hero-bg); border-color: transparent; color: var(--hero-ink);
  padding: 24px 24px 8px; position: relative; overflow: hidden; box-shadow: var(--shadow-md);
}
.kpi--hero::after {
  content: ""; position: absolute; right: -40px; top: -60px; width: 220px; height: 220px;
  background: radial-gradient(circle, var(--accent-soft-2), transparent 70%); pointer-events: none;
}
.kpi--hero .kpi__label { color: var(--hero-ink-2); }
.kpi--hero .kpi__value { font-size: clamp(38px, 6vw, 58px); margin: 4px 0 2px; }
.kpi--hero .kpi__foot { color: var(--hero-ink-2); }
.kpi__top { display: flex; align-items: center; justify-content: space-between; }
.kpi__badge {
  font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 100px;
  background: rgba(255,255,255,.1); color: var(--hero-ink);
}
.kpi__badge.up { color: #ff9ba0; background: rgba(229,72,77,.16); }
.kpi__badge.down { color: #8ce0ad; background: rgba(18,161,80,.18); }
.sparkline { height: 62px; margin-top: 8px; }
.sparkline canvas { width: 100% !important; height: 100% !important; }

/* ---- Panels ---- */
.panel-grid { display: grid; gap: 14px; grid-template-columns: 2fr 1fr; margin-bottom: 16px; }
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 18px 18px 20px; box-shadow: var(--shadow-sm); margin-bottom: 16px;
}
.panel--wide { margin-bottom: 0; }
.panel-grid .panel { margin-bottom: 0; }
.panel__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; }
.panel__title { margin: 0; font-size: 15.5px; font-weight: 700; letter-spacing: -.01em; }
.chart-wrap { position: relative; height: 260px; }
.chart-wrap--donut { height: 240px; }
.link { border: 0; background: transparent; color: var(--accent); font-weight: 600; font-size: 13.5px; }
.link:hover { text-decoration: underline; }

/* Segmented control */
.seg { display: inline-flex; background: var(--bg-2); border-radius: 100px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: transparent; color: var(--ink-2); font-weight: 600; font-size: 12.5px;
  padding: 6px 13px; border-radius: 100px; transition: background var(--dur), color var(--dur);
}
.seg button.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.seg--wide { display: grid; grid-auto-flow: column; width: 100%; }

/* ---- Recent activity ---- */
.recent { display: flex; flex-direction: column; }
.recent__row {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px;
  padding: 13px 4px; border-bottom: 1px solid var(--line-2);
}
.recent__row:last-child { border-bottom: 0; }
.avatar {
  width: 40px; height: 40px; border-radius: 12px; flex: none; display: grid; place-items: center;
  font-weight: 700; font-size: 15px; background: var(--accent-soft); color: var(--accent);
}
[data-theme="dark"] .avatar { color: #b9b2ff; }
.recent__meta { min-width: 0; }
.recent__name { font-weight: 600; font-size: 14px; }
.recent__sub { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent__amt { font-weight: 700; font-size: 15px; text-align: right; }

/* =========================== EXPENSES =========================== */
.filters { margin-bottom: 16px; display: flex; flex-direction: column; gap: 12px; }
.search {
  display: flex; align-items: center; gap: 10px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 0 14px; box-shadow: var(--shadow-sm);
}
.search .ic { color: var(--ink-3); width: 20px; height: 20px; }
.search input { flex: 1; border: 0; background: transparent; color: var(--ink); padding: 13px 0; font-size: 14.5px; outline: none; }
.filters__row { display: flex; flex-wrap: wrap; gap: 8px; }
.field-sm {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xs);
  padding: 9px 11px; color: var(--ink); font-size: 13px; outline: none; min-width: 0;
}
.field-sm:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field-num { width: 96px; }
.filters__foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.btn-ghost {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  padding: 9px 14px; border-radius: var(--r-xs); font-weight: 600; font-size: 13px;
  transition: background var(--dur), color var(--dur);
}
.btn-ghost:hover { background: var(--bg-2); color: var(--ink); }
.muted { color: var(--ink-3); font-size: 13px; }

/* Timeline */
.timeline { display: flex; flex-direction: column; gap: 22px; }
.timeline__day { position: relative; }
.timeline__date {
  display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13px;
  color: var(--ink-2); margin-bottom: 10px;
}
.timeline__date .tot { color: var(--ink-3); font-weight: 600; }
.exp-card {
  display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 14px 16px; box-shadow: var(--shadow-sm); margin-bottom: 10px;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.exp-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.exp-card__body { min-width: 0; }
.exp-card__title { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tag {
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 100px;
  background: var(--bg-2); color: var(--ink-2);
}
.exp-card__sub { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.exp-card__amt { font-weight: 700; font-size: 17px; }
.exp-card__side { display: flex; align-items: center; gap: 6px; }
.mini-sync { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-3); flex: none; }
.mini-sync[data-s="synced"] { background: var(--ok); }
.mini-sync[data-s="pending"] { background: var(--warn); }
.mini-sync[data-s="syncing"] { background: var(--accent); }
.mini-sync[data-s="error"] { background: var(--danger); }
.ib { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); }
.ib:hover { background: var(--bg-2); color: var(--ink); }
.ib .ic { width: 17px; height: 17px; }
.ib--danger:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.ib--receipt.has:hover { color: var(--accent); border-color: var(--accent); }

/* Table view */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; box-shadow: var(--shadow-sm); }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th, table.data td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
table.data th { font-size: 11.5px; color: var(--ink-3); font-weight: 700; text-transform: none; background: var(--surface-2); }
table.data td.num { text-align: right; font-family: "Space Grotesk"; font-variant-numeric: tabular-nums; font-weight: 600; }
table.data tr:hover td { background: var(--bg-2); }
.row-actions { display: flex; gap: 6px; }

.empty { text-align: center; padding: 60px 20px; color: var(--ink-3); }
.empty__art { font-size: 54px; font-weight: 800; color: var(--accent-soft-2); font-family: "Space Grotesk"; }
.empty p { margin: 8px 0 18px; }

/* =========================== REPORTS =========================== */
.report-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.report-controls .seg { flex-wrap: wrap; }
.report-controls__custom { display: flex; align-items: center; gap: 8px; }
.analytics-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.acard {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 15px 16px; box-shadow: var(--shadow-sm);
}
.acard__label { font-size: 11.5px; color: var(--ink-3); font-weight: 600; display: flex; align-items: center; gap: 7px; }
.acard__value { font-size: 20px; font-weight: 700; margin-top: 6px; }
.acard__value.money { }
.acard__meta { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }

/* =========================== DOWNLOAD =========================== */
.dl-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, 1fr); }
.dl-range { grid-template-columns: 1fr 1fr; display: grid; gap: 12px; }
.dl-summary {
  display: flex; gap: 30px; margin: 18px 0; padding: 16px 18px;
  background: var(--bg-2); border-radius: var(--r-sm);
}
.dl-summary > div { display: flex; flex-direction: column; gap: 3px; }
.dl-summary strong { font-size: 22px; font-weight: 700; }
.dl-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-outline {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); padding: 12px 18px; border-radius: var(--r-sm);
  font-weight: 600; font-size: 14px; transition: background var(--dur), border-color var(--dur), transform var(--dur);
}
.btn-outline:hover { background: var(--bg-2); border-color: var(--accent); }
.btn-outline:active { transform: scale(.98); }
.btn-outline .ic { width: 18px; height: 18px; color: var(--accent); }

/* =========================== SETTINGS =========================== */
.panel--form { max-width: 760px; }
.conn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 6px 0 18px; }
.conn { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--bg-2); border-radius: var(--r-sm); }
.conn .dot { width: 11px; height: 11px; border-radius: 50%; background: var(--ink-3); flex: none; }
.conn[data-ok="1"] .dot { background: var(--ok); }
.conn[data-ok="0"] .dot { background: var(--danger); }
.conn strong { display: block; font-size: 14px; }
.conn small { color: var(--ink-3); font-size: 12px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.settings-row small { display: block; }
.btn-danger-ghost {
  border: 1px solid var(--danger); background: transparent; color: var(--danger);
  padding: 10px 16px; border-radius: var(--r-xs); font-weight: 600; font-size: 13px;
}
.btn-danger-ghost:hover { background: var(--danger-soft); }
.about { line-height: 1.6; }
.hint { font-size: 12px; color: var(--ink-3); margin: 8px 0 0; }

.btn-primary {
  border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 14px;
  padding: 12px 20px; border-radius: var(--r-sm); box-shadow: 0 8px 20px var(--accent-soft-2);
  transition: filter var(--dur), transform var(--dur);
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .6; cursor: default; }

/* =========================== FIELDS =========================== */
.field-group { display: flex; flex-direction: column; gap: 7px; }
.field-group--full { grid-column: 1 / -1; }
.lbl { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field {
  width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 12px 14px; color: var(--ink); font-size: 14.5px; outline: none;
  transition: border-color var(--dur), box-shadow var(--dur);
}
.field::placeholder { color: var(--ink-3); }
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.field { resize: vertical; min-height: 46px; }
.err { color: var(--danger); font-size: 12px; min-height: 0; }
.err:not(:empty) { min-height: 16px; }
.field.invalid, .amount-hero.invalid { border-color: var(--danger); }

/* =========================== ADD/EDIT SHEET =========================== */
.sheet { position: fixed; inset: 0; z-index: 60; display: none; }
.sheet.is-open { display: block; }
.sheet__scrim { position: absolute; inset: 0; background: rgba(10, 11, 16, .5); backdrop-filter: blur(3px); animation: fade .25s var(--ease); }
.sheet__panel {
  position: absolute; right: 0; top: 0; height: 100dvh; width: min(520px, 100%);
  background: var(--surface); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; padding: 8px 24px 24px;
  animation: slideIn .34s var(--ease); overflow-y: auto;
}
@keyframes slideIn { from { transform: translateX(30px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet__grab { display: none; }
.sheet__head { display: flex; align-items: center; justify-content: space-between; padding: 14px 0 8px; position: sticky; top: 0; background: var(--surface); z-index: 2; }
.sheet__head h2 { margin: 0; font-size: 19px; font-weight: 800; letter-spacing: -.01em; }

.eform { display: flex; flex-direction: column; gap: 6px; }
.amount-hero {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--bg-2); border: 1.5px solid var(--line); border-radius: var(--r-lg);
  padding: 22px 18px; margin: 12px 0 2px;
  transition: border-color var(--dur), box-shadow var(--dur);
}
.amount-hero:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.amount-hero__cur { font-family: "Space Grotesk"; font-size: 34px; font-weight: 600; color: var(--ink-3); }
.amount-hero__input {
  border: 0; background: transparent; outline: none; color: var(--ink);
  font-family: "Space Grotesk"; font-size: 46px; font-weight: 700; text-align: center;
  width: 100%; max-width: 320px; font-variant-numeric: tabular-nums;
}
.amount-hero__input::placeholder { color: var(--ink-3); }

.eform__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 8px; }

/* Combo (searchable dropdown) */
.combo { position: relative; }
.combo__menu {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 20;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
  box-shadow: var(--shadow-md); max-height: 240px; overflow-y: auto; padding: 6px; display: none;
}
.combo.is-open .combo__menu { display: block; }
.combo__opt {
  padding: 10px 12px; border-radius: var(--r-xs); font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.combo__opt:hover, .combo__opt.active { background: var(--accent-soft); color: var(--accent); }
[data-theme="dark"] .combo__opt:hover, [data-theme="dark"] .combo__opt.active { color: #b9b2ff; }
.combo__add { color: var(--accent); font-weight: 600; }
.combo__add .ic { width: 16px; height: 16px; }

/* Uploader */
.uploader__drop {
  border: 1.5px dashed var(--line); border-radius: var(--r-sm); padding: 20px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--ink-3);
  transition: border-color var(--dur), background var(--dur);
}
.uploader__drop.drag { border-color: var(--accent); background: var(--accent-soft); }
.uploader__drop .ic { width: 30px; height: 30px; }
.uploader__cta { display: flex; gap: 8px; }
.chip-btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 9px 15px; border-radius: 100px; font-weight: 600; font-size: 13px;
  transition: background var(--dur), border-color var(--dur);
}
.chip-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.chip-btn--cam { }
.chip-btn--danger { color: var(--danger); }
.chip-btn--danger:hover { border-color: var(--danger); background: var(--danger-soft); }
.uploader__hint { font-size: 11.5px; }
.uploader__preview { position: relative; border-radius: var(--r-sm); overflow: hidden; border: 1px solid var(--line); }
.uploader__preview img { width: 100%; max-height: 240px; object-fit: cover; display: block; }
.uploader__preview-actions { display: flex; gap: 8px; padding: 10px; background: var(--surface); }

.eform__foot { display: flex; gap: 10px; margin-top: 18px; position: sticky; bottom: 0; background: var(--surface); padding: 12px 0 4px; }
.eform__foot .btn-ghost { flex: none; }
.btn-save { flex: 1; padding: 15px; font-size: 15px; }
.btn-save.is-loading { pointer-events: none; }
.btn-save.is-loading .btn-save__label::after { content: "…"; }

/* =========================== LIGHTBOX / CONFIRM =========================== */
.lightbox { position: fixed; inset: 0; z-index: 80; background: rgba(8,9,13,.86); display: none; place-items: center; padding: 24px; animation: fade .2s; }
.lightbox.is-open { display: grid; }
.lightbox img { max-width: 92vw; max-height: 88vh; border-radius: var(--r-md); box-shadow: var(--shadow-lg); }

.confirm { position: fixed; inset: 0; z-index: 90; display: none; }
.confirm.is-open { display: grid; place-items: center; }
.confirm__scrim { position: absolute; inset: 0; background: rgba(10,11,16,.5); backdrop-filter: blur(2px); }
.confirm__box { position: relative; background: var(--surface); border-radius: var(--r-lg); padding: 24px; width: min(380px, 92vw); box-shadow: var(--shadow-lg); animation: pop .24s var(--ease); }
@keyframes pop { from { transform: scale(.94); opacity: .4; } to { transform: none; opacity: 1; } }
.confirm__box h3 { margin: 0 0 6px; font-size: 18px; }
.confirm__actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.btn-danger { border: 0; background: var(--danger); color: #fff; font-weight: 700; padding: 11px 18px; border-radius: var(--r-sm); }
.btn-danger:hover { filter: brightness(1.05); }

/* =========================== TOASTS =========================== */
.toasts { position: fixed; z-index: 100; bottom: 24px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 10px; align-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; background: var(--hero-bg); color: var(--hero-ink);
  padding: 13px 18px; border-radius: 100px; box-shadow: var(--shadow-lg); font-size: 13.5px; font-weight: 600;
  animation: toastIn .3s var(--ease); max-width: 90vw;
}
.toast .ic { width: 18px; height: 18px; flex: none; }
.toast--ok .ic { color: #8ce0ad; }
.toast--err .ic { color: #ff9ba0; }
.toast.out { animation: toastOut .3s var(--ease) forwards; }
@keyframes toastIn { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toastOut { to { transform: translateY(16px); opacity: 0; } }

/* =========================== BOTTOM NAV (mobile) =========================== */
.botnav { display: none; }

/* =========================== RESPONSIVE =========================== */
@media (max-width: 1100px) {
  .hero-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi--hero { grid-column: span 2; }
  .analytics-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 920px) {
  .panel-grid { grid-template-columns: 1fr; }
  .chart-wrap { height: 240px; }
}

@media (max-width: 780px) {
  :root { --sidebar-w: 0px; }
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { height: auto; min-height: 100dvh; }
  .scroll { height: auto; overflow: visible; padding: 4px 16px 120px; }
  .topbar { padding: 16px 16px 10px; position: sticky; top: 0; background: var(--bg); z-index: 30; }
  .topbar__sub { display: none; }

  .hero-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi--hero { grid-column: span 2; }
  .dl-grid { grid-template-columns: 1fr; }
  .conn-grid { grid-template-columns: 1fr; }
  .filters__foot { flex-direction: column; align-items: stretch; gap: 10px; }
  .filters__foot .seg { justify-content: center; }

  /* Bottom nav */
  .botnav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    justify-content: space-around; align-items: center; box-shadow: 0 -6px 24px rgba(0,0,0,.06);
  }
  .botnav__item {
    border: 0; background: transparent; color: var(--ink-3); display: flex; flex-direction: column;
    align-items: center; gap: 3px; font-size: 10.5px; font-weight: 600; padding: 4px 10px; border-radius: 12px;
    flex: 1; transition: color var(--dur);
  }
  .botnav__item .ic { width: 22px; height: 22px; }
  .botnav__item.is-active { color: var(--accent); }
  .botnav__add {
    border: 0; width: 58px; height: 58px; margin-top: -26px; border-radius: 20px; flex: none;
    background: var(--accent); color: var(--accent-ink); font-size: 30px; font-weight: 400;
    display: grid; place-items: center; box-shadow: 0 12px 26px var(--accent-soft-2);
    transition: transform var(--dur);
  }
  .botnav__add:active { transform: scale(.92); }
  .botnav__add .plus { font-size: 30px; }

  /* Bottom-sheet form on mobile */
  .sheet__panel {
    right: 0; left: 0; top: auto; bottom: 0; width: 100%; height: auto; max-height: 92dvh;
    border-radius: var(--r-xl) var(--r-xl) 0 0; padding: 4px 18px calc(18px + env(safe-area-inset-bottom));
    animation: sheetUp .34s var(--ease);
  }
  @keyframes sheetUp { from { transform: translateY(40px); opacity: .5; } to { transform: none; opacity: 1; } }
  .sheet__grab { display: block; width: 42px; height: 5px; border-radius: 100px; background: var(--line); margin: 10px auto 4px; }
  .eform__grid { grid-template-columns: 1fr; }
  .exp-card { grid-template-columns: auto 1fr; grid-template-areas: "av body" "side side"; row-gap: 10px; }
  .exp-card__amt { grid-area: none; }
  .exp-card__side { grid-area: side; justify-content: flex-end; }
}

@media (max-width: 420px) {
  .hero-grid { grid-template-columns: 1fr; }
  .kpi--hero { grid-column: 1; }
  .analytics-grid { grid-template-columns: 1fr 1fr; }
  .topbar__title { font-size: 20px; }
}

/* Accessibility */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
