:root {
  --paper: #f5f6f5;
  --surface: #ffffff;
  --surface-2: #eceeed;
  --ink: #0b0d0e;
  --ink-2: #2e3439;
  --ink-3: #5c6469;
  --ink-4: #7c858b;
  --rule: #d3d8da;
  --rule-2: #e4e8e9;
  --vault: #12314f;
  --vault-700: #1a4269;
  --brass: #9a7b34;
  --brass-100: #eadfc4;
  --green: #33754d;
  --green-soft: #e6f2ea;
  --red: #943a34;
  --red-soft: #f9e9e7;
  --amber: #8a6500;
  --amber-soft: #fff3d6;
  --sans: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Newsreader", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sidebar: 252px;
  --shadow: 0 18px 50px rgba(18, 49, 79, 0.08);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: var(--sans); font-size: 14px; line-height: 1.5; font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
:focus-visible { outline: 2px solid var(--vault); outline-offset: 3px; }
.skip-link { position: fixed; top: 10px; left: 10px; z-index: 100; transform: translateY(-150%); background: var(--ink); color: white; padding: 8px 12px; text-decoration: none; }
.skip-link:focus { transform: translateY(0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(330px, .9fr) minmax(520px, 1.1fr); background: var(--surface); }
.login-brand { color: white; background: var(--vault); padding: clamp(32px, 6vw, 88px); display: flex; flex-direction: column; justify-content: space-between; min-height: 100vh; position: relative; overflow: hidden; }
.login-brand::after { content: ""; position: absolute; width: 460px; height: 460px; border: 1px solid rgba(255,255,255,.16); right: -230px; bottom: -120px; transform: rotate(45deg); }
.brand-lockup { display: inline-flex; align-items: center; gap: 12px; font-size: 25px; font-weight: 600; letter-spacing: -.045em; }
.brand-lockup svg { width: 30px; height: 30px; flex: none; }
.brand-lockup small { display: block; font-family: var(--mono); font-size: 8px; font-weight: 400; letter-spacing: .14em; opacity: .62; text-transform: uppercase; margin-top: -2px; }
.login-statement { position: relative; z-index: 1; max-width: 540px; }
.eyebrow { color: var(--ink-3); font-family: var(--mono); font-size: 10px; font-weight: 500; letter-spacing: .09em; text-transform: uppercase; }
.login-brand .eyebrow { color: #aabaca; }
.login-statement h1 { font-family: var(--serif); font-weight: 300; font-size: clamp(42px, 6vw, 76px); letter-spacing: -.035em; line-height: .98; margin: 18px 0 24px; }
.login-statement p { max-width: 46ch; color: #cad5df; font-size: 16px; }
.login-foot { color: #91a7ba; font-family: var(--mono); font-size: 10px; letter-spacing: .04em; z-index: 1; }
.login-panel { display: grid; place-items: center; padding: 40px; }
.login-card { width: min(520px, 100%); }
.login-card h2 { font-family: var(--serif); font-size: 38px; font-weight: 300; letter-spacing: -.02em; margin: 12px 0 8px; }
.login-card > p { color: var(--ink-3); margin: 0 0 34px; }
.role-options { display: grid; gap: 10px; }
.role-button { width: 100%; border: 1px solid var(--rule); background: var(--surface); padding: 18px; display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 14px; text-align: left; cursor: pointer; transition: border-color .18s, box-shadow .18s, transform .18s; }
.role-button:hover { border-color: var(--vault); box-shadow: var(--shadow); transform: translateY(-1px); }
.role-icon { width: 42px; height: 42px; display: grid; place-items: center; color: white; background: var(--vault); }
.role-icon.client { color: var(--vault); background: var(--surface-2); }
.role-button strong { display: block; font-size: 14px; }
.role-button span { color: var(--ink-3); font-size: 12px; }
.arrow { font-size: 22px; color: var(--ink-4); }
.demo-note { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--rule-2); color: var(--ink-4); font-size: 11px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--vault); color: white; padding: 25px 18px 18px; display: flex; flex-direction: column; z-index: 20; }
.sidebar .brand-lockup { padding: 2px 8px 28px; }
.side-label { color: #91a7ba; font-family: var(--mono); font-size: 9px; text-transform: uppercase; letter-spacing: .1em; padding: 16px 10px 8px; }
.side-nav { display: grid; gap: 3px; }
.nav-button { width: 100%; border: 0; color: #cbd7e2; background: transparent; padding: 10px; display: flex; align-items: center; gap: 11px; text-align: left; font-size: 13px; cursor: pointer; }
.nav-button svg { width: 18px; height: 18px; opacity: .75; }
.nav-button:hover { color: white; background: rgba(255,255,255,.07); }
.nav-button.active { color: white; background: rgba(255,255,255,.12); box-shadow: inset 2px 0 0 white; }
.side-bottom { margin-top: auto; border-top: 1px solid rgba(255,255,255,.14); padding-top: 16px; }
.profile-chip { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 9px; padding: 7px; }
.avatar { display: grid; place-items: center; flex: none; width: 34px; height: 34px; background: #e1e8ee; color: var(--vault); font-size: 11px; font-weight: 600; border-radius: 50%; }
.profile-chip strong { display: block; font-size: 11px; }
.profile-chip small { display: block; color: #91a7ba; font-size: 9px; }
.logout { color: #91a7ba; background: none; border: 0; cursor: pointer; padding: 6px; }

.main-shell { min-width: 0; }
.topbar { height: 68px; padding: 0 clamp(20px, 4vw, 52px); border-bottom: 1px solid var(--rule); background: rgba(245,246,245,.93); backdrop-filter: blur(12px); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 15; }
.crumbs { color: var(--ink-3); font-size: 12px; }
.crumbs strong { color: var(--ink); font-weight: 500; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.status-pill, .tag { display: inline-flex; align-items: center; gap: 6px; width: max-content; border: 1px solid var(--rule); background: var(--surface); color: var(--ink-3); padding: 4px 8px; font-family: var(--mono); font-size: 9px; letter-spacing: .03em; text-transform: uppercase; }
.status-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--amber); }
.mobile-menu { display: none; border: 0; background: none; padding: 8px; }
.content { width: min(1500px, 100%); margin: 0 auto; padding: clamp(24px, 4vw, 52px); }
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 30px; }
.page-head h1 { font-family: var(--serif); font-size: clamp(32px, 4vw, 48px); font-weight: 300; line-height: 1; letter-spacing: -.025em; margin: 7px 0 0; }
.page-head p { color: var(--ink-3); max-width: 700px; margin: 10px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.button { min-height: 38px; border: 1px solid var(--vault); padding: 8px 13px; background: var(--vault); color: white; cursor: pointer; font-size: 12px; font-weight: 500; text-transform: lowercase; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.button:hover { background: var(--vault-700); }
.button.secondary { color: var(--vault); background: transparent; border-color: var(--rule); }
.button.secondary:hover { border-color: var(--vault); background: var(--surface); }
.button.ghost { color: var(--ink-3); background: transparent; border-color: transparent; }
.button.danger { color: var(--red); background: transparent; border-color: var(--rule); }
.button:disabled { cursor: not-allowed; opacity: .45; }
.button svg { width: 15px; height: 15px; }

.grid { display: grid; gap: 14px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { min-width: 0; background: var(--surface); border: 1px solid var(--rule); padding: 20px; }
.card.soft { background: transparent; }
.card.vault { color: white; background: var(--vault); border-color: var(--vault); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.card-head h2, .card-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.card-head p { color: var(--ink-3); font-size: 11px; margin: 3px 0 0; }
.card.vault .card-head p { color: #9db0c1; }
.metric-label { color: var(--ink-3); font-family: var(--mono); font-size: 9px; letter-spacing: .07em; text-transform: uppercase; }
.metric-value { font-size: clamp(24px, 3vw, 34px); font-weight: 500; letter-spacing: -.04em; margin: 8px 0 3px; }
.metric-note { color: var(--ink-4); font-size: 10px; }
.metric-value.positive, .positive { color: var(--green); }
.metric-value.negative, .negative { color: var(--red); }
.card.vault .metric-label, .card.vault .metric-note { color: #9db0c1; }
.card.vault .metric-value { color: white; }

.briefing { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, .6fr); padding: 0; overflow: hidden; margin-bottom: 14px; }
.brief-main { padding: clamp(24px, 3.5vw, 42px); }
.brief-main h2 { font-family: var(--serif); font-size: clamp(28px, 3vw, 42px); font-weight: 300; line-height: 1.12; margin: 10px 0 22px; max-width: 24ch; }
.brief-points { display: grid; gap: 12px; }
.brief-point { display: grid; grid-template-columns: 22px 1fr; gap: 10px; color: #d2dde6; font-size: 12px; }
.brief-point b { color: white; font-family: var(--mono); font-size: 9px; padding-top: 2px; }
.brief-side { background: #0e1f33; padding: 28px; display: flex; flex-direction: column; justify-content: space-between; }
.freshness { color: #e8c978; font-family: var(--mono); font-size: 9px; text-transform: uppercase; letter-spacing: .06em; }
.advisor-quote { font-family: var(--serif); font-size: 20px; font-weight: 300; line-height: 1.35; margin-top: 35px; }

.section { margin-top: 28px; }
.section-title { display: flex; justify-content: space-between; align-items: end; gap: 20px; border-bottom: 1px solid var(--ink); padding-bottom: 9px; margin-bottom: 14px; }
.section-title h2 { font-size: 15px; margin: 0; }
.section-title p { color: var(--ink-4); font-size: 10px; margin: 0; }
.signal-list { display: grid; }
.signal-row { display: grid; grid-template-columns: 1.2fr .8fr .8fr .8fr; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--rule-2); font-size: 12px; }
.signal-row:last-child { border-bottom: 0; }
.signal-row .tag { justify-self: end; }
.tag.positive { color: var(--green); border-color: #b7d3c0; background: var(--green-soft); }
.tag.negative { color: var(--red); border-color: #e4bbb7; background: var(--red-soft); }
.tag.neutral { color: var(--ink-3); background: var(--surface-2); }

.client-table-wrap, .table-wrap { overflow-x: auto; border: 1px solid var(--rule); background: var(--surface); }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th { color: var(--ink-4); font-family: var(--mono); font-size: 9px; font-weight: 500; letter-spacing: .06em; text-align: left; text-transform: uppercase; padding: 11px 16px; border-bottom: 1px solid var(--rule); background: #fafbfa; }
td { padding: 14px 16px; border-bottom: 1px solid var(--rule-2); font-size: 12px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: #f8f9f8; }
.client-cell { display: flex; align-items: center; gap: 11px; }
.client-cell strong { display: block; font-size: 12px; }
.client-cell small { color: var(--ink-4); font-size: 9px; }
.mono { font-family: var(--mono); }
.text-muted { color: var(--ink-3); }
.alert-count { display: inline-flex; align-items: center; gap: 5px; color: var(--red); font-size: 10px; }
.alert-count::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.toolbar { display: flex; gap: 10px; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.search { width: min(340px, 100%); border: 1px solid var(--rule); background: var(--surface); padding: 10px 12px; }

.client-hero { background: var(--vault); color: white; padding: clamp(24px, 4vw, 40px); margin-bottom: 0; display: grid; grid-template-columns: 1.2fr 1fr; gap: 30px; align-items: end; }
.client-identity { display: flex; align-items: center; gap: 16px; }
.client-identity .avatar { width: 50px; height: 50px; background: white; font-size: 14px; }
.client-identity h1 { font-family: var(--serif); font-size: clamp(30px, 4vw, 44px); font-weight: 300; line-height: 1; margin: 0 0 6px; }
.client-identity p { color: #aebdca; margin: 0; font-size: 11px; }
.hero-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.hero-metrics .metric-value { font-size: 20px; }
.client-tabs { display: flex; gap: 0; overflow-x: auto; border: 1px solid var(--rule); border-top: 0; background: var(--surface); padding: 0 18px; margin-bottom: 26px; }
.tab-button { white-space: nowrap; background: none; border: 0; border-bottom: 2px solid transparent; padding: 15px 13px 13px; color: var(--ink-3); cursor: pointer; font-size: 11px; }
.tab-button.active { color: var(--ink); border-bottom-color: var(--vault); font-weight: 600; }

.allocation-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 28px; align-items: center; }
.donut { width: 210px; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; position: relative; margin: auto; }
.donut::after { content: ""; width: 112px; aspect-ratio: 1; border-radius: 50%; background: var(--surface); position: absolute; }
.donut-center { z-index: 1; text-align: center; }
.donut-center strong { display: block; font-size: 18px; }
.donut-center small { color: var(--ink-4); font-size: 9px; }
.allocation-list { display: grid; gap: 11px; }
.allocation-row { display: grid; grid-template-columns: 12px 1fr auto auto; gap: 10px; align-items: center; font-size: 11px; }
.swatch { width: 9px; height: 9px; }
.allocation-row strong { font-size: 11px; }
.allocation-row span:last-child { width: 86px; text-align: right; color: var(--ink-3); }
.bar-track { height: 4px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; background: var(--vault); }

.alert-list { display: grid; gap: 8px; }
.alert { display: grid; grid-template-columns: 4px 1fr; gap: 12px; border: 1px solid var(--rule); background: var(--surface); padding: 14px; }
.alert::before { content: ""; background: var(--amber); }
.alert.high::before { background: var(--red); }
.alert strong { display: block; font-size: 11px; margin-bottom: 3px; }
.alert p { color: var(--ink-3); font-size: 10px; margin: 0; }
.empty-metric { color: var(--ink-4); font-size: 24px; margin: 10px 0 4px; }

.policy-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0; border: 1px solid var(--rule); background: var(--surface); }
.policy-item { padding: 17px; border-bottom: 1px solid var(--rule-2); }
.policy-item:nth-child(odd) { border-right: 1px solid var(--rule-2); }
.policy-item dt { color: var(--ink-4); font-family: var(--mono); font-size: 9px; text-transform: uppercase; letter-spacing: .05em; }
.policy-item dd { margin: 6px 0 0; font-size: 12px; }
.timeline { position: relative; display: grid; gap: 0; }
.timeline-item { display: grid; grid-template-columns: 86px 16px 1fr; gap: 10px; min-height: 86px; }
.timeline-date { color: var(--ink-4); font-family: var(--mono); font-size: 9px; padding-top: 2px; text-align: right; }
.timeline-mark { position: relative; }
.timeline-mark::before { content: ""; position: absolute; left: 7px; top: 7px; bottom: -7px; width: 1px; background: var(--rule); }
.timeline-mark::after { content: ""; position: absolute; left: 3px; top: 3px; width: 8px; height: 8px; background: var(--surface); border: 2px solid var(--vault); border-radius: 50%; }
.timeline-item:last-child .timeline-mark::before { display: none; }
.timeline-content strong { display: block; font-size: 12px; }
.timeline-content p { color: var(--ink-3); font-size: 10px; margin: 4px 0 0; }

.meeting-shell { max-width: 1050px; margin: 0 auto; }
.stepper { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--rule); background: var(--surface); margin-bottom: 18px; }
.step { padding: 13px 16px; color: var(--ink-4); font-size: 10px; border-right: 1px solid var(--rule-2); }
.step:last-child { border-right: 0; }
.step b { font-family: var(--mono); font-size: 8px; display: block; margin-bottom: 3px; }
.step.active { color: white; background: var(--vault); }
.step.done { color: var(--green); background: var(--green-soft); }
.meeting-panel { background: var(--surface); border: 1px solid var(--rule); padding: clamp(22px, 4vw, 38px); }
.meeting-panel h2 { font-family: var(--serif); font-size: 31px; font-weight: 300; margin: 0 0 8px; }
.meeting-panel > p { color: var(--ink-3); margin: 0 0 26px; }
.discussion-list { display: grid; gap: 10px; }
.discussion { display: grid; grid-template-columns: 28px 1fr; gap: 11px; border-top: 1px solid var(--rule-2); padding-top: 13px; }
.discussion b { color: var(--ink-4); font-family: var(--mono); font-size: 9px; }
.discussion strong { display: block; font-size: 12px; }
.discussion p { color: var(--ink-3); font-size: 10px; margin: 3px 0 0; }
.meeting-footer { display: flex; justify-content: space-between; gap: 12px; margin-top: 26px; }
.field { display: grid; gap: 6px; }
.field label { font-size: 10px; font-weight: 600; }
.field textarea { width: 100%; min-height: 130px; border: 1px solid var(--rule); resize: vertical; padding: 12px; background: #fcfdfc; }
.allocation-editor { display: grid; gap: 9px; }
.allocation-input { display: grid; grid-template-columns: 1fr minmax(160px, 1.5fr) 80px 110px; align-items: center; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--rule-2); }
.allocation-input label { font-size: 11px; }
.allocation-input input[type="range"] { accent-color: var(--vault); }
.allocation-input input[type="number"] { width: 100%; padding: 8px; border: 1px solid var(--rule); text-align: right; }
.allocation-input .value { color: var(--ink-3); text-align: right; font-size: 10px; }
.reconcile { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 13px; margin-top: 14px; background: var(--red-soft); color: var(--red); font-size: 11px; }
.reconcile.valid { background: var(--green-soft); color: var(--green); }
.comparison { display: grid; gap: 0; }
.compare-row { display: grid; grid-template-columns: 1fr 100px 28px 100px 90px; gap: 10px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--rule-2); font-size: 11px; }
.delta-up { color: var(--green); }
.delta-down { color: var(--red); }
.letter-editor { width: 100%; min-height: 420px; padding: 20px; border: 1px solid var(--rule); font-family: var(--serif); font-size: 16px; line-height: 1.62; resize: vertical; }
.letter-paper { max-width: 760px; margin: auto; padding: clamp(28px, 6vw, 68px); background: white; border: 1px solid var(--rule); box-shadow: var(--shadow); }
.letter-paper h2 { font-family: var(--serif); font-weight: 300; font-size: 34px; }
.letter-meta { display: flex; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--ink); padding-bottom: 14px; margin-bottom: 32px; color: var(--ink-4); font-family: var(--mono); font-size: 9px; }
.letter-content { font-family: var(--serif); font-size: 16px; line-height: 1.7; white-space: pre-wrap; }

.client-mode .sidebar { background: #0e1f33; }
.client-mode .content { max-width: 1260px; }
.client-welcome { display: grid; grid-template-columns: 1.4fr .6fr; gap: 14px; }
.client-welcome .card.vault { padding: clamp(26px, 4vw, 46px); }
.client-welcome h1 { font-family: var(--serif); font-size: clamp(34px, 4vw, 50px); font-weight: 300; margin: 9px 0 14px; }
.client-welcome p { color: #b9c8d5; max-width: 55ch; }

.toast { position: fixed; right: 20px; bottom: 20px; z-index: 100; color: white; background: var(--ink); padding: 11px 15px; font-size: 11px; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1100px) {
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
  .briefing, .client-hero, .client-welcome { grid-template-columns: 1fr; }
  .brief-side { min-height: 240px; }
  .hero-metrics { margin-top: 10px; }
}

@media (max-width: 820px) {
  :root { --sidebar: 220px; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; transform: translateX(-101%); transition: transform .2s; width: var(--sidebar); }
  .app-shell.menu-open .sidebar { transform: translateX(0); box-shadow: 20px 0 50px rgba(0,0,0,.18); }
  .mobile-menu { display: inline-grid; place-items: center; }
  .topbar { padding: 0 18px; }
  .allocation-layout { grid-template-columns: 1fr; }
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { min-height: 340px; }
  .login-panel { padding: 34px 20px; }
}

@media (max-width: 620px) {
  .content { padding: 24px 15px 40px; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .page-actions { justify-content: flex-start; }
  .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
  .hero-metrics { grid-template-columns: 1fr 1fr; }
  .policy-grid { grid-template-columns: 1fr; }
  .policy-item:nth-child(odd) { border-right: 0; }
  .stepper { grid-template-columns: 1fr 1fr; }
  .step:nth-child(2) { border-right: 0; }
  .allocation-input { grid-template-columns: 1fr 72px; }
  .allocation-input input[type="range"], .allocation-input .value { grid-column: 1 / -1; }
  .compare-row { grid-template-columns: 1fr 70px 20px 70px; }
  .compare-row span:last-child { grid-column: 2 / -1; text-align: right; }
  .top-actions .status-pill { display: none; }
}

@media print {
  .sidebar, .topbar, .client-tabs, .page-actions, .meeting-footer { display: none !important; }
  .app-shell { display: block; }
  .content { padding: 0; }
  .letter-paper { box-shadow: none; border: 0; max-width: none; }
}
