/* PatriView — design tokens + components. Light by default, dark via [data-theme=dark] or system. */
:root {
  --bg: #fafafa; --surface: #ffffff; --surface-2: #f4f4f5; --surface-3: #ececee;
  --border: #e6e6e9; --border-strong: #d4d4d8;
  --text: #18181b; --text-2: #52525b; --text-3: #8b8b94;
  --accent: #4f46e5; --accent-soft: #eef2ff; --accent-text: #4338ca;
  --pos: #059669; --pos-soft: #ecfdf5; --neg: #e11d48; --neg-soft: #fff1f2; --warn: #d97706; --warn-soft: #fffbeb;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 1px 1px rgba(0,0,0,.02);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.12), 0 2px 6px rgba(0,0,0,.06);
  --radius: 10px; --radius-sm: 7px;
  --grid: #efeff1; --axis: #a1a1aa;
  --font: "Inter", "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b0b0d; --surface: #131316; --surface-2: #1a1a1e; --surface-3: #232328;
  --border: #26262b; --border-strong: #34343a;
  --text: #f4f4f5; --text-2: #b4b4bc; --text-3: #7a7a84;
  --accent: #818cf8; --accent-soft: #1e1b4b; --accent-text: #a5b4fc;
  --pos: #34d399; --pos-soft: #052e22; --neg: #fb7185; --neg-soft: #3b0a16; --warn: #fbbf24; --warn-soft: #3a2a05;
  --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 16px 48px rgba(0,0,0,.6);
  --grid: #1f1f24; --axis: #5b5b64;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg: #0b0b0d; --surface: #131316; --surface-2: #1a1a1e; --surface-3: #232328;
    --border: #26262b; --border-strong: #34343a;
    --text: #f4f4f5; --text-2: #b4b4bc; --text-3: #7a7a84;
    --accent: #818cf8; --accent-soft: #1e1b4b; --accent-text: #a5b4fc;
    --pos: #34d399; --pos-soft: #052e22; --neg: #fb7185; --neg-soft: #3b0a16; --warn: #fbbf24; --warn-soft: #3a2a05;
    --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 16px 48px rgba(0,0,0,.6);
    --grid: #1f1f24; --axis: #5b5b64; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01"; }
.num, .money, td.r, .kpi-value { font-variant-numeric: tabular-nums; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent-text); }
svg { display: block; }

/* ---------- shell */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--border); background: var(--surface);
  display: flex; flex-direction: column; padding: 14px 10px; gap: 2px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; font-weight: 650; letter-spacing: -.01em; }
.brand-logo { width: 28px; height: 28px; border-radius: 8px; flex: none; display: block; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: linear-gradient(135deg, var(--accent), #06b6d4);
  display: grid; place-items: center; color: #fff; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); cursor: pointer; border: 0; background: none; width: 100%; text-align: left; font-weight: 500; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--surface-3); color: var(--text); }
.nav-item svg { width: 16px; height: 16px; flex: none; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 16px 10px 6px; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.sync { font-size: 11.5px; color: var(--text-3); padding: 8px 10px; display: flex; gap: 6px; align-items: center; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--pos); display: inline-block; flex: none; }
.dot.off { background: var(--warn); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); padding: 10px 28px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.topbar h1 { font-size: 15px; margin: 0 12px 0 0; font-weight: 600; letter-spacing: -.01em; }
.spacer { flex: 1; }
.content { padding: 24px 28px 64px; max-width: 1480px; width: 100%; }

/* ---------- controls */
.select, .input { height: 32px; padding: 0 10px; border: 1px solid var(--border); background: var(--surface);
  border-radius: var(--radius-sm); outline: none; }
.select { padding-right: 26px; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%238b8b94' stroke-width='3'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; }
.select:focus, .input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.select.sm { height: 28px; font-size: 12.5px; padding-left: 8px; }
.btn { height: 32px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; display: inline-flex; align-items: center; gap: 7px; font-weight: 500;
  white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.primary:hover { opacity: .9; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.icon { width: 32px; padding: 0; justify-content: center; }
.btn:disabled { opacity: .5; cursor: default; }
.toggles { display: flex; gap: 4px; flex-wrap: wrap; }
.switch { display: inline-flex; align-items: center; gap: 7px; padding: 0 10px; height: 30px; border: 1px solid var(--border);
  border-radius: 999px; cursor: pointer; font-size: 12.5px; color: var(--text-2); background: var(--surface); user-select: none; white-space: nowrap; flex: none; }
.switch .knob { width: 24px; height: 14px; border-radius: 99px; background: var(--surface-3); position: relative; transition: .15s; flex: none; }
.switch .knob::after { content: ""; position: absolute; top: 2px; left: 2px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--text-3); transition: .15s; }
.switch.on { color: var(--text); border-color: var(--border-strong); }
.switch.on .knob { background: var(--accent); }
.switch.on .knob::after { left: 12px; background: #fff; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px; background: var(--surface-2); }
.seg button { border: 0; background: none; padding: 3px 10px; border-radius: 5px; cursor: pointer; color: var(--text-2); font-size: 12.5px; font-weight: 500; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: 12.5px; color: var(--text-2); }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip .count { font-size: 11px; opacity: .7; }

/* ---------- layout + cards */
.grid { display: grid; gap: 16px; }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-h { display: flex; align-items: center; gap: 10px; padding: 14px 18px 0; flex-wrap: wrap; }
.card-h h3 { margin: 0; font-size: 13.5px; font-weight: 600; letter-spacing: -.005em; }
.card-h .sub { color: var(--text-3); font-size: 12.5px; }
.card-b { padding: 14px 18px 18px; }
.section-title { font-size: 13px; color: var(--text-3); font-weight: 500; margin: 28px 0 10px; }
.kpi { padding: 16px 18px; }
.kpi-label { color: var(--text-3); font-size: 12.5px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi-value { font-size: 26px; font-weight: 620; letter-spacing: -.02em; margin-top: 4px; }
.kpi-foot { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.pos { color: var(--pos); } .neg { color: var(--neg); } .muted { color: var(--text-3); } .warn { color: var(--warn); }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; padding: 1px 7px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; font-weight: 500; }
.badge.pos { background: var(--pos-soft); color: var(--pos); border-color: transparent; }
.badge.neg { background: var(--neg-soft); color: var(--neg); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.swatch { width: 9px; height: 9px; border-radius: 3px; display: inline-block; flex: none; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.legend span.off { opacity: .35; }
.empty { text-align: center; padding: 72px 20px; color: var(--text-2); }
.empty h2 { color: var(--text); font-size: 20px; margin: 14px 0 6px; letter-spacing: -.01em; }

/* ---------- tables */
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; color: var(--text-3); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 1; white-space: nowrap; }
th.sortable { cursor: pointer; } th.sortable:hover { color: var(--text); }
td { padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
td.r, th.r { text-align: right; white-space: nowrap; }
.desc { font-weight: 500; max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.desc-sub { color: var(--text-3); font-size: 12px; max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tr.ignored td { opacity: .5; }
tr.selected td { background: var(--accent-soft) !important; }
input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
.cat-select { height: 26px; border: 1px solid transparent; background: var(--surface-2); border-radius: 6px; padding: 0 22px 0 8px;
  font-size: 12.5px; max-width: 190px; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='9' viewBox='0 0 24 24' fill='none' stroke='%238b8b94' stroke-width='3'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 7px center; }
.cat-select:hover { border-color: var(--border-strong); }

/* ---------- charts */
.chart { position: relative; width: 100%; }
.chart text { fill: var(--text-3); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .grid-line { stroke: var(--grid); }
.chart .axis-line { stroke: var(--border-strong); }
.chart .hit { cursor: pointer; }
.chart .hit:hover { opacity: .82; }
.tooltip { position: fixed; z-index: 100; pointer-events: none; background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); border-radius: 8px; padding: 8px 10px; font-size: 12px; min-width: 140px; max-width: 280px;
  font-variant-numeric: tabular-nums; }
.tooltip .t-title { font-weight: 600; margin-bottom: 4px; }
.tooltip .t-row { display: flex; gap: 10px; justify-content: space-between; align-items: center; }
.tooltip .t-row span:first-child { display: inline-flex; gap: 6px; align-items: center; color: var(--text-2); }
.heat { display: grid; gap: 2px; font-size: 12px; overflow: auto; }
.heat .h-cell { height: 30px; border-radius: 4px; display: flex; align-items: center; justify-content: flex-end; padding: 0 7px;
  cursor: pointer; font-variant-numeric: tabular-nums; font-size: 11.5px; }
.heat .h-cell:hover { outline: 2px solid var(--accent); outline-offset: -1px; }
.heat .h-row { display: flex; align-items: center; gap: 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 8px; cursor: pointer; }
.heat .h-head { color: var(--text-3); font-size: 11.5px; text-align: right; padding: 0 7px 4px; }
.bar-track { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; position: relative; }
.bar-fill { height: 100%; border-radius: 99px; }
.bar-mark { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); border-radius: 2px; }

/* ---------- drawer, modal, toast */
.overlay { position: fixed; inset: 0; background: rgba(9,9,11,.35); z-index: 60; animation: fade .15s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(900px, 100vw); background: var(--surface); z-index: 61;
  border-left: 1px solid var(--border); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .2s ease-out; }
.drawer-h { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; gap: 12px; }
.drawer-h h2 { margin: 0; font-size: 16px; letter-spacing: -.01em; }
.drawer-b { overflow: auto; flex: 1; padding: 6px 12px 24px; }
.drawer .desc, .drawer .desc-sub { max-width: 230px; }
.drawer td.acct { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer .cat-select { max-width: 140px; }
.modal { position: fixed; z-index: 61; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(1080px, calc(100vw - 32px));
  max-height: calc(100vh - 48px); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; animation: pop .18s ease-out; }
.modal.narrow { width: min(640px, calc(100vw - 32px)); }
.modal-h { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.modal-h h2 { margin: 0; font-size: 16px; }
.modal-b { padding: 18px 22px; overflow: auto; flex: 1; }
.modal-f { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; align-items: center; }
.dropzone { border: 1.5px dashed var(--border-strong); border-radius: 12px; padding: 44px 20px; text-align: center; cursor: pointer;
  transition: .15s; background: var(--surface-2); }
.dropzone.over, .dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone h3 { margin: 12px 0 4px; font-size: 15px; }
.file-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; margin-top: 8px; }
.stmt { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 14px; overflow: hidden; }
.stmt-h { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; padding: 12px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.stmt-h .field { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--text-3); }
.stmt-h .field b { color: var(--text); font-weight: 600; font-size: 13px; }
.stmt .table-wrap { max-height: 340px; }
tr.dupe td { opacity: .45; text-decoration: line-through; }
.toast-wrap { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--text); color: var(--bg); border-radius: 10px; padding: 10px 12px 10px 16px; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 12px; font-size: 13px; animation: pop .18s ease-out; max-width: min(640px, calc(100vw - 32px)); }
.toast .btn { height: 28px; background: transparent; color: var(--bg); border-color: color-mix(in srgb, var(--bg) 35%, transparent); }
.toast .btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -48%) scale(.98); } }
.toast { animation: none; }

/* ---------- advisor */
.score-ring { position: relative; width: 148px; height: 148px; flex: none; }
.score-ring .v { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.score-ring .v b { font-size: 38px; letter-spacing: -.03em; font-weight: 650; display: block; line-height: 1; }
.subscore { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.subscore:last-child { border-bottom: 0; }
.subscore .name { font-weight: 550; }
.subscore .detail { grid-column: 1 / -1; color: var(--text-3); font-size: 12.5px; }
.rec { padding: 16px 18px; display: grid; grid-template-columns: 1fr auto; gap: 8px 18px; border-bottom: 1px solid var(--border); }
.rec:last-child { border-bottom: 0; }
.rec h4 { margin: 0; font-size: 14px; display: flex; gap: 8px; align-items: center; }
.rec .obs, .rec .act { font-size: 13px; color: var(--text-2); }
.rec .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 600; margin-right: 6px; }
.rec .gain { text-align: right; }
.rec .gain b { font-size: 18px; color: var(--pos); display: block; letter-spacing: -.01em; }
.slider { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; margin-bottom: 14px; font-size: 12.5px; color: var(--text-2); }
.slider input { grid-column: 1 / -1; width: 100%; accent-color: var(--accent); }
.slider b { color: var(--text); font-variant-numeric: tabular-nums; }
.milestones { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.milestone { background: var(--surface-2); border-radius: 8px; padding: 10px; }
.milestone .y { font-size: 11.5px; color: var(--text-3); }
.form-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.kbd { font-size: 11px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--text-3); }
.hr { height: 1px; background: var(--border); margin: 16px 0; }

@media (max-width: 1180px) { .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cols-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sim-grid { grid-template-columns: 1fr !important; }
  .card-b { overflow-x: auto; }
  .cols-4, .cols-3, .cols-2 { grid-template-columns: 1fr; } .span-2 { grid-column: auto; }
  .content { padding: 14px 14px calc(84px + env(safe-area-inset-bottom)); }
  .milestones { grid-template-columns: 1fr 1fr; }
}

.files-panel { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 10px; }
.files-panel summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 12.5px; font-weight: 500; user-select: none; }
.files-panel summary::-webkit-details-marker { display: none; }
.files-panel summary svg { transition: transform .15s; }
.files-panel[open] summary svg { transform: rotate(90deg); }
.files-panel > div { max-height: 360px; overflow: auto; margin-top: 6px; }

/* reminders */
.reminders { display: grid; gap: 8px; margin-bottom: 16px; }
.reminder { display: flex; gap: 12px; align-items: center; padding: 11px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); flex-wrap: wrap; }
.reminder.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, var(--border)); }
.reminder.info { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }
.reminder .r-ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--surface); flex: none; }

/* analysis run-time line */
.analysis-bar { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; padding: 8px 18px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.analysis-bar.stale { background: var(--warn-soft); }

/* statement coverage strip */
.cov-strip { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 6px; }
.cov { width: 17px; height: 17px; border-radius: 4px; background: var(--surface-3); font: 600 9px/17px var(--font); text-align: center; color: #fff; font-style: normal; }
.cov.ok { background: var(--pos); } .cov.miss { background: var(--neg); } .cov.na { background: transparent; border: 1px solid var(--border); }
.cov.now { background: transparent; border: 1.5px dashed var(--border-strong); color: var(--text-3); }

/* holdings: groups and emojis */
.emo { display: inline-block; width: 1.5em; font-size: 1.05em; text-align: center; margin-right: 4px; }
.emo.big { font-size: 1.25em; }
tr.grp td { background: var(--surface-2); cursor: pointer; padding: 9px 10px; border-bottom: 1px solid var(--border); }
tr.grp:hover td { background: var(--surface-3); }
tr.grp.total td { cursor: default; border-top: 1px solid var(--border-strong); }
tr.grp.total:hover td { background: var(--surface-2); }
.chev { display: inline-grid; place-items: center; transition: transform .15s; color: var(--text-3); }
.chev.open { transform: rotate(90deg); }
.grp-bar { width: 110px; height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.grp-bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

/* people: switcher, banner */
:root { --profile: #4f46e5; }
.sidebar { border-top: 3px solid var(--profile); }
.profile-switch { position: relative; margin: 2px 4px 10px; }
.profile-btn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; text-align: left; }
.profile-btn:hover { background: var(--surface-2); }
.profile-btn .pname { flex: 1; font-weight: 600; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-btn .pc { color: var(--text-3); transform: rotate(90deg); }
.avatar { display: inline-grid; place-items: center; border-radius: 50%; border: 1.5px solid var(--border-strong); flex: none; line-height: 1; }
.avatar.plain { border-color: transparent; background: var(--surface-2); }
.profile-menu { position: absolute; z-index: 70; left: 0; right: 0; top: calc(100% + 6px); min-width: 250px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; }
.pm-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 6px 8px 4px; }
.pm-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.profile-item { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; padding: 7px 8px; border-radius: 8px; cursor: pointer; text-align: left; }
.profile-item:hover, .profile-item.on { background: var(--surface-2); }
.pi-text { flex: 1; display: grid; line-height: 1.25; min-width: 0; } .pi-text .muted { font-size: 12px; }
.family-banner { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 16px; border: 1px solid color-mix(in srgb, var(--profile) 35%, var(--border)); border-radius: var(--radius); background: color-mix(in srgb, var(--profile) 9%, var(--surface)); }
.family-banner .fb-ic { font-size: 22px; } .fb-people { display: flex; gap: 6px; flex-wrap: wrap; }

/* who is it for? ticker */
.who { display: inline-flex; gap: 2px; padding: 2px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); }
.who-b { width: 26px; height: 24px; border: 1px solid transparent; border-radius: 99px; background: transparent; cursor: pointer; font-size: 13px; line-height: 1; filter: grayscale(1); opacity: .55; transition: .12s; padding: 0; }
.who-b:hover { opacity: 1; filter: none; background: var(--surface-3); }
.who-b.on { opacity: 1; filter: none; background: color-mix(in srgb, var(--who, var(--accent)) 22%, var(--surface)); border-color: var(--who, var(--accent)); }
.who-b.auto { border-style: dashed; background: color-mix(in srgb, var(--who, var(--accent)) 9%, var(--surface)); }

.ov-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.ov-row:hover { background: var(--surface-2); }

/* Keep the Amount column always visible: pin it to the right edge when a table is wider than its container */
.table-wrap td:last-child.r, .table-wrap th:last-child.r { position: sticky; right: 0; background: var(--surface); box-shadow: -8px 0 8px -8px rgba(0,0,0,.18); }
.table-wrap tr.selected td:last-child.r { background: var(--accent-soft); }

/* ---------- Money Flow animations (play-state is switched off with .no-motion or the OS "reduce motion" setting) */
.sk .sk-link { transition: stroke-opacity .18s; }
.sk .sk-node, .sk .sk-label { transition: opacity .18s; }
.sk-dots { stroke: #fff; stroke-opacity: .7; stroke-linecap: round; stroke-dasharray: .1 15; pointer-events: none; animation: sk-flow var(--v, 1.8s) linear infinite; transition: opacity .18s; }
.sk.focus .sk-link:not(.hl) { stroke-opacity: .05; }
.sk.focus .sk-link.hl { stroke-opacity: .55; }
.sk.focus .sk-dots:not(.hl) { opacity: 0; }
@keyframes sk-flow { to { stroke-dashoffset: -15.1; } }
.no-motion .sk-dots { display: none; }
@media (prefers-reduced-motion: reduce) { .sk-dots { display: none; } }
/* ---------- Money 3D */
.m3-stage { position: relative; height: clamp(440px, 66vh, 680px); background: radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--accent) 7%, var(--surface)), var(--surface)); }
.m3-hud { position: absolute; left: 16px; top: 14px; display: flex; gap: 18px; align-items: center; flex-wrap: wrap; pointer-events: none; }
.m3-date { font-weight: 650; font-size: 15px; padding: 5px 12px; border-radius: 99px; background: var(--surface); border: 1px solid var(--border); }
.m3-stat { display: flex; flex-direction: column; font-size: 11.5px; color: var(--text-3); line-height: 1.15; }
.m3-stat b { font-size: 17px; color: var(--text); font-variant-numeric: tabular-nums; }
.m3-legend { position: absolute; left: 16px; bottom: 12px; font-size: 12px; color: var(--text-2); pointer-events: none; }
.m3-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; width: 270px; flex: none; }
.m3-grid i { aspect-ratio: 1; border-radius: 50%; box-shadow: inset 0 -2px 0 rgba(0,0,0,.2), inset 0 2px 0 rgba(255,255,255,.35); animation: m3-pop .45s cubic-bezier(.3,1.5,.5,1) backwards; }
.m3-coins { display: flex; gap: 22px; flex-wrap: wrap; align-items: center; }
.m3-keys { display: grid; gap: 6px; font-size: 13px; flex: 1; min-width: 190px; }
.m3-keys > div { display: flex; align-items: center; gap: 8px; }
.m3-keys i { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.m3-keys span { flex: 1; } .m3-keys em { font-style: normal; color: var(--text-3); width: 72px; text-align: right; }
.m3-strip { display: flex; height: 44px; border-radius: 10px; overflow: hidden; gap: 2px; }
.m3-strip > div { display: grid; place-items: center; color: #fff; font-weight: 650; font-size: 13px; min-width: 2px; }
.m3-days { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-3); margin-top: 4px; }
@keyframes m3-pop { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .m3-grid i { animation: none; } }

/* ---------- Cut Game */
.cg-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.cg-chip { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 12.5px; cursor: pointer; }
.cg-chip i { width: 10px; height: 10px; border-radius: 50%; }
.cg-chip b { font-variant-numeric: tabular-nums; }
.cg-chip.s1 { border-style: dashed; } .cg-chip.s2 { opacity: .5; text-decoration: line-through; }
.cg-chip:hover { background: var(--surface-2); }
.cg-row { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.cg-bar { flex: 1; height: 10px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.cg-bar i { display: block; height: 100%; border-radius: 99px; transition: width .35s; }

/* ---------- Money Lab tabs + Invest Plan */
.lab-tabs { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.lab-tab { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text-2); cursor: pointer; font: inherit; text-align: left; }
.lab-tab span { display: flex; flex-direction: column; line-height: 1.2; } .lab-tab b { font-size: 14px; color: var(--text); } .lab-tab small { font-size: 11.5px; color: var(--text-3); }
.lab-tab:hover { background: var(--surface-2); } .lab-tab.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }
.cg-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-3); }
.live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--pos); margin-right: 4px; animation: ip-pulse 1.8s ease-in-out infinite; }
@keyframes ip-pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }
.ip-action { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; }
.ip-n { width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.ip-bar { position: relative; display: flex; height: 36px; border-radius: 10px; overflow: visible; gap: 2px; }
.ip-bar > div { display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 650; min-width: 2px; }
.ip-bar > div:first-child { border-radius: 10px 0 0 10px; } .ip-bar > div:last-of-type { border-radius: 0 10px 10px 0; }
.ip-mark { position: absolute; top: -6px; bottom: -6px; width: 0; border-left: 3px dashed var(--text); pointer-events: auto; }
.ip-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--text-2); margin-top: 10px; }
.ip-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; } .ip-legend i.mk { width: 0; height: 12px; border-radius: 0; border-left: 3px dashed var(--text); }
.ip-track { position: relative; height: 12px; border-radius: 99px; background: var(--surface-3); margin: 8px 0 4px; }
.ip-track i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 99px; } .ip-track em { position: absolute; top: -4px; bottom: -4px; width: 0; border-left: 3px solid var(--text); }
.ip-mini { display: flex; height: 10px; border-radius: 99px; overflow: hidden; gap: 1px; }
.warn-t { color: var(--warn); }

/* ---------- exchange rates (sidebar) */
.lab-groups { display: flex; flex-wrap: wrap; gap: 6px 28px; margin-bottom: 14px; } .lab-groups .lab-tabs { margin-bottom: 0; }
.lab-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin: 0 0 6px 2px; font-weight: 650; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; }
.ip-seg { cursor: pointer; transition: filter .15s; } .ip-seg:hover, .ip-seg:focus-visible { filter: brightness(1.12) saturate(1.1); outline: none; }
.ip-click { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; } .ip-click:hover { color: var(--text); }
.kpi-click { cursor: pointer; } .kpi-click:hover { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.card-h .chev { flex: none; margin-left: -2px; }

/* ---------- drag to reorder tabs */
.nav-item[draggable="true"], .lab-tab[draggable="true"] { cursor: grab; } .nav-item.dragging, .lab-tab.dragging { opacity: .4; }
.nav-item { position: relative; } .lab-tab { position: relative; }
.nav-item.drop-before::before, .nav-item.drop-after::after { content: ''; position: absolute; left: 6px; right: 6px; height: 3px; border-radius: 3px; background: var(--accent); }
.nav-item.drop-before::before { top: -2px; } .nav-item.drop-after::after { bottom: -2px; }
.lab-tab.drop-before::before, .lab-tab.drop-after::after { content: ''; position: absolute; top: 4px; bottom: 4px; width: 3px; border-radius: 3px; background: var(--accent); }
.lab-tab.drop-before::before { left: -7px; } .lab-tab.drop-after::after { right: -7px; }
.nav-reset { margin: 6px 12px 0; padding: 4px 8px; border: 0; background: transparent; color: var(--text-3); font: inherit; font-size: 12px; cursor: pointer; text-align: left; } .nav-reset:hover { color: var(--text); }
.hide-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 9px 14px; margin-bottom: 12px; border-style: dashed; background: var(--surface-2); font-size: 13px; }

/* ---------- Transactions filters: what it is (adds up to All) / narrow down (overlaps) */
.tx-filters { display: grid; gap: 6px; margin-bottom: 12px; }
.tx-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; } .tx-row .toggles { flex: 1; align-items: center; }
.tx-lab { width: 104px; flex: none; font-size: 12px; font-weight: 650; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.tx-eq { margin-left: 114px; font-size: 12.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.chip-eq { color: var(--text-3); font-weight: 600; padding: 0 1px; align-self: center; }
.chip-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.sortbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sortbar .chip { cursor: pointer; }

/* ---------- Savings Radar and deals */
.rd-card { padding: 16px 18px; } .rd-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 10px; } .rd-emo { font-size: 26px; line-height: 1; }
.rd-save { text-align: right; white-space: nowrap; } .rd-save b { font-size: 18px; } .rd-save .badge { margin-top: 4px; }
.rd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; }
.rd-offer { border: 1px solid var(--border); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; background: var(--surface); } .rd-offer.hl { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.rd-ph { display: flex; justify-content: space-between; align-items: center; gap: 8px; } .rd-feat { margin: 8px 0 12px; padding-left: 18px; font-size: 12.5px; color: var(--text-2); flex: 1; } .rd-offer .btn { align-self: flex-start; text-decoration: none; }
.rd-disc { margin-top: 14px; font-size: 12.5px; }
.rd-sum { cursor: pointer; padding: 14px 18px; } .rd-sum .sub { color: var(--text-3); font-size: 12.5px; }
.rd-tbl th { text-align: left; font-size: 11.5px; } .rd-tbl td { vertical-align: top; } .rd-tbl .rd-feat { margin: 0 0 4px; flex: none; } .rd-tbl .btn { text-decoration: none; white-space: nowrap; }

/* sign-in screen (multi-user mode) */
.auth-screen { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 24px 16px; text-align: center; }
.auth-screen h1 { margin: 4px 0 0; }
.auth-slot { margin-top: 16px; min-height: 120px; }
.account-slot { padding: 6px 10px; }

/* landing page (signed-out visitors, multi-user mode) */
.landing { max-width: 1120px; margin: 0 auto; padding: 0 20px 32px; }
html:has(.landing) { scroll-behavior: smooth; }
.lp-nav { display: flex; align-items: center; gap: 24px; padding: 18px 0; }
.lp-links { display: flex; gap: 22px; margin-left: 12px; flex: 1; }
.lp-links a { color: var(--text-2); text-decoration: none; font-size: 14px; font-weight: 500; }
.lp-links a:hover { color: var(--text); }
.lp-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn.lg { height: 44px; padding: 0 22px; font-size: 15px; }
.lp-hero { display: grid; grid-template-columns: 1.15fr 1fr; gap: 40px; align-items: center; padding: 56px 0 64px; }
.lp-pill { display: inline-block; padding: 5px 12px; border-radius: 99px; background: var(--accent-soft); color: var(--accent-text); font-size: 13px; font-weight: 600; margin-bottom: 18px; }
.lp-hero h1 { font-size: clamp(34px, 5.4vw, 56px); line-height: 1.05; letter-spacing: -0.03em; margin: 0 0 18px; }
.lp-lead { font-size: 18px; line-height: 1.55; color: var(--text-2); margin: 0 0 26px; max-width: 540px; }
.lp-note { font-size: 13px; color: var(--text-3); margin: 14px 0 0; }
.lp-mock { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 22px; }
.lp-mock-tag { position: absolute; top: 12px; right: 14px; font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.lp-mock-label { color: var(--text-3); font-size: 13px; }
.lp-mock-num { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; margin: 2px 0; }
.lp-mock-delta { color: var(--pos); font-size: 13px; font-weight: 600; }
.lp-spark { width: 100%; height: 90px; margin: 14px 0; display: block; }
.lp-ai { background: var(--accent-soft); color: var(--text); border-radius: 12px; padding: 12px 14px; font-size: 14px; line-height: 1.45; }
.lp-ai-badge { display: block; color: var(--accent-text); font-weight: 700; font-size: 12px; margin-bottom: 4px; }
.lp-section { padding: 48px 0; text-align: center; }
.lp-section h2, .lp-final h2 { font-size: clamp(26px, 3.6vw, 36px); letter-spacing: -0.02em; margin: 0 0 10px; }
.lp-sub { color: var(--text-2); font-size: 17px; margin: 0 0 28px; }
.lp-section h2 + .lp-grid3, .lp-section h2 + .lp-steps, .lp-section h2 + .lp-privacy { margin-top: 28px; }
.lp-grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; text-align: left; }
.lp-card { padding: 22px; }
.lp-card h3 { margin: 10px 0 6px; font-size: 17px; }
.lp-card p { margin: 0; font-size: 14.5px; line-height: 1.55; }
.lp-emoji { font-size: 28px; }
.lp-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 24px; }
.lp-num { width: 40px; height: 40px; border-radius: 50%; background: var(--text); color: var(--bg); display: grid; place-items: center; font-weight: 700; margin: 0 auto 10px; }
.lp-step h3 { margin: 0 0 4px; }
.lp-step p { margin: 0; }
.lp-privacy { max-width: 720px; margin: 0 auto; padding: 8px 26px; text-align: left; }
.lp-privacy li { margin: 14px 0; line-height: 1.55; }
.lp-final { text-align: center; margin: 32px 0; padding: 48px 20px; border-radius: 20px; background: var(--accent-soft); }
.lp-final h2 { margin-bottom: 20px; }
.lp-foot { text-align: center; margin-top: 32px; font-size: 13px; }
@media (max-width: 860px) { .lp-hero { grid-template-columns: 1fr; padding-top: 28px; } .lp-links { display: none; } .lp-nav { justify-content: space-between; } }
.lp-invite { background: var(--accent-soft); color: var(--text); border: 1px solid var(--border); border-radius: 12px; padding: 14px 18px; margin: 8px 0 0; text-align: center; font-size: 15px; }

/* ---------- phones: bottom tabs + slide-in menu ---------- */
.tabbar, .scrim { display: none; }
@media (max-width: 860px) {
  body.no-scroll { overflow: hidden; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: var(--surface);
    border-top: 1px solid var(--border); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; border: 0; background: none; color: var(--text-3);
    font: inherit; font-size: 11px; font-weight: 500; border-radius: 10px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .tab.active { color: var(--accent-text); background: var(--accent-soft); }
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: min(86vw, 320px); height: 100dvh; z-index: 80; overflow-y: auto; overscroll-behavior: contain;
    padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom)); border-right: 1px solid var(--border); box-shadow: var(--shadow-lg);
    transform: translateX(-104%); transition: transform .22s ease; visibility: hidden; }
  .app.menu-open .sidebar { transform: none; visibility: visible; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.45); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .app.menu-open .scrim { opacity: 1; pointer-events: auto; }
  .nav-item { padding: 11px 12px; font-size: 15px; }
  .nav-item svg { width: 18px; height: 18px; }
  .sidebar-foot .nav-item { padding: 11px 12px; }
  .profile-menu { min-width: 0; }
  /* top bar: one tidy row, filters scroll sideways instead of wrapping into a wall */
  .topbar { padding: 10px 14px; gap: 8px; }
  .topbar h1 { font-size: 17px; margin: 0 auto 0 0; }
  .topbar .spacer { display: none; }
  .topbar .select { max-width: 46vw; }
  .topbar .toggles { overflow-x: auto; flex-wrap: nowrap; max-width: 100%; padding-bottom: 4px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .topbar .toggles::-webkit-scrollbar { display: none; }
  .topbar .toggles > * { flex: none; }
  .btn, .select, .input, .chip { min-height: 38px; }
  /* dialogs become full-height sheets */
  .modal, .modal.narrow { top: 0; left: 0; transform: none; width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; border: 0; animation: none; }
  .modal-h { padding: calc(12px + env(safe-area-inset-top)) 14px 12px; } .modal-b { padding: 14px; } .modal-f { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); flex-wrap: wrap; }
  .drawer { width: 100vw; border-left: 0; } .drawer-h { padding: calc(12px + env(safe-area-inset-top)) 14px 12px; }
  .family-banner { padding: 10px 12px; }
  .hide-m { display: none !important; }   /* actions that already live in the bottom tabs or inside the page */
  .topbar > .select { flex: 1 1 0; min-width: 0; max-width: none; }
  .topbar > h1 { flex: 1 0 100%; }
  /* filter rows: label above its chips instead of a side column */
  .tx-row { flex-direction: column; align-items: stretch; gap: 4px; }
  .tx-lab { width: auto; }
  .tx-row .toggles { flex-wrap: wrap; }
  /* tab strips scroll sideways */
  .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; } .seg::-webkit-scrollbar { display: none; }
  .seg button { white-space: nowrap; flex: none; padding: 6px 12px; }
  /* wide tables: collapse the secondary columns (the <colgroup> keeps group-row colspans valid) */
  .tbl-holdings, .tbl-snaps { width: 100%; table-layout: fixed; }
  col.c-m { visibility: collapse; width: 0; }
  col.cw-104 { width: 104px; } col.cw-54 { width: 54px; } col.cw-116 { width: 100px; } col.cw-96 { width: 96px; } col.cw-46 { width: 44px; }
  .tbl-holdings td { overflow: hidden; text-overflow: ellipsis; }
  .tbl-snaps td { white-space: normal; overflow-wrap: anywhere; }
}

/* ---------- transactions on phones: one card per transaction, filters behind a button ---------- */
.tx-ftoggle, .tx-bulk-toggle { display: none; }
@media (max-width: 860px) {
  .tx-ftoggle { display: inline-flex; align-items: center; gap: 6px; flex: none; }
  .tx-ftoggle.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
  .form-row #tx-search { flex: 1 1 0; min-width: 0 !important; }
  [data-txf="0"] .tx-extra { display: none !important; }
  .tx-table, .tx-table tbody { display: block; width: 100%; }
  .tx-table thead { display: none; }
  .tx-table tr.txr { display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "desc desc amt" "date acct acct" "cat cat who";
    column-gap: 10px; row-gap: 6px; align-items: center; padding: 12px 6px; border-bottom: 1px solid var(--border); }
  .tx-table tr.txr.has-chk { grid-template-columns: 34px auto 1fr auto; grid-template-areas: "chk desc desc amt" "chk date acct acct" "chk cat cat who"; }
  .tx-table tr.txr.selected { background: var(--accent-soft); border-radius: 10px; }
  .tx-table td { display: block; padding: 0; border: 0; min-width: 0; width: auto !important; }
  .tx-chk { grid-area: chk; align-self: start; } .tx-chk input { width: 22px; height: 22px; margin: 2px 0 0; }
  .tx-desc { grid-area: desc; } .tx-desc .desc { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: none; }
  .tx-desc .desc-sub { display: none; }
  .tx-amt { grid-area: amt; text-align: right; font-size: 15px; font-weight: 650; white-space: nowrap; }
  .tx-date { grid-area: date; font-size: 12.5px; }
  .tx-acct { grid-area: acct; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: none !important; }
  .tx-cat { grid-area: cat; } .tx-cat .cat-select, .tx-cat select { width: 100%; max-width: none; min-height: 36px; }
  .tx-who { grid-area: who; justify-self: end; }
  .topbar { position: static; }   /* three rows of filters must not stay stuck on a small screen */
  .tx-eq { margin-left: 0 !important; padding-left: 0 !important; }
  /* ticked rows: the bulk actions stay reachable above the tab bar */
  .tx-bulk { position: fixed; left: 10px; right: 10px; bottom: calc(66px + env(safe-area-inset-bottom)); z-index: 45; max-height: 42vh; overflow-y: auto;
    margin: 0 !important; box-shadow: var(--shadow-lg); }
  .tx-bulk-toggle { display: inline-flex; }
  .tx-bulk:not(.more) .tx-bulk-more { display: none; }
  .tx-bulk { padding: 8px 10px !important; gap: 6px !important; max-height: 50vh; }
}

/* ---------- uploads ---------- */
.up-row { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; cursor: pointer; font: inherit; color: inherit; text-align: left; padding: 10px 2px; }
.up-row:hover { background: var(--surface-2); }
.up-badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.finding { display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px; border-radius: 10px; font-size: 13.5px; line-height: 1.5; border: 1px solid var(--border); background: var(--surface-2); }
.finding svg { flex: none; margin-top: 2px; }
.finding.error { background: var(--neg-soft); border-color: color-mix(in srgb, var(--neg) 35%, var(--border)); }
.finding.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, var(--border)); }
.tx-table tr.anomaly td { background: color-mix(in srgb, var(--warn-soft) 70%, transparent); }
.tx-flags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }
.btn.danger { color: var(--neg); }
@media (max-width: 860px) { .up-row { flex-wrap: wrap; } .up-badges { justify-content: flex-start; width: 100%; padding-left: 28px; } }
@media (max-width: 860px) {
  /* inspector header: the title gets its own line, the sort and action buttons wrap below it */
  .drawer-h { flex-wrap: wrap; row-gap: 8px; }
  .drawer-h > div:first-child { flex: 1 1 calc(100% - 56px); min-width: 0; overflow-wrap: anywhere; }
  .drawer-h > button.icon { order: 1; }
  .drawer-h > .seg, .drawer-h > .btn.sm { order: 2; }
}
@media (max-width: 860px) {
  .tx-table tr.anomaly td { background: none; }
  .tx-table tr.anomaly { background: color-mix(in srgb, var(--warn-soft) 80%, transparent); border-radius: 10px; }
}

/* ---------- grouped menu ---------- */
.nav-group { margin-bottom: 2px; }
.nav-group-h { display: flex; align-items: center; gap: 6px; width: 100%; background: none; border: 0; cursor: pointer; text-align: left; font: inherit; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 12px 10px 4px; }
.nav-group-h:hover { color: var(--text-2); }
.nav-group-h svg { transition: transform .15s; flex: none; }
.nav-group:not(.closed) .nav-group-h svg { transform: rotate(90deg); }   /* the chevron points right: down when the group is open */
.nav-items { display: flex; flex-direction: column; gap: 2px; }
@media (max-width: 860px) { .nav-group-h { padding: 16px 12px 6px; font-size: 12px; } }
@media (min-width: 861px) { .sidebar { overflow-y: auto; } }   /* a short screen scrolls the menu instead of cutting it off */

/* ---------- Savings Radar menu icon: just a coloured gem, the row itself looks like any other ---------- */

.rd-hero { padding: 22px 24px; display: grid; gap: 16px; border-color: color-mix(in srgb, #f59e0b 38%, var(--border));
  background: linear-gradient(135deg, color-mix(in srgb, #f59e0b 13%, var(--surface)), color-mix(in srgb, #10b981 11%, var(--surface))); }
.rd-eyebrow { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--warn); }
.rd-headline { font-size: clamp(24px, 4.2vw, 36px); line-height: 1.15; letter-spacing: -.02em; margin: 8px 0 6px; }
.rd-amount { color: var(--pos); white-space: nowrap; }
.rd-sub { margin: 0; color: var(--text-2); font-size: 15px; max-width: 640px; line-height: 1.5; }
.rd-cta, .rd-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.rd-cta { margin-top: 16px; }
.btn.rd-primary { background: var(--pos); color: #fff; border-color: var(--pos); height: 44px; padding: 0 20px; font-size: 15px; font-weight: 650; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn.rd-primary:hover { filter: brightness(1.06); }
.rd-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.rd-stat { background: color-mix(in srgb, var(--surface) 82%, transparent); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; }
.rd-quick { display: flex; gap: 8px; flex-wrap: wrap; }
.rd-qw { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); cursor: pointer; font: inherit; color: var(--text); text-align: left; }
.rd-qw:hover { border-color: var(--pos); } .rd-qw-t { font-size: 13.5px; }
.rd-best { border: 1.5px solid color-mix(in srgb, var(--pos) 45%, var(--border)); background: color-mix(in srgb, var(--pos-soft) 55%, var(--surface)); border-radius: 14px; padding: 14px 16px; margin-top: 12px; }
.rd-best-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.rd-best-tag { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--pos); }
.rd-spons { margin-left: auto; font-size: 11px; color: var(--text-3); border: 1px solid var(--border); border-radius: 6px; padding: 1px 7px; }
.rd-best-name { font-size: 16px; } .rd-best .rd-feat { margin: 6px 0 10px; }
.rd-why { margin-top: 10px; } .rd-why summary { cursor: pointer; font-size: 12.5px; color: var(--text-2); }
.rd-more { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 16px 20px; }
@media (max-width: 860px) {
  .rd-hero { padding: 18px 16px; } .rd-stats { gap: 6px; } .rd-stat { padding: 8px 10px; } .rd-stat .num { font-size: 15px !important; } .rd-stat .kpi-label { font-size: 10.5px; line-height: 1.25; } .rd-save { text-align: left; } .rd-head { flex-wrap: wrap; }
  .rd-actions .btn { flex: 1 1 100%; justify-content: center; } .btn.rd-primary { width: 100%; justify-content: center; } .rd-spons { margin-left: 0; }
}
.rd-qw b { white-space: nowrap; }

/* ---------- Train de vie ---------- */
.tv-hero { padding: 22px 24px; display: grid; gap: 10px; background: linear-gradient(135deg, color-mix(in srgb, #7c3aed 11%, var(--surface)), color-mix(in srgb, #0ea5e9 9%, var(--surface))); border-color: color-mix(in srgb, #7c3aed 28%, var(--border)); }
.tv-eyebrow { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: #7c3aed; }
.tv-headline { font-size: clamp(24px, 4vw, 34px); line-height: 1.15; letter-spacing: -.02em; margin: 4px 0 0; }
.tv-speed { color: #7c3aed; white-space: nowrap; } .tv-sub { margin: 0; color: var(--text-2); font-size: 15px; line-height: 1.5; max-width: 760px; }
.tv-chips { display: flex; gap: 8px; flex-wrap: wrap; } .tv-gap { margin: 0; font-size: 14px; color: var(--text-2); }
.tv-race { margin-top: 16px; padding: 0; overflow: hidden; } .tv-canvas { display: block; width: 100%; background: #cfe6f5; }
.tv-controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 12px 14px; border-top: 1px solid var(--border); }
.tv-tbl td, .tv-tbl th { white-space: nowrap; } .tv-tbl td:nth-child(2) { white-space: normal; } .tv-tbl tr.tv-you td { background: color-mix(in srgb, #7c3aed 10%, transparent); }
.tv-fields { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; } .tv-whatif { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; } .tv-whatif input[type=range] { flex: 1 1 180px; min-width: 140px; }
@media (max-width: 860px) { .tv-hero { padding: 18px 16px; } .tv-controls .seg { max-width: 100%; } }
.tv-tbl .desc-sub { white-space: normal; overflow: visible; text-overflow: clip; max-width: 46ch; }
@media (max-width: 860px) { .tv-tbl td:nth-child(2) { min-width: 150px; } .tv-tbl .desc-sub { max-width: 30ch; } }
.tv-tbl td:last-child.r, .tv-tbl th:last-child.r { position: static; box-shadow: none; background: transparent; }
@media (max-width: 860px) { .tv-tbl th:nth-child(4), .tv-tbl td:nth-child(4) { display: none; } }


/* ---- demo mode strip */
.demo-bar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 16px; background: #fef3c7; color: #78350f; border-bottom: 1px solid #f59e0b; font-size: 13.5px; }
.demo-bar .btn { background: #fff; color: #78350f; border-color: #f59e0b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .demo-bar { background: #3b2a0a; color: #fde68a; border-color: #b45309; } :root:not([data-theme="light"]) .demo-bar .btn { background: transparent; color: #fde68a; } }
:root[data-theme="dark"] .demo-bar { background: #3b2a0a; color: #fde68a; border-color: #b45309; } :root[data-theme="dark"] .demo-bar .btn { background: transparent; color: #fde68a; }

/* Internal tabs of a section (Spending, Patriview AI, ...) */
.subtabs { display: flex; width: fit-content; max-width: 100%; margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.subtabs::-webkit-scrollbar { display: none; }
.subtabs button { white-space: nowrap; flex: none; padding: 6px 14px; font-size: 13px; }
