:root {
  --paper: #eef3f3;
  --surface: #ffffff;
  --ink: #172a30;
  --muted: #5b6e73;
  --rule: #cfdadb;
  --accent: #12708a;
  --accent-ink: #ffffff;
  --up: #b4232f;
  --up-soft: #fbe9ea;
  --down: #217a4f;
  --down-soft: #e4f3ea;
  --warn: #9a6400;
  --warn-soft: #fbf1dc;
  --font: "Atkinson Hyperlegible Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  --figures: "Atkinson Hyperlegible Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #10191c;
    --surface: #172327;
    --ink: #e2ebed;
    --muted: #93a6ab;
    --rule: #2a3b40;
    --accent: #5bb4cf;
    --accent-ink: #0d1a1e;
    --up: #f07a83;
    --up-soft: #3a1d21;
    --down: #6fcf9c;
    --down-soft: #16322a;
    --warn: #e2b04a;
    --warn-soft: #3a2f16;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.5 var(--font); }
a { color: var(--accent); text-underline-offset: 3px; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
h1 { font-size: 1.75rem; line-height: 1.2; margin: 0 0 .5rem; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
code { font-family: var(--figures); font-size: .85em; background: var(--paper); padding: .1em .35em; border-radius: 3px; }
.muted { color: var(--muted); }
.plain { font-family: var(--font); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Top bar */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1.5rem;
  padding: .85rem clamp(1rem, 4vw, 2.5rem); background: var(--surface); border-bottom: 1px solid var(--rule);
}
.brand { font-weight: 700; color: var(--ink); text-decoration: none; font-size: 1.05rem; }
.nav { display: flex; flex-wrap: wrap; gap: .25rem; align-items: center; }
.nav a { color: var(--ink); text-decoration: none; padding: .4rem .7rem; border-radius: 6px; }
.nav a:hover { background: var(--paper); }
.nav a.is-active { background: var(--paper); font-weight: 600; }
.nav a.nav-cta { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.nav a.nav-quiet { color: var(--muted); }

.wrap { max-width: 1120px; margin: 0 auto; padding: 2rem clamp(1rem, 4vw, 2.5rem) 4rem; }
.crumb { margin: 0 0 .5rem; font-size: .95rem; }
.lede { max-width: 62ch; color: var(--muted); margin: 0 0 1.5rem; }

/* Flash */
.flash { padding: .7rem 1rem; border-radius: 6px; margin: 0 0 1rem; border-left: 4px solid var(--accent); background: var(--surface); }
.flash-ok { border-color: var(--down); }
.flash-warn { border-color: var(--warn); background: var(--warn-soft); }
.flash-error { border-color: var(--up); background: var(--up-soft); }

/* Summary */
.summary { margin-bottom: 2rem; }
.summary h1 { font-size: clamp(1.6rem, 3.4vw, 2.3rem); max-width: 30ch; }
.summary-sub { color: var(--muted); margin: 0; }
.warn-link { color: var(--warn); font-weight: 600; }

/* Recent changes: the one loud element */
.changes { margin-bottom: 2.5rem; }
.change-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; }
.change {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; grid-template-areas: "name prices pct time" "partner prices pct time";
  align-items: center; gap: 0 1.5rem; padding: .85rem 1.25rem .85rem 1.1rem;
  border-left: 6px solid var(--rule); border-bottom: 1px solid var(--rule);
}
.change:last-child { border-bottom: 0; }
.change.is-up { border-left-color: var(--up); }
.change.is-down { border-left-color: var(--down); }
.change-name { grid-area: name; font-weight: 600; color: var(--ink); text-decoration: none; }
.change-name:hover { text-decoration: underline; }
.change-partner { grid-area: partner; color: var(--muted); font-size: .9rem; }
.change-prices { grid-area: prices; display: flex; align-items: baseline; gap: .75rem; font-family: var(--figures); }
.price-old { color: var(--muted); font-size: .95rem; text-decoration-thickness: 1.5px; }
.price-new { font-size: 1.45rem; font-weight: 600; }
.change-pct { grid-area: pct; font-family: var(--figures); font-weight: 600; min-width: 5.5ch; text-align: right; }
.is-up .change-pct, td.is-up { color: var(--up); }
.is-down .change-pct, td.is-down { color: var(--down); }
.change-time { grid-area: time; color: var(--muted); font-size: .9rem; min-width: 9rem; text-align: right; }

/* Tours table */
.tours-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: .75rem; margin-bottom: .75rem; }
.tours-head h2 { margin: 0; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; }
.table-scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: .85rem; padding: .7rem 1rem; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.table td { padding: .7rem 1rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; }
.table .price, .table td.num { font-family: var(--figures); }
.tour-link { font-weight: 600; color: var(--ink); text-decoration: none; }
.tour-link:hover { text-decoration: underline; }
.tour-partner { display: block; color: var(--muted); font-size: .85rem; }
.raw { max-width: 32ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.no-match { padding: 1rem; margin: 0; color: var(--muted); }

.pill { display: inline-block; font-size: .8rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px; white-space: nowrap; }
.pill-ok { background: var(--down-soft); color: var(--down); }
.pill-error { background: var(--up-soft); color: var(--up); }
.pill-new { background: var(--warn-soft); color: var(--warn); }
.pill-paused { background: var(--paper); color: var(--muted); }

/* Tour page */
.tour-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 1rem 2rem; margin-bottom: 1.25rem; }
.tour-meta { margin: 0; color: var(--muted); }
.tour-price { display: grid; justify-items: end; font-family: var(--figures); }
.price-big { font-size: clamp(2rem, 5vw, 2.8rem); font-weight: 600; line-height: 1.1; }
.tour-price .change-pct { font-size: .95rem; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: 1.5rem; }
.toolbar form { margin: 0; }
.toolbar-status { margin-left: auto; color: var(--muted); font-size: .9rem; display: flex; gap: .5rem; align-items: center; }
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 1.25rem; margin-bottom: 1.25rem; }
.panel .table-scroll { border: 0; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--rule); stroke-width: 1; }
.chart .axis { fill: var(--muted); font: 12px var(--figures); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.chart .dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2.5; }
.details dl { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.5rem; margin: 0; }
.details dt { color: var(--muted); }
.details dd { margin: 0; word-break: break-word; }

/* Forms */
.form { max-width: 680px; }
.field { margin: 0 0 1.1rem; border: 0; padding: 0; min-width: 0; }
.field label, .field legend { display: block; font-weight: 600; margin-bottom: .35rem; padding: 0; }
.field-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.field-row .field { flex: 1 1 260px; }
.field-row .field-short { flex: 0 1 160px; }
input[type="text"], input[type="url"], input[type="email"], input[type="search"], input[type="password"], input:not([type]), select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--rule); border-radius: 6px; padding: .55rem .7rem;
}
.filters input, .filters select { width: auto; min-width: 12rem; }
#selector, textarea#lines { font-family: var(--figures); font-size: .92rem; }
.method-options { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .5rem; }
.method { display: flex; align-items: center; gap: .4rem; border: 1px solid var(--rule); background: var(--surface); padding: .45rem .8rem; border-radius: 6px; cursor: pointer; font-weight: 400; }
.field .method { display: flex; font-weight: 400; margin: 0; }
.method:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.hint { color: var(--muted); font-size: .9rem; margin: .35rem 0 0; }
.check { display: flex; gap: .5rem; align-items: center; margin-bottom: 1.25rem; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .5rem; }

.test-result { border-radius: 8px; padding: 1rem 1.1rem; margin: 0 0 1.25rem; border: 1px solid var(--rule); }
.test-result p { margin: .2rem 0; }
.test-result.is-ok { background: var(--down-soft); border-color: var(--down); }
.test-result.is-error { background: var(--up-soft); border-color: var(--up); }
.test-price { font-family: var(--figures); font-size: 1.8rem; font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  padding: .55rem 1rem; border-radius: 6px; border: 1px solid var(--rule); background: var(--surface); color: var(--ink);
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { color: var(--up); }
.btn[disabled] { opacity: .65; cursor: progress; }

/* Alerts page */
.channels { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .75rem; }
.channel { background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: .8rem 1rem; display: grid; }
.channel-name { font-weight: 700; }
.channel.is-on { border-left: 5px solid var(--down); }
.channel.is-off { border-left: 5px solid var(--rule); color: var(--muted); }
.channels + .actions { margin-bottom: 2rem; }

/* Empty state & login */
.empty { max-width: 560px; padding: 3rem 0; }
.empty p { color: var(--muted); }
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login { width: min(360px, 100%); background: var(--surface); border: 1px solid var(--rule); border-radius: 12px; padding: 1.75rem; }
.login h1 { font-size: 1.3rem; margin-bottom: 1.25rem; }
.login .btn { width: 100%; }

@media (max-width: 720px) {
  .change { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name pct" "partner pct" "prices time"; row-gap: .35rem; }
  .change-time { min-width: 0; }
  .toolbar-status { margin-left: 0; width: 100%; }
  .filters input, .filters select { min-width: 0; flex: 1; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.table td:first-child { min-width: 11rem; }

/* v2: websites, rule hints */
[hidden] { display: none !important; }
.optional { font-weight: 400; color: var(--muted); font-size: .85rem; margin-left: .35rem; }
div.hint p { margin: .3rem 0 0; }
.hint .example { margin-top: .35rem; }
.hint mark { background: var(--warn-soft); color: inherit; padding: 0 .1em; border-radius: 2px; }
.test-warning { color: var(--warn); }
code.rule { white-space: normal; word-break: break-word; }
.site-tests { margin: 0 0 1.25rem; border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); padding: 1rem 1.1rem; }
.site-tests h2 { font-size: 1rem; }
.site-tests ul { list-style: none; margin: 0; padding: 0; }
.site-tests li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .1rem 1rem; padding: .55rem 0 .55rem .75rem; border-left: 4px solid var(--rule); margin-bottom: .4rem; }
.site-tests li.is-ok { border-left-color: var(--down); }
.site-tests li.is-error { border-left-color: var(--up); }
.site-test-name { font-weight: 600; }
.site-test-price { font-family: var(--figures); font-weight: 600; text-align: right; }
.site-test-note { grid-column: 1 / -1; color: var(--muted); font-size: .9rem; }
.is-error .site-test-note { color: var(--up); }
.site-tours { margin-top: 2rem; }
.danger-zone { margin-top: 2rem; padding-top: 1.25rem; border-top: 1px solid var(--rule); }

/* v3: live updates */
.livebar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; padding: .65rem 1rem; margin: 0 0 1rem;
  border-radius: 8px; background: var(--surface); border: 1px solid var(--rule); border-left: 4px solid var(--accent); }
.livebar-changed { border-left-color: var(--up); }
.livebar-done { border-left-color: var(--down); }
.livebar-warn { border-left-color: var(--warn); background: var(--warn-soft); }
.livebar-text { font-weight: 600; }
.livebar-track { flex: 1 1 160px; height: 6px; border-radius: 3px; background: var(--paper); overflow: hidden; }
.livebar-fill { display: block; height: 100%; width: 0; background: var(--accent); transition: width .6s ease; }
.toast-stack { position: fixed; right: 1rem; bottom: 1rem; display: grid; gap: .5rem; z-index: 50; max-width: min(380px, calc(100vw - 2rem)); }
.toast { display: block; padding: .8rem 1rem; border-radius: 8px; background: var(--surface); color: var(--ink); text-decoration: none;
  border: 1px solid var(--rule); border-left: 5px solid var(--accent); box-shadow: 0 6px 24px rgba(23, 42, 48, .18);
  font-family: var(--figures); font-size: .92rem; animation: toast-in .25s ease-out; }
.toast.is-up { border-left-color: var(--up); }
.toast.is-down { border-left-color: var(--down); }
.toast:hover { border-color: var(--accent); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.row-updated td { animation: row-flash 2.5s ease-out; }
@keyframes row-flash { from { background: var(--warn-soft); } to { background: transparent; } }
.link-btn { font: inherit; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .toast, .row-updated td, .livebar-fill { animation: none; transition: none; } }

/* v4: email recipients */
.recipient-add { display: flex; flex-wrap: wrap; align-items: end; gap: .75rem; margin: 0 0 1.25rem; }
.recipient-add .field { margin: 0; flex: 1 1 200px; }
.recipient-add .field:last-of-type { flex: 1 1 260px; }
.recipients select { width: auto; max-width: 100%; padding: .35rem .5rem; }
.recipients form { margin: 0; }
.recipients tr.is-paused .tour-link, .recipients tr.is-paused .tour-partner { color: var(--muted); }
.row-actions { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: flex-end; }
.btn-small { padding: .3rem .65rem; font-size: .88rem; }
#recipients { scroll-margin-top: 1rem; }
.test-all { margin: 0 0 1.25rem; }