:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e3e6eb;
  --border-strong: #cfd4dc;
  --text: #1b1f24;
  --muted: #667085;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #e8efff;
  --ok: #15803d;
  --ok-soft: #e7f6ec;
  --warn: #b45309;
  --warn-soft: #fdf3e2;
  --bad: #c62828;
  --bad-soft: #fdecec;
  --info: #1d4ed8;
  --info-soft: #e8efff;
  --idle: #8a94a6;
  --idle-soft: #eef0f3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #171b21;
    --surface-2: #1e232b;
    --border: #2a303a;
    --border-strong: #38404c;
    --text: #e6e9ee;
    --muted: #97a0af;
    --accent: #5b8cff;
    --accent-hover: #7aa2ff;
    --accent-soft: #1c2a4a;
    --ok: #4ade80;
    --ok-soft: #15291d;
    --warn: #fbbf24;
    --warn-soft: #2e2512;
    --bad: #f87171;
    --bad-soft: #321a1b;
    --info: #7aa2ff;
    --info-soft: #1c2a4a;
    --idle: #7c8698;
    --idle-soft: #232830;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 22px; font-weight: 650; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 15px; font-weight: 600; }
h3 { font-size: 13px; font-weight: 600; margin-top: 14px; }
p { margin: 4px 0 0; }
.muted { color: var(--muted); }
a.muted:hover { color: var(--text); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: .92em; }
.ok { color: var(--ok); }
.bad { color: var(--bad); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.inline { display: inline; }

/* ---------- layout ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: 0 16px; height: 56px; display: flex; align-items: center; gap: 28px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; color: var(--text); font-size: 15px; }
.brand:hover { text-decoration: none; }
.brand svg, .login-brand svg { width: 22px; height: 22px; fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a { color: var(--muted); padding: 6px 12px; border-radius: 8px; font-weight: 500; }
.topbar nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.topbar nav a.active { color: var(--text); background: var(--surface-2); }
.logout { margin-left: auto; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 24px 16px 64px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.stack > * + * { margin-top: 14px; }
.stack-xs > * + * { margin-top: 2px; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card > h2 { margin-bottom: 12px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.card-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stats-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.stats-7 { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.gcs-link { white-space: nowrap; }
.gcs-path { margin: -6px 0 16px; word-break: break-all; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat-value.sm { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-sub { font-size: 12px; color: var(--muted); }

.callout { border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; border: 1px solid; }
.callout ul { margin: 6px 0 0; padding-left: 20px; }
.callout-warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.callout-bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.error-text { margin: 6px 0 0; white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: 12.5px; }

.attention-list { list-style: none; margin: 0; padding: 0; }
.attention-list li { display: flex; align-items: baseline; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.attention-list li:first-child { border-top: 0; padding-top: 0; }

.checks ul { list-style: none; margin: 0 0 8px; padding: 0; }
.checks li { padding: 5px 0; display: flex; gap: 10px; word-break: break-word; }
.checks li.ok { color: var(--text); }
.checks li.bad { color: var(--bad); }
.check-icon { font-weight: 700; width: 14px; flex: none; }
.checks li.ok .check-icon { color: var(--ok); }

/* ---------- key/value ---------- */
.kv { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 10px 16px; margin: 0; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; min-width: 0; word-break: break-word; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.row-title { font-weight: 600; color: var(--text); }
.row-muted .row-title { color: var(--muted); }
.err-line { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--bad); }

/* ---------- pills & run strip ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; line-height: 1.6; vertical-align: middle; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-success, .pill-ok { color: var(--ok); background: var(--ok-soft); }
.pill-failed { color: var(--bad); background: var(--bad-soft); }
.pill-partial, .pill-overdue { color: var(--warn); background: var(--warn-soft); }
.pill-running, .pill-queued { color: var(--info); background: var(--info-soft); }
.pill-running::before { animation: pulse 1.2s ease-in-out infinite; }
.pill-never, .pill-disabled { color: var(--idle); background: var(--idle-soft); }
.pill-default { color: var(--accent); background: var(--accent-soft); }
.pill-default::before { display: none; }
h1 .pill { font-size: 12px; }

.strip { display: flex; gap: 3px; align-items: center; min-height: 20px; }
.tick { width: 8px; height: 20px; border-radius: 2px; background: var(--idle); display: block; }
.strip-lg .tick { width: 12px; height: 24px; }
.tick:hover { transform: scaleY(1.15); text-decoration: none; }
.tick-success { background: var(--ok); }
.tick-failed { background: var(--bad); }
.tick-partial { background: var(--warn); }
.tick-running, .tick-queued { background: var(--info); animation: pulse 1.2s ease-in-out infinite; }

@keyframes pulse { 50% { opacity: .35; } }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; font: inherit; font-weight: 550; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-link { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 6px 8px; }
.btn-link:hover { color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- forms ---------- */
.form fieldset { border: 0; padding: 0; margin: 0 0 22px; }
.form legend { font-weight: 600; font-size: 15px; margin-bottom: 10px; padding: 0; }
.form label, .login label { display: flex; flex-direction: column; gap: 5px; font-weight: 500; font-size: 13px; margin-bottom: 14px; }
.form label.check, label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; font-size: 14px; }
input, select, textarea { font: inherit; font-size: 14px; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; padding: 7px 10px; width: 100%; min-width: 0; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.hint { font-weight: 400; font-size: 12px; color: var(--muted); }
.field-error { font-weight: 500; font-size: 12px; color: var(--bad); }
.req { color: var(--bad); }
.row-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; }
.row-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.presets { display: flex; flex-direction: column; gap: 6px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font: inherit; font-size: 12px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.fieldset-hint { margin: -4px 0 12px; }
.radio-cards-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tier-list { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.tier-list li { margin: 2px 0; }
.kind-tag { display: inline-block; font-size: 11px; font-weight: 600; color: var(--muted); border: 1px solid var(--border-strong); border-radius: 4px; padding: 0 5px; margin-left: 6px; vertical-align: 1px; }
.radio-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.radio-card { flex-direction: row !important; align-items: flex-start; gap: 10px !important; padding: 12px 14px; border: 1px solid var(--border-strong); border-radius: 8px; cursor: pointer; margin: 0 !important; }
.radio-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.radio-card input { width: 16px; height: 16px; margin-top: 2px; flex: none; accent-color: var(--accent); }
.radio-card > span { display: flex; flex-direction: column; gap: 4px; font-weight: 400; }
.radio-card strong { font-size: 14px; font-weight: 600; }
.fieldset-details { margin: 0 0 22px; border-top: 1px solid var(--border); padding-top: 16px; }
.fieldset-details summary { cursor: pointer; font-weight: 600; font-size: 15px; margin-bottom: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--border); padding-top: 16px; }
.filters { display: flex; gap: 8px; }
.filters select { width: auto; min-width: 170px; }
.help p { color: var(--muted); font-size: 13px; }

/* ---------- misc ---------- */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; word-break: break-word; }
.flash-success { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.flash-info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.flash-warning { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.flash-error { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }

.log { margin: 0; padding: 16px 20px; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; max-height: 70vh; overflow: auto; background: var(--surface-2); }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--info); font-weight: 600; }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pulse 1.2s ease-in-out infinite; }

.empty { text-align: center; padding: 48px 24px; }
.empty h2 { font-size: 17px; }
.empty p { max-width: 480px; margin: 8px auto 18px; }
.small-empty { padding: 24px; }
.small-empty p { margin: 0 auto; }
.pager { display: flex; justify-content: center; align-items: center; gap: 14px; }

.login { max-width: 360px; margin: 10vh auto 0; }
.login-brand { text-align: center; margin-bottom: 20px; }
.login-brand svg { width: 36px; height: 36px; }
.login-brand h1 { justify-content: center; margin-top: 8px; }

@media (max-width: 900px) {
  .stats, .stats-6, .stats-7 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .row-2, .row-3, .radio-cards { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .topbar-inner { gap: 12px; }
  .brand span { display: none; }
  .topbar nav a { padding: 6px 8px; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .kv dd { margin-bottom: 10px; }
  .filters { width: 100%; }
  .filters select { flex: 1; min-width: 0; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; }
}
