/* TradingAgents web UI. Neutral surfaces; color only where it carries meaning:
   blue = live, the rating scale (green..gray..red), and status. */

:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --ink: #18181b;
  --ink-2: #3f3f46;
  --muted: #71717a;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --ring: rgb(161 161 170 / 0.45);
  --primary: #18181b;
  --primary-ink: #fafafa;

  --live: #2563eb;
  --live-soft: #eff6ff;
  --ok: #15803d;
  --ok-soft: #f0fdf4;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --bad: #dc2626;
  --bad-ink: #b91c1c;
  --bad-soft: #fef2f2;
  --chart: #2563eb;

  /* The 5-tier rating, a diverging scale with a neutral middle. */
  --r-buy: #16a34a;        --r-buy-soft: #dcfce7;  --r-buy-ink: #14532d;
  --r-over: #4ade80;       --r-over-soft: #ecfdf5; --r-over-ink: #166534;
  --r-hold: #a1a1aa;       --r-hold-soft: #f4f4f5; --r-hold-ink: #3f3f46;
  --r-under: #f87171;      --r-under-soft: #fff1f2; --r-under-ink: #9f1239;
  --r-sell: #dc2626;       --r-sell-soft: #fee2e2; --r-sell-ink: #991b1b;

  --shadow-card: 0 0 0 1px rgb(0 0 0 / 0.06), 0 1px 2px -1px rgb(0 0 0 / 0.06), 0 2px 4px 0 rgb(0 0 0 / 0.03);
  --shadow-pop: 0 0 0 1px rgb(0 0 0 / 0.06), 0 4px 12px -2px rgb(0 0 0 / 0.08), 0 12px 32px -4px rgb(0 0 0 / 0.08);

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-icon: cubic-bezier(0.2, 0, 0, 1);

  --sans: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-family: var(--sans);
  font-size: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0b;
    --surface: #141416;
    --surface-2: #1d1d20;
    --ink: #fafafa;
    --ink-2: #d4d4d8;
    --muted: #8b8b94;
    --border: #27272a;
    --border-strong: #3f3f46;
    --ring: rgb(161 161 170 / 0.35);
    --primary: #fafafa;
    --primary-ink: #18181b;

    --live: #60a5fa;
    --live-soft: rgb(96 165 250 / 0.12);
    --ok: #4ade80;
    --ok-soft: rgb(74 222 128 / 0.1);
    --warn: #fbbf24;
    --warn-soft: rgb(251 191 36 / 0.1);
    --bad: #f87171;
    --bad-ink: #fca5a5;
    --bad-soft: rgb(248 113 113 / 0.1);
    --chart: #3b82f6;

    --r-buy: #22c55e;   --r-buy-soft: rgb(34 197 94 / 0.16);    --r-buy-ink: #86efac;
    --r-over: #4ade80;  --r-over-soft: rgb(74 222 128 / 0.09);  --r-over-ink: #bbf7d0;
    --r-hold: #71717a;  --r-hold-soft: rgb(161 161 170 / 0.12); --r-hold-ink: #d4d4d8;
    --r-under: #f87171; --r-under-soft: rgb(248 113 113 / 0.09); --r-under-ink: #fecaca;
    --r-sell: #ef4444;  --r-sell-soft: rgb(239 68 68 / 0.16);   --r-sell-ink: #fca5a5;

    --shadow-card: 0 0 0 1px rgb(255 255 255 / 0.07);
    --shadow-pop: 0 0 0 1px rgb(255 255 255 / 0.09), 0 12px 32px -4px rgb(0 0 0 / 0.5);
    color-scheme: dark;
  }
}

/* --- Base ------------------------------------------------------------------ */

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.5; }
a { color: inherit; text-decoration: none; }
p, li { text-wrap: pretty; }
h1, h2, h3 { text-wrap: balance; color: var(--ink); }
h1 { font-size: 1.6rem; font-weight: 600; letter-spacing: -0.025em; line-height: 1.2; margin: 0; }
h2 { font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
h3 { font-size: 0.95rem; font-weight: 600; margin: 0; }
code, pre, textarea.mono { font-family: var(--mono); font-size: 0.86em; }
:focus-visible { outline: 2px solid var(--live); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: 0.857rem; }
.nowrap { white-space: nowrap; }
.num, .tnum { font-variant-numeric: tabular-nums; }
.link { color: var(--ink); text-decoration: underline; text-decoration-color: var(--border-strong);
        text-underline-offset: 3px; transition: text-decoration-color 150ms ease; }
.link:hover { text-decoration-color: currentColor; }
.icon { width: 16px; height: 16px; flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* --- Header ---------------------------------------------------------------- */

.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 85%, transparent);
       backdrop-filter: saturate(1.6) blur(10px); -webkit-backdrop-filter: saturate(1.6) blur(10px);
       border-bottom: 1px solid var(--border); }
.top-inner { max-width: 1200px; margin: 0 auto; padding: 0 24px; height: 56px;
             display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -0.01em; }
.brand-logo { width: 24px; height: 25px; flex: none; color: var(--ink); }
.nav { display: flex; gap: 2px; }
.nav a { position: relative; color: var(--muted); padding: 6px 12px; border-radius: 8px; font-weight: 500;
         transition: color 150ms ease, background-color 150ms ease; }
.nav a:hover { color: var(--ink); background: var(--surface-2); }
.nav a.on { color: var(--ink); background: var(--surface-2); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.live-pill { display: inline-flex; align-items: center; gap: 8px; height: 28px; padding: 0 10px 0 9px;
             border-radius: 999px; background: var(--live-soft); color: var(--live); font-weight: 500; font-size: 0.857rem;
             transition: filter 150ms ease; }
.live-pill:hover { filter: brightness(0.97); }
.logout { color: var(--muted); font-size: 0.857rem; padding: 6px 8px; border-radius: 6px;
          transition: color 150ms ease; }
.logout:hover { color: var(--ink); }

main { max-width: 1200px; margin: 0 auto; padding: 32px 24px 64px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px;
             margin-bottom: 24px; flex-wrap: wrap; }
.page-head p { margin: 6px 0 0; color: var(--muted); max-width: 68ch; }
.crumb { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 0.857rem;
         margin-bottom: 8px; transition: color 150ms ease; }
.crumb:hover { color: var(--ink); }
.meta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; color: var(--muted); font-size: 0.857rem; }
.meta span { display: inline-flex; align-items: center; gap: 6px; }
.meta b { color: var(--ink-2); font-weight: 500; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* --- Surfaces -------------------------------------------------------------- */

.card { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-card); padding: 20px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head p { margin: 2px 0 0; color: var(--muted); font-size: 0.857rem; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .card-head { padding: 16px 20px 0; margin-bottom: 8px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
.grid.halves { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid > .card { margin-bottom: 0; }
.stack-gap { margin-bottom: 16px; }
@media (max-width: 900px) { .grid.two, .grid.halves { grid-template-columns: minmax(0, 1fr); } .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .grid.four { grid-template-columns: minmax(0, 1fr); } }
.grid.align-start { align-items: start; }

/* --- Stats ----------------------------------------------------------------- */

.stat { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-card); padding: 16px 18px; min-width: 0; }
.stat .label { color: var(--muted); font-size: 0.857rem; font-weight: 500; }
.stat .value { font-size: 1.6rem; font-weight: 600; letter-spacing: -0.025em; margin-top: 4px; line-height: 1.2; }
.stat .sub { color: var(--muted); font-size: 0.857rem; margin-top: 4px; }

/* --- Tables ---------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 0.857rem; font-weight: 500; color: var(--muted); white-space: nowrap; }
th:first-child, td:first-child { padding-left: 20px; }
th:last-child, td:last-child { padding-right: 20px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background-color 120ms ease; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
tr.total td { font-weight: 600; border-top: 1px solid var(--border); }
tr[data-href] { cursor: pointer; }
.card:not(.flush) table th:first-child, .card:not(.flush) table td:first-child { padding-left: 0; }
.card:not(.flush) table th:last-child, .card:not(.flush) table td:last-child { padding-right: 0; }
.share { display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.share-bar { width: 64px; height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.share-bar i { display: block; height: 100%; border-radius: 999px; background: var(--chart); }

/* --- Badges ---------------------------------------------------------------- */

.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 6px;
         font-size: 0.786rem; font-weight: 500; white-space: nowrap; background: var(--surface-2); color: var(--ink-2); }
.badge.edited, .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.active { background: var(--ok-soft); color: var(--ok); }
.badge.outline { background: transparent; box-shadow: inset 0 0 0 1px var(--border); color: var(--muted); }

.status { display: inline-flex; align-items: center; gap: 7px; font-size: 0.857rem; font-weight: 500; color: var(--ink-2); white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--r-hold); flex: none; }
.status.done::before { background: var(--ok); }
.status.running::before, .status.stopping::before { background: var(--live); animation: pulse 1.6s ease-out infinite; }
.status.running { color: var(--live); }
.status.queued::before { background: transparent; box-shadow: inset 0 0 0 1.5px var(--muted); }
.status.failed { color: var(--bad-ink); }
.status.failed::before { background: var(--bad); }
.status.stopped::before, .status.stopping::before { background: var(--muted); }
.status.lg { height: 28px; padding: 0 12px; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow-card); }

.rating { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px;
          font-size: 0.786rem; font-weight: 600; white-space: nowrap; background: var(--r-hold-soft); color: var(--r-hold-ink); }
.rating.buy { background: var(--r-buy-soft); color: var(--r-buy-ink); }
.rating.overweight { background: var(--r-over-soft); color: var(--r-over-ink); }
.rating.underweight { background: var(--r-under-soft); color: var(--r-under-ink); }
.rating.sell { background: var(--r-sell-soft); color: var(--r-sell-ink); }

.chip { display: inline-block; vertical-align: middle; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
        height: 22px; line-height: 22px; font-size: 0.786rem; padding: 0 7px; border-radius: 6px;
        background: var(--surface-2); color: var(--muted); margin: 2px 4px 2px 0; white-space: nowrap;
        transition: color 150ms ease, background-color 150ms ease; }
a.chip:hover { color: var(--ink); background: var(--border); }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 55%, transparent); }
  70%, 100% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--live) 0%, transparent); }
}

/* --- Forms ----------------------------------------------------------------- */

form.stack { display: grid; gap: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > label { flex: 1 1 160px; }
label, .label-text { display: grid; gap: 6px; font-size: 0.857rem; font-weight: 500; color: var(--ink-2); }
.hint { font-weight: 400; color: var(--muted); }
input[type=text], input[type=password], input[type=date], input[type=number], select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 8px; height: 36px; padding: 0 12px; width: 100%; min-width: 0;
  transition: border-color 150ms ease, box-shadow 150ms ease; }
textarea { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.55; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.8; }
input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: none; border-color: var(--muted); box-shadow: 0 0 0 3px var(--ring); }
input.ticker { height: 44px; font-size: 1.15rem; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; }
input.ticker::placeholder { text-transform: none; font-weight: 400; letter-spacing: 0; }
input.compact { width: 96px; height: 32px; text-align: right; font-variant-numeric: tabular-nums; }

/* Analysts as toggles: a real checkbox, drawn as a pill. */
.toggles { display: flex; flex-wrap: wrap; gap: 8px; }
.toggle { position: relative; display: inline-flex; }
.toggle input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.toggle span { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px 0 12px; border-radius: 8px;
               font-weight: 500; color: var(--muted); background: transparent; box-shadow: inset 0 0 0 1px var(--border);
               transition: color 150ms ease, background-color 150ms ease, box-shadow 150ms ease, transform 160ms var(--ease-out); }
.toggle span::before { content: ""; width: 14px; height: 14px; border-radius: 4px; box-shadow: inset 0 0 0 1.5px var(--border-strong);
                       background: center / 10px no-repeat; transition: background-color 150ms ease, box-shadow 150ms ease; }
/* Checked: a soft fill and a hairline; the little checkbox carries the state, not a loud border. */
.toggle input:checked + span { color: var(--ink); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); }
.toggle input:not(:checked) + span:hover { color: var(--ink-2); background: color-mix(in srgb, var(--surface-2) 50%, transparent); }
.toggle input:checked + span::before { background-color: var(--primary); box-shadow: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 8.5l3 3 6-7'/%3E%3C/svg%3E"); }
@media (prefers-color-scheme: dark) {
  .toggle input:checked + span::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2318181b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 8.5l3 3 6-7'/%3E%3C/svg%3E"); }
}
.toggle input:focus-visible + span { box-shadow: inset 0 0 0 1px var(--border-strong), 0 0 0 3px var(--ring); }
.toggle input:active + span { transform: scale(0.96); }

.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink-2); cursor: pointer; height: 36px; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; }

details.disclosure > summary { display: block; cursor: pointer; color: var(--muted);
                               font-size: 0.857rem; font-weight: 500; list-style: none; padding: 4px 0; transition: color 150ms ease; }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary:hover { color: var(--ink); }
details.disclosure > summary .icon { vertical-align: -3px; margin-right: 4px; transition: transform 200ms var(--ease-out); }
details.disclosure[open] > summary .icon { transform: rotate(90deg); }
details.disclosure[open] > summary { margin-bottom: 12px; }
.summary-value { color: var(--ink-2); font-weight: 400; }

/* --- Buttons --------------------------------------------------------------- */

button, .button { font: inherit; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 16px; border-radius: 8px; border: 0; cursor: pointer; white-space: nowrap;
  background: var(--primary); color: var(--primary-ink);
  transition: transform 160ms var(--ease-out), opacity 150ms ease, background-color 150ms ease, box-shadow 150ms ease; }
button:hover, .button:hover { opacity: 0.9; }
button:active, .button:active { transform: scale(0.96); }
button.lg { height: 44px; padding: 0 20px; }
button.outline, .button.outline { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--border-strong); }
button.outline:hover, .button.outline:hover { opacity: 1; background: var(--surface-2); }
button.ghost, .button.ghost { background: transparent; color: var(--muted); }
button.ghost:hover, .button.ghost:hover { opacity: 1; background: var(--surface-2); color: var(--ink); }
button.danger { background: var(--surface); color: var(--bad-ink); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bad) 35%, transparent); }
button.danger:hover { opacity: 1; background: var(--bad-soft); }
button.sm, .button.sm { height: 32px; padding: 0 12px; font-size: 0.857rem; }
button:disabled { opacity: 0.45; cursor: default; transform: none; }
form.inline { display: inline; }

/* --- Notices --------------------------------------------------------------- */

.notice { display: flex; gap: 10px; align-items: flex-start; border-radius: 10px; padding: 12px 14px; margin-bottom: 16px;
          font-size: 0.929rem; background: var(--surface-2); color: var(--ink-2); }
.notice .icon { margin-top: 2px; }
.notice a { text-decoration: underline; text-underline-offset: 3px; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.bad { background: var(--bad-soft); color: var(--bad-ink); }
.notice.info { background: var(--live-soft); color: var(--ink-2); }
.notice.stopped { background: var(--surface-2); color: var(--ink-2); }
p.warn, p.ok { margin: 6px 0; padding: 8px 12px; border-radius: 8px; font-size: 0.857rem; }
p.warn { background: var(--warn-soft); color: var(--warn); }
p.ok { color: var(--ok); background: var(--ok-soft); }

.empty { color: var(--muted); padding: 32px 16px; text-align: center; }
.empty strong { display: block; color: var(--ink); font-weight: 500; margin-bottom: 4px; }

/* --- Run summary ------------------------------------------------------------ */

.summary { display: grid; grid-template-columns: minmax(0, 1.6fr) repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
@media (max-width: 900px) { .summary { grid-template-columns: repeat(3, minmax(0, 1fr)); } .summary > :first-child { grid-column: 1 / -1; } }
@media (max-width: 520px) { .summary { grid-template-columns: minmax(0, 1fr); } }

.decision .value { font-size: 2.6rem; letter-spacing: -0.035em; line-height: 1.1; margin-top: 2px; }
.decision .value.buy { color: var(--r-buy-ink); }
.decision .value.sell { color: var(--r-sell-ink); }
.scale { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 3px; margin-top: 14px; }
.scale div { display: grid; gap: 6px; font-size: 0.75rem; color: var(--muted); }
.scale div::before { content: ""; height: 6px; border-radius: 2px; background: var(--surface-2); }
.scale div:first-child::before { border-radius: 999px 2px 2px 999px; }
.scale div:last-child::before { border-radius: 2px 999px 999px 2px; text-align: right; }
.scale div:last-child { text-align: right; }
.scale div:nth-child(3) { text-align: center; }
.scale div.on { color: var(--ink); font-weight: 600; }
.scale div.on.buy::before { background: var(--r-buy); }
.scale div.on.overweight::before { background: var(--r-over); }
.scale div.on.hold::before { background: var(--r-hold); }
.scale div.on.underweight::before { background: var(--r-under); }
.scale div.on.sell::before { background: var(--r-sell); }

.progress { height: 6px; border-radius: 999px; background: var(--live-soft); overflow: hidden; margin-top: 12px; }
.progress i { display: block; height: 100%; width: 100%; background: var(--live); border-radius: 999px;
              transform-origin: left; transform: scaleX(var(--p, 0)); transition: transform 500ms var(--ease-out); }
.progress.done { background: var(--surface-2); }
.progress.done i { background: var(--ok); }

/* --- Pipeline --------------------------------------------------------------- */

.pipeline { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; }
.stage { padding-right: 12px; min-width: 0; }
.stage:last-child { padding-right: 0; }
.stage-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.stage-mark { width: 22px; height: 22px; border-radius: 50%; flex: none; display: grid; place-items: center;
              background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--border-strong); color: var(--muted);
              font-size: 0.714rem; font-weight: 600; transition: background-color 300ms ease, box-shadow 300ms ease, color 300ms ease; }
.stage-name { font-weight: 600; font-size: 0.929rem; white-space: nowrap; }
.stage-count { color: var(--muted); font-size: 0.786rem; font-variant-numeric: tabular-nums; }
/* The connector to the next stage: a gray track that fills green once this stage is done. */
.stage-line { flex: 1; min-width: 12px; height: 1.5px; border-radius: 1px; background: var(--border); overflow: hidden; }
.stage-line::before { content: ""; display: block; height: 100%; background: var(--r-buy); transform-origin: left; transform: scaleX(0);
                      transition: transform 600ms var(--ease-out); }
.stage[data-state="done"] .stage-line::before { transform: scaleX(1); }
.stage[data-state="active"] .stage-mark { box-shadow: inset 0 0 0 1.5px var(--live); color: var(--live); background: var(--live-soft); }
.stage[data-state="done"] .stage-mark { background: var(--r-buy); box-shadow: none; color: var(--surface); }
.stage-mark .icon { width: 12px; height: 12px; stroke-width: 3; display: none; }
.stage[data-state="done"] .stage-mark .icon { display: block; }
.stage[data-state="done"] .stage-mark .n { display: none; }

.prompt-versions li { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; padding: 8px 0; align-items: baseline; }
.prompt-versions .pv-name { font-weight: 500; color: var(--ink-2); font-size: 0.857rem; }
@media (max-width: 520px) { .prompt-versions li { grid-template-columns: 1fr; gap: 2px; } }

.agents { list-style: none; margin: 0; padding: 0 0 0 4px; display: grid; gap: 2px; }
.agent a, .agent > span { display: flex; align-items: center; gap: 10px; min-height: 32px; padding: 4px 8px; margin-left: -8px;
                          border-radius: 8px; color: var(--ink-2); font-weight: 500; transition: background-color 150ms ease, color 150ms ease; }
.agent a:hover { background: var(--surface-2); color: var(--ink); }
.agent .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent .state-text { margin-left: auto; font-size: 0.75rem; font-weight: 500; color: var(--muted); white-space: nowrap; }
.agent[data-state="waiting"] a, .agent[data-state="waiting"] > span { color: var(--muted); }
.agent[data-state="skipped"] a, .agent[data-state="skipped"] > span { color: var(--muted); }
.agent[data-state="working"] .state-text { color: var(--live); }

/* The state dot: an empty ring, a pulsing blue dot, or a green check. Both icons stay
   in the DOM and cross-fade, so the change reads as one mark turning into another. */
.dot { position: relative; width: 16px; height: 16px; flex: none; display: grid; place-items: center; }
.dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--border-strong);
               transition: opacity 200ms var(--ease-icon), transform 200ms var(--ease-icon), background-color 200ms ease, box-shadow 200ms ease; }
.dot svg { position: absolute; inset: 0; width: 16px; height: 16px; color: var(--ok); opacity: 0; transform: scale(0.25); filter: blur(4px);
           transition: opacity 300ms var(--ease-icon), transform 300ms var(--ease-icon), filter 300ms var(--ease-icon); }
.agent[data-state="working"] .dot::before { background: var(--live); box-shadow: none; animation: pulse 1.6s ease-out infinite; }
.agent[data-state="reported"] .dot::before { opacity: 0; transform: scale(0.25); }
.agent[data-state="reported"] .dot svg { opacity: 1; transform: scale(1); filter: blur(0); }
.agent[data-state="skipped"] .dot::before { box-shadow: inset 0 0 0 1.5px var(--border); }

@media (max-width: 900px) {
  .pipeline { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .stage { padding-right: 0; padding-left: 0; }
  .stage-line { display: none; }
  .stage-head { margin-bottom: 6px; }
  .agents { padding-left: 32px; }
}

/* --- Live -------------------------------------------------------------------- */

.log { height: 420px; overflow-y: auto; font-size: 0.8rem; font-family: var(--mono); display: grid; align-content: start; gap: 1px;
       margin: 0 -8px; padding: 0 8px; overscroll-behavior: contain; }
.log .entry { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--border);
              white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink-2); }
.log .entry:last-child { border-bottom: none; }
.log .kind { color: var(--muted); font-size: 0.7rem; padding-top: 2px; text-transform: lowercase; }
.log .entry.tool .kind { color: var(--live); }
.log .entry.usage { color: var(--muted); }
.log .entry.data .body { color: var(--muted); }
.log .entry.long { cursor: pointer; }
.log .entry.long .body { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; overflow: hidden; }
.log .entry.long.open .body { display: block; }
.log .entry.bad .body { color: var(--bad-ink); }
.log .placeholder { font-family: var(--sans); color: var(--muted); padding: 8px 0; }
.live-sections { display: grid; gap: 8px; max-height: 420px; overflow-y: auto; overscroll-behavior: contain; }
.live-sections details { border-radius: 8px; background: var(--surface-2); padding: 10px 12px; }
.live-sections summary { cursor: pointer; font-weight: 500; display: flex; align-items: center; gap: 8px; list-style: none; }
.live-sections summary::-webkit-details-marker { display: none; }
.live-sections summary .icon { color: var(--ok); }
.live-sections .markdown { margin-top: 10px; font-size: 0.9rem; }
.live-sections details { animation: rise 300ms var(--ease-out); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

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

.report { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 40px; align-items: start; }
.toc { position: sticky; top: 80px; display: grid; gap: 14px; font-size: 0.857rem; }
.toc-group { display: grid; gap: 1px; }
.toc-title { color: var(--muted); font-weight: 500; font-size: 0.786rem; padding: 0 8px 4px; }
.toc a { padding: 4px 8px; border-radius: 6px; color: var(--ink-2); transition: background-color 150ms ease, color 150ms ease; }
.toc a:hover { background: var(--surface-2); color: var(--ink); }
.toc a.on { background: var(--surface-2); color: var(--ink); font-weight: 500; }
.report-body { min-width: 0; max-width: 76ch; }
.part { margin-bottom: 8px; }
.part-head { font-size: 1.15rem; font-weight: 600; letter-spacing: -0.015em;
             padding: 24px 0 4px; border-bottom: 1px solid var(--border); }
.part:first-child .part-head { padding-top: 0; }
.section { padding: 20px 0; border-bottom: 1px solid var(--border); scroll-margin-top: 80px; }
.part .section:last-child { border-bottom: none; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
@media (max-width: 900px) { .report { grid-template-columns: minmax(0, 1fr); } .toc { display: none; } }

.markdown { overflow-wrap: anywhere; color: var(--ink-2); line-height: 1.65; }
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4 { color: var(--ink); font-size: 1rem; margin: 1.4em 0 0.5em; letter-spacing: -0.01em; }
.markdown h1 { font-size: 1.15rem; }
.markdown p, .markdown ul, .markdown ol { margin: 0.7em 0; }
.markdown ul, .markdown ol { padding-left: 1.3em; }
.markdown li { margin: 0.25em 0; }
.markdown strong { color: var(--ink); font-weight: 600; }
.markdown a { text-decoration: underline; text-underline-offset: 3px; }
.markdown table { font-size: 0.857rem; margin: 12px 0; display: block; overflow-x: auto; }
.markdown th, .markdown td { padding: 6px 10px; border-bottom: 1px solid var(--border); }
.markdown th:first-child, .markdown td:first-child { padding-left: 0; }
.markdown code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.markdown pre { background: var(--surface-2); padding: 12px; border-radius: 8px; overflow-x: auto; }
.markdown pre code { background: none; padding: 0; }
.markdown blockquote { margin: 0.8em 0; padding-left: 14px; border-left: 2px solid var(--border-strong); color: var(--muted); }
.markdown hr { border: 0; border-top: 1px solid var(--border); margin: 1.4em 0; }

/* --- Spend chart ------------------------------------------------------------- */

.chart { position: relative; }
.chart-plot { position: relative; height: 180px; display: flex; align-items: flex-end; gap: 2px;
              border-bottom: 1px solid var(--border); }
.chart-grid { position: absolute; left: 0; right: 0; top: 0; border-top: 1px solid var(--border); }
.chart-grid span { position: absolute; right: 0; top: -20px; font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { position: relative; flex: 1 1 0; height: 100%; display: flex; align-items: flex-end; justify-content: center; }
.bar i { display: block; width: 100%; max-width: 24px; min-height: 0; background: var(--chart); border-radius: 4px 4px 0 0;
         transition: opacity 150ms ease; }
.bar.zero i { height: 0 !important; }
.chart-plot:hover .bar i { opacity: 0.45; }
.chart-plot .bar:hover i, .chart-plot .bar:focus-visible i { opacity: 1; }
.bar .tip { position: absolute; bottom: calc(100% + 6px); left: 50%; z-index: 2; pointer-events: none; white-space: nowrap;
            background: var(--surface); box-shadow: var(--shadow-pop); border-radius: 8px; padding: 6px 10px; font-size: 0.786rem;
            color: var(--ink-2); opacity: 0; transform: translate(-50%, 4px); transition: opacity 125ms ease, transform 125ms var(--ease-out); }
.bar .tip b { display: block; color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.bar:hover .tip, .bar:focus-visible .tip { opacity: 1; transform: translate(-50%, 0); }
.bar:first-child .tip, .bar:nth-child(2) .tip { left: 0; transform: translate(0, 4px); }
.bar:first-child:hover .tip, .bar:nth-child(2):hover .tip { transform: translate(0, 0); }
.bar:last-child .tip, .bar:nth-last-child(2) .tip { left: auto; right: 0; transform: translate(0, 4px); }
.bar:last-child:hover .tip, .bar:nth-last-child(2):hover .tip { transform: translate(0, 0); }
.bar:focus-visible { outline: none; }
.chart-x { display: flex; justify-content: space-between; margin-top: 8px; font-size: 0.75rem; color: var(--muted); }

/* --- Prompts ----------------------------------------------------------------- */

.list { list-style: none; margin: 0; padding: 0; }
.list li { border-top: 1px solid var(--border); }
.list li:first-child { border-top: none; }
.list a { display: flex; align-items: center; gap: 16px; padding: 12px 20px; transition: background-color 120ms ease; }
.list a:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 500; color: var(--ink); }
.list .sub { color: var(--muted); font-size: 0.857rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .icon { color: var(--muted); }

.diff { background: var(--surface-2); border-radius: 8px; padding: 8px 0; overflow-x: auto; font-family: var(--mono); font-size: 0.8rem; }
.diff div { white-space: pre-wrap; overflow-wrap: anywhere; padding: 1px 14px; }
.diff .add { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ink); }
.diff .del { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--ink); }
.diff .hunk { color: var(--muted); padding-top: 6px; }
textarea.editor { min-height: 420px; font-size: 0.82rem; background: var(--surface); }
.save-bar { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.save-bar > label { flex: 1 1 280px; }

/* --- Login ------------------------------------------------------------------- */

.login-body { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login { width: 100%; max-width: 360px; padding: 0; }
.login .brand { justify-content: center; margin-bottom: 24px; }
.login-card { padding: 28px; display: grid; gap: 16px; box-shadow: var(--shadow-pop); }
.login-card h1 { font-size: 1.25rem; }
.login-card .notice { margin: 0; }
.login-card button { width: 100%; }

/* --- Guide ------------------------------------------------------------------- */
/* The how-to page, for people using the app. Its pictures are the app's own
   components, so they always match the real pages, in both themes. */

.guide { max-width: 880px; margin: 0 auto; }
.guide-hero { text-align: center; padding: 16px 0 40px; }
.guide-hero h1 { font-size: 2.3rem; letter-spacing: -0.035em; }
.guide-hero p { margin: 12px auto 0; color: var(--muted); font-size: 1.05rem; max-width: 52ch; }
.guide-hero .brand-logo { width: 40px; height: 42px; margin-bottom: 16px; }
.jump { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.jump a { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px 0 6px; border-radius: 999px; background: var(--surface);
          box-shadow: var(--shadow-card); font-weight: 500; font-size: 0.857rem; color: var(--ink-2); transition: transform 160ms var(--ease-out), color 150ms ease; }
.jump a:hover { color: var(--ink); }
.jump a:active { transform: scale(0.96); }
.jump a b { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-size: 0.75rem; }

.g-section { padding: 48px 0; border-top: 1px solid var(--border); scroll-margin-top: 64px; }
.g-head { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 20px; }
.g-n { width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 600;
       background: var(--primary); color: var(--primary-ink); }
.g-head h2 { font-size: 1.5rem; letter-spacing: -0.025em; }
.g-head p { margin: 4px 0 0; color: var(--muted); font-size: 1rem; max-width: 60ch; }
.g-note { color: var(--muted); font-size: 0.929rem; margin: 14px 0 0; text-align: center; }

.window { border-radius: 14px; background: var(--bg); box-shadow: var(--shadow-pop); overflow: hidden; }
.window-bar { display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; background: var(--surface); border-bottom: 1px solid var(--border); }
.window-bar i { width: 10px; height: 10px; border-radius: 50%; background: var(--border-strong); }
.window-bar span { margin: 0 auto; padding: 0 12px; height: 22px; line-height: 22px; border-radius: 6px; background: var(--surface-2);
                   color: var(--muted); font-size: 0.75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 70%; }
.window-bar .badge { margin-left: -6px; }
.window-body { padding: 20px; }
.window-body .card, .window-body .summary { margin-bottom: 0; }
.window-body > * + * { margin-top: 16px; }

/* Numbered callouts on a picture. */
.tips { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 20px; }
.tip { display: flex; gap: 10px; padding: 14px; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-card); font-size: 0.9rem; color: var(--ink-2); }
.tip b { color: var(--ink); display: block; font-weight: 600; margin-bottom: 2px; }
.tip .icon { color: var(--muted); margin-top: 2px; }
@media (max-width: 760px) { .tips { grid-template-columns: minmax(0, 1fr); } }

/* The sample run: a play button and a finished state that fades in. */
.play-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.play-bar .muted { font-size: 0.857rem; }
.reveal { transition: opacity 400ms var(--ease-out), transform 400ms var(--ease-out); }
.reveal[hidden] { display: block; opacity: 0; transform: translateY(6px); pointer-events: none; height: 0; overflow: hidden; margin: 0 !important; }

/* The rating explorer: the decision scale, made of buttons. */
.picker { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.picker button { height: auto; display: grid; justify-content: stretch; text-align: center; gap: 8px; padding: 10px 6px 8px; border-radius: 10px; background: var(--surface); color: var(--muted);
                 box-shadow: var(--shadow-card); font-size: 0.857rem; font-weight: 500; }
.picker button::before { content: ""; height: 6px; border-radius: 999px; background: var(--surface-2); transition: background-color 200ms ease; }
.picker button:hover { opacity: 1; color: var(--ink); }
.picker button[aria-pressed="true"] { color: var(--ink); font-weight: 600; box-shadow: inset 0 0 0 1px var(--border-strong), var(--shadow-card); }
.picker button.buy[aria-pressed="true"]::before { background: var(--r-buy); }
.picker button.overweight[aria-pressed="true"]::before { background: var(--r-over); }
.picker button.hold[aria-pressed="true"]::before { background: var(--r-hold); }
.picker button.underweight[aria-pressed="true"]::before { background: var(--r-under); }
.picker button.sell[aria-pressed="true"]::before { background: var(--r-sell); }
.meaning { margin-top: 16px; padding: 18px 20px; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-card); min-height: 92px; }
.meaning .rating { height: 26px; font-size: 0.857rem; padding: 0 10px; }
.meaning p { margin: 10px 0 0; color: var(--ink-2); font-size: 1rem; }

.how { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.how > div { display: grid; gap: 12px; align-content: start; }
.how .window-body { padding: 14px; min-height: 120px; display: grid; align-content: center; }
.how h3 { font-size: 0.95rem; }
.how p { margin: 2px 0 0; color: var(--muted); font-size: 0.857rem; }
@media (max-width: 760px) { .how { grid-template-columns: minmax(0, 1fr); } }

/* A team to pick from: tap a card to read about it. */
.team { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.team button { height: auto; display: flex; align-items: center; justify-content: flex-start; gap: 12px; padding: 12px 14px; border-radius: 12px; text-align: left;
               background: var(--surface); color: var(--ink-2); box-shadow: var(--shadow-card); font-weight: 500; }
.team button:hover { opacity: 1; color: var(--ink); }
.team button[aria-pressed="true"] { color: var(--ink); box-shadow: inset 0 0 0 1px var(--border-strong), var(--shadow-card); }
.team .face { width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--surface-2);
              font-size: 0.8rem; font-weight: 600; color: var(--ink); transition: background-color 200ms ease, color 200ms ease; }
.team button[aria-pressed="true"] .face { background: var(--primary); color: var(--primary-ink); }
.team small { display: block; color: var(--muted); font-weight: 400; font-size: 0.786rem; }
@media (max-width: 760px) { .team { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* A list that grows as the sample fund advances. */
.ledger { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; }
.ledger li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); font-size: 0.9rem; animation: rise 300ms var(--ease-out); }
.ledger li:first-child { border-top: 0; }
.ledger .grow { flex: 1; color: var(--muted); }

.faq details { border-bottom: 1px solid var(--border); padding: 14px 0; }
.faq summary { cursor: pointer; font-weight: 500; color: var(--ink); list-style: none; display: flex; gap: 10px; align-items: center; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary .icon { color: var(--muted); transition: transform 200ms var(--ease-out); }
.faq details[open] summary .icon { transform: rotate(90deg); }
.faq details p { margin: 8px 0 0 26px; color: var(--ink-2); max-width: 64ch; }

@media (max-width: 720px) {
  .top-inner { padding: 0 16px; gap: 12px; height: auto; min-height: 56px; flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
  .nav { order: 3; width: 100%; overflow-x: auto; margin: 0 -4px; }
  .brand-text, .live-extra { display: none; }
  main { padding: 24px 16px 48px; }
  .card { padding: 16px; }
  th:first-child, td:first-child { padding-left: 16px; }
  th:last-child, td:last-child { padding-right: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
  .progress i, .stage-line::before, .dot svg, .dot::before { transition-property: opacity; }
}
