/* Attendance Tracker - shared styles.
   Calm, paper-like look: warm off-white background, white cards, one muted green accent.
   Status colours (red / amber / green) are only used where they carry meaning. */

:root {
    --bg: #F7F5F0;
    --surface: #FFFFFF;
    --surface-alt: #F1EEE7;       /* neutral tint, e.g. lab cells */
    --border: #E2DED5;
    --border-strong: #CFCAC0;
    --text: #2B2B2B;
    --text-muted: #6B6862;

    --accent: #2F5D50;
    --accent-hover: #264C41;
    --accent-soft: #E3EBE7;

    --red: #B4473B;    --red-bg: #F5E3E0;    --red-text: #8A3329;
    --amber: #C08A2E;  --amber-bg: #F6ECD8;  --amber-text: #7A5614;
    --green: #4E7D5B;  --green-bg: #E3EDE5;  --green-text: #365A40;

    --radius: 6px;
    --radius-lg: 8px;
    --shadow: 0 1px 2px rgba(43, 43, 43, 0.04);

    --fs-sm: 13px;
    --fs-base: 15px;
    --fs-lg: 18px;
    --fs-xl: 22px;

    --sidebar-w: 224px;
    --bottom-nav-h: 60px;
    --topbar-h: 48px;
}

* { box-sizing: border-box; }

/* Elements hidden from JavaScript stay hidden even if a class sets "display". */
[hidden] { display: none !important; }

html, body { margin: 0; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: var(--fs-base);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; line-height: 1.3; }
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-base); }

a { color: var(--accent); }

.muted { color: var(--text-muted); }
.nowrap { white-space: nowrap; }
.small { font-size: var(--fs-sm); }
.num { font-variant-numeric: tabular-nums; text-align: right; }

.lucide, [data-lucide] { width: 18px; height: 18px; stroke-width: 1.75; flex-shrink: 0; }

/* ------------------------------------------------------------ app shell */

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 12px;
}

.brand {
    font-weight: 600;
    font-size: var(--fs-base);
    padding: 0 10px 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}
.brand small { display: block; font-weight: 400; color: var(--text-muted); font-size: var(--fs-sm); }

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius);
    color: var(--text);
    text-decoration: none;
    margin-bottom: 2px;
}
.nav-link:hover { background: var(--surface-alt); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }

.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding: 12px 10px 0;
    font-size: var(--fs-sm);
}
.sidebar-footer .user-name { font-weight: 500; }

.main {
    margin-left: var(--sidebar-w);
    padding: 28px 32px 48px;
    max-width: calc(1120px + var(--sidebar-w));
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.page-header p { margin: 2px 0 0; color: var(--text-muted); }

.topbar, .bottom-nav { display: none; }

/* ------------------------------------------------------------ cards, grid */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 16px 18px;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}
.stat .label { font-size: var(--fs-sm); color: var(--text-muted); }
.stat .value { font-size: var(--fs-xl); font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-link { color: inherit; text-decoration: none; }
.stat-link:hover { border-color: var(--border-strong); }

.empty {
    padding: 28px 18px;
    text-align: center;
    color: var(--text-muted);
}

/* ------------------------------------------------------------ forms, buttons */

.field { margin-bottom: 14px; }
.field label { display: block; font-size: var(--fs-sm); font-weight: 500; margin-bottom: 4px; }

.input, select.input {
    width: 100%;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 9px 11px;
}
.input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font: inherit;
    font-weight: 500;
    padding: 9px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { background: var(--surface-alt); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-block { width: 100%; }
.btn-link {
    background: none; border: none; padding: 0; font: inherit;
    color: var(--text-muted); cursor: pointer; text-decoration: underline;
}

.alert {
    border-radius: var(--radius);
    padding: 9px 12px;
    font-size: var(--fs-sm);
    margin-bottom: 14px;
}
.alert-error { background: var(--red-bg); color: var(--red-text); }

/* ------------------------------------------------------------ badges */

.badge {
    display: inline-block;
    font-size: var(--fs-sm);
    font-weight: 500;
    padding: 1px 8px;
    border-radius: 4px;
    background: var(--surface-alt);
    color: var(--text-muted);
    white-space: nowrap;
}
.badge-red { background: var(--red-bg); color: var(--red-text); }
.badge-amber { background: var(--amber-bg); color: var(--amber-text); }
.badge-green { background: var(--green-bg); color: var(--green-text); }

.btn-danger { background: var(--surface); border-color: var(--red); color: var(--red-text); }
.btn-danger:hover { background: var(--red-bg); }
.btn-sm { padding: 5px 10px; font-size: var(--fs-sm); }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: none;
    color: var(--text-muted);
    cursor: pointer;
}
.icon-btn:hover { background: var(--surface-alt); color: var(--text); border-color: var(--border); }
.icon-btn.danger:hover { color: var(--red-text); background: var(--red-bg); }

.input-invalid { border-color: var(--red); }
.field-error { color: var(--red-text); font-size: var(--fs-sm); margin-top: 3px; }
.field-hint { color: var(--text-muted); font-size: var(--fs-sm); margin-top: 3px; }

.check { display: inline-flex; align-items: center; gap: 6px; margin-right: 18px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

/* ------------------------------------------------------------ sections, toolbars */

.section { margin-bottom: 20px; }
.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar .input { width: auto; min-width: 0; }
.back-link {
    display: inline-flex; align-items: center; gap: 4px;
    color: var(--text-muted); text-decoration: none; font-size: var(--fs-sm); margin-bottom: 6px;
}
.back-link:hover { color: var(--text); }

/* ------------------------------------------------------------ register-style tables */

.table-wrap { overflow-x: auto; }
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-base);
}
.table th {
    text-align: left;
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-strong);
    padding: 8px 10px;
    white-space: nowrap;
}
.table td {
    border-bottom: 1px solid var(--border);
    padding: 9px 10px;
    vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: #FBFAF7; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; width: 1%; }
.table .roll { font-variant-numeric: tabular-nums; width: 1%; white-space: nowrap; color: var(--text-muted); }
.card.flush { padding: 0; }
.card.flush .table th:first-child, .card.flush .table td:first-child { padding-left: 18px; }
.card.flush .table th:last-child, .card.flush .table td:last-child { padding-right: 14px; }

.row-error td { background: #FBF3F1; }
.row-error:hover td { background: #FBF3F1; }
.cell-errors { color: var(--red-text); font-size: var(--fs-sm); }
.cell-errors div + div { margin-top: 2px; }

/* batch chips on the class page */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: var(--radius);
    padding: 4px 4px 4px 12px;
}
.chip .chip-name { font-weight: 500; }
.chip .icon-btn { width: 28px; height: 28px; }

/* ------------------------------------------------------------ timetable grid (printed-register look) */

.main-wide { max-width: none; }

.tt-grid {
    width: 100%;
    min-width: 860px;
    border-collapse: collapse;
    table-layout: fixed;
}
.tt-grid th, .tt-grid td {
    border: 1px solid var(--border);
    padding: 6px;
    vertical-align: top;
}
.tt-grid thead th {
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--text-muted);
    text-align: left;
    background: var(--bg);
    padding: 8px;
}
.tt-grid tr > :first-child { border-left: none; }
.tt-grid tr > :last-child { border-right: none; }
.tt-grid thead tr:first-child th { border-top: none; }
.tt-grid tbody tr:last-child td { border-bottom: none; }
.tt-grid .tt-slot { width: 92px; background: var(--bg); font-variant-numeric: tabular-nums; }

.tt-entry {
    display: block;
    width: 100%;
    text-align: left;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 5px 8px;
    margin-bottom: 4px;
    cursor: pointer;
}
.tt-entry:hover { border-color: var(--border-strong); }
.tt-entry.tt-lab { background: var(--surface-alt); }
.tt-title { display: block; font-weight: 500; }
.tt-batch { font-weight: 600; margin-right: 6px; }
.tt-type {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    border: 1px solid var(--border-strong);
    border-radius: 3px;
    padding: 0 4px;
    margin-left: 4px;
    vertical-align: 1px;
}
.tt-meta { display: block; font-size: var(--fs-sm); color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tt-free { font-size: var(--fs-sm); color: var(--text-muted); padding: 4px 8px; margin-bottom: 4px; }
.tt-add {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font: inherit;
    font-size: var(--fs-sm);
    color: var(--text-muted);
    background: none;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    padding: 3px 8px;
    cursor: pointer;
}
.tt-add:hover { color: var(--accent); border-color: var(--accent); }
.tt-add .lucide { width: 14px; height: 14px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ------------------------------------------------------------ status badges, notices */

.badge.status { display: inline-flex; align-items: center; gap: 3px; }
.badge.status .lucide { width: 13px; height: 13px; stroke-width: 2.25; }
.status-cancelled { text-decoration: line-through; }
.alert-info { background: var(--surface-alt); color: var(--text); border: 1px solid var(--border); }

/* ------------------------------------------------------------ "My sessions today" cards */

.session-list { display: flex; flex-direction: column; gap: 8px; }
.session-card {
    display: grid;
    grid-template-columns: 56px 1fr auto;
    gap: 14px;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px 14px;
    color: var(--text);
    text-decoration: none;
    box-shadow: var(--shadow);
}
.session-card:hover { border-color: var(--border-strong); }
.session-card.is-cancelled { opacity: 0.6; }
.session-time { display: flex; flex-direction: column; font-variant-numeric: tabular-nums; line-height: 1.3; }
.session-time span { font-size: var(--fs-sm); color: var(--text-muted); }
.session-title { font-weight: 600; }
.session-meta { font-size: var(--fs-sm); color: var(--text-muted); }
.session-status { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; }

/* ------------------------------------------------------------ class day view (slots x batches) */

.day-toolbar { margin-bottom: 14px; }
.date-nav { display: flex; align-items: center; gap: 4px; }
.date-nav .input { width: auto; }

.day-grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.day-grid th, .day-grid td { border: 1px solid var(--border); padding: 5px; vertical-align: top; }
.day-grid thead th {
    font-size: var(--fs-sm); font-weight: 500; color: var(--text-muted);
    text-align: left; background: var(--bg); padding: 8px;
}
.day-grid tr > :first-child { border-left: none; }
.day-grid tr > :last-child { border-right: none; }
.day-grid thead tr:first-child th { border-top: none; }
.day-grid tbody tr:last-child td { border-bottom: none; }
.day-grid .day-slot { width: 64px; background: var(--bg); font-variant-numeric: tabular-nums; }
.day-grid td.day-slot span { display: block; font-size: var(--fs-sm); color: var(--text-muted); }
.day-cell {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    padding: 6px 8px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    color: var(--text);
    text-decoration: none;
}
.day-cell.is-lab { background: var(--surface-alt); }
.day-cell.is-mine { border-color: var(--border-strong); background: var(--surface); }
.day-cell.is-mine.is-lab { background: var(--surface-alt); }
a.day-cell:hover { border-color: var(--accent); }
.day-cell.is-cancelled { opacity: 0.6; }
.day-subject { font-weight: 600; }
.day-meta { font-size: var(--fs-sm); color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-status { margin-top: 3px; }
.day-cell.is-lab .badge.status:not(.badge-green) { background: var(--surface); }
button.day-cell { width: 100%; font: inherit; text-align: left; cursor: pointer; }
button.day-cell:hover { border-color: var(--accent); }
.day-free { display: block; font-size: var(--fs-sm); color: var(--text-muted); padding: 6px 8px; }

/* ------------------------------------------------------------ marking attendance */

.mark-page { max-width: calc(760px + var(--sidebar-w)); }
.mark-header h1 { font-size: var(--fs-xl); }
.mark-header p { margin: 2px 0 0; }

.mark-summary {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
    background: var(--bg);
    padding: 10px 0;
    font-size: var(--fs-lg);
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
}
.mark-summary .sep { color: var(--text-muted); }
.mark-summary .absent-count { color: var(--red-text); }
.mark-summary .small { margin-left: auto; }

.mark-list {
    list-style: none;
    margin: 0;
    padding: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.mark-list li + li { border-top: 1px solid var(--border); }
.mark-row {
    display: grid;
    grid-template-columns: 44px 1fr auto;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 56px;            /* large, easy to tap on a phone */
    padding: 10px 16px;
    background: var(--surface);
    border: none;
    font: inherit;
    color: var(--text);
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.mark-row:hover { background: #FBFAF7; }
.mark-roll { font-variant-numeric: tabular-nums; color: var(--text-muted); }
.mark-name { min-width: 0; }
.mark-batch { margin-left: 8px; font-size: var(--fs-sm); color: var(--text-muted); }
.mark-state { font-size: var(--fs-sm); color: var(--text-muted); }

.mark-row.is-absent { background: var(--red-bg); box-shadow: inset 4px 0 0 var(--red); }
.mark-row.is-absent:hover { background: var(--red-bg); }
.mark-row.is-absent .mark-roll,
.mark-row.is-absent .mark-name { color: var(--red-text); }
.mark-row.is-absent .mark-state {
    color: #fff;
    background: var(--red);
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
}

.more-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 18px 0; }

.save-bar {
    position: fixed;
    left: var(--sidebar-w);
    right: 0;
    bottom: 0;
    z-index: 20;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 10px 32px;
    background: var(--surface);
    border-top: 1px solid var(--border);
}
.save-bar .btn-primary { min-width: 140px; }
body.has-save-bar .main { padding-bottom: 96px; }

/* ------------------------------------------------------------ tabs and reports */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tab {
    font: inherit;
    font-weight: 500;
    color: var(--text-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 8px 14px;
    margin-bottom: -1px;
    cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.report-toolbar { margin-bottom: 12px; }
.report-facts { margin-bottom: 10px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.report-table th.sortable { cursor: pointer; user-select: none; }
.report-table th.sortable:hover, .report-table th.sorted { color: var(--text); }
.report-table td.below { color: var(--red-text); font-weight: 600; }
.report-table td { white-space: nowrap; }
.report-table td.small { white-space: normal; min-width: 160px; }
.report-table td.note { white-space: nowrap; }

/* ------------------------------------------------------------ class report extras */

.report-table th.group-start, .report-table td.group-start { border-left: 1px solid var(--border); }
.tabs-inline { border-bottom: none; margin-bottom: 0; }
.tabs-inline .tab { border: 1px solid var(--border); border-radius: var(--radius); margin: 0; padding: 6px 12px; }
.tabs-inline .tab.active { border-color: var(--accent); background: var(--accent-soft); }

/* ------------------------------------------------------------ student detail */

.summary-grid { display: grid; grid-template-columns: minmax(200px, 1fr) 2fr; gap: 12px; }
.stat .value.big { font-size: 34px; line-height: 1.1; margin: 4px 0 6px; }
.stat .unit { font-size: var(--fs-lg); color: var(--text-muted); margin-left: 2px; }
.value-line { font-size: var(--fs-lg); margin: 4px 0; }
.advice { margin: 8px 0 0; }
.below-text { color: var(--red-text); font-weight: 600; }
.section-head.pad { padding: 14px 18px 0; }
.card > h2:first-child { margin-bottom: 12px; }
.login-mark { display: block; width: 40px; height: 40px; border-radius: 9px; margin-bottom: 14px; }

.calendar { display: flex; flex-wrap: wrap; gap: 20px; margin-bottom: 8px; }
.cal-month { width: 238px; }
.cal-title { font-weight: 500; margin-bottom: 6px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 32px); gap: 2px; }
.cal-head { font-size: 11px; color: var(--text-muted); text-align: center; }
.cal-day {
    width: 32px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    font: inherit; font-size: var(--fs-sm); font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    border: 1px solid transparent; border-radius: 4px; background: none; padding: 0;
}
button.cal-day { cursor: pointer; color: var(--text); }
button.cal-day:hover { border-color: var(--border-strong); }
.cal-day.empty { visibility: hidden; }
.cal-safe { background: var(--green-bg); color: var(--green-text) !important; }
.cal-risk { background: var(--amber-bg); color: var(--amber-text) !important; }
.cal-low { background: var(--red-bg); color: var(--red-text) !important; font-weight: 600; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 12px; color: var(--text-muted); }
.cal-legend span { display: inline-flex; align-items: center; gap: 5px; }
.cal-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--border); }

.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chart-grid h2 { margin-bottom: 8px; }
.chart-box { position: relative; height: 260px; }

/* ------------------------------------------------------------ teacher dashboard cards */

.dashboard { margin-top: 28px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.class-card h3 { margin-bottom: 2px; }
.class-card .card-meta { font-size: var(--fs-sm); color: var(--text-muted); margin-bottom: 12px; }
.card-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.card-stats .label { font-size: 12px; color: var(--text-muted); }
.card-stats .value { font-size: var(--fs-lg); font-weight: 600; font-variant-numeric: tabular-nums; }
.card-pending { border-top: 1px solid var(--border); padding-top: 8px; font-size: var(--fs-sm); }
.card-pending a { margin-right: 8px; }
.card-links { display: flex; gap: 12px; margin-top: 8px; font-size: var(--fs-sm); }

/* ------------------------------------------------------------ dialogs */

.dialog {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0;
    width: min(440px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    color: var(--text);
    background: var(--surface);
    box-shadow: 0 4px 16px rgba(43, 43, 43, 0.08);
}
.dialog-wide { width: min(820px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(43, 43, 43, 0.28); }
.dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 50px); }
.dialog-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.dialog-body { padding: 16px 18px; overflow-y: auto; }
.dialog-body p { margin: 0; }
.dialog-foot {
    display: flex; justify-content: flex-end; gap: 8px;
    padding: 12px 18px; border-top: 1px solid var(--border);
}

/* ------------------------------------------------------------ notice (toast) */

.notice {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    background: var(--text);
    color: #fff;
    padding: 9px 16px;
    border-radius: var(--radius);
    font-size: var(--fs-sm);
    z-index: 100;
    max-width: calc(100vw - 32px);
}
.notice-error { background: var(--red-text); }

/* ------------------------------------------------------------ upload */

.upload-box {
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    padding: 20px;
    text-align: center;
    background: var(--bg);
}
.upload-box input[type=file] { font: inherit; max-width: 100%; }
.upload-summary { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }

/* ------------------------------------------------------------ login page */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.login-card { width: 100%; max-width: 360px; padding: 28px 26px; }
.login-card h1 { margin-bottom: 2px; }
.login-card .muted { margin: 0 0 22px; }

/* ------------------------------------------------------------ mobile */

@media (max-width: 899px) {
    .sidebar { display: none; }

    .topbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: sticky;
        top: 0;
        z-index: 10;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        height: var(--topbar-h);
        padding: 0 16px;
        font-weight: 600;
    }

    .main {
        margin-left: 0;
        padding: 18px 16px calc(var(--bottom-nav-h) + 24px);
    }

    .bottom-nav {
        display: flex;
        position: fixed;
        inset: auto 0 0 0;
        height: var(--bottom-nav-h);
        background: var(--surface);
        border-top: 1px solid var(--border);
        z-index: 10;
        padding-bottom: env(safe-area-inset-bottom);
    }
    .bottom-nav a {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        font-size: 12px;
        color: var(--text-muted);
        text-decoration: none;
    }
    .bottom-nav a.active { color: var(--accent); font-weight: 500; }
    .notice { bottom: calc(var(--bottom-nav-h) + 16px); }
    .more-menu {
        position: fixed;
        right: 8px;
        bottom: calc(var(--bottom-nav-h) + 8px);
        z-index: 30;
        min-width: 200px;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
        box-shadow: 0 4px 16px rgba(43, 43, 43, 0.08);
        padding: 6px;
    }
    .page-header .toolbar .btn { flex: 1 1 auto; }

    .toolbar { width: 100%; }
    .toolbar .input { flex: 1 1 140px; }
    .table .hide-sm { display: none; }

    .save-bar { left: 0; bottom: var(--bottom-nav-h); padding: 10px 16px; }
    .save-bar .btn { flex: 1; }
    body.has-save-bar .main { padding-bottom: calc(var(--bottom-nav-h) + 90px); }
    body.has-save-bar .notice { bottom: calc(var(--bottom-nav-h) + 76px); }
    .mark-summary { top: var(--topbar-h); }   /* stays below the sticky top bar */

    .session-card { grid-template-columns: 48px 1fr; gap: 10px; }
    .session-status { grid-column: 2; flex-direction: row; align-items: center; gap: 8px; }

    .day-toolbar .input { flex: 1 1 auto; }
    .date-nav { width: 100%; }
    .date-nav .input { flex: 1; }
    .day-grid .day-slot { width: 46px; padding: 5px 4px; }
    .day-cell { padding: 4px 5px; }
    .day-grid th, .day-grid td { padding: 3px; }
    .summary-grid, .chart-grid, .rules-form .form-row { grid-template-columns: 1fr; }
    .cal-month { width: 100%; }
    .cal-grid { grid-template-columns: repeat(7, 1fr); }
    .cal-day { width: 100%; height: 36px; }
    .dialog { max-height: calc(100vh - 24px); }
}
