/* ==========================================================================
   Drift design system: "Modern Ledger" (milestone 11)
   --------------------------------------------------------------------------
   Rules instead of boxes, figures in a monospace, one ink color, and two
   signal colors kept for drift (over target / under target).
     1. Tokens (light and dark)
     2. Base
     3. App shell: top bar, page header, view switcher
     4. Components: sections, buttons, badges, tables, forms, alerts,
        flashes, segmented controls, empty states, lists, tiles, menus
     5. Overview: hero, the Brief, chart, drift, balance sheet
     6. Auth pages
     7. Utilities
   Colors are only read through the custom properties in section 1.
   ========================================================================== */

/* 1. Tokens ---------------------------------------------------------------- */

:root {
  color-scheme: light;

  --bg: #F6F6F4;
  --surface: #FFFFFF;
  --hover: #EDECE8;
  --ink: #0E0E0D;
  --text-2: #3C3B37;
  --muted: #66655F;
  --faint: #9A9893;
  --rule: #DCDAD4;
  --hairline: #ECEBE7;

  /* Drift: over target is warm, under target is cool. */
  --over: #C2410C;
  --under: #1D4ED8;

  --positive: #15803D;
  --negative: #B42318;
  --warning: #9A5B06;
  --warning-soft: #FBF1DE;
  --info-soft: #EBEFF8;
  --error-soft: #FBEAE7;

  /* Asset classes, for small dots only. */
  --ac-us_equity: #0E0E0D;
  --ac-intl_equity: #1D4ED8;
  --ac-bonds: #A16207;
  --ac-cash: #78776F;
  --ac-private: #7C3AED;
  --ac-real_estate: #C2410C;
  --ac-multi: #0F766E;
  --ac-other: #B5B3AC;

  --ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--ink);

  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --content-width: 1280px;
  --gutter: 40px;

  scroll-behavior: auto !important; /* keeps Turbo's scroll preservation working */
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0F0F0E;
  --surface: #181816;
  --hover: #23221F;
  --ink: #F2F1EE;
  --text-2: #D3D1CB;
  --muted: #9C9A93;
  --faint: #6E6C66;
  --rule: #34332F;
  --hairline: #252421;

  --over: #FB8A4F;
  --under: #7EA6FF;

  --positive: #4ADE80;
  --negative: #F87171;
  --warning: #FBBF24;
  --warning-soft: rgba(251, 191, 36, 0.12);
  --info-soft: rgba(126, 166, 255, 0.12);
  --error-soft: rgba(248, 113, 113, 0.12);

  --ac-us_equity: #F2F1EE;
  --ac-intl_equity: #7EA6FF;
  --ac-bonds: #E3B341;
  --ac-cash: #9C9A93;
  --ac-private: #B79CF7;
  --ac-real_estate: #FB8A4F;
  --ac-multi: #5EC8B8;
  --ac-other: #5A5853;
}

/* 2. Base ------------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 { margin: 0; color: var(--ink); line-height: 1.15; }
h1 { font-size: 44px; font-weight: 400; letter-spacing: -0.045em; }
h2 { font-size: 18px; font-weight: 500; letter-spacing: -0.015em; }
h3 { font-size: 14px; font-weight: 600; }
p { margin: 0 0 0.75rem; }
p:last-child { margin-bottom: 0; }
small { font-size: 0.86em; color: var(--muted); }
strong { font-weight: 600; }
code { font-family: var(--mono); font-size: 0.9em; padding: 0.05em 0.3em; background: var(--hover); }
mark { background: none; color: inherit; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 1.5rem 0; }
ul { padding-left: 1.2rem; }

a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--ink); }
:focus-visible { outline: none; box-shadow: var(--ring); }

svg.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg.icon-sm { width: 14px; height: 14px; }
svg.icon-lg { width: 22px; height: 22px; }

.mono, .num, td.num, th.num, .stat-value { font-family: var(--mono); font-variant-numeric: tabular-nums; }
td, th { font-variant-numeric: tabular-nums; }

/* 3. App shell ------------------------------------------------------------- */

.wrap { max-width: var(--content-width); margin: 0 auto; padding: 0 var(--gutter); }

.topbar { border-bottom: 1px solid var(--ink); background: var(--bg); }
.topbar .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 36px; min-height: 60px; }
.wordmark { font-size: 20px; font-weight: 600; letter-spacing: -0.045em; text-decoration: none; }
.mainnav { display: flex; flex-wrap: wrap; gap: 0 28px; flex: 1; }
.mainnav a { display: inline-flex; align-items: center; gap: 6px; padding: 19px 0 17px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.mainnav a:hover { color: var(--ink); }
.mainnav a[aria-current="page"] { color: var(--ink); font-weight: 500; border-bottom-color: var(--ink); }
.nav-count { font-family: var(--mono); font-size: 11px; color: var(--over); }

.usermenu { margin-left: auto; }
.usermenu > button { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0; border: 0; background: none; color: var(--muted); font: inherit; cursor: pointer; }
.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none; border: 1px solid var(--ink); border-radius: 50%; font-family: var(--mono); font-size: 11px; color: var(--ink); }

.content { padding-bottom: 72px; }

@media (max-width: 760px) {
  :root { --gutter: 18px; }
  h1 { font-size: 34px; }
  .mainnav { order: 3; flex-basis: 100%; overflow-x: auto; gap: 0 20px; }
  .mainnav a { padding: 10px 0; }
  .usermenu .usermenu-name { display: none; }
}

.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; padding: 32px 0 24px; margin-bottom: 28px; border-bottom: 1px solid var(--rule); }
.page-header p { margin: 8px 0 0; color: var(--muted); max-width: 62ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.eyebrow { display: block; font-family: var(--mono); font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }

.back-link { display: inline-flex; align-items: center; gap: 4px; margin-top: 24px; color: var(--muted); font-size: 13px; text-decoration: none; }
.back-link:hover { color: var(--ink); }
.back-link + .page-header { padding-top: 12px; }

/* The view switcher is the page title: "My accounts ⌄" opens a menu. */
.switcher { position: relative; }
.switcher-button { display: flex; align-items: center; gap: 14px; margin-top: 2px; padding: 0; border: 0; background: none; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.switcher-button h1 { line-height: 1.1; }
.switcher-chevron { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border: 1px solid var(--ink); border-radius: 50%; transition: transform 0.15s; }
.switcher-button[aria-expanded="true"] .switcher-chevron { transform: rotate(180deg); }
.switcher-meta { margin-top: 8px; font-family: var(--mono); font-size: 12px; color: var(--muted); }

/* 4. Components ------------------------------------------------------------ */

/* Sections: a rule on top, no box. */
.card { border-top: 1px solid var(--ink); }
.card-header { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; padding: 14px 0 12px; border-bottom: 1px solid var(--rule); }
.card-header p, .card-subtitle { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.card-body { padding: 18px 0; }
.card-footer { padding: 16px 0; border-top: 1px solid var(--rule); }
.card-flush .card-body { padding: 0; }
.section, .card + .card, .stack > * + * { margin-top: 40px; }
.section-title { font-size: 36px; font-weight: 300; letter-spacing: -0.04em; line-height: 1; }
.grid { display: grid; gap: 40px 56px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 960px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* Buttons. button_to wraps its <button> in a form; .inline-form keeps it in line. */
/* :where() adds no specificity, so .btn-primary, .btn-ghost and the rest
   override this base rule without needing longer selectors. */
.btn, input[type="submit"], :where(.content, .auth-main) button:where(:not(.unstyled, .switcher-button, .menu-item)) {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 16px;
  border: 1px solid var(--ink); border-radius: 0;
  background: transparent; color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 500; line-height: 1;
  text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.btn:hover, input[type="submit"]:hover, :where(.content, .auth-main) button:where(:not(.unstyled, .switcher-button, .menu-item)):hover { background: var(--hover); text-decoration: none; }
.btn-primary, input[type="submit"], .content button.btn-primary, .auth-main input[type="submit"] { background: var(--ink); color: var(--bg); }
.btn-primary:hover, input[type="submit"]:hover, .content button.btn-primary:hover { background: var(--text-2); }
.btn-ghost, .content button.btn-ghost { border-color: transparent; color: var(--text-2); }
.btn-ghost:hover, .content button.btn-ghost:hover { background: var(--hover); }
.btn-danger, .content button.btn-danger { color: var(--negative); border-color: var(--negative); }
.btn-ghost.btn-danger, .content button.btn-ghost.btn-danger { border-color: transparent; }
.btn-danger:hover, .content button.btn-danger:hover { background: var(--error-soft); }
.btn-sm, .content button.btn-sm { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn-icon, .content button.btn-icon { width: 32px; padding: 0; }
.content button:disabled, input[type="submit"]:disabled { opacity: 0.5; cursor: not-allowed; }

.inline-form, .button_to { display: inline-flex; margin: 0; }
.button-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.table .row-actions { flex-wrap: nowrap; }

/* Badges: small mono labels. */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 6px; border: 1px solid currentColor; font-family: var(--mono); font-size: 10.5px; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; line-height: 1.6; white-space: nowrap; color: var(--muted); }
.badge-positive { color: var(--positive); }
.badge-negative { color: var(--negative); }
.badge-warning { color: var(--warning); }
.badge-info { color: var(--under); }
.badge-accent { color: var(--ink); }
.badge-muted { color: var(--muted); }

.stale { display: flex; align-items: center; gap: 6px; margin-top: 3px; font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: nowrap; }
.num .stale, .text-right .stale, .amount .stale { justify-content: flex-end; }
.stale mark { padding: 0 5px; background: var(--warning-soft); color: var(--warning); font-weight: 500; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--hairline); }
.table thead th { padding-top: 12px; padding-bottom: 8px; font-family: var(--mono); font-size: 11px; font-weight: 400; color: var(--muted); border-bottom: 1px solid var(--rule); white-space: nowrap; }
.table tbody tr:hover { background: color-mix(in srgb, var(--hover) 50%, transparent); }
.table th:first-child, .table td:first-child { padding-left: 0; }
.table th:last-child, .table td:last-child { padding-right: 0; }
.table tfoot th, .table tfoot td { border-top: 1px solid var(--ink); border-bottom: 0; font-weight: 600; }
.table .group-row th { padding-top: 18px; font-family: var(--mono); font-size: 11px; font-weight: 400; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.table .group-row:hover { background: transparent; }
.table .num, .table .text-right { text-align: right; }
.table td .sub { display: block; font-size: 12px; color: var(--muted); }
.table a.row-title { font-weight: 500; text-decoration: none; }
.table a.row-title:hover { text-decoration: underline; }
.table-compact th, .table-compact td { padding: 6px 8px; }

.ticker { display: inline-block; min-width: 52px; font-family: var(--mono); font-size: 12px; font-weight: 500; }
.cell-security { display: flex; align-items: baseline; gap: 10px; }
.cell-security .name { color: var(--muted); }
.cell-account { display: flex; align-items: center; gap: 12px; }
.inst-icon { display: inline-grid; place-items: center; width: 30px; height: 30px; flex: none; border: 1px solid var(--rule); font-family: var(--mono); font-size: 12px; color: var(--text-2); }

/* Forms */
.form { display: flex; flex-direction: column; gap: 20px; }
.form > .card + .card { margin-top: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.field > label, .label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.hint, .field .hint { font-size: 12px; color: var(--muted); }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"], input[type="url"], input[type="tel"], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 10px;
  border: 1px solid var(--rule); border-radius: 0;
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 14px;
  transition: border-color 0.12s;
}
input[type="number"] { font-family: var(--mono); }
textarea { min-height: 90px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
select { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2366655F' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 14px; }
/* A select that sits inside a table row and reads as plain text, with a
   faint chevron; it shows a background only on hover or keyboard focus.
   Used for a holding's asset class. */
.class-picker { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
select.select-inline {
  width: auto; min-height: 0; margin-left: -6px; padding: 3px 22px 3px 6px;
  border: 1px solid transparent; background-color: transparent; color: inherit;
  font-size: inherit; cursor: pointer;
  background-position: right 5px center; background-size: 12px;
}
select.select-inline.muted { color: var(--muted); }
select.select-inline:hover { background-color: var(--hover); border-color: transparent; }
select.select-inline:focus { border-color: transparent; box-shadow: none; }
select.select-inline:focus-visible { background-color: var(--hover); box-shadow: 0 0 0 1px var(--ink); }
.field_with_errors { display: contents; }
.field_with_errors input, .field_with_errors select, .field_with_errors textarea { border-color: var(--negative); }

input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--ink); cursor: pointer; vertical-align: middle; }
.check { display: flex; align-items: flex-start; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--hairline); cursor: pointer; }
.check input { margin-top: 2px; }
.check label { cursor: pointer; font-weight: 500; }
.check .hint { display: block; font-weight: 400; }

fieldset { margin: 0; padding: 0; border: 0; }
legend { padding: 0; font-weight: 600; }
.form-actions { display: flex; gap: 8px; align-items: center; padding-top: 4px; }
.input-suffix { position: relative; display: flex; align-items: center; }
.input-suffix input { padding-right: 28px; text-align: right; }
.input-suffix span { position: absolute; right: 10px; color: var(--muted); font-family: var(--mono); pointer-events: none; }
.inline-fields { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.inline-fields .field { flex: 1 1 180px; }

/* Alerts and flashes */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; font-size: 14px; background: var(--hover); }
.alert ul { margin: 4px 0 0; padding-left: 1.1rem; }
.alert p { margin: 0; }
.alert .icon { margin-top: 2px; flex: none; }
.alert-error { background: var(--error-soft); }
.alert-error .icon { color: var(--negative); }
.alert-success .icon { color: var(--positive); }
.alert-info { background: var(--info-soft); }
.alert-info .icon { color: var(--under); }
.alert-warning { background: var(--warning-soft); }
.alert-warning .icon { color: var(--warning); }
.alert .alert-body { flex: 1; min-width: 0; }
.alert .alert-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.alert.section { margin-top: 24px; }

.flashes { position: fixed; top: 14px; right: 14px; z-index: 50; display: flex; flex-direction: column; gap: 8px; width: min(400px, calc(100vw - 28px)); }
.flash { display: flex; align-items: flex-start; gap: 10px; padding: 12px 12px 12px 14px; background: var(--surface); border: 1px solid var(--ink); box-shadow: 0 12px 32px rgba(14, 14, 13, 0.12); font-size: 14px; animation: flash-in 0.2s ease-out; }
.flash p { margin: 0; flex: 1; }
.flash .icon { margin-top: 2px; }
.flash-notice .icon { color: var(--positive); }
.flash-alert .icon { color: var(--negative); }
.flash button.unstyled { padding: 2px; border: 0; background: none; color: var(--muted); cursor: pointer; display: grid; }
.flash button.unstyled:hover { color: var(--ink); }
@keyframes flash-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* Segmented controls: chart ranges and the like. */
.segmented { display: inline-flex; flex-wrap: wrap; gap: 2px; font-family: var(--mono); font-size: 11px; }
.segmented a { display: inline-flex; align-items: center; min-height: 28px; padding: 0 9px; color: var(--muted); text-decoration: none; }
.segmented a:hover { color: var(--ink); background: var(--hover); }
.segmented a[aria-current] { background: var(--ink); color: var(--bg); }

/* Empty states */
.empty { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 36px 0; }
.empty .empty-icon { display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid var(--ink); margin-bottom: 4px; }
.empty h2, .empty h3 { font-size: 22px; font-weight: 400; letter-spacing: -0.02em; }
.empty p { color: var(--muted); max-width: 52ch; margin: 0; }
.empty .button-row { margin-top: 8px; }
.empty-inline { padding: 16px 0; color: var(--muted); }

/* Lists (members, shared accounts, invitations) */
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 0; border-bottom: 1px solid var(--hairline); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 500; }
.list-item .meta { font-size: 12px; color: var(--muted); }

/* Portfolio tiles */
.tile { display: flex; flex-direction: column; gap: 12px; padding: 16px 0 0; color: var(--ink); text-decoration: none; }
a.tile:hover h3 { text-decoration: underline; text-underline-offset: 3px; }
.tile-head { display: flex; align-items: center; gap: 12px; }
.tile h3 { font-size: 22px; font-weight: 400; letter-spacing: -0.02em; }
.tile .meta { display: flex; gap: 16px; flex-wrap: wrap; font-family: var(--mono); font-size: 12px; color: var(--muted); margin-top: auto; padding-top: 12px; border-top: 1px solid var(--hairline); }
.tile .meta span { display: inline-flex; align-items: center; gap: 6px; }

/* Add-account picker */
/* Six options fit one row at full width (170px minimum each) and wrap below that. */
.type-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; }
.type-option { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--rule); background: var(--bg); color: var(--ink); font-weight: 500; text-decoration: none; }
.type-option:hover { background: var(--hover); }
.type-option small { display: block; font-weight: 400; line-height: 1.35; }
.type-option .icon-wrap { display: grid; place-items: center; width: 28px; height: 28px; flex: none; border: 1px solid var(--rule); }
.type-option.featured { background: var(--ink); color: var(--bg); }
.type-option.featured small { color: var(--faint); }
.type-option.featured .icon-wrap { border-color: var(--muted); }
.type-option.featured:hover { background: var(--text-2); }

/* Menus (dropdown_controller toggles .show) */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu { display: none; position: absolute; z-index: 30; top: calc(100% + 8px); right: 0; min-width: 240px; margin: 0; padding: 6px 0; list-style: none; background: var(--surface); border: 1px solid var(--ink); box-shadow: 0 18px 40px rgba(14, 14, 13, 0.12); }
.dropdown-menu.show { display: block; }
.dropdown-menu a, .dropdown-menu button.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 14px; border: 0; background: none; color: var(--ink); font: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.dropdown-menu a:hover, .dropdown-menu button.menu-item:hover { background: var(--hover); }
.dropdown-menu .menu-label { padding: 10px 14px 4px; font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: 0.04em; }
.dropdown-menu .divider { height: 1px; margin: 6px 0; background: var(--rule); }
.dropdown-menu form { margin: 0; }

.switcher .dropdown-menu { left: 0; right: auto; width: min(400px, calc(100vw - 36px)); }
.view-option { gap: 12px !important; padding: 12px 16px !important; }
.view-option .check-mark { width: 14px; font-weight: 600; }
.view-option .grow { flex: 1; min-width: 0; }
.view-option .name { display: block; font-size: 15px; font-weight: 500; }
.view-option .meta { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.view-option .total { font-family: var(--mono); font-size: 13px; }
.switcher-footer { display: flex; justify-content: space-between; gap: 12px; padding: 10px 16px 6px; border-top: 1px solid var(--rule); margin-top: 6px; font-size: 13px; }
.dropdown-menu .switcher-footer a { width: auto; padding: 0; }
.dropdown-menu .switcher-footer a:hover { background: none; text-decoration: underline; }

/* Facts line under an account name */
.facts { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; color: var(--muted); font-size: 13px; }
.facts .sep { color: var(--faint); }

.danger-zone { border-top-color: var(--negative); }
.danger-zone .card-header h2 { color: var(--negative); }

/* 5. Overview -------------------------------------------------------------- */

.hero { display: flex; flex-wrap: wrap; gap: 32px 48px; padding: 4px 0 36px; border-bottom: 1px solid var(--ink); }
.hero-main, .hero > turbo-frame { flex: 1.8 1 560px; min-width: 0; display: flex; flex-direction: column; }
.hero-figures { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 32px; }
.hero-label { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.hero-value { margin-top: 6px; font-weight: 300; font-size: 72px; line-height: 0.95; letter-spacing: -0.06em; font-variant-numeric: tabular-nums; }
.hero-change { margin-top: 10px; font-family: var(--mono); font-size: 13px; }
.hero-change .since { color: var(--muted); }
.hero-stats { margin: 0 0 4px; display: grid; grid-template-columns: repeat(3, auto); gap: 2px 28px; font-family: var(--mono); font-size: 13px; }
.hero-stats dt { font-size: 11px; color: var(--muted); }
.hero-stats dd { margin: 0; }
@media (max-width: 640px) { .hero-value { font-size: 52px; } .hero-main, .hero > turbo-frame { flex-basis: 100%; } }

.chart { margin: 24px 0 0; }
.chart-plot { position: relative; height: 170px; border-bottom: 1px solid var(--ink); }
.chart-plot svg { position: absolute; left: 0; top: 8px; width: 100%; height: calc(100% - 8px); overflow: visible; }
.chart .area { fill: var(--ink); opacity: 0.04; }
.chart .line { fill: none; stroke: var(--ink); stroke-width: 1.5; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.chart-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 8px; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.chart-empty { display: flex; align-items: center; gap: 10px; margin-top: 24px; padding: 28px 0; border-top: 1px dashed var(--rule); border-bottom: 1px dashed var(--rule); color: var(--muted); }

/* The Brief */
.brief { flex: 1 1 320px; min-width: 280px; border-left: 1px solid var(--ink); padding-left: 28px; }
.brief-head { display: flex; justify-content: space-between; align-items: baseline; }
.brief-head h2 { font-size: 13px; font-weight: 600; letter-spacing: 0; }
.brief-head span { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.brief ol { margin: 12px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 12px; font-size: 16px; line-height: 1.5; letter-spacing: -0.005em; }
.brief li { display: flex; gap: 12px; }
.brief li > .n { padding-top: 4px; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.brief .quiet { color: var(--muted); }
@media (max-width: 760px) { .brief { border-left: 0; padding-left: 0; border-top: 1px solid var(--ink); padding-top: 18px; } }

a.ref { font-weight: 500; text-decoration: none; border-bottom: 1px solid currentColor; font-variant-numeric: tabular-nums; }
a.ref:hover { background: var(--hover); }
.over { color: var(--over); }
.under { color: var(--under); }

/* Section headings on the overview */
.ledger-section { padding-top: 48px; }
.ledger-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px 24px; padding-bottom: 14px; border-bottom: 1px solid var(--ink); }
.ledger-head .lead { display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap; }
.ledger-head .lead span { color: var(--muted); }
.ledger-head .meta { display: flex; flex-wrap: wrap; gap: 6px 20px; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.ledger-head .meta a { color: var(--ink); }

/* Drift rows */
.drift-table { min-width: 720px; }
.drift-row { display: grid; grid-template-columns: 160px 64px 64px minmax(0, 1fr) 150px; gap: 16px; align-items: center; min-height: 44px; border-top: 1px solid var(--rule); }
.drift-row.drift-axis { min-height: 0; padding: 12px 0 8px; border-top: 0; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.drift-axis .scale { text-align: center; }
.drift-row .class-name { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); }
.drift-row .fig { font-family: var(--mono); text-align: right; color: var(--ink); }
.drift-row .fig.target { color: var(--muted); }
.drift-row .action { font-family: var(--mono); text-align: right; }
.drift-track { position: relative; height: 14px; }
.drift-track .zero { position: absolute; left: 50%; top: -15px; bottom: -15px; width: 1px; background: var(--ink); }
.drift-track .bar { position: absolute; top: 3px; height: 8px; background: currentColor; }
.drift-track .tag { position: absolute; top: -2px; font-family: var(--mono); font-size: 11px; white-space: nowrap; }
.drift-track .note { position: absolute; left: calc(50% + 10px); top: -3px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.drift-row.even { color: var(--muted); }

/* Balance sheet and holdings side by side */
.ledger-columns { display: flex; flex-wrap: wrap; gap: 48px 64px; padding-top: 64px; }
.ledger-columns > section { flex: 1 1 420px; min-width: 0; }
.ledger-columns .section-title { margin-bottom: 14px; }

.sheet { border-top: 1px solid var(--ink); }
.sheet details { border-bottom: 1px solid var(--rule); }
.sheet summary { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 4px; cursor: pointer; list-style: none; }
.sheet summary::-webkit-details-marker { display: none; }
.sheet summary:hover { background: var(--hover); }
.sheet summary .chev { transition: transform 0.15s; color: var(--muted); }
.sheet details[open] summary .chev { transform: rotate(90deg); }
.sheet summary .name { flex: 1; font-weight: 500; }
.sheet summary .name span { color: var(--muted); font-weight: 400; }
.sheet summary .amount { font-family: var(--mono); }
.sheet .rows { padding: 0 4px 10px 28px; }
.sheet .row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 4px 0; font-size: 13px; }
.sheet .row .who { color: var(--muted); }
.sheet .row .amount { font-family: var(--mono); color: var(--text-2); text-align: right; }
.sheet .row.untracked, .sheet .row.untracked .amount { color: var(--muted); }
.sheet-totals { display: flex; justify-content: space-between; padding: 10px 4px 0; font-family: var(--mono); font-size: 13px; color: var(--muted); }
.sheet-net { display: flex; justify-content: space-between; align-items: baseline; padding: 16px 4px 0; font-size: 16px; }
.sheet-net .label { font-weight: 600; }
.sheet-net .amount { font-family: var(--mono); font-weight: 500; border-bottom: 3px double var(--ink); padding-bottom: 3px; }

.weight { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.weight .track { position: relative; width: 48px; height: 1px; background: var(--rule); }
.weight .track span { position: absolute; left: 0; top: -2px; height: 5px; background: var(--ink); }
.weight .pct { width: 44px; text-align: right; font-family: var(--mono); }
.more-rows summary { padding: 10px 0; border-top: 1px solid var(--rule); font-size: 13px; cursor: pointer; list-style: none; text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; }
.more-rows summary::-webkit-details-marker { display: none; }
.more-rows[open] summary { display: none; }

.dot { display: inline-block; width: 8px; height: 8px; flex: none; border-radius: 50%; }

.footer-line { margin-top: 72px; padding-top: 14px; border-top: 1px solid var(--ink); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; font-family: var(--mono); font-size: 11px; color: var(--muted); }

/* 6. Auth pages ------------------------------------------------------------ */

.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-aside { display: flex; flex-direction: column; justify-content: space-between; padding: 40px; background: #0E0E0D; color: #F2F1EE; }
.auth-aside .wordmark { color: #F2F1EE; }
.auth-aside h2 { color: #F2F1EE; font-size: clamp(34px, 4vw, 52px); font-weight: 300; letter-spacing: -0.045em; line-height: 1.05; max-width: 14ch; }
.auth-aside p { max-width: 42ch; color: #A8A69F; margin-top: 16px; }
.auth-aside svg.auth-art { width: 100%; max-width: 480px; height: auto; margin-top: 32px; }
.auth-aside small { font-family: var(--mono); font-size: 11px; color: #A8A69F; }
.auth-main { display: grid; place-items: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { font-size: 36px; }
.auth-card .lead { color: var(--muted); margin: 8px 0 28px; }
.auth-card input[type="submit"] { width: 100%; min-height: 44px; }
.auth-links { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--rule); font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.auth-links p { margin: 0; }
.auth .flashes { position: static; width: 100%; margin-bottom: 20px; }
.auth .flash { box-shadow: none; animation: none; }
@media (max-width: 880px) { .auth { grid-template-columns: 1fr; } .auth-aside { display: none; } }

/* 7. Utilities ------------------------------------------------------------- */

.muted { color: var(--muted); }
.text-right { text-align: right; }
.positive { color: var(--positive); }
.negative { color: var(--negative); }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0 !important; }
.gap-sm { gap: 8px; }
.flex { display: flex; align-items: center; }
.between { justify-content: space-between; }
.wrap-items { flex-wrap: wrap; }
.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: 576px) { #dev-toolbar { display: none !important; } }

/* Drift tones: a row's bar and figures take its tone's color. */
.drift-track.even, .action.even { color: var(--muted); }

/* Invitation banner: inverted so it stands out on every page. */
.invite-banner { background: var(--ink); color: var(--bg); }
.invite-banner .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; min-height: 60px; padding-top: 10px; padding-bottom: 10px; }
.invite-banner p { flex: 1 1 420px; margin: 0; }
.invite-banner strong { color: var(--bg); }
.invite-banner .detail { color: var(--faint); }
.invite-banner .btn { border-color: var(--bg); color: var(--bg); }
.invite-banner .btn:hover { background: color-mix(in srgb, var(--bg) 15%, transparent); }
.invite-banner .btn-primary { background: var(--bg); color: var(--ink); }
.invite-banner .btn-primary:hover { background: var(--hover); }
.invite-banner .btn-ghost { border-color: transparent; }

/* Chart hover readout (chart_controller.js). The overlay sits exactly over
   the SVG, so the server's percent positions line up with the line. */
.chart-plot { cursor: crosshair; }
.chart-plot:focus-visible { box-shadow: none; outline: 1px dashed var(--muted); outline-offset: 4px; }
.chart-overlay { position: absolute; left: 0; right: 0; top: 8px; bottom: 0; pointer-events: none; }
.chart-overlay[hidden] { display: none; }
.chart-overlay .cursor { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--ink); opacity: 0.35; }
.chart-overlay .point { position: absolute; width: 9px; height: 9px; margin: -4px 0 0 -4px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 3px var(--bg); }
.chart-overlay .readout { position: absolute; top: 0; display: flex; flex-direction: column; padding: 6px 8px; background: var(--surface); border: 1px solid var(--ink); font-family: var(--mono); font-size: 11px; white-space: nowrap; }
.chart-overlay .readout .date { color: var(--muted); }
.chart-overlay .readout .value { font-size: 13px; font-weight: 500; }

/* Targets page (F9) */
.targets-layout { display: flex; flex-wrap: wrap; gap: 48px 64px; align-items: flex-start; }
.targets-main { flex: 1.3 1 480px; min-width: 0; }
.models { flex: 1 1 340px; min-width: 0; }
.targets-table { margin-top: 20px; border-top: 1px solid var(--ink); }
.targets-row { display: grid; grid-template-columns: minmax(0, 1fr) 80px 130px; gap: 6px 16px; align-items: center; min-height: 52px; padding: 6px 0; border-bottom: 1px solid var(--hairline); }
.targets-row.head { min-height: 0; padding: 12px 0 8px; font-family: var(--mono); font-size: 11px; color: var(--muted); border-bottom-color: var(--rule); }
.targets-row.total { border-top: 1px solid var(--ink); border-bottom: 0; font-weight: 600; }
.targets-row .class-name { display: flex; align-items: center; gap: 8px; }
.targets-row .class-name label { font-weight: 500; color: var(--ink); }
.targets-row .fig { font-family: var(--mono); text-align: right; }
.targets-row .row-note { grid-column: 1 / -1; margin: -4px 0 4px 16px; font-size: 12px; color: var(--warning); }
.band-field { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 12px 24px; margin-top: 28px; padding: 16px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.band-field > div { flex: 1 1 280px; }
.band-field .hint { margin: 4px 0 0; }
.band-input { width: 130px; }
.band-input input { padding-left: 24px; }
.band-input .prefix { left: 10px; right: auto; }
.band-input span:last-child { right: 10px; }

.model-list { list-style: none; margin: 20px 0 0; padding: 0; border-top: 1px solid var(--ink); }
.model-list li { padding: 18px 0; border-bottom: 1px solid var(--rule); }
.model-list p { margin: 6px 0 0; color: var(--text-2); }
.model-list .source { font-size: 12px; color: var(--muted); }
.model-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.model-head h3 { font-size: 16px; font-weight: 500; }
.model-mix { display: flex; gap: 2px; height: 6px; margin: 10px 0 6px; }
.model-mix span { display: block; height: 100%; }
.model-legend { display: flex; flex-wrap: wrap; gap: 2px 14px; margin-bottom: 4px; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.model-legend > span { display: inline-flex; align-items: center; gap: 5px; }
.band-input input { padding-right: 38px; }
.drift-track .band { position: absolute; top: -15px; bottom: -15px; background: var(--hover); }

/* Type-to-confirm delete dialog (F11) */
.danger-dialog { width: min(480px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--negative); background: var(--surface); color: var(--ink); box-shadow: 0 24px 64px rgba(14, 14, 13, 0.25); }
.danger-dialog::backdrop { background: rgba(14, 14, 13, 0.45); }
.danger-box { padding: 24px; display: flex; flex-direction: column; gap: 10px; }
.danger-box h2 { font-size: 22px; font-weight: 500; color: var(--negative); }
.danger-box p { margin: 0; }
.danger-box ul { margin: 0; padding-left: 1.1rem; }
.danger-box form { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.danger-box .form-actions { margin-top: 6px; }
.btn-solid, .content button.btn-solid, .danger-box button.btn-solid { background: var(--negative); border-color: var(--negative); color: #FFFFFF; }
.btn-solid:hover, .danger-box button.btn-solid:hover { background: color-mix(in srgb, var(--negative) 85%, black); }
.danger-box button:disabled { opacity: 0.4; cursor: not-allowed; }
