:root {
  --ink: #142321;
  --muted: #6b7773;
  --paper: #f6f5f0;
  --card: #fffef9;
  --line: #e1e3d9;
  --sage: #8ca69a;
  --sage-deep: #356158;
  --moss: #173f3a;
  --amber: #d99b4a;
  --rose: #ba665b;
  --shadow: 0 16px 48px rgba(26, 45, 39, .08);
  --radius: 18px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}
a { color: var(--sage-deep); text-decoration: none; }
a:hover { color: var(--moss); text-decoration: underline; }
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; background: var(--moss); color: #ecf1e9; padding: 28px 20px;
  display: flex; flex-direction: column; gap: 26px; flex-shrink: 0;
}
.brand { display: flex; gap: 12px; align-items: center; color: #fff; }
.brand-mark { width: 38px; height: 38px; border-radius: 13px; background: #dce7d8; color: var(--moss); display: grid; place-items: center; font-weight: 800; }
.brand strong { display: block; letter-spacing: -.02em; }
.brand small { display: block; color: #b9cdc2; margin-top: 2px; }
.nav { display: grid; gap: 4px; }
.nav a { color: #b9cdc2; border-radius: 11px; padding: 10px 12px; font-size: 14px; }
.nav a:hover, .nav a.active { color: #fff; background: rgba(255,255,255,.11); text-decoration: none; }
.sidebar-footer { margin-top: auto; color: #b9cdc2; font-size: 12px; }
.content { flex: 1; min-width: 0; padding: 34px 42px 60px; }
.topbar { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 28px; }
.eyebrow { color: var(--sage-deep); font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
h1, h2, h3 { letter-spacing: -.04em; line-height: 1.08; margin: 0; }
h1 { font-size: clamp(28px, 4vw, 46px); max-width: 700px; }
h2 { font-size: 23px; }
h3 { font-size: 18px; }
.subtitle { color: var(--muted); margin: 10px 0 0; max-width: 700px; }
.actions { display: flex; flex-wrap: wrap; gap: 9px; justify-content: flex-end; }
.btn {
  border: 1px solid var(--line); border-radius: 11px; padding: 10px 14px; background: var(--card);
  color: var(--ink); font-size: 13px; font-weight: 750; cursor: pointer; display: inline-block;
}
.btn:hover { border-color: var(--sage); text-decoration: none; }
.btn.primary { background: var(--moss); border-color: var(--moss); color: #fff; }
.btn.soft { background: #e5efe7; color: var(--moss); border-color: #d3e1d5; }
.btn.danger { background: #fff2ee; color: #8f4139; border-color: #eed2c9; }
.grid { display: grid; gap: 18px; }
.grid.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.two { grid-template-columns: minmax(0, 1.45fr) minmax(290px, .75fr); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.kpi-label { color: var(--muted); font-size: 13px; }
.kpi-value { font-size: clamp(24px, 3vw, 34px); font-weight: 790; letter-spacing: -.05em; margin: 5px 0; }
.kpi-meta { color: var(--muted); font-size: 12px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.section-head p { margin: 0; color: var(--muted); font-size: 13px; }
.chart-wrap { height: 290px; position: relative; }
.chart-section-head { align-items: flex-start; }
.chart-horizons { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.chart-horizons .btn { padding: 7px 10px; font-size: 12px; }
.warning { background: #fff5df; border: 1px solid #efd8a6; color: #76531d; border-radius: 12px; padding: 12px 14px; font-size: 13px; margin-bottom: 10px; }
.success { background: #e7f1e8; border: 1px solid #c5dcc9; color: #2e5d45; border-radius: 12px; padding: 12px 14px; font-size: 13px; margin-bottom: 10px; }
.error { background: #fff0ec; border: 1px solid #ebc7bd; color: #8f4139; border-radius: 12px; padding: 12px 14px; font-size: 13px; margin-bottom: 10px; }
.messages { margin-bottom: 18px; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 700px; }
th { text-align: left; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 13px 10px; border-bottom: 1px solid #eceee7; font-size: 13px; white-space: nowrap; vertical-align: middle; }
tbody tr:hover { background: #fafbf5; }
td.num, th.num { text-align: right; }
.ticker { font-weight: 800; color: var(--moss); }
.muted { color: var(--muted); }
.badge { display: inline-flex; align-items: center; border-radius: 99px; padding: 4px 8px; font-size: 11px; font-weight: 750; background: #edf2eb; color: var(--sage-deep); }
.badge.warn { background: #fff1cf; color: #76531d; }
.badge.other { background: #f0e7e1; color: #805041; }
.form-card { max-width: 720px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.form-field { display: grid; gap: 6px; }
.form-field.full { grid-column: 1 / -1; }
label { font-size: 13px; font-weight: 700; }
input, select, textarea {
  width: 100%; border: 1px solid #d7ddd4; background: #fff; border-radius: 10px; padding: 10px 11px;
  color: var(--ink); font: inherit; font-size: 14px;
}
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(140,166,154,.25); border-color: var(--sage-deep); }
.helptext { font-size: 12px; color: var(--muted); }
ul.errorlist { list-style: none; color: var(--rose); padding: 0; margin: 0; font-size: 12px; }
.empty { color: var(--muted); text-align: center; padding: 34px 12px; }
.stat-list { display: grid; gap: 13px; }
.stat-row { display: flex; justify-content: space-between; gap: 15px; align-items: baseline; border-bottom: 1px dashed var(--line); padding-bottom: 10px; }
.stat-row:last-child { border-bottom: 0; padding-bottom: 0; }
.stat-row span:first-child { color: var(--muted); font-size: 13px; }
.stat-row span small { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; }
.stat-row strong { text-align: right; }
.login-page { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at 30% 10%, #dce9dc, transparent 40%), var(--paper); padding: 20px; }
.login-box { max-width: 440px; width: 100%; }
.login-box .brand { color: var(--moss); margin-bottom: 28px; }
.login-box .brand small { color: var(--muted); }
.login-box .card { padding: 30px; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: #edf1eb; padding: 2px 5px; border-radius: 5px; }
@media (max-width: 1100px) {
  .grid.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.two { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { display: block; }
  .sidebar { width: auto; padding: 16px 18px; gap: 16px; }
  .nav { display: flex; overflow-x: auto; gap: 2px; }
  .nav a { white-space: nowrap; }
  .sidebar-footer { display: none; }
  .content { padding: 24px 18px 42px; }
  .topbar { display: block; }
  .actions { justify-content: flex-start; margin-top: 18px; }
  .chart-section-head { display: block; }
  .chart-horizons { justify-content: flex-start; margin-top: 12px; }
  .grid.kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { padding: 17px; border-radius: 15px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-field.full { grid-column: auto; }
}

/* Effective exposure dashboard */
.exposure-topbar { margin-bottom: 20px; }
.exposure-topbar h1 { max-width: 760px; }
.exposure-summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 0 0 18px; }
.exposure-metric { background: var(--moss); color: #fff; border-radius: 16px; padding: 18px 20px; box-shadow: var(--shadow); }
.exposure-metric.warning { background: #604d2d; }
.exposure-metric span, .exposure-metric small { display: block; color: #bed3c9; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; }
.exposure-metric strong { display: block; font-size: clamp(24px, 3vw, 32px); letter-spacing: -.05em; margin: 7px 0 3px; }
.exposure-dashboard-card { padding-bottom: 18px; }
.exposure-section-head { margin-bottom: 12px; }
.exposure-controls { display: flex; align-items: center; gap: 9px; }
.exposure-controls label, .etf-top-control { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.exposure-controls input, .etf-top-control input { width: 70px; height: 36px; padding: 0 8px; }
.exposure-dashboard { display: grid; grid-template-columns: minmax(330px, .85fr) minmax(520px, 1.6fr); gap: 24px; }
.exposure-chart-panel { position: relative; min-height: 510px; padding: 12px 8px 8px; }
.exposure-chart-panel svg, .etf-chart-panel svg { width: min(330px, 100%); display: block; margin: 0 auto; }
.exposure-chart-center, .etf-chart-center { position: absolute; left: 50%; top: 181px; transform: translate(-50%, -50%); text-align: center; pointer-events: none; }
.exposure-chart-center strong, .etf-chart-center strong { display: block; font-size: 29px; letter-spacing: -.04em; }
.exposure-chart-center span, .etf-chart-center span { display: block; color: var(--muted); font-size: 10px; letter-spacing: .06em; }
.exposure-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin: 4px 12px; }
.exposure-legend-item { display: grid; grid-template-columns: 9px 1fr auto; align-items: center; gap: 7px; min-width: 0; font-size: 11px; }
.exposure-legend-item i { width: 9px; height: 9px; border-radius: 3px; }
.exposure-legend-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exposure-legend-item b { font-weight: 650; font-variant-numeric: tabular-nums; }
.exposure-chart-slice { cursor: help; transition: opacity .12s ease; }
.exposure-chart-slice:hover, .exposure-chart-slice:focus { opacity: .8; outline: none; }
.exposure-holdings-panel { min-width: 0; }
.exposure-search-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 11px 0; }
.exposure-search-row input { width: 250px; height: 37px; }
.exposure-search-row span { color: var(--muted); font-size: 12px; }
.exposure-table-scroll { height: 485px; }
.exposure-table-scroll thead, .etf-holdings-scroll thead { position: sticky; top: 0; z-index: 1; }
.exposure-table-scroll th[data-sort] { cursor: pointer; }
.exposure-table-scroll th[data-sort]:hover, .exposure-table-scroll th[data-sort]:focus { color: var(--moss); background: #eaf0ea; outline: none; }
.company-cell strong, .company-cell span { display: block; }
.company-cell span { color: var(--muted); font-size: 11px; margin-top: 3px; }
.weight-cell { font-weight: 750; font-variant-numeric: tabular-nums; }
.exposure-breakdown-trigger { cursor: help; text-decoration: underline dotted #7b9186; text-underline-offset: 3px; }
.exposure-source-pill { display: inline-block; padding: 3px 6px; border-radius: 5px; background: #e7efeb; color: #315f4b; font-size: 10px; margin: 1px; }
.exposure-source-card { margin-top: 18px; }
.exposure-source-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.exposure-source-item { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 11px; padding: 13px; background: var(--card); color: var(--ink); text-align: left; }
button.exposure-source-item { width: 100%; font: inherit; cursor: pointer; transition: border-color .15s, transform .15s, box-shadow .15s; }
button.exposure-source-item:hover { border-color: var(--sage); transform: translateY(-1px); box-shadow: 0 8px 20px rgba(24, 79, 60, .09); }
button.exposure-source-item:focus-visible { outline: 3px solid rgba(49, 112, 82, .22); outline-offset: 2px; }
.exposure-status-dot { width: 9px; height: 9px; border-radius: 50%; background: #48a477; }
.exposure-status-dot.bad { background: var(--rose); }
.exposure-source-item strong, .exposure-source-item span { display: block; }
.exposure-source-item strong { font-size: 13px; }
.exposure-source-item span { color: var(--muted); font-size: 11px; margin-top: 3px; }
.exposure-source-item > em { color: var(--muted); font-size: 11px; font-style: normal; text-align: right; white-space: nowrap; }
.exposure-howto { display: flex; align-items: flex-start; gap: 10px; margin: 16px 2px 0; color: var(--muted); font-size: 12px; }
.exposure-howto p { margin: 0; max-width: 850px; }
.exposure-howto strong { color: var(--ink); }
.exposure-howto-icon { display: grid; place-items: center; flex: 0 0 24px; width: 24px; height: 24px; background: #e5efe7; border-radius: 8px; color: var(--moss); font-weight: 800; }
.exposure-tooltip { position: fixed; z-index: 1100; display: none; min-width: 220px; max-width: 300px; padding: 13px 14px; border-radius: 11px; background: #17221d; color: #fff; box-shadow: 0 12px 34px rgba(12, 28, 21, .28); pointer-events: none; font-size: 12px; }
.exposure-tooltip.show { display: block; }
.tooltip-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 10px; }
.tooltip-heading strong { font-size: 13px; line-height: 1.3; }
.tooltip-heading span { color: #a9c3b6; font-size: 10px; padding-top: 2px; }
.tooltip-summary, .tooltip-row { display: flex; justify-content: space-between; gap: 20px; padding: 3px 0; }
.tooltip-summary span, .tooltip-empty { color: #b9c9c1; }
.tooltip-summary b, .tooltip-row b { font-variant-numeric: tabular-nums; }
.tooltip-divider { border-top: 1px solid rgba(255, 255, 255, .16); margin: 7px 0 5px; }
.tooltip-total { font-weight: 700; margin-bottom: 3px; }
.tooltip-row span { color: #d8e5df; }
.tooltip-empty { padding-top: 4px; font-style: italic; }

.etf-dialog { width: min(1100px, calc(100% - 32px)); max-width: none; max-height: calc(100vh - 32px); padding: 0; border: 0; border-radius: 20px; background: var(--card); color: var(--ink); box-shadow: 0 28px 80px rgba(10, 30, 20, .28); }
.etf-dialog::backdrop { background: rgba(15, 29, 22, .56); backdrop-filter: blur(3px); }
.etf-dialog-shell { padding: 25px; }
.etf-dialog-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding-bottom: 17px; border-bottom: 1px solid var(--line); }
.etf-dialog-header .eyebrow { margin-bottom: 7px; }
.etf-dialog-header h2 { font-size: 30px; }
.etf-dialog-header p:last-child { color: var(--muted); font-size: 12px; margin: 7px 0 0; }
.etf-dialog-actions { display: flex; align-items: center; gap: 12px; }
.dialog-close { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border-radius: 50%; background: #edf2ef; color: var(--moss); font-size: 24px; }
.etf-detail-grid { display: grid; grid-template-columns: minmax(320px, .85fr) minmax(480px, 1.35fr); gap: 25px; padding-top: 18px; }
.etf-chart-panel { position: relative; }
.etf-chart-center { top: 165px; }
.etf-legend { margin-top: 2px; }
.etf-detail-slice { cursor: help; transition: opacity .15s; }
.etf-detail-slice:hover, .etf-detail-slice:focus { opacity: .78; outline: none; }
.etf-table-summary { display: flex; align-items: baseline; gap: 8px; margin: 5px 0 11px; }
.etf-table-summary strong { font-size: 24px; }
.etf-table-summary span { color: var(--muted); font-size: 12px; }
.etf-holdings-scroll { max-height: 525px; overflow: auto; }
.etf-holdings-scroll th:nth-child(n+2), .etf-holdings-scroll td:nth-child(n+2) { text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 1100px) {
  .exposure-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .exposure-dashboard { grid-template-columns: 1fr; }
  .exposure-source-list { grid-template-columns: 1fr; }
  .exposure-chart-panel { min-height: auto; }
  .etf-detail-grid { grid-template-columns: 1fr; }
  .etf-holdings-scroll { max-height: 420px; }
}
@media (max-width: 760px) {
  .exposure-controls { align-items: flex-start; margin-top: 14px; }
  .exposure-section-head { display: block; }
  .exposure-search-row input { width: 100%; }
  .exposure-search-row { align-items: stretch; flex-direction: column; }
  .exposure-legend { grid-template-columns: 1fr; }
  .etf-dialog { width: calc(100% - 16px); max-height: calc(100vh - 16px); }
  .etf-dialog-shell { padding: 18px; }
  .etf-dialog-header { align-items: flex-start; }
  .etf-dialog-actions { align-items: flex-end; flex-direction: column-reverse; }
}

/* ETF allocation tracker */
.allocation-topbar { margin-bottom: 20px; }
.allocation-source-note { color: var(--muted); font-size: 12px; }
.allocation-setup-card { margin-bottom: 18px; }
.allocation-setup-grid { display: grid; grid-template-columns: minmax(220px, .65fr) minmax(420px, 1.35fr); gap: 14px; }
.allocation-control-card { border: 1px solid var(--line); border-radius: 13px; padding: 15px; background: #fbfcf8; }
.allocation-control-card > label, .allocation-picker-head label { display: block; font-size: 13px; font-weight: 750; }
.allocation-control-card > input { margin-top: 9px; max-width: 140px; }
.allocation-control-card small { display: block; color: var(--muted); font-size: 12px; margin-top: 8px; }
.allocation-picker-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.allocation-picker-head > span { color: var(--muted); font-size: 12px; }
.allocation-checkboxes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.allocation-checkbox { display: flex; align-items: center; gap: 8px; min-width: 0; border: 1px solid #dce5dd; border-radius: 10px; padding: 8px 9px; background: #fff; cursor: pointer; }
.allocation-checkbox:has(input:checked) { border-color: var(--sage); background: #eef5ee; }
.allocation-checkbox input { width: auto; margin: 0; accent-color: var(--moss); }
.allocation-checkbox span { min-width: 0; }
.allocation-checkbox strong, .allocation-checkbox small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.allocation-checkbox strong { color: var(--moss); font-size: 13px; }
.allocation-checkbox small { color: var(--muted); font-size: 10px; margin-top: 1px; }
.allocation-form-actions { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-top: 15px; }
.allocation-form-actions p { margin: 0; font-size: 12px; }
.allocation-summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 0 0 18px; }
.allocation-metric { background: #e8f2e9; border: 1px solid #d2e2d3; border-radius: 16px; padding: 17px 19px; color: var(--moss); }
.allocation-metric span, .allocation-metric small { display: block; color: var(--sage-deep); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; }
.allocation-metric strong { display: block; font-size: 27px; letter-spacing: -.04em; margin: 6px 0 3px; }
.allocation-metric-source { font-size: 19px !important; line-height: 1.15; min-height: 44px; }
.allocation-table-card { padding-bottom: 15px; }
.allocation-table-head { align-items: flex-start; }
.allocation-table-actions { display: flex; align-items: center; gap: 8px; }
.allocation-search input { width: 225px; height: 38px; }
.allocation-table-scroll { max-height: 625px; overflow: auto; }
.allocation-table-scroll table { min-width: 980px; }
.allocation-table-scroll thead { position: sticky; top: 0; z-index: 1; }
.allocation-table-scroll th[data-sort] { cursor: pointer; }
.allocation-table-scroll th[data-sort]:hover, .allocation-table-scroll th[data-sort]:focus { color: var(--moss); background: #eaf0ea; outline: none; }
.allocation-table-scroll tbody tr:nth-child(even) { background: #fafcf8; }
.allocation-table-scroll tbody tr:hover { background: #f0f6ee; }
.allocation-weight { font-weight: 750; color: var(--moss); }
.allocation-retrieved { font-size: 10px; margin-top: 2px; }
.allocation-table-footer { display: flex; justify-content: space-between; gap: 15px; color: var(--muted); font-size: 11px; padding: 11px 10px 0; }
.allocation-sources-card { margin-top: 18px; }
.allocation-source-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.allocation-source-item { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 11px; border: 1px solid var(--line); border-radius: 11px; padding: 12px 13px; }
.allocation-source-status { width: 9px; height: 9px; border-radius: 50%; background: var(--rose); }
.allocation-source-status.ready { background: #48a477; }
.allocation-source-item strong, .allocation-source-item span { display: block; }
.allocation-source-item strong { color: var(--moss); font-size: 13px; }
.allocation-source-item span { color: var(--muted); font-size: 11px; margin-top: 3px; }
.allocation-source-item em { color: var(--muted); font-size: 11px; font-style: normal; text-align: right; white-space: nowrap; }
.allocation-howto { display: flex; align-items: flex-start; gap: 10px; margin: 16px 2px 0; color: var(--muted); font-size: 12px; }
.allocation-howto p { margin: 0; max-width: 900px; }
.allocation-howto strong { color: var(--ink); }
.allocation-howto-icon { display: grid; place-items: center; flex: 0 0 24px; width: 24px; height: 24px; background: #e5efe7; border-radius: 8px; color: var(--moss); font-weight: 800; }
.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; }

@media (max-width: 1100px) {
  .allocation-setup-grid { grid-template-columns: 1fr; }
  .allocation-checkboxes { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .allocation-summary-grid { grid-template-columns: 1fr 1fr; }
  .allocation-source-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .allocation-checkboxes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .allocation-form-actions { align-items: flex-start; flex-direction: column; }
  .allocation-table-head { display: block; }
  .allocation-table-actions { flex-wrap: wrap; margin-top: 14px; }
  .allocation-search { flex: 1 1 100%; }
  .allocation-search input { width: 100%; }
  .allocation-summary-grid { grid-template-columns: 1fr; }
  .allocation-table-footer { align-items: flex-start; flex-direction: column; }
}
