body { background: #f5f2ec; }
.boot { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: .6rem; background: var(--paper); z-index: 50; font-family: var(--font-head); font-size: 1.3rem; }
.boot img { border-radius: 50%; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.94); opacity: .7; } }

/* ---------- sign-in ---------- */
.signin { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(900px 400px at 50% 0%, #efe1c4, transparent 70%), var(--paper); }
.signin-card { width: min(420px, 100%); padding: 2rem 1.6rem; text-align: center; background: #fff; border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); }
.signin-card img { width: 96px; height: 96px; border-radius: 50%; margin: 0 auto 1rem; }
.signin-card h1 { font-family: var(--font-head); font-size: 1.9rem; margin: 0 0 .2rem; }
.signin-card p { color: var(--muted); margin: 0 0 1.4rem; }
.gbtn { width: 100%; min-height: 50px; display: flex; align-items: center; justify-content: center; gap: .7rem; border: 1px solid var(--line); border-radius: 12px; background: #fff; font-weight: 600; cursor: pointer; }
.gbtn:hover { background: #faf8f4; }
.gbtn svg { width: 20px; height: 20px; }
.signin-note { font-size: .82rem; color: var(--muted); margin-top: 1.2rem !important; }
.signin-card .back { display: inline-block; margin-top: 1rem; font-size: .9rem; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100dvh; }
.side { position: sticky; top: 0; height: 100dvh; overflow-y: auto; background: var(--ink); color: #e9e3d6; padding: 1rem .8rem; display: flex; flex-direction: column; gap: .2rem; }
.side-brand { display: flex; align-items: center; gap: .6rem; padding: .3rem .5rem 1rem; color: #fff; text-decoration: none; }
.side-brand img { width: 40px; height: 40px; border-radius: 50%; }
.side-brand strong { font-family: var(--font-head); font-size: 1.15rem; line-height: 1.1; display: block; }
.side-brand small { color: #b9b09f; font-size: .72rem; }
.side .grp { font-size: .7rem; text-transform: uppercase; letter-spacing: .12em; color: #8f8778; padding: .9rem .7rem .3rem; }
.side a.nl { display: flex; align-items: center; gap: .7rem; padding: .6rem .7rem; border-radius: 10px; color: #e9e3d6; text-decoration: none; font-weight: 500; font-size: .95rem; }
.side a.nl:hover { background: rgba(255, 255, 255, .06); }
.side a.nl.on { background: rgba(226, 196, 143, .16); color: #f3dcae; }
.side a.nl svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.side-foot { margin-top: auto; padding: .8rem .5rem 0; border-top: 1px solid rgba(255, 255, 255, .08); font-size: .85rem; }
.side-foot .who { color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.side-foot .rl { color: #b9b09f; font-size: .78rem; }
.side-foot .acts { display: flex; gap: .4rem; margin-top: .6rem; flex-wrap: wrap; }
.side-foot button { background: rgba(255, 255, 255, .08); color: #e9e3d6; border: 0; border-radius: 8px; padding: .4rem .7rem; cursor: pointer; font-size: .82rem; }

.main { min-width: 0; padding: 1.4rem clamp(16px, 3vw, 2rem) 6rem; }
.topbar { display: none; }
.net { position: fixed; right: 14px; bottom: 14px; z-index: 30; padding: .35rem .75rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--warn-soft); color: var(--warn); box-shadow: var(--shadow); }
.net.ok { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 40; transform: translateX(-102%); transition: transform .2s ease; }
  .shell.open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); }
  .topbar { display: flex; align-items: center; gap: .6rem; position: sticky; top: 0; z-index: 20; background: rgba(245, 242, 236, .95); backdrop-filter: blur(8px); padding: .6rem 16px; border-bottom: 1px solid var(--line); }
  .topbar button { width: 42px; height: 42px; border-radius: 10px; border: 1px solid var(--line); background: #fff; display: grid; place-items: center; cursor: pointer; }
  .topbar img { width: 32px; height: 32px; border-radius: 50%; }
  .topbar strong { font-family: var(--font-head); font-size: 1.15rem; }
  .main { padding-top: 1rem; }
  .net { bottom: 14px; }
}

/* ---------- page parts ---------- */
.ph { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .8rem; margin-bottom: 1.2rem; }
.ph h1 { font-family: var(--font-head); font-size: clamp(1.7rem, 3.4vw, 2.3rem); margin: 0; line-height: 1.1; }
.ph p { margin: .25rem 0 0; color: var(--muted); }
.ph .acts { display: flex; flex-wrap: wrap; gap: .5rem; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin-bottom: 1rem; }
.panel h2 { font-size: 1.05rem; margin: 0 0 .8rem; }
.grid { display: grid; gap: 1rem; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1000px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .g2, .g3 { grid-template-columns: 1fr; } }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.stat .k { font-size: .8rem; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 1.7rem; font-weight: 700; margin-top: .15rem; font-variant-numeric: tabular-nums; }
.stat .s { font-size: .82rem; color: var(--muted); }
.stat.gold { background: var(--ink); color: #fff; border-color: var(--ink); }
.stat.gold .k, .stat.gold .s { color: #cfc6b4; }
.alerts { display: grid; gap: .5rem; }
.alert { display: flex; gap: .7rem; align-items: flex-start; padding: .7rem .9rem; border-radius: 10px; background: var(--warn-soft); color: #5b3600; font-size: .92rem; }
.alert.bad { background: var(--bad-soft); color: #6d1712; }
.alert.ok { background: var(--ok-soft); color: #0f4a2d; }
.empty { padding: 2rem 1rem; text-align: center; color: var(--muted); }

.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .9rem; }
.toolbar .input { width: auto; min-width: 0; flex: 1 1 180px; }
.toolbar select.input { flex: 0 1 170px; }

.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .93rem; }
.tbl th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: #faf8f3; padding: .65rem .8rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: .65rem .8rem; border-bottom: 1px solid #f0ebe1; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: #fbf7ef; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tag { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--stone); color: var(--ink-2); white-space: nowrap; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.gold { background: var(--gold-soft); color: var(--gold); }
.muted { color: var(--muted); }
.due { color: var(--bad); font-weight: 700; }
.adv { color: var(--ok); font-weight: 700; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem 1rem; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.form-sec { grid-column: 1 / -1; font-weight: 700; font-size: .85rem; color: var(--gold); text-transform: uppercase; letter-spacing: .08em; margin-top: .6rem; }
.hint { font-size: .8rem; color: var(--muted); }

/* attendance roll */
.roll { display: grid; gap: .45rem; }
.roll-item { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.roll-row { display: flex; align-items: center; gap: .7rem; padding: .55rem .7rem; }
.roll > .roll-row, .modal .roll-row { background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.roll-row .rn { width: 1.6rem; text-align: right; flex: none; }
.roll-row .nm { flex: 1; min-width: 0; }
.roll-row .nm strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roll-row .nm small { color: var(--muted); margin-right: .4rem; }
.roll-row .nm .tag { margin-top: .2rem; }
.pal { display: flex; gap: .3rem; flex: none; }
.pal button { min-width: 40px; height: 40px; padding: 0 .35rem; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-weight: 700; cursor: pointer; font-size: .88rem; }
.pal button.on[data-v="P"] { background: var(--ok); border-color: var(--ok); color: #fff; }
.pal button.on[data-v="A"] { background: var(--bad); border-color: var(--bad); color: #fff; }
.pal button.on[data-v="T"] { background: #c77700; border-color: #c77700; color: #fff; }
.pal button.on[data-v="H"] { background: #7a5a1c; border-color: #7a5a1c; color: #fff; }
.pal button.on[data-v="L"] { background: #2d5e9e; border-color: #2d5e9e; color: #fff; }
.roll-item.is-A { border-color: #f1c4bf; background: #fff8f7; }
.roll-item.is-T, .roll-item.is-H { border-color: #f0d6a8; background: #fffaf0; }
.roll-item.is-L { border-color: #c9d8ee; background: #f6f9fe; }
.roll-detail { display: grid; gap: .5rem; padding: 0 .7rem .7rem 2.9rem; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { min-height: 34px; padding: .3rem .75rem; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: .85rem; font-weight: 500; cursor: pointer; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.late-time { display: flex; align-items: center; gap: .5rem; font-size: .85rem; font-weight: 600; }
.late-time .input { width: auto; min-height: 38px; }
.roll-tools .legend { display: flex; flex-wrap: wrap; gap: .2rem .8rem; font-size: .8rem; color: var(--muted); margin-left: auto; }
.roll-tools .legend b { color: var(--ink); }
@media (max-width: 520px) {
  .roll-item .roll-row { flex-wrap: wrap; }
  .roll-item .pal { width: 100%; padding-left: 2.3rem; }
  .roll-item .pal button { flex: 1; min-width: 0; }
  .roll-detail { padding-left: .7rem; }
  .roll-tools .legend { margin-left: 0; }
}
/* monthly register */
.reg .tbl { font-size: .82rem; }
.reg th, .reg td { padding: .45rem .5rem; }
.reg .dcol { text-align: center; min-width: 30px; font-weight: 700; cursor: default; }
.reg td.m-P { color: var(--ok); }
.reg td.m-A { color: #fff; background: var(--bad); }
.reg td.m-T { color: #c77700; }
.reg td.m-H { color: #7a5a1c; }
.reg td.m-L { color: #2d5e9e; }
.reg td.m-none { color: #cfc8ba; }
.print-only { display: none !important; }
.sticky-save { position: sticky; bottom: 12px; display: flex; gap: .7rem; align-items: center; justify-content: space-between; margin-top: 1rem; padding: .7rem .9rem; background: var(--ink); color: #fff; border-radius: 14px; box-shadow: var(--shadow); }
.sticky-save .cnt { font-size: .92rem; }
.sticky-save .btn { background: var(--gold); white-space: nowrap; flex: none; }
.sticky-save .cnt { font-size: .85rem; }

/* modal */
.modal-bg { position: fixed; inset: 0; z-index: 60; background: rgba(22, 21, 19, .45); display: grid; place-items: center; padding: 16px; animation: fade .15s ease; }
.modal { width: min(640px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; background: #fff; border-radius: 18px; box-shadow: 0 30px 80px rgba(0, 0, 0, .3); }
.modal header { position: sticky; top: 0; background: #fff; display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); z-index: 1; }
.modal header h2 { margin: 0; font-size: 1.15rem; }
.modal header button { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 1.2rem; }
.modal .body { padding: 1.1rem 1.2rem; }
.modal footer { position: sticky; bottom: 0; background: #fff; display: flex; justify-content: flex-end; gap: .5rem; padding: .9rem 1.2rem; border-top: 1px solid var(--line); }
@keyframes fade { from { opacity: 0; } }

.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 70; display: grid; gap: .4rem; width: min(420px, calc(100% - 32px)); }
.toast { padding: .75rem 1rem; border-radius: 12px; background: var(--ink); color: #fff; box-shadow: var(--shadow); font-weight: 500; animation: fade .2s ease; }
.toast.err { background: var(--bad); }
.toast.ok { background: var(--ok); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; font-size: .93rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tabs a { padding: .6rem .9rem; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--ink); border-color: var(--gold); }
.big-due { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.pill-list { display: flex; flex-wrap: wrap; gap: .4rem; }
.chk { display: flex; align-items: center; gap: .5rem; padding: .45rem .7rem; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.chk input { width: 18px; height: 18px; accent-color: var(--gold); }

/* print: receipts */
.receipt { width: min(720px, 100%); margin: 0 auto; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 1.6rem; }
.rc-head { display: flex; gap: 1rem; align-items: center; border-bottom: 2px solid var(--ink); padding-bottom: .9rem; }
.rc-head img { width: 76px; height: 76px; border-radius: 50%; }
.rc-head h2 { font-family: var(--font-head); font-size: 1.7rem; margin: 0; line-height: 1.05; }
.rc-head p { margin: .1rem 0 0; color: var(--muted); font-size: .85rem; }
.rc-title { display: flex; justify-content: space-between; align-items: center; margin: 1rem 0; }
.rc-title strong { letter-spacing: .14em; text-transform: uppercase; font-size: .85rem; }
.rc-amt { font-size: 1.8rem; font-weight: 800; text-align: right; }
.rc-words { font-style: italic; color: var(--ink-2); margin: .4rem 0 1rem; }
.rc-sign { display: flex; justify-content: space-between; margin-top: 2.6rem; font-size: .85rem; color: var(--muted); }
.rc-void { margin-top: 1rem; padding: .7rem; border: 2px solid var(--bad); color: var(--bad); font-weight: 800; text-align: center; letter-spacing: .1em; }
@media print {
  body { background: #fff; }
  .side, .topbar, .no-print, .net, .toasts { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; }
  .receipt { border: 0; padding: 0; }
  .print-only { display: flex !important; }
  .reg { overflow: visible; border: 0; }
  .reg .tbl { font-size: 9px; }
  .reg th, .reg td { padding: 2px 3px; }
  @page { size: landscape; margin: 10mm; }
}
