:root {
  --bg: #FAFAF8;
  --ink: #1A1A1A;
  --muted: #8A8A85;
  --border: #E4E4E0;
  --accent: #2B5CE6;
  --accent-soft: #EDF1FD;
  --danger: #C0392B;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

nav.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 24px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border);
}

nav.topbar .brand {
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.01em;
}

nav.topbar .links { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; font-size: 14px; }
/* On a phone the links drop below the brand instead of pushing the page wider. */
nav.topbar { flex-wrap: wrap; gap: 12px 24px; }
nav.topbar .links a.button { color: var(--ink); }

/* Breadcrumbs are plain inline links with the separator in the markup
   itself, so they read as one line even if this stylesheet is stale. */
nav.breadcrumbs { margin: -16px 0 24px; font-size: 13px; color: var(--muted); line-height: 1.8; }
nav.breadcrumbs .sep { margin: 0 3px; }
nav.breadcrumbs [aria-current="page"] { color: var(--ink); }

h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 4px; }
h2 { font-size: 18px; font-weight: 600; margin: 0 0 12px; }
.subtitle { color: var(--muted); font-size: 14px; margin: 0 0 28px; }

.messages { list-style: none; padding: 0; margin: 0 0 20px; }
.messages li {
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 14px;
  margin-bottom: 8px;
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12.5px; }
tr:last-child td { border-bottom: none; }

.btn {
  display: inline-block;
  border: none;
  background: var(--ink);
  color: var(--bg);
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { opacity: 0.85; text-decoration: none; }
.btn-secondary { background: transparent; color: var(--ink); border: 1px solid var(--border); }

form .field { margin-bottom: 18px; }
form label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
form input[type="text"], form input[type="email"], form input[type="url"],
form input[type="number"], form input[type="date"], form input[type="password"],
form textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 14.5px;
  color: var(--ink);
  font-family: inherit;
}
form select {
  width: 100%;
  border: 1px solid var(--border);
  /* Solid, not transparent: a <select>'s open option-list popup is drawn
     by the browser/OS, not the page, and doesn't reliably inherit a
     transparent background -- it tends to fall back to a system default
     (often white), which combined with var(--ink) text color can render
     as invisible white-on-white in dark mode. option { } below applies
     the same treatment to the popup's individual rows. */
  background: var(--bg);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 14.5px;
  color: var(--ink);
  font-family: inherit;
}
form select option {
  background: var(--bg);
  color: var(--ink);
}
form input:focus, form textarea:focus, form select:focus { outline: none; border-color: var(--accent); }
form .helptext { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
form ul.errorlist { list-style: none; padding: 0; margin: 4px 0 0; color: var(--danger); font-size: 13px; }

.badge {
  display: inline-block;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}
.badge.muted { background: var(--border); color: var(--muted); }

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  min-height: 1px; /* avoids a layout jump when the first chip appears */
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 4px 6px 4px 12px;
  font-size: 13px;
  line-height: 1.4;
}
.chip button {
  border: none;
  background: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 999px;
}
.chip button:hover { background: rgba(0, 0, 0, 0.08); }

.progress-track { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; width: 100px; }
.progress-fill { height: 100%; background: var(--accent); }

.empty { color: var(--muted); font-size: 14px; padding: 32px 0; text-align: center; }

.alert-warning {
  background: rgba(192, 57, 43, 0.1);
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 20px;
}

.actions-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }

.key-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--accent-soft);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  word-break: break-all;
}

/* -- Back office (admin subdomain) ------------------------------------ */

.shell.wide { max-width: 1160px; }
nav.topbar .links a.current { color: var(--ink); font-weight: 600; }
.messages li.error { background: rgba(192, 57, 43, 0.1); color: var(--danger); }
.muted { color: var(--muted); }

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin: 0 0 28px;
}
.kpi { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.kpi .label { font-size: 12.5px; color: var(--muted); }
.kpi .value { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .note { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.total td { font-weight: 600; border-top: 2px solid var(--border); }
.neg { color: var(--danger); }
.table-scroll { overflow-x: auto; }

.section { margin-top: 40px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.section-head h2 { margin: 0; }
.section-head .links { display: flex; gap: 14px; font-size: 13.5px; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 32px; }
@media (max-width: 820px) { .grid-2, .grid-main { grid-template-columns: minmax(0, 1fr); } }
.panel { border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; margin-bottom: 20px; }
.panel h2 { font-size: 15px; }

form.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 20px; }
form.toolbar .field { margin: 0; }
form.toolbar input, form.toolbar select { width: auto; padding: 7px 10px; font-size: 14px; }
form.toolbar input[type="search"] { min-width: 220px; border: 1px solid var(--border); background: transparent; border-radius: 8px; color: var(--ink); font-family: inherit; }
form.toolbar .range { display: flex; gap: 10px; align-items: flex-end; }
form.toolbar .range[hidden] { display: none; }
form.toolbar .check { display: flex; gap: 6px; align-items: center; font-size: 14px; color: var(--ink); margin: 0 0 8px; }
.period-label { font-size: 13px; color: var(--muted); margin: 0 0 9px; }

form.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
form.inline input[type="number"] { width: 100px; padding: 5px 8px; font-size: 13.5px; }
form.inline .inline-label { display: flex; flex-direction: column; gap: 2px; font-size: 11.5px; color: var(--muted); margin: 0; }
form.inline:has(.inline-label) { align-items: flex-end; }
.btn-small { padding: 5px 10px; font-size: 13px; }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.pills { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.pill { font-size: 13px; padding: 4px 11px; border-radius: 999px; border: 1px solid var(--border); color: var(--ink); }
.pill:hover { text-decoration: none; border-color: var(--accent); }
.pill.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.pill .count { color: var(--muted); margin-left: 4px; }
.pill.on .count { color: var(--bg); opacity: 0.7; }

.badge.warn { background: rgba(192, 57, 43, 0.1); color: var(--danger); }
.badge.ok { background: var(--accent-soft); color: var(--accent); }

.bar-track { background: var(--border); border-radius: 4px; height: 8px; min-width: 120px; }
.bar-fill { background: var(--accent); border-radius: 4px; height: 100%; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 12px 0; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: none; }
.timeline .meta { font-size: 12.5px; color: var(--muted); margin-bottom: 3px; }
.timeline .body { white-space: pre-line; font-size: 14px; }

.report-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; }
.report-list .panel { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.report-list .panel p { margin: 0; font-size: 13.5px; color: var(--muted); flex: 1; }
.report-list .panel .links { display: flex; gap: 14px; font-size: 13.5px; }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; font-size: 14px; }
dl.facts dt { color: var(--muted); font-size: 13px; }
dl.facts dd { margin: 0; }

.checkbox-list label { display: flex; gap: 8px; align-items: center; color: var(--ink); font-size: 14px; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Hourly weighting preview on the ad page. The equalizer itself is styled
   in ads/ad_weighting.html. */
.eq-mini { display: inline-flex; align-items: flex-end; gap: 2px; width: 168px; height: 28px; vertical-align: middle; }
.eq-mini span { flex: 1; min-height: 2px; background: var(--accent); border-radius: 1px; }
.eq-mini:hover { text-decoration: none; opacity: 0.8; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17171A; --ink: #F0F0EE; --muted: #86868C;
    --border: #2B2B30; --accent: #6E93F7; --accent-soft: #202638;
  }
}
