:root {
  --bg: #f4f7f9;
  --card: #ffffff;
  --ink: #1c2733;
  --muted: #5f7183;
  --line: #e2e8ee;
  --brand: #1f7a8c;
  --ok: #1a9e6a;
  --ok-bg: #e6f6ee;
  --warn: #d64545;
  --warn-bg: #fceaea;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(28, 39, 51, 0.08);
}
* { box-sizing: border-box; margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--bg); line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
.wrap { width: 100%; max-width: 640px; margin: 0 auto; padding: 0 16px; }

.topbar { background: var(--brand); color: #fff; padding: 22px 0 20px; }
.topbar h1 { font-size: 1.35rem; letter-spacing: 0.2px; }
.tagline { color: #d6eef2; opacity: 0.92; font-size: 0.92rem; margin-top: 4px; }

.tabs { display: flex; gap: 8px; margin: 16px auto 0; }
.tab {
  flex: 1; padding: 12px; border: 1px solid var(--line); background: var(--card);
  border-radius: 999px; font-size: 1rem; font-weight: 600; color: var(--muted);
  cursor: pointer;
}
.tab[aria-selected="true"] { background: var(--brand); color: #fff; border-color: var(--brand); }

main { padding: 16px 0 8px; }
.panel { display: flex; flex-direction: column; gap: 14px; }

.summary {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px; display: flex; align-items: baseline; gap: 12px;
}
.summary-status {
  font-size: 1.5rem; font-weight: 800; padding: 2px 12px; border-radius: 10px;
  background: #eef2f6; color: var(--muted);
}
.summary-status.ok { background: var(--ok-bg); color: var(--ok); }
.summary-status.over { background: var(--warn-bg); color: var(--warn); }
.summary-detail { color: var(--muted); font-size: 0.95rem; }

.group {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px;
}
.group-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.group-name { font-weight: 700; }
.group-ratio { color: var(--muted); font-size: 0.82rem; }
.badge { font-size: 0.78rem; font-weight: 800; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.over { background: var(--warn-bg); color: var(--warn); }
.group-inputs { display: flex; gap: 14px; margin-top: 12px; }
.field { flex: 1; }
.field label { display: block; font-size: 0.78rem; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.4px; }
.stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.stepper button {
  width: 42px; height: 44px; border: none; background: #f0f4f7; font-size: 1.4rem; color: var(--brand);
  cursor: pointer; line-height: 1;
}
.stepper button:active { background: #e2ebf0; }
.stepper input {
  flex: 1; min-width: 0; height: 44px; border: none; text-align: center; font-size: 1.15rem;
  font-weight: 700; color: var(--ink); background: var(--card);
}
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.group-note { margin-top: 10px; font-size: 0.85rem; color: var(--muted); }
.group-note.over { color: var(--warn); font-weight: 600; }

.settings { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 16px; box-shadow: var(--shadow); }
.settings summary { padding: 12px 0; font-weight: 600; cursor: pointer; color: var(--brand); }
.hint { color: var(--muted); font-size: 0.85rem; margin: 6px 0 12px; }
.ratio-edit-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.ratio-edit-row span { font-weight: 600; }
.ratio-edit-row .r { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.ratio-edit-row input { width: 64px; height: 38px; text-align: center; border: 1px solid var(--line); border-radius: 8px; font-size: 1rem; font-weight: 700; }

.add-row { display: flex; gap: 8px; }
.add-row input { flex: 1; height: 46px; border: 1px solid var(--line); border-radius: 10px; padding: 0 14px; font-size: 1rem; }
.btn { height: 46px; padding: 0 18px; border: none; border-radius: 10px; background: var(--brand); color: #fff; font-size: 1rem; font-weight: 600; cursor: pointer; }
.btn.ghost { background: transparent; color: var(--brand); border: 1px solid var(--line); margin: 8px 0 4px; height: 40px; }

.roster { list-style: none; display: flex; flex-direction: column; gap: 8px; padding: 0; }
.roster li {
  display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); cursor: pointer; user-select: none;
}
.roster li .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--line); flex: none; }
.roster li.present .dot { background: var(--ok); }
.roster li .rname { flex: 1; font-weight: 600; }
.roster li.absent .rname { color: var(--muted); text-decoration: line-through; }
.roster li .state { font-size: 0.78rem; font-weight: 700; color: var(--muted); }
.roster li.present .state { color: var(--ok); }
.roster li .remove { border: none; background: none; color: var(--muted); font-size: 1.2rem; cursor: pointer; padding: 4px 6px; }
.empty { color: var(--muted); text-align: center; padding: 24px; }

.foot { margin: 20px auto 40px; color: var(--muted); font-size: 0.82rem; display: flex; flex-direction: column; gap: 8px; }
.foot a { color: var(--brand); }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10161c; --card: #182029; --ink: #e8eef3; --muted: #93a3b3; --line: #26313c;
    --brand: #3aa6ba; --ok: #35c58a; --ok-bg: #12352a; --warn: #ff6b6b; --warn-bg: #3a1f21;
  }
}
