:root {
  color-scheme: light dark;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1b2230;
  --muted: #5d6778;
  --border: #d9dee6;
  --accent: #1f5fbf;
  --accent-text: #ffffff;
  --danger: #b3261e;
  --ok-bg: #e5f4ea;
  --ok-text: #17603a;
  --info-bg: #e7effb;
  --info-text: #1d4c91;
  --error-bg: #fbe9e7;
  --paused-bg: #f6edd9;
  --paused-text: #7a5600;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161d;
    --surface: #1b212b;
    --text: #e8ebf0;
    --muted: #a1abba;
    --border: #333c4a;
    --accent: #6ea3ee;
    --accent-text: #0e1420;
    --danger: #f2978f;
    --ok-bg: #173325;
    --ok-text: #8fd9ad;
    --info-bg: #1b2d47;
    --info-text: #a9c8f4;
    --error-bg: #3c1f1c;
    --paused-bg: #3a2f14;
    --paused-text: #e6c677;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }
h1 { margin: 0; font-size: 1.5rem; line-height: 1.25; }
h2 { margin: 0 0 12px; font-size: 1.05rem; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; }

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 24px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { color: var(--text); font-weight: 700; font-size: 1.05rem; text-decoration: none; }
.nav { display: flex; gap: 16px; }
.nav a { color: var(--muted); text-decoration: none; padding: 4px 0; border-bottom: 2px solid transparent; }
.nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.logout { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.who { color: var(--muted); }

.page { max-width: 1040px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 20px; }
.stack { display: grid; gap: 16px; max-width: 680px; }
.fields { display: grid; gap: 16px; }
.section-note { margin: -8px 0 12px; color: var(--muted); }
.empty { text-align: center; padding: 40px 20px; }
.empty h1, .empty h2 { margin-bottom: 8px; }
.empty p { color: var(--muted); margin: 0 0 16px; }
.login { max-width: 380px; margin: 48px auto; }
.login h1 { margin-bottom: 16px; }

label { display: block; font-weight: 600; margin-bottom: 4px; }
.optional { color: var(--muted); font-weight: 400; font-size: 0.87em; }
input:not([type="checkbox"]), textarea {
  width: 100%;
  padding: 8px 10px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
}
input:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
[aria-invalid="true"] { border-color: var(--danger); }
.check { display: flex; align-items: center; gap: 8px; margin: 0; }
.hint { margin: 4px 0 0; color: var(--muted); font-size: 0.87rem; }
.error { margin: 4px 0 0; color: var(--danger); font-size: 0.87rem; }
.muted { color: var(--muted); font-size: 0.87rem; }

.btn {
  display: inline-block;
  padding: 7px 12px;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.35;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { color: var(--accent-text); background: var(--accent); border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { border-color: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--danger); }
.btn-quiet { border-color: transparent; color: var(--muted); }
.form-actions { display: flex; gap: 8px; }

.flash { margin: 0 0 16px; padding: 10px 14px; border-radius: 6px; }
.flash-ok { background: var(--ok-bg); color: var(--ok-text); }
.flash-info { background: var(--info-bg); color: var(--info-text); }
.flash-error { background: var(--error-bg); color: var(--danger); }

.table-card { padding: 0; overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: 0.8rem; font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
td { overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }

.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; }
.pill-active { background: var(--ok-bg); color: var(--ok-text); }
.pill-paused { background: var(--paused-bg); color: var(--paused-text); }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 760px) {
  .topbar { padding: 12px 16px; }
  .page { padding: 16px; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  tr { display: block; padding: 8px 0; border-bottom: 1px solid var(--border); }
  tbody tr:last-child { border-bottom: 0; }
  td { display: block; padding: 6px 16px; border: 0; }
  td[data-label]::before { content: attr(data-label); display: block; color: var(--muted); font-size: 0.8rem; }
  .actions { justify-content: flex-start; padding-top: 10px; }
}

.result-ok { color: var(--ok-text); }
