:root {
  --bg: #000; --panel: #0e0d0b; --panel-2: #16140f; --line: #2a261d; --text: #f1ede4; --muted: #a59f92;
  --gold: #DBB464; --gold-light: #F5DDA1; --gold-dark: #B28843;
  --pos: #6fd39a; --neg: #ff8a7a; --warn: #f3c969;
  --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; }
h1, h2, h3, .brand { font-family: Montserrat, Inter, system-ui, sans-serif; }
h1 { font-size: 1.6rem; margin: 0; color: var(--gold-light); }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; color: var(--gold); }
h3 { font-size: .95rem; margin: 1rem 0 .4rem; color: var(--gold-light); }
a { color: var(--gold-light); }
a:hover { color: var(--gold); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 8px; top: 8px; background: var(--gold); color: #000; padding: 6px 10px; z-index: 10; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.top-btn, .cloud-pill { font-size: .8rem; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: 999px; padding: 3px 11px; line-height: 1.5; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.top-btn[hidden] { display: none; }
.top-btn:hover:not(:disabled), .cloud-pill:hover:not(:disabled) { border-color: var(--gold); color: var(--gold-light); }
.cloud-pill.is-signed-in { border-color: var(--gold-dark); color: var(--gold-light); }
.sync-dot { width: 7px; height: 7px; border-radius: 999px; background: var(--muted); display: inline-block; flex-shrink: 0; }
.sync-dot.active { background: var(--pos); }
.sync-dot.err { background: var(--neg); }
.sync-dot.syncing { background: var(--gold); animation: cloudPulse 1s ease-in-out infinite; }
@keyframes cloudPulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.cloud-v-sm { font-size: 1rem; word-break: break-word; }
body.gated #nav, body.gated .top-actions { display: none; }
.auth-gate { display: flex; justify-content: center; padding: 40px 0; }
.gate-card { width: 100%; max-width: 440px; padding: 28px; }
.gate-card h1 { margin-bottom: 6px; }
.gate-form label { display: block; margin: 12px 0 0; }
.gate-form input { width: 100%; }
.gate-actions { margin-top: 14px; flex-wrap: wrap; gap: 8px; }
.gate-error:empty, .gate-ok:empty { display: none; }
.gate-error, .gate-ok { margin: 10px 0 0; }
.gate-foot { margin-top: 18px; }
.btn-gold { display: inline-flex; align-items: center; background: var(--gold); color: #000; border-radius: 8px; padding: 8px 14px; font-weight: 600; text-decoration: none; }
.btn-gold:hover { background: var(--gold-light); color: #000; }
.cloud-cfg-details { margin-top: 12px; }
.cloud-cfg-box { padding-top: 6px; }
.brand { color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; }
.mark { background: var(--gold); color: #000; border-radius: 6px; padding: 2px 6px; font-size: .85rem; }
.pro { color: var(--gold); }
.tz-badge { font-size: .8rem; border: 1px solid var(--gold-dark); color: var(--gold-light); border-radius: 999px; padding: 3px 10px; text-decoration: none; white-space: nowrap; }
nav { display: flex; gap: 4px; padding: 8px 16px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: thin; }
nav a { color: var(--muted); text-decoration: none; padding: 6px 12px; border-radius: 8px; white-space: nowrap; font-weight: 500; }
nav a:hover { color: var(--text); background: var(--panel-2); }
nav a[aria-current="page"] { color: #000; background: var(--gold); }
main { max-width: 1200px; margin: 0 auto; padding: 20px; outline: none; }
.foot { max-width: 1200px; margin: 30px auto 0; padding: 16px 20px 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem; }

.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.head-actions, .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 14px 0; overflow-x: auto; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.two-col > .panel { margin: 0; }
.two-col + .panel, .panel + .two-col { margin-top: 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin: 12px 0; }
.card, .clock { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.k { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.v { font-size: 1.35rem; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.sub { color: var(--muted); font-size: .82rem; }
.muted { color: var(--muted); }
.note { color: var(--muted); font-size: .88rem; }
.warn { color: var(--warn); background: rgba(243, 201, 105, .08); border-left: 3px solid var(--warn); padding: 8px 12px; border-radius: 4px; font-size: .9rem; }
.warn-text { color: var(--warn); }
.banner { background: rgba(219, 180, 100, .1); border: 1px solid var(--gold-dark); border-radius: 8px; padding: 8px 12px; }
.hypo { color: var(--gold-light); font-weight: 600; border: 1px dashed var(--gold-dark); border-radius: 8px; padding: 8px 12px; }
.refuse { border-color: var(--neg); }
.empty { border: 1px dashed var(--line); border-radius: var(--radius); padding: 24px; text-align: center; color: var(--muted); margin: 14px 0; }
.pos { color: var(--pos); } .neg { color: var(--neg); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88em; }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: .82rem; }
td.num, th.num { text-align: right; }
table.small td, table.small th { padding: 4px 6px; font-size: .85rem; }
table.kv th { width: 45%; color: var(--muted); font-size: .9rem; font-weight: 400; }
.table-wrap { overflow-x: auto; }
.table-wrap.tall { max-height: 320px; overflow-y: auto; }
td.actions { white-space: nowrap; text-align: right; }
.pill { display: inline-block; border-radius: 999px; padding: 1px 9px; font-size: .78rem; background: var(--panel-2); border: 1px solid var(--line); }
.s-paid, .s-funded, .s-passed { border-color: var(--pos); color: var(--pos); }
.s-active, .s-bought { border-color: var(--gold-dark); color: var(--gold-light); }
.s-closed { color: var(--muted); }
.tag { display: inline-block; font-size: .75rem; background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 6px; margin: 0 4px 2px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chips span { font-size: .82rem; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; }
.gate { font-size: .8rem; border-radius: 999px; padding: 2px 10px; border: 1px solid; }
.gate.pass { color: var(--pos); } .gate.fail { color: var(--neg); } .gate.unknown { color: var(--muted); }
.verdict { font-family: Montserrat, sans-serif; font-weight: 700; margin-bottom: 10px; color: var(--muted); } .verdict.pass { color: var(--pos); }
.rule-status { font-size: .88rem; border-radius: 6px; padding: 6px 10px; }
.rule-status.ok { color: var(--pos); } .rule-status.stale, .rule-status.unverified { color: var(--warn); background: rgba(243, 201, 105, .08); }
.rule-status.example { color: var(--neg); background: rgba(255, 138, 122, .08); }
.firm-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.assumptions { color: var(--muted); font-size: .88rem; padding-left: 18px; }
.pager { display: flex; gap: 12px; justify-content: center; align-items: center; margin-top: 10px; }
.stack { display: flex; flex-wrap: wrap; gap: 8px; }
.danger-zone { border-color: #4a2320; }
svg.equity { width: 100%; height: 140px; display: block; }
svg.equity .line { fill: none; stroke: var(--gold); stroke-width: 2; vector-effect: non-scaling-stroke; }
svg.equity .zero { stroke: var(--line); stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }

button { font: inherit; cursor: pointer; border-radius: 8px; padding: 7px 14px; border: 1px solid var(--gold-dark); background: var(--panel-2); color: var(--text); }
button:hover:not(:disabled) { border-color: var(--gold); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--gold); color: #000; border-color: var(--gold); font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--gold-light); }
button.ghost { background: transparent; border-color: var(--line); }
button.small { padding: 3px 9px; font-size: .82rem; }
button.danger { color: var(--neg); }
label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); margin-bottom: 8px; }
label.inline { flex-direction: row; align-items: center; gap: 8px; margin: 0; }
input, select, textarea { font: inherit; color: var(--text); background: #050505; border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; min-width: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); outline: none; }
textarea.mono { font-size: .82rem; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 8px 0; }
legend { color: var(--gold-light); font-size: .85rem; padding: 0 6px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 12px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 0 10px; align-items: flex-end; }
.filters label { min-width: 130px; }
.cost-row, .sess-row { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 6px; margin-bottom: 6px; }
.sess-row { grid-template-columns: 2fr 1fr 1fr auto; max-width: 560px; }
.zone-other { margin-top: 6px; }
.sticky-save { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 14px 0; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--gold-dark); border-radius: 12px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); }
dialog.wide { width: min(860px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(0, 0, 0, .7); }
dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 34px); }
dialog header { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 6px; }
dialog header h2 { margin: 0; }
.dlg-body { padding: 6px 16px; overflow-y: auto; }
dialog footer { display: flex; gap: 8px; padding: 12px 16px 16px; }
.form-error { color: var(--neg); margin: 0 16px; min-height: 0; }
.form-error:empty { display: none; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--gold); color: var(--text); padding: 10px 16px; border-radius: 8px; z-index: 1000; max-width: calc(100vw - 32px); }
.toast.error { border-color: var(--neg); }

/* Today page */
.meter { display: inline-block; width: 80px; height: 8px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); vertical-align: middle; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--gold); }
ul.tight { margin: 0; padding-left: 1.1em; } ul.tight li { margin: 0; }
/* Backup reminder */
.backup-banner { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; margin: 0 0 14px; }
.backup-banner .row { gap: 6px; }
@media (max-width: 640px) {
  main { padding: 14px 16px; }
  .top { padding: 12px 16px; }
  h1 { font-size: 1.35rem; }
  .cost-row { grid-template-columns: 1fr 1fr; }
  .filters label { min-width: calc(50% - 10px); }
  td.actions button { margin: 2px 0; }
}
.rules-text { background: var(--panel-2); border-left: 3px solid var(--gold); border-radius: 4px; padding: 8px 12px; font-size: .9rem; }
.row.end { justify-content: flex-end; align-self: end; margin-bottom: 8px; }
details summary { cursor: pointer; color: var(--gold-light); margin: 8px 0; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); grid-column: 1 / -1; }
label.check input { width: 18px; height: 18px; }

.chips .soft { border-color: var(--warn); }
.chips .hard { border-color: var(--neg); }

.note-cell { max-width: 220px; white-space: normal; }

/* Visual equity + drawdown & leak detector (Overview) */
svg.equity-dd, svg.bar-chart { width: 100%; display: block; }
svg.equity-dd { height: 180px; }
svg.bar-chart { height: 140px; }
svg.equity-dd .line { fill: none; stroke: var(--gold); stroke-width: 2.2; vector-effect: non-scaling-stroke; }
svg.equity-dd .eq-area { fill: rgba(219, 180, 100, .14); }
svg.equity-dd .dd-area { fill: rgba(255, 138, 122, .16); }
svg.equity-dd .dd-line { fill: none; stroke: var(--neg); stroke-width: 1.2; stroke-dasharray: 3 3; opacity: .75; vector-effect: non-scaling-stroke; }
svg.equity-dd .zero, svg.bar-chart .zero { stroke: var(--line); stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
.svg-lbl { font-size: 11px; fill: var(--muted); font-family: Inter, system-ui, sans-serif; }
.svg-lbl.pos { fill: var(--pos); font-weight: 600; }
.svg-lbl.neg { fill: var(--neg); font-weight: 600; }
svg.bar-chart .bar-pos { fill: var(--pos); opacity: .85; }
svg.bar-chart .bar-neg { fill: var(--neg); opacity: .85; }
svg.bar-chart .svg-val { font-size: 10.5px; fill: var(--text); font-family: Inter, system-ui, sans-serif; font-variant-numeric: tabular-nums; }
svg.bar-chart .svg-axis { font-size: 11px; fill: var(--muted); font-family: Inter, system-ui, sans-serif; }

.what-if { background: rgba(111, 211, 154, .08); border: 1px solid var(--pos); border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; justify-content: space-between; }
.leak-list { display: grid; gap: 10px; }
.leak-item { background: var(--panel-2); border: 1px solid var(--line); border-left-width: 3px; border-radius: 8px; padding: 10px 12px; }
.leak-item.leak-high { border-left-color: var(--neg); }
.leak-item.leak-med { border-left-color: var(--warn); }
.leak-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.leak-badge { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; border-radius: 999px; padding: 1px 8px; border: 1px solid var(--line); }
.leak-badge.high { color: var(--neg); border-color: var(--neg); }
.leak-badge.med { color: var(--warn); border-color: var(--warn); }

.heatmap td.hm-cell { text-align: right; border-radius: 4px; font-size: .82rem; }
.hm-pos { background: rgba(111, 211, 154, .12); color: var(--pos); }
.hm-neg { background: rgba(255, 138, 122, .12); color: var(--neg); }
.hm-zero { color: var(--muted); }
.hm-meta { display: block; font-size: .72rem; color: var(--muted); font-weight: 400; }

/* News Guard, Pre-Market Checklist & Eval Budget */
.news-badge { display: inline-block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; border-radius: 999px; padding: 1px 8px; border: 1px solid var(--neg); color: var(--neg); background: rgba(255, 138, 122, .1); }
.chk-list { display: grid; gap: 6px; margin: 10px 0; }
.chk-item { display: flex; flex-direction: row; align-items: center; gap: 10px; margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); cursor: pointer; font-size: .92rem; }
.chk-item input { width: 17px; height: 17px; margin: 0; accent-color: var(--gold); }
.chk-item.done { border-color: rgba(111, 211, 154, .45); color: var(--pos); }
.meter.wide { width: 100%; height: 10px; }
.meter.warn > span { background: var(--warn); }
.meter.neg > span { background: var(--neg); }
