/* ============================================================
   Advisor — sage/greige design system
   Matches the investments + spending apps (Newsreader + Hanken).
   ============================================================ */
:root {
  --ink: #2f3a31; --ink2: #3a3d37; --ink3: #6f7269; --ink4: #9a9c8f;
  --paper: #e4e1d9; --surface: #f7f5ef; --inset: #fbfaf5; --panel: #efece3;
  --accent: #5f7560; --accent2: #566b57;
  --green: #5f7560; --green-bg: rgba(95,117,96,0.14);
  --red: #a8604a; --red-bg: rgba(200,127,94,0.14);
  --amber: #b07d2e; --amber-bg: rgba(176,125,46,0.13);
  --blue: #5b7d8c; --blue-bg: rgba(91,125,140,0.13);
  --gold: #b89a3e;
  --border: rgba(56,58,53,0.07); --border2: rgba(56,58,53,0.12);
  --shadow: 0 1px 2px rgba(56,58,53,0.05); --shadow-lg: 0 6px 28px rgba(56,58,53,0.10);
  --r: 16px; --r-card: 14px; --r-btn: 12px; --r-in: 10px; --r-pill: 20px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; scroll-behavior: smooth; }
body {
  font-family: 'Hanken Grotesk', system-ui, sans-serif;
  background: var(--paper); color: var(--ink2);
  font-variant-numeric: tabular-nums; min-height: 100vh;
}
h1, h2, h3, h4, .serif { font-family: 'Newsreader', Georgia, serif; }
a { color: var(--accent2); }
.mono { font-variant-numeric: tabular-nums; }

/* ---- LOGIN ---- */
#login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
#login .box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 34px 32px; width: 100%; max-width: 380px; box-shadow: var(--shadow-lg); text-align: center; }
#login h1 { font-size: 1.5rem; font-weight: 500; color: var(--ink); margin-bottom: 6px; }
#login p { color: var(--ink3); font-size: 0.88rem; margin-bottom: 22px; }
#login input { width: 100%; padding: 0.7rem 0.8rem; border: 1px solid var(--border2); border-radius: var(--r-in); font-size: 1rem; font-family: inherit; background: var(--inset); margin-bottom: 14px; }
#login input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(95,117,96,0.16); }
#login button { width: 100%; padding: 0.75rem; background: var(--ink); color: #fff; border: none; border-radius: var(--r-btn); font-size: 1rem; font-weight: 600; cursor: pointer; font-family: inherit; }
#login button:hover { background: var(--accent2); }
#login .err { color: var(--red); font-size: 0.85rem; margin-top: 12px; min-height: 1em; }

/* ---- HEADER ---- */
.site-header { background: var(--ink); color: #fff; padding: 22px 40px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.site-header h1 { font-size: 1.5rem; font-weight: 500; color: #f3f1e9; letter-spacing: 0.01em; }
.site-header .meta { text-align: right; }
.site-header .meta .asof { color: #b9bdac; font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; }
.site-header .meta .nw { font-size: 1.7rem; font-weight: 600; color: #fff; }

/* ---- NAV ---- */
nav { background: var(--panel); border-bottom: 1px solid var(--border2); padding: 0 28px; display: flex; gap: 2px; overflow-x: auto; position: sticky; top: 0; z-index: 50; }
nav a { padding: 13px 14px; font-size: 0.78rem; font-weight: 600; color: var(--ink3); text-decoration: none; letter-spacing: 0.03em; text-transform: uppercase; border-bottom: 2px solid transparent; white-space: nowrap; }
nav a:hover, nav a.active { color: var(--accent2); border-bottom-color: var(--accent); }

main { max-width: 1140px; margin: 0 auto; padding: 36px 28px 20px; }
section { margin-bottom: 52px; scroll-margin-top: 60px; }
.s-title { font-size: 1.4rem; font-weight: 600; color: var(--ink); }
.s-sub { font-size: 0.84rem; color: var(--ink4); margin: 2px 0 18px; }
.s-divider { height: 1px; background: linear-gradient(to right, var(--accent), transparent); opacity: 0.5; margin-bottom: 22px; }
.label { font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink4); font-weight: 600; }

/* ---- CARDS ---- */
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2,1fr); } .g3 { grid-template-columns: repeat(3,1fr); } .g4 { grid-template-columns: repeat(4,1fr); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: 18px 20px; box-shadow: var(--shadow); }
.card .label { margin-bottom: 7px; }
.card .val { font-size: 1.5rem; font-weight: 600; color: var(--ink); line-height: 1.1; }
.card .val.sm { font-size: 1.2rem; }
.card .sub { font-size: 0.76rem; color: var(--ink3); margin-top: 5px; line-height: 1.5; }
.card.accent { border-left: 3px solid var(--accent); }
.card.green { border-left: 3px solid var(--green); }
.card.amber { border-left: 3px solid var(--amber); }
.card.red   { border-left: 3px solid var(--red); }
.card.blue  { border-left: 3px solid var(--blue); }
.card.gold  { border-left: 3px solid var(--gold); }

.two { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.two > * { min-width: 0; } /* allow grid columns to shrink below content width (mobile) */

/* ---- TABLES ---- */
.tw { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
thead th { text-align: left; padding: 9px 12px; font-size: 0.68rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink4); border-bottom: 1px solid var(--border2); font-weight: 600; }
tbody td { padding: 9px 12px; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--inset); }
.right { text-align: right; }
td.pos, .pos { color: var(--green); font-weight: 600; }
td.neg, .neg { color: var(--red); font-weight: 600; }
tr.total td { font-weight: 700; border-top: 1px solid var(--border2); }

/* ---- BARS ---- */
.bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 9px; }
.bar-lab { font-size: 0.8rem; color: var(--ink2); min-width: 180px; flex-shrink: 0; }
.bar-track { flex: 1; height: 8px; background: var(--panel); border-radius: 5px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 5px; background: var(--accent); }
.bar-amt { font-size: 0.78rem; color: var(--ink3); min-width: 72px; text-align: right; }

/* ---- BADGES ---- */
.badge { display: inline-block; padding: 2px 9px; border-radius: var(--r-pill); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.02em; }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.blue { background: var(--blue-bg); color: var(--blue); }

/* ---- SCORES ---- */
.score { display: flex; align-items: center; gap: 12px; margin-bottom: 11px; }
.score .lab { font-size: 0.82rem; color: var(--ink2); min-width: 200px; }
.score .track { flex: 1; height: 6px; background: var(--panel); border-radius: 3px; overflow: hidden; }
.score .fill { height: 100%; border-radius: 3px; }
.score .v { font-weight: 600; min-width: 30px; text-align: right; font-size: 0.82rem; }

/* ---- TAX / PERSON ---- */
.taxline { display: flex; justify-content: space-between; font-size: 0.83rem; padding: 4px 0; }
.taxline.ded span:last-child { color: var(--green); }
.taxline.tot { font-weight: 700; border-top: 1px solid var(--border2); margin-top: 6px; padding-top: 8px; }

/* ---- PRIORITIES ---- */
.prio { display: flex; gap: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: 15px 18px; box-shadow: var(--shadow); margin-bottom: 12px; }
.prio .num { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.76rem; font-weight: 700; flex-shrink: 0; margin-top: 2px; }
.prio.red .num { background: var(--red-bg); color: var(--red); }
.prio.amber .num { background: var(--amber-bg); color: var(--amber); }
.prio.green .num { background: var(--green-bg); color: var(--green); }
.prio h4 { font-size: 0.95rem; font-weight: 600; margin-bottom: 3px; color: var(--ink); }
.prio p { font-size: 0.82rem; color: var(--ink3); line-height: 1.55; }

/* ---- PROJECTION CONTROLS ---- */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border2); margin-bottom: 20px; flex-wrap: wrap; }
.tab { padding: 9px 16px; font-size: 0.8rem; font-weight: 600; color: var(--ink3); background: none; border: none; border-bottom: 2px solid transparent; cursor: pointer; font-family: inherit; }
.tab:hover { color: var(--accent2); }
.tab.active { color: var(--accent2); border-bottom-color: var(--accent); }
.panel { display: none; } .panel.active { display: block; }
.sl { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; font-size: 0.8rem; }
.sl label { color: var(--ink3); min-width: 200px; flex-shrink: 0; }
.sl input[type=range] { flex: 1; min-width: 0; accent-color: var(--accent); height: 4px; }
.sl select { min-width: 0; max-width: 100%; text-overflow: ellipsis; }
.sl .v { font-weight: 600; min-width: 56px; text-align: right; color: var(--ink); }

.note { font-size: 0.78rem; color: var(--ink4); line-height: 1.6; font-style: italic; }
.callout { background: var(--inset); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--r-card); padding: 14px 16px; font-size: 0.85rem; color: var(--ink2); line-height: 1.6; }
.callout.amber { border-left-color: var(--amber); }
.callout.red { border-left-color: var(--red); }
.formula { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 0.8rem; background: var(--ink); color: #e8e6dc; border-radius: var(--r-in); padding: 14px 16px; line-height: 1.7; overflow-x: auto; white-space: pre; }

/* ---- FOOTER ---- */
footer { background: var(--ink); color: #b9bdac; text-align: center; padding: 22px; font-size: 0.76rem; margin-top: 40px; }
footer a { color: #d7d4c6; cursor: pointer; text-decoration: underline; }
footer .row { margin-top: 8px; }

@media (max-width: 900px) {
  .g3, .g4 { grid-template-columns: repeat(2,1fr); }
  .two { grid-template-columns: 1fr; }
  .site-header { padding: 18px 20px; } main { padding: 28px 18px; }
  .bar-lab, .sl label, .score .lab { min-width: 130px; }
}
@media (max-width: 540px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }
