/* ========================================
   CICO v1.1 — Theme & Variables
   ======================================== */
:root {
    --navy: #183153;
    --blue: #2d5f9a;
    --gold: #d8b24c;
    --cream: #fffaf2;
    --sky: #eef6ff;
    --mint: #eaf8ef;
    --rose: #fff0f2;
    --card: #ffffff;
    --text: #1f2937;
    --border: #dbe5f0;
    --shadow: 0 10px 28px rgba(24, 49, 83, 0.10);
    --danger: #d94841;
    --success: #2d8f4e;
    /* AA text colours (audit U8). --text-muted is 5.2:1 on white — use it for
       every hint, caption, axis and placeholder instead of the old #9aa5b4/
       #8e9bab/#8a98a8/#9ca3af/#b0bac8 family (1.96–2.9:1). Gold is a FILL
       colour; gold-as-text is --gold-text (5.4:1). */
    --text-muted: #5f6e84;
    --gold-text: #8a6410;
}

body.dark {
    --cream: #101827;
    --sky: #162132;
    --mint: #16271c;
    --rose: #2c1a23;
    --card: #182434;
    --text: #eef3fb;
    --border: #30455f;
    --shadow: none;
    --text-muted: #a8b4c4;
    --gold-text: #e6c15c;
}

/* ========================================
   Reset & Base
   ======================================== */
*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(180deg, var(--sky), var(--cream));
    color: var(--text);
    min-height: 100vh;
}

/* ========================================
   Login Page
   ======================================== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--navy), var(--blue));
}

.login-footer-link {
    margin-top: 20px;
    margin-bottom: -20px;
    text-align: center;
    font-size: 0.8rem;
}

.login-footer-link a {
    color: var(--text-muted);
    text-decoration: none;
}

.login-footer-link a:hover {
    color: #6b7c93;
    text-decoration: underline;
}

/* ========================================
   Alerts & Toasts
   ======================================== */
.alert {
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 16px;
    font-size: 0.9rem;
    font-weight: 600;
}

.alert-error {
    background: #ffe1df;
    color: #a22c26;
    border: 1px solid #f5c6c3;
}

.alert-success {
    background: #dff5e5;
    color: #22663a;
    border: 1px solid #b8e6c8;
}

.alert-info {
    background: #deeeff;
    color: #1a4a7a;
    border: 1px solid #b8d4f0;
}

#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 20px;
    border-radius: 16px;
    color: #fff;
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    animation: slideIn 0.3s ease;
    max-width: 360px;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--blue); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.badge-initials {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--navy);
    letter-spacing: 0.04em;
    line-height: 1;
}

.profile-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
    min-width: 210px;
    z-index: 300;
    overflow: hidden;
}

.profile-dropdown-name {
    padding: 12px 16px 10px;
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--navy);
    border-bottom: 1px solid #dbe5f0;
    white-space: nowrap;
}
.profile-dropdown-role {
    font-weight: 400;
    font-size: 0.78rem;
    opacity: 0.7;
}

nav button,
.nav-btn {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.28);
    padding: 0.55rem 0.9rem;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
    font-size: 0.85rem;
    white-space: nowrap;
}

/* Close button — shown only when admin opens form from tile */
.nav-close-btn {
    background: rgba(255, 255, 255, 0.92) !important;
    color: var(--navy) !important;
    border-color: rgba(255, 255, 255, 0.7) !important;
    font-weight: 700 !important;
}
.nav-close-btn:hover {
    background: #fff !important;
    opacity: 0.9;
}

/* ========================================
   Tab Bar
   ======================================== */
/* Day Navigation Strip */
#day-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
}
body.dark #day-nav { background: var(--card); }

/* Left group: icon + name + tags */
#day-nav-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    /* Children are nowrap pills; without this they cannot shrink and overflow
       straight into #day-nav-right (the iPad overlap, audit U1). */
    flex-wrap: wrap;
}

#day-nav-icon { font-size: 1.3rem; line-height: 1; }

#day-nav-name {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--navy);
    white-space: nowrap;
}
body.dark #day-nav-name { color: var(--text); }

#day-nav-tags {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

.info-bar-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.74rem;
    font-weight: 600;
    color: #6b7c93;
    background: var(--sky);
    padding: 3px 10px;
    border-radius: 999px;
    white-space: nowrap;
}
.info-bar-tag i { font-size: 0.68rem; color: var(--blue); }
body.dark .info-bar-tag { background: #1e3350; color: #a8c5e8; }
.info-bar-goal { background: #dff5e5; color: #22663a; }
body.dark .info-bar-goal { background: #1a3326; color: #6ee7b7; }

/* Right group: prev + date + next */
#day-nav-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

#day-nav-date {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--navy);
    white-space: nowrap;
    padding: 0 2px;
}
body.dark #day-nav-date { color: var(--text); }

#day-nav button {
    background: none;
    border: 2px solid var(--border);
    border-radius: 999px;
    padding: 0.4rem 0.8rem;
    font-weight: 700;
    font-size: 0.78rem;
    color: var(--navy);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    transition: all 0.15s;
}
#day-nav button:hover:not(:disabled) {
    background: var(--sky);
    border-color: var(--blue);
    color: var(--blue);
}
#day-nav button:disabled { opacity: 0.3; cursor: not-allowed; }
body.dark #day-nav button { color: var(--text); border-color: var(--border); }
body.dark #day-nav button:hover:not(:disabled) { background: #1e3350; }

/* Absent Today button */
.absent-btn {
    background: none;
    border: 2px solid #e53e3e !important;
    color: #e53e3e !important;
}
.absent-btn:hover:not(:disabled) {
    background: #fff5f5 !important;
    border-color: #c53030 !important;
    color: #c53030 !important;
}
.absent-btn.absent-active {
    background: #22c55e !important;
    border-color: #16a34a !important;
    color: #fff !important;
}
.absent-btn.absent-active:hover:not(:disabled) {
    background: #16a34a !important;
}
body.dark .absent-btn { border-color: #fc8181 !important; color: #fc8181 !important; }
body.dark .absent-btn.absent-active { background: #16a34a !important; border-color: #15803d !important; color: #fff !important; }

/* Panel — absent state: grey out all cards and block interaction */
.panel-absent .card {
    opacity: 0.4;
    pointer-events: none;
    user-select: none;
    transition: opacity 0.2s;
}

/* Score wrap — absent state */
.score-wrap.absent-day {
    background: linear-gradient(135deg, #f0f4f8, #fff);
    border-color: #cbd5e0;
}
.score-wrap.absent-day .score-head { color: #718096; }
.absent-day-notice {
    text-align: center;
    padding: 10px 0 4px;
    font-weight: 700;
    font-size: 0.95rem;
    color: #718096;
    letter-spacing: 0.02em;
}
body.dark .score-wrap.absent-day { background: linear-gradient(135deg, #1a2535, var(--card)); }

/* ========================================
   Main Content
   ======================================== */
#main {
    max-width: 1080px;
    margin: 0 auto;
    padding: 18px;
}

.student-panel { display: none; }
.student-panel.active { display: block; }

#archive-panel { display: none; }
#archive-panel.active { display: block; }

#empty-state {
    display: none;
    text-align: center;
    padding: 4rem 1rem;
}

#empty-state h2 { color: var(--navy); }

#empty-add-btn {
    background: var(--gold);
    border: none;
    padding: 0.9rem 1.5rem;
    border-radius: 999px;
    font-weight: 800;
    cursor: pointer;
}

/* ========================================
   Cards & Forms
   ======================================== */
/* Hero removed — student info now in day-nav strip */

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 18px;
    margin-bottom: 18px;
    box-shadow: var(--shadow);
}

.card h3 {
    margin: 0 0 14px;
    color: var(--navy);
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

body.dark .card h3 { color: #a8c5e8; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
}

.mood-sel {
    width: 100%;
    padding: 0.85rem 2.4rem 0.85rem 1.1rem;
    border: 2px solid var(--border);
    border-radius: 50px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7c93' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 1rem center;
    -webkit-appearance: none;
    appearance: none;
    color: #1f2937;
    font-size: 0.95rem;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.mood-sel:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(45, 95, 154, 0.15);
}

body.dark .mood-sel {
    background-color: #0f1825;
    color: #eef3fb;
    border-color: #2a3f5a;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239aa5b4' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 6px;
    opacity: 0.8;
}

.form-group input,
.form-group select,
textarea {
    width: 100%;
    padding: 0.75rem 0.85rem;
    border: 2px solid var(--border);
    border-radius: 16px;
    background: #fff;
    color: #1f2937;
    font-size: 0.92rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
textarea:focus {
    outline: none;
    border-color: var(--blue);
}

.form-group input.invalid,
.form-group select.invalid,
textarea.invalid {
    border-color: var(--danger);
}

body.dark .form-group input,
body.dark .form-group select,
body.dark textarea {
    background: #0f1825;
    color: #eef3fb;
}

textarea { min-height: 88px; resize: vertical; }

/* ========================================
   Expectations Chips
   ======================================== */
.exp-chips { display: flex; flex-wrap: wrap; gap: 10px; }

.exp-chip {
    padding: 0.55rem 0.95rem;
    border-radius: 999px;
    border: 2px solid transparent;
    background: linear-gradient(135deg, var(--navy), var(--blue));
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
}

body.dark .exp-chip { background: linear-gradient(135deg, var(--navy), var(--blue)); color: #fff; }
    cursor: pointer;
    font-weight: 700;
}

/* ========================================
   Score Bar
   ======================================== */
.score-wrap {
    background: linear-gradient(135deg, var(--mint), #fff);
    padding: 14px;
    border-radius: 18px;
    border: 1px solid var(--border);
    margin-bottom: 14px;
}

body.dark .score-wrap { background: linear-gradient(135deg, var(--mint), var(--card)); }

.score-head {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 8px;
}

body.dark .score-head { color: #a8c5e8; }

.score-bar-bg {
    height: 20px;
    border-radius: 999px;
    background: #fff0b3;
    overflow: hidden;
}

body.dark .score-bar-bg { background: #4a3d00; }

.score-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #ff6b6b, #ffd166, #6bcB77);
    border-radius: 999px;
    transition: width 0.35s ease;
}

/* ========================================
   Period Table
   ======================================== */
.table-scroll { overflow-x: auto; }

table { width: 100%; border-collapse: separate; border-spacing: 0 8px; font-size: 0.9rem; }

th {
    background: var(--navy);
    color: #fff;
    padding: 0.7rem 0.75rem;
    text-align: left;
    white-space: nowrap;
}

th:first-child { border-radius: 14px 0 0 14px; }
th:last-child { border-radius: 0 14px 14px 0; }

td {
    background: #fff;
    padding: 0.65rem 0.55rem;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

body.dark td { background: #132033; }

td:first-child { border-left: 1px solid var(--border); border-radius: 14px 0 0 14px; }
td:last-child { border-right: 1px solid var(--border); border-radius: 0 14px 14px 0; }

/* With six expectations the table is wider than an iPad and scrolls inside
   .table-scroll. Pin the Period column so a teacher scrolled to the right can
   still see which row they are rating. th/td already carry opaque backgrounds
   (navy / #fff / dark #132033), which sticky cells need to cover what slides
   beneath them. */
th:first-child, td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
}
td:first-child { box-shadow: 4px 0 6px -4px rgba(24, 49, 83, 0.25); }

.editable { border-radius: 10px; }
.editable:hover { outline: 2px dashed var(--gold); }

/* ========================================
   Rating Buttons
   ======================================== */
.rating-btns { display: flex; gap: 8px; justify-content: center; }

/* 44px is the minimum comfortable touch target; teachers score on iPads and
   hit 30+ of these per day (was 32px — audit U2). touch-action stops the
   double-tap-to-zoom delay so a quick second tap registers as a tap. */
.rating-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: #fff;
    cursor: pointer;
    font-weight: 800;
    font-size: 0.95rem;
    transition: all 0.15s;
    touch-action: manipulation;
    flex-shrink: 0;
}

body.dark .rating-btn { background: #0f1825; color: #eef3fb; }

.rating-btn.sel-0 { background: #7f1d1d; color: #fff; border-color: #7f1d1d; }
.rating-btn.sel-1 { background: #ff6b6b; color: #fff; border-color: #ff6b6b; }
.rating-btn.sel-2 { background: #ffb703; color: #1d2430; border-color: #ffb703; }   /* dark text: white was 1.75:1 */
.rating-btn.sel-3 { background: #6bcb77; color: #1d2430; border-color: #6bcb77; }   /* dark text: white was 2.0:1 */

.del-row {
    background: none;
    border: none;
    color: #9aa7b3;
    font-size: 1rem;
    cursor: pointer;
}

.del-row:hover { color: var(--danger); }

.add-row-btn {
    width: 100%;
    margin-top: 10px;
    border: 2px dashed #bfd2ea;
    background: #f8fbff;
    color: var(--navy);
    padding: 0.8rem;
    border-radius: 18px;
    cursor: pointer;
    font-weight: 800;
}

body.dark .add-row-btn { background: #162540; border-color: #2d4a70; color: #a8c5e8; }

/* ========================================
   Celebrations
   ======================================== */
.celebrations-grid { display: flex; flex-wrap: wrap; gap: 28px; justify-content: center; }

.cel-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 18px;
    border-radius: 20px;
    cursor: default;
    background: #f0f5ff;
    border: 2px solid #cfe0fa;
    transition: all 0.2s;
    min-width: 90px;
    opacity: 0.45;
}

.cel-item.cel-on {
    background: linear-gradient(135deg, #fffbe6, #fff3b0);
    border-color: var(--gold);
    box-shadow: 0 4px 14px rgba(216, 178, 76, 0.35);
    transform: scale(1.07);
    opacity: 1;
}

body.dark .cel-item { background: #162540; border-color: #2d4a70; }
body.dark .cel-item.cel-on { background: linear-gradient(135deg, #3a2e00, #4e3d00); border-color: var(--gold); opacity: 1; }

.cel-emoji { font-size: 2rem; margin-bottom: 6px; }
.cel-label { font-size: 0.8rem; font-weight: 700; color: var(--navy); text-align: center; }
body.dark .cel-label { color: #a8c5e8; }

/* ========================================
   Signatures
   ======================================== */
.sig-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-top: 18px;
}

.sig-line { border-bottom: 2px dashed #9fb1c7; height: 30px; }
.sig-label { font-size: 0.76rem; opacity: 0.7; margin-top: 6px; }

/* ========================================
   Action Buttons
   ======================================== */
.action-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

.btn {
    border: none;
    border-radius: 18px;
    padding: 0.8rem 1.15rem;
    font-weight: 800;
    cursor: pointer;
    font-size: 0.88rem;
    transition: opacity 0.15s;
}

.btn:hover { opacity: 0.88; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Tooltip shown on hover when Send to Parents is disabled */
.send-btn-wrap { position: relative; display: inline-block; }
.send-btn-wrap::after {
    content: 'Save before sending to parents';
    position: absolute;
    bottom: calc(100% + 7px);
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: #fff;
    font-size: 0.72rem;
    padding: 4px 10px;
    border-radius: 5px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.18s;
    z-index: 20;
}
.send-btn-wrap.send-disabled:hover::after { opacity: 1; }

.btn-primary { background: var(--navy); color: #fff; }
.btn-accent { background: var(--gold); color: #1d2430; }
.btn-success { background: var(--success); color: #fff; }
.btn-warn { background: var(--danger); color: #fff; }
.btn-block { display: block; width: 100%; }

/* ========================================
   Archive Table
   ======================================== */
.archive-table { width: 100%; border-collapse: collapse; }
.archive-table th,
.archive-table td { border: 1px solid var(--border); padding: 0.7rem; }
.archive-table th { background: var(--navy); color: #fff; }
body.dark .archive-table td { background: var(--card); }

.archive-table tbody tr { cursor: pointer; transition: background 0.15s; }
.archive-table tbody tr:hover td { background: var(--sky); }
body.dark .archive-table tbody tr:hover td { background: #1e3350; }

.archive-filters {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.archive-filters .form-group { margin: 0; }

/* ========================================
   Badges
   ======================================== */
.badge {
    display: inline-block;
    padding: 0.28rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 800;
}

.badge-green { background: #dff5e5; color: #22663a; }
.badge-amber { background: #fff3d6; color: #9b6500; }
.badge-red { background: #ffe1df; color: #a22c26; }
.badge-role { background: rgba(255,255,255,0.2); color: #fff; font-size: 0.72rem; }

/* ========================================
   Modal
   ======================================== */
#modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

#modal.show { display: flex; }

#modal-box {
    background: var(--card);
    width: min(92vw, 600px);
    max-height: 80vh;
    overflow: auto;
    border-radius: 24px;
    padding: 22px;
    box-shadow: var(--shadow);
    position: relative;
}

#modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text);
}

/* ── Send to Parents confirm modal ── */
#send-confirm-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 200;
    align-items: center;
    justify-content: center;
}
#send-confirm-modal.show { display: flex; }

#send-confirm-box {
    background: var(--card);
    width: min(92vw, 400px);
    border-radius: 24px;
    padding: 32px 28px 28px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.22);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    animation: scaleIn 0.18s ease;
}

@keyframes scaleIn {
    from { transform: scale(0.92); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

.send-confirm-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--navy), var(--blue));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.3rem;
    margin-bottom: 4px;
}

.send-confirm-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--navy);
}

.send-confirm-body {
    margin: 0;
    font-size: 0.88rem;
    color: #4a6785;
    line-height: 1.6;
    max-width: 320px;
}

.send-confirm-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
    width: 100%;
}

.send-confirm-actions button {
    flex: 1;
    padding: 11px 0;
    border-radius: 12px;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: opacity 0.15s;
}
.send-confirm-actions button:hover { opacity: 0.85; }

#send-confirm-ok {
    background: linear-gradient(135deg, var(--navy), var(--blue));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
}

#send-confirm-cancel {
    background: var(--bg);
    color: #6b7c93;
    border: 1.5px solid var(--border) !important;
}

/* ========================================
   Utility
   ======================================== */
.muted { opacity: 0.65; }

.note-input {
    width: 130px;
    padding: 5px 8px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    font-size: 0.82rem;
    background: #fff;
    color: #1f2937;
    font-family: inherit;
}

body.dark .note-input { background: #0f1825; color: #eef3fb; }

.save-state {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.76rem;
    font-weight: 700;
    padding: 5px 11px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    white-space: nowrap;
    line-height: 1;
}
.save-state[hidden] { display: none; }
.save-state::before {
    content: '';
    width: 8px; height: 8px; border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}
.save-state.is-dirty   { background: rgba(216, 178, 76, 0.28); }
.save-state.is-saving  { background: rgba(255, 255, 255, 0.16); }
.save-state.is-saving::before { animation: save-pulse 1s ease-in-out infinite; }
.save-state.is-saved   { background: rgba(45, 143, 78, 0.55); }
.save-state.is-error   { background: var(--danger); cursor: pointer; }
.save-state.is-error:hover { filter: brightness(1.1); }
.save-state.is-offline { background: rgba(31, 41, 55, 0.6); }
@keyframes save-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { .save-state.is-saving::before { animation: none; } }

/* Visually hidden, still read by screen readers (chart data tables, etc.) */
.sr-only {
    position: absolute !important;
    display: block !important;   /* a <table> treats height as a minimum; block makes 1px stick */
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ========================================
   Print
   ======================================== */
#print-header { display: none; }

@media print {
    nav, #day-nav, .action-bar, .add-exp, .add-row-btn, .del-row,
    #toast-container, .archive-filters, #logout-btn { display: none !important; }

    #print-header {
        display: flex !important;
        align-items: center;
        gap: 14px;
        margin-bottom: 16px;
    }

    body { background: #fff; }
    .card { box-shadow: none; }
}

/* ========================================
   Responsive
   ======================================== */
/* iPad portrait (768) and landscape (1024): the identity group and the
   date controls each take a full row instead of sharing one (audit U1). */
@media (max-width: 1100px) {
    #day-nav { flex-wrap: wrap; gap: 8px; row-gap: 6px; }
    #day-nav-left { flex: 1 1 100%; }
    #day-nav-right { flex: 1 1 100%; justify-content: flex-start; }
}

@media (max-width: 640px) {
    nav { padding: 10px 14px; gap: 10px;
         background: linear-gradient(90deg, #ffffff 0, #ffffff 150px, #b9d4ec 48%, var(--blue, #2d5f9a) 78%, var(--navy, #183153) 100%); }
    .nav-logo { height: 38px; }
    .nav-title h1 { font-size: 1.05rem; }
    .school-badge { width: 38px; height: 38px; border-radius: 10px; }
    .badge-initials { font-size: 0.9rem; }
    #day-nav { padding: 10px 14px; flex-wrap: wrap; gap: 8px; }
    #day-nav-left { flex: 1 1 100%; }
    #day-nav-right { flex: 1 1 100%; justify-content: center; }
    #day-nav-left, #day-nav-tags { flex-wrap: wrap; }
    #day-nav-name { font-size: 0.95rem; }
    .day-btn-label { display: none; }
    .day-btn-label { display: none; }
    #main { padding: 12px; }
    .card { padding: 14px; }
    .form-grid { grid-template-columns: 1fr; }
    .sig-grid { grid-template-columns: 1fr; }
}

/* ========================================
   Split Auth Card  (change_password.php)
   ----------------------------------------
   A deliberately horizontal card, so an authenticated task is not mistaken
   for the sign-in screen. Every sign-in and account screen now renders
   through includes/auth_shell.php, which always uses the photo variant below
   — the navy, non-photo brand panel this section originally paired with had
   no remaining consumers and was removed.
   ======================================== */
.auth-split-wrapper {
    width: 100%;
    max-width: 900px;
    padding: 20px;
}

.auth-split {
    display: grid;
    grid-template-columns: 0.85fr 1fr;
    background: var(--card);
    border-radius: 28px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

/* ── Right: the form ───────────────────────────────────────────────────── */
.auth-form-panel {
    padding: 40px 34px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.auth-form-panel .form-group {
    text-align: left;
    margin-bottom: 16px;
}

/* Room for the reveal button inside the field. */
.auth-field {
    position: relative;
}

.auth-field input {
    padding-right: 3rem;
}

.auth-reveal {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
    color: #6b7c93;
    border-radius: 12px;
}

.auth-reveal:hover { color: var(--navy); }

.auth-reveal svg {
    width: 19px;
    height: 19px;
    pointer-events: none;
}

.auth-hint {
    margin: 6px 0 0;
    font-size: 0.76rem;
    line-height: 1.4;
    color: #5f6e84; /* 5.19:1 on white — #6b7c93 measured 4.26 and failed AA */
}

.auth-actions {
    margin-top: 22px;
}

/* The shared .btn is 42px tall; nudge it over the 44px touch minimum here
   rather than changing .btn globally, which every other page depends on. */
.auth-actions .btn {
    min-height: 46px;
}

.auth-cancel {
    display: block;
    margin-top: 4px;
    padding: 14px 8px;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--blue);
    text-decoration: none;
}

.auth-cancel:hover { text-decoration: underline; }

/* Keyboard focus must stay obvious on both panels. */
.auth-split a:focus-visible,
.auth-split button:focus-visible,
.auth-split input:focus-visible {
    outline: 3px solid var(--gold);
    outline-offset: 2px;
}

/* ── Success state ─────────────────────────────────────────────────────── */
.auth-done {
    text-align: center;
}

.auth-done-mark {
    width: 54px;
    height: 54px;
    margin: 0 auto 16px;
    border-radius: 50%;
    background: #dff5e5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-done-mark svg {
    width: 27px;
    height: 27px;
    stroke: var(--success);
}

.auth-done h2 {
    margin: 0 0 8px;
    font-size: 1.15rem;
    color: var(--navy);
}

.auth-done p {
    margin: 0 0 22px;
    font-size: 0.88rem;
    line-height: 1.55;
    color: #5f6e84; /* 5.19:1 on white */
}

/* .btn is written for <button>; as an <a> it keeps the underline and baseline
   alignment of a link, so reset both here. */
.auth-done .btn {
    text-decoration: none;
    text-align: center;
    box-sizing: border-box;
}

/* ── Stacked layout on small screens ───────────────────────────────────── */
@media (max-width: 860px) {
    .auth-split {
        grid-template-columns: 1fr;
        border-radius: 22px;
    }

    .auth-form-panel {
        padding: 26px 24px 30px;
    }
}

body.dark .auth-split { background: #16202e; }
body.dark .auth-form-panel .auth-hint { color: #94a3b8; }
body.dark .auth-done h2 { color: #eef3fb; }

@media (prefers-reduced-motion: reduce) {
    .auth-split *,
    .auth-split *::before,
    .auth-split *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

/* ========================================
   Split Auth Card — photo variant  (staff_invite_accept.php)
   ----------------------------------------
   Mirrors .auth-split: the form takes the left half on plain white, and a
   portrait photograph fills the right. Invited staff arrive here from an email
   with no idea what PulsePoint is, so the picture does the warmth a brand
   panel would elsewhere, and the form stays first in reading order. This is
   now the only variant includes/auth_shell.php renders — every auth screen
   uses it.
   ======================================== */
.auth-split--photo {
    grid-template-columns: 1fr 1fr;
    background: #fff; /* the form half is white regardless of theme */
    /* The short states (activated / expired link) are only a few lines tall;
       without a floor the picture crops down to a letterbox strip. */
    min-height: 430px;
}

/* Guarantees visible page behind the card top and bottom, rather than the card
   running the full height of the viewport. Own class, so change_password.php's
   wrapper keeps its original padding. */
.auth-split-wrapper--photo {
    padding-top: 40px;
    padding-bottom: 40px;
    /* .login-page centres with align-items:center, which clips the TOP of any
       item taller than the viewport — on a short laptop that would put the logo
       and heading out of reach. Auto margins centre the same way but overflow
       downward into a scroll instead. */
    margin: auto;
}

/* Form first in the DOM, so keyboard and screen-reader order match the visual
   order and the fields are what loads above the fold on a phone. */
.auth-split--photo .auth-form-panel {
    padding: 30px 38px;
}

/* Tighter than the 16px the navy-panel variant uses — this form carries more
   above it (logo, heading, intro, email) and the card was outgrowing the
   viewport. */
.auth-split--photo .auth-form-panel .form-group {
    margin-bottom: 12px;
}

.auth-split--photo .auth-actions {
    margin-top: 14px;
}

.auth-split--photo .auth-hint {
    margin-top: 4px;
}

.auth-photo {
    position: relative;
    /* Fills the gap while the photo decodes, and matches its darkest tones. */
    background: var(--navy);
    border-left: 1px solid var(--border);
}

/* The source is a 9:16 portrait; cover-crop it to whatever height the form
   next to it happens to need. Taken out of flow so its own aspect ratio can't
   stretch the card — otherwise the short states get a tall panel of dead white
   beside the picture. */
.auth-photo img {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

/* ── Form-panel header ─────────────────────────────────────────────────── */
.auth-form-head {
    margin-bottom: 18px;
}

/* Logo artwork is navy on white, so it needs no chip on this panel. */
.auth-form-head img {
    display: block;
    width: 100%;
    max-width: 170px;
    height: auto;
    margin-bottom: 14px;
}

.auth-form-head h1 {
    margin: 0 0 6px;
    font-size: 1.35rem;
    line-height: 1.25;
    color: var(--navy);
}

.auth-form-head p {
    margin: 0;
    font-size: 0.88rem;
    line-height: 1.55;
    color: #5f6e84; /* 5.19:1 on white — matches .auth-hint */
}

.auth-form-head p + p {
    margin-top: 10px;
}

.auth-form-head strong {
    color: var(--navy);
}

/* The invitee's login email is the one detail they must carry to the sign-in
   screen, so lift it out of the paragraph flow. */
.auth-identity {
    margin: 14px 0 0;
    padding: 9px 12px;
    background: var(--sky);
    border-radius: 10px;
    font-size: 0.82rem;
    line-height: 1.45;
    color: #5f6e84;
    word-break: break-word;
}

.auth-identity strong {
    display: block;
    margin-top: 2px;
    font-size: 0.88rem;
    color: var(--navy);
}

/* Expired / already-used links reuse the .auth-done layout, but a green tick
   would read as success. */
.auth-done-mark--alert { background: #fdeaea; }
.auth-done-mark--alert svg { stroke: var(--danger); }

/* Secondary links under an auth form — replaces the inline-styled <p> the
   old vertical login card pages used. */
.auth-links {
    margin: 18px 0 0;
    text-align: center;
    font-size: 0.85rem;
}
.auth-links a {
    color: var(--blue);
    font-weight: 600;
    text-decoration: none;
}
.auth-links a:hover { text-decoration: underline; }

/* ── Stacked layout on small screens ───────────────────────────────────── */
@media (max-width: 860px) {
    .auth-split--photo {
        grid-template-columns: 1fr;
    }

    /* A tall portrait below the form would be a dead scroll; crop it to a
       banner above instead, so the fields still start near the top. */
    .auth-photo {
        order: -1;
        height: 150px;
        border-left: none;
        border-bottom: 1px solid var(--border);
    }

    .auth-split--photo .auth-form-panel {
        padding: 26px 24px 30px;
    }
}

@media (max-width: 420px) {
    .auth-photo { height: 112px; }
}

/* The form half stays white in dark mode by design — it is the only surface
   the PulsePoint logo and the photo edge are tuned against. */
body.dark .auth-split--photo,
body.dark .auth-split--photo .auth-form-panel { background: #fff; }
body.dark .auth-split--photo .auth-form-head h1,
body.dark .auth-split--photo .auth-done h2 { color: var(--navy); }
body.dark .auth-split--photo .auth-hint { color: #5f6e84; }

.btn-microsoft {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
    background: #fff;
    color: #3c4043;
    border: 1px solid #8c8c8c;
    border-radius: 6px;
    padding: 11px 16px;
    font-weight: 600;
    text-decoration: none;
    margin-bottom: 4px;
}
.btn-microsoft:hover { background: #f5f5f5; }
.login-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0;
    color: var(--text-muted);
    font-size: 0.8rem;
}
.login-divider::before, .login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border, #e2e8f0);
}
/* ========================================
   Legal pages (privacy.php, terms.php) and the shell's legal links
   ======================================== */
/* Every shell-rendered screen ends with Privacy · Terms. Sits below
   .login-footer-link on login.php, which pulls itself up with a negative
   margin, so this one restores a little space. */
.auth-legal-links {
    margin: 26px 0 0;
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-muted);
}
.auth-legal-links a {
    color: var(--text-muted);
    text-decoration: none;
}
.auth-legal-links a:hover { text-decoration: underline; }

/* One wide white column instead of the form/photo split. */
.auth-split-wrapper--document {
    max-width: 860px;
    padding-top: 40px;
    padding-bottom: 40px;
    margin: auto;
}
.auth-split--document {
    grid-template-columns: 1fr;
    background: #fff;
}
.auth-document-panel {
    padding: 36px 44px 30px;
    justify-content: flex-start;
    /* A grid item's min-width defaults to auto, so the retention table's
       natural width would push the whole card past a phone's viewport. */
    min-width: 0;
    overflow-wrap: anywhere;
}
@media (max-width: 860px) {
    .auth-document-panel { padding: 24px 20px 26px; }
}

.legal-head { margin-bottom: 8px; }
.legal-head img {
    display: block;
    width: 100%;
    max-width: 150px;
    height: auto;
    margin-bottom: 14px;
}
.legal-head h1 {
    margin: 0 0 6px;
    font-size: 1.7rem;
    line-height: 1.2;
    color: var(--navy);
}
.legal-meta {
    margin: 0 0 14px;
    font-size: 0.82rem;
    color: #5f6e84;
}
.legal-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 18px;
    margin: 0 0 22px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}
.legal-actions .btn { padding: 9px 16px; }
.legal-actions a:not(.btn) { color: var(--blue); }

.legal-body { font-size: 0.95rem; line-height: 1.6; color: var(--text); }
.legal-body .legal-intro { font-size: 1.02rem; color: #3b4a5e; }
.legal-body h2 {
    margin: 26px 0 8px;
    font-size: 1.12rem;
    color: var(--navy);
}
.legal-body p { margin: 0 0 10px; }
.legal-body ul { margin: 0 0 12px; padding-left: 22px; }
.legal-body li { margin-bottom: 5px; }
.legal-body a { color: var(--blue); }
.legal-table {
    width: 100%;
    table-layout: fixed;   /* columns share the width and wrap, never overflow */
    border-collapse: collapse;
    margin: 6px 0 14px;
    font-size: 0.86rem;
}
.legal-table th, .legal-table td {
    text-align: left;
    vertical-align: top;
    padding: 8px 10px;
    border: 1px solid var(--border);
}
.legal-table th { background: #f3f6fb; color: var(--navy); font-weight: 600; }
.legal-contact { line-height: 1.7; }

/* Print straight from the browser: white page, no card chrome, no buttons. */
@media print {
    .login-page { background: #fff; display: block; }
    .auth-split-wrapper--document { max-width: none; padding: 0; }
    .auth-split--document { box-shadow: none; border-radius: 0; }
    .auth-document-panel { padding: 0; }
    .legal-actions, .auth-legal-links { display: none !important; }
    .legal-body h2 { page-break-after: avoid; }
    .legal-table tr { page-break-inside: avoid; }
}
