/* Giao diện trường mầm non: nút to, đọc rõ trên điện thoại. Dựa trên Pico.css */
:root:not([data-theme=dark]),
[data-theme=light] {
  --ink: #1c2b33;
  --muted: #5c6b73;
  --line: #e3ebe8;
  --surface: #ffffff;
  --bg: #f3f6f4;
  --brand: #0e6b5c;
  --brand-dark: #0a5348;
  --pico-font-family: "Be Vietnam Pro", "Segoe UI", sans-serif;
  --pico-primary: var(--brand);
  --pico-primary-background: var(--brand);
  --pico-primary-hover: var(--brand-dark);
  --pico-primary-hover-background: var(--brand-dark);
  --pico-primary-focus: rgba(14, 107, 92, .28);
  --pico-background-color: var(--bg);
  --pico-color: var(--ink);
  --pico-muted-color: var(--muted);
  --pico-border-radius: 12px;
  --pico-font-size: 106%;
}
body { background: var(--bg); color: var(--ink); }
main.container { padding-top: 1.25rem; padding-bottom: 5rem; }
h2, h3 { letter-spacing: -0.02em; }
.topbar { background: rgba(255,255,255,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; justify-content: space-between; align-items: center; padding: .7rem 0 .45rem; gap: .75rem; }
.brand { display: flex; align-items: center; gap: .7rem; text-decoration: none; color: inherit; min-width: 0; }
.logo { width: 44px; height: 44px; flex: none; border-radius: 12px; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text strong { font-size: 1rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { color: var(--muted); font-size: .75rem; font-weight: 500; }
.page-brand { margin-bottom: 1rem; }
.page-brand .brand-text strong { white-space: normal; }
.logout { display: flex; align-items: center; gap: .65rem; margin: 0; flex: none; }
.logout button { margin: 0; width: auto; }
.who { display: flex; flex-direction: column; align-items: flex-end; font-size: .8rem; color: var(--muted); line-height: 1.2; }
.who b { color: var(--ink); font-weight: 600; }
.mainnav { display: flex; gap: .35rem; overflow-x: auto; padding: .15rem 0 .7rem; white-space: nowrap; }
.mainnav a { padding: .45rem .85rem; border-radius: 999px; background: #fff; border: 1px solid var(--line); text-decoration: none; font-size: .92rem; font-weight: 600; color: var(--ink); }
.mainnav a:hover { background: #e7f3f0; border-color: #c5ddd6; }
.mainnav a.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.site-footer { color: var(--muted); font-size: .8rem; padding-bottom: 1.5rem; }
.login-wrap { min-height: calc(100vh - 5rem); display: flex; align-items: center; justify-content: center; }
.login-card { width: min(440px, 100%); margin: 1.5rem auto; padding: 2rem 1.5rem 1.5rem; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: 0 16px 40px rgba(16, 42, 36, .08); }
.login-brand { text-align: center; margin-bottom: 1.25rem; }
.login-brand .logo-lg { display: flex; justify-content: center; margin: 0 auto .85rem; }
.login-brand .logo-lg .logo { width: 72px; height: 72px; }
.login-brand h1 { font-size: 1.35rem; margin: 0 0 .2rem; line-height: 1.3; }
.login-brand p { margin: 0; color: var(--muted); }
.login-card button.big { width: 100%; }
@media (max-width: 640px) {
  .who span { display: none; }
  .brand-text strong { max-width: 52vw; }
}
.muted { color: #777; }
.small-text { font-size: .8rem; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.narrow { max-width: 560px; margin: 1rem auto; }
.row-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5rem; }
.inline { display: inline-block; margin: 0; }
.inline input, .inline button { margin-bottom: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .5rem 0 1rem; }
.actions > *, .actions button, .actions [role=button] { margin: 0; width: auto; }
button.big, [role=button].big { font-size: 1.05rem; padding: .75rem 1.2rem; }
button.small, .small { font-size: .85rem; padding: .3rem .6rem; }
button.link { background: none; border: none; color: var(--pico-primary); padding: 0 .3rem; width: auto; margin: 0; text-decoration: underline; }
.danger { color: #c92a2a !important; }
.flash { padding: .75rem 1rem; border-radius: .5rem; margin-bottom: .75rem; }
.flash-success { background: #e6fcf5; border-left: 4px solid #12b886; }
.flash-error { background: #fff5f5; border-left: 4px solid #fa5252; }
.flash-warning { background: #fff9db; border-left: 4px solid #fab005; }
.flash-info { background: #e7f5ff; border-left: 4px solid #339af0; }
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .8rem; background: #eee; }
.badge.warn { background: #fff3bf; color: #8a5a00; }
.badge.info { background: #e7f5ff; color: #1864ab; }
.badge.ok { background: #d3f9d8; color: #2b8a3e; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: .75rem; margin: 1rem 0; }
.stat { background: #fff; border-radius: .75rem; padding: .75rem; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.stat b { display: block; font-size: 1.8rem; color: var(--pico-primary); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .75rem; }
.tile { display: flex; flex-direction: column; gap: .2rem; padding: 1rem; background: #fff; border-radius: .75rem; text-decoration: none; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.tile strong { font-size: 1.2rem; }
.checklist { list-style: none; padding: 0; }
.checklist li { list-style: none; padding: .2rem 0; }
.checklist li.ok::before { content: "✅ "; }
.checklist li.todo::before { content: "⏳ "; }
.table-wrap { overflow-x: auto; }
tr.inactive td { opacity: .5; }
tr.total td { font-weight: 700; background: #e7f3f0; }
.filter { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.filter input, .filter select, .filter button { margin-bottom: .5rem; width: auto; }
.seg { display: flex; border-radius: .5rem; overflow: hidden; border: 1px solid var(--brand); margin-bottom: .5rem; }
.seg-btn { padding: .55rem 1rem; text-decoration: none; }
.seg-btn.active { background: var(--brand); color: #fff; }
.tabs { display: flex; gap: .5rem; margin-bottom: .5rem; }
.tabs a { padding: .4rem 1rem; border-radius: .5rem; text-decoration: none; background: #e7f3f0; }
.tabs a.active { background: var(--brand); color: #fff; }
.low { color: #c92a2a; }

/* Điểm danh */
.kid-list { display: flex; flex-direction: column; gap: .6rem; }
.kid { background: #fff; border-radius: .75rem; padding: .75rem; border-left: 6px solid #ddd; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.kid.s-present { border-left-color: #40c057; }
.kid.s-late { border-left-color: #fab005; }
.kid.s-excused { border-left-color: #339af0; }
.kid.s-unexcused { border-left-color: #fa5252; }
.kid-head { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-bottom: .5rem; }
.kid-name { font-weight: 600; font-size: 1.05rem; }
.status-btns { display: grid; grid-template-columns: repeat(4, 1fr); gap: .35rem; }
@media (max-width: 520px) { .status-btns { grid-template-columns: repeat(2, 1fr); } }
.sbtn { margin: 0; }
.sbtn input { position: absolute; opacity: 0; pointer-events: none; }
.sbtn span { display: block; text-align: center; padding: .7rem .3rem; border-radius: .5rem; border: 2px solid #e9ecef; cursor: pointer; font-size: .95rem; user-select: none; }
.sbtn.s-present input:checked + span { background: #40c057; border-color: #40c057; color: #fff; }
.sbtn.s-late input:checked + span { background: #fab005; border-color: #fab005; color: #222; }
.sbtn.s-excused input:checked + span { background: #339af0; border-color: #339af0; color: #fff; }
.sbtn.s-unexcused input:checked + span { background: #fa5252; border-color: #fa5252; color: #fff; }
.kid .note { margin: .5rem 0 0; padding: .4rem .6rem; font-size: .9rem; height: auto; }
.badge.s-present { background: #d3f9d8; } .badge.s-late { background: #fff3bf; } .badge.s-excused { background: #d0ebff; } .badge.s-unexcused { background: #ffe3e3; }
.sticky-bar { position: sticky; bottom: 0; display: flex; gap: .5rem; padding: .75rem 0; background: linear-gradient(transparent, var(--bg) 30%); }
.sticky-bar button { flex: 1; margin: 0; }

/* Báo cơm */
.meal-row { padding: 1rem; }
.stepper { display: flex; gap: .5rem; align-items: center; margin: .5rem 0; }
.stepper input { text-align: center; font-size: 1.5rem; font-weight: 700; margin: 0; }
.stepper .step { width: 3.5rem; font-size: 1.5rem; margin: 0; padding: .4rem; }
.type-row { align-items: center; }

/* Thông báo */
.notif.confirmed { border-left: 5px solid #40c057; }
.notif textarea.msg { font-size: .9rem; margin: .5rem 0; }
.parent-note { background: #fff9db; padding: .5rem; border-radius: .5rem; }

/* Thẻ QR */
.qr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .75rem; }
.qr-card { border: 1px dashed #aaa; border-radius: .5rem; padding: .5rem; text-align: center; background: #fff; display: flex; flex-direction: column; break-inside: avoid; }
.qr-card img { width: 100%; max-width: 160px; margin: 0 auto; }
@media print { .topbar, footer, .noprint, .flash { display: none !important; } body { background: #fff; } }

/* ---------- Đón / trả trẻ ---------- */
:root { --st-chua: #9e9e9e; --st-den: #2e7d32; --st-ve: #1565c0; --st-nghi: #ef6c00; --st-vang: #c62828; }
.state-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0 1rem; }
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .45rem .8rem; border-radius: 999px; border: 2px solid var(--st-chua);
  text-decoration: none; color: inherit; font-size: .95rem; min-height: 44px; background: var(--pico-background-color, #fff); }
.chip b { font-size: 1.15rem; }
.chip.active { background: #263238; color: #fff; border-color: #263238; }
.chip.st-chua_den { border-color: var(--st-chua); }
.chip.st-da_den { border-color: var(--st-den); }
.chip.st-da_ve { border-color: var(--st-ve); }
.chip.st-xin_nghi { border-color: var(--st-nghi); }
.chip.st-vang { border-color: var(--st-vang); }
.chip.late, .chip.st-late { border-color: #6a1b9a; }
.big-chips .chip { flex: 1 1 40%; justify-content: center; }
.stat.st-da_den b { color: var(--st-den); } .stat.st-chua_den b { color: var(--st-chua); }
.stat.st-da_ve b { color: var(--st-ve); } .stat.st-xin_nghi b { color: var(--st-nghi); }

.board { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .6rem; }
.ktile { border: 1px solid #ddd; border-left: 6px solid var(--st-chua); border-radius: .6rem; padding: .6rem .7rem; background: var(--pico-card-background-color, #fff); }
.ktile.st-da_den { border-left-color: var(--st-den); }
.ktile.st-da_ve { border-left-color: var(--st-ve); opacity: .85; }
.ktile.st-xin_nghi { border-left-color: var(--st-nghi); background: #fff8f0; }
.ktile.st-vang { border-left-color: var(--st-vang); }
.ktile-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.ktile-info { margin: .3rem 0; }
.ktile-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.ktile-actions > *, .ktile-actions button, .ktile-actions [role=button] { flex: 1 1 auto; margin: 0; min-height: 48px; }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 2.4rem; height: 2.4rem; border-radius: 50%;
  background: #e0f2f1; color: #00695c; font-weight: 700; flex: none; font-size: .9rem; }
.badge.late { background: #f3e5f5; color: #6a1b9a; }
.badge.st-chua_den { background: #eeeeee; color: #424242; }
.badge.st-da_den { background: #e8f5e9; color: var(--st-den); }
.badge.st-da_ve { background: #e3f2fd; color: var(--st-ve); }
.badge.st-xin_nghi { background: #fff3e0; color: var(--st-nghi); }
.badge.st-vang { background: #ffebee; color: var(--st-vang); }
.badge.kind-checkin { background: #e8f5e9; color: var(--st-den); }
.badge.kind-checkout { background: #e3f2fd; color: var(--st-ve); }

.guardian-list { display: grid; gap: .5rem; margin-bottom: 1rem; }
.gcard { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .6rem .8rem; border: 2px solid #ddd;
  border-radius: .6rem; cursor: pointer; min-height: 56px; margin: 0; }
.gcard > span { display: flex; align-items: center; gap: .6rem; }
.gcard input[type=radio] { margin: 0; }
.gcard:has(input:checked) { border-color: var(--st-den); background: #f1f8e9; }
.gcard.static { cursor: default; }
.gphoto { width: 3rem; height: 3rem; object-fit: cover; border-radius: 50%; flex: none; }
.camera-btn { display: block; border: 2px dashed #90a4ae; border-radius: .6rem; padding: .8rem; text-align: center; cursor: pointer; margin: .6rem 0; }
.camera-btn input[type=file] { margin-top: .4rem; }
.big-camera { font-size: 1.3rem; padding: 1.5rem .8rem; }
.preview { max-width: 100%; max-height: 320px; border-radius: .6rem; display: block; margin: .5rem auto; }
.face-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; margin: .6rem 0; }
.face-card { border: 2px solid #ddd; border-radius: .6rem; padding: .5rem; text-align: center; margin: 0; }
.face-card.matched { border-color: var(--st-den); }
.face-card.unknown { border-color: #ffb74d; }
.face-card img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: .4rem; }
.face-card select { margin: .3rem 0 0; font-size: .9rem; }
ul.plain { list-style: none; padding: 0; } ul.plain li { list-style: none; margin-bottom: .4rem; }
.kid.lv-pending { border-left: 5px solid var(--st-nghi); }
.kid.lv-rejected, .kid.lv-cancelled { opacity: .6; }

article, .stat, .tile, .kid, .ktile {
  border-color: var(--line);
  box-shadow: 0 1px 2px rgba(16, 42, 36, .04);
}
.stat b { color: var(--brand); }
.class-card > header { background: transparent; border: 0; padding: 0 0 .35rem; margin: 0; }
button.big, [role=button].big { min-height: 48px; font-weight: 600; }
input, select, textarea { background: #fff; }

.scan-launch { margin: 0 0 .8rem; }
.scan-stage { position: relative; background: #10211c; border-radius: 16px; overflow: hidden; aspect-ratio: 3 / 4; max-height: 68vh; margin-bottom: .8rem; }
.scan-stage video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame { position: absolute; inset: 16% 14%; border: 3px solid #fff; border-radius: 16px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .35); pointer-events: none; }
.scan-result { margin: .8rem 0; padding: .9rem 1rem; border-radius: 12px; }
.scan-result p { margin: 0 0 .5rem; }
.scan-result button { width: 100%; margin-bottom: .4rem; }
.scan-ok { background: #e6fcf5; border-left: 4px solid #0e6b5c; }
.scan-bad { background: #fff5f5; border-left: 4px solid #fa5252; }
