:root {
  --canvas: #f4f5f3; --surface: #ffffff; --ink: #19222d; --ink-2: #4d5866; --muted: #7b8490;
  --rule: #dde1e4; --hover: #eef1f2; --focus: #2a78d6;
  --good: #0ca30c; --warn: #b77f00; --bad: #d03b3b; --idle: #a6adb5;
  --ok-bg: #e7f4e7; --err-bg: #fbe9e9;
  color-scheme: light;
}
/* Dark is the default (data-theme="dark" on <html>). "Automatic" removes data-theme so the
   device setting decides; "Light" sets data-theme="light". */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --canvas: #14171b; --surface: #1c2026; --ink: #e8eaed; --ink-2: #aab1ba; --muted: #858d97;
    --rule: #2c3138; --hover: #242931; --focus: #6da7ec; --warn: #fab219; --idle: #5b636d;
    --ok-bg: #16301a; --err-bg: #3a1c1c; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --canvas: #14171b; --surface: #1c2026; --ink: #e8eaed; --ink-2: #aab1ba; --muted: #858d97;
    --rule: #2c3138; --hover: #242931; --focus: #6da7ec; --warn: #fab219; --idle: #5b636d;
    --ok-bg: #16301a; --err-bg: #3a1c1c; color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--canvas); color: var(--ink); font: 15px/1.5 "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }

.top { background: var(--surface); border-bottom: 1px solid var(--rule); }
.top-in { max-width: 1400px; margin: 0 auto; padding: 0 24px; display: flex; align-items: center; gap: 28px; min-height: 58px; }
.brand { font-weight: 700; letter-spacing: -0.01em; text-decoration: none; display: flex; align-items: center; gap: 10px; }
.brand::before { content: ""; width: 14px; height: 14px; border-radius: 3px; background: var(--brand); }
/* With a logo set, a small copy replaces the colored square: 28 px tall, at most 112 px wide */
.brand.has-logo::before { content: none; }
.brand-logo { display: block; height: 28px; width: auto; max-width: 112px; object-fit: contain; flex: none; }
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a { white-space: nowrap; text-decoration: none; padding: 6px 10px; border-radius: 6px; color: var(--ink-2); font-weight: 500; }
.nav a:hover { background: var(--hover); color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--brand); border-radius: 0; }
.who { display: flex; align-items: center; gap: 12px; font-size: 13.5px; color: var(--ink-2); }
.who form { margin: 0; }
/* Keep the menu on one line: drop the signed-in address before anything wraps */
@media (max-width: 1400px) { .who .who-email { display: none; } .top-in { gap: 20px; } }

main.wrap { max-width: 1240px; margin: 0 auto; padding: 28px 24px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: 26px; letter-spacing: -0.02em; }
.page-head p { margin: 4px 0 0; color: var(--ink-2); max-width: 70ch; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.actions form { margin: 0; display: flex; gap: 8px; align-items: center; }

.btn { font: inherit; font-weight: 600; font-size: 14px; border-radius: 7px; padding: 8px 14px; border: 1px solid var(--rule);
  background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.link { border: 0; background: none; padding: 0; font-weight: 500; color: var(--ink-2); text-decoration: underline; text-underline-offset: 2px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: 7px; padding: 8px 10px; max-width: 100%; }
textarea { width: 100%; min-height: 150px; line-height: 1.55; }
label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.hint { color: var(--muted); font-size: 13px; }

.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; }
.panel-pad { padding: 20px 22px; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; background: var(--ok-bg); }
.flash.error { background: var(--err-bg); }

table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
.grid th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--ink-2); padding: 10px 12px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.grid td { padding: 11px 12px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.grid tr:last-child td { border-bottom: 0; }
.grid tbody tr:hover { background: var(--hover); }
.grid .name { font-weight: 600; }
.grid .name a { text-decoration: none; }
.grid .name a:hover { text-decoration: underline; }
.scroll { overflow-x: auto; }

.dot { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--idle); }
.dot.ok::before { background: var(--good); }
.dot.error::before { background: var(--bad); }
.dot.unmapped::before, .dot.missing::before { background: transparent; box-shadow: inset 0 0 0 1.5px var(--idle); }
.dot.demo::before { background: var(--warn); }
.tag { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--hover); color: var(--ink-2); white-space: nowrap; }
.tag.pub { background: var(--ok-bg); color: var(--good); }

.platforms { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13.5px; color: var(--ink-2); margin-bottom: 18px; }
.running { display: inline-flex; gap: 8px; align-items: center; color: var(--ink-2); font-size: 14px; }
.running::before { content: ""; width: 12px; height: 12px; border: 2px solid var(--rule); border-top-color: var(--brand); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .running::before { animation: none; } }

/* mapping */
.map select { width: 100%; min-width: 170px; }
.map select.suggested { border-color: var(--warn); box-shadow: 0 0 0 1px var(--warn); }
.map .score { font-size: 12px; color: var(--warn); }
.sticky-save { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--rule); padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; border-radius: 0 0 10px 10px; }

/* report pages */
.report-shell { display: grid; grid-template-columns: 1fr 300px; gap: 24px; align-items: start; }
.report-paper { background: #fff; border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; }
.side-tools { display: grid; gap: 16px; }
.side-tools h2 { font-size: 15px; margin: 0 0 10px; }
.src-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 13.5px; }
.src-list li { display: flex; justify-content: space-between; gap: 8px; }
.src-list a { font-size: 12.5px; color: var(--muted); }
.months { display: flex; gap: 6px; flex-wrap: wrap; }
.months a { text-decoration: none; font-size: 13.5px; padding: 5px 10px; border-radius: 6px; border: 1px solid var(--rule); background: var(--surface); }
.months a[aria-current="page"] { background: var(--brand); color: #fff; border-color: var(--brand); }

/* switch */
.switch { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; font-weight: 600; cursor: pointer; margin: 0; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 38px; height: 22px; border-radius: 99px; background: var(--idle); position: relative; transition: background .15s; margin-top: 1px; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked + .track { background: var(--good); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--focus); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .switch .track, .switch .track::after { transition: none; } }
.rule { border: 0; border-top: 1px solid var(--rule); margin: 18px 0; }
.sub { font-size: 13.5px; margin: 18px 0 8px; }
.hist { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; font-size: 13.5px; }
.hist li { display: grid; gap: 1px; }
.warn-box { background: var(--err-bg); border-radius: 8px; padding: 10px 12px; font-size: 13.5px; margin-bottom: 10px; }
.warn-box ul { margin: 4px 0 0; padding-left: 18px; }
.tag.auto { background: var(--ok-bg); color: var(--good); }
.tag.warn { background: var(--err-bg); color: var(--bad); }

/* login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth .panel { width: 100%; max-width: 460px; padding: 32px; }
.auth h1 { font-size: 22px; margin: 0 0 4px; }
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.auth-brand p { margin: 0; }
.auth-brand img { height: 3.4em; width: auto; max-width: 45%; object-fit: contain; flex: none; display: block; }
@media (max-width: 420px) {
  .auth { padding: 16px; }
  .auth .panel { padding: 24px 20px; }
}
.auth input { width: 100%; }
.auth .btn { width: 100%; justify-content: center; margin-top: 6px; }
.err { color: var(--bad); font-size: 14px; margin: 0 0 12px; }

.two { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.empty-state { text-align: center; padding: 48px 24px; color: var(--ink-2); }
.empty-state h2 { color: var(--ink); margin: 0 0 6px; font-size: 19px; }

@media (max-width: 980px) {
  .report-shell { grid-template-columns: 1fr; }
  .side-tools { position: static; }
}
@media (max-width: 720px) {
  .top-in { flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .who .who-email { display: none; }
  main.wrap { padding: 20px 16px 48px; }
  .two { grid-template-columns: 1fr; }
  .grid .hide-sm { display: none; }
}
@media print {
  .site-foot { display: none; }
  body { padding-bottom: 0; }
  .top, .side-tools, .flash, .page-head, .no-print { display: none !important; }
  body, main.wrap { background: #fff; padding: 0; margin: 0; max-width: none; }
  .report-shell { display: block; }
  .report-paper { border: 0; border-radius: 0; }
}

/* SQLBackupAndFTP setup */
.steps { margin: 0 0 14px; padding-left: 20px; display: grid; gap: 12px; }
.copy { display: flex; gap: 8px; align-items: flex-start; margin-top: 6px; background: var(--hover); border-radius: 8px; padding: 10px; }
.copy code, .copy pre { flex: 1; min-width: 0; margin: 0; font-size: 12.5px; white-space: pre-wrap; word-break: break-all; }
.grid-stack { display: grid; gap: 20px; }

/* configuration */
.cfg-nav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.cfg-nav a { text-decoration: none; font-size: 14px; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--rule); background: var(--surface); }
.cfg-nav a:hover { background: var(--hover); }
.cfg { display: grid; gap: 20px; max-width: 900px; }
.cfg-sec { padding: 22px 24px; scroll-margin-top: 16px; }
.cfg-sec header h2 { margin: 0; font-size: 18px; }
.cfg-sec header p { margin: 4px 0 0; }
.cfg-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 24px; margin-top: 18px; }
.cfg-row { min-width: 0; }
.cfg-row[hidden] { display: none; }
.cfg-row input:not([type=checkbox]):not([type=color]), .cfg-row select { width: 100%; }
.cfg-row .hint, .cfg-row .err { margin: 4px 0 0; }
.cfg-row.has-error input, .cfg-row.has-error select { border-color: var(--bad); }
.cfg-row .switch { font-weight: 600; }
label.inline { display: flex; gap: 6px; align-items: center; font-weight: 400; font-size: 13px; color: var(--ink-2); margin: 6px 0 0; }
.src-note { display: block; font-size: 13px; color: var(--muted); margin-top: 4px; }
.color-pick { display: flex; align-items: center; gap: 10px; }
.color-pick input { width: 44px; height: 36px; padding: 2px; }
.cfg-actions { margin-top: 18px; }
.cfg-save { position: sticky; bottom: 0; background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 12px 16px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px; }
@media (max-width: 720px) { .cfg-fields { grid-template-columns: 1fr; } }

.logo-upload { display: grid; grid-template-columns: 180px 1fr; gap: 20px; align-items: start; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--rule); }
.logo-preview { height: 96px; border: 1px dashed var(--rule); border-radius: 8px; display: grid; place-items: center; padding: 10px;
  background: repeating-conic-gradient(var(--hover) 0% 25%, transparent 0% 50%) 50% / 16px 16px; }
.logo-preview img { max-height: 76px; max-width: 158px; width: auto; height: auto; object-fit: contain; }
.logo-upload input[type=file] { width: 100%; }
.logo-upload.has-error input[type=file] { border-color: var(--bad); }
@media (max-width: 720px) { .logo-upload { grid-template-columns: 1fr; } }

/* theme toggle */
.theme-toggle { display: inline-flex; border: 1px solid var(--rule); border-radius: 8px; padding: 2px; gap: 2px; background: var(--surface); }
.theme-toggle button { display: inline-grid; place-items: center; width: 28px; height: 26px; padding: 0; border: 0; border-radius: 6px;
  background: transparent; color: var(--muted); cursor: pointer; }
.theme-toggle button:hover { color: var(--ink); background: var(--hover); }
.theme-toggle button[aria-pressed="true"] { color: var(--ink); background: var(--hover); box-shadow: inset 0 0 0 1px var(--rule); }
.theme-toggle svg { width: 16px; height: 16px; }
/* Footer pinned to the bottom of the window. The bar spans the full width and matches the header
   (same background, same line colour as the header's bottom border); its text lines up with the page
   content (same width and side padding as main.wrap). Build on the left (staff only), copyright right. */
:root { --foot-h: 40px; }
body { padding-bottom: var(--foot-h); }
.site-foot { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 0 24px;
  background: var(--surface); border-top: 1px solid var(--rule); }
.site-foot-in { max-width: 1192px; margin: 0 auto; height: var(--foot-h); box-sizing: border-box;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  color: var(--ink-2); font-size: 12.5px; }
.sticky-save, .cfg-save { bottom: calc(var(--foot-h) + 1px); }
@media (max-width: 980px) { .site-foot { padding: 0 16px; } }
/* Add or remove clients */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--rule); margin: 0 0 16px; }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--ink-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--brand); }
.pick-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: 0 0 14px; flex-wrap: wrap; }
.pick-head .hint { max-width: 760px; }
.pick-bar { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-bottom: 1px solid var(--rule); flex-wrap: wrap; }
.pick-search { flex: 1 1 260px; max-width: 420px; }
.pick-bar .btn { margin-left: auto; }
.pick .pick-none { padding: 14px 16px; margin: 0; }
.pick tbody tr:has(input:checked) { background: var(--hover); }
.pick-bar label.inline { margin: 0; }
.pick [hidden] { display: none !important; }
/* Configuration tabs */
.cfg-tabs { max-width: 900px; }
.cfg-sec[hidden], .cfg-nav [hidden] { display: none !important; }
.by-name { margin: 0 0 16px; }
/* Messages at the bottom of the window (Client mapping): above the save bar and footer, fade after 10 s */
.toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--foot-h) + 76px); z-index: 30; padding: 0 24px;
  display: grid; gap: 8px; pointer-events: none; }
.toast { max-width: 1192px; width: 100%; margin: 0 auto; box-sizing: border-box; pointer-events: auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .25); transition: opacity .6s ease; }
.toast.fading { opacity: 0; }
.toast-x { border: 0; background: none; color: inherit; font-size: 18px; line-height: 1; cursor: pointer; padding: 0 2px; opacity: .7; }
.toast-x:hover { opacity: 1; }
@media (max-width: 980px) { .toasts { padding: 0 16px; } }
