:root {
    --bg: #f4fbf7;
    --panel: #ffffff;
    --ink: #172822;
    --muted: #6f827a;
    --line: #d8ebe3;
    --green: #12a06d;
    --green-dark: #08714e;
    --mint: #dff8ec;
    --mint-2: #bff0db;
    --yellow: #fff0ad;
    --blue: #e2f3ff;
    --red: #df645f;
    --shadow: 0 14px 34px rgba(11, 90, 61, .09);
}

* { box-sizing: border-box; }
body { margin: 0; background: radial-gradient(circle at top left, #d9fff0 0, transparent 32%), var(--bg); color: var(--ink); font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; }
button { border: 0; border-radius: 12px; background: var(--green); color: white; min-height: 44px; padding: 0 14px; font-weight: 800; cursor: pointer; box-shadow: 0 8px 18px rgba(18, 160, 109, .16); }
button:active { transform: translateY(1px); }
button.ghost { background: var(--mint); color: var(--green-dark); box-shadow: none; }
button.off { background: #eef3ef; color: var(--muted); }
button.wide { width: 100%; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; min-height: 44px; padding: 10px; background: white; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(18, 160, 109, .15); border-color: var(--green); }
textarea { min-height: 110px; resize: vertical; }
.hidden { display: none !important; }

.login { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-box { width: min(370px, 100%); display: grid; gap: 14px; background: rgba(255,255,255,.9); border: 1px solid rgba(216,235,227,.95); border-radius: 24px; padding: 28px 24px; box-shadow: var(--shadow); text-align: center; backdrop-filter: blur(14px); }
.login-mark { width: 56px; height: 56px; display: grid; place-items: center; justify-self: center; border-radius: 18px; background: linear-gradient(145deg, var(--green), #68d6a6); color: white; font-weight: 950; letter-spacing: .04em; }
.login-box strong { font-size: 1.55rem; }
.login-box p { margin: -4px 0 2px; color: var(--muted); font-weight: 700; }
.pin-wrap { position: relative; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 6px 0; }
.pin-dot { height: 58px; border-radius: 16px; background: #f6fbf8; border: 1px solid var(--line); display: grid; place-items: center; }
.pin-dot.filled::after { content: ""; width: 14px; height: 14px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 6px rgba(18, 160, 109, .12); }
.pin-wrap input { position: absolute; inset: 0; opacity: 0; }
#login-btn.loading { opacity: .72; pointer-events: none; }

.top { position: sticky; top: 0; z-index: 3; display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 12px; background: rgba(244, 251, 247, .92); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.top strong { display: block; font-size: 1.1rem; }
.top span { color: var(--muted); font-size: .85rem; }
.top input { width: 150px; }

main { max-width: 1100px; margin: 0 auto; padding: 12px 12px 80px; }
.tabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 12px; }
.tabs button { min-height: 42px; padding: 0 6px; border: 1px solid var(--line); background: rgba(255,255,255,.9); color: var(--muted); box-shadow: none; font-size: .86rem; }
.tabs button.active { background: var(--green); color: white; border-color: var(--green); box-shadow: 0 8px 18px rgba(18, 160, 109, .14); }
.tab { display: none; }
.tab.active { display: block; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stat { display: grid; place-items: center; min-height: 78px; background: var(--panel); color: var(--ink); border: 1px solid var(--line); padding: 8px; box-shadow: 0 8px 22px rgba(34, 79, 56, .05); }
.stat b { font-size: 1.15rem; }
.stat span { color: var(--muted); font-size: .82rem; }

.panel, .class-card { background: rgba(255,255,255,.94); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin-bottom: 12px; box-shadow: 0 8px 24px rgba(34, 79, 56, .05); }
.panel h3, .class-card h3 { margin: 0 0 10px; }
details summary { min-height: 44px; display: flex; align-items: center; font-weight: 800; cursor: pointer; }

.person-list, .child-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.person { min-height: 54px; border: 1px solid var(--line); border-radius: 14px; background: #fff; color: var(--ink); text-align: left; display: flex; align-items: center; justify-content: space-between; gap: 8px; box-shadow: none; }
.person.present { background: linear-gradient(180deg, #e9fff3, var(--mint)); border-color: #91dcb9; color: #12583c; }
.person small { color: var(--muted); }

.split-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.form { display: grid; gap: 10px; }
.form label { display: grid; gap: 5px; color: var(--muted); font-size: .9rem; font-weight: 700; }
.form label > * { color: var(--ink); font-weight: 500; }

.content-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.content-card { background: white; border: 1px solid var(--line); border-radius: 16px; padding: 12px; display: grid; gap: 8px; box-shadow: 0 8px 24px rgba(34, 79, 56, .05); }
.content-card strong { font-size: 1.02rem; }
.tag { display: inline-flex; width: fit-content; border-radius: 999px; padding: 3px 8px; background: var(--blue); color: #17618e; font-size: .78rem; font-weight: 800; }
.selected { display: grid; gap: 8px; }
.selected-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: 6px; align-items: center; border: 1px solid var(--line); border-radius: 14px; padding: 8px; background: #fff; }
.selected-row button { min-height: 34px; padding: 0 10px; }

pre { white-space: pre-wrap; word-break: keep-all; margin: 0; line-height: 1.7; }
dialog { width: min(520px, calc(100% - 24px)); border: 0; border-radius: 18px; padding: 0; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(20, 30, 25, .45); }
#modal-body { padding: 16px; display: grid; gap: 10px; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }

@media (min-width: 760px) {
    .tabs { display: flex; }
    .tabs button { padding: 0 18px; }
    .stats { grid-template-columns: 180px 180px 180px; }
}

@media (max-width: 420px) {
    .top { align-items: flex-start; }
    .top input { width: 135px; }
    .stats { grid-template-columns: 1fr; }
    .split-actions { grid-template-columns: 1fr; }
    .person-list, .child-grid { grid-template-columns: repeat(2, 1fr); }
}
