/* ═══════════════════════════════════════════════════════════════════════════
   Design Tokens & CSS Custom Properties
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
    /* ── Color Palette ─────────────────────────────────────────────── */
    --gray-50:  #f8fafc;
    --gray-75:  #f5f7fb;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    --blue-50:  #eff6ff;
    --blue-100: #dbeafe;
    --blue-200: #bfdbfe;
    --blue-300: #93c5fd;
    --blue-500: #3b82f6;
    --blue-600: #2563eb;
    --blue-700: #1d4ed8;
    --blue-800: #1e40af;

    --violet-50:  #f5f3ff;
    --violet-100: #ede9fe;
    --violet-200: #ddd6fe;
    --violet-500: #8b5cf6;
    --violet-600: #7c3aed;
    --violet-700: #6d28d9;
    --violet-800: #5b21b6;

    --green-50:  #f0fdf4;
    --green-100: #dcfce7;
    --green-200: #bbf7d0;
    --green-300: #a7f3d0;
    --green-400: #4ade80;
    --green-500: #22c55e;
    --green-600: #16a34a;
    --green-700: #047857;

    --red-50:  #fef2f2;
    --red-100: #fee2e2;
    --red-200: #fecaca;
    --red-300: #fca5a5;
    --red-500: #ef4444;
    --red-600: #dc2626;

    --amber-50:  #fffbeb;
    --amber-100: #fef3c7;
    --amber-200: #fde68a;
    --amber-400: #f59e0b;
    --amber-600: #d97706;
    --amber-700: #b45309;

    --orange-50:  #fff7ed;
    --orange-100: #ffedd5;
    --orange-200: #fed7aa;
    --orange-500: #f97316;

    --indigo-50:  #eef2ff;
    --indigo-100: #e0e7ff;
    --indigo-200: #c7d2fe;
    --indigo-500: #6366f1;
    --indigo-700: #4338ca;
    --indigo-800: #3730a3;

    /* ── Semantic Tokens ──────────────────────────────────────────── */
    --bg:        var(--gray-75);
    --surface:   #ffffff;
    --line:      #d9e2ec;
    --text:      var(--gray-900);
    --text-heading: var(--gray-800);
    --muted:     var(--gray-500);

    --primary:       var(--blue-600);
    --primary-dark:  var(--blue-700);
    --primary-soft:  var(--blue-50);
    --primary-border: var(--blue-200);

    --success:       var(--green-600);
    --success-soft:  var(--green-50);
    --success-border: var(--green-200);

    --danger:        var(--red-600);
    --danger-soft:   var(--red-50);
    --danger-border: var(--red-200);

    --warning:       var(--amber-700);
    --warning-soft:  var(--amber-50);
    --warning-border: var(--amber-200);

    --occupied-bg:   var(--blue-50);
    --free-bg:       var(--green-50);

    /* ── Spacing Scale ────────────────────────────────────────────── */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;

    /* ── Radius ───────────────────────────────────────────────────── */
    --radius-sm:  6px;
    --radius-md:  8px;
    --radius-lg:  12px;
    --radius-xl:  16px;
    --radius-full: 999px;

    /* ── Shadows ──────────────────────────────────────────────────── */
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 2px 10px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.16);
    --shadow-xl: 0 24px 80px rgba(15, 23, 42, 0.25);

    /* ── Typography ───────────────────────────────────────────────── */
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;

    /* ── Transitions ──────────────────────────────────────────────── */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;

    /* ── Layout ───────────────────────────────────────────────────── */
    --sidebar-width: 228px;
    --header-height: 58px;
}


/* ═══════════════════════════════════════════════════════════════════════════
   Reset & Base
   ═══════════════════════════════════════════════════════════════════════════ */

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; }

img, svg { display: block; max-width: 100%; }

/* ═══════════════════════════════════════════════════════════════════════════
   Accessibility
   ═══════════════════════════════════════════════════════════════════════════ */

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

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

/* ═══════════════════════════════════════════════════════════════════════════
   Shared: Topbar & Shell
   ═══════════════════════════════════════════════════════════════════════════ */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-6);
    padding: var(--space-6) var(--space-10);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.topbar h1,
.login-panel h1 {
    margin: var(--space-1) 0 0;
    font-size: 28px;
    font-weight: 700;
}

.eyebrow {
    margin: 0;
    color: var(--primary);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.userbar {
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--muted);
    font-size: 14px;
}

.userbar a {
    color: var(--primary);
    text-decoration: none;
}

.userbar a:hover { text-decoration: underline; }

.shell {
    width: min(1440px, calc(100% - var(--space-8)));
    margin: var(--space-6) auto var(--space-12);
}


/* ═══════════════════════════════════════════════════════════════════════════
   Shared: Panel
   ═══════════════════════════════════════════════════════════════════════════ */

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 22px;
    margin-bottom: var(--space-5);
}

.panel-title {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: 18px;
}

.panel-title h2 {
    margin: 0;
    font-size: 20px;
    color: var(--text-heading);
}

.panel-title p,
.login-note {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 14px;
}


/* ═══════════════════════════════════════════════════════════════════════════
   Shared: Buttons
   ═══════════════════════════════════════════════════════════════════════════ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 var(--space-4);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    font-weight: 650;
    text-decoration: none;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: background var(--transition-fast),
                border-color var(--transition-fast),
                color var(--transition-fast),
                box-shadow var(--transition-fast);
}

.btn:hover {
    border-color: var(--gray-300);
    background: var(--gray-50);
}

.btn:active {
    transform: scale(0.98);
}

.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.btn.primary {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

.btn.primary:hover {
    border-color: var(--primary-dark);
    background: var(--primary-dark);
    box-shadow: var(--shadow-xs);
}

.btn.success {
    border-color: var(--success);
    background: var(--success);
    color: #fff;
}

.btn.success:hover {
    filter: brightness(1.1);
}

.btn.danger {
    border-color: var(--danger-border);
    background: var(--danger-soft);
    color: var(--danger);
}

.btn.danger:hover {
    background: var(--red-100);
    border-color: var(--danger);
}

.btn.small {
    min-height: 32px;
    padding: 0 10px;
    font-size: 13px;
}

.btn.wide { width: 100%; }

.hero-action {
    min-width: 180px;
    height: 46px;
}


/* ═══════════════════════════════════════════════════════════════════════════
   Shared: Forms
   ═══════════════════════════════════════════════════════════════════════════ */

form, .login-form {
    display: grid;
    gap: 14px;
}

label {
    display: grid;
    gap: 7px;
    color: var(--text);
    font-size: 14px;
    font-weight: 650;
}

input, select {
    width: 100%;
    height: 40px;
    padding: 0 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    color: var(--text);
    font: inherit;
    font-weight: 400;
    background: var(--surface);
    transition: border-color var(--transition-fast),
                box-shadow var(--transition-fast);
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

input::placeholder { color: var(--gray-400); }

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
}

.inline-check {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-height: 40px;
}

.inline-check input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}


/* ═══════════════════════════════════════════════════════════════════════════
   Shared: Tables
   ═══════════════════════════════════════════════════════════════════════════ */

.schedule-table {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
}

.schedule-table.is-drag-scrolling,
.admin-table.is-drag-scrolling,
.m-table-scroll.is-drag-scrolling {
    cursor: grabbing;
    user-select: none;
}

table {
    width: 100%;
    min-width: 1080px;
    border-collapse: collapse;
    background: var(--surface);
}

th, td {
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

th:last-child, td:last-child { border-right: 0; }
tr:last-child td { border-bottom: 0; }

th {
    position: sticky;
    top: 0;
    z-index: 2;
    height: 44px;
    background: var(--gray-900);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
}

tbody tr:hover td {
    background: rgba(37, 99, 235, 0.025);
}

td {
    min-width: 130px;
    height: 112px;
    padding: 10px;
    vertical-align: top;
    font-size: 14px;
    transition: background var(--transition-fast);
}

.time-slot {
    width: 120px;
    min-width: 120px;
    background: var(--gray-50);
    color: var(--text);
}

.time-slot strong,
.time-slot span { display: block; }

.time-slot span {
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
}


/* ═══════════════════════════════════════════════════════════════════════════
   Shared: Status Message
   ═══════════════════════════════════════════════════════════════════════════ */

.status-message {
    display: none;
    margin-bottom: 18px;
    padding: var(--space-3) 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
    font-size: 14px;
    line-height: 1.5;
}

.status-message.success {
    display: block;
    background: var(--success-soft);
    border-color: var(--success-border);
    color: var(--green-700);
}

.status-message.error {
    display: block;
    background: var(--danger-soft);
    border-color: var(--danger-border);
    color: var(--danger);
}

.status-message.warning {
    display: block;
    background: var(--warning-soft);
    border-color: var(--warning-border);
    color: var(--warning);
}

.status-message.info {
    display: block;
    background: var(--primary-soft);
    border-color: var(--primary-border);
    color: var(--primary-dark);
}


/* ═══════════════════════════════════════════════════════════════════════════
   Shared: Toast (floating notification)
   ═══════════════════════════════════════════════════════════════════════════ */

.toast-container {
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    max-width: 420px;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    line-height: 1.5;
    animation: toast-slide-in var(--transition-normal) ease;
    cursor: default;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info    { border-left: 3px solid var(--primary); }

.toast-dismiss {
    flex-shrink: 0;
    margin-left: auto;
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 0 2px;
}

.toast-dismiss:hover { color: var(--text); }

@keyframes toast-slide-in {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}

@keyframes toast-fade-out {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(100%); }
}

.toast.removing {
    animation: toast-fade-out var(--transition-fast) ease forwards;
}


/* ═══════════════════════════════════════════════════════════════════════════
   Shared: Skeleton Loading
   ═══════════════════════════════════════════════════════════════════════════ */

.skeleton {
    background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-50) 50%, var(--gray-100) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

.skeleton-text {
    height: 14px;
    width: 100%;
    margin-bottom: var(--space-2);
}

.skeleton-text:last-child { width: 60%; }

.skeleton-heading {
    height: 20px;
    width: 40%;
    margin-bottom: var(--space-3);
}

.skeleton-cell {
    height: 40px;
    border-radius: var(--radius-sm);
}

@keyframes skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}


/* ═══════════════════════════════════════════════════════════════════════════
   Shared: Pills & Badges
   ═══════════════════════════════════════════════════════════════════════════ */

.pill {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 9px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 700;
}

.pill.success { background: var(--success-soft); color: var(--green-700); }
.pill.muted   { background: var(--gray-100);   color: var(--muted); }
.pill.warning { background: var(--warning-soft); color: var(--warning); }


/* ═══════════════════════════════════════════════════════════════════════════
   Student Page: Stats Row
   ═══════════════════════════════════════════════════════════════════════════ */

.stats-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: var(--space-5);
}

.stat-card {
    padding: 18px var(--space-5);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

.stat-card strong {
    display: block;
    margin-top: var(--space-2);
    font-size: 30px;
    line-height: 1;
    color: var(--text-heading);
}


/* ═══════════════════════════════════════════════════════════════════════════
   Student Page: Scanner
   ═══════════════════════════════════════════════════════════════════════════ */

.scanner-panel {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto;
    align-items: center;
    gap: 18px;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.actions.compact { justify-content: flex-end; }


/* ═══════════════════════════════════════════════════════════════════════════
   Student Page: Week Controls
   ═══════════════════════════════════════════════════════════════════════════ */

.week-panel .panel-title { align-items: center; }

.week-controls {
    display: grid;
    grid-template-columns: minmax(180px, 220px) auto minmax(220px, 300px);
    align-items: end;
    gap: var(--space-3);
}

.week-controls.single-control { grid-template-columns: minmax(220px, 320px); }
.week-controls.assignment-controls { grid-template-columns: minmax(220px, 300px) auto; }

.setting-hint {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    padding: 0 var(--space-3);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--gray-50);
    color: var(--muted);
    font-size: 14px;
    font-weight: 650;
}


/* ═══════════════════════════════════════════════════════════════════════════
   Student Page: Course Cells
   ═══════════════════════════════════════════════════════════════════════════ */

.course-cell.free-time { background: var(--free-bg); }
.course-cell.occupied  { background: var(--occupied-bg); }

.course-info {
    display: grid;
    gap: var(--space-1);
    padding: var(--space-2);
    border-left: 3px solid var(--primary);
    background: rgba(255, 255, 255, 0.72);
    border-radius: var(--radius-sm);
}

.course-info + .course-info { margin-top: var(--space-2); }

.course-info strong { line-height: 1.35; }

.course-info small {
    color: var(--muted);
    line-height: 1.35;
}

.free-slot, .empty-slot {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--green-700);
    font-weight: 700;
}

.empty-slot {
    color: var(--muted);
    font-weight: 500;
}


/* ═══════════════════════════════════════════════════════════════════════════
   Student Page: Assignment Table
   ═══════════════════════════════════════════════════════════════════════════ */

.assignment-table td { height: 104px; }

.assignment-cell.assigned { background: var(--green-50); }
.assignment-cell.lottery  { background: var(--orange-50); }
.assignment-cell.manual   { background: var(--indigo-50); }

.assignment-info {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 72px;
    padding: 10px;
    border-left: 3px solid var(--success);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.74);
    text-align: center;
}

.assignment-cell.lottery .assignment-info { border-left-color: var(--warning); }

.assignment-info strong {
    line-height: 1.3;
    font-size: 16px;
}

.assignment-summary {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    padding: 0 11px;
    border: 1px solid var(--primary-border);
    border-radius: var(--radius-md);
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}


/* ═══════════════════════════════════════════════════════════════════════════
   Student Page: Free Times & Modal
   ═══════════════════════════════════════════════════════════════════════════ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--space-3);
}

.free-time-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: 14px;
    border: 1px solid var(--success-border);
    border-radius: var(--radius-md);
    background: var(--success-soft);
}

.free-time-card span {
    color: var(--green-700);
    font-size: 13px;
}

.time-list {
    display: grid;
    gap: var(--space-2);
    max-height: 420px;
    overflow: auto;
    margin-bottom: 14px;
}

.time-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: 10px var(--space-3);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
}

.empty-message {
    margin: 0 0 14px;
    color: var(--muted);
    font-size: 14px;
}


/* ═══════════════════════════════════════════════════════════════════════════
   Student Page: Work Hours & Submissions
   ═══════════════════════════════════════════════════════════════════════════ */

.hours-inline-edit-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.hours-inline-edit {
    min-width: 78px;
    padding: 6px 10px;
    border: 1px solid transparent;
    border-radius: var(--radius-full);
    background: var(--gray-50);
    color: inherit;
    cursor: pointer;
    font: inherit;
    text-align: center;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.hours-inline-edit:hover {
    border-color: var(--line);
    background: var(--surface);
}

.assignment-hours span {
    display: block;
    color: var(--muted);
    font-size: 11px;
}

.assignment-hours strong {
    display: block;
    color: var(--text);
    font-size: 16px;
}

.assignment-hours-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    margin: 7px auto 0;
    padding: 2px var(--space-2);
    border: 1px solid var(--indigo-200);
    border-radius: var(--radius-full);
    background: var(--indigo-50);
    color: var(--indigo-800);
    cursor: default;
}

.assignment-hours-chip span,
.assignment-hours-chip strong {
    display: inline;
    color: inherit;
    font-size: 11px;
    line-height: 1;
}

.assignment-hours-chip strong {
    font-size: 12px;
    font-weight: 800;
}


/* ═══════════════════════════════════════════════════════════════════════════
   Student Page: Modal (old-style)
   ═══════════════════════════════════════════════════════════════════════════ */

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(15, 23, 42, 0.42);
}

.modal-content {
    width: min(520px, 100%);
    max-height: min(760px, calc(100vh - 36px));
    overflow: auto;
    padding: var(--space-6);
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
}

.modal-large  { width: min(760px, 100%); }
.modal-browser { width: min(860px, 100%); }

.modal-content h2 { margin: 0 42px 18px 0; }

.close {
    float: right;
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.close:hover {
    background: var(--gray-100);
    color: var(--text);
}


/* ═══════════════════════════════════════════════════════════════════════════
   Student Page: Browser Helper Modal
   ═══════════════════════════════════════════════════════════════════════════ */

.browser-address {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: end;
    gap: var(--space-3);
    margin-bottom: 14px;
}

.browser-message {
    padding: 14px;
    border-radius: var(--radius-md);
    background: var(--indigo-50);
    color: var(--gray-700);
    line-height: 1.6;
}

.browser-placeholder {
    display: grid;
    place-items: center;
    gap: 10px;
    min-height: 260px;
    margin: var(--space-4) 0;
    padding: 28px;
    border: 1px dashed var(--gray-300);
    border-radius: var(--radius-md);
    background: var(--gray-50);
    text-align: center;
}

.browser-placeholder strong { font-size: 20px; }

.browser-placeholder span {
    max-width: 560px;
    color: var(--muted);
    line-height: 1.7;
}

.portal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
}


/* ═══════════════════════════════════════════════════════════════════════════
   Login Page
   ═══════════════════════════════════════════════════════════════════════════ */

.login-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: var(--space-6);
    background: var(--bg);
}

.login-panel {
    width: min(420px, 100%);
    padding: 30px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

.login-form { margin-top: 22px; }

.small-note { font-size: 12px; color: var(--muted); }


/* ═══════════════════════════════════════════════════════════════════════════
   Admin: Layout Shell
   ═══════════════════════════════════════════════════════════════════════════ */

.admin-dashboard-page { background: #eef3f8; }

.admin-app {
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.admin-side {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 0;
    background: var(--surface);
    border-right: 1px solid var(--gray-200);
    overflow-y: auto;
}

.side-brand {
    height: var(--header-height);
    display: grid;
    align-content: center;
    gap: 3px;
    padding: 0 18px;
    border-bottom: 1px solid var(--gray-100);
}

.side-brand strong { font-size: 15px; }

.side-brand span {
    color: var(--muted);
    font-size: 12px;
}

.side-menu { padding: 14px 0; }

.side-section { margin-bottom: 14px; }

.side-section p {
    margin: 0 18px 6px;
    color: var(--gray-400);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.05em;
}

.side-link {
    position: relative;
    display: block;
    padding: 10px 18px;
    color: var(--gray-600);
    font-size: 14px;
    text-decoration: none;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.side-link:hover,
.side-link.active {
    background: var(--violet-50);
    color: var(--violet-800);
    font-weight: 800;
}

.side-link.active::after {
    content: "";
    position: absolute;
    right: 0;
    top: var(--space-2);
    bottom: var(--space-2);
    width: 3px;
    border-radius: var(--radius-full) 0 0 var(--radius-full);
    background: var(--violet-600);
}

.admin-main { min-width: 0; }

.admin-header {
    position: sticky;
    top: 0;
    z-index: 20;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-5);
    padding: 0 18px;
    background: var(--surface);
    border-bottom: 1px solid var(--gray-200);
}

.admin-header h1 {
    margin: 2px 0 0;
    font-size: 16px;
    font-weight: 800;
}

.breadcrumb {
    color: var(--muted);
    font-size: 12px;
}

.admin-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-user {
    color: var(--gray-700);
    font-size: 13px;
    font-weight: 700;
}

.admin-canvas { padding: var(--space-3) 14px var(--space-8); }

.admin-view { display: none; }
.admin-view.active { display: block; }


/* ═══════════════════════════════════════════════════════════════════════════
   Admin: Page Tabs
   ═══════════════════════════════════════════════════════════════════════════ */

.page-tabs {
    height: 32px;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
}

.page-tab {
    min-height: 24px;
    display: inline-flex;
    align-items: center;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--muted);
    font-size: 12px;
    text-decoration: none;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.page-tab.active {
    background: var(--violet-700);
    color: #fff;
}

.page-tab:hover:not(.active) {
    background: var(--gray-100);
}


/* ═══════════════════════════════════════════════════════════════════════════
   Admin: Dashboard / Overview
   ═══════════════════════════════════════════════════════════════════════════ */

.dashboard-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.metric-card {
    min-height: 94px;
    padding: var(--space-4) 18px;
    border: 1px solid #e8edf3;
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-fast);
}

.metric-card:hover { box-shadow: var(--shadow-md); }

.metric-card span,
.metric-card small {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.metric-card strong {
    display: block;
    margin: var(--space-2) 0 6px;
    color: var(--gray-800);
    font-size: 24px;
    line-height: 1;
}

.dashboard-grid { display: grid; gap: 10px; }

.compact-grid {
    grid-template-columns: minmax(280px, 0.85fr) minmax(420px, 1.15fr);
}

.dashboard-panel {
    margin-bottom: 10px;
    border-color: #e8edf3;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-xs);
}

.dashboard-section { margin-bottom: var(--space-3); }

.dashboard-form {
    grid-template-columns: minmax(180px, 240px) auto minmax(140px, 1fr);
}

.dashboard-account-form {
    grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
    gap: 10px;
}

.dashboard-account-form label:nth-child(3) { grid-column: span 2; }

.mini-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.mini-metrics div {
    min-height: 86px;
    display: grid;
    align-content: center;
    gap: var(--space-2);
    padding: 14px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    background: var(--gray-50);
}

.mini-metrics span {
    color: var(--muted);
    font-size: 12px;
}

.mini-metrics strong {
    color: var(--gray-800);
    font-size: 26px;
    line-height: 1;
}


/* ═══════════════════════════════════════════════════════════════════════════
   Admin: Overview Charts
   ═══════════════════════════════════════════════════════════════════════════ */

.overview-charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
}

.chart-panel { margin-bottom: 0; }
.chart-panel-wide { grid-column: 1 / -1; }

.chart-container {
    position: relative;
    width: 100%;
    height: 260px;
}

.chart-container-square {
    max-width: 340px;
    margin: 0 auto;
}

.chart-container-heatmap { height: 300px; }

.chart-empty {
    min-height: 120px;
    display: grid;
    place-items: center;
    color: var(--muted);
    font-size: 14px;
}

.chart-empty[hidden] { display: none !important; }

.coverage-unassigned { padding: var(--space-2) var(--space-3) var(--space-1); }

.coverage-unassigned-label {
    font-size: 12px;
    color: var(--muted);
    margin-right: var(--space-1);
}

.coverage-unassigned-tag {
    display: inline-block;
    padding: 3px var(--space-2);
    margin: 0 var(--space-1) 6px 0;
    font-size: 12px;
    color: var(--warning);
    background: var(--warning-soft);
    border-radius: var(--radius-sm);
}


/* ═══════════════════════════════════════════════════════════════════════════
   Admin: Work Assignment Table
   ═══════════════════════════════════════════════════════════════════════════ */

.admin-assignment-table td { height: 96px; }

.admin-edit-cell { vertical-align: middle; }

.assignment-select { height: 36px; font-size: 13px; }

.assignment-preview {
    margin-top: 7px;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}

.free-check-panel {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 14px;
    padding: var(--space-3);
    border: 1px dashed var(--line);
    border-radius: var(--radius-md);
    background: var(--gray-50);
}

.free-result {
    flex: 1;
    min-width: 260px;
    color: var(--muted);
    font-size: 14px;
}

.admin-edit-cell.selected-free-check {
    outline: 3px solid var(--primary);
    outline-offset: -3px;
    background: var(--primary-soft);
}


/* ═══════════════════════════════════════════════════════════════════════════
   Admin: Table (data tables)
   ═══════════════════════════════════════════════════════════════════════════ */

.admin-table {
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    overflow: hidden;
}

/* 学生列表表格允许操作菜单溢出 */
#studentListPanel .admin-table {
    overflow: visible;
}

.admin-table table { min-width: 780px; }

.admin-table td {
    height: auto;
    min-width: 80px;
    padding: 10px 14px;
    vertical-align: middle;
    overflow: visible;
}

.admin-table tbody, .admin-table tr { overflow: visible; }

.admin-shell table { min-width: 1180px; }

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.admin-note {
    max-width: 340px;
    color: var(--gray-600);
    line-height: 1.6;
}

.muted-text { color: var(--muted); font-size: 13px; }

.cleaning-task-board {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.cleaning-task-card {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fff;
}

.cleaning-task-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.cleaning-task-head strong {
    display: block;
    font-size: 14px;
    line-height: 1.45;
}

.cleaning-task-head > div:first-child span,
.cleaning-assignee-preview {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.cleaning-chip-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.cleaning-chip-grid.compact { gap: 6px; }

.cleaning-chip {
    min-height: 30px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #f8fafc;
    color: var(--gray-700);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}

.cleaning-chip.is-active {
    border-color: rgba(15, 159, 110, 0.38);
    background: var(--green-50);
    color: var(--success);
    font-weight: 650;
}

.cleaning-empty-chip.is-active {
    border-color: var(--gray-300);
    background: var(--gray-100);
    color: var(--muted);
}

.cleaning-area-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.cleaning-area-card {
    padding: 10px;
    border: 1px dashed var(--line);
    border-radius: var(--radius-sm);
    background: #fbfdff;
}

.cleaning-area-title {
    margin-bottom: 8px;
    color: var(--gray-800);
    font-size: 13px;
    font-weight: 700;
}

.admin-list-tools { width: min(280px, 100%); }

.admin-list-tools input { height: 38px; }


/* ═══════════════════════════════════════════════════════════════════════════
   Admin: Custom Arrangement Table
   ═══════════════════════════════════════════════════════════════════════════ */

.custom-arr-table table { min-width: 680px; }

.custom-arr-table td { padding: var(--space-3) 14px; vertical-align: middle; }

.custom-arr-table th { font-size: 13px; font-weight: 600; }

.arr-title-cell strong { display: block; font-size: 14px; line-height: 1.4; }

.arr-desc {
    display: block;
    margin-top: var(--space-1);
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
    font-weight: 400;
}

.arr-time-cell { white-space: nowrap; }

.arr-time-detail {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 400;
}


/* ═══════════════════════════════════════════════════════════════════════════
   Admin: Student Action Menu (popover)
   ═══════════════════════════════════════════════════════════════════════════ */

.student-action-wrap {
    position: relative;
    display: inline-flex;
    justify-content: flex-end;
    width: 38px;
}

.student-action-toggle {
    width: 38px;
    height: 38px;
    padding: 0;
    font-size: 22px;
    line-height: 1;
}

.hours-popover,
.student-action-menu,
.assignment-hour-popover {
    position: absolute;
    z-index: 200;
    display: none;
    flex-direction: column;
    gap: 6px;
    min-width: 150px;
    padding: var(--space-2);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

.hours-popover.is-open:not([hidden]),
.student-action-menu.is-open:not([hidden]),
.assignment-hour-popover.is-open:not([hidden]) { display: flex; }

.hours-popover[hidden],
.student-action-menu[hidden],
.assignment-hour-popover[hidden] { display: none !important; }

.hours-popover { left: 0; top: calc(100% + 6px); min-width: 120px; }

.hours-popover button,
.student-action-menu button,
.student-action-menu a,
.assignment-hour-popover button { justify-content: flex-start; }

.student-action-menu { right: 0; top: calc(100% + var(--space-2)); min-width: 180px; }

.hour-edit-trigger {
    width: 100%;
    margin-top: var(--space-2);
    padding: var(--space-2) 10px;
    cursor: pointer;
    text-align: center;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
}


/* ═══════════════════════════════════════════════════════════════════════════
   Admin: Form Layouts
   ═══════════════════════════════════════════════════════════════════════════ */

.admin-form-row,
.admin-account-form {
    display: grid;
    grid-template-columns: minmax(180px, 240px) auto 1fr;
    align-items: end;
    gap: var(--space-3);
}

.admin-account-form {
    grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) minmax(180px, 1fr) auto auto;
}


/* ═══════════════════════════════════════════════════════════════════════════
   Admin: Hours Log Table
   ═══════════════════════════════════════════════════════════════════════════ */

.hours-log-table { font-size: 13px; }

.hours-log-table th {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    background: var(--gray-50);
}

.hours-log-table td { padding: 6px 10px; }

.text-success { color: var(--success); font-weight: 600; }
.text-danger  { color: var(--danger);  font-weight: 600; }


/* ═══════════════════════════════════════════════════════════════════════════
   Admin: Legacy Nav (alternative layout)
   ═══════════════════════════════════════════════════════════════════════════ */

.admin-layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    align-items: start;
    gap: 18px;
}

.admin-nav {
    position: sticky;
    top: 18px;
    display: grid;
    gap: var(--space-2);
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
}

.admin-nav-item {
    display: grid;
    gap: var(--space-1);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    color: var(--text);
    text-decoration: none;
    transition: background var(--transition-fast);
}

.admin-nav-item:hover { background: var(--gray-50); }

.admin-nav-item span { font-size: 14px; font-weight: 800; }

.admin-nav-item small {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
}

.admin-content { min-width: 0; }
.admin-category { scroll-margin-top: 18px; margin-bottom: var(--space-6); }

.category-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 10px;
    padding: 0 2px;
}

.category-title span {
    color: var(--primary);
    font-size: 13px;
    font-weight: 800;
}

.category-title strong {
    color: var(--gray-700);
    font-size: 14px;
}


/* ═══════════════════════════════════════════════════════════════════════════
   Modal Overlay (new-style for admin)
   ═══════════════════════════════════════════════════════════════════════════ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modal-fade-in 0.2s ease;
}

.modal-overlay[hidden] { display: none !important; }

.modal-field[hidden] { display: none !important; }

@keyframes modal-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal-dialog {
    background: var(--surface);
    border-radius: var(--radius-xl);
    max-width: 560px;
    width: 92%;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
    animation: modal-slide-up 0.25s ease;
    overflow: hidden;
}

@keyframes modal-slide-up {
    from { transform: translateY(24px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--line);
    background: var(--bg);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--muted);
    cursor: pointer;
    padding: 2px var(--space-2);
    border-radius: var(--radius-sm);
    line-height: 1;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.modal-close-btn:hover {
    background: var(--line);
    color: var(--text);
}

.modal-body {
    padding: var(--space-6);
    overflow-y: auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px var(--space-3);
}

.modal-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.modal-field.span-2 { grid-column: span 2; }

.modal-sub-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: var(--space-3);
}

.modal-sub-row .modal-field { gap: 6px; }

.modal-field label {
    font-size: 0.82rem;
    color: var(--muted);
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1.4;
    min-height: 1.15em;
}

.modal-field input.field-error,
.modal-field select.field-error {
    border-color: var(--danger) !important;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1) !important;
}

.modal-field input,
.modal-field select {
    font-size: 0.88rem;
    padding: 9px var(--space-3);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--bg);
    color: var(--text);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    width: 100%;
    box-sizing: border-box;
}

.modal-field input:focus,
.modal-field select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.modal-field select[multiple] { min-height: 80px; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--line);
    background: var(--bg);
}


/* ═══════════════════════════════════════════════════════════════════════════
   Push Manager
   ═══════════════════════════════════════════════════════════════════════════ */

.push-status-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
}

.push-status-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: var(--space-4);
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--bg);
}

.push-status-label {
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 600;
}

.push-status-value {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text);
}


/* ═══════════════════════════════════════════════════════════════════════════
   Approval: Inline Edit
   ═══════════════════════════════════════════════════════════════════════════ */

.approval-row {
    cursor: pointer;
    transition: background var(--transition-fast);
}

.approval-row.row-selected {
    background: var(--primary-soft) !important;
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.editable-cell {
    display: inline-block;
    min-width: 52px;
    padding: 3px var(--space-2);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--gray-900);
    font-weight: 700;
    cursor: cell;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.editable-cell:hover {
    border-color: var(--gray-300);
    background: var(--gray-50);
}

.editable-note {
    min-width: 80px;
    max-width: 240px;
    font-weight: 500;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.editable-input {
    height: 28px;
    padding: 0 6px;
    border: 2px solid var(--primary);
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}


/* ═══════════════════════════════════════════════════════════════════════════
   Responsive: Tablet / Mobile (< 900px)
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 900px) {
    .admin-dashboard-page { overflow-x: hidden; }

    .admin-app {
        display: block;
        width: 100%;
        max-width: 100vw;
    }

    .admin-side,
    .admin-header {
        position: static;
        height: auto;
    }

    .admin-side {
        border-right: 0;
        border-bottom: 1px solid var(--gray-200);
        overflow: visible;
    }

    .side-brand {
        height: auto;
        padding: 12px 14px 8px;
    }

    .side-menu {
        display: flex;
        gap: 8px;
        padding: 8px 12px 12px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .side-menu::-webkit-scrollbar { display: none; }

    .side-section {
        flex: 0 0 auto;
        margin: 0;
    }

    .side-section p { display: none; }

    .side-link {
        display: inline-flex;
        align-items: center;
        min-height: 36px;
        padding: 0 13px;
        border: 1px solid var(--line);
        border-radius: var(--radius-full);
        background: var(--surface);
        white-space: nowrap;
    }

    .side-link.active::after { display: none; }

    .admin-main {
        width: 100%;
        max-width: 100vw;
        overflow: hidden;
    }

    .admin-header {
        position: sticky;
        top: 0;
        z-index: 30;
        align-items: flex-start;
        padding: 12px 14px;
    }

    .admin-header-actions {
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 6px;
    }

    .admin-header-actions .btn {
        width: auto;
        min-width: 68px;
    }

    .header-user {
        width: 100%;
        text-align: right;
    }

    .admin-canvas {
        width: 100%;
        max-width: 100vw;
        padding: 10px 10px 28px;
    }

    .panel,
    .dashboard-panel {
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }

    .dashboard-metrics,
    .compact-grid,
    .dashboard-form,
    .dashboard-account-form,
    .overview-charts-grid { grid-template-columns: 1fr; }

    .dashboard-account-form label:nth-child(3) { grid-column: auto; }

    .topbar,
    .panel-title,
    .scanner-panel { display: block; }

    .panel-title h2 { font-size: 17px; }

    .panel-title p {
        margin-top: 4px;
        line-height: 1.45;
    }

    .topbar { padding: var(--space-5); }

    .userbar,
    .actions { margin-top: 14px; }

    .stats-row,
    .admin-layout,
    .form-grid,
    .browser-address,
    .portal-actions,
    .week-controls,
    .admin-form-row,
    .admin-account-form { grid-template-columns: 1fr; }

    .admin-nav {
        position: static;
        grid-template-columns: 1fr;
    }

    .btn { width: 100%; }

    .week-controls,
    .assignment-controls,
    .free-check-panel,
    .table-actions {
        width: 100%;
        gap: 8px;
    }

    .week-controls label,
    .assignment-controls label {
        width: 100%;
    }

    .week-controls select,
    .assignment-controls select,
    .admin-form-row input,
    .admin-account-form input,
    .admin-list-tools,
    .admin-list-tools input {
        width: 100%;
        min-width: 0;
    }

    .schedule-table,
    .admin-table,
    .m-table-scroll {
        max-width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-x pan-y;
        overscroll-behavior-x: contain;
    }

    .schedule-table table,
    .admin-table table {
        width: max-content;
        min-width: 760px;
    }

    .admin-assignment-table table {
        min-width: 880px;
    }

    .admin-assignment-table td {
        min-width: 116px;
        height: 88px;
        padding: 8px;
    }

    .admin-table td {
        min-width: 96px;
        padding: 9px 10px;
        font-size: 13px;
    }

    th {
        top: 0;
        height: 40px;
        font-size: 13px;
    }

    .assignment-select {
        width: 100%;
        min-width: 96px;
    }

    .assignment-hours-chip {
        min-height: 30px;
        padding: 4px 8px;
    }

    .cleaning-area-grid {
        grid-template-columns: 1fr;
    }

    .cleaning-task-head {
        display: block;
    }

    .cleaning-task-head .table-actions {
        margin-top: 10px;
    }

    .cleaning-task-head .table-actions .btn,
    .cleaning-task-head .table-actions .pill {
        width: auto;
    }

    .cleaning-chip {
        min-height: 34px;
        padding: 0 13px;
    }

    .custom-arr-table table,
    #studentListPanel table {
        min-width: 880px;
    }

    #studentListPanel {
        overflow: hidden;
    }

    #studentListPanel .admin-table {
        position: relative;
        max-width: 100%;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-x pan-y;
        overscroll-behavior-x: contain;
    }

    #studentListPanel .admin-table table {
        width: max-content;
        min-width: 980px;
    }

    #studentListPanel .admin-table td,
    #studentListPanel .admin-table tr,
    #studentListPanel .admin-table tbody {
        overflow: visible;
    }

    #studentListPanel .student-action-wrap {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        width: 180px;
    }

    #studentListPanel .student-action-toggle {
        width: 38px;
        flex: 0 0 auto;
    }

    #studentListPanel .student-action-menu {
        position: static;
        width: 180px;
        min-width: 180px;
        margin-top: 6px;
        box-shadow: none;
        border-color: var(--line);
    }

    #studentListPanel .student-action-menu .btn,
    #studentListPanel .student-action-menu a {
        width: 100%;
    }

    .modal-overlay {
        align-items: flex-end;
    }

    .modal-dialog {
        width: 100%;
        max-height: 92vh;
        border-radius: 18px 18px 0 0;
    }

    .chart-container-square { max-width: 100%; }

    .chart-container,
    .chart-container-heatmap { height: 240px; }
}


/* ═══════════════════════════════════════════════════════════════════════════
   Responsive: Small Mobile (< 640px)
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 640px) {
    body.admin-dashboard-page {
        min-width: 0;
    }

    .admin-header {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 10px;
    }

    .breadcrumb { display: none; }

    .admin-header h1 {
        font-size: 18px;
    }

    .admin-header-actions {
        justify-content: flex-start;
    }

    .header-user {
        text-align: left;
    }

    .page-tabs {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }

    .page-tab {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .modal-body { grid-template-columns: 1fr; }
    .modal-sub-row { grid-template-columns: 1fr; }
    .modal-field.span-2 { grid-column: span 1; }
    .modal-dialog { width: 96%; max-height: 92vh; }

    .dashboard-metrics {
        grid-template-columns: 1fr 1fr;
    }

    .metric-card strong { font-size: 20px; }

    .stats-row {
        grid-template-columns: 1fr 1fr;
    }

    .push-status-grid { grid-template-columns: 1fr; }

    .mini-metrics { grid-template-columns: 1fr; }

    .dashboard-metrics {
        gap: 8px;
    }

    .metric-card {
        padding: 12px;
    }

    .metric-card strong { font-size: 19px; }

    .free-check-panel {
        padding: 10px;
    }

    .free-result {
        width: 100%;
        line-height: 1.45;
    }

    .cleaning-task-card {
        padding: 12px;
    }

    .cleaning-chip-grid {
        gap: 7px;
    }

    .cleaning-chip {
        font-size: 12px;
    }

    .modal-dialog {
        width: 100%;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Mobile Student Page — mirrors UniApp glass design
   ═══════════════════════════════════════════════════════════════════════════ */

.mobile-page {
    background: #e8ecf1;
    -webkit-tap-highlight-color: transparent;
}

.app-shell {
    max-width: 520px;
    margin: 0 auto;
    padding: 0 16px 40px;
    box-sizing: border-box;
}

/* ── Topbar ────────────────────────────── */
.m-topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 20px; margin: 12px 0 0;
    background: rgba(255,255,255,0.55);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-radius: 22px;
    border: 1px solid rgba(255,255,255,0.7);
    box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset, 0 6px 24px rgba(0,0,0,0.03);
    position: sticky; top: 10px; z-index: 50;
}
.m-topbar-left { display: flex; align-items: center; gap: 10px; }
.m-topbar-name { font-size: 17px; font-weight: 700; color: #1d1d1f; }
.m-week-picker-wrap { position: relative; }
.m-week-picker {
    height: 32px; padding: 0 12px; border: 0; border-radius: 16px;
    background: rgba(99,102,241,0.08); font-size: 13px; font-weight: 700; color: #6366f1;
    -webkit-appearance: none; cursor: pointer; outline: none;
}
.m-topbar-logout { font-size: 13px; font-weight: 600; color: #86868b; text-decoration: none; }

/* ── Status ───────────────────────────── */
.m-status {
    display: none; margin: 14px 0 0; padding: 12px 16px; border-radius: 16px;
    font-size: 14px; text-align: center;
}
.m-status.success { display: block; background: rgba(16,185,129,0.08); color: #059669; border: 1px solid rgba(16,185,129,0.15); }
.m-status.error   { display: block; background: rgba(239,68,68,0.08); color: #ef4444; border: 1px solid rgba(239,68,68,0.15); }
.m-status.warning { display: block; background: rgba(245,158,11,0.08); color: #b45309; border: 1px solid rgba(245,158,11,0.15); }
.m-status.info    { display: block; background: rgba(99,102,241,0.06); color: #6366f1; border: 1px solid rgba(99,102,241,0.12); }

/* ── Stats Grid ───────────────────────── */
.m-stats {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
    margin: 16px 0;
}
.m-stat-card {
    padding: 16px; border-radius: 20px;
    background: rgba(255,255,255,0.45);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.6);
    box-shadow: 0 1px 0 rgba(255,255,255,0.5) inset;
}
.m-stat-card span { display: block; font-size: 12px; color: #86868b; font-weight: 600; }
.m-stat-card strong { display: block; margin-top: 4px; font-size: 28px; font-weight: 800; color: #1d1d1f; }

/* ── Card ─────────────────────────────── */
.m-card {
    margin: 14px 0; padding: 18px; border-radius: 24px;
    background: rgba(255,255,255,0.45);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.7);
    box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset, 0 6px 24px rgba(0,0,0,0.03);
}
.m-card-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 12px; margin-bottom: 14px;
}
.m-card-title { display: block; font-size: 16px; font-weight: 700; color: #1d1d1f; }
.m-card-sub { display: block; margin-top: 2px; font-size: 12px; color: #86868b; }
.m-card-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ── Buttons ──────────────────────────── */
.m-btn {
    display: inline-flex; align-items: center; justify-content: center;
    height: 36px; padding: 0 16px; border: 1px solid rgba(0,0,0,0.08);
    border-radius: 18px; background: rgba(255,255,255,0.5);
    font-size: 13px; font-weight: 600; color: #3a3a3c; cursor: pointer;
    white-space: nowrap; transition: all 0.15s;
}
.m-btn:hover { background: rgba(255,255,255,0.8); }
.m-btn:active { transform: scale(0.97); }
.m-btn-primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff; border-color: transparent;
}
.m-btn-primary:hover { opacity: 0.9; }
.m-btn-success {
    background: rgba(16,185,129,0.1); color: #059669; border-color: rgba(16,185,129,0.2);
}
.m-btn-danger {
    background: rgba(239,68,68,0.08); color: #ef4444; border-color: rgba(239,68,68,0.15);
}
.m-btn-sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 14px; }
.m-btn-full { width: 100%; }
.m-badge {
    display: inline-flex; align-items: center; padding: 4px 14px;
    border-radius: 14px; font-size: 13px; font-weight: 700;
    background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff;
}

/* ── Table ────────────────────────────── */
.m-table-scroll {
    width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
    border-radius: 16px; margin: 0 -4px; padding: 0 4px;
}
.m-table {
    width: 1100px; border-collapse: collapse; border-radius: 16px; overflow: hidden;
    background: rgba(255,255,255,0.3);
}
.m-table th {
    padding: 10px 6px; background: rgba(0,0,0,0.03); color: #1d1d1f;
    font-size: 12px; font-weight: 700; text-align: center; border-bottom: 1px solid rgba(0,0,0,0.04);
}
.m-table td { padding: 8px 6px; border-bottom: 1px solid rgba(0,0,0,0.03); text-align: center; vertical-align: top; }
.m-table tr:last-child td { border-bottom: 0; }
.m-time-cell {
    width: 100px; background: rgba(0,0,0,0.015); text-align: left !important;
}
.m-time-cell strong { display: block; font-size: 12px; font-weight: 700; }
.m-time-cell small { display: block; font-size: 10px; color: #86868b; margin-top: 2px; }
.m-cell { min-width: 110px; height: 72px; vertical-align: middle !important; }
.m-cell-free { background: rgba(16,185,129,0.06); }
.m-cell-occupied { background: rgba(99,102,241,0.04); }
.m-course {
    display: inline-block; text-align: left; padding: 4px 8px; border-radius: 8px;
    background: rgba(255,255,255,0.7); border: 1px solid rgba(0,0,0,0.04);
    margin: 2px 0;
}
.m-course strong { display: block; font-size: 12px; line-height: 1.3; }
.m-course small { display: block; font-size: 10px; color: #86868b; line-height: 1.3; }
.m-free-tag { font-size: 12px; font-weight: 700; color: #059669; }
.m-empty-tag { font-size: 12px; color: #d1d1d6; }
.m-assigned { background: rgba(16,185,129,0.04); }
.m-assignee-name {
    display: inline-block; padding: 4px 10px; border-radius: 10px;
    background: rgba(0,0,0,0.03); font-size: 13px; font-weight: 600; color: #3a3a3c;
}

/* ── Form ─────────────────────────────── */
.m-form { display: flex; flex-direction: column; gap: 12px; }
.m-form-row { display: flex; gap: 10px; }
.m-form-field { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.m-form-field label { font-size: 12px; font-weight: 700; color: #3a3a3c; }
.m-form-field input, .m-form-field select {
    height: 36px; padding: 0 12px; border: 1px solid rgba(0,0,0,0.08);
    border-radius: 12px; background: rgba(0,0,0,0.02); font-size: 14px; color: #1d1d1f;
    outline: none; box-sizing: border-box; width: 100%;
}
.m-form-field input:focus, .m-form-field select:focus {
    border-color: rgba(99,102,241,0.3); background: #fff;
}
.m-req { color: #ef4444; }
.m-settings-row { display: flex; gap: 8px; margin-bottom: 12px; }
.m-input { flex: 1; height: 36px; padding: 0 12px; border: 1px solid rgba(0,0,0,0.08); border-radius: 12px; font-size: 13px; outline: none; }

/* ── List ─────────────────────────────── */
.m-list { display: flex; flex-direction: column; gap: 8px; }
.m-list-item {
    display: flex; align-items: center; gap: 12px; padding: 12px 14px;
    border-radius: 16px; background: rgba(0,0,0,0.02); font-size: 13px;
}
.m-list-item-left { flex: 1; }
.m-list-item-right { text-align: right; flex-shrink: 0; }
.m-list-item.mine { background: rgba(16,185,129,0.08); }
.m-list-item strong { line-height: 1.35; }
.m-list-item small { color: #86868b; line-height: 1.45; }
.m-hours-item .m-list-item-right {
    min-width: 54px;
    font-size: 15px;
    font-weight: 800;
}
.m-list-toggle {
    width: 100%;
    margin-top: 10px;
    height: 38px;
    border: 0;
    border-radius: 16px;
    background: rgba(99,102,241,0.08);
    color: #4f46e5;
    font-size: 13px;
    font-weight: 800;
}
.m-list-toggle:active { transform: scale(0.98); }
.m-duty-today {
    display: grid;
    grid-template-columns: minmax(92px, 0.8fr) minmax(0, 1.5fr);
    gap: 10px;
    align-items: stretch;
    padding: 12px;
    border-radius: 18px;
    background: rgba(255,255,255,0.5);
    border: 1px solid rgba(0,0,0,0.04);
}
.m-duty-today span {
    display: block;
    color: #86868b;
    font-size: 12px;
    font-weight: 700;
}
.m-duty-today strong {
    display: block;
    margin-top: 4px;
    color: #1d1d1f;
    font-size: 16px;
    line-height: 1.3;
}
.m-duty-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
}
.m-duty-pill {
    display: inline-flex;
    flex-direction: column;
    gap: 2px;
    min-width: 96px;
    padding: 9px 10px;
    border-radius: 14px;
    background: rgba(99,102,241,0.09);
    border: 1px solid rgba(99,102,241,0.12);
}
.m-duty-pill.late {
    background: rgba(16,185,129,0.09);
    border-color: rgba(16,185,129,0.14);
}
.m-duty-pill span {
    color: #4f46e5;
    font-size: 12px;
}
.m-duty-pill.late span { color: #047857; }
.m-duty-pill strong {
    margin: 0;
    font-size: 13px;
}
.m-duty-empty {
    width: 100%;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(0,0,0,0.025);
    color: #86868b;
    font-size: 13px;
    text-align: center;
}
.m-week-duty-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(88px, 1fr));
    gap: 8px;
    margin-top: 12px;
    overflow-x: auto;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
}
.m-week-duty-day {
    min-width: 88px;
    padding: 10px;
    border-radius: 16px;
    background: rgba(255,255,255,0.52);
    border: 1px solid rgba(0,0,0,0.04);
}
.m-week-duty-day.today {
    border-color: rgba(99,102,241,0.24);
    box-shadow: 0 0 0 2px rgba(99,102,241,0.06) inset;
}
.m-week-duty-name {
    margin-bottom: 8px;
    color: #1d1d1f;
    font-size: 13px;
    font-weight: 800;
    text-align: center;
}
.m-week-duty-slot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    min-height: 30px;
    margin-top: 6px;
    padding: 0 8px;
    border-radius: 12px;
    background: rgba(0,0,0,0.025);
    color: #b0b0b6;
}
.m-week-duty-slot span {
    flex: 0 0 auto;
    font-size: 12px;
    font-weight: 800;
}
.m-week-duty-slot small {
    min-width: 0;
    color: inherit;
    font-size: 11px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.m-week-duty-slot.active {
    color: #4f46e5;
    background: rgba(99,102,241,0.1);
}
.m-week-duty-slot.active.late {
    color: #047857;
    background: rgba(16,185,129,0.1);
}
@media (max-width: 420px) {
    .m-duty-today {
        grid-template-columns: 1fr;
    }
    .m-duty-list {
        justify-content: stretch;
    }
    .m-duty-pill {
        flex: 1 1 120px;
    }
}
.m-cleaning-focus {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.m-cleaning-mine,
.m-cleaning-empty {
    padding: 12px 14px;
    border-radius: 18px;
    background: rgba(16,185,129,0.09);
    border: 1px solid rgba(16,185,129,0.12);
}
.m-cleaning-empty {
    background: rgba(0,0,0,0.025);
    border-color: rgba(0,0,0,0.03);
    color: #86868b;
    font-size: 13px;
}
.m-cleaning-mine strong,
.m-cleaning-item strong {
    display: block;
    color: #1d1d1f;
    font-size: 13px;
    line-height: 1.4;
}
.m-cleaning-mine small,
.m-cleaning-item small {
    display: block;
    margin-top: 4px;
    color: #86868b;
    font-size: 12px;
    line-height: 1.45;
}
.m-cleaning-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}
.m-cleaning-item {
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(0,0,0,0.02);
}
.m-cleaning-item.mine { background: rgba(16,185,129,0.055); }
.m-area-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.m-area-tags span {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 9px;
    border-radius: 999px;
    background: rgba(255,255,255,0.62);
    color: #6e6e73;
    font-size: 12px;
    font-weight: 600;
}
.m-area-tags span.mine {
    background: rgba(16,185,129,0.13);
    color: #047857;
}
.m-empty { text-align: center; padding: 20px; font-size: 13px; color: #86868b; }

/* ── Actions Row ──────────────────────── */
.m-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ── Overlay / Dialog ─────────────────── */
.m-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.35);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    display: flex; align-items: flex-end; justify-content: center;
    z-index: 9999;
}
.m-overlay[hidden] { display: none !important; }
.m-dialog {
    width: 100%; max-height: 80vh; padding: 24px 20px 32px;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(28px); -webkit-backdrop-filter: blur(28px);
    border-radius: 28px 28px 0 0; border: 1px solid rgba(255,255,255,0.7);
    box-shadow: 0 -1px 0 rgba(255,255,255,0.5) inset, 0 -8px 40px rgba(0,0,0,0.08);
    overflow-y: auto;
}
.m-dialog-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 18px;
}
.m-dialog-header strong { font-size: 18px; font-weight: 700; color: #1d1d1f; }
.m-dialog-close {
    width: 32px; height: 32px; border: 0; border-radius: 12px;
    background: rgba(0,0,0,0.04); font-size: 20px; color: #86868b;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.m-time-list { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow: auto; margin-bottom: 14px; }
.m-time-item {
    display: flex; justify-content: space-between; padding: 10px 14px;
    border-radius: 14px; background: rgba(0,0,0,0.02); font-size: 13px;
}
.m-hint { font-size: 12px; color: #86868b; line-height: 1.5; margin-top: 8px; text-align: center; }

@media (min-width: 520px) {
    .app-shell { padding: 0 0 40px; }
    .m-table { width: 1200px; }
}
