/* ============================================================
   CSS DESIGN TOKENS
   ============================================================ */
:root {
    --blue:        #4F86C6;
    --blue-dark:   #3A6EA8;
    --blue-light:  #EBF3FB;
    --blue-muted:  #BACED8;

    --gold:        #E09830;
    --gold-light:  #FFF5DC;

    --bg:          #F2F5F8;
    --surface:     #FFFFFF;
    --surface-alt: #F7F9FB;

    --text:        #1A2638;
    --text-muted:  #5C6E82;
    --border:      #DDE4EB;

    --green:       #2D9E5F;
    --green-light: #E2F5EC;
    --red:         #D44040;
    --red-light:   #FDEAEA;
    --amber:       #C07800;
    --amber-light: #FFF4D4;

    --radius-sm: 6px;
    --radius:    10px;
    --radius-lg: 14px;

    /* Layout rhythm — used for consistent mobile / desktop spacing */
    --page-pad-x: clamp(12px, 3.5vw, 20px);
    --page-pad-y: clamp(12px, 3vw, 16px);
    --header-pad-x: max(12px, env(safe-area-inset-left, 0px));
    --header-pad-right: max(12px, env(safe-area-inset-right, 0px));
    --focus-ring: 0 0 0 3px rgba(79, 134, 198, 0.22);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}

.hidden  { display: none !important; }
.w-100   { width: 100%; }
.no-wrap { white-space: nowrap; }
.muted   { color: var(--text-muted); }
.small-text { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }
.visually-hidden {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ============================================================
   APP SHELL HEADER
   ============================================================ */
.app-header {
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: max(0px, env(safe-area-inset-top, 0px)) var(--header-pad-right) 0 var(--header-pad-x);
    min-height: calc(52px + env(safe-area-inset-top, 0px));
    box-sizing: border-box;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
}
.logo {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--blue-dark);
    letter-spacing: -0.02em;
}
.user-profile { display: flex; align-items: center; gap: 10px; }
.user-role-badge {
    font-size: 0.8rem;
    color: var(--text-muted);
    max-width: 50vw;
    text-align: right;
    line-height: 1.25;
}
.user-role-badge.role-admin   { font-weight: 600; color: var(--blue-dark); }
.user-role-badge.role-teacher { color: var(--text-muted); }
.btn-logout {
    background: none; border: none; color: var(--text-muted);
    font-size: 0.82rem; cursor: pointer; padding: 4px 8px;
    border-radius: var(--radius-sm); font-weight: 500; font-family: inherit;
}
.btn-logout:hover { background: var(--bg); color: var(--text); }

/* ============================================================
   APP NAVIGATION TABS
   ============================================================ */
.app-nav {
    display: flex;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    position: sticky;
    top: calc(52px + env(safe-area-inset-top, 0px));
    z-index: 999;
    -ms-overflow-style: none;
    scrollbar-width: none;
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}
.app-nav::-webkit-scrollbar { display: none; }

.nav-tab {
    flex: 1;
    min-width: 56px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    padding: 0 8px;
    min-height: 48px;
    height: auto;
    font-size: clamp(0.72rem, 2.8vw, 0.78rem);
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    line-height: 1.15;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
    font-family: inherit;
}
.nav-tab:hover { color: var(--text); background: var(--bg); }
.nav-tab.active { color: var(--blue-dark); border-bottom-color: var(--blue); font-weight: 700; }
.nav-tab[hidden], .nav-tab.nav-hidden { display: none !important; }
.nav-tab-icon  { font-size: 1.05rem; line-height: 1; }
.nav-tab-label { font-weight: inherit; }

.app-main {
    padding: var(--page-pad-y) var(--page-pad-x);
    padding-bottom: calc(var(--page-pad-y) + env(safe-area-inset-bottom, 0px));
    max-width: 880px;
    margin: 0 auto;
    width: 100%;
}
.app-shell.hidden { display: none !important; }

/* ============================================================
   BUTTONS
   ============================================================ */
button {
    cursor: pointer;
    border-radius: var(--radius-sm);
    border: none;
    font-weight: 600;
    font-family: inherit;
    transition: opacity 0.15s, background 0.15s, border-color 0.15s;
    line-height: 1.35;
}
button:active { opacity: 0.82; }

.btn-primary {
    background: var(--blue);
    color: #fff;
    padding: 9px 16px;
    font-size: 0.88rem;
    border-radius: var(--radius-sm);
}
.btn-primary:hover { background: var(--blue-dark); }

.btn-secondary {
    background: transparent;
    color: var(--text);
    padding: 9px 16px;
    font-size: 0.88rem;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
}
.btn-secondary:hover { border-color: var(--text-muted); background: var(--bg); }

.btn-warning {
    background: var(--gold);
    color: #fff;
    padding: 9px 16px;
    font-size: 0.88rem;
    border-radius: var(--radius-sm);
}
.btn-warning:hover { background: #c08020; }

.btn-action {
    background: var(--surface);
    color: var(--blue-dark);
    border: 1.5px solid var(--blue-muted);
    padding: 7px 12px;
    font-size: 0.84rem;
    border-radius: var(--radius-sm);
}
.btn-action:hover { background: var(--blue-light); }

.btn-danger {
    background: var(--red);
    color: #fff;
    padding: 7px 12px;
    font-size: 0.84rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    flex-shrink: 0;
}
.btn-danger:hover { background: #b83030; }

.btn-small    { padding: 5px 10px; font-size: 0.8rem; white-space: nowrap; }
.btn-login-wide { width: 100%; padding: 12px; font-size: 0.98rem; border-radius: var(--radius); }
.btn-link-like {
    background: none; border: none; color: var(--blue);
    cursor: pointer; font-size: 0.9rem; text-decoration: underline; padding: 4px 0; font-family: inherit;
}
.btn-link-like:hover { color: var(--blue-dark); }
.btn-landing-large {
    padding: 10px 18px; font-size: 0.92rem; border-radius: var(--radius);
    text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}
.btn-camera-scan { font-size: 0.86rem; }

/* ============================================================
   INPUTS & FORM CONTROLS
   ============================================================ */
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="time"],
textarea, select {
    /* ≥16px prevents iOS Safari from zooming the viewport on focus */
    font-family: inherit;
    font-size: max(16px, 0.9rem);
    color: var(--text);
    background-color: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 11px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    -webkit-appearance: none;
    appearance: none;
}
input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus,
input[type="number"]:focus, input[type="date"]:focus, input[type="time"]:focus,
textarea:focus, select:focus {
    border-color: var(--blue);
    box-shadow: var(--focus-ring);
}
input[type="text"] { width: 100%; margin-bottom: 10px; }
textarea { width: 100%; resize: vertical; }
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='7' viewBox='0 0 11 7'%3E%3Cpath d='M1 1l4.5 4.5L10 1' stroke='%235C6E82' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 9px center;
    background-size: 11px 7px;
    padding-right: 26px;
    cursor: pointer;
}
select:hover { border-color: var(--blue); }

.search-input, .inline-add-input, .input-std {
    border: 1.5px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
    margin-bottom: 0;
}
.search-input:focus, .input-std:focus {
    border-color: var(--blue) !important;
    box-shadow: 0 0 0 3px rgba(79,134,198,0.14);
}
.pin-input {
    width: 100%; padding: 13px; font-size: 1.5rem;
    letter-spacing: 0.45em; text-align: center;
    border: 1.5px solid var(--border); border-radius: var(--radius);
    margin-bottom: 12px; transition: border-color 0.15s;
}
.pin-input:focus { border-color: var(--blue); outline: none; box-shadow: var(--focus-ring); }

.form-row {
    display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 4px;
}
.form-row input, .form-row select { flex: 1; min-width: 120px; margin-bottom: 0; }
.form-row .btn-primary { white-space: nowrap; padding: 9px 13px; }
.admin-form { margin-bottom: 14px; }
.select-wide { width: 100%; margin-bottom: 12px; }
.qr-id-input-group { display: flex; align-items: center; gap: 6px; }
.qr-id-input-group input { flex: 1; }
.qr-id-input-group--compact { flex: 1 1 150px; min-width: 130px; }

.file-input-label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; width: 100%; }
input[type="file"].input-file-inline, input[type="file"].input-file-std {
    width: 100%; max-width: 300px; font-size: 0.84rem;
    padding: 7px 10px; border: 1.5px solid var(--border);
    border-radius: var(--radius-sm); background: var(--surface); cursor: pointer;
}
input[type="file"].input-file-inline:focus, input[type="file"].input-file-std:focus {
    border-color: var(--blue); box-shadow: 0 0 0 3px rgba(79,134,198,0.14); outline: none;
}
input[type="file"].input-file-inline::file-selector-button,
input[type="file"].input-file-std::file-selector-button {
    margin-right: 10px; padding: 5px 10px; border: none;
    border-radius: var(--radius-sm); background: var(--blue-light);
    color: var(--blue-dark); font-weight: 600; font-size: 0.8rem; cursor: pointer;
}
.checkbox-inline {
    display: flex; align-items: center; gap: 7px;
    font-size: 0.86rem; font-weight: 500; margin: 7px 0; cursor: pointer;
}
.checkbox-inline input { width: auto; margin: 0; }
.login-error { color: var(--red); font-size: 0.86rem; font-weight: 600; margin-top: 8px; }

/* ============================================================
   PAGE STRUCTURE
   ============================================================ */
.page-intro  { margin-bottom: 12px; }
.page-title  { font-size: 1.15rem; font-weight: 700; color: var(--text); margin-bottom: 3px; }
.page-lead   { font-size: 0.86rem; color: var(--text-muted); line-height: 1.45; max-width: 36rem; }
.section-heading { font-size: 0.92rem; font-weight: 700; margin-bottom: 8px; color: var(--text); }
.scanner-meta    { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 6px; }
.empty-state     { color: var(--text-muted); font-size: 0.86rem; padding: 18px; text-align: center; }
.empty-inline    { color: var(--text-muted); font-size: 0.83rem; margin: 5px 0 9px; padding: 0 4px; }
.admin-sub-desc  { font-size: 0.84rem; color: var(--text-muted); margin: -5px 0 11px; }

/* Collapsible secondary panel inside an admin tab (e.g. QR export inside Classes) */
.admin-inline-panel {
    margin-top: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.admin-inline-panel > summary {
    list-style: none;
    cursor: pointer;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--surface-alt);
    user-select: none;
    transition: background 0.15s;
    position: relative;
}
.admin-inline-panel > summary::-webkit-details-marker { display: none; }
.admin-inline-panel > summary:hover { background: var(--bg); }
.admin-inline-panel > summary::after {
    content: '▾';
    position: absolute;
    right: 14px; top: 50%;
    transform: translateY(-50%) rotate(-90deg);
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: transform 0.18s ease;
}
.admin-inline-panel[open] > summary::after { transform: translateY(-50%) rotate(0deg); }
.admin-inline-panel-title { font-weight: 700; font-size: 0.95rem; color: var(--text); }
.admin-inline-panel-hint { font-size: 0.78rem; color: var(--text-muted); padding-right: 24px; }
.admin-inline-panel-body { padding: 14px; border-top: 1px solid var(--border); }
.admin-inline-panel-body .admin-sub-desc { margin-top: 0; }

.panel-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 18px 16px;
    border: 1px solid var(--border);
    max-width: 400px;
    margin: 0 auto 16px;
    text-align: center;
}
#classroom-class-picker, #grades-class-picker {
    display: flex; flex-direction: column; align-items: stretch;
    justify-content: flex-start; align-self: center;
    width: 100%; max-width: 400px; min-height: unset;
    margin-top: 16px; margin-bottom: 24px;
    padding: 22px 18px 26px; box-sizing: border-box; gap: 14px;
}
.login-icon { font-size: 2.4rem; margin-bottom: 8px; }
.login-card {
    background: var(--surface); border-radius: var(--radius-lg);
    padding: 28px 22px; text-align: center; border: 1px solid var(--border);
    width: 100%; max-width: 340px;
}

/* Page header row (title + info button) */
.page-header-row {
    display: flex; align-items: center; gap: 8px; margin-bottom: 12px;
}
.page-header-row .page-title { margin-bottom: 0; }
.btn-info-help {
    width: 22px; height: 22px; border-radius: 50%;
    border: 1.5px solid var(--border); background: var(--bg);
    color: var(--text-muted); font-size: 0.72rem; font-weight: 700;
    font-style: italic; line-height: 1; cursor: pointer; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-family: Georgia, serif;
}
.btn-info-help:hover { color: var(--text); border-color: var(--text-muted); background: var(--surface); }
.page-help-sheet {
    background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 9px 12px;
    font-size: 0.82rem; color: var(--text-muted); line-height: 1.45;
    margin-bottom: 10px;
}

/* ============================================================
   SCANNER (Gate + Class share this design)
   ============================================================ */
.scanner-container {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 14px;
    border: 1px solid var(--border);
    margin-bottom: 14px;
}
.scanner-compact { margin-bottom: 10px; }
.hidden-scanner-input { position: absolute; left: -9999px; opacity: 0; }

/* Modern unified scan card — same shell for gate and class */
.scan-card {
    background: linear-gradient(160deg, #FFFFFF 0%, #F4F8FB 100%);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 16px 16px 14px;
    margin-bottom: 14px;
    box-shadow: 0 1px 3px rgba(15, 35, 60, 0.04), 0 6px 18px rgba(15, 35, 60, 0.04);
    position: relative;
    overflow: hidden;
}
.scan-card::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, var(--green) 0%, var(--blue) 50%, var(--green) 100%);
    opacity: 0.85;
}
.scan-card[data-scan-mode='class']::before {
    background: linear-gradient(90deg, var(--blue) 0%, #6A8FB8 50%, var(--blue) 100%);
}
.scan-card-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; margin-bottom: 10px; flex-wrap: wrap;
}
.scan-card-head-right {
    display: flex; align-items: center; justify-content: flex-end;
    gap: 8px; flex-wrap: wrap; margin-left: auto;
}
.btn-scan-card-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 30px; padding: 0;
    border: 1px solid var(--border); border-radius: 10px;
    background: var(--surface); color: var(--text-muted);
    cursor: pointer; flex-shrink: 0;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.btn-scan-card-toggle:hover {
    color: var(--text); border-color: var(--text-muted); background: var(--bg);
}
.btn-scan-card-toggle-icon {
    display: inline-block; font-size: 0.55rem; line-height: 1;
    transition: transform 0.2s ease;
}
.scan-card--collapsed .btn-scan-card-toggle-icon { transform: rotate(-90deg); }
.scan-card--collapsed .scan-card-panel { display: none; }
.scan-card-eyebrow {
    font-size: 0.7rem; font-weight: 800; letter-spacing: 0.14em;
    text-transform: uppercase; color: var(--text-muted);
}
.scan-card-meta {
    font-size: 0.74rem; color: var(--text-muted);
    display: inline-flex; align-items: center; gap: 6px;
}
.scan-card-meta-hint {
    background: var(--blue-light);
    color: var(--blue-dark);
    padding: 3px 9px;
    border-radius: 10px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* Scan status pill — single size, used everywhere */
.scan-action-area { display: flex; flex-direction: column; align-items: center; gap: 3px; margin: 0 0 2px; }

.scan-pulse,
.scan-pulse-sm {
    width: 100%; max-width: 320px; height: 50px; border-radius: 25px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.95rem; letter-spacing: 0.01em;
    border: 2px solid var(--blue-muted);
    background: var(--blue-light); color: var(--blue-dark);
    animation: pulseRing 2.4s ease-in-out infinite;
    transition: background 0.22s, border-color 0.22s, color 0.22s, transform 0.18s;
}
@keyframes pulseRing {
    0%,100% { box-shadow: 0 0 0 0 rgba(79,134,198,0.22); }
    55%     { box-shadow: 0 0 0 8px rgba(79,134,198,0); }
}
.scan-pulse.scanning,
.scan-pulse-sm.scanning  { animation-duration: 0.45s; border-color: var(--blue); transform: scale(1.01); }
.scan-pulse.success,
.scan-pulse-sm.success   { background: var(--green-light); border-color: var(--green);  color: var(--green);  animation: none; }
.scan-pulse.error,
.scan-pulse-sm.error     { background: var(--red-light);   border-color: var(--red);    color: var(--red);    animation: none; }
.scan-pulse.duplicate,
.scan-pulse-sm.duplicate { background: var(--amber-light); border-color: var(--amber);  color: var(--amber);  animation: none; }

.scan-feedback-msg {
    min-height: 0; font-weight: 600; font-size: 0.88rem;
    transition: opacity 0.2s; text-align: center;
}
.scan-feedback-msg.feedback-success { color: var(--green); }
.scan-feedback-msg.feedback-warning { color: var(--amber); }
.scan-feedback-msg.feedback-error   { color: var(--red); }

.scan-count-badge {
    display: inline-block; background: var(--blue); color: #fff;
    font-size: 0.7rem; font-weight: 700; padding: 1px 7px;
    border-radius: 20px; vertical-align: middle; margin-left: 5px;
}
.scan-item-empty { color: var(--text-muted); font-size: 0.86rem; padding: 14px; text-align: center; list-style: none; }

.status-indicator.online  { color: var(--green); font-weight: 700; }
.status-indicator.offline { color: var(--red);   font-weight: 700; }

/* Big, prominent camera button — same for both scanners */
.scan-camera-row { display: flex; justify-content: center; margin: 2px 0 10px; }
.btn-camera-scan {
    display: inline-flex; align-items: center; gap: 9px;
    padding: 11px 22px;
    font-size: 0.95rem; font-weight: 600;
    color: var(--blue-dark);
    background: #FFFFFF;
    border: 1.5px solid var(--blue-muted);
    border-radius: 30px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.18s, border-color 0.18s, color 0.18s;
    box-shadow: 0 2px 6px rgba(79, 134, 198, 0.12);
}
.btn-camera-scan:hover {
    border-color: var(--blue);
    color: var(--blue);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(79, 134, 198, 0.22);
}
.btn-camera-scan:active { transform: translateY(0); box-shadow: 0 2px 6px rgba(79, 134, 198, 0.16); }
.btn-camera-icon { font-size: 1.05rem; line-height: 1; }
.btn-camera-text { line-height: 1; }

/* Manual search row — same for both scanners */
.scan-manual {
    display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
    padding-top: 12px; margin-top: 2px;
    border-top: 1px dashed var(--border);
}
.scan-manual-search {
    flex: 1; min-width: 0;
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    background: #FFFFFF;
    color: var(--text);
    font-size: max(16px, 0.92rem);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.scan-manual-search:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: var(--focus-ring);
}
.scan-manual-actions { display: flex; gap: 6px; flex-shrink: 0; }
.scan-manual-hint {
    flex: 1 1 100%;
    margin: 4px 0 0;
    font-size: 0.74rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Legacy aliases — keep existing JS/CSS class hooks working */
.manual-override { display: flex; gap: 7px; }
.manual-override.gate-manual-row,
.manual-override.class-manual-row { flex-wrap: wrap; align-items: center; }
.manual-override .search-input { margin-bottom: 0; flex: 1; min-width: 0; }
.scanner-compact .manual-override .search-input { margin-bottom: 0; }
.gate-manual-actions { display: flex; gap: 5px; flex-shrink: 0; }
p.gate-manual-hint {
    flex: 1 1 100%; margin: 3px 0 0; font-size: 0.74rem; color: var(--text-muted); line-height: 1.3;
}
.gate-camera-row { margin: 7px 0 9px; text-align: center; }

@media (max-width: 520px) {
    .scan-card { padding: 14px 12px 12px; border-radius: 14px; }
    .scan-manual-actions { width: 100%; }
    .scan-manual-actions .btn-primary,
    .scan-manual-actions .btn-secondary { flex: 1; }
}

/* Scan activity list */
.scan-list { list-style: none; }
.scan-item {
    background: var(--surface); padding: 10px 12px; border-radius: var(--radius);
    margin-bottom: 5px; display: flex; align-items: center;
    justify-content: space-between; gap: 9px; border: 1px solid var(--border);
}
.scan-item-in  { border-left: 3px solid var(--green); }
.scan-item-out { border-left: 3px solid #8FA8B8; background: var(--surface-alt); }
.scan-item-out .scan-item-photo-wrap { border-color: rgba(120,144,156,0.3); }
.scan-item-main { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1; }
.scan-item-photo-wrap {
    width: 38px; height: 38px; border-radius: 50%; overflow: hidden; flex-shrink: 0;
    border: 2px solid rgba(45,158,95,0.25); background: var(--bg);
}
.scan-item-photo { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-item-photo-ph {
    width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 0.95rem; color: var(--blue-dark); background: var(--blue-light);
}
.scan-item .child-info { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; min-width: 0; }
.scan-item-gate-badge {
    font-size: 0.64rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
    color: var(--text-muted); background: var(--bg); padding: 1px 6px; border-radius: 3px;
}
.scan-item-in .scan-item-gate-badge { color: #1A6035; background: var(--green-light); }
.scan-item-name {
    font-weight: 700; font-size: 0.95rem; color: var(--text);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
}
.scan-time { flex-shrink: 0; font-size: 0.8rem; color: var(--text-muted); font-weight: 500; }
.page-lead .gate-pickup-hint { display: block; margin-top: 5px; font-size: 0.84em; color: var(--text-muted); }

/* ============================================================
   CLASSROOM ROSTER
   ============================================================ */
.class-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; gap: 8px; }
.teacher-byline { color: var(--text-muted); font-size: 0.86rem; margin-top: 2px; }
.class-header-right { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }
.missing-alert {
    background: var(--red); color: #fff; padding: 3px 10px;
    border-radius: 20px; font-size: 0.78rem; font-weight: 700;
}
.bulk-actions { display: flex; gap: 7px; margin-bottom: 10px; overflow-x: auto; padding-bottom: 3px; }
.roster-card {
    background: var(--surface); padding: 10px 12px; border-radius: var(--radius);
    margin-bottom: 5px; display: flex; align-items: center; gap: 10px; border: 1px solid var(--border);
}
.roster-card.alert { background: var(--gold-light); border-color: rgba(224,152,48,0.5); }
.roster-card.in-class { background: var(--green-light); border-left: 3px solid var(--green); }
.roster-card.in-class .roster-status { color: #1A6035; font-weight: 600; }
.roster-card.roster-departed { opacity: 0.8; border-left: 3px solid #8FA8B8; background: var(--surface-alt); }
.roster-card.roster-departed .roster-status { color: #607D8B; font-weight: 600; }
.roster-details { flex: 1; display: flex; flex-direction: row; align-items: center; gap: 10px; min-width: 0; }
.roster-nameblock { display: flex; flex-direction: column; min-width: 0; }
.roster-avatar {
    width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg); border: 1.5px solid var(--border);
    font-weight: 700; font-size: 0.9rem; color: var(--blue-dark);
}
.roster-avatar-ph { line-height: 1; }
.roster-photo { width: 100%; height: 100%; object-fit: cover; display: block; }
.roster-card.alert .roster-avatar { border-color: rgba(224,152,48,0.5); background: rgba(255,255,255,0.5); }
.roster-name   { font-weight: 700; font-size: 0.98rem; }
.roster-status { font-size: 0.8rem; }
.bulk-select   { width: 17px; height: 17px; }
.roster-actions { display: flex; gap: 5px; align-items: center; margin-left: auto; }
.roster-loading { color: var(--text-muted); font-size: 0.86rem; padding: 18px; text-align: center; }

/* ============================================================
   ADMIN STATS
   ============================================================ */
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 9px; margin: 10px 0 14px;
}
.stat-card {
    background: var(--surface); padding: 14px 10px; border-radius: var(--radius);
    text-align: center; border: 1px solid var(--border);
}
.stat-card.highlight { background: var(--blue-light); border-color: var(--blue-muted); }
.stat-card.warning   { background: var(--amber-light); border-color: rgba(224,152,48,0.4); }
.stat-card h3        { font-size: 1.7rem; margin-bottom: 3px; }
.admin-noticeboard textarea { height: 105px; resize: vertical; }
.admin-sub-title { margin-bottom: 12px; font-size: 1.05rem; font-weight: 700; }
.admin-sub-view  { padding: 2px 0; }

/* Admin sub-navigation */
.admin-sub-nav {
    display: flex; background: transparent; border-bottom: 1px solid var(--border);
    overflow-x: auto; margin-bottom: 14px;
    scrollbar-width: none; -ms-overflow-style: none;
}
.admin-sub-nav::-webkit-scrollbar { display: none; }
.admin-tab {
    flex-shrink: 0; background: none; border: none; border-bottom: 2px solid transparent;
    padding: 7px 12px; font-size: 0.8rem; font-weight: 600; color: var(--text-muted);
    cursor: pointer; white-space: nowrap; transition: color 0.15s, border-color 0.15s;
    margin-bottom: -1px; font-family: inherit;
}
.admin-tab:hover  { color: var(--text); }
.admin-tab.active { color: var(--blue-dark); border-bottom-color: var(--blue); }

/* Admin list */
.admin-list { margin-top: 5px; }
.admin-list-item {
    background: var(--surface); border-radius: var(--radius); padding: 10px 13px;
    margin-bottom: 5px; display: flex; align-items: center;
    justify-content: space-between; border: 1px solid var(--border); gap: 9px;
}
.ali-info { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.ali-info strong { font-size: 0.93rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ali-meta { font-size: 0.76rem; color: var(--text-muted); margin-top: 1px; }

/* Admin class blocks */
.admin-class-block { margin-bottom: 7px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.admin-class-head-row { display: flex; align-items: stretch; background: var(--surface); }
.admin-class-block:not(.is-expanded) .admin-class-head-row { border-radius: var(--radius); }
.admin-class-block.is-expanded .admin-class-head-row { border-radius: var(--radius) var(--radius) 0 0; border-bottom: 1px solid var(--border); }
.admin-class-toggle {
    flex: 1; display: flex; align-items: center; gap: 9px; padding: 10px 12px;
    margin: 0; border: none; background: transparent; cursor: pointer;
    text-align: left; font: inherit; color: inherit; min-width: 0;
}
.admin-class-toggle:hover { background: var(--bg); }
.admin-class-toggle:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.admin-class-toggle-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.admin-class-toggle-text strong { font-size: 0.93rem; }
.admin-class-chevron {
    width: 0; height: 0; border-style: solid; border-width: 5px 0 5px 7px;
    border-color: transparent transparent transparent var(--text-muted);
    flex-shrink: 0; transition: transform 0.2s; margin-left: 2px;
}
.admin-class-block.is-expanded .admin-class-chevron { transform: rotate(90deg); }
.admin-class-block:not(.is-expanded) .admin-class-children { display: none !important; }
.admin-class-block.is-expanded .admin-class-children { display: block; }
.admin-class-children { background: var(--bg); padding: 8px 10px 12px; border-radius: 0 0 var(--radius) var(--radius); }
.class-block-actions { display: flex; align-items: center; gap: 5px; padding: 6px 8px 6px 0; flex-shrink: 0; }
.class-child-row {
    display: flex; align-items: center; gap: 8px; padding: 6px 6px;
    margin-bottom: 4px; background: var(--surface);
    border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.class-child-info { flex: 1; min-width: 0; }
.class-child-actions { flex-shrink: 0; display: flex; gap: 5px; }
.class-inline-add {
    display: flex; flex-wrap: wrap; align-items: center; gap: 7px;
    margin-top: 9px; padding-top: 9px; border-top: 1px dashed var(--border);
}
.class-inline-add .inline-add-input {
    flex: 1 1 130px; min-width: 110px; padding: 7px 9px;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: 0.87rem;
}
.admin-child-thumb {
    width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg); border: 1.5px solid var(--border);
    font-size: 0.78rem; font-weight: 700; color: var(--blue-dark);
}
.admin-child-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.admin-child-thumb-ph { line-height: 1; }
.ech-photo-prev { max-width: 110px; max-height: 110px; border-radius: var(--radius-sm); display: block; margin-bottom: 7px; object-fit: cover; }

.role-pill {
    display: inline-block; background: var(--blue-light); color: var(--blue-dark);
    font-size: 0.66rem; font-weight: 700; padding: 1px 6px; border-radius: 3px;
    margin-right: 4px; vertical-align: middle;
}

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(12, 20, 32, 0.52);
    display: flex; align-items: center; justify-content: center; z-index: 3000;
    backdrop-filter: blur(2px);
}
.modal-content {
    background: var(--surface); width: 92%; max-width: 460px;
    border-radius: var(--radius-lg); overflow: hidden;
    border: 1px solid var(--border); box-shadow: 0 10px 36px rgba(0,0,0,0.15);
}
.modal-header {
    background: transparent; color: var(--text); padding: 13px 15px;
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 0.98rem; font-weight: 700; margin: 0; }
.btn-close-modal {
    background: none; color: var(--text-muted); font-size: 1.2rem; border: none;
    padding: 2px 6px; border-radius: var(--radius-sm); line-height: 1; cursor: pointer; font-family: inherit;
}
.btn-close-modal:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 14px 15px; }
.camera-upload {
    background: var(--bg); padding: 14px; text-align: center;
    border-radius: var(--radius-sm); margin: 10px 0; border: 1.5px dashed var(--border);
}
.notice-ack-lead { font-size: 0.88rem; margin-bottom: 9px; }
.notice-ack-box {
    max-height: 190px; overflow-y: auto; padding: 9px 11px; margin-bottom: 11px;
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: 0.87rem; line-height: 1.5; white-space: pre-wrap;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
#toast-container {
    position: fixed; bottom: 18px; left: 0; right: 0; z-index: 9000;
    display: flex; flex-direction: column; align-items: center; gap: 7px; pointer-events: none;
}
.toast {
    background: var(--text); color: #fff; padding: 9px 18px; border-radius: 18px;
    font-size: 0.88rem; font-weight: 600; box-shadow: 0 4px 14px rgba(0,0,0,0.18);
    opacity: 0; transform: translateY(8px); transition: opacity 0.2s, transform 0.2s;
    will-change: opacity, transform; max-width: 300px; text-align: center;
}
.toast.toast-visible { opacity: 1; transform: translateY(0); }
.toast.toast-success { background: #1B6B38; }
.toast.toast-warning { background: var(--amber); }
.toast.toast-error   { background: var(--red); }
.toast.toast-info    { background: var(--blue-dark); }

/* ============================================================
   SCHEDULE PAGE (redesigned)
   ============================================================ */
.sched-page { padding-bottom: 24px; }
.schedule-page-header { margin-bottom: 8px; }
.sched-toolbar {
    display: flex; flex-wrap: wrap; align-items: flex-end;
    gap: 12px 14px;
    background: var(--surface);
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
}
.sched-toolbar--secondary {
    background: var(--surface-alt);
    align-items: flex-end;
}
.sched-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.sched-field--grow { flex: 1 1 180px; }
.sched-field--full { flex: 1 1 100%; }
.sched-field--actions { flex-shrink: 0; justify-content: flex-end; }
.sched-field--row-actions {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    flex: 1 1 100%;
}
@media (min-width: 720px) {
    .sched-field--row-actions { flex: 0 1 auto; justify-content: flex-end; }
}
.sched-field--submit { flex-shrink: 0; justify-content: flex-end; }
.sched-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}
.sched-optional { font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--text-muted); }
.sched-input, .sched-select {
    width: 100%;
    min-height: 40px;
    margin-bottom: 0 !important;
    font-size: 0.9rem;
}
.sched-input-date { max-width: 200px; }

.sched-add-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px 16px;
    margin-bottom: 14px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}
.sched-add-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}
.sched-add-title { margin: 0; font-size: 1rem; font-weight: 700; color: var(--text); }
.sched-add-form { margin: 0; }
.sched-add-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px 14px;
}
@media (min-width: 560px) {
    .sched-add-grid {
        grid-template-columns: minmax(120px, 140px) 1fr;
        align-items: end;
    }
    .sched-field--full { grid-column: 1 / -1; }
    .sched-field--submit { grid-column: 1 / -1; justify-self: start; }
}

.sched-display {
    margin-bottom: 16px;
}
.sched-empty {
    margin: 0 0 12px;
    padding: 14px;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px dashed var(--border);
}
.sched-empty.hidden { display: none !important; }
.sched-timeline { display: flex; flex-direction: column; gap: 8px; }

.sched-card {
    display: flex;
    align-items: stretch;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: box-shadow 0.15s;
}
.sched-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,0.06); }
.sched-card-time {
    min-width: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.8rem;
    color: var(--text);
    padding: 0 10px;
    background: var(--bg);
    letter-spacing: -0.02em;
}
.sched-card-bar { width: 4px; flex-shrink: 0; }
.sched-card-body { flex: 1; padding: 11px 14px; min-width: 0; }
.sched-card-title { font-weight: 700; font-size: 0.95rem; margin-bottom: 3px; color: var(--text); }
.sched-card-desc { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 6px; line-height: 1.35; }
.sched-tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.68rem; font-weight: 700; color: #fff; }
.sched-del-btn { margin: 8px 10px; flex-shrink: 0; align-self: center; }
.sched-global-badge {
    display: inline-block;
    background: var(--blue-light);
    color: var(--blue-dark);
    font-size: 0.62rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
    vertical-align: middle;
}

.sched-presets {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
}
.sched-presets-title { font-size: 0.95rem; font-weight: 700; margin: 0 0 6px; color: var(--text); }
.sched-presets-lead { font-size: 0.82rem; color: var(--text-muted); margin: 0 0 12px; line-height: 1.45; }
.presets-list { display: flex; flex-wrap: wrap; gap: 8px; }
.preset-item { flex: 1; min-width: 200px; }

.mini-schedule-section { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 13px; }
.mini-sched-title { font-size: 0.88rem; font-weight: 700; margin-bottom: 7px; }
.mini-sched-item { display: flex; align-items: center; gap: 6px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 0.87rem; }
.sched-time-badge { background: var(--blue); color: #fff; font-size: 0.68rem; font-weight: 700; padding: 2px 7px; border-radius: 10px; white-space: nowrap; }
.sched-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.sched-title { font-weight: 600; flex: 1; }
.sched-desc  { font-size: 0.74rem; color: var(--text-muted); }

/* ============================================================
   INCIDENTS
   ============================================================ */
.incident-notes { margin: 5px 0 0; font-size: 0.83rem; color: var(--text); background: var(--amber-light); border-left: 3px solid var(--gold); padding: 5px 8px; border-radius: var(--radius-sm); width: 100%; }
.incident-time { color: var(--text-muted); font-size: 0.76rem; }

/* ============================================================
   GRADES
   ============================================================ */
.assessment-item { flex-direction: column; align-items: flex-start !important; gap: 6px; }
.avg-score-badge { display: inline-block; padding: 2px 8px; border-radius: 9px; font-size: 0.76rem; font-weight: 700; color: #fff; margin-top: 2px; }
.grade-pass { background: #1B6B38; }
.grade-fail { background: var(--red); }
.score-entry-panel { background: var(--surface); border-radius: var(--radius-lg); padding: 15px; margin-top: 12px; border: 1.5px solid var(--blue); }
.score-entry-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 9px; }
.score-entry-header h3 { margin: 0; color: var(--blue-dark); font-size: 0.98rem; }
.score-entry-meta { font-size: 0.8rem; color: var(--text-muted); margin: 2px 0 0; }
.score-table-wrap { overflow-x: auto; }
.score-table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
.score-table th { background: var(--bg); padding: 7px 9px; text-align: left; font-size: 0.76rem; color: var(--text-muted); border-bottom: 1.5px solid var(--border); }
.score-table td { padding: 7px 9px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.score-table tr:hover td { background: var(--bg); }
.score-input { border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 4px 7px; text-align: center; font-size: 0.88rem; }
.score-input:focus { border-color: var(--blue); outline: none; }
.score-grade-cell { font-size: 0.98rem; text-align: center; }
.score-max-cell, .score-pct-cell { color: var(--text-muted); font-size: 0.8rem; }
.score-notes { border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 4px 7px; font-size: 0.8rem; }

/* ============================================================
   ANALYTICS
   ============================================================ */
.analytics-controls { display: flex; align-items: center; gap: 9px; margin-bottom: 14px; flex-wrap: wrap; }
.analytics-controls label { font-weight: 700; font-size: 0.86rem; color: var(--text-muted); }
.analytics-controls select { min-width: 145px; }
.chart-section { background: var(--surface); border-radius: var(--radius); padding: 15px; margin-bottom: 13px; border: 1px solid var(--border); }
.chart-title { font-size: 0.93rem; font-weight: 700; margin-bottom: 11px; }
.chart-wrap { overflow-x: auto; }
.chart-wrap canvas { display: block; max-width: 100%; border-radius: var(--radius-sm); }
.absence-table-wrap { overflow-x: auto; }
.absence-legend { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 7px; }
.absence-tbl { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.absence-tbl th { background: var(--bg); padding: 7px 10px; text-align: left; font-size: 0.76rem; color: var(--text-muted); border-bottom: 1.5px solid var(--border); }
.absence-tbl td { padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.absence-tbl tr:hover td { background: var(--bg); }

/* ============================================================
   NOTICE BANNER (classroom)
   ============================================================ */
.notice-banner {
    display: flex; flex-wrap: wrap; align-items: flex-start;
    justify-content: space-between; gap: 9px 12px;
    background: var(--gold-light); border-left: 3px solid var(--gold);
    border-radius: var(--radius-sm); padding: 11px 13px;
    margin: 0 0 12px; border: 1px solid rgba(224,152,48,0.3);
}
.notice-banner.hidden { display: none !important; }
.notice-banner-body { display: flex; align-items: flex-start; gap: 8px; flex: 1; min-width: 0; }
.notice-dismiss-btn { flex-shrink: 0; align-self: center; }
@keyframes fadeSlideIn { from { opacity:0; transform:translateY(-5px); } to { opacity:1; transform:translateY(0); } }
.notice-icon { font-size: 1rem; flex-shrink: 0; }
.notice-text { font-size: 0.88rem; color: #5C3E00; line-height: 1.45; white-space: pre-wrap; }

/* ============================================================
   POTTY TRAINING LOG (retain exact functional styles)
   ============================================================ */
.btn-potty-open { background: #5C8A68 !important; color: #fff !important; }
.btn-potty-open:hover { background: #486e52 !important; }
.potty-log-section { background: var(--surface); border-radius: var(--radius-lg); padding: 13px; margin: 13px 0; border: 1.5px solid #7B9E87; }
.potty-header { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 8px; margin-bottom: 9px; }
.potty-header h3 { margin: 0; color: #2A4830; font-size: 0.98rem; }
.potty-header-left { display: flex; flex-direction: column; gap: 5px; min-width: 0; flex: 1; }
.potty-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.potty-title-row h3 { flex: 0 1 auto; }
.potty-help-sheet {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin: 0 0 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.45;
    max-width: 42rem;
}
.potty-help-sheet p { margin: 0 0 8px; }
.potty-help-sheet p:last-child { margin-bottom: 0; }
.potty-help-sheet strong { color: var(--text); }
.potty-header-right { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.potty-legend {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 14px;
    font-size: 0.76rem;
    color: var(--text-muted);
}
.potty-legend .pl-badge { flex-shrink: 0; }
.potty-date-input { padding: 5px 8px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: 0.86rem; }
.pl-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 4px; border-radius: 4px; font-size: 0.68rem; font-weight: 800; color: #fff; box-sizing: border-box; }
.potty-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-sm); }
.potty-table { border-collapse: collapse; font-size: 0.78rem; min-width: max-content; }
.potty-table th { background: #3a5a40; color: #fff; padding: 5px 4px; text-align: center; white-space: nowrap; font-size: 0.7rem; position: sticky; top: 0; z-index: 2; }
.potty-table th.pt-name-h { position: sticky; left: 0; z-index: 3; }
.potty-table td { padding: 3px 2px; border-bottom: 1px solid #e8f0e9; vertical-align: middle; text-align: center; }
.potty-table tr:nth-child(even) td { background: #f4faf5; }
.potty-table tr:hover td { background: #e8f5ea; }
.pt-name { position: sticky; left: 0; background: #fff; z-index: 1; font-weight: 600; text-align: left; padding: 4px 8px !important; min-width: 110px; white-space: nowrap; border-right: 2px solid #c8e6c9; }
.potty-table tr:nth-child(even) .pt-name { background: #f4faf5; }
.potty-table tr:hover .pt-name { background: #e8f5ea; }
.pt-arrive { min-width: 44px; font-size: 0.7rem; color: var(--text-muted); }
.pt-type select, .pt-type { min-width: 50px; }
.pt-num input { width: 46px; text-align: center; border: 1px solid var(--border); border-radius: 3px; padding: 2px 4px; font-size: 0.78rem; }
.pt-time { min-width: 38px; font-size: 0.66rem !important; }
.pt-teeth input[type=checkbox] { transform: scale(1.3); cursor: pointer; }
.pt-select { border: 1px solid var(--border); border-radius: 3px; padding: 2px; font-size: 0.78rem; }
.pt-cell { min-width: 34px; width: auto; height: 28px; padding: 0 3px; border: none; border-radius: 4px; font-size: 0.72rem; font-weight: 800; cursor: pointer; transition: transform 0.1s; display: flex; align-items: center; justify-content: center; margin: 1px auto; }
.pt-cell:active { transform: scale(0.88); }
.pl-empty { background: #f0f0f0; color: #bbb; }
.pl-c  { background: #BBDEFB; color: #1565C0; }
.pl-n  { background: #C8E6C9; color: #2E7D32; }
.pl-1  { background: #FFF9C4; color: #F57F17; border: 1px solid #F9A825; }
.pl-2  { background: #EFEBE9; color: #5D4037; }
.pl-a1 { background: #FFE0B2; color: #E65100; }
.pl-a2 { background: #FFCDD2; color: #B71C1C; }
.pt-cell-wrap { position: relative; display: inline-block; }
.pt-picker { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); z-index: 100; background: #fff; border: 1.5px solid var(--border); border-radius: var(--radius); box-shadow: 0 6px 18px rgba(0,0,0,0.13); padding: 7px; display: flex; gap: 4px; flex-wrap: wrap; width: 200px; animation: fadeSlideIn 0.15s ease; }
.pt-picker-btn { width: 38px; height: 34px; border: none; border-radius: 5px; font-size: 0.85rem; font-weight: 800; cursor: pointer; transition: transform 0.1s; }
.pt-picker-btn:hover { transform: scale(1.12); }
.pt-picker-btn.pick-empty { background: #f0f0f0; color: #999; font-size: 0.68rem; }

.lf-title { font-size: 1.05rem; margin: 0 0 6px; color: var(--text); }
.lf-sub { font-size: 0.88rem; margin: 0 0 6px; color: var(--text-muted); font-weight: 600; }
.lf-check-grid { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; font-size: 0.86rem; }

.ech-qr-block { margin-bottom: 12px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.ech-qr-block > label { display: block; font-size: 0.78rem; font-weight: 600; margin-bottom: 6px; }
.ech-qr-panel.hidden { display: none !important; }
.ech-qr-panel { margin-top: 10px; text-align: center; }
.ech-qr-canvas { max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.ech-qr-dl-hint { font-size: 0.76rem; color: var(--text-muted); margin: 8px 0 4px; }
.ech-qr-dl-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

.btn-meal-open { background: #B8860B !important; color: #fff !important; }
.btn-meal-open:hover { background: #9a7310 !important; }
.meal-log-section { background: var(--surface); border-radius: var(--radius-lg); padding: 13px; margin: 13px 0; border: 1.5px solid #c9a227; }
.meal-header { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 8px; margin-bottom: 9px; }
.meal-header h3 { margin: 0; color: #6b4e16; font-size: 0.98rem; }
.meal-header-left { display: flex; flex-direction: column; gap: 5px; min-width: 0; flex: 1; }
.meal-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.meal-help-sheet {
    font-size: 0.8rem; line-height: 1.45; color: var(--text-muted);
    background: #fffbeb; border: 1px solid #fde68a; border-radius: var(--radius-sm); padding: 10px 12px; margin-top: 4px;
}
.meal-help-sheet p { margin: 0 0 8px; }
.meal-help-sheet p:last-child { margin-bottom: 0; }
.meal-help-sheet strong { color: var(--text); }
.meal-header-right { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.meal-legend { display: flex; flex-wrap: wrap; gap: 10px 14px; font-size: 0.72rem; color: var(--text-muted); align-items: center; }
.meal-legend .ml-badge { flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; min-width: 1.35rem; height: 1.35rem; border-radius: 4px; font-size: 0.72rem; font-weight: 800; }
.meal-date-input { padding: 5px 8px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: 0.86rem; }
.meal-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-sm); }
.meal-table { border-collapse: collapse; font-size: 0.82rem; min-width: max-content; width: 100%; }
.meal-table th { background: #7a5c12; color: #fff; padding: 7px 8px; text-align: center; white-space: nowrap; font-size: 0.74rem; position: sticky; top: 0; z-index: 2; }
.meal-table th.ml-name-h { position: sticky; left: 0; z-index: 3; text-align: left; }
.meal-table td { padding: 5px 6px; border-bottom: 1px solid #f5e6c8; vertical-align: middle; text-align: center; }
.meal-table tr:nth-child(even) td { background: #fffdf7; }
.meal-table tr:hover td { background: #fff8e6; }
.meal-table .ml-name { position: sticky; left: 0; text-align: left; font-weight: 600; background: var(--surface); z-index: 1; min-width: 7rem; }
.meal-table tr:nth-child(even) .ml-name { background: #fffdf7; }
.meal-table tr:hover .ml-name { background: #fff8e6; }
.ml-cell { min-width: 2.4rem; height: 2.1rem; border: none; border-radius: 6px; font-size: 1rem; font-weight: 700; cursor: pointer; transition: transform 0.08s; }
.ml-cell:hover { transform: scale(1.06); }
.ml-empty { background: #f3f4f6; color: #9ca3af; }
.ml-y { background: #bbf7d0; color: #166534; }
.ml-n { background: #fecaca; color: #991b1b; }
.ml-notes { width: 100%; min-width: 8rem; max-width: 18rem; padding: 4px 6px; border: 1px solid var(--border); border-radius: 4px; font-size: 0.78rem; }
.ml-arrive { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; }

/* ============================================================
   PRINT STYLES
   ============================================================ */
@media print {
    .app-header, .app-nav, .bulk-actions, .scanner-container,
    .roster-list, .mini-schedule-section, .btn-print-potty,
    .btn-close-potty, .potty-header-right,
    .btn-print-meal, .btn-close-meal, .meal-header-right { display: none !important; }
    .potty-log-section { border: none; box-shadow: none; padding: 0; }
    .meal-log-section { border: none; box-shadow: none; padding: 0; }
    .potty-table th { background: #3a5a40 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .meal-table th { background: #7a5c12 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .pl-c  { background: #BBDEFB !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .pl-n  { background: #C8E6C9 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .pl-1  { background: #FFF9C4 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .pl-2  { background: #EFEBE9 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .pl-a1 { background: #FFE0B2 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .pl-a2 { background: #FFCDD2 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .ml-y { background: #bbf7d0 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .ml-n { background: #fecaca !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .ml-empty { background: #f3f4f6 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ============================================================
   CLEARED CELEBRATION
   ============================================================ */
.cleared-celebration {
    position: fixed; inset: 0; z-index: 2500;
    display: flex; align-items: center; justify-content: center; padding: 20px;
    background: rgba(10, 20, 35, 0.5); backdrop-filter: blur(4px);
    pointer-events: none; opacity: 0; transition: opacity 0.3s ease;
}
.cleared-celebration.cleared-celebration--show { opacity: 1; }
.cleared-celebration.hidden { display: none !important; opacity: 0; }
.cleared-celebration-card {
    text-align: center; max-width: 260px; padding: 22px 18px 26px;
    background: var(--surface); border-radius: 18px;
    box-shadow: 0 14px 44px rgba(0,0,0,0.17);
    border: 1.5px solid rgba(45,158,95,0.3);
    transform: scale(0.88) translateY(12px);
    transition: transform 0.4s cubic-bezier(0.34,1.4,0.64,1), opacity 0.3s ease;
    opacity: 0;
}
.cleared-celebration.cleared-celebration--show .cleared-celebration-card { transform: scale(1) translateY(0); opacity: 1; }
.cleared-celebration-brand { font-size: clamp(1.6rem, 7vw, 2rem); font-weight: 900; letter-spacing: 0.15em; color: #1A5820; margin-bottom: 14px; }
.cleared-celebration-footnote { font-size: 0.68rem; font-weight: 600; letter-spacing: 0.18em; color: var(--text-muted); text-transform: uppercase; margin: 11px 0 0; opacity: 0.7; }
.cleared-celebration-avatar {
    width: 96px;
    height: 96px;
    margin: 0 auto 10px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid #81C784;
    background: var(--bg);
    flex-shrink: 0;
    box-sizing: border-box;
    box-shadow: 0 4px 14px rgba(45, 158, 95, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
}
.cleared-celebration-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Placeholder shares the same fixed circle — do NOT override width/height. */
.cleared-celebration-avatar.cleared-celebration-avatar-ph {
    background: var(--blue-light);
    font-size: 2.3rem;
    font-weight: 800;
    color: var(--blue-dark);
}
.cleared-celebration-name { font-size: 1.1rem; font-weight: 700; color: var(--text); margin: 0; }

/* ============================================================
   APP LOGIN SCREEN
   ============================================================ */
.app-login-screen {
    min-height: 100dvh; display: flex; align-items: center; justify-content: center;
    padding: max(20px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px))
             max(24px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
    background: var(--bg);
}
.app-login-card {
    width: 100%; max-width: 370px; background: var(--surface);
    border-radius: var(--radius-lg); padding: 26px 22px; border: 1px solid var(--border);
}
.app-login-title { font-size: 1.2rem; font-weight: 700; color: var(--text); text-align: center; margin: 0 0 8px; }
.app-login-brand { text-align: center; margin-bottom: 4px; }
.app-login-logo  { font-size: 1.55rem; font-weight: 800; color: var(--blue-dark); letter-spacing: -0.02em; }
.app-login-tagline { text-align: center; font-size: 0.86rem; color: var(--text-muted); margin-bottom: 18px; line-height: 1.45; }
.app-login-label { display: block; font-size: 0.78rem; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.app-login-pin { text-align: center; font-size: 1.2rem; letter-spacing: 0.4em; margin-bottom: 11px; }
.app-login-hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 11px; line-height: 1.45; }
.app-login-hint.small { font-size: 0.74rem; margin-top: 3px; margin-bottom: 0; }
.app-login-demo { margin-top: 14px; text-align: center; font-size: 0.74rem; }
.school-slug-wrap { margin-bottom: 14px; }
.school-slug-wrap.hidden { display: none !important; }
.app-login-slug { width: 100%; margin-bottom: 5px; }
.landing-back-wrap { margin-top: 11px; text-align: center; }

/* ============================================================
   LANDING PAGE
   ============================================================ */
.landing-page { min-height: 100vh; background: var(--surface); color: var(--text); }
.landing-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: max(0px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px));
    min-height: calc(52px + env(safe-area-inset-top, 0px));
    box-sizing: border-box;
    background: var(--surface);
    border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50;
}
.landing-logo { font-size: 1.2rem; font-weight: 800; color: var(--blue-dark); letter-spacing: -0.02em; }
.landing-header-cta { padding: 7px 14px; font-size: 0.86rem; }
.landing-hero { padding: clamp(36px,6vw,72px) 20px clamp(44px,7vw,80px); max-width: 820px; margin: 0 auto; }
.landing-hero-inner { max-width: 600px; }
.landing-kicker { font-size: 0.73rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--blue); margin-bottom: 11px; }
.landing-hero-title { font-size: clamp(1.6rem, 4.5vw, 2.35rem); font-weight: 800; line-height: 1.15; margin-bottom: 14px; letter-spacing: -0.02em; }
.landing-hero-lead { font-size: 0.98rem; color: var(--text-muted); max-width: 48ch; margin-bottom: 22px; line-height: 1.6; }
.landing-hero-actions { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.landing-section { padding: 44px 20px 52px; max-width: 1060px; margin: 0 auto; }
.landing-section--alt { background: var(--bg); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.landing-section-title { font-size: 1.35rem; font-weight: 800; margin-bottom: 22px; text-align: center; letter-spacing: -0.01em; }
.landing-benefits { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.landing-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.landing-card h3 { font-size: 0.96rem; color: var(--text); margin-bottom: 6px; font-weight: 700; }
.landing-card p  { font-size: 0.88rem; color: var(--text-muted); line-height: 1.55; }
.landing-split { display: grid; gap: 18px; grid-template-columns: 1fr; }
@media (min-width: 800px) { .landing-split { grid-template-columns: 1.2fr 0.8fr; align-items: start; } }
.landing-prose { font-size: 0.96rem; color: var(--text); line-height: 1.65; margin-bottom: 11px; }
.landing-list  { margin-left: 1.2rem; color: var(--text-muted); line-height: 1.7; font-size: 0.92rem; }
.landing-callout { background: var(--blue-light); border-radius: var(--radius); padding: 14px; font-size: 0.9rem; line-height: 1.55; border: 1px solid var(--blue-muted); }
.landing-steps { max-width: 560px; margin: 0 auto; padding-left: 1.4rem; line-height: 1.8; color: var(--text-muted); }
.landing-steps li { margin-bottom: 7px; }
.landing-footer { text-align: center; padding: 32px 20px 40px; border-top: 1px solid var(--border); background: var(--bg); }
.landing-footer-text { color: var(--text-muted); margin-bottom: 12px; font-size: 0.88rem; }

/* ============================================================
   CAMERA QR MODAL
   ============================================================ */
.cleared-camera-modal {
    position: fixed; inset: 0; z-index: 4000;
    background: rgba(10,18,30,0.58);
    display: flex; align-items: flex-end; justify-content: center;
    padding-top: max(12px, env(safe-area-inset-top, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    backdrop-filter: blur(3px);
}
@media (min-width: 600px) { .cleared-camera-modal { align-items: center; } }
.cleared-camera-modal__inner {
    width: 100%; max-width: 420px; background: var(--surface);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    overflow: hidden; border: 1px solid var(--border);
    box-shadow: 0 -8px 38px rgba(0,0,0,0.2);
}
@media (min-width: 600px) { .cleared-camera-modal__inner { border-radius: var(--radius-lg); } }
.cleared-camera-modal__head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--border);
}
.cleared-camera-modal__head-main { display: flex; align-items: center; gap: 7px; min-width: 0; flex: 1; }
.cleared-camera-modal__title { font-size: 0.98rem; margin: 0; font-weight: 700; min-width: 0; }
.cleared-camera-modal__icon-btn {
    flex-shrink: 0; width: 23px; height: 23px; padding: 0; border-radius: 50%;
    border: 1px solid var(--border); background: var(--bg); color: var(--text-muted);
    font-size: 0.72rem; font-weight: 700; font-style: italic; line-height: 1; cursor: pointer; font-family: Georgia, serif;
}
.cleared-camera-modal__icon-btn:hover { color: var(--text); border-color: var(--text-muted); background: var(--surface); }
.cleared-camera-modal__help-sheet {
    margin: 0; padding: 7px 14px 8px; font-size: 0.78rem;
    color: var(--text-muted); line-height: 1.35;
    border-bottom: 1px solid var(--border); background: var(--bg);
}
.cleared-camera-modal__close { padding: 5px 10px; min-width: auto; }
.cleared-camera-modal__video-wrap {
    position: relative; background: #111; margin: 10px 14px 7px;
    border-radius: var(--radius); overflow: hidden; aspect-ratio: 4/3; max-height: 55vh;
}
.cleared-camera-modal__video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cleared-camera-modal__frame {
    position: absolute; inset: 10% 12%;
    border: 2.5px solid rgba(255,255,255,0.9);
    border-radius: var(--radius); box-shadow: 0 0 0 9999px rgba(0,0,0,0.32);
    pointer-events: none; z-index: 2;
}
.cleared-camera-modal__feedback {
    position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center;
    padding: 13px; background: rgba(8,16,28,0.48); backdrop-filter: blur(3px); pointer-events: none;
}
.cleared-camera-modal__feedback[hidden] { display: none !important; }
.cleared-camera-modal__feedback-card {
    display: flex; flex-wrap: wrap; align-items: flex-start; gap: 11px;
    max-width: 100%; padding: 12px 13px; border-radius: var(--radius-lg);
    background: var(--surface); box-shadow: 0 10px 30px rgba(0,0,0,0.22);
    text-align: left; border: 1.5px solid var(--border);
}
.cleared-camera-modal__feedback-card--success { border-color: rgba(45,158,95,0.5); background: var(--green-light); }
.cleared-camera-modal__feedback-card--warning { background: var(--amber-light); border-color: rgba(192,120,0,0.38); }
.cleared-camera-modal__feedback-card--error   { background: var(--red-light);   border-color: rgba(198,40,40,0.3); }
.cleared-camera-modal__feedback-card--info    { background: var(--blue-light);  border-color: var(--blue-muted); }
.cleared-camera-modal__feedback-photo {
    flex-shrink: 0; width: 58px; height: 58px; border-radius: 50%;
    overflow: hidden; border: 2.5px solid #81C784; background: var(--bg);
}
.cleared-camera-modal__feedback-card--warning .cleared-camera-modal__feedback-photo,
.cleared-camera-modal__feedback-card--error   .cleared-camera-modal__feedback-photo { border-color: rgba(180,128,0,0.5); }
.cleared-camera-modal__feedback-card--error .cleared-camera-modal__feedback-photo { border-color: rgba(198,40,40,0.4); }
.cleared-camera-modal__feedback-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cleared-camera-modal__feedback-ph {
    display: flex; align-items: center; justify-content: center; width: 100%; height: 100%;
    font-size: 1.35rem; font-weight: 800; color: var(--blue-dark); background: var(--blue-light);
}
.cleared-camera-modal__feedback-text { min-width: 0; flex: 1; }
.cleared-camera-modal__feedback-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 7px; margin-bottom: 3px; }
.cleared-camera-modal__feedback-detail { margin: 7px 0 0; padding: 0; font-size: 0.78rem; font-weight: 500; color: var(--text-muted); line-height: 1.35; }
.cleared-camera-modal__feedback-title { font-size: 1.08rem; font-weight: 800; color: #1A5820; line-height: 1.2; margin: 0 0 3px; }
.cleared-camera-modal__feedback-card--warning .cleared-camera-modal__feedback-title { color: #744400; }
.cleared-camera-modal__feedback-card--error   .cleared-camera-modal__feedback-title { color: #A01E1E; }
.cleared-camera-modal__feedback-card--info    .cleared-camera-modal__feedback-title { color: var(--text); }
.cleared-camera-modal__feedback-sub { font-size: 0.88rem; font-weight: 600; color: var(--text); line-height: 1.25; margin: 0; opacity: 0.9; }
.cleared-camera-modal__feedback-actions { flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; margin-top: 2px; }
.cleared-camera-modal__feedback-btn  { font-size: 0.86rem; padding: 6px 12px; }
.cleared-camera-modal__feedback--interactive { pointer-events: auto; }
.cleared-camera-modal__canvas { display: none; }
.cleared-camera-modal__status { padding: 8px 14px 12px; font-size: 0.83rem; color: var(--text-muted); text-align: center; margin: 0; }

/* ============================================================
   SCHOOL FEATURES / SETTINGS PANEL
   ============================================================ */
.sf-panel {
    max-width: 560px;
}
.sf-intro {
    font-size: 0.84rem;
    color: var(--text-muted);
    margin-bottom: 14px;
    line-height: 1.45;
}
.sf-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 16px;
}
.sf-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.sf-row + .sf-row { border-top-color: transparent; border-radius: 0; }
.sf-row:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.sf-row:last-child  { border-radius: 0 0 var(--radius) var(--radius); border-top-color: var(--border); }
.sf-row:only-child  { border-radius: var(--radius); }
.sf-row-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
    word-break: normal;
    overflow-wrap: anywhere;
}
.sf-row:not(.sf-row--stack) .sf-row-info {
    flex: 1 1 45%;
    min-width: min(100%, 10rem);
}
.sf-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}
.sf-desc {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.35;
}
.sf-text-input {
    width: 100%;
    max-width: 100%;
    flex-shrink: 0;
    margin-bottom: 0 !important;
    font-size: 0.86rem;
}

/* Text rows: stack label + field so narrow panels never crush the label */
.sf-row--stack {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
}
.sf-row--stack .sf-row-info {
    flex: none;
    min-width: 0;
    width: 100%;
}
.sf-row--stack .sf-text-input {
    max-width: 100%;
}

/* Toggle switch */
.sf-toggle {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    cursor: pointer;
    position: relative;
}
.sf-toggle input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.sf-track {
    display: flex;
    align-items: center;
    width: 42px;
    height: 24px;
    border-radius: 12px;
    background: var(--border);
    transition: background 0.2s;
    padding: 2px;
    position: relative;
}
.sf-toggle input:checked ~ .sf-track { background: var(--blue); }
.sf-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.18);
    transition: transform 0.2s;
    flex-shrink: 0;
}
.sf-toggle input:checked ~ .sf-track .sf-thumb { transform: translateX(18px); }
.sf-toggle:hover .sf-track { filter: brightness(0.97); }

.sf-save-btn { min-width: 120px; }
.sf-saved-msg {
    display: inline-block;
    margin-left: 12px;
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--green);
    vertical-align: middle;
}

/* ============================================================
   NEW SETTINGS PAGE (school templates, chip editors, save bar)
   ============================================================ */
.settings-page {
    max-width: 940px;
    margin: 0 auto;
    padding-bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}
/* Collapsible settings sections (<details>) */
details.settings-card.settings-collapsible { padding: 0; overflow: hidden; }
details.settings-card > summary.settings-collapsible-summary {
    list-style: none;
    cursor: pointer;
    padding: 18px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    user-select: none;
}
details.settings-card > summary.settings-collapsible-summary::-webkit-details-marker { display: none; }
.settings-collapsible-summary-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: left;
    flex: 1;
    min-width: 0;
}
.settings-collapsible-summary-title { font-weight: 700; color: var(--text); font-size: 1.02rem; }
.settings-collapsible-summary-hint { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; }
details.settings-collapsible > summary.settings-collapsible-summary::after {
    content: '▼';
    font-size: 0.55rem;
    opacity: 0.45;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}
details.settings-collapsible:not([open]) > summary.settings-collapsible-summary::after {
    transform: rotate(-90deg);
}
.settings-collapsible-body {
    padding: 0 22px 20px;
    border-top: 1px solid var(--border);
}
details.settings-hero > summary.settings-collapsible-summary {
    background: linear-gradient(135deg, var(--blue-light), var(--surface));
}
.admin-register-child-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px 16px;
    margin-bottom: 16px;
}
.admin-register-child-panel .admin-subsection-title { margin-top: 0; }
.notice-current-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    margin-bottom: 16px;
}
.notice-current-wrap .admin-subsection-title { margin: 0 0 10px; }
.notice-current-text {
    white-space: pre-wrap;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text);
    margin: 0 0 8px;
}
.theme-setting-collapsible { margin-bottom: 14px; }
.theme-setting-collapsible .theme-setting-card { margin: 0; border-radius: 0; border: none; box-shadow: none; }
.theme-setting-collapsible .settings-collapsible-body { padding: 0 18px 16px; }
/* Appearance block on School settings (collapsible <details>) */
details.theme-setting-wrap { margin: 12px 0; }
.theme-setting-collapsible-body { padding-bottom: 18px; }
.theme-setting-card.theme-setting-inline {
    margin: 0;
    width: 100%;
    box-sizing: border-box;
}
.theme-setting-inline .theme-setting-card-title { font-size: 0.98rem; }
.settings-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    box-shadow: 0 1px 3px rgba(15, 35, 60, 0.04);
}
.settings-section-head { margin-bottom: 14px; }
.settings-section-title {
    margin: 0 0 4px;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}
.settings-section-sub {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
}
.settings-subsection {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px dashed var(--border);
}
.settings-subsection:first-of-type { margin-top: 0; padding-top: 0; border-top: none; }
.settings-subsection-head { margin-bottom: 10px; }
.settings-subsection-title {
    margin: 0 0 2px;
    font-size: 0.86rem;
    font-weight: 700;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.settings-subsection-sub {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.45;
}
.settings-tip {
    margin: 8px 0 0;
    font-size: 0.78rem;
    color: var(--text-muted);
}
.settings-tip.warn { color: var(--red); font-weight: 500; }

/* Hero section */
.settings-hero { background: linear-gradient(135deg, var(--blue-light), var(--surface)); border-color: var(--blue-muted); }
.settings-hero-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
}
.settings-hero-icon {
    font-size: 2.4rem;
    line-height: 1;
    flex-shrink: 0;
}
.settings-hero-title {
    margin: 0 0 2px;
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--blue-dark);
    letter-spacing: -0.02em;
}
.settings-hero-sub {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
}
.settings-hero-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.hero-input {
    width: 100%;
    max-width: 420px;
    font-size: 1rem;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.hero-input:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(79, 134, 198, 0.18);
}
.settings-hero-hint {
    margin: 6px 0 0;
    font-size: 0.76rem;
    color: var(--text-muted);
}

/* Template cards */
.tmpl-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 10px;
}
.tmpl-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 14px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    color: inherit;
    transition: transform 0.15s ease, border-color 0.15s, box-shadow 0.15s;
}
.tmpl-card:hover {
    border-color: var(--blue);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(79, 134, 198, 0.14);
}
.tmpl-card:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.tmpl-card.flash {
    animation: tmplFlash 0.7s ease;
}
@keyframes tmplFlash {
    0%   { background: var(--blue); color: #fff; }
    100% { background: var(--surface); color: var(--text); }
}
.tmpl-card-icon { font-size: 1.7rem; line-height: 1; }
.tmpl-card-name {
    font-weight: 700;
    font-size: 0.92rem;
    color: var(--text);
}
.tmpl-card-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Feature groups */
.feature-group + .feature-group { margin-top: 18px; }
.feature-group-head { margin-bottom: 8px; padding: 0 2px; }
.feature-group-title {
    margin: 0 0 2px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}
.feature-group-sub {
    margin: 0;
    font-size: 0.76rem;
    color: var(--text-muted);
    line-height: 1.4;
}
.feature-group-rows {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.feature-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 10px;
}
.feature-row-icon {
    font-size: 1.4rem;
    line-height: 1;
    width: 32px;
    text-align: center;
    flex-shrink: 0;
}
.feature-row-info { flex: 1; min-width: 0; }
.feature-row-name {
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--text);
}
.feature-row-desc {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin-top: 1px;
}

/* Time-slot chip grid */
.time-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
    gap: 6px;
    margin-bottom: 4px;
}
.time-chip {
    padding: 7px 4px;
    border: 1.5px solid var(--border);
    border-radius: 7px;
    background: var(--surface);
    font-size: 0.8rem;
    font-family: ui-monospace, "SFMono-Regular", "Consolas", monospace;
    cursor: pointer;
    transition: all 0.12s;
    user-select: none;
    color: var(--text);
}
.time-chip:hover { border-color: var(--blue); color: var(--blue-dark); }
.time-chip.active {
    background: var(--blue);
    border-color: var(--blue);
    color: #fff;
    font-weight: 700;
}
.time-custom-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 10px;
    flex-wrap: wrap;
}
.time-custom-row input[type="time"] {
    width: 130px;
    padding: 6px 10px;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
}

/* Toggle pills (single column visibility) */
.toggle-pill-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.toggle-pill {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1.5px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    cursor: pointer;
    user-select: none;
    font-size: 0.84rem;
    font-family: inherit;
    color: var(--text);
    transition: all 0.12s;
}
.toggle-pill:hover { border-color: var(--blue); }
.toggle-pill.active {
    background: var(--blue);
    border-color: var(--blue);
    color: #fff;
    font-weight: 600;
}
.toggle-pill.active::before {
    content: '✓';
    margin-right: 2px;
    font-size: 0.78rem;
}

/* Meal-column chip editor */
.meal-cols {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}
.meal-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px 4px 12px;
    background: var(--blue-light);
    border: 1.5px solid var(--blue-muted);
    border-radius: 999px;
    font-size: 0.85rem;
    transition: border-color 0.12s;
}
.meal-chip:focus-within { border-color: var(--blue); }
.meal-chip-edit {
    border: none;
    background: transparent;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--blue-dark);
    width: 9rem;
    max-width: 14rem;
    outline: none;
    padding: 2px 0;
    font-family: inherit;
}
.meal-chip-actions {
    display: inline-flex;
    gap: 1px;
    align-items: center;
}
.meal-chip-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    color: var(--text-muted);
    transition: background 0.12s, color 0.12s;
}
.meal-chip-btn:hover { background: rgba(0, 0, 0, 0.06); color: var(--text); }
.meal-chip-btn:disabled { opacity: 0.35; cursor: default; }
.meal-chip-btn:disabled:hover { background: transparent; color: var(--text-muted); }
.meal-chip-btn.btn-remove:hover {
    background: var(--red-light);
    color: var(--red);
}
.meal-add-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 6px;
}
.meal-add-input {
    flex: 1;
    max-width: 260px;
    padding: 7px 12px;
    border: 1.5px dashed var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
    background: var(--surface);
    font-family: inherit;
}
.meal-add-input:focus {
    outline: none;
    border-color: var(--blue);
    border-style: solid;
}

/* Link-styled inline buttons (e.g. “Use default grid”) */
.link-btn {
    background: none;
    border: none;
    padding: 0;
    color: var(--blue-dark);
    font-size: inherit;
    font-family: inherit;
    cursor: pointer;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}
.link-btn:hover { color: var(--blue); }

/* Sticky save bar */
.settings-savebar {
    position: sticky;
    bottom: 0;
    z-index: 5;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    margin-top: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 -6px 20px rgba(15, 35, 60, 0.06);
}
.settings-dirty-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--green);
    transition: background 0.2s;
    flex-shrink: 0;
}
.settings-dirty-dot.dirty { background: #E09830; box-shadow: 0 0 0 4px rgba(224, 152, 48, 0.18); }
.settings-dirty-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}
.settings-dirty-text.err { color: var(--red); font-weight: 600; }
.save-spacer { flex: 1; }

@media (max-width: 640px) {
    .settings-card { padding: 16px; border-radius: var(--radius); }
    .settings-hero-title { font-size: 1.2rem; }
    .settings-hero-icon { font-size: 1.9rem; }
    .tmpl-grid { grid-template-columns: 1fr 1fr; }
    .feature-row { padding: 10px 12px; gap: 10px; }
    .feature-row-icon { font-size: 1.2rem; width: 24px; }
}

/* Staff duty + accountability */
/* ============================================================
   CLASS PICKER (post-login dashboard)
   ============================================================ */
.class-picker {
    max-width: 900px; margin: 24px auto; padding: 0 16px;
}
.class-picker-header { text-align: center; margin-bottom: 18px; }
.class-picker-lead { color: var(--text-muted, #5a6c7c); margin-top: 4px; font-size: 0.95rem; }
.class-picker-grid {
    display: grid; gap: 14px;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.class-picker-card {
    background: var(--surface, #fff);
    border: 1px solid var(--border, #d8e0e8);
    border-radius: 14px;
    padding: 18px 16px;
    cursor: pointer;
    text-align: left;
    font: inherit;
    color: inherit;
    transition: transform 0.1s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    display: flex; flex-direction: column; gap: 8px;
}
.class-picker-card:hover {
    border-color: var(--blue-dark, #2f6e9a);
    box-shadow: 0 6px 18px rgba(47, 110, 154, 0.12);
    transform: translateY(-1px);
}
.class-picker-card[disabled] { opacity: 0.55; cursor: progress; }
.class-picker-card-emoji { font-size: 2rem; line-height: 1; }
.class-picker-card-name { font-weight: 700; font-size: 1.1rem; color: var(--blue-dark, #2f6e9a); }
.class-picker-card-meta { color: var(--text-muted, #5a6c7c); font-size: 0.85rem; }
.class-picker-card-tag {
    display: inline-block; align-self: flex-start;
    background: var(--blue-light, #eaf3fa); color: var(--blue-dark, #2f6e9a);
    padding: 2px 8px; border-radius: 999px; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.02em;
}
.class-picker-card-tag--sub { background: #fff3df; color: #9a5d17; }
.class-picker-card-tag--co  { background: #ecf6e7; color: #3a7b29; }
.class-picker-card-tag--admin { background: #f1ecff; color: #5b3aa0; }

/* ============================================================
   STAFF ADMIN (Admin → Staff)
   ============================================================ */
.staff-admin-head {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
    flex-wrap: wrap; margin-bottom: 12px;
}
.staff-admin-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.staff-admin-toolbar {
    display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
    padding: 8px 0 12px;
}
.staff-admin-search {
    flex: 1; min-width: 220px;
    padding: 8px 12px;
    border: 1px solid var(--border, #d8e0e8);
    border-radius: 10px; font: inherit;
}
.staff-admin-list {
    display: flex; flex-direction: column; gap: 10px;
}
.staff-card {
    display: grid;
    grid-template-columns: minmax(0, 2.4fr) minmax(0, 2fr) minmax(0, 1.5fr) auto;
    gap: 12px; align-items: center;
    padding: 14px 16px;
    background: var(--surface, #fff);
    border: 1px solid var(--border, #d8e0e8);
    border-radius: 12px;
}
.staff-card--inactive { opacity: 0.62; }
.staff-card-identity { min-width: 0; }
.staff-card-name { font-weight: 700; color: var(--blue-dark, #2f6e9a); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.staff-card-email { font-size: 0.86rem; color: var(--text-muted, #5a6c7c); word-break: break-all; }
.staff-card-class { font-size: 0.92rem; }
.staff-card-class strong { color: var(--blue-dark); }
.staff-card-assigns { font-size: 0.85rem; color: var(--text-muted, #5a6c7c); display: flex; gap: 4px; flex-wrap: wrap; }
.staff-card-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.staff-pill {
    display: inline-block; padding: 2px 8px; border-radius: 999px;
    font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em;
}
.staff-pill--admin { background: #f1ecff; color: #5b3aa0; }
.staff-pill--sub { background: #fff3df; color: #9a5d17; }
.staff-pill--co  { background: #ecf6e7; color: #3a7b29; }
.staff-pill--disabled { background: #f6dadb; color: #8a2024; }
.staff-pill--temp-pw { background: #fff7d6; color: #8a6900; }

@media (max-width: 720px) {
    .staff-card {
        grid-template-columns: 1fr;
    }
    .staff-card-actions { justify-content: flex-start; }
}

/* Modal — generic */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(15, 30, 55, 0.55);
    display: flex; align-items: center; justify-content: center;
    z-index: 1200; padding: 16px;
}
.modal-card {
    width: 100%; max-width: 520px;
    background: var(--surface, #fff);
    border: 1px solid var(--border, #d8e0e8);
    border-radius: 14px;
    padding: 20px;
    max-height: 90vh; overflow-y: auto;
}
.modal-head {
    display: flex; justify-content: space-between; align-items: center; gap: 8px;
    margin-bottom: 16px;
}
.modal-head h3 { margin: 0; color: var(--blue-dark, #2f6e9a); }
.btn-icon {
    border: 0; background: transparent; cursor: pointer; padding: 4px 8px;
    font-size: 1.05rem; color: var(--text-muted, #5a6c7c); border-radius: 6px;
}
.btn-icon:hover { background: rgba(15, 30, 55, 0.06); }
.modal-actions {
    display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px;
}
.staff-modal-form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 0.85rem; font-weight: 600; color: var(--text-muted, #5a6c7c); }
.field input, .field select {
    padding: 9px 12px; border: 1px solid var(--border, #d8e0e8);
    border-radius: 10px; font: inherit;
}
.staff-modal-hint { font-size: 0.82rem; color: var(--text-muted, #5a6c7c); margin: 4px 0 0; }

.staff-temp-pw-warning {
    margin: 0 0 12px; padding: 10px 12px;
    background: #fff7d6; border: 1px solid #f0d780;
    border-radius: 10px; color: #6e5200; font-size: 0.92rem;
}
.staff-temp-pw-box {
    display: flex; gap: 8px; align-items: center; padding: 10px 14px;
    background: #f4f7fa; border-radius: 10px;
}
.staff-temp-pw-box code {
    flex: 1; font-size: 1.1rem; font-weight: 700; word-break: break-all;
    letter-spacing: 0.04em;
}
.staff-temp-pw-meta { font-size: 0.85rem; color: var(--text-muted, #5a6c7c); margin: 12px 0 0; }

.staff-assign-list {
    display: flex; flex-direction: column; gap: 8px; margin: 8px 0 12px;
}
.staff-assign-row {
    display: flex; justify-content: space-between; align-items: center; gap: 8px;
    padding: 10px 12px; border: 1px solid var(--border, #d8e0e8);
    border-radius: 10px;
}
.staff-assign-row-name { font-weight: 600; }
.staff-assign-row-role { font-size: 0.85rem; color: var(--text-muted, #5a6c7c); }
.staff-assign-form {
    display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
    margin-top: 6px;
}
.staff-assign-form select {
    flex: 1; min-width: 140px;
    padding: 8px 12px; border: 1px solid var(--border, #d8e0e8); border-radius: 10px; font: inherit;
}

/* ============================================================
   INLINE GRADES (inside Class tab)
   ============================================================ */
.btn-grades-open { background: #6b4be0; color: #fff; }
.btn-grades-open:hover { background: #5938c8; }
.grades-section {
    margin-top: 18px;
    padding: 16px;
    background: var(--surface, #fff);
    border: 1px solid var(--border, #d8e0e8);
    border-radius: 14px;
    box-shadow: 0 2px 6px rgba(15, 30, 55, 0.04);
}
.grades-section-header {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
    flex-wrap: wrap; margin-bottom: 12px;
}
.grades-section-title { margin: 0; color: var(--blue-dark, #2f6e9a); font-size: 1.15rem; }
.grades-section-meta { margin: 4px 0 0; color: var(--text-muted, #5a6c7c); font-size: 0.88rem; }
.grades-section-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.visually-hidden {
    position: absolute !important; clip: rect(0 0 0 0); width: 1px; height: 1px;
    margin: -1px; padding: 0; overflow: hidden; border: 0;
}

.offline-demo-login {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border, #e0e0e0);
}
.offline-demo-login summary {
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.staff-duty-panel {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #E8F4FD 0%, #F0F7FF 100%);
    border: 1px solid var(--blue-muted);
    border-radius: 12px;
}
.staff-duty-status { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 200px; font-size: 0.88rem; font-weight: 600; color: var(--blue-dark); }
.staff-duty-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; background: var(--text-muted); }
.staff-duty-dot--on { background: var(--green); box-shadow: 0 0 0 3px rgba(45, 158, 95, 0.25); }
.staff-duty-actions { display: flex; gap: 6px; flex-shrink: 0; }
.modal-content-narrow { max-width: 360px; }
.pin-verify-lead { font-size: 0.88rem; color: var(--text-muted); margin: 0 0 12px; line-height: 1.45; }
.admin-subsection-title { font-size: 1rem; font-weight: 700; margin: 18px 0 10px; color: var(--text); }
.duty-timeline-item.duty-sign_in { border-left: 3px solid var(--green); }
.duty-timeline-item.duty-sign_out { border-left: 3px solid #8FA8B8; }
.audit-item { border-left: 3px solid var(--border); }
.audit-detail { font-size: 0.8rem; color: var(--text-muted); margin: 4px 0 0; line-height: 1.35; }
.csv-preview { margin-top: 10px; padding: 10px; background: var(--surface-alt); border-radius: 8px; font-size: 0.86rem; }
.csv-preview-list, .csv-errors { margin: 8px 0 0; padding-left: 18px; }
.csv-preview .warn { color: var(--amber); font-weight: 600; }
.inc-field { margin-bottom: 10px; }
.req { color: var(--red); }

/* ============================================================
   DARK MODE
   Soft navy palette — not pure black, keeps the ClearED blue
   identity but lowers contrast so the screen is restful at night.
   Trigger: <html data-theme="dark">  (set by bootstrap script).
   ============================================================ */
.btn-theme-toggle {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    width: 32px; height: 32px;
    border-radius: 999px;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.btn-theme-toggle:hover { background: var(--bg); border-color: var(--border); }
.btn-theme-toggle:active { transform: scale(0.94); }
.btn-theme-toggle-icon { line-height: 1; }

[data-theme="dark"] {
    color-scheme: dark;

    --blue:        #7EB3F0;
    --blue-dark:   #A8D0FF;
    --blue-light:  #243A52;
    --blue-muted:  #4A6688;

    --gold:        #EBA94B;
    --gold-light:  #3A2F1B;

    --bg:          #121A24;
    --surface:     #1A2533;
    --surface-alt: #243040;

    --text:        #F0F5FA;
    /* Higher contrast vs surface for “muted” labels (was ~4.5:1; now clearer) */
    --text-muted:  #B9CCDE;
    --border:      #344A63;

    --green:       #4CD495;
    --green-light: #1A3328;
    --red:         #F07171;
    --red-light:   #3A2226;
    --amber:       #E8B050;
    --amber-light: #3B3020;

    --focus-ring: 0 0 0 3px rgba(126, 179, 240, 0.35);
}

/* Inputs / selects use the platform default border which is too light on dark */
[data-theme="dark"] body { background: var(--bg); }
[data-theme="dark"] input,
[data-theme="dark"] textarea {
    background-color: var(--surface-alt);
    color: var(--text);
    border-color: var(--border);
}
/* Use background-color only so the custom caret SVG is not reset or tiled by the `background` shorthand */
[data-theme="dark"] select {
    background-color: var(--surface-alt);
    color: var(--text);
    border-color: var(--border);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='7' viewBox='0 0 11 7'%3E%3Cpath d='M1 1l4.5 4.5L10 1' stroke='%23B9CCDE' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 9px center;
    background-size: 11px 7px;
}
[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder { color: var(--text-muted); opacity: 0.75; }

/* Scan card uses a hardcoded white gradient; soften it for dark */
[data-theme="dark"] .scan-card {
    background: linear-gradient(160deg, var(--surface) 0%, var(--surface-alt) 100%);
}
[data-theme="dark"] .btn-scan-card-toggle {
    background: var(--surface-alt);
    border-color: var(--border);
    color: var(--text-muted);
}
[data-theme="dark"] .btn-scan-card-toggle:hover {
    color: var(--text);
    border-color: var(--text-muted);
}

/* Hardcoded warm yellow on temp-password banner — too bright on dark */
[data-theme="dark"] .staff-temp-pw-warning {
    background: rgba(235, 169, 75, 0.12);
    border-color: rgba(235, 169, 75, 0.35);
    color: #f3d899;
}
[data-theme="dark"] .staff-temp-pw-box { background: var(--surface-alt); }

/* Staff role pills use tinted backgrounds — darken to fit theme */
[data-theme="dark"] .staff-pill--admin    { background: rgba(155, 119, 230, 0.18); color: #c5b3ea; }
[data-theme="dark"] .staff-pill--sub      { background: rgba(235, 169, 75, 0.18);  color: #e8c486; }
[data-theme="dark"] .staff-pill--co       { background: rgba(63, 185, 122, 0.18);  color: #92d8ad; }
[data-theme="dark"] .staff-pill--disabled { background: rgba(230, 98, 98, 0.18);   color: #e89191; }
[data-theme="dark"] .staff-pill--temp-pw  { background: rgba(235, 169, 75, 0.18);  color: #e8c486; }

/* Modal backdrop is fine, but make modal cards & icon buttons sit on the right surface */
[data-theme="dark"] .modal-backdrop { background: rgba(0, 0, 0, 0.6); }
[data-theme="dark"] .btn-icon:hover { background: rgba(255, 255, 255, 0.06); }
[data-theme="dark"] .btn-logout:hover { background: var(--surface-alt); color: var(--text); }

/* Class picker cards — they use generic surface vars already, but assignment-tag
   colors were hardcoded. Recolor them. */
[data-theme="dark"] .class-picker-card-tag--sub   { background: rgba(235, 169, 75, 0.18); color: #e8c486; }
[data-theme="dark"] .class-picker-card-tag--co    { background: rgba(63, 185, 122, 0.18); color: #92d8ad; }
[data-theme="dark"] .class-picker-card-tag--admin { background: rgba(155, 119, 230, 0.18); color: #c5b3ea; }

/* Status indicators on dark stay legible */
[data-theme="dark"] .status-indicator.online  { color: #6ad59b; }
[data-theme="dark"] .status-indicator.offline { color: #ec8181; }

/* Logo a touch lighter in dark so it still reads as "blue brand" */
[data-theme="dark"] .logo { color: var(--blue-dark); }

/* Header / sticky surfaces don't get a black bottom border, soften */
[data-theme="dark"] .app-header,
[data-theme="dark"] .app-nav { background: var(--surface); }

/* When the theme toggle is in 'pressed' (dark) state, show the sun icon */
[data-theme="dark"] .btn-theme-toggle-icon { font-size: 0; line-height: 1; }
[data-theme="dark"] .btn-theme-toggle-icon::before { content: '☀️'; font-size: 1rem; }

/* Hardcoded #FFFFFF surfaces that don't auto-adapt */
[data-theme="dark"] .btn-camera-scan {
    background: var(--surface-alt);
    color: var(--blue-dark);
    border-color: var(--blue-muted);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}
[data-theme="dark"] .btn-camera-scan:hover { color: var(--blue); }
[data-theme="dark"] .scan-manual-search { background: var(--surface-alt); }
[data-theme="dark"] .pt-name             { background: var(--surface); }
[data-theme="dark"] .pt-picker           { background: var(--surface); box-shadow: 0 6px 18px rgba(0,0,0,0.45); }

/* Potty & meal table tinted rows — keep the colour cue but dial brightness */
[data-theme="dark"] .potty-table tr:nth-child(even) td,
[data-theme="dark"] .potty-table tr:nth-child(even) .pt-name { background: rgba(63, 185, 122, 0.08); }
[data-theme="dark"] .potty-table tr:hover td,
[data-theme="dark"] .potty-table tr:hover .pt-name           { background: rgba(63, 185, 122, 0.15); }
[data-theme="dark"] .meal-table  tr:nth-child(even) td,
[data-theme="dark"] .meal-table  tr:nth-child(even) .ml-name { background: rgba(235, 169, 75, 0.08); }
[data-theme="dark"] .meal-table  tr:hover td,
[data-theme="dark"] .meal-table  tr:hover .ml-name           { background: rgba(235, 169, 75, 0.16); }

/* Status pills (potty levels, meal indicators) — desaturate the harsh light pastels */
[data-theme="dark"] .pl-empty { background: rgba(255,255,255,0.05); color: var(--text-muted); }
[data-theme="dark"] .pl-1     { background: rgba(255, 235, 130, 0.18); color: #f1d68a; border-color: rgba(249, 168, 37, 0.4); }
[data-theme="dark"] .pl-2     { background: rgba(120, 90, 70, 0.30);  color: #d3b9a0; }
[data-theme="dark"] .pl-a1    { background: rgba(255, 168, 80, 0.20); color: #ffb371; }
[data-theme="dark"] .pl-a2    { background: rgba(230, 98, 98, 0.25);  color: #ee9ea0; }
[data-theme="dark"] .ml-empty { background: rgba(255,255,255,0.05); color: var(--text-muted); }
[data-theme="dark"] .ml-n     { background: rgba(230, 98, 98, 0.25); color: #ee9ea0; }

/* QR canvas must remain pure white for scanability */
[data-theme="dark"] .ech-qr-canvas { background: #fff; }

/* Soft callouts / yellow advisory boxes */
[data-theme="dark"] .meal-summary-card,
[data-theme="dark"] .gradesheet-tip,
[data-theme="dark"] .landing-callout {
    background: rgba(235, 169, 75, 0.10);
    border-color: rgba(235, 169, 75, 0.30);
    color: #f3d899;
}

/* Settings card */
.theme-setting-card {
    display: flex; justify-content: space-between; align-items: center;
    gap: 12px; padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    margin: 12px 0;
}
.theme-setting-card-text { display: flex; flex-direction: column; gap: 2px; }
.theme-setting-card-title { font-weight: 700; color: var(--text); }
.theme-setting-card-meta { font-size: 0.85rem; color: var(--text-muted); }
.theme-setting-switch {
    appearance: none; -webkit-appearance: none;
    width: 46px; height: 26px;
    background: var(--border);
    border-radius: 999px;
    position: relative; cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}
.theme-setting-switch::after {
    content: '';
    position: absolute; top: 3px; left: 3px;
    width: 20px; height: 20px;
    background: var(--surface);
    border-radius: 50%;
    transition: transform 0.2s, background 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.theme-setting-switch:checked { background: var(--blue); }
.theme-setting-switch:checked::after { transform: translateX(20px); }

/* ============================================================
   COMPACT LOGIN
   ============================================================ */
.app-login-card-compact { padding: 18px 18px 16px; max-width: 340px; }
.app-login-head {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    margin-bottom: 14px;
}
.app-login-head .app-login-logo { font-size: 1.45rem; }
.app-login-info { margin: 0; }
.app-login-info-sheet {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 12px;
}
.app-login-info-sheet p { margin: 0 0 6px; }
.app-login-info-sheet ul { margin: 0; padding-left: 18px; }
.app-login-info-sheet li { margin-bottom: 4px; }
.app-login-info-sheet li:last-child { margin-bottom: 0; }
.school-slug-wrap-compact { margin-bottom: 10px; }
.school-slug-wrap-compact .app-login-label { margin-bottom: 3px; }
.school-slug-wrap-compact .app-login-slug { margin-bottom: 6px; }
.school-slug-wrap-compact .btn-login-wide { margin-top: 6px; }

/* Landing header actions row */
.landing-header-actions { display: flex; align-items: center; gap: 10px; }

/* ============================================================
   DARK MODE — hardcoded light-theme colors (navy / brown text)
   ============================================================ */
[data-theme="dark"] .notice-text {
    color: #F5E8C8;
}

[data-theme="dark"] .potty-log-section,
[data-theme="dark"] .meal-log-section {
    border-color: var(--border);
}

[data-theme="dark"] .potty-header h3 {
    color: var(--text);
}

[data-theme="dark"] .meal-header h3 {
    color: var(--text);
}

/* Meal info sheet: light yellow + light muted text fails on dark; use a solid tinted panel */
[data-theme="dark"] .meal-help-sheet {
    background: #2a2418;
    border: 1px solid rgba(232, 176, 80, 0.45);
    color: #f2e8d4;
    box-shadow: none;
}
[data-theme="dark"] .meal-help-sheet strong { color: #fff; }
[data-theme="dark"] .meal-legend { color: var(--text-muted); }

/* Schedule: secondary row actions easier to spot on dark */
[data-theme="dark"] .sched-field--row-actions .btn-secondary {
    border-color: rgba(185, 204, 222, 0.42);
    color: #e8eef4;
    background-color: var(--surface-alt);
}
[data-theme="dark"] .sched-field--row-actions .btn-secondary:hover {
    border-color: rgba(185, 204, 222, 0.65);
    background: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .potty-table th {
    background: var(--green-light);
    color: var(--green);
}

[data-theme="dark"] .potty-table td {
    border-bottom-color: var(--border);
}

[data-theme="dark"] .potty-table tr:nth-child(even) td {
    background: rgba(76, 212, 149, 0.06);
}

[data-theme="dark"] .potty-table tr:hover td {
    background: rgba(76, 212, 149, 0.12);
}

[data-theme="dark"] .pt-name {
    background: var(--surface);
    border-right-color: var(--border);
    color: var(--text);
}

[data-theme="dark"] .potty-table tr:nth-child(even) .pt-name {
    background: rgba(76, 212, 149, 0.06);
}

[data-theme="dark"] .potty-table tr:hover .pt-name {
    background: rgba(76, 212, 149, 0.12);
}

[data-theme="dark"] .meal-table th {
    background: rgba(232, 176, 80, 0.18);
    color: var(--gold);
}

[data-theme="dark"] .meal-table td {
    border-bottom-color: var(--border);
}

[data-theme="dark"] .meal-table tr:nth-child(even) td {
    background: rgba(232, 176, 80, 0.06);
}

[data-theme="dark"] .meal-table tr:hover td {
    background: rgba(232, 176, 80, 0.11);
}

[data-theme="dark"] .meal-table tr:nth-child(even) .ml-name {
    background: rgba(232, 176, 80, 0.06);
}

[data-theme="dark"] .meal-table tr:hover .ml-name {
    background: rgba(232, 176, 80, 0.11);
}

[data-theme="dark"] .gradesheet-tip {
    background: rgba(232, 176, 80, 0.1);
    border-color: rgba(232, 176, 80, 0.35);
    color: #F5E8C8;
}

[data-theme="dark"] .scan-item-in .scan-item-gate-badge {
    color: var(--green);
    background: var(--green-light);
}

[data-theme="dark"] .roster-card.in-class .roster-status {
    color: var(--green);
}

[data-theme="dark"] .roster-card.roster-departed .roster-status {
    color: var(--text-muted);
}

[data-theme="dark"] .class-picker-card-name {
    color: var(--blue);
}

[data-theme="dark"] .class-picker-card-tag {
    background: var(--blue-light);
    color: var(--blue-dark);
}

[data-theme="dark"] .class-picker-card-tag--sub {
    background: rgba(232, 176, 80, 0.2);
    color: #FFD49A;
}

[data-theme="dark"] .class-picker-card-tag--co {
    background: rgba(76, 212, 149, 0.15);
    color: #9CF0C2;
}

[data-theme="dark"] .class-picker-card-tag--admin {
    background: rgba(200, 180, 255, 0.12);
    color: #D9CCFF;
}

[data-theme="dark"] .staff-pill--admin { background: rgba(200, 180, 255, 0.14); color: #E6DCFF; }
[data-theme="dark"] .staff-pill--sub { background: rgba(232, 176, 80, 0.2); color: #FFD49A; }
[data-theme="dark"] .staff-pill--co { background: rgba(76, 212, 149, 0.15); color: #9CF0C2; }
[data-theme="dark"] .staff-pill--disabled { background: rgba(240, 113, 113, 0.18); color: #FFB4B4; }
[data-theme="dark"] .staff-pill--temp-pw { background: rgba(232, 176, 80, 0.2); color: #FFD49A; }

[data-theme="dark"] .modal-head h3 {
    color: var(--text);
}

[data-theme="dark"] .cleared-camera-modal__feedback-title {
    color: var(--green);
}

[data-theme="dark"] .cleared-camera-modal__feedback-card--warning .cleared-camera-modal__feedback-title {
    color: var(--amber);
}

[data-theme="dark"] .cleared-camera-modal__feedback-card--error .cleared-camera-modal__feedback-title {
    color: var(--red);
}

[data-theme="dark"] .cleared-camera-modal__feedback-card--success {
    background: var(--green-light);
    border-color: rgba(76, 212, 149, 0.4);
}

[data-theme="dark"] .cleared-camera-modal__feedback-card--warning {
    background: var(--amber-light);
    border-color: rgba(232, 176, 80, 0.35);
}

[data-theme="dark"] .cleared-camera-modal__feedback-card--error {
    background: var(--red-light);
    border-color: rgba(240, 113, 113, 0.35);
}

[data-theme="dark"] .cleared-camera-modal__feedback-card--info {
    background: var(--blue-light);
    border-color: var(--blue-muted);
}

[data-theme="dark"] .btn-potty-open {
    background: var(--green) !important;
    color: #0d1a14 !important;
}

[data-theme="dark"] .btn-potty-open:hover {
    background: #5ee4ac !important;
}

[data-theme="dark"] .btn-meal-open {
    background: var(--amber) !important;
    color: #1a1408 !important;
}

[data-theme="dark"] .btn-meal-open:hover {
    background: #f0c46a !important;
}

[data-theme="dark"] .pl-c { background: rgba(126, 179, 240, 0.25); color: #C8E4FF; }
[data-theme="dark"] .pl-n { background: rgba(76, 212, 149, 0.2); color: #B8F5D3; }

[data-theme="dark"] .ml-y { background: rgba(76, 212, 149, 0.2); color: #B8F5D3; }
[data-theme="dark"] .ml-n { background: rgba(240, 113, 113, 0.22); color: #FFCACA; }

[data-theme="dark"] .settings-savebar {
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.35);
}

/* ============================================================
   MOBILE & SMALL VIEWPORTS — rhythm, grids, touch
   ============================================================ */
@media (max-width: 600px) {
    .class-picker {
        margin: 16px auto;
        padding: 0 var(--page-pad-x);
    }

    .class-picker-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .class-picker-card {
        padding: 16px 14px;
        border-radius: var(--radius-lg);
    }

    .landing-benefits {
        grid-template-columns: 1fr;
    }

    .landing-hero {
        padding-left: var(--page-pad-x);
        padding-right: var(--page-pad-x);
    }

    .landing-section {
        padding-left: var(--page-pad-x);
        padding-right: var(--page-pad-x);
    }

    .landing-footer {
        padding-left: var(--page-pad-x);
        padding-right: var(--page-pad-x);
        padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px));
    }

    .modal-backdrop {
        padding: max(12px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px))
                 max(12px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
        align-items: flex-end;
    }

    .modal-card {
        max-height: calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        padding: 16px;
    }

    .staff-admin-search {
        min-width: 0;
        width: 100%;
    }

    .staff-admin-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .page-lead {
        max-width: none;
    }

    .user-role-badge {
        max-width: min(50vw, 200px);
    }
}

@media (max-width: 400px) {
    .nav-tab-label {
        font-size: 0.68rem;
    }

    .nav-tab {
        padding: 0 4px;
        min-width: 48px;
    }

    .logo {
        font-size: 1.05rem;
    }
}
