/* quantpicker web layer.
 *
 * Colour is assigned by the job it does, not by taste:
 *   - score            magnitude          -> sequential, one hue (blue), light->dark
 *   - signal weight    polarity           -> diverging (blue <-> red) on a neutral zero
 *   - regime, heat     state              -> status palette, always with an icon AND a
 *                                            text label, because status-green and
 *                                            diverging-red are indistinguishable under
 *                                            deuteranopia (measured dE 2.5) and hue
 *                                            must therefore never carry the meaning
 *   - market, flags    identity           -> no colour at all; the label already says it
 *
 * Dark values are stepped for the dark surface, not flipped.
 */

:root {
  color-scheme: light;

  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);

  /* sequential: score magnitude. Track is a light step of the same ramp. */
  --seq-fill: #2a78d6;
  --seq-track: #cde2fb;

  /* diverging: signal contribution, centred on a neutral zero. */
  --pos: #2a78d6;
  --neg: #e34948;
  --zero: #f0efec;

  /* categorical: two series on one chart (portfolio vs benchmark), slots 1-2
   * of the validated order. */
  --series-1: #2a78d6;
  --series-2: #eb6834;

  /* status: fixed, never themed. */
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-text: #006300;

  --radius: 10px;
  --gap: 16px;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --seq-fill: #3987e5;
    --seq-track: #184f95;
    --pos: #3987e5;
    --neg: #e66767;
    --zero: #383835;
    --series-1: #3987e5;
    --series-2: #d95926;
    --good-text: #0ca30c;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --seq-fill: #3987e5;
  --seq-track: #184f95;
  --pos: #3987e5;
  --neg: #e66767;
  --zero: #383835;
  --series-1: #3987e5;
  --series-2: #d95926;
  --good-text: #0ca30c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  /* Malgun Gothic is on every Windows install and Apple SD Gothic Neo on every
   * Mac, so Korean renders in a proper Hangul face with no web-font download. */
  font: 14px/1.55 system-ui, -apple-system, "Segoe UI", "Malgun Gothic", "맑은 고딕",
    "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}

/* Korean breaks between words, not inside them. */
:root[lang="ko"] body {
  word-break: keep-all;
  overflow-wrap: anywhere;
  line-height: 1.65;
}

a {
  color: inherit;
}

/* ---------------------------------------------------------------- banners */
.banner {
  margin: 18px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--axis);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13px;
}

.banner.stale {
  border-left-color: var(--warning);
  color: var(--ink);
}

.banner .icon {
  font-weight: 700;
  margin-right: 6px;
}

/* ---------------------------------------------------------------- filter row */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 20px 0 4px;
  font-size: 13px;
  color: var(--ink-2);
}

.filters select,
.filters button {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
}

.filters button {
  cursor: pointer;
}

/* ---------------------------------------------------------------- cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--gap);
  margin-top: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.card h3 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}

.tile-label {
  font-size: 12px;
  color: var(--ink-2);
}

.tile-value {
  font-size: 26px;
  font-weight: 600;
  line-height: 1.15;
  margin-top: 2px;
  /* Proportional figures: tabular-nums makes a big standalone number look loose. */
}

.tile-note {
  margin-top: 6px;
  font-size: 12px;
  color: var(--ink-2);
}

/* Stacked label/value pairs inside a card need air between the groups, but
 * not above the first one. */
.tile-label + .tile-note {
  margin-top: 2px;
}

.tile-note + .tile-label {
  margin-top: 14px;
}

.score-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.notes {
  margin: 10px 0 0;
  padding-left: 18px;
  font-size: 12px;
  color: var(--ink-2);
}

/* ---------------------------------------------------------------- status */
.state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}

.state .icon {
  font-size: 11px;
  flex: 0 0 auto;
}

/* A wrapping verdict must keep its icon on the first line, not centred
 * against the whole block. */
.tile-note .state {
  align-items: baseline;
}

.state.ok {
  color: var(--good-text);
}

.state.warn {
  color: var(--ink);
}

.state.bad {
  color: var(--critical);
}

.state.neutral {
  color: var(--ink-2);
}

/* ---------------------------------------------------------------- meters */
.meter {
  margin-top: 10px;
}

.meter-track {
  position: relative;
  height: 8px;
  border-radius: 4px;
  /* Neutral track: the fill carries severity from the status palette, so a
   * same-hue track would have to invent status ramp steps that do not exist. */
  background: var(--zero);
  overflow: visible;
}

.meter-fill {
  height: 100%;
  border-radius: 0 4px 4px 0; /* square at the baseline, rounded data-end */
  background: var(--muted);
}

.meter-fill.ok {
  background: var(--good);
}

.meter-fill.warn {
  background: var(--warning);
}

.meter-fill.bad {
  background: var(--critical);
}

.meter-limit {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 1px;
  background: var(--axis);
}

/* The budget caption sits exactly under its tick rather than wherever
 * space-between happens to put it - a limit marker that is 28px off its label
 * is a limit marker you cannot read. */
.meter-scale .at-limit {
  position: absolute;
  transform: translateX(-50%);
}

.meter-scale {
  position: relative;
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* score meter, inline in a table cell */
/* The meter only - the picks table's score cell carries the same class name
 * and must stay a table cell, or it stops stretching to the row's height. */
div.score {
  display: flex;
  align-items: center;
  gap: 8px;
}

.score-value {
  min-width: 34px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.score-track {
  display: inline-block;
  width: 64px;
  height: 6px;
  border-radius: 3px;
  background: var(--seq-track);
}

.score-fill {
  display: block;
  height: 100%;
  border-radius: 0 3px 3px 0;
  background: var(--seq-fill);
}

/* ---------------------------------------------------------------- tables */
.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 34px 0 8px;
}

.section-head h2 {
  margin: 0;
  font-size: 17px;
}

.section-head .meta {
  font-size: 12px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

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

/* A table right after a row of cards (the Portfolio page's totals) gets the
 * same gap the cards keep between themselves. */
.cards + .table-scroll {
  margin-top: var(--gap);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  position: sticky;
  top: 0;
  background: var(--surface);
  text-align: right;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 10px 10px 8px;
  border-bottom: 1px solid var(--grid);
  white-space: nowrap;
}

thead th.left,
tbody td.left {
  text-align: left;
}

tbody td {
  padding: 9px 10px;
  text-align: right;
  border-bottom: 1px solid var(--grid);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: color-mix(in srgb, var(--seq-fill) 5%, transparent);
}

td.ticker a {
  font-weight: 600;
  text-decoration: none;
}

td.ticker a:hover {
  text-decoration: underline;
}

td .name {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--ink-2);
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
}

td.why {
  /* Prose, so left-aligned: the numeric right-alignment of every other cell
   * would leave a paragraph ragged on the edge the eye reads from. */
  text-align: left;
  white-space: normal;
  min-width: 260px;
  color: var(--ink-2);
  font-size: 12px;
}

.chip {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11px;
  color: var(--ink-2);
}

.chip.warn {
  border-color: var(--serious);
  color: var(--ink);
}

/* Two-column share lists inside a card (portfolio mix). */
.mini-table {
  width: 100%;
  margin: 6px 0;
  border-collapse: collapse;
  font-size: 13px;
}

.mini-table td {
  padding: 2px 0;
  text-align: right;
}

.mini-table td.left {
  text-align: left;
}

.flag {
  display: inline-block;
  margin: 1px 4px 1px 0;
  padding: 1px 7px;
  /* A soft rectangle, not a pill: a 3px accent edge on a 999px radius renders
   * as a curved arc and reads as a stray parenthesis. */
  border-radius: 6px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--serious);
  font-size: 11px;
  color: var(--ink-2);
}

.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--ink-2);
}

/* ---------------------------------------------------------------- attribution */
.legend {
  display: flex;
  gap: 16px;
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--ink-2);
}

.legend .key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend .swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.legend .swatch.pos {
  background: var(--pos);
}

.legend .swatch.neg {
  background: var(--neg);
}

.attr-cell {
  width: 260px;
  min-width: 200px;
}

.attr {
  position: relative;
  height: 10px;
}

.attr::before {
  /* the zero line: solid hairline, one step off the surface */
  content: "";
  position: absolute;
  left: 50%;
  top: -3px;
  bottom: -3px;
  width: 1px;
  background: var(--axis);
}

.attr-bar {
  position: absolute;
  top: 0;
  height: 100%;
  min-width: 2px;
}

.attr-bar.pos {
  left: 50%;
  background: var(--pos);
  border-radius: 0 4px 4px 0;
}

.attr-bar.neg {
  background: var(--neg);
  border-radius: 4px 0 0 4px;
}

/* Hover layer: the exact figure is already in the next column, so this
 * supplements rather than gates it. */
.attr[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 5;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
}

/* ---------------------------------------------------------------- plan */
.plan {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 14px;
}

.plan div {
  min-width: 0;
}

.plan dt {
  font-size: 12px;
  color: var(--ink-2);
}

.plan dd {
  margin: 2px 0 0;
  font-size: 17px;
  font-weight: 600;
}

.plan dd .unit {
  font-size: 12px;
  font-weight: 400;
  color: var(--ink-2);
}

/* ---------------------------------------------------------------- footer */
footer {
  margin-top: 48px;
  padding-top: 16px;
  border-top: 1px solid var(--grid);
  font-size: 12px;
  color: var(--ink-2);
}

footer p {
  margin: 0 0 8px;
  max-width: none;
}

footer code {
  font-size: 11px;
}

.back {
  display: inline-block;
  margin: 18px 0 0;
  font-size: 13px;
  color: var(--ink-2);
}

/* ------------------------------------------------- section-head heat meter */
.section-head .heat {
  width: 250px;
  flex: 0 0 auto;
}

.section-head .meter {
  margin-top: 0;
}

pre {
  margin: 10px 0;
  padding: 10px 12px;
  overflow-x: auto;
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.6;
}


/* ================================================================ control panel */
.banner.running {
  display: flex;
  align-items: center;
  gap: 10px;
  border-left-color: var(--seq-fill);
  color: var(--ink);
  text-decoration: none;
}

.spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--seq-track);
  border-top-color: var(--seq-fill);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  flex: 0 0 auto;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
  }
}

.guide,
.group,
.horizon {
  margin-top: 28px;
}

.guide h2,
.group h2,
.horizon h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

.horizon {
  padding-top: 8px;
  border-top: 1px solid var(--grid);
}

.group-note {
  margin-left: 6px;
  font-size: 12px;
  font-weight: 400;
  color: var(--ink-2);
}

.steps {
  margin: 0;
  padding-left: 20px;
  color: var(--ink-2);
}

.steps li {
  margin: 4px 0;
}

.steps strong {
  color: var(--ink);
}

.actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(330px, 100%), 1fr));
  gap: var(--gap);
}

.card.action {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card.action .tile-note {
  margin-top: 0;
}

.action-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.action-head h3 {
  margin: 0;
  font-size: 15px;
  color: var(--ink);
}

.badges {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  padding: 1px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11px;
  color: var(--ink-2);
  white-space: nowrap;
}

.badge.offline {
  color: var(--good-text);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}

.field-label {
  font-weight: 600;
  font-size: 12px;
  color: var(--ink-2);
}

.field-help {
  font-size: 12px;
  color: var(--muted);
}

.field-error {
  font-size: 12px;
  font-weight: 600;
  color: var(--critical);
}

.field.has-error input,
.field.has-error select {
  border-color: var(--critical);
}

.field input[type="number"],
.field input[type="text"] {
  width: 180px;
}

.field input[type="number"],
.field input[type="text"],
.field select {
  font: inherit;
  color: var(--ink);
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  max-width: 100%;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.check.inline {
  font-weight: 400;
}

.check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}

details summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--ink-2);
}

details[open] > summary {
  margin-bottom: 10px;
}

.card.action details {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card.action details .field + .field {
  margin-top: 10px;
}

.expect {
  margin: 0;
  font-size: 12px;
  color: var(--ink-2);
}

.action-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: auto;
}

button,
.button {
  display: inline-block;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--axis);
  border-radius: 8px;
  padding: 7px 14px;
  text-decoration: none;
  cursor: pointer;
}

button.primary,
.button.primary {
  color: #ffffff;
  background: var(--seq-fill);
  border-color: var(--seq-fill);
  font-weight: 600;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button:focus-visible,
.button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--seq-fill);
  outline-offset: 2px;
}

.inline-form {
  margin-top: 12px;
}

code.command {
  flex: 1 1 200px;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 11px;
  color: var(--muted);
}

pre.command-block {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

pre.log {
  max-height: 560px;
  overflow: auto;
  white-space: pre;
  font-size: 12px;
  line-height: 1.45;
}

.toc {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 14px;
  font-size: 13px;
}

/* ---------------------------------------------------------------- charts */
.chart-title {
  margin: 0;
  font-size: 14px;
  color: var(--ink);
}

.chart-sub {
  margin: 4px 0 10px;
  max-width: none;
  font-size: 12px;
  color: var(--ink-2);
}

.legend .swatch.series-1 {
  background: var(--series-1);
}

.legend .swatch.series-2 {
  background: var(--series-2);
}

.chart {
  position: relative;
  max-width: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 4px 0;
}

.chart svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart .grid {
  stroke: var(--grid);
  stroke-width: 1;
}

.chart .baseline {
  stroke: var(--axis);
  stroke-width: 1;
}

.chart .axis-label {
  fill: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.chart .end-label {
  fill: var(--ink-2);
  font-size: 11px;
  font-weight: 600;
}

.chart .line {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart .line.series-1 {
  stroke: var(--series-1);
}

.chart .line.series-2 {
  stroke: var(--series-2);
}

.chart .crosshair {
  display: none;
}

.chart .crosshair.on {
  display: inline;
}

.chart .cross {
  stroke: var(--axis);
  stroke-width: 1;
}

.chart .dot {
  stroke: var(--surface);
  stroke-width: 2;
}

.chart .dot.series-1 {
  fill: var(--series-1);
}

.chart .dot.series-2 {
  fill: var(--series-2);
}

.chart .hit {
  fill: transparent;
  cursor: crosshair;
}

.chart[data-chart="bars"] .hit {
  cursor: default;
}

.chart .bar.pos {
  fill: var(--pos);
}

.chart .bar.neg {
  fill: var(--neg);
}

.chart .hit.active {
  fill: var(--grid);
  fill-opacity: 0.35;
}

.tooltip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink);
  white-space: pre;
  font-variant-numeric: tabular-nums;
}

.tooltip .tip-head {
  font-weight: 600;
}

@media (max-width: 640px) {
  .actions {
    grid-template-columns: 1fr;
  }
}

details.cmd summary {
  font-size: 12px;
  color: var(--muted);
}

details.cmd code {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}

/* ================================================================ app shell
 * A fixed side menu split into the daily routine and setup/management, and a
 * content column. Under 900px the menu becomes an overlay opened by the
 * "Menu" label, which toggles a checkbox - so it works without JavaScript.
 */
:root {
  --sidebar: 236px;
  --accent: var(--seq-fill);
  --accent-soft: color-mix(in srgb, var(--seq-fill) 10%, transparent);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.06);
}

/* Korean convention: rises are red, falls are blue, as in every Korean
 * brokerage app. Applied only to the diverging pair, which is exactly the
 * pair that means "up / for" and "down / against"; status colours keep their
 * icons and words. */
:root[data-updown="kr"] {
  --pos: #d8352f;
  --neg: #2a6fd6;
}

@media (prefers-color-scheme: dark) {
  :root[data-updown="kr"]:where(:not([data-theme="light"])) {
    --pos: #ef6660;
    --neg: #4c8ee8;
  }
}

:root[data-updown="kr"][data-theme="dark"] {
  --pos: #ef6660;
  --neg: #4c8ee8;
}

.nav-toggle {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 14px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 8px 6px;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
  font-size: 16px;
  flex: 0 0 auto;
}

.brand-text {
  display: flex;
  flex-direction: column;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
}

.brand-sub {
  font-weight: 400;
  font-size: 11px;
  color: var(--muted);
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-title {
  padding: 0 10px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ink-2);
  text-decoration: none;
  font-size: 14px;
}

.nav-link:hover {
  background: var(--accent-soft);
  color: var(--ink);
}

.nav-link.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav-icon {
  width: 18px;
  text-align: center;
  font-size: 13px;
  opacity: 0.85;
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 6px;
}

.lang-switch,
.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--page);
}

.lang-switch a,
.segmented a {
  flex: 1 1 auto;
  padding: 5px 12px;
  border-radius: 7px;
  text-align: center;
  text-decoration: none;
  font-size: 13px;
  color: var(--ink-2);
  white-space: nowrap;
}

.lang-switch a.on,
.segmented a.on {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: var(--shadow);
}

.api-link {
  font-size: 12px;
  color: var(--muted);
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-height: 52px;
  padding: 8px 28px;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--grid);
}

.menu-button,
.topbar-brand {
  display: none;
}

/* The stock search sits at the left of the top bar; the badge and the running
   pill stay at the right (the bar is justify-content: flex-end). */
.topbar-search {
  margin-right: auto;
}

.topbar-search .stock-box {
  width: 220px;
  max-width: 42vw;
}

/* The suggestions hang below the box; the top bar is sticky with a stacking context
   of its own, so they paint over the page without a z-index of their own. */
.topbar-search .stock-suggest {
  min-width: 260px;
}

.running-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
  text-decoration: none;
  box-shadow: var(--shadow);
}

.content {
  width: 100%;
  max-width: 1240px;
  padding: 24px 28px 40px;
}

.footer {
  max-width: 1240px;
  margin-top: auto;
  padding: 16px 28px 32px;
  border-top: 1px solid var(--grid);
  font-size: 12px;
  color: var(--ink-2);
}

.footer p {
  margin: 8px 0 0;
  max-width: none;
}

.footer-line {
  color: var(--muted);
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: min(280px, 86vw);
    transform: translateX(-105%);
    transition: transform 0.18s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.25);
  }

  .nav-toggle:checked ~ .shell .sidebar {
    transform: none;
  }

  .menu-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    cursor: pointer;
    font-size: 13px;
  }

  .topbar {
    justify-content: flex-start;
  }

  .topbar-brand {
    display: inline;
    font-weight: 700;
    text-decoration: none;
    margin-right: auto;
  }

  .topbar,
  .content,
  .footer {
    padding-left: 16px;
    padding-right: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar {
    transition: none;
  }
}

/* ------------------------------------------------- folded menu (desktop only) */
.nav-collapse {
  display: none;
}

@media (min-width: 901px) {
  .nav-collapse {
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: flex-end;
    width: 28px;
    height: 28px;
    margin: -6px 2px -10px 0;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--page);
    color: var(--ink-2);
    cursor: pointer;
  }

  .nav-collapse:hover {
    background: var(--accent-soft);
    color: var(--ink);
  }

  .nav-collapse-icon::before {
    content: "\00ab";
    font-size: 16px;
    line-height: 1;
  }

  html[data-nav="mini"] .nav-collapse-icon::before {
    content: "\00bb";
  }

  html[data-nav="mini"] .shell {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  html[data-nav="mini"] .sidebar {
    padding: 20px 8px;
    align-items: center;
  }

  html[data-nav="mini"] .nav-collapse {
    align-self: center;
    margin: -6px 0 -10px;
  }

  html[data-nav="mini"] .brand {
    padding: 2px 0 6px;
  }

  html[data-nav="mini"] .brand-text,
  html[data-nav="mini"] .nav-title,
  html[data-nav="mini"] .nav-label,
  html[data-nav="mini"] .sidebar-foot {
    display: none;
  }

  html[data-nav="mini"] .nav-group {
    width: 100%;
  }

  html[data-nav="mini"] .nav-link {
    justify-content: center;
    padding: 9px 0;
  }

  html[data-nav="mini"] .nav-icon {
    width: auto;
    font-size: 16px;
  }
}

/* ================================================================ page head */
.page-head {
  margin-bottom: 18px;
}

.page-head h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.page-sub {
  margin: 6px 0 0;
  color: var(--ink-2);
  font-size: 14px;
  max-width: none;
}

.page-sub .state,
.page-sub .chip {
  margin-left: 6px;
}

.page-actions {
  margin: 12px 0 0;
}

.muted {
  color: var(--muted);
}

.prose {
  max-width: none;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 26px 0 0;
  font-size: 17px;
}

/* ================================================================ intro box */
.intro {
  margin: 16px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.intro > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  list-style: none;
  font-weight: 600;
  color: var(--ink-2);
}

.intro > summary::-webkit-details-marker {
  display: none;
}

.intro > summary::after {
  content: "▾";
  margin-left: auto;
  color: var(--muted);
}

.intro[open] > summary::after {
  content: "▴";
}

.intro[open] > summary {
  margin-bottom: 0;
  border-bottom: 1px solid var(--grid);
}

.intro-icon {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.intro-body {
  padding: 4px 18px 10px;
  color: var(--ink-2);
  font-size: 13px;
  max-width: none;
}

.intro-body li {
  margin: 4px 0;
}

/* ================================================================ tooltips
 * A real button. CSS alone opens it on hover and on keyboard focus; the
 * script adds tap-to-open, Escape, and viewport-aware placement - it switches
 * the popup to fixed positioning so a scrolling table cannot clip it.
 */
.tip {
  position: relative;
  display: inline-flex;
  vertical-align: middle;
  text-transform: none;
  letter-spacing: normal;
}

.tip-button {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  cursor: help;
}

.tip-button:hover,
.tip.open .tip-button {
  color: var(--accent);
}

.tip-body {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  z-index: 40;
  display: none;
  width: max-content;
  max-width: min(300px, 80vw);
  transform: translateX(-50%);
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  font-size: 12.5px;
  font-weight: 400;
  line-height: 1.55;
  text-align: left;
  white-space: normal;
}

.tip-body strong {
  display: block;
  margin-bottom: 2px;
}

.tip-body a {
  display: inline-block;
  margin-top: 6px;
  color: var(--accent);
}

.tip:hover .tip-body,
.tip:focus-within .tip-body,
.tip.open .tip-body {
  display: block;
}

:root.js .tip-body {
  position: fixed;
  top: auto;
  left: auto;
  transform: none;
}

/* ================================================================ home */
.home-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 4px 0 8px;
}

.scan-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

button.big {
  padding: 10px 20px;
  font-size: 15px;
  border-radius: 10px;
}

.scan-meta {
  font-size: 12px;
  color: var(--muted);
}

.date-pick {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-2);
}

.date-pick select {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
}

.card.progress {
  flex: 1 1 360px;
  border-left: 3px solid var(--accent);
}

.progress-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.progress-line {
  min-height: 1.4em;
  margin: 6px 0;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cards.markets {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.market-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.market-head h3 {
  margin: 0;
  font-size: 15px;
  color: var(--ink);
}

.kv {
  display: grid;
  gap: 4px;
  margin: 0;
}

.kv div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.kv dt {
  color: var(--ink-2);
}

.kv dd {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 28px 0 0;
  border-bottom: 1px solid var(--grid);
}

.tabs [role="tab"] {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: -1px;
  padding: 10px 16px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--ink-2);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.tabs [role="tab"][aria-selected="true"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-count {
  padding: 0 7px;
  border-radius: 999px;
  background: var(--zero);
  color: var(--ink-2);
  font-size: 12px;
}

.panel {
  padding-top: 8px;
}

.model-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px 28px;
  margin: 12px 0 14px;
}

.model-text {
  flex: 1 1 420px;
}

.model-text h2 {
  margin: 0;
  font-size: 18px;
}

.model-desc,
.model-evidence {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--ink-2);
  max-width: none;
}

.model-evidence .state {
  margin-right: 4px;
}

.model-head .heat {
  flex: 0 0 260px;
}

.model-head .meta {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 10px;
}

.chip-button {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12px;
  cursor: pointer;
}

.chip-button.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

table.picks td.why {
  min-width: 300px;
  max-width: 460px;
}

.why-text {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* "td .name" greys the second line of a cell; the up/down pair must win. */
td .name.up,
td .name.down {
  font-weight: 600;
}

td .name.up {
  color: var(--pos);
}

td .name.down {
  color: var(--neg);
}

.nav-backdrop {
  display: none;
}

@media (max-width: 900px) {
  .nav-toggle:checked ~ .shell .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 25;
    background: rgba(0, 0, 0, 0.35);
    cursor: pointer;
  }
}

.up,
.plan dd .unit.up {
  color: var(--pos);
}

.down,
.plan dd .unit.down {
  color: var(--neg);
}

/* first-run checklist */
.setup-steps {
  display: grid;
  gap: 14px;
  margin: 8px 0 16px;
  padding: 0;
  list-style: none;
}

.step {
  display: flex;
  gap: 16px;
}

.step h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0 4px;
  font-size: 16px;
  color: var(--ink);
}

.step-num {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.step.done .step-num {
  background: color-mix(in srgb, var(--good) 16%, transparent);
  color: var(--good-text);
}

.step .button,
.step .scan-form {
  margin-top: 10px;
}

/* ================================================================ run page */
.action-facts {
  display: grid;
  gap: 6px;
  margin: 0;
  font-size: 13px;
}

.action-facts dt {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.action-facts dd {
  margin: 0;
  color: var(--ink-2);
}

details.group > summary {
  list-style: none;
}

details.group > summary h2 {
  display: inline;
}

details.group > summary::before {
  content: "▸ ";
  color: var(--muted);
}

details.group[open] > summary::before {
  content: "▾ ";
}

/* ================================================================ help */
.help-section {
  margin-top: 18px;
  scroll-margin-top: 70px;
}

.help-section h2 {
  margin: 0 0 8px;
  font-size: 16px;
}

/* The guide is read, not scanned: one size down from the page. On a wide screen the sections
 * sit side by side, so lines stay short without leaving half the page empty. */
.help-section .prose {
  font-size: 13px;
  line-height: 1.6;
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(520px, 100%), 1fr));
  gap: var(--gap);
  align-items: start;
  margin-top: 18px;
}

.help-grid > .help-section {
  margin-top: 0;
}

.help-grid > .help-section:first-child {
  grid-column: 1 / -1;
}

.help-section .prose p {
  margin: 0 0 8px;
}

.help-section .prose li {
  margin: 4px 0;
}

.gloss-group {
  margin: 20px 0 8px;
  font-size: 14px;
}

.glossary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  gap: 8px;
  margin: 0;
}

.gloss-entry {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  scroll-margin-top: 70px;
}

.gloss-entry:target {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.gloss-entry dt {
  font-size: 13px;
  font-weight: 700;
}

.gloss-entry dd {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.5;
}

.gloss-entry dd p {
  margin: 0 0 6px;
}

/* ================================================================ settings */
.settings-table th {
  position: static;
  width: 40%;
  font-weight: 600;
  text-transform: none;
  letter-spacing: normal;
  color: var(--ink-2);
  font-size: 13px;
}

/* Korean labels are words, not acronyms: no small caps in table headers. */
:root[lang="ko"] thead th {
  text-transform: none;
  letter-spacing: normal;
  font-size: 12px;
}

.settings-picks {
  margin-bottom: 16px;
}

.picks-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
}

.picks-form select {
  font: inherit;
  color: var(--ink);
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
}

.login-card {
  max-width: 420px;
  margin: 40px auto;
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 22px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.login-form input {
  font: inherit;
  color: var(--ink);
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
}

/* ================================================================ news */
.news-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0 6px 4px 0;
  padding: 1px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.news-badge.serious {
  border-color: var(--critical);
  color: var(--critical);
}

.news-badge.watch {
  border-color: var(--warning);
  color: var(--ink);
}

.news-badge.none {
  color: var(--good-text);
}

.news-card {
  margin-top: 16px;
}

.banner.hold {
  margin-top: 0;
  border-left-color: var(--critical);
  color: var(--ink);
}

.news-flags {
  margin: 10px 0 0;
  padding-left: 0;
  list-style: none;
  font-size: 13px;
}

.news-flags li {
  margin: 6px 0;
}

.ai-read {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--page);
  border: 1px solid var(--border);
  font-size: 13px;
}

.ai-read p {
  margin: 8px 0 0;
}

.ai-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.news-items {
  margin-top: 12px;
  font-size: 13px;
}

.news-items ul {
  margin: 0;
  padding-left: 0;
  list-style: none;
}

.news-items li {
  margin: 6px 0;
}

.news-items li .chip {
  margin-right: 6px;
}

/* ---------------------------------------------------------------- track record */
.track-model {
  margin-top: 28px;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 12px 0 20px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.kpi-value {
  font-size: 19px;
  font-weight: 600;
  margin-top: 2px;
}

.kpi .tile-note {
  margin-top: 2px;
}

.chart .model-marker {
  stroke: var(--ink-2);
  stroke-width: 1;
  stroke-dasharray: 4 3;
}

.legend .swatch.marker {
  background: none;
  border-left: 2px dashed var(--ink-2);
  width: 0;
}

.model-history {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  display: grid;
  gap: 6px;
  font-size: 13px;
}

.model-history li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* ---------------------------------------------------------------- home: held picks */
.cards.holding {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  margin-bottom: 8px;
}

.holding-list summary {
  cursor: pointer;
  margin-top: 10px;
  font-size: 13px;
  color: var(--accent);
}

.holding-list ul {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  display: grid;
  gap: 6px;
}

.holding-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 90px 64px;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.holding-list .ticker {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.holding-list .net {
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Stop on the left, target on the right, the latest close as a tick. */
.range {
  position: relative;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--neg), var(--zero) 50%, var(--pos));
  opacity: 0.85;
}

.range.none {
  background: var(--zero);
}

.range-mark {
  position: absolute;
  top: -4px;
  width: 3px;
  height: 14px;
  margin-left: -1.5px;
  border-radius: 1px;
  background: var(--ink);
}

/* ---------------------------------------------------------------- picks as cards on phones
 * The table keeps every column on a desk; on a phone each pick becomes a
 * card: name and score on top, the plan as labelled pairs, the reason below. */
@media (max-width: 640px) {
  .table-scroll:has(> table.picks) {
    overflow: visible;
    border: 0;
    background: none;
  }

  table.picks,
  table.picks tbody {
    display: block;
    width: 100%;
  }

  table.picks thead {
    display: none;
  }

  table.picks tr {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px 10px;
    padding: 12px;
    margin-bottom: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }

  table.picks tr[hidden] {
    display: none;
  }

  table.picks td {
    display: block;
    padding: 0;
    border: 0;
    text-align: left;
    white-space: normal;
  }

  table.picks td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    color: var(--ink-2);
  }

  table.picks td.rank {
    display: none;
  }

  table.picks td.ticker {
    grid-column: 1 / 3;
    font-size: 15px;
  }

  table.picks td.score::before {
    display: none;
  }

  table.picks td.why,
  table.picks td.muted,
  table.picks td.empty {
    grid-column: 1 / -1;
  }
}

/* ---------------------------------------------------------------- one list per country */
.country-list + .country-list {
  margin-top: 22px;
}

.country-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 0 8px;
  font-size: 15px;
}

.country-head .muted {
  font-size: 12px;
  font-weight: 400;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

/* ---------------------------------------------------------------- portfolio */
.portfolio-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 12px 0 4px;
}

.portfolio-actions form {
  margin: 0;
}

.holding-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px 18px;
  max-width: none;
}

.holding-form .action-foot {
  grid-column: 1 / -1;
}

/* An input the width of its column, padding included: it must not run into the next column. */
.holding-form .field input {
  box-sizing: border-box;
}

.holding-form .form-note {
  grid-column: 1 / -1;
  margin: 0;
}

/* Cards stacked one under another on the page keep its gap, not a hairline. Only direct
 * children of the content: cards inside a .cards grid are spaced by the grid itself. */
.content > .cards + .card,
.content > .card + .card,
.content > .card + .cards {
  margin-top: var(--gap);
}

/* A row that is always three columns wide, so the rows of cards on a page line up under one
 * another whatever their count (a row of two leaves the third column empty). */
@media (min-width: 901px) {
  .cards.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* The watchlist's alert form is a row of cards in the same grid as the cards above it, so
 * its columns line up with theirs. */
.watch-edit .form-title,
.watch-edit .form-foot {
  grid-column: 1 / -1;
  margin: 0;
}

.watch-edit .form-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}

.watch-edit .form-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.watch-edit .card input {
  box-sizing: border-box;
  width: 100%;
}

.holding-form .field input[type="text"],
.holding-form .field input[type="date"],
.holding-form .field select {
  width: 100%;
}

.field input[type="date"] {
  font: inherit;
  color: var(--ink);
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  max-width: 100%;
}

.portfolio-table .range {
  display: block;
  width: 120px;
  margin: 6px 0 2px;
}

button.small,
.button.small {
  font-size: 12px;
  line-height: 1.4;
  padding: 4px 10px;
}

.alert-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: grid;
  gap: 4px;
}

.alert-list .news-badge,
.portfolio-table .news-badge {
  margin: 2px 4px 2px 0;
}

/* Buy / watch buttons under each pick. */
.pick-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.pick-actions form {
  margin: 0;
}

.pick-actions .state {
  font-size: 12px;
  text-decoration: none;
}

/* ---------------------------------------------------------------- freshness line */
.freshness {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 14px;
  width: 100%;
  max-width: 1240px;
  margin: 0;
  /* Lined up with the page content below it. */
  padding: 12px 28px 0;
  font-size: 12px;
  color: var(--muted);
}

.freshness.stale span:first-child {
  color: var(--critical);
  font-weight: 600;
}

@media (max-width: 900px) {
  .freshness {
    padding-left: 16px;
    padding-right: 16px;
  }
}

/* ---------------------------------------------------------------- a stock's price chart */
.chart .level {
  stroke-width: 1.5;
  stroke-dasharray: 5 4;
}

/* What you paid for a holding, and the entry reference of a pick you own none of:
   the same neutral line, named differently on the two pages. */
.chart .level-bought,
.chart .level-entry {
  stroke: var(--axis);
}

.chart .level-stop {
  stroke: var(--critical);
}

.chart .level-target {
  stroke: var(--good);
}

.chart .dot-end {
  fill: var(--series-1);
}

.legend .swatch.level-bought,
.legend .swatch.level-entry {
  background: var(--axis);
}

.legend .swatch.level-stop {
  background: var(--critical);
}

.legend .swatch.level-target {
  background: var(--good);
}

.price-chart-card {
  margin-top: var(--gap);
}

/* ---------------------------------------------------------------- home: my portfolio */
.home-portfolio {
  margin: var(--gap) 0;
}

/* The title and its badge on one line. Two cards share the shape; they keep
   separate names so that a test can ask whether the portfolio card is there. */
.home-portfolio-head,
.today-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.home-portfolio-head h3 a {
  color: inherit;
}

.home-portfolio-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

/* ---------------------------------------------------------------- sortable headers */
th .sort-button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-align: inherit;
}

th .sort-button::after {
  content: " ↕";
  color: var(--muted);
  font-size: 11px;
}

th[aria-sort="ascending"] .sort-button::after {
  content: " ↑";
  color: var(--ink);
}

th[aria-sort="descending"] .sort-button::after {
  content: " ↓";
  color: var(--ink);
}

/* Regime gauge: the scan's own 0-1 score on its three state bands. */
.gauge {
  margin: 4px 0 12px;
}

.gauge-track {
  position: relative;
  display: flex;
  height: 10px;
  border-radius: 5px;
  overflow: visible;
}

.gauge-track .band {
  height: 100%;
  opacity: 0.35;
}

.gauge-track .band:first-child {
  border-radius: 5px 0 0 5px;
}

.gauge-track .band.bad {
  background: var(--critical);
}

.gauge-track .band.warn {
  background: var(--warning);
}

.gauge-track .band.ok {
  background: var(--good);
  border-radius: 0 5px 5px 0;
}

.gauge-marker {
  position: absolute;
  top: -4px;
  width: 4px;
  height: 18px;
  margin-left: -2px;
  border-radius: 2px;
  background: var(--ink);
}

.gauge-scale {
  position: relative;
  height: 16px;
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
}

.gauge-scale span {
  position: absolute;
  transform: translateX(-50%);
}

.gauge-scale span:first-child {
  transform: none;
}

.gauge-scale span:last-child {
  transform: translateX(-100%);
}

.gauge-line {
  margin: 4px 0;
  font-size: 13px;
  color: var(--ink-2);
}

.gauge-strip {
  display: block;
  width: 100%;
  height: 48px;
  margin-top: 6px;
}

.gauge-strip .line {
  fill: none;
  stroke: var(--series-1);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.gauge-strip .band-line {
  stroke-width: 1;
  stroke-dasharray: 3 3;
  vector-effect: non-scaling-stroke;
}

.gauge-strip .band-line.ok {
  stroke: var(--good);
}

.gauge-strip .band-line.bad {
  stroke: var(--critical);
}

.gauge-strip-note {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.gauge-parts {
  margin-top: 8px;
  font-size: 13px;
}

.gauge-parts summary {
  cursor: pointer;
  color: var(--ink-2);
}

.gauge-parts ul {
  list-style: none;
  margin: 8px 0 4px;
  padding: 0;
}

.gauge-parts li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px auto;
  gap: 8px;
  align-items: center;
  padding: 2px 0;
}

.part-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--seq-track);
}

.part-fill {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--seq-fill);
}

.part-pts {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

/* Stock name search on the add forms (app.js stockSearch). */
.stock-box {
  position: relative;
}

.stock-box input {
  width: 100%;
}

.stock-suggest {
  position: absolute;
  z-index: 20;
  top: 100%;
  left: 0;
  right: 0;
  margin: 2px 0 0;
  padding: 4px 0;
  list-style: none;
  max-height: 320px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

.stock-suggest li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  cursor: pointer;
}

.stock-suggest li:hover,
.stock-suggest li.active {
  background: var(--zero);
}

.stock-suggest .stock-name {
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stock-suggest .stock-meta {
  flex: none;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.stock-confirm {
  display: block;
  min-height: 1.2em;
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted);
}

.stock-confirm:empty {
  display: none; /* no blank line pushing the hint below its neighbours' */
}

.stock-confirm.ok {
  color: var(--good-text);
}

/* Sector and market news beside a stock's own (news_card.html, home). */
.news-context {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.news-context h4 {
  margin: 0 0 8px;
  font-size: 14px;
}

.context-head {
  margin: 8px 0 4px;
}

.context-read {
  margin: 4px 0;
}

.mood {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  vertical-align: middle;
  background: var(--zero);
  color: var(--ink-2);
}

.mood.positive {
  background: color-mix(in srgb, var(--good) 16%, transparent);
  color: var(--good-text);
}

.mood.negative {
  background: color-mix(in srgb, var(--critical) 16%, transparent);
  color: var(--critical);
}

.market-news .headlines {
  margin: 8px 0 0;
  padding-left: 18px;
}

.market-news .headlines li {
  margin: 4px 0;
}

/* ---------------------------------------------------------------- company profile */
.company-card {
  margin-top: 16px;
}

.company-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 8px 24px;
  margin-top: 14px;
}

.company-results-wrap {
  margin-top: 18px; /* the box, not the table inside it, keeps its distance from the facts above */
}

.company-results {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.company-results caption {
  caption-side: top;
  text-align: left;
}

.company-results td {
  text-align: right;
}

.company-results td.down {
  color: var(--critical);
}

.company-read {
  font-size: 13px;
}

.company-links a {
  white-space: nowrap;
}

.company-results th[scope="row"] {
  text-align: left;
  white-space: nowrap;
}

/* A name that just entered the list; the ones that stay carry a plain day count. */
.chip-new {
  border-color: var(--accent, currentColor);
  color: var(--accent, var(--ink-2));
  font-weight: 600;
}

/* The measured-results text inside a model card: folded so a tall card does not stretch its row. */
details.measured {
  margin-top: 8px;
}

details.measured > summary {
  cursor: pointer;
  color: var(--ink-2);
  font-size: 13px;
}
