/* ============================================================
   TRAX — "Data terminal" design system
   Inter for UI · IBM Plex Mono for numerals, codes, IDs
   ============================================================ */

:root {
  --bg:        oklch(0.171 0.006 250);
  --bg-2:      oklch(0.205 0.007 250);
  --bg-3:      oklch(0.240 0.008 250);
  --bg-inset:  oklch(0.150 0.006 250);
  --line:      oklch(0.305 0.010 250);
  --line-soft: oklch(0.255 0.008 250);
  --text:      oklch(0.940 0.004 250);
  --text-2:    oklch(0.700 0.010 250);
  --text-3:    oklch(0.540 0.012 250);
  --accent:    oklch(0.815 0.130 78);
  --accent-2:  oklch(0.700 0.110 78);
  --accent-dim:oklch(0.815 0.130 78 / 0.14);
  --pos:       oklch(0.760 0.150 158);
  --pos-dim:   oklch(0.760 0.150 158 / 0.13);
  --neg:       oklch(0.690 0.185 24);
  --neg-dim:   oklch(0.690 0.185 24 / 0.14);
  --info:      oklch(0.720 0.110 235);
  --info-dim:  oklch(0.720 0.110 235 / 0.14);

  --r: 4px;
  --r-lg: 7px;
  --sb-w: 232px;
  --top-h: 52px;
  --ui: 'Inter', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', monospace;
  --shadow: 0 1px 0 rgba(0,0,0,0.4), 0 8px 30px -12px rgba(0,0,0,0.6);
}

[data-theme="light"] {
  --bg:        oklch(0.968 0.004 250);
  --bg-2:      oklch(0.998 0.001 250);
  --bg-3:      oklch(0.948 0.005 250);
  --bg-inset:  oklch(0.978 0.003 250);
  --line:      oklch(0.886 0.006 250);
  --line-soft: oklch(0.922 0.005 250);
  --text:      oklch(0.235 0.013 250);
  --text-2:    oklch(0.470 0.014 250);
  --text-3:    oklch(0.610 0.013 250);
  --accent:    oklch(0.585 0.135 62);
  --accent-2:  oklch(0.520 0.130 62);
  --accent-dim:oklch(0.585 0.135 62 / 0.12);
  --pos:       oklch(0.520 0.150 152);
  --pos-dim:   oklch(0.520 0.150 152 / 0.10);
  --neg:       oklch(0.530 0.205 27);
  --neg-dim:   oklch(0.530 0.205 27 / 0.09);
  --info:      oklch(0.510 0.140 248);
  --info-dim:  oklch(0.510 0.140 248 / 0.10);
  --shadow: 0 1px 2px rgba(20,30,48,0.05), 0 12px 32px -16px rgba(20,30,48,0.22);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  font-family: var(--ui);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 240ms ease, color 240ms ease;
}
.mono { font-family: var(--mono); font-feature-settings: 'tnum' 1; }
.num { font-family: var(--mono); font-feature-settings: 'tnum' 1; font-variant-numeric: tabular-nums; letter-spacing: -0.2px; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.micro { font-size: 9.5px; font-weight: 600; letter-spacing: 1.4px; text-transform: uppercase; font-family: var(--ui); }
::selection { background: var(--accent-dim); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); border: 3px solid transparent; background-clip: padding-box; }

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

/* ---- Sidebar ---- */
.sidebar {
  background: var(--bg-inset);
  border-right: 1px solid var(--line-soft);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  z-index: 60;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); height: var(--top-h); flex-shrink: 0; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
  overflow: hidden; background: var(--bg-3);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 1px var(--line), 0 2px 10px rgba(0,0,0,0.35);
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.brand-name { font-weight: 600; font-size: 15px; letter-spacing: 0; line-height: 1; font-family: var(--ui); }
.brand-tm { font-size: 8px; font-weight: 400; vertical-align: super; letter-spacing: 0; color: var(--text-3); margin-left: 1px; }
.brand-sub { font-family: var(--ui); font-size: 8.5px; letter-spacing: 1px; color: var(--text-3); text-transform: uppercase; margin-top: 3px; }
nav { flex: 1; overflow-y: auto; padding: 10px 8px; }
.nav-group { font-family: var(--ui); font-size: 9px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: var(--text-3); padding: 14px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 7px 10px; border-radius: var(--r); cursor: pointer;
  color: var(--text-2); font-size: 13px; font-weight: 500; border: none; background: none; text-align: left;
  font-family: var(--ui); position: relative; transition: background 130ms, color 130ms;
}
.nav-item .ic { width: 15px; height: 15px; flex-shrink: 0; opacity: 0.8; }
.nav-item .kbd { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--text-3); opacity: 0; transition: opacity 130ms; }
.nav-item:hover { background: var(--bg-3); color: var(--text); }
.nav-item:hover .kbd { opacity: 0.7; }
.nav-item.active { background: var(--bg-3); color: var(--text); }
.nav-item.active::before { content: ''; position: absolute; left: 0; top: 6px; bottom: 6px; width: 2.5px; border-radius: 3px; background: var(--accent); box-shadow: 0 0 10px -1px var(--accent); }
.nav-item.active .ic { opacity: 1; color: var(--accent); }
.sb-foot { padding: 10px 12px; border-top: 1px solid var(--line-soft); font-family: var(--ui); font-size: 10px; color: var(--text-3); display: flex; align-items: center; gap: 7px; }

/* ---- Main ---- */
.main { display: flex; flex-direction: column; min-width: 0; overflow-x: hidden; }
.topbar {
  height: var(--top-h); flex-shrink: 0; position: sticky; top: 0; z-index: 50;
  background: color-mix(in oklch, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 14px; padding: 0 18px;
}
.tb-title { display: flex; flex-direction: column; min-width: 0; }
.tb-crumb { font-family: var(--ui); font-size: 9px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-3); }
.tb-h1 { font-size: 15px; font-weight: 650; letter-spacing: 0.2px; line-height: 1.1; white-space: nowrap; }
.tb-spacer { flex: 1; }
.tb-actions { display: flex; align-items: center; gap: 8px; }
.hamburger { display: none; }

/* Topbar brand — visible when the persistent sidebar is not shown */
.tb-brand { display: flex; align-items: center; gap: 8px; margin-right: 2px; flex-shrink: 0; }
.tb-brand-mark {
  width: 28px; height: 28px; border-radius: 7px; flex-shrink: 0;
  overflow: hidden; background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 2px color-mix(in oklch, var(--accent) 40%, transparent), 0 2px 6px rgba(0,0,0,0.3);
}
.tb-brand-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tb-brand-name { font-family: var(--ui); font-weight: 600; font-size: 14px; letter-spacing: 0; line-height: 1; white-space: nowrap; }
.tb-brand-sub { font-family: var(--ui); font-size: 9px; color: var(--text-3); letter-spacing: 1px; text-transform: uppercase; margin-top: 2px; white-space: nowrap; }
/* Hide on desktop and tablet landscape — sidebar is always visible there */
@media (min-width: 1024px) { .tb-brand { display: none; } }
@media (max-width: 1023px) and (min-width: 768px) and (orientation: landscape) { .tb-brand { display: none; } }
/* On very small mobile portrait, show logo only — no room for name */
/* Currency button text: show full label on ≥600px, symbol on smaller */
.cur-sym { display: none; }
@media (max-width: 599px) { .cur-full { display: none; } .cur-sym { display: inline; } }
/* New button label: hide text on tiny screens */
@media (max-width: 479px) { .btn-new-label { display: none; } }
/* segmented control (currency / period / theme) */
.seg { display: inline-flex; background: var(--bg-3); border: 1px solid var(--line); border-radius: var(--r); padding: 2px; gap: 2px; }
.seg button { font-family: var(--ui); font-size: 11px; font-weight: 600; padding: 4px 10px; border: none; background: none; color: var(--text-2); cursor: pointer; border-radius: 3px; transition: background 130ms, color 130ms; letter-spacing: 0.3px; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--bg-2); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,0.18); }
.seg button.on.accent { color: var(--accent); }

/* icon button */
.icobtn { width: 32px; height: 32px; display: grid; place-items: center; background: var(--bg-3); border: 1px solid var(--line); border-radius: var(--r); color: var(--text-2); cursor: pointer; transition: all 130ms; position: relative; flex-shrink: 0; }
.icobtn:hover { color: var(--text); border-color: var(--text-3); background: var(--bg-2); }
.icobtn.save-ok { color: var(--pos); border-color: var(--pos); }
.icobtn svg { width: 15px; height: 15px; }
.icobtn[data-tip]::after { content: attr(data-tip); position: absolute; top: calc(100% + 7px); right: 0; background: var(--bg-inset); color: var(--text); border: 1px solid var(--line); font-family: var(--mono); font-size: 10px; white-space: nowrap; padding: 4px 7px; border-radius: var(--r); opacity: 0; pointer-events: none; transition: opacity 140ms; z-index: 80; }
.icobtn:hover[data-tip]::after { opacity: 1; }

/* status pill */
.pill { display: inline-flex; align-items: center; gap: 6px; font-family: var(--ui); font-size: 10px; font-weight: 600; padding: 5px 9px; border-radius: 20px; border: 1px solid var(--line); color: var(--text-2); background: var(--bg-3); cursor: pointer; transition: all 130ms; letter-spacing: 0.3px; }
.pill:hover { border-color: var(--text-3); color: var(--text); }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); }
.pill.github .dot { background: var(--pos); box-shadow: 0 0 7px var(--pos); }
.pill.supabase .dot { background: var(--pos); box-shadow: 0 0 7px var(--pos); }
.pill.seed .dot { background: var(--info); }
.pill.local .dot { background: var(--accent); }
.pill.syncing .dot { background: var(--accent); animation: blink 0.8s infinite; }
.pill.err .dot { background: var(--neg); }
@keyframes blink { 50% { opacity: 0.25; } }

/* primary button */
.btn { font-family: var(--ui); font-size: 12.5px; font-weight: 600; padding: 7px 13px; border-radius: var(--r); border: 1px solid var(--line); background: var(--bg-3); color: var(--text); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: all 130ms; white-space: nowrap; }
.btn:hover { border-color: var(--text-3); background: var(--bg-2); }
.btn svg { width: 14px; height: 14px; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: oklch(0.18 0.01 80); font-weight: 700; }
.btn-accent:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-ghost { background: none; }
.btn-danger { color: var(--neg); }
.btn-danger:hover { background: var(--neg-dim); border-color: var(--neg); }
.btn-sm { padding: 5px 9px; font-size: 11.5px; }
.btn:active { transform: translateY(0.5px); }

/* ============ CONTENT ============ */
.content { padding: 20px; max-width: 1320px; width: 100%; margin: 0 auto; }
.page { animation: fade 260ms ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.sec-label { font-family: var(--ui); font-size: 10px; font-weight: 700; letter-spacing: 1.6px; text-transform: uppercase; color: var(--text-3); }

/* ---- stat ticker strip ---- */
.ticker { display: grid; grid-template-columns: repeat(5, 1fr); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--bg-2); overflow: hidden; margin-bottom: 18px; }
.tk { padding: 13px 16px 14px; border-right: 1px solid var(--line-soft); position: relative; }
.tk:last-child { border-right: none; }
.tk-label { display: flex; align-items: center; gap: 6px; font-size: 9.5px; font-weight: 700; letter-spacing: 1.3px; text-transform: uppercase; color: var(--text-3); margin-bottom: 9px; }
.tk-label .swatch { width: 7px; height: 7px; border-radius: 2px; }
.tk-val { font-family: var(--mono); font-size: 23px; font-weight: 600; letter-spacing: -0.8px; line-height: 1; font-variant-numeric: tabular-nums; }
.tk-sub { font-family: var(--mono); font-size: 10.5px; color: var(--text-3); margin-top: 7px; display: flex; align-items: center; gap: 5px; }
.tk-delta { padding: 1px 5px; border-radius: 3px; font-weight: 600; font-size: 10px; }
.tk-delta.up { color: var(--pos); background: var(--pos-dim); }
.tk-delta.down { color: var(--neg); background: var(--neg-dim); }

/* ---- panel / card ---- */
.panel { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.panel + .panel { margin-top: 16px; }
.panel-hd { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); }
.panel-hd h3 { font-size: 13px; font-weight: 650; letter-spacing: 0.2px; display: flex; align-items: center; gap: 8px; }
.panel-hd .tag { font-family: var(--mono); font-size: 9.5px; color: var(--text-3); border: 1px solid var(--line); padding: 2px 6px; border-radius: 3px; }
.panel-bd { padding: 16px; }

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

/* ---- table ---- */
.tbl-scroll { overflow-x: auto; }
table.tx { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.tx thead th { position: sticky; top: 0; background: var(--bg-3); text-align: left; font-family: var(--ui); font-size: 9.5px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--text-3); padding: 9px 14px; white-space: nowrap; border-bottom: 1px solid var(--line); }
table.tx tbody td,
table.tx tfoot td { padding: 9px 14px; border-bottom: 1px solid var(--line-soft); color: var(--text); white-space: nowrap; }
table.tx tfoot td { border-top: 1px solid var(--line); border-bottom: none; }
table.tx tbody tr:last-child td { border-bottom: none; }
table.tx tbody tr { transition: background 90ms; }
table.tx tbody tr:hover td { background: var(--bg-3); }
table.tx td.r, table.tx th.r { text-align: right; }
.t-id { font-family: var(--mono); font-size: 11px; color: var(--text-3); }
.t-desc { font-weight: 550; font-size: 12px; }
.t-meta { font-size: 10.5px; color: var(--text-3); margin-top: 1px; }
.t-amt { font-family: var(--mono); font-weight: 600; font-variant-numeric: tabular-nums; }

/* type badge */
.tb-badge { display: inline-flex; align-items: center; gap: 5px; font-family: var(--mono); font-size: 9.5px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; padding: 2px 7px 2px 6px; border-radius: 3px; border: 1px solid transparent; }
.tb-badge .d { width: 5px; height: 5px; border-radius: 1px; }
.tb-badge.income { color: var(--pos); background: var(--pos-dim); } .tb-badge.income .d { background: var(--pos); }
.tb-badge.expense { color: var(--neg); background: var(--neg-dim); } .tb-badge.expense .d { background: var(--neg); }
.tb-badge.asset { color: var(--info); background: var(--info-dim); } .tb-badge.asset .d { background: var(--info); }
.tb-badge.liability { color: var(--accent); background: var(--accent-dim); } .tb-badge.liability .d { background: var(--accent); }
.tb-badge.equity { color: var(--text-2); background: var(--bg-3); border-color: var(--line); } .tb-badge.equity .d { background: var(--text-2); }

.rowact { display: inline-flex; gap: 2px; opacity: 0; transition: opacity 120ms; }
tr:hover .rowact { opacity: 1; }
.iconmini { width: 24px; height: 24px; display: grid; place-items: center; background: none; border: none; border-radius: var(--r); color: var(--text-3); cursor: pointer; transition: all 120ms; }
.iconmini:hover { background: var(--bg-2); color: var(--text); }
.iconmini.del:hover { color: var(--neg); background: var(--neg-dim); }
.iconmini svg { width: 13px; height: 13px; }

/* ---- search / filters ---- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.field { position: relative; }
.field svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--text-3); pointer-events: none; }
.input { font-family: var(--ui); font-size: 12.5px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 11px; color: var(--text); outline: none; transition: border-color 130ms, box-shadow 130ms; width: 100%; }
.input.with-ic { padding-left: 30px; }
.input::placeholder { color: var(--text-3); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
select.input { cursor: pointer; -webkit-appearance: none; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237a869c' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; padding-right: 28px; }
.search { min-width: 260px; flex: 1 1 260px; }

/* ---- mini chart ---- */
.chart-bars { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding-top: 8px; }
.cb-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 7px; height: 100%; justify-content: flex-end; }
.cb-stack { width: 100%; max-width: 34px; display: flex; flex-direction: column-reverse; gap: 2px; justify-content: flex-end; flex: 1; }
.cb-seg { width: 100%; border-radius: 2px; min-height: 0; transition: height 400ms cubic-bezier(0,0,0.2,1); }
.cb-seg.inc { background: var(--pos); }
.cb-seg.exp { background: var(--neg); }
.cb-label { font-family: var(--mono); font-size: 10px; color: var(--text-3); }
.legend { display: flex; gap: 14px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; color: var(--text-2); font-family: var(--mono); }
.legend i { width: 8px; height: 8px; border-radius: 2px; }

/* category bars */
.catbar { display: flex; flex-direction: column; gap: 11px; }
.catrow { display: grid; grid-template-columns: 1fr auto; gap: 4px; }
.catrow .cn { font-size: 12px; color: var(--text); }
.catrow .cv { font-family: var(--mono); font-size: 12px; font-weight: 600; }
.cattrack { grid-column: 1 / -1; height: 5px; border-radius: 3px; background: var(--bg-3); overflow: hidden; }
.catfill { height: 100%; border-radius: 3px; transition: width 500ms cubic-bezier(0,0,0.2,1); }

/* ---- report ---- */
.rpt-doc { background: var(--bg-2); }
.rpt-head { text-align: center; padding: 26px 20px 20px; border-bottom: 1px solid var(--line); }
.rpt-co { font-family: var(--mono); font-size: 11px; letter-spacing: 4px; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.rpt-title { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; margin-top: 5px; }
.rpt-period { font-family: var(--mono); font-size: 11px; color: var(--text-3); margin-top: 5px; }
.rpt-sec { font-family: var(--ui); font-size: 10px; font-weight: 700; letter-spacing: 1.6px; text-transform: uppercase; padding: 9px 18px; background: var(--bg-3); color: var(--text-2); border-top: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.rpt-sec .bar { width: 3px; height: 12px; border-radius: 2px; background: var(--text-3); }
.rpt-sec.inc .bar { background: var(--pos); } .rpt-sec.inc { color: var(--pos); }
.rpt-sec.exp .bar { background: var(--neg); } .rpt-sec.exp { color: var(--neg); }
.rpt-sec.ast .bar { background: var(--info); } .rpt-sec.ast { color: var(--info); }
.rpt-sec.lia .bar { background: var(--accent); } .rpt-sec.lia { color: var(--accent); }

/* Each line: label stretches, value column fixed-width right-aligned */
.rpt-line { display: flex; justify-content: space-between; align-items: baseline; padding: 9px 18px; border-bottom: 1px solid var(--line-soft); font-size: 13px; gap: 16px; }
.rpt-line:hover { background: var(--bg-3); }
.rpt-label { flex: 1; min-width: 0; }
.rpt-line .lcode { font-family: var(--mono); font-size: 10.5px; color: var(--text-3); margin-right: 9px; }
.rpt-line .lv { font-family: var(--mono); font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.2px; white-space: nowrap; text-align: right; min-width: 160px; flex-shrink: 0; }

/* color overrides — higher specificity so they beat .rpt-line.net .lv */
.lv.pos { color: var(--pos); }
.lv.neg { color: var(--neg); }

/* subtotal rows — slightly larger value */
.rpt-line.sub { font-weight: 700; background: var(--bg-3); border-top: 1px solid var(--line); font-size: 13.5px; }
.rpt-line.sub .lv { font-size: 15px; }

/* net / bottom-line row — largest */
.rpt-line.net { background: var(--bg-inset); font-weight: 700; font-size: 15px; padding: 20px 18px; border-bottom: none; }
.rpt-line.net .lv { font-size: 22px; font-weight: 700; letter-spacing: -0.6px; }

.rpt-balance { margin: 14px 18px 20px; padding: 12px 18px; border-radius: var(--r); display: flex; justify-content: space-between; align-items: center; font-family: var(--mono); font-size: 12px; font-weight: 600; gap: 12px; }
.rpt-balance.ok { background: var(--pos-dim); color: var(--pos); }
.rpt-balance.no { background: var(--neg-dim); color: var(--neg); }
.rpt-balance .num { font-size: 14px; white-space: nowrap; }
.rpt-cols { display: grid; grid-template-columns: 1fr 1fr; }
.rpt-cols > div:first-child { border-right: 1px solid var(--line); }

/* period tabs */
.periods { display: inline-flex; gap: 2px; background: var(--bg-3); border: 1px solid var(--line); border-radius: var(--r); padding: 2px; }
.periods button { font-family: var(--ui); font-size: 11px; font-weight: 600; padding: 5px 11px; border: none; background: none; color: var(--text-2); cursor: pointer; border-radius: 3px; transition: all 120ms; }
.periods button:hover { color: var(--text); }
.periods button.on { background: var(--bg-2); color: var(--accent); }

/* ---- empty ---- */
.empty { text-align: center; padding: 50px 20px; color: var(--text-3); }
.empty svg { width: 30px; height: 30px; opacity: 0.4; margin-bottom: 12px; }
.empty p { font-size: 13px; }
.empty .micro { margin-top: 4px; color: var(--text-3); }

/* ============ MODAL ============ */
.ov { position: fixed; inset: 0; background: oklch(0.1 0.01 250 / 0.6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 20px; animation: fade 180ms ease; }
.dialog { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-lg); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; box-shadow: var(--shadow); animation: pop 220ms cubic-bezier(0,0,0.2,1); }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(0.98); } to { opacity: 1; transform: none; } }
.dialog-hd { display: flex; align-items: flex-start; justify-content: space-between; padding: 18px 20px 14px; border-bottom: 1px solid var(--line-soft); position: sticky; top: 0; background: var(--bg-2); z-index: 2; }
.dialog-hd h2 { font-size: 17px; font-weight: 700; letter-spacing: -0.2px; }
.dialog-hd p { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.dialog-bd { padding: 18px 20px; }
.dialog-ft { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line-soft); position: sticky; bottom: 0; background: var(--bg-2); }
.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.fg { display: flex; flex-direction: column; gap: 5px; }
.fg.full { grid-column: 1 / -1; }
.fg label { font-size: 9.5px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--text-3); display: flex; justify-content: space-between; align-items: center; }
.fg textarea.input { resize: vertical; min-height: 62px; font-family: var(--ui); }
.fg .hint { font-family: var(--mono); font-size: 10px; color: var(--text-3); }
.readonly { background: var(--bg-inset) !important; color: var(--text-3); font-family: var(--mono); cursor: default; }
.linkbtn { background: none; border: none; color: var(--accent); cursor: pointer; font-family: var(--ui); font-size: 9.5px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; display: inline-flex; align-items: center; gap: 4px; padding: 0; }
.linkbtn:hover { text-decoration: underline; }
.amt-wrap { position: relative; }
.amt-wrap .cur { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); font-family: var(--mono); font-size: 13px; color: var(--text-3); pointer-events: none; }
.amt-wrap .input { padding-left: 26px; }

/* gh connect dialog */
.gh-note { font-size: 11.5px; color: var(--text-2); line-height: 1.5; background: var(--bg-inset); border: 1px solid var(--line-soft); border-radius: var(--r); padding: 11px 13px; margin-bottom: 14px; }
.gh-note code { font-family: var(--mono); font-size: 10.5px; color: var(--accent); }
.gh-status { font-family: var(--mono); font-size: 11px; margin-top: 12px; display: flex; align-items: center; gap: 7px; padding: 9px 11px; border-radius: var(--r); }
.gh-status.ok { color: var(--pos); background: var(--pos-dim); }
.gh-status.err { color: var(--neg); background: var(--neg-dim); }
.gh-status.info { color: var(--info); background: var(--info-dim); }
.spin { animation: spin 0.8s linear infinite; } @keyframes spin { to { transform: rotate(360deg); } }

/* toast */
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%) translateY(20px); z-index: 300; background: var(--bg-inset); border: 1px solid var(--line); color: var(--text); font-family: var(--ui); font-size: 11.5px; padding: 9px 15px; border-radius: 20px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: all 240ms cubic-bezier(0,0,0.2,1); display: flex; align-items: center; gap: 8px; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.toast.ok .dot { background: var(--pos); } .toast.err .dot { background: var(--neg); }

/* ============ TOUCH & INTERACTION ============ */
@media (hover: none) and (pointer: coarse) {
  /* Minimum 44px tap targets on touch devices */
  .btn, .icobtn, .nav-item, .seg button, .periods button { min-height: 44px; }
  .iconmini { width: 36px; height: 36px; }
  /* Always show row actions on touch (no hover) */
  .rowact { opacity: 1; }
  /* Remove tooltip pseudo-elements that need hover */
  .icobtn[data-tip]::after { display: none; }
}

/* ============ BOTTOM NAV (mobile) ============ */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
  background: var(--bg-inset);
  border-top: 1px solid var(--line);
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.bottom-nav-inner {
  display: flex; align-items: stretch; height: 56px;
}
.bn-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-family: var(--ui); font-size: 9.5px; font-weight: 600; cursor: pointer;
  letter-spacing: 0.3px; transition: color 130ms; padding: 0 4px;
  -webkit-tap-highlight-color: transparent;
}
.bn-item .ic { width: 18px; height: 18px; }
.bn-item.active { color: var(--accent); }
.bn-item.active .ic { color: var(--accent); }

/* ============ RESPONSIVE ============ */
.scrim { display: none; }

/* ---- Desktop wide (1440px+) ---- */
@media (min-width: 1440px) {
  :root { --sb-w: 256px; }
  .content { max-width: 1480px; padding: 24px 28px; }
  .ticker { grid-template-columns: repeat(5, 1fr); }
}

/* ---- Laptop / large desktop (1024px – 1439px) ---- */
@media (max-width: 1439px) and (min-width: 1024px) {
  :root { --sb-w: 220px; }
  .content { padding: 18px 20px; }
}

/* ============================================================
   TABLET LANDSCAPE  768px – 1023px  (landscape orientation)
   Persistent sidebar at 200px, 2-col panels, 3-col ticker
   ============================================================ */
@media (max-width: 1023px) and (min-width: 768px) and (orientation: landscape) {
  :root { --sb-w: 200px; }
  .brand-name { font-size: 14px; }
  .nav-item { font-size: 12.5px; padding: 6px 9px; }
  .content { padding: 16px 18px; }
  .grid-2 { grid-template-columns: 1.4fr 1fr; gap: 14px; }
  .ticker { grid-template-columns: repeat(3, 1fr); }
  .tk:nth-child(3n) { border-right: none; }
  .tk { border-bottom: 1px solid var(--line-soft); }
  .tk:nth-last-child(-n+2) { border-bottom: none; }
  .tb-actions { gap: 6px; }
  .pill { padding: 5px 7px; font-size: 9.5px; }
  .chart-bars { height: 130px; }
}

/* ============================================================
   TABLET PORTRAIT  768px – 1023px  (portrait orientation)
   Slide-over sidebar, stacked panels, 3-col ticker
   ============================================================ */
@media (max-width: 1023px) and (min-width: 768px) and (orientation: portrait) {
  :root { --sb-w: 0px; --top-h: 54px; }
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; width: 280px; height: 100%; z-index: 60;
    transform: translateX(-100%); transition: transform 260ms cubic-bezier(0,0,0.2,1);
  }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 18px; row-gap: 6px; }
  .tb-brand { width: 100%; order: 0; flex-shrink: 0; }
  .tb-title { display: none; }
  .tb-spacer { flex: 1; order: 5; }
  .tb-actions { order: 6; gap: 6px; }
  .hamburger { display: grid; order: 7; }
  .scrim.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 55; }
  .content { padding: 18px 20px; }
  .grid-2 { grid-template-columns: 1fr 1fr; gap: 14px; }
  .ticker { grid-template-columns: repeat(3, 1fr); }
  .tk:nth-child(3n) { border-right: none; }
  .tk { border-bottom: 1px solid var(--line-soft); }
  .tk:nth-last-child(-n+2) { border-bottom: none; }
  .chart-bars { height: 130px; }
}

/* ============================================================
   LARGE MOBILE / SMALL TABLET  600px – 767px
   Slide-over sidebar, 1-col panels, 2-col ticker
   ============================================================ */
@media (max-width: 767px) and (min-width: 600px) {
  :root { --sb-w: 0px; --top-h: 54px; }
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; width: 260px; height: 100%; z-index: 60;
    transform: translateX(-100%); transition: transform 260ms cubic-bezier(0,0,0.2,1);
  }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 16px; row-gap: 6px; }
  .tb-brand { width: 100%; order: 0; flex-shrink: 0; }
  .tb-title { display: none; }
  .tb-spacer { flex: 1; order: 5; }
  .tb-actions { order: 6; gap: 6px; }
  .hamburger { display: grid; order: 7; }
  .scrim.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 55; }
  .content { padding: 16px; }
  .grid-2 { grid-template-columns: 1fr; gap: 14px; }
  .ticker { grid-template-columns: repeat(2, 1fr); }
  .tk:nth-child(2n) { border-right: none; }
  .tk { border-bottom: 1px solid var(--line-soft); }
  .tk:nth-last-child(-n+2) { border-bottom: none; }
  .rpt-cols { grid-template-columns: 1fr; }
  .rpt-cols > div:first-child { border-right: none; border-bottom: 1px solid var(--line); }
  .fgrid { grid-template-columns: 1fr 1fr; }
  .chart-bars { height: 120px; }
}

/* ============================================================
   MOBILE LANDSCAPE  480px – 599px
   Slide-over sidebar, compact layout, 3-col ticker
   ============================================================ */
@media (max-width: 599px) and (min-width: 480px) {
  :root { --sb-w: 0px; --top-h: 50px; }
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; width: 240px; height: 100%; z-index: 60;
    transform: translateX(-100%); transition: transform 260ms cubic-bezier(0,0,0.2,1);
  }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .topbar { flex-wrap: wrap; height: auto; padding: 9px 14px; row-gap: 6px; }
  .tb-brand { width: 100%; order: 0; flex-shrink: 0; }
  .tb-title { display: none; }
  .tb-spacer { flex: 1; order: 5; }
  .tb-actions { order: 6; gap: 5px; }
  .hamburger { display: grid; order: 7; }
  .scrim.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 55; }
  .content { padding: 10px 12px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .grid-2 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .ticker { grid-template-columns: repeat(3, 1fr); }
  .tk:nth-child(3n) { border-right: none; }
  .tk { border-bottom: 1px solid var(--line-soft); padding: 10px 12px; }
  .tk:nth-last-child(-n+2) { border-bottom: none; }
  .tk-val { font-size: 18px; }
  .rpt-cols { grid-template-columns: 1fr; }
  .rpt-cols > div:first-child { border-right: none; border-bottom: 1px solid var(--line); }
  .fgrid { grid-template-columns: 1fr 1fr; }
  .pill { max-width: 80px; overflow: hidden; text-overflow: ellipsis; }
  .chart-bars { height: 90px; }
  table.tx { font-size: 12px; }
  table.tx thead th, table.tx tbody td, table.tx tfoot td { padding: 7px 9px; }
}

/* ============================================================
   MOBILE PORTRAIT  < 480px
   Bottom nav replaces sidebar, 2-col ticker, full-width content
   ============================================================ */
@media (max-width: 479px) {
  :root { --sb-w: 0px; --top-h: 50px; }
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .hamburger { display: none; }
  .bottom-nav { display: block; }
  .main { padding-bottom: 56px; }
  .topbar { flex-wrap: wrap; height: auto; padding: 9px 14px; row-gap: 6px; }
  .tb-brand { width: 100%; order: 0; flex-shrink: 0; }
  .tb-brand-name { display: block; }
  .tb-title { display: none; }
  .tb-spacer { flex: 1; order: 5; }
  .tb-actions { order: 6; gap: 5px; }
  .content { padding: 12px; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .grid-2 { grid-template-columns: 1fr; gap: 12px; }
  .ticker { grid-template-columns: repeat(2, 1fr); }
  .tk:nth-child(2n) { border-right: none; }
  .tk { border-bottom: 1px solid var(--line-soft); }
  .tk:nth-last-child(-n+2) { border-bottom: none; }
  .tk-val { font-size: 19px; }
  .rpt-cols { grid-template-columns: 1fr; }
  .rpt-cols > div:first-child { border-right: none; border-bottom: 1px solid var(--line); }
  .fgrid { grid-template-columns: 1fr; }
  .fg.full { grid-column: unset; }
  .pill { font-size: 0; padding: 0; width: 32px; height: 32px; justify-content: center; border-radius: var(--r); }
  .pill .dot { margin: 0; }
  .tbl-scroll { -webkit-overflow-scrolling: touch; }
  table.tx { font-size: 12px; }
  table.tx thead th, table.tx tbody td, table.tx tfoot td { padding: 8px 10px; }
  .ov { padding: 0; align-items: flex-end; }
  .dialog { max-width: 100%; border-radius: var(--r-lg) var(--r-lg) 0 0; max-height: 92vh; }
  .dialog-ft { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .rpt-title { font-size: 18px; }
  .filters { gap: 6px; }
  .search { min-width: 100%; }
  .icobtn { width: 34px; height: 34px; }
  .chart-bars { height: 110px; }
  .panel-bd { padding: 12px; }
}

/* ============================================================
   PHONE LANDSCAPE  max-height 500px + landscape
   Short viewport — slim topbar, slide-over sidebar, compact ticker
   ============================================================ */
@media (max-height: 500px) and (orientation: landscape) {
  :root { --sb-w: 0px; --top-h: 44px; }
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; width: 220px; height: 100%; z-index: 60;
    transform: translateX(-100%); transition: transform 260ms cubic-bezier(0,0,0.2,1);
    display: flex;
  }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .hamburger { display: grid !important; }
  .scrim.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 55; }
  .bottom-nav { display: none; }
  .main { padding-bottom: 0; }
  .content { padding: 8px 14px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .grid-2 { grid-template-columns: 1.6fr 1fr; gap: 10px; }
  .ticker { grid-template-columns: repeat(5, 1fr); }
  .tk:nth-child(5n) { border-right: none; }
  .tk { padding: 8px 10px; border-bottom: none; }
  .tk-val { font-size: 17px; }
  .chart-bars { height: 80px; }
  .panel-bd { padding: 10px 14px; }
  table.tx { font-size: 12px; }
  table.tx thead th, table.tx tbody td, table.tx tfoot td { padding: 7px 10px; }
}

/* Safe-area padding for notched phones */
@supports (padding: env(safe-area-inset-bottom)) {
  .topbar { padding-left: max(18px, env(safe-area-inset-left)); padding-right: max(18px, env(safe-area-inset-right)); }
  .sidebar { padding-bottom: env(safe-area-inset-bottom); }
}

/* print */
@media print {
  .sidebar, .topbar, .scrim, .filters, .periods, .rowact, .panel-hd .btn { display: none !important; }
  .app { grid-template-columns: 1fr; }
  body { background: #fff; color: #000; }
  .content { max-width: 100%; padding: 0; }
}

/* ---- airport split-flap digit animation ---- */
.flip-outer {
  display: inline-block;
  perspective: 320px;
  vertical-align: bottom;
  overflow: hidden;           /* clip 3D overflow so it can't cover sibling elements */
  pointer-events: none;       /* purely visual — never intercept clicks */
}
.flip-char {
  display: inline-block;
  animation: flip-char 72ms ease-in both;
  transform-origin: 50% 60%;
  backface-visibility: hidden;
  pointer-events: none;
}
@keyframes flip-char {
  0%   { transform: rotateX(-90deg); opacity: 0.15; }
  60%  { transform: rotateX(8deg);   opacity: 1; }
  100% { transform: rotateX(0deg);   opacity: 1; }
}

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