/* Wealth dashboard — single deliberate light theme.
 * Inter (self-hosted, zero third-party requests) on a warm-white surface
 * system. The chart palette (--series-1..8) is the validated categorical
 * set — never reorder or restep it without re-running the dataviz validator. */

@font-face {
  font-family: "Inter";
  src: url("/static/fonts/inter-var-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --page: #f6f8fa;
  --surface: #ffffff;
  --sidebar: #fafbfc;
  --ink: #0a2540;
  --ink-2: #425466;
  --muted: #687385;
  --grid: #eef1f4;
  --baseline: #d8dee6;
  --border: rgba(10, 37, 64, 0.10);
  --shadow: 0 1px 2px rgba(10, 37, 64, 0.06), 0 6px 20px -10px rgba(10, 37, 64, 0.08);
  --good: #1a7a2e;
  --good-bg: #e6f4ea;
  --bad: #cd3d64;
  --bad-bg: #fdeef2;
  --accent: #635bff;
  --accent-strong: #5348d6;
  --accent-bg: #eeecff;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;
  --radius: 14px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 400 13.5px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* --- app shell: fixed sidebar + scrolling content -------------------------- */
.app-body { display: flex; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; align-self: flex-start;
  height: 100vh; width: 218px; flex-shrink: 0;
  display: flex; flex-direction: column;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  padding: 20px 14px 16px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--ink); text-decoration: none;
  font-weight: 700; font-size: 15px; letter-spacing: -0.01em;
  padding: 2px 8px 18px;
}
.brand-mark { color: var(--accent-strong); display: flex; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 9px;
  color: var(--ink-2); text-decoration: none;
  font-weight: 500; font-size: 13.5px;
}
.side-nav a svg { color: var(--muted); flex-shrink: 0; }
.side-nav a:hover { background: rgba(10, 37, 64, 0.05); color: var(--ink); }
.side-nav a.active { background: var(--accent-bg); color: var(--accent-strong); font-weight: 600; }
.side-nav a.active svg { color: var(--accent-strong); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.side-foot form { margin: 0; }

.content { flex: 1; min-width: 0; padding: 28px 32px 56px; max-width: 1160px; }

/* --- page header ------------------------------------------------------------ */
.page-head { margin: 0 0 20px; display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.page-head h1 { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: -0.02em; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }

/* --- buttons & inputs -------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--baseline); border-radius: 9px;
  padding: 7px 13px; cursor: pointer;
  font: 500 13px/1.2 var(--font);
  transition: border-color 120ms, background 120ms, color 120ms;
}
.btn:hover { border-color: var(--ink-2); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn.primary:hover { background: #4438c9; border-color: #4438c9; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { color: var(--ink); background: rgba(10, 37, 64, 0.05); }
.btn.block { width: 100%; }

input, textarea, select {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--baseline); border-radius: 9px;
  padding: 8px 10px; font: 400 13px/1.4 var(--font);
}
input:focus-visible, textarea:focus-visible, select:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
textarea { font-family: ui-monospace, SFMono-Regular, monospace; font-size: 12px; }

/* --- stat tiles --------------------------------------------------------------- */
.tiles { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 14px; margin: 0 0 20px; }
.tiles.four { grid-template-columns: 1.6fr 1fr 1fr 1fr; }
@media (max-width: 1100px) { .tiles.four { grid-template-columns: 1fr 1fr; } }
.tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.tile-label {
  color: var(--muted); font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.07em;
}
.tile-value { font-size: 32px; font-weight: 700; letter-spacing: -0.025em; line-height: 1.15; }
.tile-value.small { font-size: 21px; }
.tile-delta { font-size: 12.5px; color: var(--ink-2); }
.tile-delta.muted { color: var(--muted); font-size: 12px; }
.delta-up { color: var(--good); }
.delta-down { color: var(--bad); }

/* delta pills (used via .pill in tables/tiles when wrapped) */
.pill {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.pill.up { color: var(--good); background: var(--good-bg); }
.pill.down { color: var(--bad); background: var(--bad-bg); }

/* --- panels -------------------------------------------------------------------- */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; margin-bottom: 18px;
}
.panel h2 {
  margin: 0 0 14px; font-size: 11px; font-weight: 650;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.panel-head h2 { margin-bottom: 14px; }
.controls { display: flex; gap: 8px; align-items: center; }
.controls select { padding: 5px 9px; }
.controls input[type="search"] { padding: 5px 9px; width: 170px; }
.range-row { display: flex; border: 1px solid var(--baseline); border-radius: 9px; overflow: hidden; }
.range-row button {
  background: none; border: none; padding: 5px 12px; cursor: pointer;
  color: var(--ink-2); font: 500 12.5px var(--font);
}
.range-row button:hover { color: var(--ink); }
.range-row button.active { background: var(--accent-strong); color: #fff; }

.chart-wrap { position: relative; height: 340px; }
.chart-wrap.short { height: 240px; }
.chart-wrap:not(.ready)::before {
  content: ""; position: absolute; inset: 8px; border-radius: 8px;
  background: linear-gradient(90deg, var(--grid), var(--page), var(--grid));
  background-size: 200% 100%; animation: shimmer 1.2s infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) {
  .two-col, .tiles { grid-template-columns: 1fr; }
}

/* --- tables --------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; margin: 0 -6px; }
.table-wrap.capped { max-height: 420px; overflow-y: auto; }
.table-wrap.capped thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--grid); }
tr:last-child td { border-bottom: none; }
th {
  color: var(--muted); font-weight: 600; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap;
}
td { font-variant-numeric: tabular-nums; }
td.num, th.num { text-align: right; white-space: nowrap; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th.sortable[data-dir="asc"]::after { content: " ↑"; }
th.sortable[data-dir="desc"]::after { content: " ↓"; }
td.date { white-space: nowrap; }
tbody tr:hover td { background: #f8fafc; }
td .sub { color: var(--muted); font-size: 11px; margin-left: 6px; font-weight: 400; }
.dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 8px; vertical-align: 1px;
}

/* --- badges ---------------------------------------------------------------------- */
.badge {
  display: inline-block; font-size: 11px; font-weight: 550;
  padding: 2px 8px; border-radius: 999px;
  background: rgba(10, 37, 64, 0.06); color: var(--ink-2);
}
.badge.err { background: var(--bad-bg); color: var(--bad); }
.badge.warn { background: #fdf3dd; color: #8a6100; }
.error { color: var(--bad); }
.note { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
.note em { font-style: italic; }

/* --- forms -------------------------------------------------------------------------- */
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; align-items: end; }
.grid-form label, .inline-form label { display: flex; flex-direction: column; gap: 5px; color: var(--ink-2); font-size: 12px; font-weight: 500; }
.grid-form .wide { grid-column: 1 / -1; }
.grid-form .btn { justify-self: start; }
.inline-form { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; margin-bottom: 14px; }
.row-actions { display: flex; gap: 8px; margin-top: 14px; }
.row-actions form { margin: 0; }

/* --- accounts page --------------------------------------------------------------------- */
.account-row { border-bottom: 1px solid var(--grid); }
.account-row:last-of-type { border-bottom: none; }
.account-row.inactive summary { opacity: 0.55; }
.account-row summary {
  display: flex; gap: 14px; align-items: baseline; cursor: pointer;
  padding: 11px 8px; list-style: none; flex-wrap: wrap; border-radius: 9px;
}
.account-row summary::-webkit-details-marker { display: none; }
.account-row summary:hover { background: #f8fafc; }
.account-row summary::before {
  content: ""; width: 7px; height: 7px; flex-shrink: 0; align-self: center;
  border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted);
  transform: rotate(-45deg); transition: transform 120ms;
}
.account-row[open] > summary::before { transform: rotate(45deg); }
.account-row[open] { background: #fafbfc; border-radius: 10px; }
.acct-name { font-weight: 600; min-width: 200px; }
.acct-meta { color: var(--muted); font-size: 12px; flex: 1; }
.acct-value { font-variant-numeric: tabular-nums; margin-left: auto; }
.acct-value small { color: var(--muted); }
.account-body {
  background: var(--page); border-radius: 10px;
  padding: 16px; margin: 2px 8px 16px;
  display: flex; flex-direction: column; gap: 16px;
}
.account-body h3 {
  margin: 0 0 8px; font-size: 10.5px; font-weight: 650;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em;
}
.account-body .inline-form { margin-bottom: 0; }
.field-error { color: var(--bad); font-size: 12px; margin: 4px 0 0; }
textarea.invalid { border-color: var(--bad); }

/* --- login --------------------------------------------------------------------------------- */
.login-body {
  min-height: 100vh; display: grid; place-items: center;
  background: var(--page); margin: 0;
  font: 400 14px/1.55 var(--font); color: var(--ink);
}
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: 0 8px 40px -12px rgba(10, 37, 64, 0.16);
  padding: 34px; width: min(350px, 90vw);
  display: flex; flex-direction: column; gap: 14px;
}
.login-card .brand { padding: 0 0 8px; font-size: 16px; }
.login-card h1 { margin: 0; font-size: 17px; letter-spacing: -0.01em; }
.login-card p.hint { margin: -6px 0 0; color: var(--muted); font-size: 12.5px; }

/* --- responsive shell -------------------------------------------------------------------------- */
@media (max-width: 760px) {
  .app-body { flex-direction: column; }
  .sidebar {
    position: static; height: auto; width: 100%;
    flex-direction: row; align-items: center; gap: 2px; flex-wrap: wrap;
    padding: 8px 10px; border-right: none; border-bottom: 1px solid var(--border);
  }
  .brand { padding: 0 6px 0 0; }
  .brand-name { display: none; }
  .side-nav { flex-direction: row; flex: 1; }
  .side-nav a { padding: 10px 10px; }
  .side-foot { margin: 0; flex-direction: row; gap: 4px; }
  .side-foot .btn.block { width: auto; min-height: 40px; padding: 7px 10px; }
  .side-foot .btn-label { display: none; }  /* icon-only Sync on phones */
  .content { padding: 18px 14px 40px; }
}
