/* TradeMaxxing — one token set, light by default, dark via [data-theme="dark"].
   Neutrals carry the UI; colour is reserved for meaning (buy/hold/sell, status)
   plus a single desaturated "signal" accent for live/focus states. */

:root {
  color-scheme: light;

  --bg: #f4f5f6;
  --surface: #ffffff;
  --surface-2: #eceef0;
  --border: #dfe2e6;
  --fg: #14171b;
  --fg-muted: #5b636d;
  --fg-faint: #8a919a;

  --accent: #2f7f86;
  --accent-soft: rgba(47, 127, 134, 0.12);
  --on-strong: #f4f5f6;
  --strong: #14171b;
  --strong-hover: #2b3037;

  --status-queued-bg: #e6e8eb;
  --status-queued-fg: #5b636d;
  --status-running-bg: rgba(47, 127, 134, 0.14);
  --status-running-fg: #23636a;
  --status-completed-bg: #e0eee4;
  --status-completed-fg: #2b6a3f;
  --status-failed-bg: #f5e1e0;
  --status-failed-fg: #a23a36;

  --tone-buy-bg: #e0eee4;
  --tone-buy-fg: #2b6a3f;
  --tone-hold-bg: #f3ecd9;
  --tone-hold-fg: #7a5a12;
  --tone-sell-bg: #f5e1e0;
  --tone-sell-fg: #a23a36;

  --shadow: 0 1px 2px rgba(20, 30, 45, 0.05), 0 8px 24px -12px rgba(20, 30, 45, 0.12);

  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;

  --radius-sm: 6px;
  --radius: 12px;
  --radius-pill: 999px;

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

  --z-tooltip: 10;
  --z-nav: 20;
}

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

  --bg: #0c0e11;
  --surface: #14171b;
  --surface-2: #1b1f24;
  --border: #252a31;
  --fg: #e9ebee;
  --fg-muted: #98a0aa;
  --fg-faint: #69717b;

  --accent: #62b3ba;
  --accent-soft: rgba(98, 179, 186, 0.14);
  --on-strong: #0c0e11;
  --strong: #e9ebee;
  --strong-hover: #ffffff;

  --status-queued-bg: #1f242a;
  --status-queued-fg: #98a0aa;
  --status-running-bg: rgba(98, 179, 186, 0.14);
  --status-running-fg: #7fc6cc;
  --status-completed-bg: rgba(94, 178, 120, 0.14);
  --status-completed-fg: #7cc593;
  --status-failed-bg: rgba(214, 100, 94, 0.15);
  --status-failed-fg: #e08480;

  --tone-buy-bg: rgba(94, 178, 120, 0.14);
  --tone-buy-fg: #7cc593;
  --tone-hold-bg: rgba(212, 170, 80, 0.14);
  --tone-hold-fg: #d9b565;
  --tone-sell-bg: rgba(214, 100, 94, 0.15);
  --tone-sell-fg: #e08480;

  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 12px 32px -16px rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
}

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

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  transition: background 200ms ease, color 200ms ease;
}

a {
  color: var(--accent);
}

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

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -48px;
  background: var(--strong);
  color: var(--on-strong);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  font-weight: 600;
  z-index: var(--z-nav);
  transition: top 150ms ease;
}

.skip-link:focus {
  top: var(--space-3);
}

/* --- Layout --- */

.topnav {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 var(--space-6);
  display: flex;
  align-items: center;
  gap: var(--space-8);
  height: 60px;
}

.topnav__brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 650;
  font-size: 1.05rem;
  color: var(--fg);
  text-decoration: none;
  letter-spacing: -0.03em;
}

.topnav__brand::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: var(--accent);
  transform: rotate(45deg);
}

.topnav__links {
  display: flex;
  gap: var(--space-2);
  flex: 1;
}

.topnav__links a {
  color: var(--fg-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: color 150ms ease, background 150ms ease;
}

.topnav__links a:hover {
  color: var(--fg);
  background: var(--surface-2);
}

.topnav__links a[aria-current="page"] {
  color: var(--fg);
  background: var(--surface-2);
}

.theme-toggle {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease, transform 100ms ease;
}

.theme-toggle:hover {
  color: var(--fg);
  background: var(--surface-2);
}

.theme-toggle:active {
  transform: scale(0.96);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

.theme-toggle .icon-moon {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: block;
}

main {
  max-width: 880px;
  margin: 0 auto;
  padding: var(--space-12) var(--space-6) 96px;
}

main.main--narrow {
  max-width: 420px;
}

main.main--wide {
  max-width: 1160px;
}

h1 {
  font-size: 2.1rem;
  font-weight: 650;
  letter-spacing: -0.035em;
  line-height: 1.1;
  margin: 0 0 var(--space-8) 0;
  text-wrap: balance;
}

h1 .ticker-date {
  color: var(--fg-faint);
  font-weight: 400;
  font-family: var(--font-mono);
  font-size: 0.55em;
  letter-spacing: 0;
  margin-left: 6px;
}

.page-lede {
  color: var(--fg-muted);
  max-width: 60ch;
  margin: calc(var(--space-4) * -1) 0 var(--space-8) 0;
  text-wrap: pretty;
}

/* --- Card --- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-8);
}

.card + .card {
  margin-top: var(--space-4);
}

.card h3,
.card h4 {
  margin-top: 0;
}

/* --- Forms --- */

.field {
  margin-bottom: var(--space-6);
}

.field-row {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: var(--space-4);
}

.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--fg-muted);
  margin-bottom: var(--space-2);
}

.field input[type="text"],
.field input[type="date"],
.field input[type="email"],
.field input[type="password"],
.field select {
  width: 100%;
  font: inherit;
  font-size: 0.95rem;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--fg);
  min-height: 46px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.field input:hover,
.field select:hover {
  border-color: var(--fg-faint);
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field input::placeholder {
  color: var(--fg-faint);
}

.field input.input--ticker {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  min-height: 60px;
  padding: 0 var(--space-4);
}

.field input.input--ticker::placeholder {
  text-transform: none;
  letter-spacing: 0;
  font-size: 1rem;
  font-family: var(--font-sans);
}

/* --- Info tooltip --- */

.info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--fg-muted);
  font-size: 0.68rem;
  font-weight: 600;
  font-style: normal;
  cursor: help;
  position: relative;
  transition: background 150ms ease, color 150ms ease;
}

.info:hover,
.info:focus-visible {
  background: var(--accent);
  color: var(--bg);
}

.info::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 250px;
  background: var(--strong);
  color: var(--on-strong);
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.45;
  text-align: left;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  transition: opacity 120ms ease;
  z-index: var(--z-tooltip);
}

.info:hover::after,
.info:focus-visible::after {
  opacity: 1;
  visibility: visible;
}

.info--wide::after {
  max-width: 320px;
  left: 0;
  transform: none;
}

fieldset {
  border: none;
  padding: 0;
  margin: 0 0 var(--space-6) 0;
}

fieldset legend {
  display: flex;
  align-items: center;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--fg-muted);
  padding: 0;
  margin-bottom: var(--space-2);
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.chip {
  position: relative;
}

.chip input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.chip span {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--fg-muted);
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease, transform 100ms ease;
  user-select: none;
}

.chip span:hover {
  border-color: var(--fg-faint);
  color: var(--fg);
}

.chip span:active {
  transform: scale(0.97);
}

.chip input:checked + span {
  background: var(--strong);
  border-color: var(--strong);
  color: var(--on-strong);
}

.chip input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 var(--space-8);
  border-radius: 10px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease, transform 100ms ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--strong);
  color: var(--on-strong);
}

.btn-primary:hover {
  background: var(--strong-hover);
}

.btn-block {
  width: 100%;
}

/* --- Status badges --- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 10px 3px 9px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: capitalize;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge--queued,
.badge--pending {
  background: var(--status-queued-bg);
  color: var(--status-queued-fg);
}

.badge--running {
  background: var(--status-running-bg);
  color: var(--status-running-fg);
}

.badge--running::before {
  animation: flow-dot-pulse 1.1s ease-in-out infinite;
}

.badge--completed {
  background: var(--status-completed-bg);
  color: var(--status-completed-fg);
}

.badge--failed {
  background: var(--status-failed-bg);
  color: var(--status-failed-fg);
}

#run-status > p:first-child {
  margin: 0 0 var(--space-4) 0;
}

/* --- Agent flow diagram --- */

.flow {
  display: flex;
  align-items: center;
  gap: 0;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 4px 2px;
}

.flow-group {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 12px;
  border-radius: 14px;
  border: 1px dashed var(--border);
}

.flow-group-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--fg-faint);
  margin-bottom: 2px;
}

.flow-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  color: var(--fg-faint);
  font-size: 1.1rem;
  align-self: center;
}

.flow-node {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--radius-pill);
  padding: 7px 14px;
  background: var(--surface);
  font-size: 0.82rem;
  font-weight: 550;
  white-space: nowrap;
  color: var(--status-queued-fg);
  border: 1.5px solid var(--border);
  isolation: isolate;
  transition: background 200ms ease, border-color 200ms ease, color 200ms ease;
}

.flow-node--single {
  align-self: center;
}

.flow-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}

.flow-node--completed {
  border-color: transparent;
  background: var(--status-completed-bg);
  color: var(--status-completed-fg);
}

/* Running: a slow accent sweep around the border plus a soft breathing glow. */
.flow-node--running {
  color: var(--status-running-fg);
  border-color: transparent;
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    linear-gradient(100deg, var(--accent), var(--fg-faint), var(--accent), var(--fg-faint)) border-box;
  background-size: 100% 100%, 300% 100%;
  animation: flow-shimmer 3s linear infinite;
}

.flow-node--running::after {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: var(--radius-pill);
  background: radial-gradient(circle, var(--accent-soft), transparent 70%);
  animation: flow-breathe 2.2s ease-in-out infinite;
  z-index: -1;
}

.flow-node--running .flow-dot {
  animation: flow-dot-pulse 1.1s ease-in-out infinite;
}

@keyframes flow-shimmer {
  0% { background-position: 0 0, 0% 0; }
  100% { background-position: 0 0, -300% 0; }
}

@keyframes flow-breathe {
  0%, 100% { transform: scale(0.92); opacity: 0.45; }
  50% { transform: scale(1.15); opacity: 0.9; }
}

@keyframes flow-dot-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.5); }
}

@media (max-width: 760px) {
  .flow {
    flex-direction: column;
    align-items: stretch;
  }

  .flow-arrow {
    min-height: 20px;
    transform: rotate(90deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .flow-node--running,
  .flow-node--running::after,
  .flow-node--running .flow-dot,
  .badge--running::before {
    animation: none;
  }
}

/* --- Report sections --- */

.badge-lg {
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-lg--buy {
  background: var(--tone-buy-bg);
  color: var(--tone-buy-fg);
}

.badge-lg--hold {
  background: var(--tone-hold-bg);
  color: var(--tone-hold-fg);
}

.badge-lg--sell {
  background: var(--tone-sell-bg);
  color: var(--tone-sell-fg);
}

.gauge {
  position: relative;
  height: 6px;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--tone-sell-fg), var(--tone-hold-fg), var(--tone-buy-fg));
  opacity: 0.85;
  margin: var(--space-3) 0 6px 0;
}

.gauge-marker {
  position: absolute;
  top: -4px;
  width: 3px;
  height: 14px;
  border-radius: 2px;
  background: var(--fg);
  box-shadow: 0 0 0 2px var(--surface);
}

.gauge-scale {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--fg-faint);
  margin-bottom: var(--space-4);
}

.stat-row {
  display: flex;
  gap: var(--space-8);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

.stat-value {
  font-size: 1.05rem;
  font-weight: 500;
  font-family: var(--font-mono);
}

.stat-label {
  font-size: 0.72rem;
  color: var(--fg-faint);
}

.report-markdown {
  font-size: 0.92rem;
  line-height: 1.7;
  max-width: 68ch;
}

.report-markdown h1,
.report-markdown h2,
.report-markdown h3 {
  font-size: 1rem;
  letter-spacing: -0.01em;
  margin: var(--space-6) 0 var(--space-2) 0;
}

.report-markdown table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-3) 0;
  font-size: 0.85rem;
}

.report-markdown th,
.report-markdown td {
  text-align: left;
  padding: 7px 10px;
  border: 1px solid var(--border);
}

.report-markdown th {
  background: var(--surface-2);
  font-weight: 600;
}

.report-markdown code {
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.85em;
}

.error-box {
  background: var(--status-failed-bg);
  color: var(--status-failed-fg);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
  font-size: 0.9rem;
}

/* --- History --- */

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

table.history {
  width: 100%;
  border-collapse: collapse;
}

table.history th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--fg-faint);
  padding: var(--space-3) var(--space-6);
  border-bottom: 1px solid var(--border);
}

table.history td {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--fg-muted);
}

table.history tr:first-child td {
  border-top: none;
}

table.history tbody tr {
  transition: background 120ms ease;
}

table.history tbody tr:hover {
  background: var(--surface-2);
}

table.history a {
  color: var(--fg);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

table.history a:hover {
  color: var(--accent);
}

.empty-state {
  padding: var(--space-12) var(--space-6);
  text-align: center;
  color: var(--fg-muted);
}

.empty-state p {
  margin: 0 0 var(--space-4) 0;
}

.empty-state .btn {
  min-height: 42px;
  padding: 0 var(--space-6);
  text-decoration: none;
}

.not-found {
  padding-top: var(--space-8);
}

.not-found__code {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--fg-faint);
  margin: 0 0 var(--space-3) 0;
}

/* --- Login --- */

.login-card {
  margin: var(--space-8) auto 0;
  max-width: 400px;
}

.login-card h1 {
  font-size: 1.8rem;
  margin-bottom: var(--space-2);
}

.login-card .page-lede {
  margin: 0 0 var(--space-6) 0;
}

.error-message {
  background: var(--status-failed-bg);
  color: var(--status-failed-fg);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  font-size: 0.9rem;
  margin-bottom: var(--space-4);
}

/* --- Responsive --- */

@media (max-width: 560px) {
  .topnav {
    padding: 0 var(--space-4);
    gap: var(--space-3);
  }

  main {
    padding: var(--space-8) var(--space-4) 64px;
  }

  h1 {
    font-size: 1.7rem;
  }

  .card {
    padding: var(--space-6) var(--space-4);
  }

  .field-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  table.history th,
  table.history td {
    padding: var(--space-3) var(--space-4);
  }
}

/* --- Run overview: asymmetric bento of double-bezel tiles --- */

:root {
  --bezel-bg: rgba(20, 30, 45, 0.045);
  --bezel-ring: rgba(20, 30, 45, 0.08);
  --core-highlight: rgba(255, 255, 255, 0.95);
  --core-shadow: 0 24px 48px -28px rgba(20, 30, 45, 0.28);
  --ease-spring: cubic-bezier(0.32, 0.72, 0, 1);
}

:root[data-theme="dark"] {
  --bezel-bg: rgba(255, 255, 255, 0.04);
  --bezel-ring: rgba(255, 255, 255, 0.08);
  --core-highlight: rgba(255, 255, 255, 0.07);
  --core-shadow: 0 24px 48px -28px rgba(0, 0, 0, 0.7);
}

.overview {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 20px;
  margin-top: var(--space-6);
}

/* Machined-hardware tile: an outer tray holding an inner core with concentric radii. */
.bezel {
  padding: 6px;
  border-radius: 28px;
  background: var(--bezel-bg);
  box-shadow: 0 0 0 1px var(--bezel-ring);
  transition: transform 600ms var(--ease-spring);
}

.bezel__core {
  height: 100%;
  padding: 28px;
  border-radius: 22px;
  background: var(--surface);
  box-shadow: inset 0 1px 1px var(--core-highlight), var(--core-shadow);
}

.eyebrow {
  display: inline-block;
  padding: 4px 11px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--fg-muted);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.verdict {
  grid-column: span 8;
}

.verdict .bezel__core {
  padding: 40px 44px 44px;
}

.verdict__rating {
  margin: 22px 0 20px;
  font-size: clamp(3.2rem, 8vw, 5.4rem);
  font-weight: 650;
  line-height: 0.95;
  letter-spacing: -0.055em;
}

.verdict__rating--buy { color: var(--tone-buy-fg); }
.verdict__rating--hold { color: var(--tone-hold-fg); }
.verdict__rating--sell { color: var(--tone-sell-fg); }

.verdict__summary {
  margin: 0;
  max-width: 58ch;
  font-size: 1.08rem;
  line-height: 1.65;
  color: var(--fg);
  text-wrap: pretty;
}

.verdict__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 48px;
  margin: 32px 0 0;
  padding-top: 24px;
  border-top: 1px solid var(--bezel-ring);
}

.verdict__stats dt,
.plan dt {
  font-size: 0.72rem;
  color: var(--fg-faint);
  margin-bottom: 4px;
}

.verdict__stats dd,
.plan dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.verdict__stats .verdict__note {
  margin-top: 4px;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--fg-muted);
  letter-spacing: 0;
  max-width: 24ch;
}

.side {
  grid-column: span 4;
  display: grid;
  gap: 20px;
  align-content: start;
}

.path {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
}

.path li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 12px 0;
}

.path li + li {
  border-top: 1px solid var(--bezel-ring);
}

.path__label {
  font-size: 0.86rem;
  color: var(--fg-muted);
}

.plan {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 18px 0 0;
}

.plan__wide {
  grid-column: 1 / -1;
}

.plan dd {
  font-size: 1.1rem;
}

.plan__reasoning {
  margin: 18px 0 0;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--fg-muted);
}

.evidence--market_report,
.evidence--fundamentals_report {
  grid-column: span 7;
}

.evidence--sentiment_report,
.evidence--news_report {
  grid-column: span 5;
}

.evidence__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: 18px;
}

.evidence__excerpt {
  margin: 0 0 20px;
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--fg);
  text-wrap: pretty;
}

.reasoning {
  grid-column: 1 / -1;
}

.reasoning__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 14px 0;
  border-top: 1px solid var(--bezel-ring);
}

.reasoning__row:first-of-type {
  margin-top: 14px;
}

.reasoning__row h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 550;
  letter-spacing: -0.01em;
}

/* Pill trigger with its icon nested in its own circle, flush to the right edge. */
.more {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 5px 5px 5px 16px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--fg);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 550;
  cursor: pointer;
  transition: background 400ms var(--ease-spring), transform 300ms var(--ease-spring);
}

.more:hover {
  background: var(--bezel-ring);
}

.more:active {
  transform: scale(0.98);
}

.more__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--fg-muted);
  transition: transform 500ms var(--ease-spring), color 300ms var(--ease-spring);
}

.more__icon svg {
  width: 14px;
  height: 14px;
}

.more:hover .more__icon {
  color: var(--fg);
  transform: translate(1px, -1px);
}

/* Report popup */
body:has(dialog[open]) {
  overflow: hidden;
}

dialog.modal {
  width: min(780px, calc(100vw - 32px));
  max-height: min(84dvh, 920px);
  padding: 0;
  border: 0;
  border-radius: 28px;
  background: var(--surface);
  color: var(--fg);
  box-shadow: 0 0 0 1px var(--bezel-ring), 0 48px 96px -32px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

dialog.modal[open] {
  display: flex;
  flex-direction: column;
  animation: modal-in 500ms var(--ease-spring);
}

dialog.modal::backdrop {
  background: rgba(8, 10, 14, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: modal-fade 400ms var(--ease-spring);
}

.modal__head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 20px 20px 18px 32px;
  border-bottom: 1px solid var(--bezel-ring);
}

.modal__head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.modal__close {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--fg-muted);
  cursor: pointer;
  transition: background 300ms var(--ease-spring), color 300ms var(--ease-spring), transform 300ms var(--ease-spring);
}

.modal__close:hover {
  background: var(--bezel-ring);
  color: var(--fg);
}

.modal__close:active {
  transform: scale(0.94);
}

.modal__close svg {
  width: 14px;
  height: 14px;
}

.modal__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 32px 36px;
  overscroll-behavior: contain;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes modal-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  dialog.modal[open],
  dialog.modal::backdrop {
    animation: none;
  }
}

/* Scroll-in: a heavy fade-up staggered by --i. Only transform and opacity animate,
   and content stays visible if JS never runs (.js is set in the head). */
.js .reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 900ms var(--ease-spring), transform 900ms var(--ease-spring);
  transition-delay: calc(var(--i, 0) * 70ms);
}

.js .reveal.is-visible {
  opacity: 1;
  transform: none;
}

@media (hover: hover) {
  .js .reveal.is-visible.evidence:hover {
    transform: translateY(-3px);
    transition-delay: 0ms;
    transition-duration: 500ms;
  }
}

@media (prefers-reduced-motion: reduce) {
  .js .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

@media (max-width: 860px) {
  .overview {
    gap: 16px;
  }

  .verdict,
  .side,
  .evidence--market_report,
  .evidence--fundamentals_report,
  .evidence--sentiment_report,
  .evidence--news_report {
    grid-column: 1 / -1;
  }

  .verdict .bezel__core {
    padding: 28px 24px 30px;
  }

  .bezel__core {
    padding: 22px 20px;
  }
}

/* --- Thesis, portfolio and privacy controls --- */

.field textarea,
.field input[type="file"] {
  width: 100%;
  font: inherit;
  font-size: 0.95rem;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--fg);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.field textarea {
  resize: vertical;
  min-height: 104px;
  line-height: 1.55;
}

.field textarea:hover,
.field input[type="file"]:hover {
  border-color: var(--fg-faint);
}

.field textarea:focus,
.field input[type="file"]:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field textarea::placeholder {
  color: var(--fg-faint);
}

.optional {
  margin-left: 6px;
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--fg-faint);
}

.field label.check {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0;
  cursor: pointer;
  font-size: 0.92rem;
  color: var(--fg);
}

.check input {
  margin-top: 3px;
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
  cursor: pointer;
}

.check em {
  display: block;
  margin-top: 2px;
  font-size: 0.8rem;
  font-style: normal;
  color: var(--fg-muted);
}

.check-hint {
  margin: 0;
  font-size: 0.86rem;
  color: var(--fg-muted);
}

.run-context {
  display: grid;
  gap: 12px;
  justify-items: start;
  margin: calc(var(--space-4) * -1) 0 var(--space-6);
}

.run-context__thesis {
  margin: 0;
  max-width: 68ch;
  color: var(--fg-muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

.run-context__thesis strong {
  margin-right: 6px;
  color: var(--fg);
  font-weight: 600;
}

.tag {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--fg-muted);
  font-family: var(--font-sans);
  font-size: 0.68rem;
  font-weight: 550;
  letter-spacing: 0.02em;
  vertical-align: middle;
}

.portfolio-table {
  margin-top: var(--space-6);
}

table.history th.num,
table.history td.num {
  text-align: right;
  font-family: var(--font-mono);
}

.portfolio-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.cash-form {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.cash-form label {
  font-size: 0.82rem;
  color: var(--fg-muted);
}

.cash-form input {
  width: 130px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.cash-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn-quiet {
  min-height: 42px;
  padding: 0 var(--space-4);
  background: transparent;
  color: var(--fg-muted);
  border: 1px solid var(--border);
}

.btn-quiet:hover {
  color: var(--fg);
  background: var(--surface-2);
}

@media (max-width: 560px) {
  .portfolio-actions,
  .cash-form {
    flex-wrap: wrap;
  }
}

.field input[type="file"]::file-selector-button {
  margin-right: 14px;
  padding: 7px 14px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--fg);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 550;
  cursor: pointer;
  transition: background 300ms var(--ease-spring);
}

.field input[type="file"]::file-selector-button:hover {
  background: var(--bezel-ring);
}
