:root {
  color-scheme: light dark;
  --bg: #f4f4f2;
  --surface: #ffffff;
  --surface-2: #fafaf9;
  --line: #ececea;
  --line-2: #e4e4e7;
  --text: #18181b;
  --text-2: #52525b;
  --muted: #71717a;
  --faint: #a1a1aa;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --accent-text: #3730a3;
  --ok: #22c55e;
  --warn: #f59e0b;
  --lock-bg: #fef3c7;
  --lock-text: #92400e;
  --alert-bg: #fef2f2;
  --alert-text: #991b1b;
  --btn-bg: #18181b;
  --btn-text: #ffffff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 12px 32px -12px rgba(0, 0, 0, .18);
  --admin-bg: #ede9fe;
  --admin-text: #5b21b6;
  --viewer-bg: #f4f4f5;
  --viewer-text: #3f3f46;
  --note-bg: #f0fdf4;
  --note-text: #166534;
  --ok-text: #15803d;
  --warn-text: #b45309;
  --bad-text: #b91c1c;
}

/* Theme: light tokens on :root; dark under the OS preference unless the person chose light,
   and again when they chose dark (data-theme on <html>, set by theme.js). color-scheme is
   inherited by the report iframe, so the report's prefers-color-scheme follows the choice. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f0f12;
    --surface: #18181b;
    --surface-2: #131316;
    --line: #27272a;
    --line-2: #3f3f46;
    --text: #f4f4f5;
    --text-2: #d4d4d8;
    --muted: #a1a1aa;
    --faint: #71717a;
    --accent: #818cf8;
    --accent-soft: #1e1b4b;
    --accent-text: #c7d2fe;
    --lock-bg: #422006;
    --lock-text: #fcd34d;
    --alert-bg: #450a0a;
    --alert-text: #fecaca;
    --btn-bg: #f4f4f5;
    --btn-text: #18181b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px -12px rgba(0, 0, 0, .6);
    --admin-bg: #2e1065;
    --admin-text: #ddd6fe;
    --viewer-bg: #27272a;
    --viewer-text: #d4d4d8;
    --note-bg: #052e16;
    --note-text: #bbf7d0;
    --ok-text: #4ade80;
    --warn-text: #fbbf24;
    --bad-text: #f87171;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f0f12;
  --surface: #18181b;
  --surface-2: #131316;
  --line: #27272a;
  --line-2: #3f3f46;
  --text: #f4f4f5;
  --text-2: #d4d4d8;
  --muted: #a1a1aa;
  --faint: #71717a;
  --accent: #818cf8;
  --accent-soft: #1e1b4b;
  --accent-text: #c7d2fe;
  --lock-bg: #422006;
  --lock-text: #fcd34d;
  --alert-bg: #450a0a;
  --alert-text: #fecaca;
  --btn-bg: #f4f4f5;
  --btn-text: #18181b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px -12px rgba(0, 0, 0, .6);
  --admin-bg: #2e1065;
  --admin-text: #ddd6fe;
  --viewer-bg: #27272a;
  --viewer-text: #d4d4d8;
  --note-bg: #052e16;
  --note-text: #bbf7d0;
  --ok-text: #4ade80;
  --warn-text: #fbbf24;
  --bad-text: #f87171;
}

:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 Inter, system-ui, sans-serif; }
a { color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
.sp { flex: 1; }

/* header */
.top { display: flex; align-items: center; gap: 18px; padding: 12px 20px; border-bottom: 1px solid var(--line);
  background: var(--surface); font-size: 13px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; text-decoration: none; color: var(--text); }
.logo { width: 22px; height: 22px; border-radius: 6px; display: block; flex: none; }
.nav { display: flex; gap: 14px; }
.nav a { text-decoration: none; color: var(--text-2); }
.nav a:hover { color: var(--text); }
.run { color: var(--muted); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.dot-ok { background: var(--ok); }
.dot-warn { background: var(--warn); }
.dot-none { background: var(--faint); }
.pill { border: 1px solid var(--line-2); border-radius: 99px; padding: 3px 10px; background: var(--surface);
  font-size: 12px; text-decoration: none; color: var(--text); white-space: nowrap; }
.signout { margin: 0; }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); cursor: pointer; text-decoration: underline; }
button.link:hover { color: var(--text); }
.theme { display: inline-flex; border: 1px solid var(--line-2); border-radius: 99px; padding: 2px; background: var(--surface); }
.theme button { background: none; border: 0; border-radius: 99px; padding: 2px 9px; font: inherit; font-size: 12px;
  color: var(--muted); cursor: pointer; }
.theme button:hover { color: var(--text); }
.theme button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.theme button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.signin .theme { margin-top: 16px; }

/* home */
.home { max-width: 1180px; margin: 0 auto; padding: 24px 20px 60px; }
.area h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin: 8px 2px 12px; }
.area + .area { margin-top: 28px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.card h3 { margin: 0; font-size: 14px; }
.card .meta { font-size: 12px; color: var(--muted); }
.card .desc { font-size: 12px; color: var(--text-2); margin: 6px 0 0; }
.highlights { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 10px 0;
  padding: 10px; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: var(--text); }
a.highlights:hover { border-color: var(--accent); }
.hl { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hl-value { font-size: 18px; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.hl-change { font-size: 11px; color: var(--muted); }
.hl-label { font-size: 11px; line-height: 1.35; color: var(--text-2); overflow-wrap: anywhere; }
.ver { font-size: 12px; color: var(--text-2); display: flex; justify-content: space-between; border-top: 1px solid var(--line);
  padding: 6px 0 2px; margin-top: 4px; text-decoration: none; }
.ver:hover span:last-child { color: var(--accent); }
.lock { font-size: 11px; background: var(--lock-bg); color: var(--lock-text); border-radius: 5px; padding: 1px 6px; font-weight: 500; vertical-align: 1px; }

/* report frame */
body.framed { display: flex; flex-direction: column; height: 100vh; }
.bar { display: flex; align-items: center; gap: 12px; padding: 8px 20px; font-size: 12px; color: var(--muted);
  border-bottom: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }
.bar b { color: var(--text); font-size: 14px; }
.back { text-decoration: none; color: var(--text-2); }
.picker { position: relative; }
.picker summary { list-style: none; cursor: pointer; }
.picker summary::-webkit-details-marker { display: none; }
.picker ul { position: absolute; right: 0; top: 28px; z-index: 5; list-style: none; margin: 0; padding: 6px; min-width: 220px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow); max-height: 60vh; overflow: auto; }
.picker li a { display: flex; justify-content: space-between; gap: 12px; padding: 6px 8px; border-radius: 7px; text-decoration: none; color: var(--text-2); }
.picker li a:hover { background: var(--surface-2); }
.picker li a.on { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
iframe.report { flex: 1; width: 100%; border: 0; background: var(--bg); }

/* sign in */
body.center { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.signin { width: 100%; max-width: 380px; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); padding: 24px; }
.signin h1 { font-size: 18px; margin: 18px 0 4px; }
.signin p { margin: 0 0 10px; }
.in { display: block; width: 100%; border: 1px solid var(--line-2); border-radius: 8px; padding: 9px 10px; margin: 6px 0;
  font: inherit; color: var(--text); background: var(--surface); }
.in:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.in.code { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 18px; letter-spacing: .4em; }
.btn { display: block; width: 100%; background: var(--btn-bg); color: var(--btn-text); border: 0; border-radius: 8px;
  padding: 9px 10px; margin-top: 8px; font: inherit; font-weight: 600; cursor: pointer; }
.again { margin-top: 14px; font-size: 12px; color: var(--muted); }
.fine { font-size: 11px; color: var(--faint); margin-top: 12px !important; }
.alert { background: var(--alert-bg); color: var(--alert-text); border-radius: 8px; padding: 8px 10px; font-size: 13px; }

/* admin */
.admin { max-width: 1080px; margin: 0 auto; padding: 24px 20px 60px; }
.admin h1 { font-size: 18px; margin: 0 0 14px; }
.admin .note { background: var(--note-bg); color: var(--note-text); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.row-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.row-form .in { width: auto; margin: 0; }
.row-form .in[type=email] { flex: 1; min-width: 200px; }
.row-form .btn, .btn.compact { width: auto; margin: 0; padding: 8px 14px; }
form.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.in.small { display: inline-block; width: auto; padding: 4px 6px; margin: 0; font-size: 12px; }
.in.mono, code { font-family: "JetBrains Mono", ui-monospace, monospace; }
.check { font-size: 12px; color: var(--text-2); display: inline-flex; gap: 4px; align-items: center; }
.scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl th { color: var(--muted); font-weight: 500; font-size: 12px; }
.tbl .num { font-variant-numeric: tabular-nums; }
.tbl .actions { display: flex; gap: 12px; }
.role { border-radius: 5px; padding: 1px 6px; font-size: 11px; font-weight: 500; }
.role-admin { background: var(--admin-bg); color: var(--admin-text); }
.role-viewer, .status-active { background: var(--viewer-bg); color: var(--viewer-text); }
.status-invited { background: var(--lock-bg); color: var(--lock-text); }
.status-disabled { background: var(--alert-bg); color: var(--alert-text); }
button.link.danger { color: var(--bad-text); }
.st-published, .st-published_with_warning { color: var(--ok-text); }
.st-held, .st-waiting, .st-queued, .st-running { color: var(--warn-text); }
.st-failed { color: var(--bad-text); }
.job + .job { margin-top: 24px; }
.job-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; font-size: 12px; }
.job-head h2 { font-size: 14px; margin: 0; }

@media (max-width: 640px) {
  .admin { padding: 18px 16px 40px; }
  .top { gap: 10px; padding: 10px 16px; }
  .run { order: 5; width: 100%; }
  .home { padding: 18px 16px 40px; }
  .bar { padding: 8px 16px; }
}
