:root {
  --brand: #00A1DF;
  --text: #1f2933;
  --muted: #64707d;
  --line: #e2e6ea;
  --bg: #f4f6f8;
  --card: #ffffff;
  --main: #1f6fd1;
  --compare: #8c8c8c;
  --bad: #d62728;
  --good: #2e8b57;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--text); background: var(--bg); }
header { padding: 14px 24px 10px; background: var(--card); border-bottom: 1px solid var(--line); }
h1 { margin: 0; font-size: 22px; font-weight: 600; color: var(--brand); letter-spacing: .2px; }
h2 { margin: 0; font-size: 18px; font-weight: 600; }
h3 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.sub { margin: 2px 0 0; color: var(--muted); }
.note { margin: 6px 0; color: var(--muted); font-size: 12px; }
.note.flash { color: #b35c00; font-weight: 600; }

/* Layout: settings panel on the left, chart on the right. */
.layout { display: grid; grid-template-columns: 270px 1fr; gap: 16px; padding: 16px 24px 40px; max-width: 1400px; }
.layout.collapsed { grid-template-columns: 1fr; }
.layout.collapsed .panel { display: none; }
.panel, .content { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; min-width: 0; }
.panel { align-self: start; position: sticky; top: 12px; }
.panelHead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.field { display: block; margin: 12px 0 0; font-size: 12px; color: var(--muted); font-weight: 600; }
.field select { display: block; width: 100%; margin-top: 4px; font-size: 14px; padding: 5px 6px; border: 1px solid #c9d0d6; border-radius: 5px; background: #fff; color: var(--text); }
.ruleLine { margin: 6px 0 0; padding: 6px 8px; font-size: 12px; background: #eef7fc; border-left: 3px solid var(--brand); border-radius: 0 4px 4px 0; }

/* Small switches. */
.seg { display: flex; margin-top: 4px; }
.seg button { flex: 1; padding: 5px 6px; font-size: 12px; border: 1px solid #c9d0d6; background: #fff; color: var(--text); cursor: pointer; margin-left: -1px; }
.seg button:first-child { border-radius: 5px 0 0 5px; margin-left: 0; }
.seg button:last-child { border-radius: 0 5px 5px 0; }
.seg button.on { background: var(--brand); border-color: var(--brand); color: #fff; position: relative; }
.seg.small button { flex: none; padding: 4px 10px; }

/* Dial. */
.dial { margin-top: 2px; }
.dialSvg { width: 100%; max-width: 260px; display: block; margin: 0 auto; }
.slice { cursor: pointer; transition: opacity .2s; }
.slice.off { opacity: .25; }
.dialLabel { font-size: 12px; fill: var(--muted); cursor: pointer; }
.dialLabel.on { fill: var(--text); font-weight: 700; }
.needle path { fill: #333; }
.hub { fill: #333; }
.dialNote { margin: 0; font-size: 12px; font-weight: 400; color: var(--muted); text-align: center; }

.iconBtn { border: 1px solid #c9d0d6; background: #fff; border-radius: 5px; padding: 3px 9px; cursor: pointer; color: var(--text); }
.contentHead { display: flex; align-items: flex-start; gap: 12px; }

/* Headline cards: the answer at a glance. */
.headline { display: flex; flex-wrap: wrap; gap: 12px; margin: 12px 0 4px; }
.card { flex: 1 1 280px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; border-left-width: 4px; }
.mainCard { border-left-color: var(--main); }
.compareCard { border-left-color: var(--compare); }
.cardRule { font-size: 12px; font-weight: 600; color: var(--muted); }
.mainCard .cardRule { color: var(--main); }
.cardBig { font-size: 18px; font-weight: 700; margin: 2px 0; }
.cardBig .date { font-size: 13px; font-weight: 400; color: var(--muted); }
.cardSmall { font-size: 12px; color: var(--muted); }
.cardSmall b { color: var(--text); }
.bad { color: var(--bad); }
.good { color: var(--good); }

/* Player. */
.player { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 8px 0; }
.player button { font-size: 13px; padding: 6px 14px; border: 1px solid #c9d0d6; background: #fff; border-radius: 5px; cursor: pointer; color: var(--text); }
.player button.primary { background: var(--brand); border-color: var(--brand); color: #fff; min-width: 96px; }
.weekLabel { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 160px; }

.counters table { border-collapse: collapse; margin: 6px 0; font-variant-numeric: tabular-nums; }
.counters th, .counters td { padding: 4px 12px; text-align: right; border-bottom: 1px solid #eee; }
.counters th:first-child, .counters td:first-child { text-align: left; }
.counters th { font-weight: 600; font-size: 12px; color: var(--muted); }
.mainRow td:first-child { color: var(--main); font-weight: 600; }
.compareRow td:first-child { color: #777; font-weight: 600; }
.counters td.bad { font-weight: 600; }
.counters { overflow-x: auto; }

/* Chart. */
.chart { position: relative; margin-top: 6px; }
.overlay { cursor: pointer; }
.axis text { fill: #555; font-size: 11px; }
.axisLabel, .openText { fill: #888; font-size: 11px; }
.zero { stroke: #333; stroke-width: 1; }
.openLine { stroke: #bbb; stroke-dasharray: 2 3; }
.line { fill: none; }
.line.main { stroke: var(--main); stroke-width: 2.2; }
.line.target { stroke: var(--main); stroke-width: 1.2; stroke-dasharray: 5 4; opacity: 0.7; }
.line.compare { stroke: var(--compare); stroke-width: 1.6; }
.arrival { fill: #2ca02c; }
.stockDot { fill: var(--bad); stroke: #fff; stroke-width: 1; }
.firstFlag line { stroke: var(--bad); stroke-dasharray: 4 3; }
.firstFlag text { fill: var(--bad); font-weight: 600; font-size: 12px; }
.cursor { stroke: #222; stroke-width: 1; opacity: 0.5; }
.hoverLine { stroke: #aaa; }
.tooltip { position: absolute; width: 210px; background: #fff; border: 1px solid #ccc; border-radius: 4px;
  padding: 6px 8px; font-size: 12px; pointer-events: none; box-shadow: 0 2px 6px rgba(0,0,0,.12); }
.tipWeek { font-weight: 600; margin-bottom: 4px; }
.tipRule { font-weight: 600; margin-top: 4px; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 4px; }
.sw { display: inline-block; width: 18px; height: 10px; margin-right: 5px; vertical-align: middle; }
.sw.main { border-top: 3px solid var(--main); height: 0; }
.sw.target { border-top: 2px dashed var(--main); height: 0; }
.sw.compare { border-top: 2px solid var(--compare); height: 0; }
.sw.short { background: var(--bad); }
.sw.expired { background: #f39c12; }
.sw.arrived { width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 10px solid #2ca02c; }

/* Narrow screens: settings above the chart. */
@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; padding: 12px 16px 32px; }
  .panel { position: static; }
  header { padding-left: 16px; padding-right: 16px; }
}

/* Tabs. */
.tabsRow { display: flex; align-items: center; gap: 12px; margin: -4px 0 12px; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 4px; }
.tabs button { border: 0; background: none; padding: 8px 14px; font-size: 14px; color: var(--muted); cursor: pointer;
  border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--brand); font-weight: 600; border-bottom-color: var(--brand); }

/* Line under the headline: all 200 trials. */
.trialsLine { margin: 2px 0 6px; font-size: 13px; color: var(--muted); }
.trialsLine b { color: var(--text); }
.trialsLine b.good { color: var(--good); }
.trialsLine b.bad { color: var(--bad); }

/* How it works. Settings panel is hidden on this tab. */
.layout.about { grid-template-columns: minmax(0, 1fr); }
.layout.about .panel, .layout.about #showPanel { display: none; }
.about { max-width: 900px; }
.about p, .about li { font-size: 14px; line-height: 1.6; }
.aboutHead { margin: 22px 0 6px; font-size: 13px; }
.rulesTable { border-collapse: collapse; width: 100%; }
.rulesTable td { padding: 6px 10px; border-bottom: 1px solid #eee; vertical-align: top; font-size: 13px; }
.rulesTable td:first-child { font-weight: 600; white-space: nowrap; color: var(--main); }
.aboutList { padding-left: 20px; margin: 6px 0; }
.aboutList li { margin-bottom: 4px; }
@media (max-width: 600px) { .rulesTable td:first-child { white-space: normal; } }
