/* Citadel Wealth — design tokens + base layout.
 * Tokens verbatim from plans/dashboard-mockups/wealth-tracker/PORTING.md.
 * Fonts fall back to system stack until .woff2 files land under /static/fonts/.
 */

:root {
  --bg: #0f1114;
  --surface: #1a1d23;
  --inset: #15181d;
  --inset2: #16191e;
  --border: rgba(255, 255, 255, 0.06);
  --text: #d7dade;
  --muted: #8b8f96;

  --accent: #d4a85a;     /* sodium amber — live values / deltas / primary CTAs ONLY */
  --gain: #4ade80;
  --loss: #f87171;
  --steel: #6b8299;

  --radius-card: 12px;
  --radius-chip: 6px;

  --font-label: 'Space Grotesk', 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Menlo', 'Consolas', ui-monospace, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-label);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

/* Topbar / nav ------------------------------------------------------------ */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.topbar-brand {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.brand-mark { color: var(--accent); font-size: 12px; }
.brand-name { font-weight: 700; letter-spacing: 0.08em; }
.brand-sub  { font-family: var(--font-mono); color: var(--muted); font-size: 11px; letter-spacing: 0.1em; }

.topnav {
  display: flex;
  gap: 4px;
  flex: 1;
  margin-left: 24px;
  overflow-x: auto;
}

.topnav-item {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: var(--radius-chip);
  font-size: 13px;
  white-space: nowrap;
  transition: color 120ms, background 120ms;
}

.topnav-item:hover { color: var(--text); background: var(--inset); }

.topnav-item.is-active {
  color: var(--text);
  background: var(--inset);
  box-shadow: inset 0 -2px 0 0 var(--accent);
}

.topbar-actions { display: flex; gap: 8px; }

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: var(--radius-chip);
  padding: 4px 10px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.icon-btn:hover { color: var(--text); border-color: var(--muted); }

/* Page shell -------------------------------------------------------------- */

.page {
  padding: 24px;
  max-width: 1440px;
  margin: 0 auto;
}

.empty {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  padding: 48px;
  text-align: center;
}

.empty-title { color: var(--muted); font-size: 14px; }
.empty-sub   { color: var(--muted); font-size: 12px; margin-top: 8px; }

.mono-link {
  font-family: var(--font-mono);
  color: var(--accent);
  text-decoration: none;
}

.mono-link:hover { text-decoration: underline; }

.pagefoot {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.num { font-family: var(--font-mono); text-align: right; font-variant-numeric: tabular-nums; }
.empty-mini {
  color: var(--muted);
  font-size: 12px;
  padding: 12px 16px;
  text-align: center;
}

.foot-key { color: var(--muted); }
.foot-val { color: var(--text); }
.foot-sep { padding: 0 8px; color: var(--border); }

/* Grid + card scaffolding ------------------------------------------------ */

.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

@media (max-width: 900px) {
  .grid-2col { grid-template-columns: 1fr; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px;
  margin-bottom: 12px;
}

.card--tall { min-height: 240px; display: flex; flex-direction: column; }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}

.card-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.card-sub   { font-size: 11px; }

/* Stat card -------------------------------------------------------------- */

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px;
}

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 500;
  color: var(--text);
}

.stat-value--accent { color: var(--accent); }

.stat-sub    { font-size: 11px; color: var(--muted); margin-top: 6px; }
.stat-delta  { font-family: var(--font-mono); font-size: 12px; margin-top: 4px; }
.stat-delta--gain { color: var(--gain); }
.stat-delta--loss { color: var(--loss); }

/* Signal cards ----------------------------------------------------------- */

.signals { display: flex; flex-direction: column; gap: 10px; }

.signal {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px 10px 14px;
  border-left: 2px solid var(--muted);
  background: var(--inset);
  border-radius: 4px;
}

.signal-dot {
  width: 8px; height: 8px; margin-top: 6px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.signal--good { border-left-color: var(--gain); }
.signal--good .signal-dot { background: var(--gain); }
.signal--info { border-left-color: var(--steel); }
.signal--info .signal-dot { background: var(--steel); }
.signal--warn { border-left-color: var(--accent); }
.signal--warn .signal-dot { background: var(--accent); }
.signal--risk { border-left-color: var(--loss); }
.signal--risk .signal-dot { background: var(--loss); }

.signal-title  { font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 2px; }
.signal-detail { font-size: 12px; color: var(--muted); line-height: 1.5; }

/* Ask box (Phase G stub) ------------------------------------------------- */

.ask { display: flex; flex-direction: column; gap: 12px; flex: 1; }
.ask-input-wrap { display: flex; gap: 8px; }
.ask-input {
  flex: 1;
  background: var(--inset);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: var(--radius-chip);
  font-family: var(--font-label);
  font-size: 13px;
}
.ask-input:disabled { color: var(--muted); }
.ask-submit {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-chip);
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 500;
}
.ask-submit:disabled { opacity: 0.4; cursor: not-allowed; }
.ask-note { font-size: 11px; }

/* Allocation bars + legend ---------------------------------------------- */

.alloc { display: flex; flex-direction: column; gap: 10px; }
.alloc-bar {
  display: flex;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  background: var(--inset);
}
.alloc-seg { min-width: 2px; height: 100%; }
.alloc-seg--0 { background: #d4a85a; }
.alloc-seg--1 { background: #6b8299; }
.alloc-seg--2 { background: #4ade80; }
.alloc-seg--3 { background: #f87171; }
.alloc-seg--4 { background: #a78bfa; }
.alloc-seg--5 { background: #38bdf8; }

.alloc-legend { width: 100%; font-size: 12px; }
.alloc-legend td { padding: 3px 6px; }
.alloc-legend-dot { width: 12px; }
.alloc-legend-label { color: var(--text); }
.alloc-legend-val { color: var(--text); }
.alloc-legend-pct { min-width: 50px; }
.alloc-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }

/* Donuts ----------------------------------------------------------------- */

.donut { display: flex; gap: 20px; align-items: center; }
.donut svg { flex-shrink: 0; }
.donut-arc.donut-seg--0 { stroke: #d4a85a; }
.donut-arc.donut-seg--1 { stroke: #6b8299; }
.donut-arc.donut-seg--2 { stroke: #4ade80; }
.donut-arc.donut-seg--3 { stroke: #f87171; }
.donut-arc.donut-seg--4 { stroke: #a78bfa; }
.donut-arc.donut-seg--5 { stroke: #38bdf8; }
.donut-legend { flex: 1; font-size: 12px; }
.donut-legend td { padding: 3px 6px; }

/* Freshness dots --------------------------------------------------------- */

.fresh-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}
.fresh {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--inset);
  border-radius: var(--radius-chip);
  font-size: 12px;
}
.fresh-dot { width: 8px; height: 8px; border-radius: 50%; }
.fresh--green .fresh-dot { background: var(--gain); }
.fresh--amber .fresh-dot { background: var(--accent); }
.fresh--red   .fresh-dot { background: var(--loss); }
.fresh-name  { color: var(--text); }
.fresh-label { font-size: 11px; }

/* Notice card ------------------------------------------------------------ */

.notice { border-color: var(--accent); }
.notice .card-title { color: var(--accent); }
.notice-body { font-size: 13px; color: var(--text); line-height: 1.6; padding: 4px 4px 8px; }

/* Portfolios — tabs + holdings table ------------------------------------ */

.port-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  padding-bottom: 0;
}

.port-tab {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 10px 14px 12px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  color: var(--muted);
  min-width: 140px;
  text-align: left;
  transition: color 120ms, border-color 120ms, background 120ms;
}

.port-tab:hover { color: var(--text); background: var(--inset); }

.port-tab.is-active {
  color: var(--text);
  border-bottom-color: var(--accent);
  background: var(--inset);
}

.port-tab-label { font-size: 13px; font-weight: 500; }
.port-tab-total { font-size: 12px; color: var(--muted); }
.port-tab.is-active .port-tab-total { color: var(--accent); }

.port-panel { display: none; }
.port-panel.is-active { display: block; }
.port-panel-sub { font-size: 11px; margin-bottom: 10px; }

/* Generic tables --------------------------------------------------------- */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.table th {
  text-align: left;
  padding: 8px 10px;
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: var(--inset);
}

.table th.col-num { text-align: right; }
.table th.col-spark { width: 60px; text-align: center; }

.table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }

.table .col-num { font-family: var(--font-mono); text-align: right; font-variant-numeric: tabular-nums; }
.table .col-sym  { width: 90px; }
.table .col-spark { text-align: center; }

.table .is-gain { color: var(--gain); }
.table .is-loss { color: var(--loss); }

.holding-row { cursor: pointer; transition: background 100ms; }
.holding-row:hover { background: var(--inset); }
.holding-row:hover .symbol-chip { color: var(--accent); }

.symbol-chip {
  display: inline-block;
  padding: 3px 8px;
  background: var(--inset2);
  border: 1px solid var(--border);
  border-radius: var(--radius-chip);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
  transition: color 100ms, border-color 100ms;
}

.spark-placeholder { font-size: 11px; letter-spacing: 0.15em; }

/* Modal ------------------------------------------------------------------ */

.modal-root {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 100;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
}

.modal-root.is-open { display: flex; }

.modal {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  max-width: 720px;
  width: 100%;
  padding: 24px;
}

.modal-close {
  position: absolute;
  top: 12px; right: 12px;
  font-size: 20px;
  line-height: 1;
  padding: 2px 10px;
}

/* Security modal --------------------------------------------------------- */

.secmod-head { border-bottom: 1px solid var(--border); padding-bottom: 14px; margin-bottom: 14px; }
.secmod-sym-block { display: flex; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.secmod-sym { font-size: 20px; font-weight: 500; color: var(--accent); letter-spacing: 0.06em; }
.secmod-sector { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }
.secmod-name { font-size: 14px; color: var(--text); margin-bottom: 4px; }
.secmod-provider { font-size: 11px; }

.secmod-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.secmod-stat {
  background: var(--inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-chip);
  padding: 10px 12px;
}

.secmod-stat .stat-value { font-size: 15px; }
.secmod-stat .stat-value.is-gain { color: var(--gain); }
.secmod-stat .stat-value.is-loss { color: var(--loss); }

.secmod-section { margin-bottom: 16px; }
.secmod-section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
}

.dividends-mini { font-size: 11px; }
.dividends-mini th { padding: 6px 8px; }
.dividends-mini td { padding: 6px 8px; }

.secmod--empty { padding: 16px 0; }

/* Forms — dividends manual entry ---------------------------------------- */

.dividend-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.form-field { display: flex; flex-direction: column; gap: 4px; }
.form-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }

.form-field input,
.form-field select {
  background: var(--inset);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px;
  border-radius: var(--radius-chip);
  font-family: var(--font-mono);
  font-size: 12px;
}

.form-field input:focus,
.form-field select:focus {
  outline: none;
  border-color: var(--accent);
}

.form-actions {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  grid-column: 1 / -1;
}
