/* =========================================================================
   School ERP — one stylesheet, two experiences:
   • < 900px  : native-app style (app bar, bottom tabs, cards, sheets, FAB)
   • ≥ 900px  : desktop ERP (sidebar, top bar, tables, multi-column forms)
   Colours come from /theme.css (school-configurable tokens).
   ========================================================================= */

:root {
  --text: #111827;
  --text-muted: #5B6475;
  --border: #E3E7EF;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 4px 16px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .16);
  --appbar-h: 56px;
  --tabbar-h: 64px;
  --sidebar-w: 248px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --gutter: 16px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 1.5;
  color: var(--text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
img, svg, picture { display: block; max-width: 100%; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
p { margin: 0 0 .5rem; }
small { font-size: .82em; }
code { background: var(--color-primary-soft); padding: .1em .35em; border-radius: 4px; }
:focus-visible { outline: 3px solid var(--color-secondary); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--color-card); padding: 8px 12px; border-radius: 8px; }
.skip-link:focus { left: 8px; }
.muted { color: var(--text-muted); }
.small { font-size: .9rem; }
.center { text-align: center; }
.text-danger { color: var(--color-danger) !important; }
.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: var(--radius);
  border: 1px solid transparent; background: var(--color-card); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important;
  transition: background .15s, transform .05s, box-shadow .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn .icon { width: 18px; height: 18px; }
.btn-primary { background: var(--color-primary); color: var(--color-primary-contrast); }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-success { background: var(--color-success); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--color-primary); }
.btn-ghost:hover { background: var(--color-primary-soft); }
.btn-light { background: rgba(255,255,255,.95); color: var(--color-primary); }
.btn-outline-danger { background: transparent; border-color: var(--color-danger); color: var(--color-danger); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: .88rem; }
.btn-lg { min-height: 52px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--color-card); color: var(--text); cursor: pointer; font-size: 1.3rem;
}
.icon-btn.disabled { opacity: .35; }
.link { font-weight: 600; font-size: .92rem; }

/* ---------- Badges & chips ---------- */
.badge { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.badge-success { background: var(--color-success-soft); color: var(--color-success); }
.badge-danger { background: var(--color-danger-soft); color: var(--color-danger); }
.badge-warning { background: var(--color-warning-soft); color: var(--color-warning); }
.badge-info { background: var(--color-primary-soft); color: var(--color-primary); }
.badge-muted { background: #EEF0F4; color: var(--text-muted); }
.chip { padding: 4px 12px; border-radius: 999px; background: var(--color-primary-soft); color: var(--color-primary); font-weight: 600; font-size: .85rem; }
.grade-chip { display: inline-grid; place-items: center; min-width: 40px; height: 28px; padding: 0 8px; border-radius: 8px; background: var(--color-primary-soft); color: var(--color-primary); font-weight: 800; }
.progress-chip { font-size: .8rem; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: var(--color-warning-soft); color: var(--color-warning); }
.progress-chip.ok { background: var(--color-success-soft); color: var(--color-success); }
.roll { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--color-primary-soft); color: var(--color-primary); font-weight: 700; font-size: .85rem; flex: none; }

.avatar {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; flex: none;
  background: var(--color-primary-soft); color: var(--color-primary); font-weight: 800;
}
.avatar-pink { background: #FCE7F3; color: #9D174D; }
.avatar-sm { width: 28px; height: 28px; font-size: .8rem; }
.avatar-lg { width: 52px; height: 52px; font-size: 1.3rem; }
.avatar-xl { width: 68px; height: 68px; font-size: 1.7rem; }

/* ---------- Cards, lists ---------- */
.card { background: var(--color-card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); margin-bottom: 16px; }
.card.narrow { max-width: 480px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.card-title { font-size: 1.05rem; margin-bottom: 10px; }
.card-head .card-title { margin-bottom: 0; }
.sub-title { font-size: .95rem; margin: 16px 0 8px; }
.stack > * + * { margin-top: 0; }
.empty { color: var(--text-muted); padding: 8px 0; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--border); }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 2px; color: inherit; min-height: 56px; }
a.list-item:hover { text-decoration: none; background: var(--color-primary-soft); border-radius: 8px; }
.list-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.list-main small { color: var(--text-muted); }
.list-item .icon { color: var(--text-muted); width: 18px; }
.right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.grid-2 > .card, .grid-2 > .stack > .card { margin-bottom: 0; }
.grid-2 { margin-bottom: 16px; }
.stack { display: grid; gap: 16px; align-content: start; }
.details { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; }
.details dt { color: var(--text-muted); }
.details dd { margin: 0; font-weight: 600; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.field label, .field > span { font-weight: 600; font-size: .92rem; }
.field.inline { margin: 0; }
input, select, textarea {
  font: inherit; color: var(--text); width: 100%; min-height: 48px; padding: 10px 12px;
  border: 1.5px solid var(--border); border-radius: calc(var(--radius) * .75); background: #fff;
}
input[type=radio], input[type=checkbox] { width: auto; min-height: 0; }
input[type=range] { padding: 0; border: 0; min-height: 32px; accent-color: var(--color-primary); }
input[type=color] { padding: 2px; width: 52px; flex: none; cursor: pointer; }
input:focus, select:focus, textarea:focus { border-color: var(--color-primary); outline: none; box-shadow: 0 0 0 3px var(--color-primary-soft); }
.has-error input, input:invalid:not(:placeholder-shown) { border-color: var(--color-danger); }
.field-error { color: var(--color-danger); font-size: .85rem; font-weight: 600; margin: 0; }
.help { color: var(--text-muted); font-size: .85rem; margin: 0; }
.req { color: var(--color-danger); }
.form-grid { display: grid; gap: 0 16px; grid-template-columns: minmax(0, 1fr); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; flex-wrap: wrap; }
.check { display: flex; gap: 10px; align-items: center; margin: 4px 0 14px; font-size: .92rem; }
fieldset { border: 0; padding: 0; margin: 0 0 8px; min-width: 0; }
legend { font-weight: 800; font-size: 1.05rem; margin-bottom: 12px; padding: 0; }
fieldset.plain { margin: 0; }
.chip-select { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-select input { position: absolute; opacity: 0; }
.chip-select span { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1.5px solid var(--border); font-weight: 600; cursor: pointer; }
.chip-select input:checked + span { background: var(--color-primary); color: var(--color-primary-contrast); border-color: var(--color-primary); }
.chip-select input:focus-visible + span { outline: 3px solid var(--color-secondary); }
.switch { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; cursor: pointer; font-weight: 500; }
.switch input { position: absolute; opacity: 0; }
.switch span { width: 46px; height: 28px; border-radius: 999px; background: #CBD2DD; position: relative; flex: none; transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .2s; }
.switch input:checked + span { background: var(--color-success); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 3px solid var(--color-secondary); }

/* ---------- Alerts / toast ---------- */
.alert { padding: 12px 14px; border-radius: var(--radius); margin-bottom: 14px; font-weight: 500; }
.alert p:last-child { margin: 0; }
.alert-danger { background: var(--color-danger-soft); color: var(--color-danger); }
.alert-warning { background: var(--color-warning-soft); color: var(--color-warning); }
.alert-info { background: var(--color-primary-soft); color: var(--color-primary); }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 60;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  background: #111827; color: #fff; padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow-lg);
  font-weight: 600; max-width: calc(100% - 32px); animation: toast-in .25s ease-out;
}
.toast-success { background: var(--color-success); }
.toast-danger { background: var(--color-danger); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } }

/* ---------- State screens ---------- */
.state-screen { text-align: center; padding: 48px 16px; max-width: 420px; margin: 0 auto; }
.state-screen.compact { padding: 24px 8px; }
.state-icon { font-size: 2.6rem; font-weight: 800; color: var(--color-primary); margin-bottom: 8px; }
.state-screen h2 { margin-bottom: 8px; }
.state-screen p { color: var(--text-muted); margin-bottom: 16px; }

/* ---------- Image fallback ---------- */
.img-fallback { background: linear-gradient(135deg, var(--color-sidebar), var(--color-primary) 55%, var(--color-secondary)); }
picture img { width: 100%; height: 100%; object-fit: cover; }

/* =========================================================================
   MOBILE APP SHELL (default)
   ========================================================================= */
.sidebar, .topbar, .desktop-only { display: none !important; }

.appbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 8px;
  height: calc(var(--appbar-h) + var(--safe-top)); padding: var(--safe-top) 8px 0;
  background: var(--color-sidebar); color: var(--color-sidebar-text);
}
.appbar-title { flex: 1; font-size: 1.1rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar-btn { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; color: inherit; }
.appbar-btn:active { background: rgba(255,255,255,.15); }
.appbar-logo { border-radius: 10px; margin: 0 6px; }

.content { padding: 16px var(--gutter) calc(var(--tabbar-h) + var(--safe-bottom) + 24px); max-width: 1280px; margin: 0 auto; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  background: var(--color-card); border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgba(16,24,40,.06);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--text-muted); font-size: .72rem; font-weight: 600; text-decoration: none !important; position: relative;
}
.tab .icon { width: 24px; height: 24px; }
.tab.active { color: var(--color-primary); }
.tab.active::before { content: ""; position: absolute; top: 6px; width: 56px; height: 32px; border-radius: 16px; background: var(--color-primary-soft); z-index: -1; }

.fab {
  position: fixed; right: 16px; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px); z-index: 35;
  display: grid; place-items: center; width: 58px; height: 58px; border-radius: 18px;
  background: var(--color-secondary); color: var(--color-secondary-contrast); box-shadow: var(--shadow-lg);
}
.fab .icon { width: 26px; height: 26px; }

.sticky-actions {
  position: sticky; bottom: calc(var(--tabbar-h) + var(--safe-bottom)); z-index: 20;
  background: var(--color-card); margin: 0 calc(-1 * var(--gutter)); padding: 12px var(--gutter);
  border-top: 1px solid var(--border);
}
.card .sticky-actions { margin: 8px -16px -16px; border-radius: 0 0 var(--radius) var(--radius); }
.btn-block-mobile { width: 100%; }

/* Mobile cards replacing tables */
.card-list { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 10px; }
.m-card {
  display: flex; align-items: center; gap: 12px; padding: 14px; min-height: 68px;
  background: var(--color-card); border-radius: var(--radius); border: 1px solid var(--border); color: inherit; box-shadow: var(--shadow-sm);
}
.m-card:hover { text-decoration: none; }
.m-card:active { transform: scale(.99); background: var(--color-primary-soft); }
.m-card-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.m-card-main small { color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-card > .icon { color: var(--text-muted); width: 18px; }
.m-card-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--color-secondary-soft); color: var(--color-secondary); flex: none; }
.m-card-amount { text-align: right; font-weight: 800; display: flex; flex-direction: column; }
.m-card-amount small { font-weight: 500; color: var(--text-muted); }
.m-card.big { padding: 16px; }
.grade-badge { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; background: var(--color-primary); color: var(--color-primary-contrast); font-weight: 800; font-size: 1.1rem; flex: none; }

/* Toolbar & search */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.search-form { display: flex; gap: 8px; flex: 1; min-width: 0; }
.search-form input[type=search] { flex: 1; min-width: 0; border-radius: 999px; padding-left: 18px; }
.search-form select { width: auto; flex: none; max-width: 40%; }
.filter-bar { gap: 12px; }
.filter-bar .field { flex: 1; min-width: 140px; }

.segmented { display: flex; background: #E9EDF4; border-radius: 999px; padding: 4px; margin-bottom: 12px; overflow-x: auto; }
.segmented a { flex: 1; text-align: center; padding: 8px 12px; border-radius: 999px; color: var(--text-muted); font-weight: 600; white-space: nowrap; text-decoration: none; font-size: .9rem; }
.segmented a.active { background: var(--color-card); color: var(--color-primary); box-shadow: var(--shadow-sm); }

/* Bottom sheet */
.sheet { position: fixed; inset: 0; z-index: 70; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .45); animation: fade .2s; }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; background: var(--color-card);
  border-radius: 20px 20px 0 0; padding: 8px 20px calc(20px + var(--safe-bottom)); max-height: 85vh; overflow: auto;
  animation: sheet-up .25s ease-out; box-shadow: var(--shadow-lg);
}
.sheet-handle { width: 40px; height: 5px; border-radius: 3px; background: var(--border); margin: 4px auto 12px; }
.sheet-title { font-size: 1.1rem; margin-bottom: 14px; }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.kpi { background: var(--color-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow-sm); min-width: 0; }
.kpi-label { color: var(--text-muted); font-size: .82rem; font-weight: 600; }
.kpi-value { font-size: 1.35rem; font-weight: 800; overflow-wrap: anywhere; }
.kpi-note { font-size: .78rem; color: var(--text-muted); }
.kpi-alert .kpi-value { color: var(--color-danger); }
.stat-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--color-card); border-radius: var(--radius); border: 1px solid var(--border); padding: 12px 8px; text-align: center; display: flex; flex-direction: column; min-width: 0; }
.stat span { font-weight: 800; font-size: 1.05rem; overflow-wrap: anywhere; }
.stat small { color: var(--text-muted); }
.stat-danger span { color: var(--color-danger); }
.stat-ok span { color: var(--color-success); }
.pill-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pill-stat { background: var(--color-bg); border-radius: 12px; padding: 10px 4px; text-align: center; display: flex; flex-direction: column; }
.pill-stat span { font-weight: 800; font-size: 1.2rem; }
.pill-stat small { color: var(--text-muted); }

/* Welcome banner */
.welcome { position: relative; border-radius: calc(var(--radius) * 1.3); overflow: hidden; margin-bottom: 16px; min-height: 136px; color: #fff; }
.welcome-img { position: absolute; inset: 0; }
.welcome-img img { height: 100%; }
.welcome::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(0,0,0,.65), rgba(0,0,0,.15)); }
.welcome-text { position: relative; z-index: 1; padding: 20px; }
.welcome-text h2 { font-size: 1.35rem; margin-bottom: 4px; }
.welcome-date { opacity: .85; font-size: .85rem; margin-bottom: 4px; }

.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quick-btn { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 56px; padding: 8px; border-radius: var(--radius); background: var(--color-primary-soft); color: var(--color-primary); font-weight: 700; font-size: .9rem; }

/* More tab */
.profile-card { display: flex; align-items: center; gap: 14px; background: var(--color-card); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; border: 1px solid var(--border); }
.profile-card div { display: flex; flex-direction: column; }
.profile-card small { color: var(--text-muted); }
.tile-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px; }
.tile {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 6px; text-align: center;
  background: var(--color-card); border-radius: var(--radius); border: 1px solid var(--border); color: var(--text);
  font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer;
}
.tile:hover { text-decoration: none; }
.tile-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: var(--color-primary-soft); color: var(--color-primary); }
.logout-form { margin-top: 8px; }

/* Profile hero */
.profile-hero { display: flex; gap: 14px; align-items: center; background: var(--color-card); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; border: 1px solid var(--border); }
.profile-hero h2 { font-size: 1.2rem; }
.profile-hero p { margin: 2px 0; }

/* Steps / wizard */
.steps { display: flex; list-style: none; padding: 0; margin: 0 0 16px; gap: 8px; counter-reset: step; }
.step { flex: 1; display: flex; align-items: center; gap: 6px; font-size: .82rem; font-weight: 600; color: var(--text-muted); }
.step::before { content: attr(data-step-label); display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--border); color: var(--text-muted); font-weight: 800; flex: none; }
.step.active { color: var(--color-primary); }
.step.active::before, .step.done::before { background: var(--color-primary); color: var(--color-primary-contrast); }
.js .wizard .wizard-step:not(.active) { display: none; }
.wizard-submit { display: none; }
.js .wizard.last-step .wizard-submit { display: inline-flex; }
.js .wizard.last-step .wizard-next { display: none; }
html:not(.js) .wizard-next, html:not(.js) .wizard-prev { display: none; }
html:not(.js) .wizard-submit { display: inline-flex; }

/* Attendance */
.att-summary { position: sticky; top: calc(var(--appbar-h) + var(--safe-top)); z-index: 15; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; background: var(--color-bg); padding: 8px 0; margin-bottom: 8px; }
.att-count { padding: 4px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--color-card); border: 1px solid var(--border); }
.att-count.present b { color: var(--color-success); }
.att-count.absent b { color: var(--color-danger); }
.att-count.late b { color: var(--color-warning); }
.att-summary .btn { margin-left: auto; }
.att-list, .marks-list { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.att-row, .marks-row { background: var(--color-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; display: grid; gap: 10px; }
.att-student { display: flex; gap: 10px; align-items: center; }
.att-student span:last-child { display: flex; flex-direction: column; }
.att-student small { color: var(--text-muted); }
.att-options { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 0; }
.att-opt input { position: absolute; opacity: 0; }
.att-opt span {
  display: grid; place-items: center; min-height: 46px; border-radius: 12px; border: 1.5px solid var(--border);
  font-weight: 800; cursor: pointer; user-select: none; color: var(--text-muted);
}
.att-opt em { font-style: normal; }
.desktop-label { display: none; }
.att-opt input:focus-visible + span { outline: 3px solid var(--color-secondary); }
.att-present input:checked + span { background: var(--color-success); border-color: var(--color-success); color: #fff; }
.att-absent input:checked + span { background: var(--color-danger); border-color: var(--color-danger); color: #fff; }
.att-late input:checked + span { background: var(--color-warning); border-color: var(--color-warning); color: #fff; }
.att-half_day input:checked + span { background: var(--color-secondary); border-color: var(--color-secondary); color: var(--color-secondary-contrast); }
.att-leave input:checked + span { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-primary-contrast); }
fieldset:disabled .att-opt span { cursor: default; opacity: .8; }

/* Marks */
.marks-inputs { display: flex; gap: 8px; align-items: center; }
.marks-input { width: 96px; flex: none; text-align: center; font-weight: 800; font-size: 1.1rem; }
.marks-max { color: var(--text-muted); font-weight: 600; flex: none; }
.marks-status { flex: 1; min-width: 0; }

/* Workflow */
.workflow { list-style: none; display: flex; padding: 0; margin: 0 0 12px; gap: 4px; }
.workflow li { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: .75rem; font-weight: 600; color: var(--text-muted); position: relative; text-align: center; }
.workflow li span { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--border); font-weight: 800; }
.workflow li.done span { background: var(--color-success); color: #fff; }
.workflow li.current span { background: var(--color-primary); color: var(--color-primary-contrast); }
.workflow li.current { color: var(--color-primary); }
.workflow-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form input { width: auto; flex: 1; min-width: 180px; }

/* Result: summary ring */
.result-summary { display: flex; gap: 16px; align-items: center; background: var(--color-card); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; border: 1px solid var(--border); }
.result-summary-text h2 { font-size: 1.15rem; }
.result-summary-text p { margin: 2px 0; }
.result-summary .badge { margin-top: 4px; margin-right: 4px; }
.ring { position: relative; width: 96px; height: 96px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 3.4; }
.ring-bg { stroke: var(--color-primary-soft); }
.ring-fg { stroke: var(--color-secondary); stroke-linecap: round; }
.ring-text { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1.1; }
.ring-text strong { font-size: 1.4rem; color: var(--color-primary); }
.ring-text small { color: var(--text-muted); font-weight: 600; }
.ring-sm { width: 64px; height: 64px; }
.ring-sm .ring-text strong { font-size: 1.05rem; }

.report-wrap { max-width: 860px; margin: 0 auto; }
.report-card, .receipt { background: var(--color-card); border-radius: var(--radius); border: 1px solid var(--border); padding: 16px; margin-bottom: 16px; }
.report-head { display: flex; gap: 12px; align-items: center; border-bottom: 3px solid var(--color-primary); padding-bottom: 12px; margin-bottom: 12px; }
.report-head h1 { font-size: 1.15rem; color: var(--color-primary); }
.report-head p { margin: 0; font-size: .82rem; color: var(--text-muted); }
.report-head img { border-radius: 12px; }
.report-title { text-align: center; font-size: 1rem; background: var(--color-primary-soft); color: var(--color-primary); padding: 8px; border-radius: 8px; margin-bottom: 12px; }
.report-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin: 0 0 14px; }
.report-meta dt { font-size: .75rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.report-meta dd { margin: 0; font-weight: 600; }
.report-table { display: none; }
.subject-cards { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 8px; }
.subject-card { border: 1px solid var(--border); border-radius: 12px; padding: 12px; display: grid; gap: 6px; }
.subject-card-top { display: flex; justify-content: space-between; align-items: center; }
.subject-card small { color: var(--text-muted); font-weight: 600; }
.bar { height: 8px; border-radius: 4px; background: var(--color-primary-soft); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--color-secondary); border-radius: 4px; }
.bar.light { background: rgba(255,255,255,.3); }
.bar.light span { background: #fff; }
.report-foot { display: grid; gap: 8px; padding: 12px; background: var(--color-bg); border-radius: 12px; margin-bottom: 16px; }
.report-foot div { display: flex; justify-content: space-between; gap: 12px; }
.report-foot dt { color: var(--text-muted); }
.report-foot dd { margin: 0; text-align: right; }
.signatures { display: flex; justify-content: space-between; gap: 24px; margin: 32px 0 8px; }
.signatures div { flex: 1; text-align: center; font-size: .82rem; color: var(--text-muted); }
.signatures span { display: block; border-top: 1px solid var(--text-muted); margin-bottom: 4px; height: 0; }
.report-note { font-size: .75rem; color: var(--text-muted); text-align: center; margin: 0; }
.report-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.report-actions .btn-primary { grid-column: 1 / -1; }
.receipt .table { margin-bottom: 14px; }

/* Parent */
.child-switcher { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; }
.child-chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; border-radius: 999px; border: 1.5px solid var(--border); background: var(--color-card); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; min-height: 44px; }
.child-chip.active { border-color: var(--color-primary); background: var(--color-primary-soft); color: var(--color-primary); }
.child-card { display: flex; gap: 16px; align-items: center; padding: 18px; border-radius: calc(var(--radius) * 1.3); margin-bottom: 14px;
  background: linear-gradient(135deg, var(--color-sidebar), var(--color-primary)); color: var(--color-sidebar-text); box-shadow: var(--shadow); }
.child-card h2 { font-size: 1.25rem; }
.child-card p { margin: 2px 0; }
.child-card .muted { color: inherit; opacity: .8; }
.child-card .avatar { background: rgba(255,255,255,.2); color: #fff; }
.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.home-tile { display: flex; flex-direction: column; gap: 4px; padding: 14px; border-radius: var(--radius); background: var(--color-card); border: 1px solid var(--border); color: inherit; min-height: 120px; }
.home-tile:hover { text-decoration: none; }
.home-tile small { color: var(--text-muted); font-size: .78rem; }
.home-tile-label { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.home-tile-value { font-size: 1.25rem; font-weight: 800; }
.tile-alert { border-color: var(--color-danger-soft); background: linear-gradient(180deg, var(--color-danger-soft), var(--color-card)); }
.tile-alert .home-tile-value { color: var(--color-danger); }
.tile-ok .home-tile-value { color: var(--color-success); }
.result-teaser { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: var(--radius); background: var(--color-card); border: 1px solid var(--border); margin-bottom: 14px; color: inherit; }
.result-teaser:hover { text-decoration: none; }
.result-teaser > div:nth-child(2) { flex: 1; display: flex; flex-direction: column; }
.result-teaser small { color: var(--text-muted); }
.fee-hero { border-radius: calc(var(--radius) * 1.3); padding: 20px; margin-bottom: 14px; display: grid; gap: 8px;
  background: linear-gradient(135deg, var(--color-danger), var(--color-warning)); color: #fff; }
.fee-hero.ok { background: linear-gradient(135deg, var(--color-success), var(--color-secondary)); }
.fee-hero strong { font-size: 2rem; }
.fee-note { opacity: .9; }

/* Calendar */
.month-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.month-nav .card-title { margin: 0; }
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-head { text-align: center; font-size: .75rem; font-weight: 700; color: var(--text-muted); padding: 4px 0; }
.cal-day { aspect-ratio: 1; display: grid; place-items: center; border-radius: 10px; font-weight: 600; font-size: .9rem; background: var(--color-bg); }
.cal-day.empty { background: transparent; }
.cal-day.today { outline: 2px solid var(--color-primary); }
.cal-present { background: var(--color-success-soft); color: var(--color-success); }
.cal-absent { background: var(--color-danger); color: #fff; }
.cal-late { background: var(--color-warning-soft); color: var(--color-warning); }
.cal-half_day { background: var(--color-warning-soft); color: var(--color-warning); }
.cal-leave { background: var(--color-primary-soft); color: var(--color-primary); }
.cal-holiday { background: var(--color-secondary-soft); color: var(--color-secondary); }
.cal-sunday { color: var(--text-muted); opacity: .6; }
.legend { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .82rem; }
.legend li { display: flex; align-items: center; gap: 6px; }
.dot { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.dot.cal-present { background: var(--color-success); }
.dot.cal-late { background: var(--color-warning); }

.notice-date { font-size: .8rem; color: var(--text-muted); margin-bottom: 4px; }

/* Table (desktop) */
.table-wrap { background: var(--color-card); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; margin-bottom: 16px; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table thead th { background: var(--color-bg); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); white-space: nowrap; }
.table thead th a { color: inherit; }
.table tbody tr:hover { background: var(--color-primary-soft); }
.table tfoot th { background: var(--color-bg); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.pagination { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 8px 0 16px; flex-wrap: wrap; }
.pagination-links { display: flex; gap: 8px; }

/* Update banner */
.update-banner { position: fixed; top: calc(var(--appbar-h) + var(--safe-top) + 8px); left: 50%; transform: translateX(-50%); z-index: 80; background: #111827; color: #fff; padding: 8px 8px 8px 16px; border-radius: 999px; display: flex; gap: 10px; align-items: center; box-shadow: var(--shadow-lg); }

/* ---------- Public: landing / auth / result check ---------- */
body.public { background: var(--color-bg); }
.landing { min-height: 100vh; display: flex; flex-direction: column; }
.landing-hero { position: relative; min-height: 46vh; color: #fff; display: flex; }
.landing-img { position: absolute; inset: 0; }
.landing-img img { height: 100%; }
.landing-hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.25), rgba(0,0,0,.7)); }
.landing-overlay { position: relative; z-index: 1; margin-top: auto; padding: calc(24px + var(--safe-top)) 20px 36px; }
.landing-logo { border-radius: 16px; margin-bottom: 12px; box-shadow: var(--shadow-lg); }
.landing-overlay h1 { font-size: 1.8rem; }
.landing-tagline { opacity: .9; font-size: 1.05rem; margin-top: 4px; }
.landing-actions { margin: -20px 16px 0; position: relative; z-index: 2; display: grid; gap: 10px; }
.action-card { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: var(--radius); background: var(--color-card); box-shadow: var(--shadow); color: var(--text); border: 0; font: inherit; text-align: left; cursor: pointer; width: 100%; }
.action-card:hover { text-decoration: none; }
.action-card > span:nth-child(2) { flex: 1; display: flex; flex-direction: column; }
.action-card small { color: var(--text-muted); }
.action-card > .icon { color: var(--text-muted); }
.action-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: var(--color-primary); color: var(--color-primary-contrast); flex: none; }
.action-icon.accent { background: var(--color-secondary); color: var(--color-secondary-contrast); }
.ios-hint { background: var(--color-primary-soft); color: var(--color-primary); padding: 12px; border-radius: var(--radius); font-size: .9rem; }
.landing-footer { margin-top: auto; padding: 24px 16px calc(24px + var(--safe-bottom)); text-align: center; font-size: .85rem; color: var(--text-muted); }

.auth { min-height: 100vh; display: flex; flex-direction: column; }
.auth-visual { position: relative; height: 30vh; min-height: 180px; color: #fff; }
.auth-img { position: absolute; inset: 0; }
.auth-img img { height: 100%; }
.auth-visual::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.1), rgba(0,0,0,.6)); }
.auth-visual-text { display: none; }
.auth-panel { flex: 1; margin-top: -28px; position: relative; z-index: 1; background: var(--color-card); border-radius: 24px 24px 0 0; padding: 0 20px calc(24px + var(--safe-bottom)); }
.auth-card { max-width: 420px; margin: 0 auto; }
.auth-logo { border-radius: 16px; margin: -28px 0 12px; box-shadow: var(--shadow); border: 4px solid var(--color-card); width: 64px; height: 64px; }
.auth-card h1 { font-size: 1.6rem; }
.auth-card .muted { margin-bottom: 20px; }
.auth-links { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; font-size: .9rem; flex-wrap: wrap; }

.result-check { min-height: 100vh; }
.rc-hero { position: relative; color: #fff; min-height: 210px; display: flex; }
.rc-hero-img { position: absolute; inset: 0; }
.rc-hero-img img { height: 100%; }
.rc-hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.35), color-mix(in srgb, var(--color-sidebar) 88%, transparent)); }
.rc-hero-text { position: relative; z-index: 1; padding: calc(16px + var(--safe-top)) 20px 44px; margin-top: auto; width: 100%; max-width: 560px; margin-inline: auto; }
.rc-hero-text h1 { font-size: 2rem; margin-top: 18px; }
.rc-brand { display: flex; align-items: center; gap: 10px; color: inherit; font-weight: 700; }
.rc-brand img { border-radius: 10px; }
.rc-body { padding: 0 16px 32px; max-width: 560px; margin: -28px auto 0; position: relative; z-index: 2; }
.rc-form { box-shadow: var(--shadow); padding: 20px; }
.rc-topbar { position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center; padding: calc(8px + var(--safe-top)) 16px 8px; background: var(--color-sidebar); color: var(--color-sidebar-text); }
.rc-topbar .btn-ghost { color: inherit; border-color: rgba(255,255,255,.4); }
.public-report { padding: 16px; }

/* ---------- Theme settings ---------- */
.theme-layout { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); margin-bottom: 16px; }
.theme-form { margin-bottom: 0; }
.preset-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 18px; }
.preset { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 12px; border: 2px solid var(--border); background: var(--color-card); font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; text-align: left; }
.preset.active { border-color: var(--color-primary); background: var(--color-primary-soft); }
.preset-swatch { display: flex; border-radius: 8px; overflow: hidden; height: 26px; flex: none; min-width: 66px; }
.preset-swatch i { flex: 1; }
.color-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 16px; }
.color-input { display: flex; gap: 8px; }
.color-input input[type=text] { font-family: ui-monospace, Consolas, monospace; text-transform: uppercase; }
.contrast-live { font-size: .88rem; font-weight: 600; }
.contrast-live.bad { color: var(--color-danger); }
.contrast-live.ok { color: var(--color-success); }
.theme-preview { display: grid; gap: 12px; }
.tp-phone { width: 240px; margin: 0 auto; border-radius: 28px; overflow: hidden; border: 8px solid #111827; background: var(--p-bg); box-shadow: var(--shadow-lg); font-size: .8rem; }
.tp-appbar { display: flex; align-items: center; gap: 8px; padding: 10px; background: var(--p-side); color: var(--p-side-text); }
.tp-appbar b { flex: 1; }
.tp-logo { width: 20px; height: 20px; border-radius: 6px; background: var(--p-secondary); }
.tp-body { padding: 10px; display: grid; gap: 8px; min-height: 230px; }
.tp-card { background: var(--p-card); border-radius: var(--p-radius); padding: 10px; display: flex; flex-direction: column; gap: 4px; border: 1px solid var(--border); }
.tp-card strong { font-size: 1.05rem; }
.tp-btn { display: inline-block; text-align: center; background: var(--p-primary); color: var(--p-primary-text); border-radius: var(--p-radius); padding: 6px 12px; font-weight: 700; }
.tp-btn.secondary { background: var(--p-secondary); color: var(--p-secondary-text); }
.tp-link { color: var(--p-primary); font-weight: 700; }
.tp-row { display: flex; gap: 6px; }
.tp-badge { padding: 2px 8px; border-radius: 999px; font-weight: 700; font-size: .72rem; color: #fff; }
.tp-badge.ok { background: var(--p-success); }
.tp-badge.warn { background: var(--p-warning); }
.tp-badge.bad { background: var(--p-danger); }
.tp-tabbar { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--p-card); border-top: 1px solid var(--border); text-align: center; padding: 8px 0; font-size: .7rem; color: var(--text-muted); }
.tp-tabbar .on { color: var(--p-primary); font-weight: 800; }
.tp-desktop { display: none; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: var(--p-bg); font-size: .8rem; }
.tp-side { background: var(--p-side); color: var(--p-side-text); padding: 10px; display: flex; flex-direction: column; gap: 6px; width: 110px; }
.tp-side .on { background: rgba(255,255,255,.18); border-radius: 6px; padding: 2px 6px; }
.tp-main { flex: 1; padding: 10px; display: grid; gap: 8px; align-content: start; }
.tp-receipt-head { border-bottom: 3px solid var(--p-primary); color: var(--p-primary); font-weight: 800; padding-bottom: 4px; }

/* =========================================================================
   DESKTOP ERP LAYOUT
   ========================================================================= */
@media (min-width: 900px) {
  .appbar, .tabbar, .mobile-only, .fab.mobile-only { display: none !important; }
  .fab { display: none; }
  .desktop-only { display: revert !important; }
  .table-wrap.desktop-only { display: block !important; }
  .btn.desktop-only { display: inline-flex !important; }
  select.desktop-only { display: block !important; }

  .sidebar {
    display: flex !important; flex-direction: column; position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
    background: var(--color-sidebar); color: var(--color-sidebar-text); padding: 16px 12px; overflow-y: auto; z-index: 30;
  }
  .sidebar-brand { display: flex; align-items: center; gap: 10px; color: inherit; font-weight: 800; font-size: 1.05rem; padding: 4px 8px 16px; }
  .sidebar-brand img { border-radius: 10px; }
  .sidebar-group { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; opacity: .65; margin: 14px 10px 6px; font-weight: 700; }
  .sidebar-link {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: inherit; opacity: .88;
    font-weight: 600; font-size: .94rem; width: 100%; background: none; border: 0; font-family: inherit; cursor: pointer; text-align: left;
  }
  .sidebar-link:hover { text-decoration: none; background: var(--color-sidebar-active); opacity: 1; }
  .sidebar-link.active { background: var(--color-sidebar-active); opacity: 1; box-shadow: inset 3px 0 0 var(--color-secondary); }
  .sidebar-link .icon { width: 20px; height: 20px; }
  .sidebar-logout { margin-top: auto; padding-top: 12px; }

  .shell { margin-left: var(--sidebar-w); min-height: 100vh; }
  .topbar {
    display: flex !important; align-items: center; justify-content: space-between; gap: 16px;
    position: sticky; top: 0; z-index: 20; height: 64px; padding: 0 28px;
    background: color-mix(in srgb, var(--color-card) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
  }
  .topbar-title { font-size: 1.25rem; }
  .topbar-right { display: flex; align-items: center; gap: 12px; }
  .topbar-user { font-weight: 600; }
  .content { padding: 24px 28px 40px; }

  .card { padding: 20px; }
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .kpi { padding: 18px; }
  .kpi-value { font-size: 1.6rem; }
  .grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid .span-2 { grid-column: 1 / -1; }
  .color-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .preset-grid { grid-template-columns: repeat(3, 1fr); }
  .theme-layout { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; }
  .theme-preview-wrap { position: sticky; top: 88px; }
  .tp-desktop { display: flex; }
  .quick-grid { grid-template-columns: repeat(4, 1fr); }
  .welcome { min-height: 160px; }
  .welcome-text { padding: 28px; }

  .sticky-actions { position: static; margin: 16px 0 0; padding: 0; border: 0; background: none; }
  .card .sticky-actions { margin: 16px 0 0; }
  .btn-block-mobile { width: auto; }
  .toast { bottom: 24px; left: auto; right: 24px; transform: none; }
  @keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }

  .att-summary { top: 64px; }
  .att-row, .marks-row { grid-template-columns: minmax(220px, 1fr) auto; align-items: center; }
  .att-options { grid-template-columns: repeat(5, auto); }
  .att-opt span { padding: 0 14px; min-height: 40px; }
  .desktop-label { display: inline; font-weight: 600; }
  .att-opt span { gap: 0; display: inline-flex; align-items: center; }
  .marks-row .field-error { grid-column: 1 / -1; }

  /* Wizard shows everything on desktop */
  .js .wizard .wizard-step:not(.active) { display: block; }
  .wizard .steps, .wizard-next, .wizard-prev { display: none !important; }
  .wizard .wizard-submit { display: inline-flex !important; }
  .wizard-step { padding-bottom: 8px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }

  .report-table { display: table; margin-bottom: 14px; }
  .subject-cards { display: none; }
  .report-meta { grid-template-columns: repeat(4, 1fr); }
  .report-card, .receipt { padding: 32px; }
  .report-head h1 { font-size: 1.5rem; }
  .report-foot { grid-template-columns: repeat(3, 1fr); }
  .report-foot div { flex-direction: column; gap: 2px; }
  .report-foot dd { text-align: left; }
  .report-actions { display: flex; justify-content: flex-end; }

  /* Public pages as split screens on desktop */
  .landing { flex-direction: row; flex-wrap: wrap; }
  .landing-hero { flex: 1 1 55%; min-height: 100vh; }
  .landing-overlay { padding: 48px; }
  .landing-overlay h1 { font-size: 2.6rem; }
  .landing-actions { flex: 1 1 35%; margin: 0; padding: 48px; align-content: center; max-width: 520px; }
  .landing-footer { flex-basis: 100%; position: absolute; bottom: 0; right: 0; width: 45%; }
  .auth { flex-direction: row; }
  .auth-visual { flex: 1.2; height: auto; min-height: 100vh; }
  .auth-visual-text { display: block; position: absolute; z-index: 1; bottom: 48px; left: 48px; right: 48px; }
  .auth-visual-text h2 { font-size: 2.2rem; margin-bottom: 8px; }
  .auth-panel { flex: 1; margin: 0; border-radius: 0; display: flex; align-items: center; padding: 48px; }
  .auth-logo { margin: 0 0 16px; }
  .rc-hero { min-height: 280px; }
  .public-report { padding: 32px 24px; }
  .result-summary { display: none; }
}

@media (min-width: 900px) and (max-width: 1100px) {
  :root { --sidebar-w: 212px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* =========================================================================
   PRINT (report cards, receipts)
   ========================================================================= */
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; font-size: 12pt; }
  .sidebar, .topbar, .appbar, .tabbar, .fab, .no-print, .toast, .alert, .update-banner, .result-summary, .rc-topbar { display: none !important; }
  .shell { margin: 0 !important; }
  .content, .public-report { padding: 0 !important; }
  .report-card, .receipt { border: 0; box-shadow: none; padding: 0; }
  .report-table { display: table !important; }
  .subject-cards { display: none !important; }
  .report-meta { grid-template-columns: repeat(4, 1fr); }
  .report-foot { grid-template-columns: repeat(3, 1fr); }
  .table th, .table td { padding: 6px 8px; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Certificates ---------- */
.type-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; margin-bottom: 14px; }
.type-card input { position: absolute; opacity: 0; }
.type-card span { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: var(--radius); cursor: pointer; background: var(--color-card); }
.type-card small { color: var(--text-muted); }
.type-card input:checked + span { border-color: var(--color-primary); background: var(--color-primary-soft); box-shadow: inset 0 0 0 1px var(--color-primary); }
.type-card input:focus-visible + span { outline: 3px solid var(--color-secondary); }
.js [data-show-for][hidden] { display: none !important; }
.profile-hero.plain { border: 0; padding: 0 0 12px; margin-bottom: 12px; border-bottom: 1px solid var(--border); border-radius: 0; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: .9rem; line-height: 1.6; }
.placeholders { margin: 4px 0 12px; font-size: .88rem; }
.placeholders summary { cursor: pointer; font-weight: 600; color: var(--color-primary); }
.placeholders code { display: inline-block; margin: 3px 2px; }
.nowrap { white-space: nowrap; }
.verify { min-height: 100vh; }
.verify-body { max-width: 520px; margin: 0 auto; padding: 24px 16px; }
.verify-card { background: var(--color-card); border-radius: calc(var(--radius) * 1.3); padding: 24px; text-align: center; box-shadow: var(--shadow); border-top: 6px solid var(--color-success); margin-bottom: 16px; }
.verify-card.bad { border-top-color: var(--color-danger); }
.verify-card h1 { font-size: 1.4rem; margin: 8px 0; }
.verify-card .details { text-align: left; margin-top: 16px; }
.verify-icon { display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; font-size: 1.8rem; font-weight: 800; background: var(--color-success-soft); color: var(--color-success); }
.verify-icon .icon { width: 34px; height: 34px; }
.verify-card.bad .verify-icon { background: var(--color-danger-soft); color: var(--color-danger); }
@media (min-width: 900px) { .type-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.seg-radio { margin: 0; }
.seg-radio label { flex: 1; }
.seg-radio input { position: absolute; opacity: 0; }
.seg-radio span { display: block; text-align: center; padding: 9px 12px; border-radius: 999px; color: var(--text-muted); font-weight: 600; cursor: pointer; font-size: .9rem; }
.seg-radio input:checked + span { background: var(--color-card); color: var(--color-primary); box-shadow: var(--shadow-sm); }
.seg-radio input:focus-visible + span { outline: 3px solid var(--color-secondary); }

/* ---------- Dashboard (redesign) ---------- */
.dash-head { margin-bottom: 16px; }
.dash-head .welcome { margin-bottom: 12px; }
.dash-quick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.dash-quick-btn { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 10px 12px; border-radius: var(--radius); background: var(--color-card); border: 1px solid var(--border); color: var(--text); font-weight: 600; font-size: .9rem; box-shadow: var(--shadow-sm); }
.dash-quick-btn:hover { text-decoration: none; border-color: var(--color-primary); color: var(--color-primary); }
.dash-quick-btn .icon { color: var(--color-primary); width: 20px; height: 20px; }
a.kpi { color: inherit; text-decoration: none; position: relative; transition: box-shadow .15s, transform .15s; }
a.kpi:hover { box-shadow: var(--shadow); }
.kpi-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; margin-bottom: 6px; background: var(--color-primary-soft); color: var(--color-primary); }
.kpi-icon .icon { width: 20px; height: 20px; }
.kpi-green .kpi-icon { background: var(--color-success-soft); color: var(--color-success); }
.kpi-teal .kpi-icon { background: var(--color-secondary-soft); color: var(--color-secondary); }
.kpi-red .kpi-icon { background: var(--color-danger-soft); color: var(--color-danger); }
.kpi-red .kpi-value { color: var(--color-danger); }
.card-sub { color: var(--text-muted); font-size: .85rem; margin: 2px 0 0; }
.dash-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.dash-main, .dash-side { display: grid; gap: 16px; align-content: start; min-width: 0; }
.dash-main > .card, .dash-side > .card { margin-bottom: 0; }
.class-tiles { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.class-tile { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--color-bg); color: inherit; height: 100%; }
.class-tile:hover { text-decoration: none; border-color: var(--color-primary); }
.class-tile.done { background: var(--color-card); }
.class-tile-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; flex-wrap: wrap; }
.class-tile-top strong { font-size: .92rem; }
.class-tile small { color: var(--text-muted); font-size: .78rem; }
.class-tile .bar span { background: var(--color-success); }
.pill-stat.ok span { color: var(--color-success); }
.pill-row.three { grid-template-columns: repeat(3, 1fr); }
a.pill-stat { color: inherit; text-decoration: none; }
a.pill-stat:hover { background: var(--color-primary-soft); }
.notice-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-secondary); flex: none; align-self: flex-start; margin-top: 8px; }

/* 7-day mini bar chart: one series, thin bars, rounded data end, recessive baseline */
.mini-chart { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; height: 140px; align-items: end; border-bottom: 1px solid var(--border); padding-top: 8px; margin-bottom: 4px; }
.mini-col { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; outline: none; cursor: default; }
.mini-col::before { content: ""; position: absolute; inset: 0 2px; border-radius: 6px; }
.mini-col:hover::before, .mini-col:focus-visible::before { background: var(--color-primary-soft); }
.mini-bar { position: relative; width: min(28px, 60%); background: var(--color-primary); border-radius: 4px 4px 0 0; min-height: 0; }
.mini-col small { position: absolute; bottom: -22px; font-size: .75rem; color: var(--text-muted); }
.mini-col[data-tip]:hover::after, .mini-col[data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%);
  background: #111827; color: #fff; font-size: .78rem; font-weight: 600; padding: 6px 10px; border-radius: 8px; white-space: nowrap; z-index: 5; pointer-events: none;
}
.mini-chart + table + .sub-title, .mini-chart ~ .sub-title { margin-top: 32px; }

@media (min-width: 900px) {
  .dash-head { display: flex; align-items: stretch; gap: 16px; }
  .dash-head .welcome { flex: 1; margin: 0; min-height: 0; color: var(--color-sidebar-text);
    background: linear-gradient(120deg, var(--color-sidebar), var(--color-primary)); }
  .dash-head .welcome-img, .dash-head .welcome::after { display: none; }
  .dash-head .welcome-text { padding: 20px 24px; }
  .dash-head .welcome-text h2 { font-size: 1.45rem; }
  .dash-head .welcome-text p:last-child { margin: 0; opacity: .85; }
  .dash-quick { flex: 0 0 auto; display: grid; grid-template-columns: repeat(2, 168px); gap: 8px; align-content: center; }
  .dash-quick-btn { min-height: 46px; }
  .dash-grid { grid-template-columns: minmax(0, 1fr) 340px; }
  .class-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .kpi { min-height: 132px; }
  .update-banner { top: auto; bottom: 24px; left: auto; right: 24px; transform: none; }
}
@media (min-width: 900px) and (max-width: 1199px) {
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
  .dash-side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .class-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }

}
@media (min-width: 1500px) {

}
@media (min-width: 900px) {
  .dash-quick, .dash-quick { display: flex; flex-wrap: wrap; align-content: center; justify-content: flex-end; gap: 8px; max-width: 48%; }
  .dash-quick-btn { padding: 10px 16px; }
}

/* ---------- Full-width fluid desktop layout (no side gutters on wide screens) ---------- */
@media (min-width: 900px) {
  .content { max-width: none; margin: 0; padding: 20px 24px 28px; }
  .topbar { padding: 0 24px; }
}
@media (min-width: 1500px) {
  .dash-grid { grid-template-columns: minmax(0, 1fr) 400px; }
  .class-tiles { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .kpis { gap: 16px; }
}

/* =========================================================================
   LOGIN (redesign) — illustration + animations; reduced-motion disables all
   ========================================================================= */
.login { min-height: 100vh; display: flex; flex-direction: column; background: var(--color-bg); }
.login-brand {
  position: relative; overflow: hidden; color: var(--color-sidebar-text);
  background: linear-gradient(150deg, var(--color-sidebar) 0%, var(--color-primary) 65%, var(--color-secondary) 140%);
  padding: calc(16px + var(--safe-top)) 20px 56px;
}
.blob { position: absolute; border-radius: 50%; filter: blur(2px); opacity: .18; background: #fff; animation: blob 14s ease-in-out infinite; }
.blob.b1 { width: 220px; height: 220px; top: -80px; right: -60px; }
.blob.b2 { width: 140px; height: 140px; bottom: 30px; left: -50px; background: var(--color-secondary); opacity: .35; animation-delay: -5s; }
.blob.b3 { width: 70px; height: 70px; top: 40%; right: 18%; opacity: .12; animation-delay: -9s; }
@keyframes blob { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(12px, -16px) scale(1.08); } }

.login-school { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 10px; color: inherit; font-weight: 800; font-size: 1.05rem; }
.login-school:hover { text-decoration: none; }
.login-school img { border-radius: 12px; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.login-art { position: relative; z-index: 1; max-width: 360px; margin: 10px auto 0; animation: rise .8s ease-out both; }
.login-photo img { border-radius: 18px; aspect-ratio: 4 / 3; box-shadow: var(--shadow-lg); }
.login-pitch { display: none; position: relative; z-index: 1; }

/* Illustration */
.ill { width: 100%; height: auto; overflow: visible; }
.ill-sun { fill: #FCD34D; animation: pulse 4s ease-in-out infinite; transform-origin: 392px 70px; }
.ill-cloud { fill: #fff; opacity: .9; }
.ill-cloud.c1 { animation: drift 18s linear infinite; }
.ill-cloud.c2 { animation: drift 26s linear infinite; animation-delay: -10s; opacity: .7; }
.ill-hill { fill: rgba(255,255,255,.16); }
.ill-hill.back { fill: rgba(255,255,255,.08); }
.ill-tree rect { fill: #7C4A21; }
.ill-tree circle { fill: #22C55E; }
.ill-school .main { fill: #fff; }
.ill-school .wing { fill: #F1F5F9; }
.ill-school .roof { fill: var(--color-secondary); }
.ill-school .main-roof { fill: var(--color-danger); }
.ill-school .win rect { fill: var(--color-primary-soft); stroke: var(--color-primary); stroke-width: 1.5; }
.ill-school .win rect:nth-child(3n) { fill: #FEF3C7; animation: glow 3s ease-in-out infinite; }
.ill-school .door { fill: var(--color-primary); }
.ill-school .step { fill: #CBD5E1; }
.ill-school .clock { fill: #fff; stroke: var(--color-primary); stroke-width: 2.5; }
.ill-school .clock-hand { stroke: var(--color-primary); stroke-width: 2; stroke-linecap: round; fill: none; }
.ill-school .pole { fill: #E5E7EB; }
.ill-flag { fill: #F97316; transform-origin: 241px 79px; animation: wave 1.6s ease-in-out infinite; }
.ill-float { animation: float 5s ease-in-out infinite; }
.ill-float.f2 { animation-duration: 6s; animation-delay: -1s; }
.ill-float.f3 { animation-duration: 7s; animation-delay: -2s; }
.ill-float.f4 { animation-duration: 5.5s; animation-delay: -3s; }
.ill-float.f5 { animation: twinkle 3s ease-in-out infinite; }
.ill .book { fill: #fff; stroke: var(--color-primary); stroke-width: 2; }
.ill .book-spine, .ill .book-line { stroke: var(--color-primary); stroke-width: 2; stroke-linecap: round; fill: none; }
.ill .star { fill: #FCD34D; }
.ill .pencil { fill: #FBBF24; }
.ill .pencil-tip { fill: #1F2937; }
.ill .badge-bg { fill: var(--color-success); }
.ill .badge-text { fill: #fff; font: 800 15px var(--font-family); }
.ill .dot { fill: #fff; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes drift { from { transform: translateX(-60px); } to { transform: translateX(520px); } }
@keyframes wave { 0%, 100% { transform: skewY(0deg) scaleX(1); } 50% { transform: skewY(-6deg) scaleX(.92); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes glow { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
@keyframes twinkle { 0%, 100% { opacity: .9; } 50% { opacity: .2; } }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

/* Sign-in card */
.login-panel { flex: 1; position: relative; z-index: 2; margin-top: -32px; background: var(--color-card); border-radius: 26px 26px 0 0; padding: 0 20px calc(24px + var(--safe-bottom)); animation: rise .6s ease-out .1s both; }
.login-card { max-width: 420px; margin: 0 auto; }
.login-crest { display: grid; place-items: center; width: 84px; height: 84px; margin: -42px auto 10px; border-radius: 24px; background: var(--color-card); box-shadow: var(--shadow-lg); animation: pop .7s cubic-bezier(.2, 1.4, .4, 1) .25s both; }
.login-crest img { border-radius: 18px; }
@keyframes pop { from { opacity: 0; transform: scale(.6) rotate(-8deg); } to { opacity: 1; transform: none; } }
.login-card h1 { text-align: center; font-size: 1.6rem; }
.login-card > .muted { text-align: center; margin-bottom: 20px; }
.input-icon { position: relative; display: flex; align-items: center; }
.input-icon > .icon { position: absolute; left: 14px; width: 20px; height: 20px; color: var(--text-muted); pointer-events: none; }
.input-icon input { padding-left: 44px; min-height: 52px; border-radius: 14px; background: var(--color-bg); border-color: transparent; transition: border-color .15s, background .15s, box-shadow .15s; }
.input-icon input:focus { background: #fff; }
.input-icon:focus-within > .icon { color: var(--color-primary); }
.pw-toggle { position: absolute; right: 8px; min-height: 36px; padding: 0 12px; border: 0; border-radius: 10px; background: transparent; color: var(--color-primary); font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer; }
.pw-toggle:hover { background: var(--color-primary-soft); }
.input-icon input[name=password] { padding-right: 76px; }
.login-submit { margin-top: 6px; min-height: 54px; border-radius: 14px; box-shadow: 0 8px 20px color-mix(in srgb, var(--color-primary) 35%, transparent); }
.login-submit .icon { width: 18px; height: 18px; transition: transform .2s; }
.login-submit:hover .icon { transform: translateX(4px); }
.login-divider { display: flex; align-items: center; gap: 12px; margin: 22px 0 12px; color: var(--text-muted); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.login-divider::before, .login-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.login-quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.login-quick a { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px; border-radius: 14px; background: var(--color-bg); color: var(--text); font-size: .8rem; font-weight: 600; text-align: center; transition: transform .15s, background .15s; }
.login-quick a:hover { text-decoration: none; background: var(--color-primary-soft); color: var(--color-primary); transform: translateY(-2px); }
.login-quick .icon { color: var(--color-primary); }
.login-secure { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 18px 0 0; color: var(--text-muted); font-size: .8rem; }
.login-secure .icon { width: 14px; height: 14px; }

@media (min-width: 900px) {
  .login { flex-direction: row; }
  .login-brand { flex: 1.15; display: flex; flex-direction: column; padding: 36px 48px; min-height: 100vh; }
  .login-art { flex: 1; display: flex; align-items: center; width: 100%; max-width: 560px; margin: 8px auto; }
  .blob.b1 { width: 420px; height: 420px; top: -140px; right: -120px; }
  .blob.b2 { width: 260px; height: 260px; bottom: -60px; left: -80px; }
  .login-pitch { display: block; }
  .login-pitch h2 { font-size: 1.9rem; line-height: 1.2; margin-bottom: 8px; animation: rise .7s ease-out .2s both; }
  .login-pitch > p { opacity: .85; margin-bottom: 18px; animation: rise .7s ease-out .3s both; }
  .login-features { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .login-features li { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; background: rgba(255,255,255,.12); backdrop-filter: blur(4px); font-weight: 600; font-size: .92rem; animation: rise .6s ease-out both; animation-delay: calc(.4s + var(--d) * .12s); }
  .login-features .icon { width: 20px; height: 20px; flex: none; }
  .login-panel { flex: 1; margin: 0; border-radius: 0; display: flex; align-items: center; justify-content: center; padding: 48px; animation: none; }
  .login-card { width: 100%; animation: rise .6s ease-out .15s both; }
  .login-crest { margin: 0 auto 14px; }
}

/* ---------- Student photo ---------- */
.photo-wrap { position: relative; flex: none; }
.student-photo { display: block; width: 84px; height: 100px; object-fit: cover; border-radius: 14px; border: 3px solid var(--color-card); box-shadow: var(--shadow); background: var(--color-primary-soft); }
.student-photo.placeholder { display: grid; place-items: center; color: var(--color-primary); font-size: 2rem; font-weight: 800; }
.photo-wrap.uploading::after { content: "Uploading…"; position: absolute; inset: 0; display: grid; place-items: center; border-radius: 14px; background: rgba(17,24,39,.6); color: #fff; font-size: .75rem; font-weight: 700; }
.profile-main { flex: 1; min-width: 0; }
.photo-form { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.photo-form label.btn { cursor: pointer; }
.photo-form .icon { width: 16px; height: 16px; }
.profile-hero .help { margin-top: 4px; }
.child-photo { width: 68px; height: 80px; border-radius: 16px; object-fit: cover; border: 3px solid rgba(255,255,255,.6); flex: none; }

/* =========================================================================
   ATTENDANCE (redesign)
   ========================================================================= */
.att-hero { display: grid; gap: 14px; background: var(--color-card); border: 1px solid var(--border); border-radius: calc(var(--radius) * 1.2); padding: 14px; margin-bottom: 14px; box-shadow: var(--shadow-sm); }
.att-hero-main { display: grid; gap: 12px; min-width: 0; }
.att-pick { display: grid; gap: 10px; }
.att-class-select { font-weight: 700; min-height: 46px; border-radius: 12px; background: var(--color-bg); border-color: transparent; }
.att-datenav { display: flex; align-items: center; gap: 8px; }
.att-datenav .icon-btn { flex: none; width: 40px; height: 40px; }
.att-datenav .icon-btn .icon { width: 18px; height: 18px; }
.icon-btn.flip .icon { transform: scaleX(-1); }
.att-date { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; padding: 4px 8px; border-radius: 12px; background: var(--color-primary-soft); color: var(--color-primary); cursor: pointer; min-width: 0; }
.att-date-day { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; opacity: .8; }
.att-date-full { font-weight: 800; font-size: 1.02rem; }
.att-date input { position: absolute; inset: 0; opacity: 0; cursor: pointer; min-height: 0; width: 100%; }

.week-strip { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.wk-day { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0 8px; border-radius: 12px; background: var(--color-bg); color: var(--text); text-decoration: none !important; border: 1.5px solid transparent; }
.wk-day small { font-size: .68rem; color: var(--text-muted); font-weight: 700; text-transform: uppercase; }
.wk-day strong { font-size: 1rem; }
.wk-day i { width: 7px; height: 7px; border-radius: 50%; background: #CBD5E1; }
.wk-day.done i { background: var(--color-success); }
.wk-day.partial i { background: var(--color-warning); }
.wk-day.pending i { background: var(--color-danger); }
.wk-day.holiday { background: var(--color-secondary-soft); }
.wk-day.holiday i { background: var(--color-secondary); }
.wk-day.future { opacity: .45; }
.wk-day.active { background: var(--color-primary); color: var(--color-primary-contrast); border-color: var(--color-primary); }
.wk-day.active small { color: inherit; opacity: .8; }
a.wk-day:hover { border-color: var(--color-primary); }

.att-ring-wrap { display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: 14px; background: var(--color-bg); }
.att-ring { width: 84px; height: 84px; }
.att-ring .ring-fg { stroke: var(--color-success); transition: stroke-dasharray .4s ease; }
.att-ring .ring-bg { stroke: var(--color-success-soft); }
.att-ring .ring-text strong { color: var(--color-success); font-size: 1.15rem; }
.att-ring-meta { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; min-width: 0; }
.att-ring-meta strong { font-size: 1.05rem; }
.att-ring-meta small { color: var(--text-muted); }

.att-stats { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; scrollbar-width: none; }
.att-stats::-webkit-scrollbar { display: none; }
.att-stat { flex: none; display: flex; flex-direction: column; align-items: center; min-width: 74px; padding: 8px 10px; border-radius: 14px; border: 1.5px solid var(--border); background: var(--color-card); font: inherit; cursor: pointer; transition: transform .12s, border-color .12s; }
.att-stat b { font-size: 1.25rem; line-height: 1.2; }
.att-stat span { font-size: .72rem; font-weight: 700; color: var(--text-muted); }
.att-stat:hover { transform: translateY(-1px); }
.att-stat.active { border-color: var(--color-primary); box-shadow: 0 0 0 2px var(--color-primary-soft); }
.att-stat.st-present b { color: var(--color-success); }
.att-stat.st-absent b { color: var(--color-danger); }
.att-stat.st-late b { color: var(--color-warning); }
.att-stat.st-half_day b { color: var(--color-secondary); }
.att-stat.st-leave b { color: var(--color-primary); }

.att-tools { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.att-search { flex: 1; min-width: 200px; }
.att-tools .btn .icon { width: 18px; height: 18px; }

.att-grid { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
.att-card { background: var(--color-card); border: 1px solid var(--border); border-radius: 16px; padding: 12px; display: grid; gap: 10px; box-shadow: var(--shadow-sm); }
.att-card.flash { animation: att-flash .35s ease-out; }
@keyframes att-flash { 0% { transform: scale(.985); } 100% { transform: none; } }
.att-who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.att-avatar { width: 44px; height: 44px; border-radius: 12px; object-fit: cover; flex: none; background: var(--color-primary-soft); }
.att-avatar.initials { display: grid; place-items: center; color: var(--color-primary); font-weight: 800; font-size: 1.1rem; }
.att-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.att-name strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-name small { color: var(--text-muted); font-size: .78rem; }
.att-month { display: flex; flex-direction: column; align-items: center; font-weight: 800; font-size: .92rem; color: var(--color-success); line-height: 1.1; }
.att-month small { font-size: .62rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; }
.att-month.low { color: var(--color-danger); }

.att-seg { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; padding: 4px; margin: 0; border-radius: 14px; background: var(--color-bg); }
.seg input { position: absolute; opacity: 0; }
.seg span { display: grid; place-items: center; min-height: 42px; border-radius: 10px; cursor: pointer; user-select: none; color: var(--text-muted); font-size: .9rem; transition: background .15s, color .15s, box-shadow .15s; }
.seg-long { display: none; font-style: normal; }
.seg-short { font-weight: 800; }
.seg span:hover { background: var(--color-card); }
.seg input:focus-visible + span { outline: 3px solid var(--color-secondary); }
.seg-present input:checked + span { background: var(--color-success); color: #fff; box-shadow: 0 3px 10px color-mix(in srgb, var(--color-success) 35%, transparent); }
.seg-absent input:checked + span { background: var(--color-danger); color: #fff; box-shadow: 0 3px 10px color-mix(in srgb, var(--color-danger) 35%, transparent); }
.seg-late input:checked + span { background: var(--color-warning); color: #fff; }
.seg-half_day input:checked + span { background: var(--color-secondary); color: var(--color-secondary-contrast); }
.seg-leave input:checked + span { background: var(--color-primary); color: var(--color-primary-contrast); }
fieldset:disabled .seg span { cursor: default; }

.att-reason { margin-top: 4px; }
.att-savebar {
  position: sticky; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 8px); z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; border-radius: 16px; background: var(--color-card); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
}
.att-savebar-sum { display: flex; align-items: center; gap: 4px 6px; flex-wrap: wrap; font-size: .85rem; color: var(--text-muted); }
.att-savebar-sum b { color: var(--text); }
.att-savebar-sum span { width: 8px; height: 8px; border-radius: 50%; margin-left: 6px; }
.att-savebar-sum span:first-child { margin-left: 0; }
.dot-p { background: var(--color-success); }
.dot-a { background: var(--color-danger); }
.dot-o { background: var(--color-warning); }
.att-savebar .btn { flex: 1 1 180px; }
.att-savebar .btn .icon { width: 18px; height: 18px; }

@media (min-width: 900px) {
  .att-hero { grid-template-columns: minmax(0, 1fr) 320px; align-items: stretch; padding: 18px; }
  .att-pick { grid-template-columns: minmax(200px, 280px) 1fr; align-items: center; }
  .week-strip { gap: 8px; }
  .att-ring-wrap { height: 100%; }
  .att-grid { grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 12px; }
  .seg-long { display: inline; font-size: .8rem; font-weight: 700; }
  .seg-short { display: none; }
  .att-savebar { bottom: 16px; }
  .att-savebar .btn { flex: 0 0 auto; }
}

/* ---------- Global search (desktop top bar) ---------- */
.global-search { display: none; }
@media (min-width: 900px) {
  .global-search { position: relative; display: flex; align-items: center; flex: 1; max-width: 520px; margin: 0 24px; }
  .global-search > .icon { position: absolute; left: 14px; width: 18px; height: 18px; color: var(--text-muted); pointer-events: none; }
  .global-search input { min-height: 40px; padding: 8px 40px 8px 40px; border-radius: 999px; background: var(--color-bg); border-color: transparent; font-size: .92rem; }
  .global-search input:focus { background: #fff; border-color: var(--color-primary); }
  .global-search kbd { position: absolute; right: 12px; font: 700 .72rem ui-monospace, Consolas, monospace; color: var(--text-muted); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; background: var(--color-card); }
  .global-search:focus-within kbd { display: none; }
}

/* ---------- Pending-fee reminders (gentle 1.5s pulse; disabled by prefers-reduced-motion) ---------- */
@keyframes fee-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--color-danger) 55%, transparent); } 70% { box-shadow: 0 0 0 10px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@keyframes fee-blink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes fee-glow { 0%, 100% { box-shadow: var(--shadow-sm); } 50% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-danger) 30%, transparent), var(--shadow); } }

.pulse-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--color-danger); flex: none; animation: fee-pulse 1.5s ease-out infinite; vertical-align: middle; }
.pulse-dot.sm { width: 8px; height: 8px; }

.due-alert { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 14px; border-radius: 14px; background: var(--color-danger-soft); border: 1px solid color-mix(in srgb, var(--color-danger) 25%, transparent); }
.due-alert-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.due-alert-text strong { color: var(--color-danger); }
.due-alert-text small { color: var(--text); opacity: .8; }
.btn-danger-soft { background: var(--color-danger); color: #fff; }
.btn-danger-soft:hover { filter: brightness(.95); }
.due-alert .btn .icon { width: 18px; height: 18px; }

.fee-alert { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 14px; border-radius: 16px; color: var(--text); text-decoration: none !important; background: var(--color-card); border: 1.5px solid color-mix(in srgb, var(--color-danger) 40%, transparent); animation: fee-glow 1.5s ease-in-out infinite; }
.fee-alert.soon { border-color: color-mix(in srgb, var(--color-warning) 45%, transparent); animation: none; }
.fee-alert-icon { position: relative; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--color-danger); color: #fff; flex: none; }
.fee-alert.soon .fee-alert-icon { background: var(--color-warning); }
.fee-alert-icon .icon { width: 22px; height: 22px; position: relative; z-index: 1; }
.fee-alert.overdue .fee-alert-icon .icon { animation: fee-blink 1.5s ease-in-out infinite; }
.ring-pulse { position: absolute; inset: 0; border-radius: 12px; animation: fee-pulse 1.5s ease-out infinite; }
.fee-alert.soon .ring-pulse { display: none; }
.fee-alert-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.fee-alert-text strong { color: var(--color-danger); }
.fee-alert.soon .fee-alert-text strong { color: var(--color-warning); }
.fee-alert-text small { color: var(--text-muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.fee-alert-cta { font-weight: 700; color: var(--color-primary); font-size: .9rem; }
.fee-hero.blink { animation: fee-glow 1.5s ease-in-out infinite; }

/* Nav indicators */
.nav-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--color-danger); animation: fee-pulse 1.5s ease-out infinite; }
.nav-dot.soon { background: var(--color-warning); animation: none; }
.nav-badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--color-danger); color: #fff; font-size: .72rem; font-weight: 800; display: inline-grid; place-items: center; animation: fee-pulse 1.5s ease-out infinite; }
.sidebar-link .nav-dot, .sidebar-link .nav-badge { margin-left: auto; }
.tab { position: relative; }
.tab .nav-dot, .tab .nav-badge { position: absolute; top: 6px; left: calc(50% + 6px); }
.tab .nav-badge { height: 17px; min-width: 17px; font-size: .62rem; padding: 0 4px; }

/* ---------- Demo one-click logins ---------- */
.demo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.demo-grid form { margin: 0; }
.demo-btn { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px; border-radius: 14px; border: 1.5px solid var(--border);
  background: var(--color-card); font: inherit; font-size: .82rem; font-weight: 700; color: var(--text); cursor: pointer; transition: transform .15s, border-color .15s, background .15s; }
.demo-btn:hover { transform: translateY(-2px); border-color: var(--color-primary); background: var(--color-primary-soft); color: var(--color-primary); }
.demo-ic { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--color-primary-soft); color: var(--color-primary); }
.demo-ic .icon { width: 18px; height: 18px; }
.demo-principal .demo-ic { background: var(--color-secondary-soft); color: var(--color-secondary); }
.demo-accountant .demo-ic { background: var(--color-warning-soft); color: var(--color-warning); }
.demo-teacher .demo-ic { background: var(--color-success-soft); color: var(--color-success); }
.demo-parent .demo-ic { background: #FCE7F3; color: #9D174D; }

/* ---------- Installer ---------- */
body.install-body { min-height: 100vh; background: linear-gradient(160deg, var(--color-sidebar), var(--color-primary) 60%, var(--color-secondary) 130%); }
.install { max-width: 760px; margin: 0 auto; padding: 32px 16px 48px; }
.install-head { display: flex; align-items: center; gap: 14px; color: #fff; margin-bottom: 18px; }
.install-head h1 { font-size: 1.6rem; }
.install-head p { margin: 0; opacity: .8; }
.install-steps { color: #fff; }
.install-steps .step { color: rgba(255,255,255,.75); }
.install-steps .step.active { color: #fff; }
.install-card { box-shadow: var(--shadow-lg); }
.mode-grid { display: grid; gap: 10px; margin-bottom: 16px; }
.mode-card input { position: absolute; opacity: 0; }
.mode-card > span { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border-radius: 14px; border: 2px solid var(--border); cursor: pointer; }
.mode-card small { color: var(--text-muted); line-height: 1.45; }
.mode-card input:checked + span { border-color: var(--color-primary); background: var(--color-primary-soft); }
.mode-card input:focus-visible + span { outline: 3px solid var(--color-secondary); }
.mode-roles { display: flex; flex-wrap: wrap; gap: 6px; font-style: normal; margin-top: 4px; }
.mode-roles i { font-style: normal; font-size: .78rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--color-card); border: 1px solid var(--border); }
p.mode-roles { justify-content: center; }
@media (min-width: 900px) { .mode-grid { grid-template-columns: 1fr 1fr; } }
