/*
 * Tradez.eu — v5 design system
 * Scope: every rule is nested under `.app` so legacy pages are untouched.
 * Source of truth: mockups/design-system-v5.md + mockups/pages_v5.html
 */

:root {
  --font-sans:  'Inter', system-ui, sans-serif;
  --font-serif: 'Fraunces', Georgia, serif;
  --font-mono:  'JetBrains Mono', ui-monospace, monospace;

  /* z-index scale (see §3 of design-system-v5.md) */
  --z-sticky: 10;
  --z-topbar: 100;
  --z-popover: 200;
  --z-modal-bg: 900;
  --z-modal: 1000;
}

/* Reset — the v5 shell paints the full viewport itself */
html { scrollbar-gutter: stable; }
html, body { margin: 0; padding: 0; }
body:has(> .app) { background: #f5f1e8; }
body:has(> .app.theme-dark) { background: #16181a; }

/* ===================== APP SHELL + TOKENS ===================== */
.app {
  font-family: var(--font-sans);
  background: var(--bg); color: var(--text);
  font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column;
  min-height: 100vh;
}
.app *, .app *::before, .app *::after { box-sizing: border-box; }

.app.theme-light {
  --bg: #f5f1e8; --panel: #faf7ef; --panel-2: #ede7d7;
  --rule: #e4ddc9; --rule-strong: #c8bfa6;
  --text: #1a1814; --text-2: #3a3630; --muted: #7a756a;
  --accent: #b8680d; --accent-hover: #96540a;
  --pos: #2e5e3f; --pos-soft: #7cb08f;
  --neg: #a8351a;
  --info: #2f5aa8; --info-soft: #8caad0;
  --pos-bg: rgba(46,94,63,0.10);
  --neg-bg: rgba(168,53,26,0.09);
  --info-bg: rgba(47,90,168,0.10);
  --accent-bg: rgba(184,104,13,0.10);
  --topbar-bg: #efe9d7;
}
.app.theme-dark {
  --bg: #16181a; --panel: #1c1f22; --panel-2: #242830;
  --rule: #262a2f; --rule-strong: #3a3f46;
  --text: #e6e1d2; --text-2: #c2bdae; --muted: #8a8579;
  --accent: #d89b3a; --accent-hover: #e9b058;
  --pos: #7cc598; --pos-soft: #4e8766;
  --neg: #e08b73;
  --info: #89a8d4; --info-soft: #4c6689;
  --pos-bg: rgba(124,197,152,0.10);
  --neg-bg: rgba(224,139,115,0.10);
  --info-bg: rgba(137,168,212,0.12);
  --accent-bg: rgba(216,155,58,0.10);
  --topbar-bg: #1a1d20;
}

/* Focus (one global rule) */
.app :focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ===================== TOPBAR ===================== */
.app .topbar {
  position: sticky; top: 0; z-index: var(--z-topbar); background: var(--topbar-bg);
  border-bottom: 1px solid var(--rule);
}
.app .topbar .topbar-inner {
  display: grid; grid-template-columns: auto 1fr auto;
  align-items: center; gap: 32px; padding: 0 24px; height: 56px;
  max-width: 1440px; width: 100%; margin: 0 auto;
}
.app .topbar .brand {
  font-family: var(--font-serif); font-weight: 700; font-size: 20px;
  letter-spacing: -0.02em; color: var(--text); text-decoration: none;
}
.app .topbar .brand .dot { color: var(--accent); }
.app .topbar .nav { display: flex; align-items: center; gap: 2px; }
.app .topbar .nav a, .app .topbar .nav button {
  font-family: var(--font-sans); font-size: 14px; color: var(--text-2);
  text-decoration: none; background: transparent; border: none; cursor: pointer;
  padding: 8px 14px; border-radius: 6px;
  display: inline-flex; align-items: center; gap: 8px; position: relative;
}
.app .topbar .nav a:hover, .app .topbar .nav button:hover { background: var(--panel); color: var(--text); }
.app .topbar .nav a.active { color: var(--text); font-weight: 500; }
.app .topbar .nav a.active::after {
  content: ''; position: absolute; left: 14px; right: 14px; bottom: -1px;
  height: 2px; background: var(--accent); border-radius: 1px;
}
.app .topbar .nav .badge {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 1px;
  background: var(--accent-bg); color: var(--accent); padding: 1px 6px; border-radius: 10px;
}
.app .topbar .nav .badge.d-none { display: none; }
.app .topbar .nav .caret {
  display: inline-block; width: 7px; height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  color: var(--muted);
  transform: rotate(45deg) translate(-2px, -2px);
  margin-left: 2px;
  transition: transform 0.15s ease;
}
.app .nav-dd.open > [data-nav-dd-toggle] .caret {
  transform: rotate(-135deg) translate(-2px, -2px);
}

/* Nav dropdowns (Play / Learn / avatar menu) */
.app .nav-dd { position: relative; display: inline-flex; align-items: center; }
.app .nav-dd > .nav-pop {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: var(--z-popover);
  min-width: 200px; background: var(--panel); border: 1px solid var(--rule);
  border-radius: 8px; padding: 6px;
  box-shadow: 0 12px 32px rgba(0,0,0,.18), 0 2px 6px rgba(0,0,0,.08);
  display: none; flex-direction: column; gap: 1px;
}
.app.theme-dark .nav-dd > .nav-pop {
  box-shadow: 0 12px 36px rgba(0,0,0,.55), 0 2px 8px rgba(0,0,0,.35);
  border-color: var(--rule-strong);
}
.app .nav-dd.open > .nav-pop { display: flex; }
.app .nav-dd > .nav-pop.nav-pop-right { left: auto; right: 0; }
.app .nav-dd > .nav-pop a {
  font-family: var(--font-sans); font-size: 13px; color: var(--text-2);
  text-decoration: none; padding: 7px 10px; border-radius: 5px;
  display: block; white-space: nowrap;
}
.app .nav-dd > .nav-pop a:hover { background: var(--panel-2); color: var(--text); }

/* Two-column sectioned variant (Play / Learn) */
.app .nav-dd > .nav-pop.nav-pop-cols {
  display: none; flex-direction: row; gap: 8px; padding: 14px;
  min-width: 380px;
}
.app .nav-dd.open > .nav-pop.nav-pop-cols { display: flex; }
.app .nav-dd > .nav-pop.nav-pop-cols.cols-3 {
  min-width: 560px;
  /* Center on the label text, not the button (the chevron adds width on
     the right, so shifting right by a few px aligns the pop visually). */
  left: calc(50% + 8px); right: auto; transform: translateX(-50%);
}
.app .nav-dd > .nav-pop-cols .nav-pop-col {
  display: flex; flex-direction: column; gap: 2px; min-width: 160px; flex: 1;
}
.app .nav-dd > .nav-pop-cols .nav-pop-head {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--muted);
  padding: 0 10px 6px; margin-bottom: 2px;
}
.app .nav-dd > .nav-pop-cols .nav-pop-title {
  display: block; font-size: 13px; font-weight: 500; color: var(--text);
}
.app .nav-dd > .nav-pop-cols .nav-pop-sub {
  display: block; font-size: 11px; color: var(--muted); margin-top: 1px;
}
.app .nav-dd > .nav-pop-cols a { padding: 8px 10px; }
.app .nav-dd > .nav-pop-cols a:hover .nav-pop-title { color: var(--accent); }
.app .topbar .right { display: flex; align-items: center; gap: 12px; }
.app .topbar .search-btn {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--rule); border-radius: 6px;
  padding: 5px 10px 5px 12px; cursor: pointer;
  font-family: var(--font-sans); font-size: 13px; color: var(--muted); min-width: 220px;
}
.app .topbar .search-btn .kbd {
  margin-left: auto; font-family: var(--font-mono); font-size: 10px;
  background: var(--panel-2); color: var(--muted);
  padding: 1px 6px; border-radius: 3px; border: 1px solid var(--rule);
}
.app .topbar .cash-chip {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 6px 12px; border-radius: 6px; background: var(--accent-bg);
}
.app .topbar .cash-chip[title] { cursor: help; }
.app .topbar .cash-chip .v {
  font-family: var(--font-serif); font-weight: 600; font-size: 15px;
  color: var(--accent); font-variant-numeric: tabular-nums;
}
.app .topbar .cash-chip .d { font-family: var(--font-mono); font-size: 10px; color: var(--pos); }
.app .topbar .avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--panel-2);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-serif); font-weight: 600; font-size: 13px; color: var(--text);
  border: 0; padding: 0; cursor: pointer; text-decoration: none;
}

/* Notification bell */
.app .topbar .bell,
.app .m-topbar .bell {
  position: relative; width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel-2); color: var(--text-2);
  border: 1px solid var(--rule); cursor: pointer;
  padding: 0; line-height: 1;
  transition: background 0.15s ease, color 0.15s ease;
}
.app .topbar .bell:hover,
.app .m-topbar .bell:hover { background: var(--panel); color: var(--accent); }
.app .topbar .bell .bell-icon,
.app .m-topbar .bell .bell-icon { display: inline-flex; }
.app .topbar .bell .bell-dot,
.app .m-topbar .bell .bell-dot {
  position: absolute; top: 3px; right: 3px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--topbar-bg);
}
.app .topbar .bell .bell-dot.d-none,
.app .m-topbar .bell .bell-dot.d-none { display: none; }

/* Mobile inbox shortcut (mirrors the .bell sizing so the topbar reads as a
   clean row of round chips). Renders only inside .m-topbar; ignored on
   desktop where the dedicated nav link + theme toggle live instead. */
.app .m-topbar .m-inbox {
  position: relative; width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel-2); color: var(--text-2);
  border: 1px solid var(--rule);
  text-decoration: none; line-height: 1;
  transition: background 0.15s ease, color 0.15s ease;
}
.app .m-topbar .m-inbox:hover { background: var(--panel); color: var(--accent); }
.app .m-topbar .m-inbox .m-inbox-icon { display: inline-flex; }
.app .m-topbar .m-inbox .m-inbox-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 16px; height: 16px; padding: 0 4px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--accent-text, #fff);
  border: 2px solid var(--topbar-bg); border-radius: 9px;
  font-family: var(--font-mono); font-size: 9px; font-weight: 700;
  line-height: 1;
}
.app .m-topbar .m-inbox .m-inbox-badge.d-none { display: none; }

/* Notifications popover */
.app .nav-dd > .nav-pop.nav-pop-notif {
  min-width: 380px; padding: 0; flex-direction: column; gap: 0;
  overflow: hidden;
}
.app .nav-dd.open > .nav-pop.nav-pop-notif { display: flex; }
.app .nav-pop-notif-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; border-bottom: 1px solid var(--rule);
}
.app .nav-pop-notif-head h3 {
  font-family: var(--font-serif); font-weight: 600; font-size: 14px;
  margin: 0; color: var(--text);
}
.app .nav-pop-notif-head button {
  font-family: var(--font-sans); font-size: 12px; color: var(--muted);
  background: transparent; border: none; cursor: pointer; padding: 2px 6px;
}
.app .nav-pop-notif-head button:hover { color: var(--accent); }
.app .nav-pop-notif-list {
  max-height: 380px; overflow-y: auto; padding: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--rule-strong) transparent;
}
.app .nav-pop-notif-list::-webkit-scrollbar { width: 8px; }
.app .nav-pop-notif-list::-webkit-scrollbar-track { background: transparent; }
.app .nav-pop-notif-list::-webkit-scrollbar-thumb {
  background: var(--rule-strong); border-radius: 4px;
  border: 2px solid var(--panel);
}
.app .nav-pop-notif-list::-webkit-scrollbar-thumb:hover { background: var(--muted); }
.app .nav-dd > .nav-pop.nav-pop-notif .nav-pop-notif-item {
  display: block; text-decoration: none;
  padding: 10px 14px 10px 30px;
  border-bottom: 1px solid var(--rule);
  color: var(--text-2); position: relative;
  border-radius: 0; white-space: normal;
}
.app .nav-dd > .nav-pop.nav-pop-notif .nav-pop-notif-item:last-child { border-bottom: none; }
.app .nav-dd > .nav-pop.nav-pop-notif .nav-pop-notif-item:hover { background: var(--panel-2); }
.app .nav-dd > .nav-pop.nav-pop-notif .nav-pop-notif-item.unread::before {
  content: ''; position: absolute; left: 12px; top: 16px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}
.app .nav-pop-notif-item .notif-title {
  display: block; font-size: 13px; font-weight: 500;
  color: var(--text); margin-bottom: 2px;
}
.app .nav-pop-notif-item .notif-content {
  display: block; font-size: 12px; color: var(--text-2); line-height: 1.4;
}
.app .nav-pop-notif-item .notif-time {
  display: block; font-family: var(--font-mono); font-size: 10px;
  color: var(--muted); letter-spacing: 0.5px; margin-top: 4px;
  text-transform: lowercase;
}
/* Count badge on a collapsed group ("Bill overdue · Battery (4)"). */
.app .nav-pop-notif-item .notif-count {
  display: inline-block; min-width: 16px; padding: 0 5px; margin-left: 4px;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  line-height: 16px; text-align: center; vertical-align: middle;
  color: var(--bg); background: var(--muted); border-radius: 99px;
}
.app .nav-pop-notif-item.unread .notif-count { background: var(--accent); }
.app .nav-pop-notif-empty {
  padding: 24px 14px; text-align: center; color: var(--muted); font-size: 13px;
}
.app .nav-pop-notif-foot {
  border-top: 1px solid var(--rule); padding: 10px 14px; text-align: center;
  background: var(--accent-bg);
}
.app .nav-pop-notif-foot a {
  font-size: 13px; font-weight: 500; color: var(--accent); text-decoration: none;
}
.app .nav-pop-notif-foot a:hover { color: var(--accent-hover); text-decoration: underline; }

/* Bell count badge — unread EVENTS (news). Mirrors .m-inbox-badge sizing. */
.app .topbar .bell .bell-count,
.app .m-topbar .bell .bell-count {
  position: absolute; top: -4px; right: -4px;
  min-width: 16px; height: 16px; padding: 0 4px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--accent-text, #fff);
  border: 2px solid var(--topbar-bg); border-radius: 9px;
  font-family: var(--font-mono); font-size: 9px; font-weight: 700;
  line-height: 1;
}
.app .topbar .bell .bell-count.d-none,
.app .m-topbar .bell .bell-count.d-none { display: none; }
/* Attention dot — an error-severity CONDITION is open (out of stock, halted
   ops …). Bottom corner so it can coexist with the count badge. */
.app .topbar .bell .bell-dot.bell-dot-attn,
.app .m-topbar .bell .bell-dot.bell-dot-attn {
  top: auto; bottom: 1px; right: 1px; background: var(--neg);
}

/* Attention strip at the top of the bell popover: a compact pointer to the
   dashboard's "Do next" (the actual condition list), not a second to-do list.
   Popover still caps at the viewport; the list flex-shrinks under it. */
.app .nav-dd > .nav-pop.nav-pop-notif { max-height: calc(100vh - 80px); }
.app .nav-pop-notif-list { flex: 1 1 auto; min-height: 0; }
.app .nav-pop-notif-attn-strip {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-bottom: 1px solid var(--rule);
  background: var(--accent-bg); text-decoration: none;
  font-size: 12.5px; font-weight: 500; color: var(--text);
  flex: 0 0 auto;
}
.app .nav-pop-notif-attn-strip:hover { background: var(--panel-2); }
.app .nav-pop-notif-attn-strip[hidden] { display: none; }
.app .attn-strip-dot {
  width: 7px; height: 7px; min-width: 7px; padding: 0; flex: none;
  border-radius: 50%; background: var(--accent);
}
.app .attn-strip-dot.is-error { background: var(--neg); }
.app .attn-strip-go {
  margin-left: auto; color: var(--accent); font-size: 12px; white-space: nowrap;
}
/* Bell foot is a button now (opens the shell modal) — style like the old link. */
.app .nav-pop-notif-foot button {
  font-family: var(--font-sans); font-size: 13px; font-weight: 500;
  color: var(--accent); background: transparent; border: none;
  cursor: pointer; padding: 0;
}
.app .nav-pop-notif-foot button:hover { color: var(--accent-hover); text-decoration: underline; }

/* Shell-level notification history modal — the events archive, available on
   every page (dashboard.css isn't, hence self-contained styles here). */
.app dialog.tz-dialog,
dialog.tz-dialog {
  border: 1px solid var(--rule); border-radius: 8px; padding: 0;
  background: var(--panel); color: var(--text);
  max-width: 560px; width: calc(100% - 32px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}
dialog.tz-dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
dialog.tz-dialog .tz-dialog-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--rule);
}
dialog.tz-dialog .tz-dialog-head h3 {
  font-family: var(--font-serif); font-weight: 500; font-size: 17px; margin: 0;
  letter-spacing: -0.01em; color: var(--text);
}
dialog.tz-dialog .tz-dialog-close {
  background: transparent; border: none; cursor: pointer;
  font-size: 18px; line-height: 1; color: var(--muted); padding: 2px 6px;
}
dialog.tz-dialog .tz-dialog-close:hover { color: var(--text); }
dialog.tz-dialog .tz-dialog-body { max-height: min(65vh, 560px); overflow-y: auto; }
/* Reusable confirm dialog (tz-confirm): message body + button footer */
dialog.tz-dialog.tz-confirm .tz-dialog-body { padding: 18px; }
dialog.tz-dialog .tz-confirm-message {
  margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--text);
}
dialog.tz-dialog .tz-dialog-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 12px 18px; border-top: 1px solid var(--rule);
}
dialog.tz-dialog .tz-dialog-foot .btn.primary.danger,
dialog.tz-dialog .tz-dialog-foot .btn.danger {
  background: var(--neg, #e05252); border-color: var(--neg, #e05252); color: #fff;
}
dialog.tz-dialog .tz-dialog-status {
  padding: 14px; text-align: center; color: var(--muted); font-size: 12.5px;
}
/* Rows reuse the bell's inner classes (.notif-title/-content/-time/-count are
   styled via .nav-pop-notif-item descendants); scope the row shell here since
   the bell's own row rules are nested under .nav-pop. */
dialog.tz-dialog .nav-pop-notif-item {
  display: block; text-decoration: none; position: relative;
  padding: 10px 18px; border-bottom: 1px solid var(--rule);
  color: var(--text-2); white-space: normal;
}
dialog.tz-dialog .nav-pop-notif-item:last-child { border-bottom: none; }
dialog.tz-dialog a.nav-pop-notif-item:hover { background: var(--panel-2); }
dialog.tz-dialog .nav-pop-notif-item.dismissed { opacity: 0.55; }

/* Account dropdown */
.app .nav-dd > .nav-pop.nav-pop-account {
  min-width: 220px; padding: 6px;
}
.app .nav-pop-account-head {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--muted);
  padding: 8px 10px 6px;
}
.app .nav-dd > .nav-pop.nav-pop-account .nav-pop-account-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 5px;
  font-size: 13px; color: var(--text-2); text-decoration: none;
  background: transparent; border: none; cursor: pointer;
  width: 100%; text-align: left;
  font-family: var(--font-sans);
}
.app .nav-dd > .nav-pop.nav-pop-account .nav-pop-account-item:hover {
  background: var(--panel-2); color: var(--text);
}
.app .nav-pop-account-item .np-ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; color: var(--muted); flex: 0 0 18px;
}
.app .nav-pop-account-item:hover .np-ico { color: var(--accent); }
.app .nav-pop-account-item .np-state {
  margin-left: auto; font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 1px; text-transform: uppercase; color: var(--muted);
}
.app .nav-pop-account-sep {
  height: 1px; background: var(--rule); margin: 6px 0;
}
.app .nav-dd > .nav-pop.nav-pop-account .nav-pop-account-danger { color: var(--neg); }
.app .nav-dd > .nav-pop.nav-pop-account .nav-pop-account-danger .np-ico { color: var(--neg); }
.app .nav-dd > .nav-pop.nav-pop-account .nav-pop-account-danger:hover {
  background: var(--neg-bg); color: var(--neg);
}
.app .nav-pop-logout-form { margin: 0; }

/* Theme toggle button (both topbars) */
.app .theme-toggle {
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--rule); cursor: pointer;
  font-size: 14px; line-height: 1; padding: 0;
  transition: background 0.15s ease, color 0.15s ease;
}
.app .theme-toggle:hover { background: var(--panel); color: var(--accent); }
.app .theme-toggle .theme-toggle-icon { display: inline-block; line-height: 1; }

/* Mobile topbar (default hidden, shown below breakpoint) */
.app .m-topbar { display: none; }
.app .bottom-nav { display: none; }

/* ===================== GUEST MODE BANNER ===================== */
/* Subtle amber strip pinned directly below the topbar on every page —
   uses the accent-bg / accent tokens so it feels part of the design
   system rather than an alert banner. */
.app .guest-account-banner {
    display: flex; align-items: center; justify-content: center;
    flex-wrap: wrap; gap: 10px 16px;
    padding: 8px 24px;
    background: var(--accent-bg);
    color: var(--text);
    border-bottom: 1px solid var(--rule);
    font-family: var(--font-sans); font-size: 12.5px;
}
.app .guest-account-banner .gb-label {
    font-family: var(--font-mono); font-size: 10px; letter-spacing: 1.5px;
    font-weight: 600; text-transform: uppercase;
    color: var(--accent);
}
.app .guest-account-banner .gb-text  { color: var(--text-2); }
.app .guest-account-banner .gb-cta {
    color: var(--accent); text-decoration: underline; font-weight: 600;
}
.app .guest-account-banner .gb-cta:hover { text-decoration: none; }

/* ===================== PAGE SHELL ===================== */
.app .main { padding: 24px 32px 48px; min-width: 0; max-width: 1440px; width: 100%; margin: 0 auto; }

.app .crumbs {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--muted); margin-bottom: 6px;
}
.app .crumbs a { color: var(--muted); text-decoration: none; }
.app .crumbs a:hover { color: var(--text); }
.app .crumbs .sep { margin: 0 8px; opacity: 0.5; }
.app .crumbs .here { color: var(--text); }

.app .page-head {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 24px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.app .page-head h1 {
  font-family: var(--font-serif); font-weight: 500; font-size: 30px; line-height: 1.1;
  letter-spacing: -0.02em; margin: 0; color: var(--text);
}
.app .page-head .sub { font-size: 14px; color: var(--muted); margin-top: 4px; }
.app .page-head .ctx { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.app .page-head .ctx .pill {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase;
  padding: 2px 8px; border-radius: 3px; background: var(--pos-bg); color: var(--pos);
}
.app .page-head .ctx .lvl {
  font-family: var(--font-mono); font-size: 11px; color: var(--muted); letter-spacing: 0.5px;
}

/* Sub-nav (page-level tabs) */
.app .sub-nav {
  border-bottom: 1px solid var(--rule); margin-bottom: 20px;
  display: flex; gap: 4px; align-items: flex-end;
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none; -ms-overflow-style: none;
  position: relative;
}
.app .sub-nav::-webkit-scrollbar { display: none; }

/* Right-edge fade to hint at scrollable overflow (mobile). Uses a sticky
 * pseudo-element anchored to the end so it fades the last visible tab. */
.app .sub-nav::after {
  content: ''; position: sticky; right: 0; flex: 0 0 28px; width: 28px;
  align-self: stretch; margin-left: -28px; pointer-events: none;
  background: linear-gradient(to right, transparent, var(--bg) 70%, var(--bg));
}
.app .sub-nav a {
  font-family: var(--font-sans); font-size: 13px; color: var(--muted); text-decoration: none;
  padding: 10px 14px; position: relative; white-space: nowrap;
}
.app .sub-nav a:hover { color: var(--text); }
.app .sub-nav a.active { color: var(--text); font-weight: 500; }
.app .sub-nav a.active::after {
  content: ''; position: absolute; left: 14px; right: 14px; bottom: -1px;
  height: 2px; background: var(--accent);
}
.app .sub-nav a .caret { font-size: 9px; color: var(--muted); margin-left: 4px; }

/* ===================== CARD + HEAD + ACTIONS ===================== */
.app .card { background: var(--panel); border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; }
.app .card + .card { margin-top: 14px; }
.app .card-head {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--rule); flex-wrap: wrap;
}
.app .card-head h2 {
  font-family: var(--font-serif); font-weight: 600; font-size: 16px;
  letter-spacing: -0.01em; margin: 0; color: var(--text);
}
.app .card-head .muted { font-family: var(--font-mono); font-size: 11px; color: var(--muted); letter-spacing: 0.5px; }
.app .card-head .head-actions { display: flex; gap: 8px; align-items: center; }
.app .card-body { padding: 14px 18px 18px; }

.app .range { display: flex; border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; }
.app .range button, .app .range a {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 1px;
  padding: 4px 10px; border: none; background: transparent;
  color: var(--muted); cursor: pointer; border-right: 1px solid var(--rule);
  text-decoration: none; display: inline-flex; align-items: center;
  white-space: nowrap;
}
.app .range button:last-child, .app .range a:last-child { border-right: none; }
.app .range button.on, .app .range a.on { background: var(--panel-2); color: var(--text); }
.app .range.offsets { max-width: 260px; overflow-x: auto; scrollbar-width: none; }
.app .range.offsets::-webkit-scrollbar { display: none; }

.app .tabs button {
  font-family: var(--font-sans); font-size: 12px; background: transparent;
  border: 1px solid transparent; color: var(--muted);
  padding: 4px 10px; border-radius: 4px; cursor: pointer;
}
.app .tabs button.on { background: var(--accent-bg); color: var(--accent); }

/* ===================== BUTTONS ===================== */
.app .btn {
  font-family: var(--font-sans); font-size: 13px;
  padding: 6px 14px; border-radius: 6px; border: 1px solid var(--rule);
  background: var(--panel); color: var(--text); cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.app .btn:hover { border-color: var(--rule-strong); background: var(--panel-2); }
.app .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.app .btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.app.theme-dark .btn.primary { color: #1a1814; }
.app .btn.danger { background: var(--neg); border-color: var(--neg); color: #fff; }

/* ===================== KPI ROW ===================== */
.app .kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.app .kpi { background: var(--panel); border: 1px solid var(--rule); border-radius: 8px; padding: 16px 18px; }
.app .kpi .label {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--muted); margin-bottom: 10px;
}
.app .kpi .value {
  font-family: 'Inter', 'Inter Tight', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-weight: 600; font-size: 26px; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; font-feature-settings: 'tnum', 'lnum';
  color: var(--text); line-height: 1.1;
}
.app .kpi .delta {
  margin-top: 8px; font-size: 12px; font-variant-numeric: tabular-nums;
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 4px;
}
.app .kpi .delta.up { color: var(--pos); background: var(--pos-bg); }
.app .kpi .delta.dn { color: var(--neg); background: var(--neg-bg); }
.app .kpi .delta.neu { color: var(--muted); background: var(--panel-2); }
.app .kpi.accent .value { color: var(--accent); }
/* KPI cards carrying a title= explanation get a visible "?" ring and a help
   cursor — native tooltips are invisible affordances otherwise. */
.app .kpi[title] { cursor: help; }
.app .kpi[title] .label::after {
  content: "?";
  display: inline-block; margin-left: 6px;
  width: 13px; height: 13px; line-height: 12px; text-align: center;
  border: 1px solid var(--rule-strong); border-radius: 50%;
  font-size: 9px; letter-spacing: 0; color: var(--muted);
}
.app .kpi[title]:hover .label::after { border-color: var(--accent); color: var(--accent); }

/* ===================== STATEMENT TABLE ===================== */
.app .fin-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 14px; align-items: start; }

/* Chart containers — Chart.js needs a positioned parent with definite height
 * when maintainAspectRatio: false. Without this, canvas can overflow. */
.app .chart-box { position: relative; width: 100%; height: 200px; }
.app canvas { max-width: 100%; display: block; }
.app .stmt-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.app .stmt-table th, .app .stmt-table td {
  padding: 4px 12px; text-align: right; font-size: 12.5px; line-height: 1.35;
}
.app .stmt-table thead th {
  padding: 8px 12px 6px; font-family: var(--font-mono); font-size: 9.5px;
  letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted);
  font-weight: 500; border-bottom: 1px solid var(--rule);
}
.app .stmt-table td:first-child, .app .stmt-table th:first-child {
  text-align: left; font-family: var(--font-sans);
}
.app .stmt-table .group td {
  padding: 10px 12px 2px; font-family: var(--font-mono); font-size: 9.5px;
  letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); font-weight: 500;
}
.app .stmt-table .row td { color: var(--text-2); padding-top: 3px; padding-bottom: 3px; }
.app .stmt-table .row td:first-child { padding-left: 18px; color: var(--text-2); }
.app .stmt-table .total td {
  border-top: 1px solid var(--rule); font-weight: 600; color: var(--text);
  font-family: var(--font-serif); font-size: 13px; padding-top: 6px; padding-bottom: 4px;
}
.app .stmt-table .subtle td {
  color: var(--muted); font-size: 11px; padding-top: 0; padding-bottom: 6px; border: none;
}
.app .stmt-table .subtle td:first-child {
  padding-left: 18px; font-family: var(--font-mono); letter-spacing: 0.3px;
}
.app .stmt-table .pos { color: var(--pos); }
.app .stmt-table .neg { color: var(--neg); }

/* ===================== SUMMARY ROWS (right-hand panels) ===================== */
.app .sum-row {
  display: flex; justify-content: space-between; padding: 7px 0; font-size: 13px;
  border-bottom: 1px dashed var(--rule);
}
.app .sum-row:last-of-type { border-bottom: none; }
.app .sum-row .l { color: var(--text-2); }
.app .sum-row .v { font-family: var(--font-serif); font-variant-numeric: tabular-nums; color: var(--text); }
.app .sum-row.total .l, .app .sum-row.total .v { color: var(--text); font-weight: 600; }
.app .sum-row .v.pos { color: var(--pos); }
.app .sum-row .v.neg { color: var(--neg); }

/* ===================== CHIPS ===================== */
.app .chip {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.5px;
  padding: 2px 6px; border-radius: 3px;
}
.app .chip.pos { background: var(--pos-bg); color: var(--pos); }
.app .chip.neg { background: var(--neg-bg); color: var(--neg); }
.app .chip.info { background: var(--info-bg); color: var(--info); }
.app .chip.accent { background: var(--accent-bg); color: var(--accent); }

/* Filter-chip variant — interactive, larger hit target. Used on Floor /
   Threads / Knowledge for tab-like filter rows. */
.app .floor-chips {
  display: flex; gap: 6px; margin: 14px 0 10px;
  overflow-x: auto; scrollbar-width: none; padding-bottom: 2px;
  flex-wrap: wrap;
}
.app .floor-chips::-webkit-scrollbar { display: none; }
.app .floor-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 6px 12px;
  border-radius: 4px;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--text-mute);
  cursor: pointer;
  flex: 0 0 auto;
  text-decoration: none;
  display: inline-flex; align-items: center;
  transition: color .12s ease, border-color .12s ease, background-color .12s ease;
}
.app .floor-chip:hover {
  border-color: var(--rule-strong);
  color: var(--text);
}
.app .floor-chip.on {
  background: var(--accent-bg);
  color: var(--accent);
  border-color: var(--accent);
}

/* Floor / Thread shared form controls */
.app .floor-input,
.app .floor-textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  font-family: var(--font-sans, system-ui);
  font-size: 14px;
  resize: vertical;
}
.app .floor-input { margin-bottom: 8px; }
.app .floor-input:focus,
.app .floor-textarea:focus { outline: none; border-color: var(--accent); }
.app .floor-composer-foot {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 10px;
}
.app .floor-counter {
  font-family: var(--font-mono); font-size: 11px; color: var(--text-mute);
}

/* ===================== FLASH ===================== */
.app .flash {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; border-radius: 6px; margin-bottom: 14px;
  border-left: 3px solid var(--rule); background: var(--panel-2); color: var(--text);
}
.app .flash .m { font-size: 13px; }
.app .flash .m strong { font-weight: 600; }
.app .flash .m a,
.app .flash .m .alert-link {
  color: inherit; text-decoration: underline; text-underline-offset: 2px;
  font-weight: 500;
}
.app .flash .m a:hover,
.app .flash .m .alert-link:hover { text-decoration: none; }
.app .flash .x { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; }
.app .flash.flash-success { background: var(--pos-bg); border-left-color: var(--pos); }
.app .flash.flash-error   { background: var(--neg-bg); border-left-color: var(--neg); }
.app .flash.flash-info    { background: var(--info-bg); border-left-color: var(--info); }

/* ===================== GUIDE LINK ===================== */
/* "? Guide" pill (render_guide_link) — contextual jump into the
   Beginner's Guide from the screen where the player is stuck. */
.app .guide-link {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.6px;
  text-transform: uppercase; text-decoration: none; white-space: nowrap;
  color: var(--muted); border: 1px solid var(--rule);
  padding: 3px 9px; border-radius: 999px;
}
.app .guide-link .q {
  display: inline-flex; align-items: center; justify-content: center;
  width: 12px; height: 12px; border-radius: 50%;
  border: 1px solid var(--rule-strong); font-size: 8px; line-height: 1;
}
.app .guide-link:hover { color: var(--accent); border-color: var(--accent); }
.app .guide-link:hover .q { color: var(--accent); border-color: var(--accent); }

/* ===================== EMPTY STATE ===================== */
.app .empty { text-align: center; padding: 48px 24px; }
.app .empty .t { font-family: var(--font-serif); font-weight: 600; font-size: 16px; color: var(--text); margin-bottom: 4px; }
.app .empty .d { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.app .empty.error .t { color: var(--neg); }

/* ===================== PAGER ===================== */
.app .pager {
  display: flex; gap: 4px; justify-content: center; align-items: center;
  font-family: var(--font-mono); font-size: 11px; margin: 20px 0;
}
.app .pager a {
  color: var(--muted); text-decoration: none; padding: 4px 10px; border-radius: 4px;
}
.app .pager a:hover { background: var(--panel-2); color: var(--text); }
.app .pager a.active { background: var(--accent-bg); color: var(--accent); font-weight: 600; }
.app .pager a.edge { color: var(--text-2); }
.app .pager .gap { color: var(--muted); padding: 0 4px; }

/* ===================== MOBILE (≤ 900px) ===================== */
@media (max-width: 900px) {
  .app .topbar { display: none; }
  .app .m-topbar { display: flex; }
  .app .bottom-nav { display: grid; }
  .app .main { padding: 14px 14px 84px; max-width: none; overflow-x: hidden; }

  .app .kpi-row { grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
  .app .kpi { padding: 8px 10px; }
  .app .kpi .value { font-size: 18px; line-height: 1.2; }
  .app .kpi .label { font-size: 9px; letter-spacing: 1.5px; margin-bottom: 4px; }
  /* Drop the chunky delta pill background on mobile — the bare arrow +
     number carries enough signal and doesn't wrap to a second line like
     the pill did ("↑ +89.3% vs. yesterday"). */
  .app .kpi .delta {
    font-size: 11px;
    background: transparent !important;
    padding: 2px 0 0 0;
    white-space: nowrap;
  }

  /* Tighten the top-of-page period selection on mobile: smaller wrap-gap
     between title and pills, compact pill rows, and less breathing room
     between the sub-nav and first card. */
  .app .page-head { margin-bottom: 8px; gap: 8px; row-gap: 8px; }
  .app .page-head h1 { font-size: 22px; }
  .app .page-head .sub { font-size: 12px; margin-top: 2px; }
  .app .page-head .ctx { gap: 6px; row-gap: 6px; }
  .app .page-head .ctx .range button, .app .page-head .ctx .range a { padding: 3px 8px; }

  .app .sub-nav { margin: 0 -14px 10px; padding: 0 0 0 14px; gap: 0; }
  .app .sub-nav a { font-size: 12px; padding: 8px 10px; }
  .app .sub-nav a.active::after { left: 10px; right: 10px; }
  /* Widen the fade on mobile so the last tab feels truly clipped */
  .app .sub-nav::after { flex: 0 0 36px; width: 36px; margin-left: -36px; }

  .app .fin-grid { grid-template-columns: 1fr; gap: 10px; }
  .app .card + .card { margin-top: 10px; }
  .app .card-head { padding: 10px 14px; }
  .app .card-head h2 { font-size: 15px; }
  .app .card-body { padding: 10px 14px 12px; }

  /* P&L: hide prior-period column on mobile */
  .app .stmt-table th, .app .stmt-table td { padding: 3px 10px; font-size: 12px; }
  .app .stmt-table thead th { padding: 8px 10px 6px; font-size: 9px; letter-spacing: 1px; white-space: nowrap; }
  .app .stmt-table .row td:first-child { padding-left: 14px; }
  .app .stmt-table th:nth-child(3), .app .stmt-table td:nth-child(3) { display: none; }

  /* Chart card toolbars: wrap to a new line instead of overflowing */
  .app .card-head { flex-wrap: wrap; row-gap: 8px; }
  .app .card-head .head-actions { flex-wrap: wrap; row-gap: 6px; width: 100%; }
  .app .range button, .app .range a { padding: 4px 8px; font-size: 10px; letter-spacing: 0.6px; }

  /* Guest banner stacks on mobile */
  .app .guest-account-banner { padding: 8px 14px; font-size: 12px; gap: 6px 10px; }
  .app .guest-account-banner .gb-text { display: none; }
  .app .guest-account-banner .gb-label { font-size: 9.5px; padding: 2px 6px; }

  /* Notifications popover must fit narrow phones — anchor to the viewport
     edge rather than the bell (avatar + theme-toggle sit to the bell's right,
     so `right: 0` on the dropdown would push the popover off-screen left). */
  .app .m-topbar .nav-dd > .nav-pop.nav-pop-notif,
  .app .m-topbar .nav-dd > .nav-pop.nav-pop-account {
      position: fixed;
      top: 56px; right: 14px; left: auto;
      min-width: 0;
      width: calc(100vw - 28px);
      max-width: 380px;
  }
}

/* Mobile topbar + bottom-nav markup (hidden until breakpoint) */
.app .m-topbar {
  position: sticky; top: 0; z-index: var(--z-topbar);
  background: var(--topbar-bg); border-bottom: 1px solid var(--rule);
  padding: 10px 14px; height: 52px;
  align-items: center; justify-content: space-between;
}
.app .m-topbar .brand {
  font-family: var(--font-serif); font-weight: 700; font-size: 18px;
  letter-spacing: -0.02em; color: var(--text); text-decoration: none;
}
.app .m-topbar .brand .dot { color: var(--accent); }
.app .m-topbar .right { display: flex; align-items: center; gap: 10px; }
.app .m-topbar .cash-chip {
  display: inline-flex; align-items: baseline; gap: 4px;
  padding: 4px 10px; background: var(--accent-bg); border-radius: 6px;
}
.app .m-topbar .cash-chip .v {
  font-family: var(--font-serif); font-weight: 600; font-size: 13px;
  color: var(--accent); font-variant-numeric: tabular-nums;
}
.app .m-topbar .cash-chip .d { font-family: var(--font-mono); font-size: 9px; color: var(--pos); }
.app .m-topbar .avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--panel-2);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-serif); font-weight: 600; font-size: 12px; color: var(--text);
  border: 0; padding: 0; cursor: pointer; text-decoration: none;
}

/* Mobile hamburger lives in the bottom-nav (see .bn-menu below).
   The legacy .m-burger styles are kept for the public landing topbar. */
.app .m-burger {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 32px;
  background: transparent; border: 1px solid var(--rule); border-radius: 6px;
  padding: 0; cursor: pointer; color: var(--text);
  margin-right: 8px;
}
.app .m-burger:hover { background: var(--panel); color: var(--accent); }
.app .m-burger-bars {
  position: relative; display: inline-block; width: 16px; height: 12px;
}
.app .m-burger-bars span {
  position: absolute; left: 0; right: 0; height: 2px;
  background: currentColor; border-radius: 1px;
  transition: transform 0.18s ease, opacity 0.18s ease, top 0.18s ease;
}
.app .m-burger-bars span:nth-child(1) { top: 0; }
.app .m-burger-bars span:nth-child(2) { top: 5px; }
.app .m-burger-bars span:nth-child(3) { top: 10px; }
.app .m-burger.is-open .m-burger-bars span:nth-child(1) { top: 5px; transform: rotate(45deg); }
.app .m-burger.is-open .m-burger-bars span:nth-child(2) { opacity: 0; }
.app .m-burger.is-open .m-burger-bars span:nth-child(3) { top: 5px; transform: rotate(-45deg); }
.app .m-burger { display: none; }

/* Bottom-nav hamburger button (replaces the old "Floor" slot). */
.app .bn-menu {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  font-size: 10px; font-family: var(--font-sans); letter-spacing: 0;
  color: var(--muted); background: transparent; border: 0;
  padding: 6px 4px 4px; text-align: center; cursor: pointer;
}
.app .bn-menu .ico {
  font-family: var(--font-serif); font-size: 15px; font-weight: 600;
  color: var(--text-2); line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  height: 15px;
}
.app .bn-menu .bn-burger-bars {
  position: relative; display: inline-block; width: 16px; height: 12px;
}
.app .bn-menu .bn-burger-bars span {
  position: absolute; left: 0; right: 0; height: 2px;
  background: currentColor; border-radius: 1px;
  transition: transform 0.18s ease, opacity 0.18s ease, top 0.18s ease;
}
.app .bn-menu .bn-burger-bars span:nth-child(1) { top: 0; }
.app .bn-menu .bn-burger-bars span:nth-child(2) { top: 5px; }
.app .bn-menu .bn-burger-bars span:nth-child(3) { top: 10px; }
.app .bn-menu.is-open { color: var(--accent); }
.app .bn-menu.is-open .ico { color: var(--accent); }
.app .bn-menu.is-open .bn-burger-bars span:nth-child(1) { top: 5px; transform: rotate(45deg); }
.app .bn-menu.is-open .bn-burger-bars span:nth-child(2) { opacity: 0; }
.app .bn-menu.is-open .bn-burger-bars span:nth-child(3) { top: 5px; transform: rotate(-45deg); }

/* Mobile drawer — slides up from above the bottom-nav as a full-width
   overlay. Hidden until the ≤900px breakpoint engages. The drawer sits
   below the topbar (z-index lower) so the topbar stays visible/clickable
   when the drawer is open. We anchor it to bottom:0 with bottom-padding
   matching the bottom-nav so the panel and the nav meet without a gap. */
.app .m-drawer {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: calc(var(--z-topbar) - 2);
  background: var(--panel); border-top: 1px solid var(--rule);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.22s ease;
}
/* Leave the mobile topbar (52px) + bottom-nav (~56px) visible. */
.app .m-drawer.is-open { max-height: calc(100vh - 52px); overflow-y: auto; }
.app .m-drawer-nav {
  display: flex; flex-direction: column; padding: 6px 0 60px;
}
.app .m-drawer-nav a {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; font-size: 14px; font-family: var(--font-sans);
  color: var(--text); text-decoration: none;
  border-bottom: 1px solid var(--rule);
}
.app .m-drawer-nav a:hover,
.app .m-drawer-nav a.active { background: var(--panel-2); color: var(--accent); }
.app .m-drawer-nav a.m-drawer-danger { color: var(--neg); }
.app .m-drawer-nav .m-drawer-logout-form { margin: 0; }
.app .m-drawer-nav button.m-drawer-danger {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 12px 18px; font-size: 14px; font-family: var(--font-sans);
  color: var(--neg); text-align: left;
  background: transparent; border: none; border-bottom: 1px solid var(--rule);
  cursor: pointer;
}
.app .m-drawer-nav button.m-drawer-danger:hover { background: var(--panel-2); }
.app .m-drawer-nav .m-drawer-section {
  padding: 12px 18px 4px;
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--rule);
}
.app .m-drawer-nav .m-drawer-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 6px;
  background: var(--accent); color: var(--accent-text, #fff);
  border-radius: 9px;
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
}
/* Backdrop for drawer (click outside to close). Sits below the drawer
   and the topbar so the topbar remains interactable. */
.app .m-drawer-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: calc(var(--z-topbar) - 3);
  opacity: 0; transition: opacity 0.22s ease;
}
.app .m-drawer-backdrop.is-open { opacity: 1; }
@media (max-width: 900px) {
  .app .m-drawer { display: block; }
  .app .m-drawer-backdrop { display: block; pointer-events: none; }
  .app .m-drawer-backdrop.is-open { pointer-events: auto; }
}

.app .bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: var(--z-topbar);
  grid-template-columns: repeat(6, 1fr);
  background: var(--topbar-bg); border-top: 1px solid var(--rule);
  padding: 2px 0 4px;
}
.app .bottom-nav a,
.app .bottom-nav .bn-menu {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  font-size: 10px; font-family: var(--font-sans); letter-spacing: 0;
  color: var(--muted); text-decoration: none; padding: 6px 2px 4px; position: relative;
  text-align: center; min-width: 0;
}
.app .bottom-nav a .ico {
  font-family: var(--font-serif); font-size: 15px; font-weight: 600; color: var(--text-2); line-height: 1;
}
.app .bottom-nav a.active { color: var(--accent); }
.app .bottom-nav a.active .ico { color: var(--accent); }


/* --- Cross-document View Transitions -------------------------------------
 * Opt the whole site into smooth document-to-document transitions on
 * Chromium-based browsers. Firefox / Safari ignore this and keep their
 * normal (already fast, prefetched) navigations � no regression.
 *
 * Combined with the hover prefetch in shell-prefetch.js, this gives the
 * shell header, mobile topbar, sidebar, and bottom-nav a pinned feel while
 * only the <main> content cross-fades. */
@view-transition { navigation: auto; }

/* Pin the nav chrome: elements sharing a view-transition-name across the
 * old and new documents are morphed in place instead of cross-faded, so
 * the topbar/sidebar/bottom-nav visually persist across navigations. */
.topbar      { view-transition-name: tradez-topbar; }
.m-topbar    { view-transition-name: tradez-mtopbar; }
.sidebar     { view-transition-name: tradez-sidebar; }
.bottom-nav  { view-transition-name: tradez-bottomnav; }

/* Tune the default root cross-fade to feel snappy (~180 ms). */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 180ms;
  animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Keep the pinned chrome frame-perfect: no fade on them at all. */
::view-transition-old(tradez-topbar),
::view-transition-new(tradez-topbar),
::view-transition-old(tradez-mtopbar),
::view-transition-new(tradez-mtopbar),
::view-transition-old(tradez-sidebar),
::view-transition-new(tradez-sidebar),
::view-transition-old(tradez-bottomnav),
::view-transition-new(tradez-bottomnav) {
  animation: none;
  mix-blend-mode: normal;
}

/* Accessibility: honor the OS-level reduced-motion setting. */
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
}

/* ===================== YOUR PATH — tracker pill, mobile strip, page hint ===================== */
/* docs/ONBOARDING_PATH_LAYOUT_2026-09-06.md §3. One cached summary, three
   surfaces: the pill in .topbar .right, the strip under .m-topbar, the hint
   under a page head. Same tokens as the dashboard card. */
.app .path-pill {
  display: inline-flex; align-items: center; gap: 8px; max-width: 220px; flex: 0 1 auto; min-width: 0;
  padding: 5px 11px 5px 9px; border-radius: 99px; white-space: nowrap;
  border: 1px solid var(--accent); background: var(--accent-bg);
  color: var(--text); text-decoration: none; font-size: 12.5px; line-height: 1.2;
}
.app .path-pill:hover { filter: brightness(1.05); }
.app .path-pill .pp-ch {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.8px;
  text-transform: uppercase; color: var(--accent); font-weight: 600; white-space: nowrap;
}
.app .path-pill .pp-next { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.app .path-pill .pp-go { color: var(--accent); flex-shrink: 0; }
.app .path-pill.is-here { border-color: var(--pos); background: var(--pos-bg); }
.app .path-pill.is-here .pp-ch { color: var(--pos); }
.app .path-pill.is-gated { border-color: var(--rule-strong); background: var(--panel-2); }
.app .path-pill.is-gated .pp-ch { color: var(--text-2); }
.app .path-strip.is-gated { background: var(--panel-2); }
.app .path-strip.is-gated .ps-ch, .app .path-strip.is-gated .ps-go { color: var(--text-2); }
/* Width budget. Brand + the eight nav links + cash/bell/theme/avatar use
   ~1190px of the 1440px topbar, so the pill gets what is left: chip + text
   only on very wide screens, chip only on normal desktops, and below 1300px
   it yields to the strip under the topbar (the same strip mobile uses) so
   the nav never wraps. */
@media (max-width: 1599px) { .app .topbar .path-pill .pp-next { display: none; } }
@media (max-width: 1299px) { .app .topbar .path-pill { display: none; } .app .path-strip { display: flex; } }

.app .path-strip {
  display: none; align-items: center; gap: 8px; padding: 7px 14px;
  background: var(--accent-bg); border-bottom: 1px solid var(--rule);
  color: var(--text); text-decoration: none; font-size: 12.5px;
}
.app .path-strip .ps-ch { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.8px; text-transform: uppercase; color: var(--accent); font-weight: 600; white-space: nowrap; }
.app .path-strip .ps-next { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app .path-strip .ps-go { color: var(--accent); }
.app .path-strip.is-here { background: var(--pos-bg); }
.app .path-strip.is-here .ps-ch, .app .path-strip.is-here .ps-go { color: var(--pos); }
/* (strip visibility: see the width-budget rules above) */

.app .path-hint {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  border: 1px solid var(--rule); border-left: 3px solid var(--accent); border-radius: 6px;
  background: var(--panel); padding: 9px 12px; margin: 0 0 14px;
  font-size: 13px; color: var(--text-2); line-height: 1.45;
}
.app .path-hint .ph-label { font-family: var(--font-mono); font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--accent); font-weight: 600; white-space: nowrap; }
.app .path-hint .ph-text { flex: 1; min-width: 220px; }
.app .path-hint .ph-text strong { color: var(--text); font-weight: 600; }
.app .path-hint .ph-link { color: var(--accent); text-decoration: none; white-space: nowrap; }
.app .path-hint .ph-link:hover { text-decoration: underline; }
.app .path-hint.legacy { border-left-color: var(--info); }
.app .path-hint.legacy .ph-label { color: var(--info); }
@media (max-width: 900px) { .app .path-hint { padding: 8px 10px; margin-bottom: 10px; font-size: 12.5px; } }
