/* SPDX-License-Identifier: MIT */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1a1d24;
  --muted: #4a5263;
  --border: #cfd5de;
  --primary: #1d5bb8;
  --on-primary: #ffffff;
  --focus: #1d5bb8;
  --ok-bg: #e2f3e7; --ok: #16592c;
  --warn-bg: #fff1d1; --warn: #6e4400;
  --bad-bg: #fde4e4; --bad: #9c1818;
  --info-bg: #e3ecfb; --info: #1b4a91;
  --neutral-bg: #eceef2; --neutral: #39404d;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1217; --surface: #171b22; --text: #e8ebf0; --muted: #aab3c2; --border: #333b47;
    --primary: #8ab6ff; --on-primary: #0b1220; --focus: #8ab6ff;
    --ok-bg: #12331f; --ok: #8fe0a8; --warn-bg: #382806; --warn: #f3c86a; --bad-bg: #3b1515; --bad: #ffa3a3;
    --info-bg: #13294a; --info: #a3c6ff; --neutral-bg: #252b35; --neutral: #cbd2dc;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1217; --surface: #171b22; --text: #e8ebf0; --muted: #aab3c2; --border: #333b47;
  --primary: #8ab6ff; --on-primary: #0b1220; --focus: #8ab6ff;
  --ok-bg: #12331f; --ok: #8fe0a8; --warn-bg: #382806; --warn: #f3c86a; --bad-bg: #3b1515; --bad: #ffa3a3;
  --info-bg: #13294a; --info: #a3c6ff; --neutral-bg: #252b35; --neutral: #cbd2dc;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--primary); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0.5rem 0 0.75rem; }
h2 { font-size: 1.2rem; margin: 2rem 0 0.75rem; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; overflow-wrap: anywhere; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }

.top { background: var(--surface); border-bottom: 1px solid var(--border); }
.top-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding-top: 12px; padding-bottom: 8px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.brand svg { color: var(--primary); }
.nav { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.nav a { display: inline-block; padding: 8px 12px; border-radius: 8px; color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--info-bg); color: var(--info); font-weight: 600; }
.settings { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; padding-bottom: 12px; font-size: 0.9rem; color: var(--muted); }
.role-form { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.switch { display: flex; gap: 2px; }
.switch a { padding: 6px 8px; border-radius: 6px; color: var(--muted); min-height: 32px; display: inline-flex; align-items: center; }
.switch a[aria-current="true"] { color: var(--text); font-weight: 600; background: var(--neutral-bg); text-decoration: none; }

main { padding-bottom: 32px; }
.notice { margin: 16px 0 0; padding: 8px 12px; border-left: 4px solid var(--primary); background: var(--info-bg); color: var(--info); border-radius: 6px; font-size: 0.9rem; }
.lead { color: var(--muted); font-size: 1.05rem; margin-top: 0; }
.hint { color: var(--muted); font-size: 0.9rem; margin: 4px 0 0; }
.cards { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 12px; grid-template-columns: 1fr; }
.card, .panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card h2 { margin-top: 0; font-size: 1.1rem; }
.card p { color: var(--muted); }
.panel { margin-top: 24px; }
.panel h2 { margin-top: 0; }
.row { display: flex; flex-wrap: wrap; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 18px;
  border: 1px solid var(--primary); border-radius: 8px; background: var(--primary); color: var(--on-primary);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn.secondary { background: transparent; color: var(--primary); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 0.9rem; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
th, td { text-align: left; vertical-align: top; padding: 10px 12px; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: 0; }
th { font-weight: 600; color: var(--muted); background: var(--bg); }
.call { color: var(--muted); }
.err { color: var(--bad); margin: 4px 0 0; font-size: 0.85rem; }
.inline { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.82rem; font-weight: 600; white-space: nowrap; background: var(--neutral-bg); color: var(--neutral); }
.b-completed, .s-done, .r-ok { background: var(--ok-bg); color: var(--ok); }
.b-pending_approval, .s-manual, .r-retry, .r-manual { background: var(--warn-bg); color: var(--warn); }
.b-failed, .s-failed, .r-error { background: var(--bad-bg); color: var(--bad); }
.b-approved, .s-skipped, .r-skipped { background: var(--info-bg); color: var(--info); }

.summary { display: grid; grid-template-columns: 1fr; gap: 0; margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.summary div { padding: 10px 16px; border-bottom: 1px solid var(--border); }
.summary div:last-child { border-bottom: 0; }
.summary dt { font-size: 0.85rem; color: var(--muted); }
.summary dd { margin: 0; overflow-wrap: anywhere; }

.form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: grid; gap: 16px; }
.field { display: grid; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field label, legend { font-weight: 600; }
input[type="text"], input[type="date"], select {
  width: 100%; min-height: 44px; padding: 8px 10px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--muted); border-radius: 8px;
}
.settings select { width: auto; min-height: 36px; padding: 4px 8px; }
[aria-invalid="true"] { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad); }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.check input { width: 22px; height: 22px; accent-color: var(--primary); }
.grid2 { display: grid; gap: 16px; grid-template-columns: 1fr; }
.alert { border: 1px solid var(--bad); background: var(--bad-bg); color: var(--bad); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; }
.alert h2 { margin: 0 0 4px; font-size: 1rem; }
.alert p { margin: 0; }

.foot { border-top: 1px solid var(--border); padding-top: 16px; padding-bottom: 32px; color: var(--muted); font-size: 0.9rem; }
.foot p { margin: 4px 0; }

@media (min-width: 720px) {
  h1 { font-size: 2rem; }
  .cards { grid-template-columns: repeat(3, 1fr); }
  .grid2 { grid-template-columns: 1fr 1fr; }
  .summary { grid-template-columns: 1fr 1fr; }
  .summary div:nth-last-child(2):nth-child(odd) { border-bottom: 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
