/* ============================ fonts ============================ */
@font-face { font-family:'Inter'; font-style:normal; font-weight:400; font-display:swap; src:url('/fonts/inter-400.woff2') format('woff2'); }
@font-face { font-family:'Inter'; font-style:normal; font-weight:500; font-display:swap; src:url('/fonts/inter-500.woff2') format('woff2'); }
@font-face { font-family:'Inter'; font-style:normal; font-weight:600; font-display:swap; src:url('/fonts/inter-600.woff2') format('woff2'); }
@font-face { font-family:'Inter'; font-style:normal; font-weight:700; font-display:swap; src:url('/fonts/inter-700.woff2') format('woff2'); }

/* ============================ tokens ============================ */
:root {
  --bg:        #0f1115;
  --surface:   #171a21;
  --surface-2: #1d212a;
  --elevated:  #1f2430;
  --border:    #272c38;
  --border-soft:#20242e;

  --text:  #e8eaf0;
  --dim:   #9aa1b2;
  --faint: #666d7e;

  --accent:      #7aa2ff;
  --accent-ink:  #0b1020;
  --accent-weak: rgba(122,162,255,0.14);
  --danger:      #ff6b6b;

  --radius:  16px;
  --radius-sm: 11px;
  --shadow: 0 8px 30px rgba(0,0,0,0.45);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --sidebar-w: 244px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ============================ base ============================ */
* { box-sizing: border-box; }

/* The whole UI shows/hides sections and modals via the [hidden] attribute.
   Author display rules (grid/flex) below would otherwise defeat the UA
   [hidden]{display:none} rule and leave everything visible at once. */
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: var(--font);
  font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2b313d; border-radius: 20px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #3a414f; background-clip: padding-box; }

.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* ============================ app shell ============================ */
#app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh; height: 100dvh;
}

/* ---------- sidebar ---------- */
.sidebar {
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border-soft);
  padding: 18px 14px;
  gap: 6px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 8px 10px 18px; }
.brand-dot { width: 12px; height: 12px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #b39bff);
  box-shadow: 0 0 16px rgba(122,162,255,0.6); }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: -0.02em; }

.side-add {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; margin: 0 0 12px; padding: 11px; border: none; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--accent-ink); font-weight: 700; transition: filter .12s;
}
.side-add:hover { filter: brightness(1.06); }
.side-add svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }

.side-nav { display: flex; flex-direction: column; gap: 3px; }
.side-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border-soft); }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 11px 12px; border: none; background: none;
  color: var(--dim); border-radius: var(--radius-sm);
  font-weight: 500; text-align: left; transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-weak); color: var(--accent); }
.nav-item.active .ic { stroke: var(--accent); }

/* ---------- main ---------- */
.main { min-width: 0; overflow: hidden; display: flex; flex-direction: column; background: var(--bg); }
.view { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.view-head {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 20px 28px 16px; border-bottom: 1px solid var(--border-soft);
}
.view-title { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin: 0; }
.head-total { margin-left: auto; text-align: right; display: flex; flex-direction: column; }
.ht-label { font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; }
.ht-value { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }

.period-nav { display: flex; align-items: center; gap: 4px; }
.nav-arrow {
  background: none; border: none; color: var(--dim); font-size: 22px; line-height: 1;
  width: 34px; height: 34px; border-radius: 9px; transition: background .12s;
}
.nav-arrow:hover { background: var(--surface-2); color: var(--text); }
.period-label {
  background: none; border: none; color: var(--text); font-weight: 600;
  min-width: 130px; text-align: center; padding: 7px 12px; border-radius: 9px; transition: background .12s;
}
.period-label:hover { background: var(--surface-2); }

.segmented { display: inline-flex; background: var(--surface-2); border-radius: 11px; padding: 3px; gap: 2px; }
.segment {
  border: none; background: none; color: var(--dim); font-weight: 600; font-size: 13.5px;
  padding: 7px 15px; border-radius: 8px; transition: background .12s, color .12s;
}
.segment:hover { color: var(--text); }
.segment.active { background: var(--accent); color: var(--accent-ink); }

.scroll-area { flex: 1; overflow-y: auto; padding: 12px 0 40px; }
.empty-state { text-align: center; color: var(--faint); padding: 60px 20px; font-size: 14px; }

/* ============================ calendar ============================ */
.calendar-layout {
  flex: 1; min-height: 0; display: grid;
  grid-template-columns: minmax(0,1fr) 360px; gap: 0;
}
.calendar-pane { padding: 16px 24px 28px; overflow-y: auto; }
.cal-dow-row, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-dow-row { margin-bottom: 6px; }
.cal-dow { text-align: center; font-size: 11px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; padding: 6px 0; }
.cal-grid { gap: 6px; }

.cal-cell {
  position: relative; min-height: 84px;
  background: var(--surface); border: 1px solid transparent; border-radius: 12px;
  padding: 8px; text-align: left; display: flex; flex-direction: column; gap: 4px;
  transition: border-color .12s, background .12s;
}
.cal-cell:hover { border-color: var(--border); }
.cal-cell.blank { background: none; pointer-events: none; }
.cal-cell.today .cal-num { color: var(--accent); font-weight: 700; }
.cal-cell.today { border-color: rgba(122,162,255,0.4); }
.cal-cell.selected { border-color: var(--accent); background: var(--accent-weak); }
.cal-num { font-size: 13px; color: var(--dim); font-weight: 500; }
.cal-amt { margin-top: auto; font-size: 12.5px; font-weight: 600; color: var(--text); }
.cal-count { font-size: 10.5px; color: var(--faint); }

/* day pane */
.day-pane {
  border-left: 1px solid var(--border-soft); background: var(--surface);
  display: flex; flex-direction: column; min-height: 0; overflow-y: auto;
}
.day-pane-head { padding: 20px 22px 14px; border-bottom: 1px solid var(--border-soft); }
.day-pane-date { font-size: 17px; font-weight: 700; }
.day-pane-total { font-size: 13px; color: var(--dim); margin-top: 2px; }
.day-pane-list { flex: 1; }
.day-pane-foot { padding: 14px 18px calc(18px + var(--safe-bottom)); border-top: 1px solid var(--border-soft); }

.add-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px; border-radius: 12px; border: 1px dashed var(--border);
  background: var(--surface-2); color: var(--accent); font-weight: 600; transition: background .12s;
}
.add-btn:hover { background: var(--elevated); }
.add-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

/* ============================ transaction rows ============================ */
.day-group { margin-bottom: 6px; }
.day-header {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 14px 28px 6px; font-size: 12.5px; color: var(--faint); font-weight: 600;
}
.day-header .dh-total { color: var(--dim); }
.day-pane-list .day-header { padding-left: 22px; padding-right: 22px; }

.tx-row {
  display: flex; align-items: center; gap: 13px; padding: 11px 28px; width: 100%;
  background: none; border: none; text-align: left; transition: background .1s;
}
.day-pane-list .tx-row { padding-left: 22px; padding-right: 22px; }
.tx-row:hover { background: var(--surface); }
.tx-emoji {
  width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 19px;
}
.tx-main { flex: 1; min-width: 0; }
.tx-cat { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-note { font-size: 12.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-amount { font-weight: 700; font-size: 14.5px; white-space: nowrap; letter-spacing: -0.01em; }

/* ============================ search ============================ */
.search-bar { display: flex; align-items: center; gap: 10px; padding: 12px 28px 4px; }
.search-ic { color: var(--faint); }
#list-search {
  flex: 1; background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: 11px; padding: 10px 14px; outline: none; transition: border-color .12s;
}
#list-search:focus { border-color: var(--accent); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px;
  background: var(--accent-weak); color: var(--accent); border: none; border-radius: 20px;
  font-size: 12.5px; font-weight: 600;
}

/* ============================ stats ============================ */
.stats-wrap { max-width: 860px; margin: 0 auto; padding: 8px 24px; }
.stats-total-card {
  background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: 22px 24px; margin-bottom: 20px; text-align: center;
}
.stats-total-card .stc-label { font-size: 12px; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; }
.stats-total-card .stc-value { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; }
.stats-total-card .stc-sub { font-size: 13px; color: var(--dim); margin-top: 4px; }

.stats-grid { display: grid; grid-template-columns: 260px 1fr; gap: 26px; align-items: start; }
.pie-card { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.pie-wrap { position: relative; width: 220px; height: 220px; }
.pie-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.pie-center .pc-label { font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; }
.pie-center .pc-value { font-size: 20px; font-weight: 700; }

.breakdown { display: flex; flex-direction: column; }
.bd-row {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  padding: 12px 6px; border-bottom: 1px solid var(--border-soft); width: 100%;
  background: none; border-left: none; border-right: none; border-top: none; text-align: left; transition: background .1s;
}
.bd-row:hover { background: var(--surface); }
.bd-emoji { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 16px; }
.bd-mid { min-width: 0; }
.bd-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bd-bar { height: 5px; border-radius: 3px; background: var(--surface-2); margin-top: 6px; overflow: hidden; }
.bd-bar > i { display: block; height: 100%; border-radius: 3px; }
.bd-right { text-align: right; }
.bd-amt { font-weight: 700; font-size: 14px; }
.bd-pct { font-size: 11.5px; color: var(--faint); }

/* ============================ stats: year-by-month trend ============================ */
.trend-card {
  background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: 24px 18px 10px;
}
.trend-chart { display: flex; align-items: flex-end; gap: 6px; height: 210px; }
.trend-bar-col {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  height: 100%; background: none; border: none; padding: 0; cursor: pointer; border-radius: 8px 8px 0 0;
  transition: background .1s;
}
.trend-bar-col:hover:not([disabled]) { background: var(--surface-2); }
.trend-bar-col[disabled] { cursor: default; }
.trend-bar-amt {
  font-size: 10.5px; font-weight: 700; color: var(--dim); margin-bottom: 6px;
  writing-mode: horizontal-tb; white-space: nowrap;
}
.trend-bar-track { width: 100%; flex: 1; display: flex; align-items: flex-end; padding: 0 3px; }
.trend-bar {
  width: 100%; min-height: 0; border-radius: 5px 5px 2px 2px;
  background: linear-gradient(180deg, var(--accent), #b39bff); transition: filter .1s;
}
.trend-bar-col:hover:not([disabled]) .trend-bar { filter: brightness(1.12); }
.trend-bar-col.is-current .trend-bar { background: linear-gradient(180deg, #ffffff, var(--accent)); }
.trend-bar-col[disabled] .trend-bar { background: var(--surface-2); }
.trend-bar-label { font-size: 11px; color: var(--faint); font-weight: 600; margin-top: 8px; }
.trend-bar-col.is-current .trend-bar-label { color: var(--accent); }

/* ============================ more / categories ============================ */
.more-wrap { max-width: 720px; margin: 0 auto; padding: 10px 24px; }
.more-section-title { font-size: 12px; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; margin: 22px 4px 10px; }
.card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); overflow: hidden; }
.card-row {
  display: flex; align-items: center; gap: 13px; padding: 14px 16px; width: 100%;
  background: none; border: none; border-bottom: 1px solid var(--border-soft); text-align: left; transition: background .1s;
}
.card-row:last-child { border-bottom: none; }
.card-row:hover { background: var(--surface-2); }
.card-row .cr-name { flex: 1; font-weight: 500; }
.card-row .cr-chev { color: var(--faint); font-size: 18px; }
.swatch { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.about-text { color: var(--dim); font-size: 14px; line-height: 1.7; padding: 4px 6px; }
.about-text strong { color: var(--text); }

.restore-warn { color: var(--dim); font-size: 13px; line-height: 1.6; margin: 0 0 14px; }
.restore-meta { color: var(--faint); font-size: 11.5px; font-weight: 400; }
#restore-list.card { margin-bottom: 14px; }
#restore-list .card-row { align-items: flex-start; }
#restore-list .cr-chev { color: var(--accent); font-size: 13px; font-weight: 600; white-space: nowrap; }

/* ============================ bottom nav + fab (mobile) ============================ */
.bottom-nav { display: none; }
.fab { display: none; }

/* ============================ modals ============================ */
.modal-scrim {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(6,8,12,0.66); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
/* The generic add/edit prompt can open on top of another sheet (e.g. editing a
   category from the categories editor), so it must stack above it. */
#prompt-modal { z-index: 70; }
.sheet {
  width: 100%; max-width: 440px; background: var(--elevated);
  border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow);
  max-height: 92vh; overflow-y: auto;
}
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--border-soft);
  position: sticky; top: 0; background: var(--elevated); z-index: 1;
}
.sheet-title { font-weight: 700; font-size: 15.5px; }
.txt-btn { background: none; border: none; color: var(--dim); font-weight: 600; padding: 4px 6px; }
.txt-btn:hover { color: var(--text); }
.txt-btn.primary { color: var(--accent); }

.amount-field {
  display: flex; align-items: baseline; justify-content: center; gap: 6px;
  padding: 26px 18px 20px;
}
.amount-field .cur { font-size: 24px; color: var(--dim); font-weight: 600; }
.amount-input {
  background: none; border: none; outline: none; text-align: center;
  font-size: 42px; font-weight: 700; letter-spacing: -0.02em; color: var(--text);
  width: 100%; min-width: 0; font-family: inherit;
}
.amount-input::placeholder { color: var(--faint); }

#tx-submit-hidden { position: absolute; width: 0; height: 0; padding: 0; margin: 0; border: 0; opacity: 0; overflow: hidden; }
#tx-form .field:focus-within .field-label,
#tx-category-btn:focus .field-label { color: var(--accent); }
#tx-category-btn:focus { outline: none; }

/* category picker grid */
.cat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 12px; }
.cat-tile {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 14px 6px; background: none; border: 1.5px solid transparent; border-radius: 14px;
  color: var(--text); transition: background .1s, border-color .1s;
}
.cat-tile:hover { background: var(--surface-2); }
.cat-tile:focus { outline: none; background: var(--surface-2); border-color: var(--accent); }
.cat-tile .ct-emoji { width: 48px; height: 48px; border-radius: 15px; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.cat-tile .ct-label { font-size: 12px; text-align: center; line-height: 1.25; color: var(--dim); }
.cat-tile-new .ct-emoji { background: var(--surface-2); color: var(--accent); font-weight: 700; }

.field-list { display: flex; flex-direction: column; padding: 0 6px 10px; }
.field {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 15px 14px; background: none; border: none; border-bottom: 1px solid var(--border-soft); text-align: left;
}
.field:last-child { border-bottom: none; }
.field-label { color: var(--dim); font-size: 14px; min-width: 74px; }
.field-value { flex: 1; text-align: right; font-weight: 500; }
.field-value.placeholder { color: var(--faint); font-weight: 400; }
.field-chev { color: var(--faint); font-size: 18px; }
.field-input {
  flex: 1; background: none; border: none; outline: none; text-align: right; min-width: 0;
}
.field-input::-webkit-calendar-picker-indicator { filter: invert(0.7); }

/* <select> in the generic prompt (e.g. the currency picker). Without an explicit
   dark background the native option popup renders near-white text on a white
   default background — invisible. Force it on-theme and left-aligned. */
select.field-input {
  text-align: left; color: var(--text); background: var(--surface-2);
  padding: 9px 11px; border-radius: var(--radius-sm); font: inherit;
  cursor: pointer; max-width: 66%;
}
select.field-input option { background: var(--surface); color: var(--text); }

.danger-btn {
  display: block; width: calc(100% - 28px); margin: 6px 14px 18px;
  padding: 13px; background: none; border: 1px solid var(--border);
  border-radius: 12px; color: var(--danger); font-weight: 600; transition: background .12s;
}
.danger-btn:hover { background: rgba(255,107,107,0.08); }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: var(--elevated); color: var(--text); border: 1px solid var(--border);
  padding: 11px 20px; border-radius: 30px; font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow); z-index: 100;
}

/* ============================ review (AI) ============================ */
.nav-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}
.side-nav .nav-item { position: relative; }
.side-nav .nav-item .nav-badge { margin-left: auto; }

.review-wrap { max-width: 760px; margin: 0 auto; padding: 12px 20px; }
.ingest-panel { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.ingest-drop {
  display: flex; align-items: center; gap: 14px; text-align: left; width: 100%;
  padding: 18px; border: 1.5px dashed var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); transition: border-color .12s, background .12s;
}
.ingest-drop:hover { border-color: var(--accent); background: var(--surface-2); }
.ingest-drop svg { width: 26px; height: 26px; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.ingest-drop span { font-size: 13px; color: var(--dim); line-height: 1.5; }
.ingest-drop strong { color: var(--text); font-size: 15px; }
.ingest-text { display: flex; gap: 8px; }
.ingest-text input {
  flex: 1; background: var(--surface); border: 1px solid var(--border-soft); border-radius: 11px;
  padding: 11px 14px; outline: none; color: var(--text);
}
.ingest-text input:focus { border-color: var(--accent); }
.ingest-send { padding: 0 20px; border: none; border-radius: 11px; background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.ingest-status { font-size: 13px; padding: 6px 2px; }
.ingest-status.busy { color: var(--dim); }
.ingest-status.ok { color: var(--positive); }
.ingest-status.err { color: var(--danger); }

.pending-card {
  background: var(--surface); border: 1px solid var(--border-soft); border-radius: 14px;
  padding: 12px; margin-bottom: 10px;
}
.pending-card.is-dupe { border-color: rgba(242,169,62,0.5); }
.dupe-warn {
  background: rgba(242,169,62,0.12); color: #f2c96b; border-radius: 9px;
  padding: 8px 10px; font-size: 12.5px; margin-bottom: 10px;
}
.pending-grid { display: grid; grid-template-columns: 148px 116px 1.1fr 1.4fr auto; gap: 8px; align-items: center; }
.pf {
  background: var(--bg); border: 1px solid var(--border-soft); border-radius: 9px;
  padding: 9px 10px; outline: none; color: var(--text); font-size: 13.5px; min-width: 0; font-family: inherit;
}
.pf:focus { border-color: var(--accent); }
.pf::-webkit-calendar-picker-indicator { filter: invert(0.7); }
.pf-amount { display: flex; align-items: center; gap: 2px; background: var(--bg); border: 1px solid var(--border-soft); border-radius: 9px; padding-left: 10px; }
.pf-amount:focus-within { border-color: var(--accent); }
.pf-amount span { color: var(--dim); }
.pf-amount .pf-amt { border: none; background: none; padding-left: 2px; }
.pf-cat { appearance: none; -webkit-appearance: none; }
.pf-cat option { color: #111; }
.pending-actions { display: flex; gap: 6px; }
.pa-approve, .pa-reject { width: 36px; height: 36px; border-radius: 9px; border: none; font-size: 15px; font-weight: 700; }
.pa-approve { background: rgba(79,214,160,0.16); color: var(--positive); }
.pa-approve:hover { background: rgba(79,214,160,0.30); }
.pa-reject { background: var(--surface-2); color: var(--dim); }
.pa-reject:hover { background: rgba(255,107,107,0.16); color: var(--danger); }
.pending-meta { display: flex; gap: 8px; margin-top: 8px; padding-left: 2px; }
.conf-chip, .src-chip { font-size: 11px; padding: 3px 8px; border-radius: 20px; }
.src-chip { background: var(--surface-2); color: var(--faint); text-transform: capitalize; }
.conf-chip.low { background: rgba(242,169,62,0.16); color: #f2c96b; }

/* ============================ responsive: tablet ============================ */
@media (max-width: 1080px) {
  .calendar-layout { grid-template-columns: minmax(0,1fr) 300px; }
  .stats-grid { grid-template-columns: 220px 1fr; gap: 18px; }
}

/* ============================ responsive: mobile ============================ */
@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; height: auto; min-height: 100dvh; }
  .sidebar { display: none; }
  .main { height: auto; min-height: 100dvh; overflow: visible; padding-bottom: calc(64px + var(--safe-bottom)); }
  .view { min-height: calc(100dvh - 64px); }

  .view-head { padding: 16px 16px 14px; gap: 12px; }
  .view-title { font-size: 20px; width: 100%; }
  .head-total { margin-left: 0; }
  .period-nav { order: 3; }
  .segmented { width: 100%; }
  .segment { flex: 1; text-align: center; padding-left: 4px; padding-right: 4px; font-size: 12.5px; }

  .calendar-layout { display: block; }
  .calendar-pane { padding: 12px 12px 18px; overflow: visible; }
  .cal-grid { gap: 4px; }
  .cal-cell { min-height: 62px; padding: 6px; border-radius: 10px; }
  .cal-cell .cal-count { display: none; }
  .cal-amt { font-size: 11px; }

  .day-pane {
    border-left: none; border-top: 1px solid var(--border-soft);
    background: var(--bg); overflow: visible;
  }
  .day-pane-foot { border-top: none; }

  .tx-row, .day-header { padding-left: 16px; padding-right: 16px; }
  .search-bar { padding: 10px 16px 2px; }
  .stats-wrap { padding: 8px 14px; }
  .stats-grid { grid-template-columns: 1fr; gap: 8px; }
  .pie-card { margin-bottom: 12px; }
  .trend-card { padding: 18px 8px 6px; }
  .trend-chart { height: 170px; gap: 2px; }
  .trend-bar-amt { font-size: 9px; writing-mode: vertical-rl; transform: rotate(180deg); margin-bottom: 4px; max-height: 46px; }
  .trend-bar-label { font-size: 9.5px; margin-top: 6px; }
  .more-wrap { padding: 8px 14px; }

  /* bottom nav */
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: rgba(20,23,30,0.92); backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-soft); padding-bottom: var(--safe-bottom);
  }
  .tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    background: none; border: none; color: var(--faint); font-size: 10.5px; font-weight: 600;
    padding: 9px 0 8px;
  }
  .tab { position: relative; }
  .tab .ic { width: 22px; height: 22px; }
  .tab.active { color: var(--accent); }
  .tab .nav-badge { position: absolute; top: 3px; left: 50%; margin-left: 6px; }

  /* review cards stack on mobile */
  .review-wrap { padding: 8px 12px; }
  .pending-grid { grid-template-columns: 1fr 1fr; }
  .pending-grid .pf-cat, .pending-grid .pf-note { grid-column: 1 / -1; }
  .pending-actions { grid-column: 1 / -1; justify-content: flex-end; }

  /* fab */
  .fab {
    display: flex; align-items: center; justify-content: center;
    position: fixed; right: 18px; bottom: calc(74px + var(--safe-bottom)); z-index: 45;
    width: 56px; height: 56px; border-radius: 50%; border: none;
    background: var(--accent); box-shadow: 0 8px 24px rgba(122,162,255,0.4);
  }
  .fab svg { width: 26px; height: 26px; fill: none; stroke: var(--accent-ink); stroke-width: 2.4; stroke-linecap: round; }

  .modal-scrim { align-items: flex-end; padding: 0; }
  .sheet { max-width: 100%; border-radius: 20px 20px 0 0; border-bottom: none; max-height: 94vh; padding-bottom: var(--safe-bottom); }
  .toast { bottom: calc(84px + var(--safe-bottom)); }
}

/* ===================== AUTH SCREEN (login / signup) ===================== */
.auth-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #1a2030 0%, var(--bg) 60%);
  z-index: 100;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 26px 22px;
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.2px;
  color: var(--text);
  margin-bottom: 20px;
}
.auth-brand .brand-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #a6c0ff);
}
.auth-title { font-size: 22px; font-weight: 700; color: var(--text); margin: 0 0 4px; }
.auth-sub { font-size: 13.5px; color: var(--dim); margin: 0 0 22px; }
.auth-label {
  display: block;
  font-size: 12px;
  color: var(--dim);
  margin-bottom: 14px;
}
.auth-input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 11px 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  outline: none;
}
.auth-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.auth-error {
  background: rgba(255,107,107,0.12);
  border: 1px solid rgba(255,107,107,0.3);
  color: #ffb4b4;
  font-size: 13px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}
.auth-submit {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 15px;
  font-weight: 650;
  cursor: pointer;
}
.auth-submit:disabled { opacity: 0.6; cursor: default; }
.auth-toggle {
  display: block;
  width: 100%;
  margin-top: 16px;
  background: none;
  border: none;
  color: var(--accent);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
}

/* Telegram link code (More → Connect) */
.tg-code-box { margin-top: 12px; padding: 12px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.tg-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 18px; font-weight: 700; letter-spacing: 1px;
  color: var(--accent); margin: 6px 0; user-select: all;
}

/* Import mapping modal */
.import-check { display: flex; gap: 9px; align-items: center; margin-top: 10px; font-size: 14px; color: var(--text); }
.import-check input { width: 16px; height: 16px; accent-color: var(--accent); }

/* Import intro (ChatGPT prompt) */
.import-steps { margin: 8px 0 14px; padding-left: 20px; color: var(--dim); font-size: 13.5px; line-height: 1.7; }
.import-steps strong { color: var(--text); }
.import-steps a { color: var(--accent); }
.import-prompt {
  width: 100%; box-sizing: border-box; resize: vertical;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; line-height: 1.5; padding: 11px 12px;
}
.import-prompt:focus { outline: none; border-color: var(--accent); }
