:root {
  --navy: #12338f; --teal: #1fa8a8; --bg: #f5f7fb; --card: #fff; --ink: #172036; --muted: #5b6478; --line: #dde2ee;
  --ok: #17794a; --ok-bg: #e3f5eb; --warn: #8a5a00; --warn-bg: #fff2d6; --bad: #a3202a; --bad-bg: #fde6e8;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --navy: #8fa8ff; --teal: #3cc6c6; --bg: #0f1424; --card: #171d33; --ink: #e8ecf8; --muted: #9aa3bd; --line: #2a3350;
    --ok: #5fd39a; --ok-bg: #123a29; --warn: #f2c35b; --warn-bg: #3a2d0c; --bad: #ff8a93; --bad-bg: #40161a;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.top { background: #fff; border-bottom: 3px solid var(--teal); padding: 10px 16px; }
.brand { display: flex; align-items: center; gap: 16px; color: var(--ink); text-decoration: none; max-width: 960px; margin: 0 auto; }
.brand-sub { color: #5b6478; font-weight: 600; font-size: .95rem; padding-left: 16px; border-left: 2px solid #dde2ee; line-height: 1.2; }
.brand img { height: 45px; width: auto; display: block; }
.wrap { max-width: 960px; margin: 0 auto; padding: 20px 16px 56px; }
h1 { font-size: 1.5rem; margin: 0 0 4px; line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 28px 0 12px; }
.muted { color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid.two { grid-template-columns: 1fr 1fr; } }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-weight: 600; font-size: .92rem; }
.field .hint { color: var(--muted); font-size: .85rem; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; min-height: 44px; width: 100%;
}
textarea { min-height: 96px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
button, .btn {
  font: inherit; font-weight: 600; min-height: 44px; padding: 0 18px; border-radius: 8px; border: 1px solid var(--navy);
  background: var(--navy); color: #fff; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) button, :root:not([data-theme="light"]) .btn { color: #0f1424; } }
button.secondary, .btn.secondary { background: transparent; color: var(--navy); }
button:disabled { opacity: .6; cursor: progress; }
.full { width: 100%; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .82rem; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.none { background: var(--line); color: var(--muted); }
.error { background: var(--bad-bg); color: var(--bad); border-radius: 8px; padding: 10px 12px; margin: 0 0 12px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 12px 0 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .82rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
td a { color: var(--navy); font-weight: 650; text-decoration: none; }
.due { color: var(--bad); font-weight: 600; }
.hist { list-style: none; margin: 0; padding: 0; }
.hist li { border-left: 3px solid var(--teal); padding: 2px 0 14px 14px; margin-left: 4px; }
.hist .when { font-weight: 650; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 10px; max-width: calc(100% - 32px); z-index: 10; }
.empty { text-align: center; padding: 28px 12px; }
@media (max-width: 639px) {
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 10px; }
  table.stack td { border: 0; padding: 2px 0; }
  table.stack td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); }
}
@media (prefers-reduced-motion: no-preference) { .toast { transition: opacity .2s; } }
