/* Stock Searcher. Colours are roles, defined once for light and once for dark. */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f1f0ec;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7d7b75;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.12);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --track: #cde2fb;
  --level-1: #e6f0fc;
  --level-2: #bcd7f8;
  --level-3: #1c5fb0;
  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;
  --good-text: #006300;
  --critical-text: #a12a2a;
  --banner: #fdecec;
  --banner-border: #d03b3b;
  --focus: #2a78d6;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #262624;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.12);
    --series-1: #3987e5;
    --series-2: #d95926;
    --track: #184f95;
    --level-1: #172a42;
    --level-2: #1d4675;
    --level-3: #2667bd;
    --good-text: #0ca30c;
    --critical-text: #e66767;
    --banner: #3a1616;
    --banner-border: #d03b3b;
    --focus: #6da7ec;
  }
}

* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0; background: var(--page); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif; line-height: 1.45;
}
a { color: var(--series-1); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1 { font-size: 1.5rem; margin: 0 0 4px; }
h2 { font-size: 1.1rem; margin: 28px 0 10px; }
h3 { font-size: 0.95rem; margin: 0 0 8px; color: var(--text-2); font-weight: 600; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.secondary { color: var(--text-2); }
.small { font-size: 0.87rem; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

/* Header */
.top { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.top-inner { max-width: 1180px; margin: 0 auto; padding: 10px 16px; display: flex; flex-wrap: wrap;
  align-items: center; gap: 8px 20px; }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav a { padding: 6px 10px; border-radius: 6px; color: var(--text-2); }
nav a.on { background: var(--surface-2); color: var(--text); font-weight: 600; }
.scan-info { margin-left: auto; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  font-size: 0.87rem; color: var(--text-2); }
.scan-info b { color: var(--text); font-weight: 600; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--good); margin-right: 5px; }
.dot.bad { background: var(--critical); }
.dot.busy { background: var(--warning); }

main { max-width: 1180px; margin: 0 auto; padding: 18px 16px 40px; }
footer { max-width: 1180px; margin: 0 auto; padding: 16px; color: var(--muted); font-size: 0.85rem;
  border-top: 1px solid var(--border); }

/* Buttons and forms */
button, .button {
  font: inherit; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer;
}
button:hover { background: var(--surface-2); }
button.primary { background: var(--series-1); border-color: var(--series-1); color: #fff; font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.quiet { border-color: transparent; color: var(--text-2); padding: 4px 8px; }
button:disabled { opacity: 0.55; cursor: default; }
input, select {
  font: inherit; padding: 7px 9px; border-radius: 6px; border: 1px solid var(--axis);
  background: var(--surface); color: var(--text);
}
input[type="number"] { width: 6.5em; }
input[type="email"], input[type="text"], input[type="password"] { width: 22em; max-width: 100%; }
label { display: block; font-weight: 600; margin: 0 0 4px; }
.field { margin: 0 0 16px; }
.field .hint { color: var(--muted); font-size: 0.87rem; margin-top: 4px; max-width: 46em; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.message { padding: 9px 12px; border-radius: 6px; margin: 10px 0; border: 1px solid var(--border);
  background: var(--surface); }
.message.ok { border-color: var(--good); }
.message.error { border-color: var(--critical); }
.message:empty { display: none; }

/* Banner and panels */
.banner { background: var(--banner); border: 1px solid var(--banner-border); border-radius: 8px;
  padding: 10px 14px; margin: 0 0 16px; }
.banner strong { display: block; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.panel + .panel { margin-top: 12px; }
details.panel summary { cursor: pointer; font-weight: 600; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 12px; }

/* Candidate cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px;
  margin: 0 0 12px; display: grid; grid-template-columns: 56px minmax(0, 1fr) 190px; gap: 6px 16px; }
.card .rank { font-size: 1.6rem; font-weight: 700; color: var(--muted); }
.card .day { font-size: 0.95rem; font-weight: 600; color: var(--text-2); line-height: 1.25; }
.card h3 { font-size: 1.05rem; color: var(--text); margin: 0; }
.card h3 a { color: var(--text); }
.card .name { color: var(--text-2); font-weight: 400; margin-left: 6px; }
.card .reason { grid-column: 2 / 4; color: var(--text-2); margin: 4px 0 0; }
.card .side { text-align: right; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chip { border: 1px solid var(--border); border-radius: 999px; padding: 2px 9px; font-size: 0.85rem;
  background: var(--surface-2); white-space: nowrap; }
.chip b { font-variant-numeric: tabular-nums; }
.big-score { font-size: 1.7rem; font-weight: 700; line-height: 1; }
.big-score small { display: block; font-size: 0.72rem; font-weight: 400; color: var(--muted); margin-top: 3px; }
@media (max-width: 720px) {
  .card { grid-template-columns: 40px minmax(0, 1fr); }
  .card .side { grid-column: 2; text-align: left; }
  .card .reason { grid-column: 1 / 3; }
}

/* 52-week range */
.range { margin-top: 8px; }
.range .bar { position: relative; height: 6px; border-radius: 3px; background: var(--track); }
.range .mark { position: absolute; top: -4px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%;
  background: var(--series-1); border: 2px solid var(--surface); }
.range .ends { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--muted);
  margin-top: 4px; font-variant-numeric: tabular-nums; }
.spark { display: block; margin-left: auto; }
.spark polyline { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round;
  stroke-linecap: round; }
@media (max-width: 720px) { .spark { margin-left: 0; } }

/* Status labels: always an icon and words, never colour alone */
.status { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.status::before { content: ""; width: 0.9em; height: 0.9em; border-radius: 50%; display: inline-block; }
.status.good::before { background: var(--good); }
.status.mixed::before { background: var(--warning); border-radius: 2px; }
.status.bad::before { background: var(--critical); border-radius: 0; transform: rotate(45deg) scale(0.85); }
.status.none::before { background: var(--axis); }

/* Discount levels: one hue, deeper for a bigger discount. The words carry the meaning, not the colour. */
.level { display: inline-block; font-size: 0.78rem; font-weight: 600; border-radius: 999px; padding: 1px 8px;
  border: 1px solid var(--border); color: var(--text-2); white-space: nowrap; vertical-align: 1px; }
.level.small { background: var(--level-1); border-color: transparent; color: var(--text); }
.level.sale { background: var(--level-2); border-color: transparent; color: var(--text); }
.level.big { background: var(--level-3); border-color: transparent; color: #fff; }
.level.none { border-style: dashed; color: var(--muted); }
.tile .value .level { font-size: 1rem; padding: 3px 12px; }

/* Which list a stock is on */
.tag.list-mine { border-color: var(--series-1); color: var(--text); font-weight: 600; }
.tag.list-news { border-style: dashed; }
tr.removed td { opacity: 0.45; }
tr.removed td:last-child { opacity: 1; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--grid); vertical-align: top; }
th { font-size: 0.82rem; color: var(--muted); font-weight: 600; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

/* Score tiles and breakdown */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 14px 0; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.tile .label { color: var(--text-2); font-size: 0.87rem; }
.tile .value { font-size: 2rem; font-weight: 700; line-height: 1.15; }
.tile .note { color: var(--muted); font-size: 0.85rem; }
.meter { display: grid; grid-template-columns: minmax(0, 1fr) 46px; gap: 8px; align-items: center; min-width: 120px; }
.meter .track { height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; }
.meter .fill { height: 100%; border-radius: 4px; background: var(--series-1); }
.meter .pts { text-align: right; font-variant-numeric: tabular-nums; }

/* Charts */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axisline { stroke: var(--axis); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart text.endlabel { fill: var(--text); font-weight: 600; paint-order: stroke; stroke: var(--surface);
  stroke-width: 4px; stroke-linejoin: round; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .s1 { stroke: var(--series-1); }
.chart .s2 { stroke: var(--series-2); }
.chart .enddot { stroke: var(--surface); stroke-width: 2; }
.chart .enddot.s1, .chart .alertdot { fill: var(--series-1); }
.chart .enddot.s2 { fill: var(--series-2); }
.chart .alertdot { stroke: var(--surface); stroke-width: 2; }
.chart .crosshair { stroke: var(--axis); stroke-width: 1; visibility: hidden; }
.chart .tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 9px; font-size: 0.82rem; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
  visibility: hidden; white-space: nowrap; z-index: 3; }
.chart .tip .when { color: var(--muted); margin-bottom: 2px; }
.chart .tip .rowv { display: flex; align-items: center; gap: 6px; }
.chart .tip .rowv b { font-variant-numeric: tabular-nums; }
.key { display: inline-block; width: 14px; height: 0; border-top: 2px solid var(--series-1); vertical-align: middle; }
.key.s2 { border-top-color: var(--series-2); }
.legend { display: flex; gap: 16px; font-size: 0.85rem; color: var(--text-2); margin: 0 0 6px; flex-wrap: wrap; }
.ranges { display: flex; gap: 4px; }
.ranges button { padding: 3px 10px; font-size: 0.85rem; }
.ranges button.on { background: var(--surface-2); font-weight: 600; }
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 6px; }

.headlines { list-style: none; margin: 0; padding: 0; }
.headlines li { padding: 7px 0; border-bottom: 1px solid var(--grid); }
.headlines li:last-child { border-bottom: none; }
.flag { color: var(--critical-text); font-weight: 600; white-space: nowrap; }
.tag { font-size: 0.78rem; border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px;
  color: var(--text-2); white-space: nowrap; }
.empty { padding: 22px; text-align: center; color: var(--text-2); }
.login { max-width: 360px; margin: 12vh auto; }
