/* Advisor dashboard. Bryan's prototype's tokens and layout (globals.css, Sidebar.tsx), hand-written so
   there is no build step. No inline styles anywhere: the page's CSP forbids them. */

:root {
  --background: #f5f6f8;
  --foreground: #1a1d23;
  --card: #ffffff;
  --card-border: #e8eaef;
  --accent: #4f6ef7;
  --accent-light: #eef1fe;
  --buy: #16a34a;
  --buy-bg: #ecfdf3;
  --hold: #d97706;
  --hold-bg: #fff7e6;
  --watch: #dc2626;
  --watch-bg: #fef2f2;
  --muted: #6e7484;
  --surface: #f7f8fa;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.03);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-width: 240px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font: 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1 { font-size: 20px; margin: 0; text-wrap: balance; }
h2 { font-size: 15px; margin: 0 0 10px; }
h3 { font-size: 12px; margin: 0 0 8px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
p { margin: 0 0 8px; max-width: 75ch; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
td.prose { min-width: 180px; }
.hidden { display: none !important; }

/* ---- shell ---- */
.shell { display: grid; grid-template-columns: var(--sidebar-width) 1fr; min-height: 100vh; }
.sidebar {
  background: #fff;
  border-right: 1px solid var(--card-border);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { font-weight: 700; font-size: 15px; padding: 0 10px; }
.brand span { display: block; font-weight: 500; font-size: 11px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav h3 { padding: 0 10px; margin: 8px 0 4px; font-size: 10px; }
.nav a { color: var(--foreground); padding: 7px 10px; border-radius: var(--radius-sm); }
.nav a:hover { background: #f8f9fb; text-decoration: none; }
.nav a.active { background: #f0f3ff; color: var(--accent); font-weight: 600; }
.sidebar .who { margin-top: auto; padding: 0 10px; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
main { padding: 20px 24px 40px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.page-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; }

/* ---- freshness ---- */
.strip { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--muted); }
.strip b { color: var(--foreground); font-weight: 600; }
.strip .bad { color: var(--watch); }
.banner {
  background: var(--accent-light);
  border: 1px solid #d6defd;
  color: var(--foreground);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.notice { background: var(--hold-bg); border: 1px solid #fde4b8; padding: 10px 14px; border-radius: var(--radius-sm); }
.notice.ok { background: var(--buy-bg); border-color: #bbf0cf; }
.notice.bad { background: var(--watch-bg); border-color: #fbd0d0; }
ul.plain { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }

/* ---- cards and grids ---- */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  min-width: 0;
}
.grid { display: grid; gap: 12px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius); padding: 12px 14px; }
.stat .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat .value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sleeve-card { display: flex; flex-direction: column; gap: 6px; }
.sleeve-card .title { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* ---- pills ---- */
.pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  border: 1px solid transparent;
}
.sig-BUY { color: var(--buy); background: var(--buy-bg); }
.sig-HOLD { color: var(--hold); background: var(--hold-bg); }
.sig-WATCH { color: var(--watch); background: var(--watch-bg); }
.sig-NOT-SCORED { color: var(--muted); background: var(--surface); border-color: var(--card-border); }
.act-TRIM, .act-EXIT { color: #fff; background: var(--watch); }
.act-WATCH { color: var(--hold); background: var(--hold-bg); }
.act-HOLD { color: var(--muted); background: var(--surface); }
.st-action_required { color: #fff; background: var(--watch); }
.st-review { color: var(--hold); background: var(--hold-bg); }
.st-all_clear { color: var(--buy); background: var(--buy-bg); }
.flag { color: var(--hold); font-size: 11px; font-weight: 600; }
.tilt-OW { color: var(--buy); font-weight: 700; }
.tilt-UW { color: var(--watch); font-weight: 700; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; border: 1px solid var(--card-border); border-radius: var(--radius); background: var(--card); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--card-border); text-align: left; vertical-align: top; }
th { background: var(--surface); font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); font-weight: 600; white-space: nowrap; position: sticky; top: 0; }
tbody tr:hover { background: #fafbfd; }
tr.group td { background: var(--surface); font-weight: 600; }
tr:last-child td { border-bottom: 0; }

/* ---- forms ---- */
.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 6px; color: var(--foreground); font-size: 13px; }
input, select, textarea {
  font: inherit;
  color: inherit;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 6px 9px;
  background: #fff;
  min-width: 0;
}
textarea { width: 100%; min-height: 140px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
input.narrow { width: 90px; text-align: right; }
.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--card-border);
  background: #fff;
  color: var(--foreground);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: #f8f9fb; text-decoration: none; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: #4361e6; }
.btn.danger { color: var(--watch); }
.btn.good { color: var(--buy); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
details summary { cursor: pointer; color: var(--accent); font-weight: 600; }
details[open] summary { margin-bottom: 10px; }
.columns-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 4px 12px; }

/* ---- regime timeline: one cell per month, colored by regime ---- */
.timeline { display: flex; flex-direction: column; gap: 3px; }
.timeline .year { display: grid; grid-template-columns: 44px repeat(12, 1fr); gap: 2px; align-items: center; font-size: 11px; }
.cell { height: 14px; border-radius: 2px; background: var(--surface); }
.rg-policy_reflation { background: #93c5fd; }
.rg-early_expansion { background: #86efac; }
.rg-goldilocks { background: #4ade80; }
.rg-late_cycle { background: #fcd34d; }
.rg-inflation_shock { background: #fb923c; }
.rg-growth_scare { background: #fca5a5; }
.rg-recession { background: #f87171; }
.rg-liquidity_crisis { background: #b91c1c; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i, i.cell { width: 12px; height: 12px; border-radius: 2px; display: inline-block; vertical-align: -1px; }

/* ---- sign-in ---- */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.signin .card { width: min(420px, 100%); display: flex; flex-direction: column; gap: 12px; }
.signin .brand { padding: 0; }
.signin form { display: flex; flex-direction: column; gap: 10px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 12px 16px; gap: 8px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav h3 { display: none; }
  main { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
