/* fugazi — terminal/Bloomberg theme.
 * Dense, data-forward, monospace-first. Sharp corners, hairline rules,
 * amber + cyan accents on a near-black ground. Light mode is a dim "paper
 * terminal" — same density, inverted.
 *
 * Theme is chosen by [data-theme] on <html>; see the no-FOUC inline script
 * in views.templ. Tokens use RGB channels (e.g. --fg-rgb) so alpha-tinted
 * rules adapt without per-theme overrides.
 */
:root {
  --bg: #13171e;
  --bg-elev: #0b0e13;
  --bg-elev-2: #11151c;
  --fg: #d6dde8;
  --fg-dim: #8a93a3;
  --fg-faint: #7b8496;
  --card: #0b0e13;
  --primary: #f5a623;          /* amber — primary accent / CTA */
  --primary-fg: #07090c;
  --accent: #4ad8e6;           /* cyan — secondary accent */
  --secondary: #11151c;
  --muted-fg: #7b8496;
  --border: rgba(214, 221, 232, 0.10);
  --border-strong: rgba(214, 221, 232, 0.20);
  --input: rgba(214, 221, 232, 0.06);
  --ring: #f5a623;
  --good: #4ad8a0;             /* mint green — up / good */
  --warn: #f5a623;             /* amber — caution */
  --bad: #ff5c57;              /* red — down / bad */
  --neutral: #8a93a3;
  --radius: 0;
  --radius-sm: 0;
  --radius-xs: 0;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font-sans: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --font-display: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --bg-rgb: 19, 23, 30;
  --fg-rgb: 214, 221, 232;
  --primary-rgb: 245, 166, 35;
  --accent-rgb: 74, 216, 230;
  --good-rgb: 74, 216, 160;
  --warn-rgb: 245, 166, 35;
  --bad-rgb: 255, 92, 87;

  --header-bg: rgba(7, 9, 12, 0.92);
  --btn-hover-bg: #161b24;
  --btn-primary-hover-bg: #ffba3a;
  --focus-ring: rgba(245, 166, 35, 0.25);
  --row-hover: rgba(245, 166, 35, 0.04);
  --row-stripe: rgba(214, 221, 232, 0.015);
  --warning-bg: rgba(245, 166, 35, 0.05);
  --toast-shadow: rgba(0, 0, 0, 0.55);
  --dialog-backdrop: rgba(0, 0, 0, 0.7);

  --rev-bar-bg: rgba(74, 216, 230, 0.35);
  --up: #4ad8a0;
  --down: #ff5c57;

  --tick: 1px;
}

[data-theme="light"] {
  --bg: #f4f1ea;
  --bg-elev: #efebdf;
  --bg-elev-2: #e6e1d2;
  --fg: #1a1d24;
  --fg-dim: #52565f;
  --fg-faint: #6e6a5e;
  --card: #efebdf;
  --primary: #b8650f;          /* darker amber for paper contrast */
  --primary-fg: #f4f1ea;
  --accent: #1c8a96;
  --secondary: #e6e1d2;
  --muted-fg: #6e6a5e;
  --border: rgba(26, 29, 36, 0.16);
  --border-strong: rgba(26, 29, 36, 0.30);
  --input: rgba(26, 29, 36, 0.08);
  --ring: #b8650f;
  --good: #2a7a4f;
  --warn: #b8650f;
  --bad: #b8362c;
  --neutral: #52565f;

  --bg-rgb: 244, 241, 234;
  --fg-rgb: 26, 29, 36;
  --primary-rgb: 184, 101, 15;
  --accent-rgb: 28, 138, 150;
  --good-rgb: 42, 122, 79;
  --warn-rgb: 184, 101, 15;
  --bad-rgb: 184, 54, 44;

  --header-bg: rgba(244, 241, 234, 0.92);
  --btn-hover-bg: #dcd6c4;
  --btn-primary-hover-bg: #a35a0d;
  --focus-ring: rgba(184, 101, 15, 0.25);
  --row-hover: rgba(184, 101, 15, 0.06);
  --row-stripe: rgba(26, 29, 36, 0.02);
  --warning-bg: rgba(184, 101, 15, 0.08);
  --toast-shadow: rgba(0, 0, 0, 0.18);
  --dialog-backdrop: rgba(0, 0, 0, 0.32);

  --rev-bar-bg: rgba(28, 138, 150, 0.30);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

/* The hidden attribute must win even over class display rules (e.g. the
   engine-weight sliders' .assumptions grid), or toggling .hidden has no
   visible effect. */
[hidden] {
  display: none !important;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 2px;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  letter-spacing: 0;
  margin: 0 0 0.5rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

h1 {
  font-size: 1.05rem;
}

h2 {
  font-size: 0.85rem;
  color: var(--fg-dim);
}

h3 {
  font-size: 0.78rem;
  color: var(--fg-dim);
}

p {
  margin: 0 0 0.6rem;
}

code,
.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

::selection {
  background: rgba(var(--primary-rgb), 0.3);
  color: var(--fg);
}

/* ---------- Theme toggle ---------- */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.3rem 0.5rem;
  line-height: 1;
  border: 1px solid var(--border);
}
.theme-toggle .theme-icon-dark,
.theme-toggle .theme-icon-light {
  display: none;
  font-size: 0.85rem;
}
[data-theme="dark"] .theme-toggle .theme-icon-light {
  display: inline;
}
[data-theme="light"] .theme-toggle .theme-icon-dark {
  display: inline;
}

/* ---------- Layout ---------- */
.container {
  max-width: 80rem;
  margin: 0 auto;
  padding: 1rem 1rem 4rem;
}

.container.narrow {
  max-width: 48rem;
}

/* ---------- Header ---------- */
.header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 2.5rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 1rem;
  border-bottom: 1px solid var(--border-strong);
  background: var(--header-bg);
  backdrop-filter: blur(8px);
  font-size: 0.78rem;
}

.header .logo {
  width: 22px;
  height: 22px;
  border-radius: 0;
  background: var(--primary);
  color: var(--primary-fg);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  flex: none;
  text-transform: uppercase;
}

.header .brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--fg);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.header .held {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--fg-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-left: 0.6rem;
  border-left: 1px solid var(--border);
}

.header .spacer {
  flex: 1;
}

.header a,
.header button {
  font-size: 0.78rem;
  color: var(--fg-dim);
}

.header .link {
  color: var(--fg-dim);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.header .link:hover {
  color: var(--fg);
  text-decoration: none;
}

/* ---------- Buttons / inputs ---------- */
button,
.btn {
  font: inherit;
  color: var(--fg);
  background: var(--secondary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.72rem;
  transition: border-color 0.12s var(--ease), background 0.12s var(--ease), color 0.12s var(--ease);
}
button:hover,
.btn:hover {
  border-color: var(--ring);
  background: var(--btn-hover-bg);
  color: var(--fg);
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-fg);
  border-color: var(--primary);
  font-weight: 700;
}
.btn-primary:hover {
  background: var(--btn-primary-hover-bg);
  border-color: var(--btn-primary-hover-bg);
  color: var(--primary-fg);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.btn-ghost:hover {
  background: var(--secondary);
  border-color: var(--border);
}

input[type="text"],
input[type="search"],
input[type="number"],
select {
  font: inherit;
  font-size: 0.8rem;
  color: var(--fg);
  background: var(--input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.55rem;
  width: 100%;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
input::placeholder {
  color: var(--fg-faint);
  text-transform: none;
  letter-spacing: 0;
}
input[type="text"]:focus,
input[type="search"]:focus,
input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 1px var(--focus-ring);
}

:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 1px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
  height: 4px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem;
}
.card h2 {
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.4rem;
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.card h2::before {
  content: "▸";
  color: var(--primary);
  font-size: 0.7rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
}
.stat {
  background: var(--card);
  border: none;
  border-radius: 0;
  padding: 0.7rem 0.85rem;
  position: relative;
}
.stat::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--accent);
  opacity: 0.6;
}

.stat .label {
  font-size: 0.65rem;
  color: var(--fg-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.3rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.stat .value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.45rem;
  font-weight: 500;
  color: var(--fg);
  letter-spacing: -0.01em;
}
.stat .sub {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--fg-faint);
  margin-top: 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---------- Letter badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  border-radius: 0;
  border: 1px solid var(--border-strong);
  line-height: 1;
  text-transform: uppercase;
}
.badge.sm {
  height: 1.5rem;
  min-width: 1.5rem;
  padding: 0 0.35rem;
  font-size: 0.75rem;
}
.badge.md {
  height: 1.75rem;
  min-width: 1.75rem;
  padding: 0 0.45rem;
  font-size: 0.85rem;
}
.badge.lg {
  height: 2.5rem;
  min-width: 2.5rem;
  padding: 0 0.65rem;
  font-size: 1.3rem;
}

.grade-good {
  color: var(--good);
  border-color: rgba(var(--good-rgb), 0.5);
  background: rgba(var(--good-rgb), 0.08);
}
.grade-ok {
  color: var(--accent);
  border-color: rgba(var(--accent-rgb), 0.4);
  background: rgba(var(--accent-rgb), 0.06);
}
.grade-warn {
  color: var(--warn);
  border-color: rgba(var(--warn-rgb), 0.5);
  background: rgba(var(--warn-rgb), 0.08);
}
.grade-bad {
  color: var(--bad);
  border-color: rgba(var(--bad-rgb), 0.5);
  background: rgba(var(--bad-rgb), 0.08);
}
.grade-none {
  color: var(--fg-faint);
  border-color: var(--border);
}

.fund-badge {
  color: var(--accent);
  border-color: rgba(var(--accent-rgb), 0.5);
  background: rgba(var(--accent-rgb), 0.08);
}
.fund-note {
  color: var(--fg-dim);
  font-style: italic;
  font-size: 0.85rem;
}

/* ---------- Watchlist ---------- */
.watchlist-summary {
  font-size: 0.75rem;
  color: var(--fg-dim);
  margin-bottom: 0.5rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.4rem 0.6rem;
  border-left: 2px solid var(--primary);
  background: var(--bg-elev);
}

.quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.6rem;
}
.chip {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.2rem 0.55rem;
  border-radius: 0;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--accent);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: border-color 0.12s var(--ease), color 0.12s var(--ease);
}
.chip:hover {
  border-color: var(--ring);
  color: var(--primary);
}

/* ---------- Watchlist picker ---------- */
.wl-picker {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.75rem 0;
}
.wl-picker-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg-faint);
}
.wl-select {
  width: auto;
  min-width: 14rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238a93a3' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  padding-right: 2rem;
  cursor: pointer;
}
.wl-select:hover {
  border-color: var(--ring);
}
.wl-new {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--fg-dim);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: border-color 0.12s var(--ease), color 0.12s var(--ease), background 0.12s var(--ease);
}
.wl-new:hover {
  border-color: var(--ring);
  color: var(--primary);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 0.75rem 0;
}
.filters > * {
  flex: 0 0 auto;
}
.filters input[type="search"] {
  flex: 1 1 18rem;
  min-width: 12rem;
}
.pill-group {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}
.pill {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.25rem 0.6rem;
  border-radius: 0;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--fg-dim);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: border-color 0.12s var(--ease), color 0.12s var(--ease), background 0.12s var(--ease);
}
.pill:hover {
  border-color: var(--ring);
  color: var(--primary);
}
.pill.active {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--bg);
}

.table-wrap {
  border: 1px solid var(--border);
  border-radius: 0;
  overflow-x: auto;
  background: var(--card);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

th,
td {
  padding: 0.45rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-faint);
  font-weight: 500;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border-strong);
}
/* Sticky watchlist header only where .table-wrap is not a horizontal
   scroll container (a sticky th inside one offsets against the wrapper
   and is painted over the first row). */
@media (min-width: 640px) {
  #watchlist .table-wrap {
    overflow-x: visible;
  }
  #watchlist th {
    position: sticky;
    top: 2.5rem;
    z-index: 1;
  }
}
tbody tr:nth-child(even) {
  background: var(--row-stripe);
}
tbody tr {
  border-left: 2px solid transparent;
  transition: border-color 0.08s var(--ease);
}
tbody tr:last-child td {
  border-bottom: none;
}
tbody tr:hover {
  background: var(--row-hover);
  border-left-color: var(--primary);
}

.td-num,
.th-num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.td-ticker {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.02em;
}
.td-name {
  color: var(--fg-faint);
  font-size: 0.72rem;
}

tr.row-clickable {
  cursor: pointer;
}

.row-action {
  background: transparent;
  border: 1px solid transparent;
  color: var(--fg-faint);
  padding: 0.25rem 0.55rem;
  font-size: 0.85rem;
  line-height: 1;
  min-width: 1.75rem;
  min-height: 1.75rem;
  text-transform: none;
  letter-spacing: 0;
}
.row-action:hover {
  color: var(--bad);
  background: rgba(var(--bad-rgb), 0.08);
  border-color: rgba(var(--bad-rgb), 0.3);
}

/* Touch: keep interactive controls at the 44px minimum hit area. */
@media (pointer: coarse) {
  button,
  .btn,
  .pill,
  .chip,
  .row-action,
  .sort-link,
  .header a,
  .header button {
    min-height: 44px;
  }
  .row-action {
    min-width: 44px;
  }
  .pill,
  .chip {
    padding: 0.45rem 0.8rem;
  }
}

.sort-link {
  color: var(--fg-faint);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}
th > .sort-link {
  display: flex;
  height: 100%;
  width: 100%;
  padding: 0.3rem 0;
}
.sort-link:hover,
.sort-link:focus-visible {
  color: var(--fg);
  text-decoration: none;
}
.sort-link.active {
  color: var(--primary);
}
.sort-link .sort-dir {
  font-size: 0.6rem;
  margin-left: 0.15rem;
}

td.empty-cell {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--fg-faint);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .spinner,
  .add-indicator,
  .btn-indicator,
  .add-pending::before {
    animation-duration: 0s;
  }
  .hero .cursor,
  .toast.fade {
    animation: none;
  }
  .toast.fade {
    opacity: 1;
  }
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Add / search ---------- */
.add-form {
  display: flex;
  gap: 0.4rem;
  align-items: flex-start;
}
.add-form input {
  flex: 1;
}
.add-results {
  position: relative;
  margin-top: 0.25rem;
}
.dropdown {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: 0;
  z-index: 10;
  max-height: 18rem;
  overflow-y: auto;
  box-shadow: 0 8px 24px var(--toast-shadow);
}
.dropdown-item {
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.dropdown-item:last-child {
  border-bottom: none;
}
.dropdown-item:hover,
.dropdown-item.active {
  background: var(--row-hover);
  box-shadow: inset 2px 0 0 0 var(--primary);
}
.dropdown-item .tick {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--accent);
  text-transform: uppercase;
}
.dropdown-item .nm {
  color: var(--fg-faint);
  font-size: 0.75rem;
}
.dropdown-item.adding {
  pointer-events: none;
  opacity: 0.6;
}
.add-pending {
  margin-top: 0.25rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--fg-dim);
}
.add-pending::before {
  content: "";
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  border: 1px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 0.4rem;
  vertical-align: -2px;
}

.progress {
  margin: 0.6rem 0;
  font-size: 0.75rem;
  color: var(--fg-dim);
  font-family: var(--font-mono);
}
.progress .bar {
  height: 3px;
  background: var(--bg-elev-2);
  border-radius: 0;
  overflow: hidden;
  margin-top: 0.25rem;
  border: 1px solid var(--border);
}
.progress .bar > span {
  display: block;
  height: 100%;
  background: var(--primary);
  transition: width 0.2s var(--ease);
}

/* ---------- Detail page ---------- */
.back-link {
  display: inline-block;
  font-size: 0.78rem;
  margin-bottom: 0.5rem;
  color: var(--fg-dim);
}
.back-link:hover {
  color: var(--fg);
}
.detail-header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.detail-header h1 {
  margin: 0;
  font-size: 1.1rem;
  text-transform: none;
  letter-spacing: 0;
}
.detail-header .subtitle {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--fg-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.2rem;
}
.detail-actions {
  display: flex;
  gap: 0.35rem;
  margin-left: auto;
}

/* Vertical rhythm between stacked cards inside a detail column. */
.stack-above {
  margin-top: 1rem;
}

/* Grade card header row: badge + investment score. */
.grade-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

/* Generic muted helper text (used inside cards). */
.hint {
  font-size: 0.7rem;
  color: var(--fg-dim);
  margin-bottom: 0.5rem;
}

.shares-line {
  font-size: 0.75rem;
  color: var(--fg-dim);
  margin: 0 0 0.75rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.shares-line .num {
  font-family: var(--font-mono);
  color: var(--primary);
}

.warnings {
  margin: 0.75rem 0;
  display: grid;
  gap: 0.3rem;
}
.warning {
  font-size: 0.75rem;
  padding: 0.4rem 0.6rem;
  border-left: 2px solid var(--warn);
  background: var(--warning-bg);
  border-radius: 0;
  font-family: var(--font-mono);
}
.warning .code {
  font-family: var(--font-mono);
  color: var(--warn);
  font-size: 0.68rem;
  text-transform: uppercase;
  margin-right: 0.5rem;
  letter-spacing: 0.06em;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin-top: 1px;
  background: var(--border);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.detail-grid > div {
  background: var(--bg);
  padding: 1px 0;
  display: grid;
  gap: 1px;
}
.detail-grid > div > .card {
  margin: 0;
}
.detail-grid .card {
  border: none;
  border-radius: 0;
}
@media (max-width: 60rem) {
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- Chart ---------- */
.chart {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.chart-legend {
  display: flex;
  gap: 0.75rem;
  font-size: 0.7rem;
  color: var(--fg-dim);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.chart-legend .swatch {
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 0;
  margin-right: 0.3rem;
  vertical-align: -1px;
}
.rev-swatch {
  background: var(--rev-bar-bg);
  border: 1px solid var(--accent);
}
.ni-swatch {
  background: var(--good);
}
.oe-swatch {
  background: var(--warn);
}
.chart-bars {
  display: grid;
  grid-template-columns: repeat(var(--cols, 10), 1fr);
}
.chart-cell {
  display: flex;
  flex-direction: column;
}
.chart-cell:first-child {
  border-left: 1px solid var(--border);
}
.chart-cell:hover {
  background: var(--row-hover);
}
.chart-cell:hover .chart-x {
  color: var(--fg);
}
.chart-col {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 11rem;
  gap: 1px;
  padding: 0.25rem 0.1rem 0;
  border-bottom: 1px solid var(--border-strong);
}
.chart-bar {
  width: 100%;
  min-height: 1px;
  border-radius: 0;
}
.chart-bar.rev {
  background: var(--rev-bar-bg);
  border-top: 1px solid var(--accent);
}
.chart-bar.ni {
  background: var(--good);
}
.chart-bar.oe {
  background: var(--warn);
}
.chart-x {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--fg-faint);
  text-align: center;
  padding: 0.2rem 0 0;
}

/* ---------- Annual table ---------- */
.annual-table {
  font-size: 0.72rem;
}
.annual-table th,
.annual-table td {
  padding: 0.3rem 0.45rem;
}

/* ---------- Assumptions ---------- */
.assumptions {
  display: grid;
  gap: 0.75rem;
}
.assumption {
  display: grid;
  gap: 0.2rem;
}
.assumption .row {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.assumption .row .v {
  font-family: var(--font-mono);
  color: var(--primary);
  font-weight: 500;
}
.assumption .hint {
  margin-bottom: 0;
}

/* ---------- Engine mode + weight sliders ---------- */
.engine-section {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.engine-mode {
  display: grid;
  gap: 0.3rem;
  margin-bottom: 0.5rem;
}
.engine-mode .row-inline {
  font-size: 0.8rem;
}

/* ---------- Valuation models breakdown table ---------- */
.models-card {
  margin-bottom: 1rem;
}
.models-table {
  width: 100%;
  font-size: 0.78rem;
  border-collapse: collapse;
}
.models-table th,
.models-table td {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.models-table th {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg-faint);
}
.models-table .td-num {
  font-family: var(--font-mono);
  text-align: right;
}
.models-note {
  color: var(--fg-faint);
  font-size: 0.7rem;
}

/* ---------- IV breakdown ---------- */
.iv-dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.3rem 1rem;
  font-size: 0.78rem;
  margin: 0;
}
.iv-dl dt {
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.72rem;
}
.iv-dl dd {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  margin: 0;
  color: var(--fg);
}
.iv-dl dt {
  cursor: help;
}

/* Silent extension flags shown under the IV breakdown. These are modeling
 * choices (net-debt bridge, fade terminal, implied growth) that don't
 * warrant a full warning block but should be visible to the user. */
.iv-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.6rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}
.iv-flag {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--accent);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 0.1rem 0.35rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ---------- Grade card / slices ---------- */
.slices {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.6rem;
}
.slice {
  display: grid;
  gap: 0.15rem;
}
.slice .row {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.slice .row .v {
  font-family: var(--font-mono);
  color: var(--fg);
}
.slice .row .slice-weight {
  color: var(--fg-dim);
}
.slice .note {
  font-size: 0.68rem;
  color: var(--fg-faint);
  font-family: var(--font-mono);
}
.slice .bar {
  height: 2px;
  background: var(--bg-elev-2);
  border-radius: 0;
  overflow: hidden;
}
.slice .bar > span {
  display: block;
  height: 100%;
  background: var(--primary);
  transition: width 0.2s var(--ease);
}
.slice .bar.good > span {
  background: var(--good);
}
.slice .bar.warn > span {
  background: var(--warn);
}
.slice .bar.bad > span {
  background: var(--bad);
}

/* ---------- Toasts ---------- */
.toasts {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  z-index: 50;
  width: min(90vw, 26rem);
  font-family: var(--font-mono);
}
.toast {
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--neutral);
  border-radius: 0;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  box-shadow: 0 8px 24px var(--toast-shadow);
  animation: toast-in 0.15s var(--ease);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.toast.success {
  border-left-color: var(--good);
  color: var(--good);
}
.toast.error {
  border-left-color: var(--bad);
  color: var(--bad);
}
.toast.message {
  border-left-color: var(--accent);
}
.toast.fade {
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-8px);
  }
}

/* ---------- Hero ---------- */
.hero {
  padding: 3.5rem 0 2rem;
  text-align: left;
  border-left: 3px solid var(--primary);
  padding-left: 1.25rem;
  margin: 2rem 0;
}
.hero h1 {
  font-size: 1.6rem;
  margin-bottom: 0.5rem;
  text-transform: none;
  letter-spacing: -0.01em;
  font-family: var(--font-display);
  color: var(--fg);
  font-weight: 600;
}
.hero h1::before {
  content: "> ";
  color: var(--primary);
  font-weight: 700;
}
.hero .cursor {
  display: inline-block;
  width: 0.55rem;
  height: 1.05rem;
  background: var(--primary);
  margin-left: 0.15rem;
  vertical-align: -2px;
  animation: blink 1.1s steps(2) infinite;
}
@keyframes blink {
  50% {
    opacity: 0;
  }
}
.hero p {
  color: var(--fg-dim);
  max-width: 34rem;
  margin: 0 0 1.25rem;
  font-size: 0.82rem;
  line-height: 1.6;
}
.hero .add-form {
  max-width: 28rem;
  margin: 0;
}

/* ---------- Method page ---------- */
.method {
  font-size: 0.82rem;
  max-width: 48rem;
  line-height: 1.65;
}
.method h2 {
  margin-top: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.3rem;
}
.method h3 {
  margin-top: 1.25rem;
  font-size: 0.78rem;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.method p,
.method li {
  color: var(--fg);
  line-height: 1.65;
}
.method code {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  padding: 0.05rem 0.3rem;
  border-radius: 0;
  font-size: 0.85em;
  color: var(--accent);
}

/* ---------- Empty / spinner ---------- */
.empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--fg-faint);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.empty::before {
  content: "// ";
  color: var(--fg-faint);
}
.spinner {
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  border: 1px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
  margin-right: 0.4rem;
}
.add-indicator {
  display: none;
  width: 0.75rem;
  height: 0.75rem;
  border-width: 1px;
  border-top-color: var(--primary-fg);
  margin-right: 0;
  margin-left: 0.3rem;
  vertical-align: -1px;
}
.htmx-request .add-indicator,
.add-indicator.htmx-request {
  display: inline-block;
}
.btn-indicator {
  display: none;
  width: 0.75rem;
  height: 0.75rem;
  border-width: 1px;
  border-top-color: var(--primary-fg);
  margin-right: 0;
  margin-left: 0.3rem;
  vertical-align: -1px;
}
.htmx-request .btn-indicator,
.btn-indicator.htmx-request {
  display: inline-block;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Dialog ---------- */
dialog {
  background: var(--bg-elev);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  border-radius: 0;
  padding: 1.25rem;
  max-width: min(92vw, 32rem);
  box-shadow: 0 16px 48px var(--toast-shadow);
}
dialog::backdrop {
  background: var(--dialog-backdrop);
  backdrop-filter: blur(2px);
}
dialog h2 {
  margin-top: 0;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.4rem;
  margin-bottom: 0.75rem;
}

/* ---------- Scrollbar (terminal feel) ---------- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 0;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--fg-faint);
}