:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #18212d;
  --muted: #5a6675;
  --line: #dce2e9;
  --accent: #0b6e4f;
  --accent-text: #ffffff;
  --good-bg: #e2f4ea;
  --good: #0a5c41;
  --warn-bg: #fff3d9;
  --warn: #7d4a00;
  --bad-bg: #fde8e8;
  --bad: #9b1c1c;
  --row: #f7f9fb;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141b;
    --card: #171f29;
    --text: #e7ecf2;
    --muted: #9aa7b6;
    --line: #2a3644;
    --accent: #3fbf90;
    --accent-text: #06231a;
    --good-bg: #12362a;
    --good: #86e3bd;
    --warn-bg: #3b2f12;
    --warn: #f3c672;
    --bad-bg: #401c1c;
    --bad: #ffa3a3;
    --row: #1c2632;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

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

.top, main, footer {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 16px;
}

.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-top: 20px;
}

h1 { font-size: 1.35rem; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; margin: 28px 0 10px; }
h3 { font-size: 1rem; margin: 22px 0 8px; }
p { margin: 0 0 8px; }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
}

.headline { font-size: 1.25rem; font-weight: 650; margin-bottom: 4px; }

.state-done { border-left: 5px solid var(--good); }
.state-waiting { border-left: 5px solid var(--accent); }
.state-due { border-left: 5px solid var(--warn); }
.state-paused, .state-missed { border-left: 5px solid var(--bad); }
.state-unknown { border-left: 5px solid var(--line); }

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  background: var(--row);
  color: var(--muted);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.badge.good { background: var(--good-bg); color: var(--good); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }

.notice {
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 10px;
  background: var(--warn-bg);
  color: var(--warn);
}
.notice.bad { background: var(--bad-bg); color: var(--bad); }

ul { margin: 6px 0 8px; padding-left: 20px; }
li { margin-bottom: 3px; }

.week-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 6px; }
.week-head strong { font-size: 1.02rem; }

details { margin-top: 8px; }
summary { cursor: pointer; color: var(--muted); font-size: 0.9rem; }
summary:hover { color: var(--text); }

pre {
  margin: 8px 0 0;
  padding: 12px;
  background: var(--row);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-x: auto;
  font: 0.8125rem/1.45 ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace;
  white-space: pre;
}
pre.wrap { white-space: pre-wrap; overflow-wrap: anywhere; }

.form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field.actions { flex-direction: row; gap: 8px; }
.hint { flex-basis: 100%; margin: 4px 0 0; font-size: 0.875rem; }

label { font-size: 0.875rem; font-weight: 600; }

input, select, button {
  font: inherit;
  color: inherit;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  padding: 9px 12px;
  min-height: 42px;
}
input { width: 11rem; }
input:focus-visible, select:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button {
  cursor: pointer;
  font-weight: 650;
  background: var(--accent);
  color: var(--accent-text);
  border-color: transparent;
}
button.quiet { background: transparent; color: var(--text); border-color: var(--line); font-weight: 500; }
button.link { background: none; border: none; padding: 0; min-height: 0; color: var(--accent); font-weight: 600; text-decoration: underline; }
button:disabled { opacity: 0.55; cursor: progress; }

.progress { display: flex; align-items: center; gap: 12px; }
.spinner {
  width: 18px; height: 18px; flex: none;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { border-collapse: collapse; width: 100%; font-size: 0.9375rem; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.8125rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tr.divider td { background: var(--row); color: var(--muted); font-size: 0.8125rem; font-weight: 600; padding: 4px 8px; }
td .sub { display: block; color: var(--muted); font-size: 0.8125rem; }
td .sub.narrow { display: none; }
.pos { color: var(--muted); font-size: 0.8125rem; font-weight: 600; white-space: nowrap; }
.role { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 4px; font-size: 0.75rem; font-weight: 700; background: var(--accent); color: var(--accent-text); }
.role.vice { background: var(--row); color: var(--text); border: 1px solid var(--line); }
.gain { font-weight: 650; color: var(--good); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 8px; margin-bottom: 8px; }
.tile { background: var(--row); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.tile .value { font-size: 1.2rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.tile .label { font-size: 0.8125rem; color: var(--muted); }

.recent { list-style: none; padding: 0; margin: 0; }
.recent li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.recent li:last-child { border-bottom: none; }

footer { padding-top: 12px; padding-bottom: 32px; font-size: 0.875rem; }

@media (max-width: 520px) {
  .field, .field input, .field select { width: 100%; }
  .field.actions button { flex: 1; }
  th, td { padding: 6px 5px; }
  table { font-size: 0.875rem; }
  .wide { display: none; }
  td .sub.narrow { display: block; }
}
