/* =========================
   DESIGN TOKENS
========================= */
:root {
    --font-sans: "Plus Jakarta Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

    --primary-50: #eff6ff;
    --primary-100: #dbeafe;
    --primary-200: #bfdbfe;
    --primary-300: #93c5fd;
    --primary-400: #60a5fa;
    --primary-500: #3b82f6;
    --primary-600: #2563eb;
    --primary-700: #1d4ed8;
    --primary-800: #1e3a8a;

    --teal-500: #14b8a6;
    --green-500: #22c55e;
    --amber-500: #f59e0b;
    --red-500: #ef4444;

    --gray-0: #ffffff;
    --gray-50: #f8fafc;
    --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;

    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --surface-strong: #eef4ff;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --sidebar-bg: linear-gradient(180deg, #162554 0%, #1e3a8a 100%);
    --sidebar-text: rgba(255, 255, 255, 0.86);
    --sidebar-text-muted: rgba(255, 255, 255, 0.62);
    --sidebar-active-bg: rgba(255, 255, 255, 0.12);

    --shadow-sm: 0 4px 14px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 20px 40px rgba(15, 23, 42, 0.12);

    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 22px;

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;

    --transition-fast: 0.2s ease;
    --transition-base: 0.3s ease;
    --sidebar-width: 280px;
}

html[data-theme="dark"] {
    --bg: #0b1220;
    --surface: #111827;
    --surface-soft: #172033;
    --surface-strong: #1d2940;
    --text: #e5eefb;
    --text-muted: #93a4bd;
    --border: #243145;
    --border-strong: #334155;
    --sidebar-bg: linear-gradient(180deg, #0f172a 0%, #162554 100%);
    --sidebar-text: rgba(255, 255, 255, 0.92);
    --sidebar-text-muted: rgba(255, 255, 255, 0.68);
    --sidebar-active-bg: rgba(255, 255, 255, 0.1);

    --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.22);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.28);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.34);
}

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

html {
    font-size: 16px;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* =========================
   LAYOUT
========================= */
.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    background: var(--bg);
}

.app-sidebar {
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: var(--space-6) var(--space-5);
    position: sticky;
    top: 0;
    height: 100vh;
    box-shadow: var(--shadow-md);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.24) transparent;
}

.app-sidebar__brand {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
    padding: 0 var(--space-1) var(--space-5);
    border-bottom: 1px solid rgba(255,255,255,.1);
}

.app-logo {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    font-size: 22px;
    background: rgba(255, 255, 255, 0.12);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.12);
}

.app-brand__title {
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.app-brand__subtitle {
    font-size: 0.875rem;
    color: var(--sidebar-text-muted);
}

.app-nav__section {
    margin: 0 0 var(--space-2);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sidebar-text-muted);
    padding: 0 12px;
}

.app-nav {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

.app-nav__group {
    display: grid;
    gap: 6px;
}

.app-nav__link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 12px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.92rem;
    transition: var(--transition-fast);
}

.app-nav__link:hover,
.app-nav__link.is-active {
    background: var(--sidebar-active-bg);
    color: #fff;
}

.app-nav__link.is-active {
    box-shadow: inset 3px 0 0 rgba(255,255,255,.52);
}

.app-nav__icon {
    width: 18px;
    min-width: 18px;
    text-align: center;
    color: inherit;
    opacity: .9;
}

.app-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-4);
    min-height: 82px;
    padding: 18px var(--space-6);
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(10px);
}

.app-header__left,
.app-header__right {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.app-header__left {
    min-width: 0;
}

.app-header__titles {
    min-width: 0;
}

.app-page-title {
    margin: 0;
    font-size: 1.42rem;
    line-height: 1.2;
}

.app-page-subtitle {
    margin: 2px 0 0;
    font-size: 0.92rem;
    color: var(--text-muted);
}

.app-content {
    padding: var(--space-6);
    display: grid;
    gap: var(--space-5);
}

/* =========================
   BUTTONS / CHIPS
========================= */
.app-icon-btn,
.app-theme-toggle {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    width: 42px;
    height: 42px;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-fast);
}

.app-icon-btn:hover,
.app-theme-toggle:hover {
    transform: translateY(-1px);
    border-color: var(--primary-300);
}

.js-sidebar-toggle {
    display: none;
}

.app-user-chip {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 6px 12px 6px 6px;
    box-shadow: var(--shadow-sm);
}

.app-user-chip__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--primary-500), var(--teal-500));
    color: white;
    font-weight: 800;
}

.app-user-chip__name {
    font-size: 0.9rem;
    font-weight: 700;
}

.app-user-chip__role {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* =========================
   CARDS
========================= */
.app-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--space-6);
}

.app-card + .app-card {
    margin-top: var(--space-6);
}

.app-card__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-5);
}

.app-card__title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 800;
}

.app-card__subtitle {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 0.92rem;
}

/* =========================
   TABLES
========================= */
.app-table-wrap {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th,
table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

table th {
    font-size: 0.83rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    background: var(--surface-soft);
}

table tr:hover td {
    background: color-mix(in srgb, var(--surface-soft) 72%, transparent);
}

/* =========================
   FORMS
========================= */
label {
    display: inline-block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text);
}

input,
select,
textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    transition: var(--transition-fast);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-400);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary-500) 14%, transparent);
}

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

button,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 16px;
    border-radius: 12px;
    border: 1px solid transparent;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    border-color: var(--primary-300);
}

.btn-danger {
    background: var(--red-500);
    color: white;
}

/* =========================
   ALERTS
========================= */
.app-alert {
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--border);
    margin-bottom: var(--space-5);
    font-weight: 600;
}

.app-alert:first-child {
    margin-top: 0;
}

.app-alert--success {
    background: color-mix(in srgb, var(--green-500) 10%, var(--surface));
    border-color: color-mix(in srgb, var(--green-500) 28%, var(--border));
}

.app-alert--error {
    background: color-mix(in srgb, var(--red-500) 10%, var(--surface));
    border-color: color-mix(in srgb, var(--red-500) 28%, var(--border));
}

.app-alert--warning {
    background: color-mix(in srgb, var(--amber-500) 10%, var(--surface));
    border-color: color-mix(in srgb, var(--amber-500) 28%, var(--border));
}

/* =========================
   CRUD HELPERS
========================= */
.page-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: var(--space-5);
}

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

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-5);
}

.form-grid .full {
    grid-column: 1 / -1;
}

/* =========================
   RESPONSIVE
========================= */
@media (max-width: 1024px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .app-sidebar {
        position: fixed;
        left: -100%;
        width: var(--sidebar-width);
        z-index: 60;
        transition: left var(--transition-base);
    }

    .app-shell.sidebar-open .app-sidebar {
        left: 0;
    }

    .js-sidebar-toggle {
        display: inline-grid;
        place-items: center;
    }
}

@media (max-width: 768px) {
    .app-header {
        padding: var(--space-4);
    }

    .app-content {
        padding: var(--space-4);
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .app-user-chip__meta {
        display: none;
    }
}


/* =========================
   FORM IMPROVEMENTS
========================= */
.app-form {
    width: 100%;
}

.app-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px;
}

.app-field--full {
    grid-column: 1 / -1;
}

.app-field {
    min-width: 0;
}

.app-label {
    display: inline-block;
    margin-bottom: 10px;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text);
}

.app-input,
input.app-input,
select.app-input,
textarea.app-input,
input[type="text"],
input[type="date"],
input[type="datetime-local"],
input[type="email"],
input[type="password"],
input[type="search"],
select,
textarea {
    width: 100%;
    /*min-height: 48px;*/
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    transition: var(--transition-fast);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.02);
}

input[type="date"] {
    appearance: none;
    -webkit-appearance: none;
}

.app-input:focus,
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-400);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary-500) 14%, transparent);
}

.app-switches {
    margin-top: 24px;
    display: grid;
    gap: 16px;
}

.app-switch-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 18px 20px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface-soft);
}

.app-switch-card__title {
    font-weight: 800;
    margin-bottom: 4px;
}

.app-switch-card__desc {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.app-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: 56px;
    height: 32px;
    flex-shrink: 0;
}

.app-switch__input {
    position: absolute;
    inset: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0 !important;
    cursor: pointer;
}

.app-switch__slider {
    position: relative;
    width: 56px;
    height: 32px;
    border-radius: 999px;
    background: var(--gray-300);
    transition: var(--transition-fast);
    box-shadow: inset 0 0 0 1px rgba(15,23,42,.05);
}

.app-switch__slider::before {
    content: "";
    position: absolute;
    top: 4px;
    left: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 4px 10px rgba(0,0,0,.14);
    transition: var(--transition-fast);
}

.app-switch__input:checked + .app-switch__slider {
    background: linear-gradient(135deg, var(--primary-500), var(--teal-500));
}

.app-switch__input:checked + .app-switch__slider::before {
    transform: translateX(24px);
}

.app-switch__input:focus + .app-switch__slider {
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary-500) 18%, transparent);
}

.app-form .form-error-message,
.app-form .invalid-feedback,
.app-form ul {
    margin: 8px 0 0;
    padding-left: 18px;
    color: #dc2626;
    font-size: 0.9rem;
}

/* =========================
   TABS / TABLE ADMIN STYLE
========================= */
.ph-tabs {
    margin-bottom: 18px;
}

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

.ph-tab {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    padding: 10px 14px;
    border-radius: 14px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-fast);
}

.ph-tab:hover {
    border-color: var(--primary-300);
}

.ph-tab.is-active {
    background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
    color: #fff;
    border-color: transparent;
}

.ph-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    background: rgba(15,23,42,.08);
    font-size: 12px;
    font-weight: 800;
}

.ph-tab.is-active .ph-chip {
    background: rgba(255,255,255,.18);
    color: #fff;
}

.ph-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow-sm);
    overflow: visible;
}

.ph-card__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 20px 20px 14px;
    position: relative;
    z-index: 20;
}

.ph-card__title {
    font-size: 1.05rem;
    font-weight: 800;
}

.ph-table-wrap {
    overflow-x: auto;
}

.ph-table {
    width: 100%;
    border-collapse: collapse;
}

.ph-table th,
.ph-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    text-align: left;
}

.ph-table th {
    background: var(--surface-soft);
    font-size: 0.82rem;
    color: var(--text-muted);
}

.ph-th {
    display: grid;
    gap: 8px;
}

.ph-th__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.ph-sort-btn {
    border: 0;
    background: transparent;
    padding: 0;
    margin: 0;
    color: inherit;
    font: inherit;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.ph-sort-icon {
    color: var(--text-muted);
    font-size: 12px;
}

.ph-filter {
    width: 100%;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    padding: 0 10px;
}

.ph-filter:focus {
    outline: none;
    border-color: rgba(59,130,246,.55);
    box-shadow: 0 0 0 3px rgba(59,130,246,.14);
}

.ph-table-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-top: 1px solid var(--border);
}

.ph-table-footer__left,
.ph-table-footer__right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.ph-page-numbers {
    display: flex;
    gap: 6px;
    align-items: center;
}

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

.ph-row-state--archived,
.ph-row-state--archived:hover {
    background: linear-gradient(0deg, rgba(239,68,68,.08), rgba(239,68,68,.08)) !important;
}

.ph-row-state--archived > td,
.ph-row-state--archived:hover > td {
    background: transparent !important;
}

.ph-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.ph-badge--success {
    background: rgba(34,197,94,.12);
    color: #15803d;
    border: 1px solid rgba(34,197,94,.22);
}

.ph-badge--archived {
    background: var(--surface-soft);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.ph-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 24px !important;
}

@media (max-width: 768px) {
    .app-form-grid {
        grid-template-columns: 1fr;
    }

    .app-switch-card {
        align-items: flex-start;
    }
}


/* =========================
   REFINEMENTS UI
========================= */
.page-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: var(--space-5);
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
}

.btn--sm {
    min-height: 36px;
    padding: 8px 12px;
    font-size: 0.88rem;
    border-radius: 12px;
}

.btn__icon,
.ph-tab__icon,
.ph-card__title-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.ph-card__title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ph-card__title-icon {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    background: var(--surface-strong);
    color: var(--primary-700);
    font-size: 14px;
    border: 1px solid var(--border);
}

.ph-tabs__bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.ph-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 10px 14px;
    border-radius: 14px;
    font-weight: 700;
}

.ph-tab__icon {
    font-size: 14px;
}

.ph-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
}

.inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.inline-actions form {
    margin: 0;
}

.ph-table td[data-col="actions"] {
    min-width: 200px;
}

.ph-badge {
    gap: 6px;
}

.ph-status-icon {
    font-size: 11px;
}

.app-section-note {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.app-status-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    padding: 18px 20px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface-soft);
}

.app-status-card__title {
    font-weight: 800;
    margin-bottom: 4px;
}

.app-status-card__desc {
    font-size: 0.92rem;
    color: var(--text-muted);
}

@media (max-width: 768px) {
    .page-actions--end {
        justify-content: flex-start;
    }

    .app-status-card {
        flex-direction: column;
        align-items: flex-start;
    }
}

input:disabled,
select:disabled,
textarea:disabled {
    background: var(--surface-soft);
    color: var(--text);
    opacity: 1;
    cursor: not-allowed;
    border-color: var(--border);
}

.app-switch__input:disabled + .app-switch__slider {
    opacity: 0.8;
    cursor: not-allowed;
}

/* =========================
   PRODUCT SHELL COMPONENTS
========================= */
.app-page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: var(--space-5);
    margin-bottom: var(--space-5);
}

.app-page-head__eyebrow {
    margin-bottom: 6px;
    color: var(--primary-700);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.app-page-head__title {
    margin: 0;
    font-size: 1.25rem;
    line-height: 1.2;
    font-weight: 800;
}

.app-page-head__subtitle {
    margin: 6px 0 0;
    color: var(--text-muted);
    font-size: .94rem;
}

.app-page-head__actions {
    margin-bottom: 0;
}

.app-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-4);
}

.app-kpi-card {
    display: flex;
    gap: var(--space-4);
    align-items: center;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.app-kpi-card__icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: var(--surface-strong);
    color: var(--primary-700);
    border: 1px solid var(--border);
}

.app-kpi-card__label {
    color: var(--text-muted);
    font-size: .82rem;
    font-weight: 700;
}

.app-kpi-card__value {
    margin-top: 2px;
    font-size: 1.35rem;
    line-height: 1.1;
    font-weight: 800;
}

.app-kpi-card__hint {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: .82rem;
}

.app-empty-state {
    display: grid;
    justify-items: center;
    gap: var(--space-3);
    padding: 32px 20px;
    color: var(--text-muted);
    text-align: center;
}

.app-empty-state__icon {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 16px;
    background: var(--surface-strong);
    color: var(--primary-700);
    border: 1px solid var(--border);
    font-size: 18px;
}

.app-empty-state__title {
    color: var(--text);
    font-weight: 800;
}

.app-empty-state__message {
    margin-top: 4px;
    max-width: 420px;
    font-size: .92rem;
}

.app-empty-state__action {
    margin-top: var(--space-2);
}

.app-section-card {
    display: block;
}

.app-table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-4);
    padding: 20px 20px 14px;
}

.app-table-toolbar__title {
    font-size: 1.05rem;
    font-weight: 800;
}

.app-table-toolbar__subtitle {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: .9rem;
}

.app-table-toolbar__meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.ph-card__actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.app-form-section {
    display: grid;
    gap: var(--space-4);
}

.app-form-section + .app-form-section {
    margin-top: var(--space-6);
}

.app-form-section__header {
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--border);
}

.app-form-section__title {
    font-weight: 800;
}

.app-form-section__subtitle {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: .9rem;
}

.app-form-section__body {
    min-width: 0;
}

.ph-muted {
    color: var(--text-muted);
}

.ph-xscroll {
    overflow-x: auto;
    overflow-y: hidden;
    height: 14px;
    border: 1px solid var(--border);
    border-bottom: 0;
    border-radius: 14px 14px 0 0;
    background: var(--surface-soft);
}

.ph-xscroll__inner {
    height: 1px;
}

.ph-columns {
    position: relative;
}

.ph-columns__button {
    white-space: nowrap;
}

.ph-columns__menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 30;
    display: none;
    min-width: 220px;
    max-height: 280px;
    overflow-y: auto;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow-md);
}

.ph-columns__menu.is-open {
    display: grid;
    gap: 2px;
}

.ph-columns__item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border-radius: 9px;
    color: var(--text);
    font-size: .86rem;
    font-weight: 700;
    cursor: pointer;
}

.ph-columns__item:hover {
    background: var(--surface-soft);
}

.ph-columns__item input {
    accent-color: var(--primary-600);
}

html[data-theme="dark"] .app-page-head__eyebrow,
html[data-theme="dark"] .app-kpi-card__icon,
html[data-theme="dark"] .app-empty-state__icon,
html[data-theme="dark"] .ph-card__title-icon {
    color: var(--primary-300);
}

@media (max-width: 1180px) {
    .app-kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .app-page-head,
    .app-table-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .app-kpi-grid {
        grid-template-columns: 1fr;
    }
}

/* =========================
   COMPACT DASHBOARDS
========================= */
.app-shell {
    --sidebar-width: 252px;
}

.app-content {
    gap: 16px;
    padding: 18px;
}

.app-header {
    min-height: 58px;
    padding: 10px 18px;
}

.app-main {
    padding: 16px 18px 22px;
}

.page-actions {
    gap: 8px;
}

.app-card,
.ph-card {
    border-radius: 16px;
}

.app-card {
    padding: 18px;
}

.app-card__header,
.ph-card__header {
    gap: 12px;
    padding: 14px 16px 10px;
}

.app-card__title,
.ph-card__title {
    font-size: 1rem;
}

.app-card__subtitle,
.app-section-note {
    font-size: .88rem;
}

.ph-table th,
.ph-table td {
    padding: 9px 11px;
}

.ph-table {
    min-width: max-content;
}

.ph-table-wrap {
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

.ph-filter,
.app-input,
.form-control,
.form-select {
    min-height: 38px;
    padding: 8px 10px;
    border-radius: 10px;
    font-size: .9rem;
}

.btn {
    min-height: 38px;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: .9rem;
}

.btn--sm {
    min-height: 32px;
    padding: 6px 9px;
    font-size: .82rem;
}

.app-page-head {
    gap: 16px;
    margin-bottom: 16px;
}

.app-page-head__title {
    font-size: 1.18rem;
}

.app-page-head__subtitle {
    font-size: .88rem;
}

.dashboard-kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 16px;
}

.dashboard-kpi-grid--teacher {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.app-kpi-card {
    min-width: 0;
    padding: 14px;
    border-radius: 16px;
}

.app-kpi-card__icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    flex: 0 0 auto;
}

.app-kpi-card__label,
.app-kpi-card__hint {
    font-size: .78rem;
}

.app-kpi-card__value {
    font-size: 1.18rem;
}

.dashboard-grid {
    display: grid;
    gap: 16px;
    margin-bottom: 16px;
}

.dashboard-grid--two {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.dashboard-quick-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 0 16px 16px;
}

.dashboard-quick-grid--teacher {
    grid-template-columns: repeat(2, minmax(0, 220px));
}

.dashboard-quick-card,
.dashboard-list__item {
    color: var(--text);
    text-decoration: none;
}

.dashboard-quick-card {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-soft);
    font-weight: 700;
    transition: transform .18s ease, border-color .18s ease, background .18s ease;
}

.dashboard-quick-card:hover,
.dashboard-list__item:hover {
    transform: translateY(-1px);
    border-color: var(--primary-300);
    background: var(--surface);
}

.dashboard-quick-card i {
    color: var(--primary-700);
}

.dashboard-list {
    display: grid;
    gap: 8px;
    padding: 0 16px 16px;
}

.dashboard-list__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-soft);
    transition: transform .18s ease, border-color .18s ease, background .18s ease;
}

.dashboard-list__item span:first-child {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.dashboard-list__item strong,
.dashboard-list__item small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dashboard-list__item small {
    color: var(--text-muted);
    font-size: .82rem;
}

.pedagogy-flow {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: -6px 0 14px;
}

.pedagogy-flow a {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-muted);
    font-size: .82rem;
    font-weight: 800;
    text-decoration: none;
}

.pedagogy-flow a:hover {
    border-color: var(--primary-300);
    color: var(--primary-700);
}

.table-main-link {
    color: var(--text);
    font-weight: 800;
    text-decoration: none;
}

.table-main-link:hover {
    color: var(--primary-700);
}

.form-actions-compact {
    margin-top: 16px;
    margin-bottom: 0;
}

.ph-table--wide th,
.ph-table--wide td {
    max-width: 260px;
}

.ph-table--wide td {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

html[data-theme="dark"] .dashboard-quick-card i {
    color: var(--primary-300);
}

@media (max-width: 1240px) {
    .dashboard-kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

@media (max-width: 920px) {
    .app-shell {
        --sidebar-width: 238px;
    }

    .app-content,
    .app-main {
        padding-inline: 14px;
    }
}

@media (max-width: 768px) {
    .dashboard-kpi-grid,
    .dashboard-kpi-grid--teacher,
    .dashboard-quick-grid,
    .dashboard-quick-grid--teacher {
        grid-template-columns: 1fr;
    }

    .dashboard-list__item {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* =========================
   STRONG GLOBAL DENSITY PASS
   Applies after older module styles.
========================= */
:root {
    --sidebar-width: 224px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --space-4: 12px;
    --space-5: 14px;
    --space-6: 18px;
    --space-8: 22px;
}

html {
    font-size: 14px;
}

.app-sidebar {
    padding: 14px 12px;
}

.app-sidebar__brand {
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 12px;
}

.app-logo {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    font-size: 17px;
}

.app-brand__title {
    font-size: .98rem;
}

.app-brand__subtitle {
    font-size: .74rem;
}

.app-nav {
    gap: 8px;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-right: 2px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.24) transparent;
}

.app-nav__group {
    gap: 4px;
    margin-bottom: 8px;
}

.app-nav__section {
    margin: 8px 8px 4px;
    font-size: .66rem;
}

.app-nav__link {
    min-height: 34px;
    padding: 7px 9px;
    border-radius: 10px;
    font-size: .84rem;
}

.app-nav__icon {
    font-size: .95rem;
}

.app-sidebar-collapse {
    position: static;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    width: 100%;
    min-height: 34px;
    margin-top: 8px;
    padding: 7px 9px;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 10px;
    color: var(--sidebar-text);
    background: rgba(255,255,255,.08);
    font: inherit;
    font-size: .78rem;
    font-weight: 800;
    cursor: pointer;
    transition: var(--transition-fast);
}

.app-sidebar-collapse:hover {
    background: rgba(255,255,255,.13);
    color: #fff;
}

.app-shell.is-sidebar-collapsed {
    --sidebar-width: 68px;
}

.app-shell.is-sidebar-collapsed .app-sidebar {
    padding-inline: 8px;
}

.app-shell.is-sidebar-collapsed .app-sidebar__brand {
    justify-content: center;
    padding-inline: 0;
}

.app-shell.is-sidebar-collapsed .app-sidebar__brand > div:not(.app-logo),
.app-shell.is-sidebar-collapsed .app-nav__label,
.app-shell.is-sidebar-collapsed .app-nav__section,
.app-shell.is-sidebar-collapsed .app-sidebar-collapse__label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.app-shell.is-sidebar-collapsed .app-nav__link,
.app-shell.is-sidebar-collapsed .app-sidebar-collapse {
    justify-content: center;
    padding-inline: 0;
}

.app-shell.is-sidebar-collapsed .app-nav__link.is-active {
    box-shadow: inset 0 -3px 0 rgba(255,255,255,.58);
}

.app-shell.is-sidebar-collapsed .app-sidebar-collapse i {
    transform: none;
}

.app-main {
    padding: 10px 12px 14px;
}

.app-header {
    min-height: 46px;
    padding: 7px 12px;
    border-radius: 14px;
}

.app-header__left,
.app-header__right {
    gap: 8px;
}

.app-page-title {
    font-size: 1rem;
    line-height: 1.15;
}

.app-page-subtitle {
    margin-top: 2px;
    font-size: .76rem;
}

.app-icon-btn,
.app-theme-toggle {
    width: 32px;
    height: 32px;
    border-radius: 10px;
}

.app-user-chip {
    min-height: 34px;
    padding: 5px 8px;
    gap: 7px;
    border-radius: 11px;
}

.app-user-chip__avatar {
    width: 24px;
    height: 24px;
    font-size: .76rem;
}

.app-user-chip__name {
    font-size: .78rem;
}

.app-user-chip__role {
    font-size: .68rem;
}

.app-content {
    gap: 9px;
    padding: 10px 0 0;
}

.page-actions {
    gap: 6px;
    margin-bottom: 8px;
}

.aa-tabs {
    gap: 6px;
    margin-bottom: 8px;
}

.aa-tab {
    min-height: 32px;
    padding: 6px 10px;
    border-radius: 10px;
    font-size: .82rem;
}

.ph-tabs {
    margin: 4px 0 8px;
}

.ph-tabs__bar {
    gap: 6px;
}

.ph-tab {
    min-height: 31px;
    padding: 5px 9px;
    border-radius: 9px;
    font-size: .8rem;
}

.app-card,
.ph-card {
    border-radius: 12px;
}

.app-card {
    padding: 12px;
}

.app-card__header,
.ph-card__header {
    min-height: 0;
    padding: 9px 10px 7px;
    gap: 8px;
}

.ph-card__title-wrap {
    gap: 8px;
}

.ph-card__title-icon {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    font-size: .92rem;
}

.app-card__title,
.ph-card__title {
    font-size: .9rem;
    line-height: 1.15;
}

.app-card__subtitle,
.app-section-note {
    font-size: .76rem;
}

.ph-chip {
    min-height: 28px;
    padding: 5px 8px;
    border-radius: 999px;
    font-size: .74rem;
}

.ph-table-wrap {
    max-width: 100%;
    overflow-x: auto;
}

.ph-xscroll {
    height: 10px;
    border-radius: 10px 10px 0 0;
}

.ph-table {
    font-size: .82rem;
}

.ph-table th,
.ph-table td {
    padding: 6px 8px;
}

.ph-th {
    gap: 5px;
}

.ph-th__top {
    min-height: 18px;
}

.ph-sort-btn {
    font-size: .75rem;
}

.ph-sort-icon {
    font-size: .7rem;
}

.ph-filter,
.app-input,
.form-control,
.form-select {
    min-height: 30px;
    padding: 5px 8px;
    border-radius: 8px;
    font-size: .8rem;
}

.btn {
    min-height: 31px;
    padding: 5px 9px;
    border-radius: 8px;
    font-size: .8rem;
}

.btn--sm {
    min-height: 27px;
    padding: 4px 7px;
    font-size: .76rem;
}

.btn__icon {
    font-size: .9em;
}

.inline-actions {
    gap: 5px;
}

.ph-badge {
    min-height: 23px;
    padding: 3px 7px;
    border-radius: 999px;
    font-size: .72rem;
}

.ph-status-icon {
    font-size: .8rem;
}

.ph-table-footer {
    min-height: 42px;
    padding: 7px 10px;
    gap: 8px;
    font-size: .78rem;
}

.ph-table-footer__left,
.ph-table-footer__right {
    gap: 6px;
}

.ph-page-numbers {
    gap: 4px;
}

.ph-btn {
    min-width: 27px;
    min-height: 27px;
    padding: 4px 7px;
    border-radius: 8px;
    font-size: .76rem;
}

.ph-columns__button {
    min-height: 28px;
    padding: 4px 8px;
    border-radius: 8px;
    font-size: .76rem;
}

.ph-columns__menu {
    min-width: 190px;
    max-height: 240px;
    padding: 6px;
    border-radius: 10px;
}

.ph-columns__item {
    padding: 5px 6px;
    border-radius: 7px;
    font-size: .78rem;
}

.app-form-grid {
    gap: 10px;
}

.app-form-section {
    gap: 10px;
}

.app-form-section + .app-form-section {
    margin-top: 14px;
}

.app-form-section__header {
    padding-bottom: 8px;
}

.app-label {
    margin-bottom: 4px;
    font-size: .76rem;
}

.app-page-head {
    margin-bottom: 9px;
    gap: 10px;
}

.app-page-head__eyebrow {
    margin-bottom: 3px;
    font-size: .66rem;
}

.app-page-head__title {
    font-size: 1rem;
}

.app-page-head__subtitle {
    margin-top: 3px;
    font-size: .78rem;
}

.app-kpi-grid {
    gap: 9px;
}

.app-kpi-card {
    gap: 9px;
    padding: 9px;
    border-radius: 12px;
}

.app-kpi-card__icon {
    width: 32px;
    height: 32px;
    border-radius: 10px;
}

.app-kpi-card__value {
    font-size: 1rem;
}

.app-kpi-card__label,
.app-kpi-card__hint {
    font-size: .7rem;
}

@media (max-width: 1180px) {
    :root {
        --sidebar-width: 210px;
    }

    .app-main {
        padding-inline: 9px;
    }
}

/* =========================
   STANDARD INDEX TABLE VIEWPORT
   Shared by every table[data-ph-table].
========================= */
.ph-card--table {
    overflow: visible;
    min-width: 0;
    max-width: 100%;
}

.app-shell {
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    max-width: 100vw;
    overflow-x: clip;
}

.app-content,
.app-content > *,
.ph-card {
    min-width: 0;
    max-width: 100%;
}

@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: minmax(0, 1fr);
    }
}

.ph-card--table .ph-card__header {
    position: relative;
    z-index: 5;
    overflow: visible;
    gap: 8px;
    align-items: center;
}

.ph-card--table .ph-card__actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: wrap;
    margin-left: auto;
    min-width: max-content;
}

.ph-card--table .ph-card__title-wrap {
    min-width: 0;
    flex: 1 1 auto;
}

.ph-table-wrap--standard {
    overflow-x: auto;
    overflow-y: visible;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    width: var(--sidebar-width);
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
    background: var(--sidebar-bg);
    background-attachment: fixed;
}

.app-main {
    grid-column: 2;
    min-width: 0;
}

@media (max-width: 1024px) {
    .app-shell {
        grid-template-columns: minmax(0, 1fr);
    }

    .app-sidebar {
        left: -100%;
        z-index: 60;
        transition: left var(--transition-base);
    }

    .app-shell.sidebar-open .app-sidebar {
        left: 0;
    }

    .app-main {
        grid-column: 1;
    }
}

.app-select {
    position: relative;
    min-width: 0;
    width: 100%;
}

.app-select-native {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none;
}

.app-select__button,
.app-select__search {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    background: var(--surface);
    font: inherit;
    font-size: .82rem;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.02);
    transition: var(--transition-fast);
}

.app-select__button {
    position: relative;
    padding: 8px 34px 8px 12px;
    overflow: hidden;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.app-select__button::after {
    position: absolute;
    top: 50%;
    right: 10px;
    content: "";
    border: 4px solid transparent;
    border-top-color: var(--text-muted);
    transform: translateY(-20%);
}

.app-select__menu {
    position: absolute;
    z-index: 90;
    top: calc(100% + 5px);
    right: 0;
    left: 0;
    display: none;
    min-width: 220px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow-md);
}

.app-select.is-open .app-select__menu {
    display: block;
}

.app-select__menu--portal {
    position: fixed;
    z-index: 1300;
    display: block;
    overflow: hidden;
}

.app-select__menu--portal .app-select__options {
    max-height: min(220px, calc(100% - 52px));
}

.app-select__menu--room.app-select__menu--portal .app-select__options {
    max-height: min(360px, calc(100dvh - 170px));
}

.app-select__search {
    margin-bottom: 5px;
    min-height: 38px;
    padding: 7px 10px;
    background: var(--surface-soft);
}

.app-select__options {
    display: grid;
    gap: 2px;
    max-height: 220px;
    overflow-y: auto;
}

.app-select__option {
    padding: 7px 9px;
    border: 0;
    border-radius: 9px;
    color: var(--text);
    background: transparent;
    font: inherit;
    font-size: .78rem;
    text-align: left;
    cursor: pointer;
}

.app-select__option:hover,
.app-select__option[aria-selected="true"] {
    background: var(--surface-soft);
    color: var(--primary-700);
}

.app-select__button:hover {
    border-color: var(--border-strong);
}

.app-select.is-open .app-select__button,
.app-select__button:focus-visible,
.app-select__search:focus {
    outline: none;
    border-color: var(--primary-400);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary-500) 14%, transparent);
}

html[data-theme="dark"] .app-select__option:hover,
html[data-theme="dark"] .app-select__option[aria-selected="true"] {
    color: #93c5fd;
}

select.app-input,
select.form-select,
.app-select__button,
.app-select__search {
    min-height: 38px;
    padding-top: 7px;
    padding-bottom: 7px;
    font-size: .84rem;
    line-height: 1.35;
}

.app-select__button {
    padding-right: 34px;
    padding-left: 10px;
}

.app-select__option {
    min-height: 30px;
    padding: 6px 8px;
    font-size: .84rem;
    line-height: 1.35;
}

.app-modal select.app-input,
.app-modal select.form-select,
.app-modal .app-select__button {
    min-height: 38px;
    font-size: .84rem;
}

.app-switch-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.app-switch {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-soft);
    transition: border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}

.app-switch:hover {
    border-color: var(--border-strong);
    background: var(--surface);
}

.app-switch:has(input:checked) {
    border-color: color-mix(in srgb, var(--primary-500) 42%, var(--border));
    background: color-mix(in srgb, var(--primary-500) 8%, var(--surface));
    box-shadow: inset 3px 0 0 var(--primary-500);
}

.app-switch input[type="checkbox"] {
    position: relative;
    flex: 0 0 auto;
    width: 34px;
    height: 19px;
    margin: 0;
    appearance: none;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    background: var(--surface);
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.app-switch input[type="checkbox"]::before {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 13px;
    height: 13px;
    content: "";
    border-radius: 50%;
    background: var(--text-muted);
    transition: transform var(--transition-fast), background var(--transition-fast);
}

.app-switch input[type="checkbox"]:checked {
    border-color: var(--primary-600);
    background: var(--primary-600);
}

.app-switch input[type="checkbox"]:checked::before {
    background: #fff;
    transform: translateX(15px);
}

.app-switch input[type="checkbox"]:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--primary-500) 28%, transparent);
    outline-offset: 2px;
}

.app-switch label {
    margin: 0;
    color: var(--text);
    font-size: .8rem;
    font-weight: 600;
    line-height: 1.25;
    cursor: pointer;
}

.app-switch--role label::after,
.app-switch--state label::after {
    display: block;
    margin-top: 2px;
    color: var(--text-muted);
    font-size: .68rem;
    font-weight: 500;
}

.app-switch--role label::after {
    content: "Autorisation applicative";
}

.app-switch--state label::after {
    content: "Paramètre du compte";
}

.app-switch-card > .app-switch {
    display: inline-flex;
    align-items: center;
    width: 46px;
    height: 26px;
    min-height: 0;
    padding: 0;
    gap: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    box-shadow: none;
}

.app-switch-card > .app-switch:hover,
.app-switch-card > .app-switch:has(input:checked) {
    border: 0;
    background: transparent;
    box-shadow: none;
}

.app-switch-card > .app-switch > .app-switch__input[type="checkbox"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.app-switch-card > .app-switch > .app-switch__slider {
    width: 46px;
    height: 26px;
}

.app-switch-card > .app-switch > .app-switch__slider::before {
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
}

.app-switch-card > .app-switch > .app-switch__input:checked + .app-switch__slider::before {
    transform: translateX(20px);
}

.app-switch-card > .app-switch > .app-switch__input:disabled + .app-switch__slider {
    opacity: .72;
    cursor: not-allowed;
}

.app-account-options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 10px;
}

.app-account-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-height: 66px;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-soft);
    transition: border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}

.app-account-option:hover {
    border-color: var(--border-strong);
    background: var(--surface);
}

.app-account-option:has(input:checked) {
    border-color: color-mix(in srgb, var(--primary-500) 42%, var(--border));
    background: color-mix(in srgb, var(--primary-500) 7%, var(--surface));
    box-shadow: inset 3px 0 0 var(--primary-500);
}

.app-account-option__content {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.app-account-option__label {
    color: var(--text);
    font-size: .8rem;
    font-weight: 750;
    line-height: 1.25;
    cursor: pointer;
}

.app-account-option__desc {
    color: var(--text-muted);
    font-size: .7rem;
    line-height: 1.3;
}

.app-account-option__toggle {
    position: relative;
    flex: 0 0 auto;
    width: 34px;
    height: 19px;
    margin: 0;
    appearance: none;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    background: var(--surface);
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.app-account-option__toggle::before {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 13px;
    height: 13px;
    content: "";
    border-radius: 50%;
    background: var(--text-muted);
    transition: transform var(--transition-fast), background var(--transition-fast);
}

.app-account-option__toggle:checked {
    border-color: var(--primary-600);
    background: var(--primary-600);
}

.app-account-option__toggle:checked::before {
    background: #fff;
    transform: translateX(15px);
}

.app-account-option__toggle:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--primary-500) 28%, transparent);
    outline-offset: 2px;
}

.app-account-detail-grid,
.app-account-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
}

.app-account-detail,
.app-account-summary {
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-soft);
}

.app-account-detail {
    display: grid;
    gap: 5px;
}

.app-account-detail__label,
.app-account-summary__label {
    display: block;
    color: var(--text-muted);
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.app-account-detail strong,
.app-account-summary strong {
    overflow-wrap: anywhere;
    font-size: .82rem;
}

.app-account-summary {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-account-summary > :nth-child(2) {
    min-width: 0;
    flex: 1;
}

.app-account-summary__icon {
    display: grid;
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    place-items: center;
    border-radius: 7px;
    color: var(--primary-600);
    background: color-mix(in srgb, var(--primary-500) 10%, var(--surface));
}

.app-account-summary__badges {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 5px;
}

.timetable-filter-card {
    margin-bottom: 12px;
}

.timetable-filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
    align-items: end;
}

.timetable-filter-actions {
    display: flex;
    align-self: end;
    margin-bottom: 8px;
    gap: 6px;
    align-items: center;
    min-height: 44px;
    min-width: 136px;
}

.timetable-filter-actions .btn {
    min-height: 40px;
}

.timetable-filter-reset {
    display: inline-grid;
    width: 40px;
    min-width: 40px;
    padding-inline: 0;
    place-items: center;
}

.timetable-card {
    overflow: hidden;
}

.timetable-card-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.timetable-legend {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 8px 10px;
    overflow-x: auto;
    border-top: 1px solid var(--border);
    background: var(--surface-soft);
    scrollbar-width: thin;
}

.timetable-legend__label {
    flex: 0 0 auto;
    color: var(--text-muted);
    font-size: .68rem;
    font-weight: 800;
    text-transform: uppercase;
}

.timetable-legend__item {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 5px;
    padding: 4px 7px;
    border: 1px solid var(--group-border);
    border-radius: 999px;
    color: var(--text);
    background: var(--group-bg);
    font-size: .68rem;
    font-weight: 700;
}

.timetable-legend__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--group-accent);
}

.timetable-matrix-wrap {
    overflow-x: auto;
    background: var(--surface);
}

.timetable-room-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.timetable-display-options,
.timetable-zoom-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.timetable-display-options__label,
.timetable-display-options label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 28px;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text);
    background: var(--surface-soft);
    font-size: .7rem;
    font-weight: 750;
}

.timetable-display-options__label {
    color: var(--text-muted);
    text-transform: uppercase;
}

.timetable-display-options input {
    width: 14px;
    height: 14px;
    accent-color: var(--primary-600);
}

.timetable-zoom-controls .btn {
    min-height: 30px;
    padding: 5px 8px;
}

.timetable-zoom-value {
    display: inline-grid;
    min-width: 48px;
    min-height: 28px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text);
    background: var(--surface-soft);
    font-size: .7rem;
    font-weight: 850;
}

.timetable-room-wrap {
    --timetable-zoom: 1;
    max-height: min(68vh, 720px);
    overflow: auto;
    background: var(--surface);
}

.timetable-room-matrix {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.timetable-room-matrix th,
.timetable-room-matrix td {
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.timetable-room-matrix thead th {
    position: sticky;
    z-index: 8;
    min-width: calc(108px * var(--timetable-zoom));
    padding: calc(7px * var(--timetable-zoom)) calc(6px * var(--timetable-zoom));
    color: var(--text);
    background: var(--surface-soft);
    font-size: calc(.72rem * var(--timetable-zoom));
    text-align: center;
}

.timetable-room-matrix thead tr:first-child th {
    top: 0;
}

.timetable-room-matrix thead tr:nth-child(2) th {
    top: calc(31px * var(--timetable-zoom));
}

.timetable-room-matrix thead th strong,
.timetable-room-matrix thead th span {
    display: block;
}

.timetable-room-matrix thead th span {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: calc(.64rem * var(--timetable-zoom));
}

.timetable-room-matrix__room {
    position: sticky;
    left: 0;
    z-index: 7;
    background: var(--surface-soft);
}

.timetable-room-matrix__day-group {
    border-left: 1px solid var(--border);
    background: color-mix(in srgb, var(--primary-500) 6%, var(--surface-soft)) !important;
    color: var(--text);
    font-size: calc(.73rem * var(--timetable-zoom));
    font-weight: 850;
}

.timetable-room-matrix__slot {
    font-size: calc(.68rem * var(--timetable-zoom));
}

.timetable-room-matrix__room {
    width: calc(108px * var(--timetable-zoom));
    min-width: calc(108px * var(--timetable-zoom));
    max-width: calc(108px * var(--timetable-zoom));
    padding: calc(7px * var(--timetable-zoom));
    color: var(--text);
    font-size: calc(.72rem * var(--timetable-zoom));
    text-align: left;
    box-shadow: 1px 0 0 var(--border);
}

.timetable-room-matrix thead .timetable-room-matrix__room {
    z-index: 10;
    top: 0;
}

.timetable-room-matrix__room strong,
.timetable-room-matrix__room span {
    display: block;
}

.timetable-room-matrix__room span {
    margin-top: 1px;
    color: var(--text-muted);
    font-size: calc(.61rem * var(--timetable-zoom));
    font-weight: 650;
}

.timetable-room-cell {
    width: calc(118px * var(--timetable-zoom));
    min-width: calc(118px * var(--timetable-zoom));
    height: calc(64px * var(--timetable-zoom));
    padding: calc(3px * var(--timetable-zoom));
    vertical-align: top;
    background: var(--surface);
}

.timetable-room-cell--free {
    background: color-mix(in srgb, var(--surface-soft) 68%, transparent);
}

.timetable-room-cell.is-drop-target {
    background: color-mix(in srgb, var(--primary-500) 10%, var(--surface));
    box-shadow: inset 0 0 0 2px var(--primary-500);
}

.timetable-room-cell--conflict {
    background: color-mix(in srgb, #dc2626 7%, var(--surface));
    box-shadow: inset 0 0 0 2px color-mix(in srgb, #dc2626 65%, var(--border));
}

.timetable-room-conflict-chip {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 2px 5px;
    align-items: center;
    margin-bottom: calc(3px * var(--timetable-zoom));
    padding: calc(4px * var(--timetable-zoom)) calc(5px * var(--timetable-zoom));
    border: 1px solid color-mix(in srgb, #dc2626 48%, var(--border));
    border-radius: 7px;
    color: #b91c1c;
    background: color-mix(in srgb, #dc2626 9%, var(--surface));
    font-size: calc(.6rem * var(--timetable-zoom));
    font-weight: 850;
}

.timetable-room-conflict-chip small {
    grid-column: 2;
    color: var(--text-muted);
    font-size: calc(.56rem * var(--timetable-zoom));
    font-weight: 750;
}

.timetable-room-entry {
    position: relative;
    display: grid;
    gap: calc(1px * var(--timetable-zoom));
    min-height: calc(56px * var(--timetable-zoom));
    padding: calc(5px * var(--timetable-zoom)) calc(21px * var(--timetable-zoom)) calc(5px * var(--timetable-zoom)) calc(7px * var(--timetable-zoom));
    border: 1px solid var(--group-border, color-mix(in srgb, var(--primary-500) 32%, var(--border)));
    border-radius: 7px;
    background: var(--group-bg, color-mix(in srgb, var(--primary-500) 7%, var(--surface)));
    box-shadow: inset 3px 0 0 var(--group-accent, var(--primary-500));
    cursor: pointer;
}

.timetable-room-entry + .timetable-room-entry {
    margin-top: calc(3px * var(--timetable-zoom));
}

.timetable-room-entry[draggable="true"] {
    cursor: grab;
}

.timetable-room-entry strong,
.timetable-room-entry span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.timetable-room-entry strong {
    color: var(--text);
    font-size: calc(.68rem * var(--timetable-zoom));
    line-height: 1.12;
}

.timetable-room-entry span {
    color: var(--text-muted);
    font-size: calc(.61rem * var(--timetable-zoom));
    line-height: 1.1;
}

.timetable-room-entry .timetable-room-entry__groups {
    display: flex;
    align-items: flex-start;
    gap: 4px;
    overflow: visible;
    white-space: normal;
}

.timetable-room-entry__groups-list {
    display: grid;
    gap: 1px;
    min-width: 0;
}

.timetable-room-entry__groups-list span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.timetable-room-cell__add,
.timetable-room-cell__free {
    display: grid;
    width: 100%;
    min-height: calc(56px * var(--timetable-zoom));
    place-items: center;
    border-radius: 7px;
    color: var(--text-muted);
    font-size: calc(.66rem * var(--timetable-zoom));
    font-weight: 750;
}

.timetable-room-cell__add {
    border: 1px dashed var(--border-strong);
    background: transparent;
    cursor: pointer;
}

.timetable-room-cell__add:hover {
    border-color: var(--primary-500);
    color: var(--primary-600);
    background: color-mix(in srgb, var(--primary-500) 6%, transparent);
}

.timetable-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.timetable-detail-grid div {
    display: grid;
    gap: 4px;
    min-height: 58px;
    padding: 9px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-soft);
}

.timetable-detail-grid span {
    color: var(--text-muted);
    font-size: .66rem;
    font-weight: 800;
    text-transform: uppercase;
}

.timetable-detail-grid strong {
    overflow-wrap: anywhere;
    color: var(--text);
    font-size: .82rem;
}

.timetable-detail-conflict {
    display: flex;
    gap: 9px;
    align-items: flex-start;
    margin-bottom: 10px;
    padding: 10px;
    border: 1px solid color-mix(in srgb, #dc2626 48%, var(--border));
    border-radius: 8px;
    color: #b91c1c;
    background: color-mix(in srgb, #dc2626 8%, var(--surface));
}

.timetable-detail-conflict[hidden] {
    display: none;
}

.timetable-detail-conflict strong,
.timetable-detail-conflict span {
    display: block;
}

.timetable-detail-conflict strong {
    color: inherit;
    font-size: .82rem;
}

.timetable-detail-conflict span {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: .72rem;
    font-weight: 700;
}

.timetable-detail-session-list {
    display: grid;
    gap: 8px;
}

.timetable-detail-session-list[hidden] {
    display: none;
}

.timetable-detail-session {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    padding: 9px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-soft);
}

.timetable-detail-session__main {
    display: grid;
    min-width: 0;
    gap: 2px;
}

.timetable-detail-session__actions {
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 7px;
}

.timetable-detail-session strong,
.timetable-detail-session span,
.timetable-detail-session small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.timetable-detail-session strong {
    color: var(--text);
    font-size: .78rem;
}

.timetable-detail-session span,
.timetable-detail-session small {
    color: var(--text-muted);
    font-size: .68rem;
    font-weight: 700;
}

html[data-timetable-show-module="0"] [data-entry-part="module"],
html[data-timetable-show-teacher="0"] [data-entry-part="teacher"],
html[data-timetable-show-group="0"] [data-entry-part="group"] {
    display: none;
}

.timetable-card.is-room-fullscreen {
    position: fixed;
    z-index: 1200;
    inset: 8px;
    display: flex;
    flex-direction: column;
    border-radius: 10px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.timetable-card.is-room-fullscreen .ph-card__header,
.timetable-card:fullscreen .ph-card__header {
    flex: 0 0 auto;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.timetable-card.is-room-fullscreen .ph-card__title,
.timetable-card:fullscreen .ph-card__title {
    font-size: .95rem;
}

.timetable-card.is-room-fullscreen .app-section-note,
.timetable-card:fullscreen .app-section-note {
    margin-top: 2px;
    font-size: .7rem;
}

.timetable-card.is-room-fullscreen .timetable-room-toolbar,
.timetable-card:fullscreen .timetable-room-toolbar {
    position: relative;
    z-index: 12;
    flex: 0 0 auto;
    padding: 8px 10px;
    border-top: 0;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    box-shadow: 0 1px 0 var(--border);
}

.timetable-card.is-room-fullscreen .timetable-display-options,
.timetable-card:fullscreen .timetable-display-options,
.timetable-card.is-room-fullscreen .timetable-zoom-controls,
.timetable-card:fullscreen .timetable-zoom-controls {
    gap: 5px;
}

.timetable-card.is-room-fullscreen .timetable-display-options__label,
.timetable-card.is-room-fullscreen .timetable-display-options label,
.timetable-card.is-room-fullscreen .timetable-zoom-value,
.timetable-card:fullscreen .timetable-display-options__label,
.timetable-card:fullscreen .timetable-display-options label,
.timetable-card:fullscreen .timetable-zoom-value {
    min-height: 26px;
    padding: 4px 7px;
    font-size: .66rem;
}

.timetable-card.is-room-fullscreen .timetable-zoom-controls .btn,
.timetable-card:fullscreen .timetable-zoom-controls .btn {
    min-height: 28px;
    padding: 4px 8px;
}

.timetable-card.is-room-fullscreen .timetable-room-wrap {
    max-height: none;
    flex: 1 1 auto;
    min-height: 0;
}

.timetable-card:fullscreen {
    display: flex;
    flex-direction: column;
    padding: 0;
    background: var(--surface);
    overflow: hidden;
}

.timetable-card:fullscreen .timetable-room-wrap {
    max-height: none;
    flex: 1 1 auto;
    min-height: 0;
}

body.timetable-fullscreen-active {
    overflow: hidden;
}

.timetable-matrix {
    width: 100%;
    min-width: 980px;
    border-collapse: collapse;
    table-layout: fixed;
}

.filiere-groups-timetable {
    display: grid;
    gap: 10px;
    padding: 10px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.filiere-group-block {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.filiere-group-block__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 10px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-soft);
}

.filiere-group-block__header h3,
.filiere-group-block__header p {
    margin: 0;
}

.filiere-group-block__header h3 {
    color: var(--text);
    font-size: .86rem;
    font-weight: 850;
}

.filiere-group-block__header p {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: .7rem;
    font-weight: 700;
}

.timetable-matrix-wrap--compact {
    overflow-x: auto;
    overflow-y: visible;
}

.timetable-matrix--group-compact {
    min-width: 760px;
}

.timetable-matrix--group-compact .timetable-cell {
    height: 64px;
    padding: 3px;
}

.timetable-matrix--group-compact .timetable-entry {
    min-height: 68px;
    padding: 5px 20px 5px 6px;
}

.timetable-matrix--group-compact .timetable-entry strong {
    font-size: .68rem;
}

.timetable-matrix--group-compact .timetable-entry span {
    font-size: .6rem;
}

.timetable-matrix th,
.timetable-matrix td {
    border: 1px solid var(--border);
}

.timetable-matrix thead th {
    padding: 8px 6px;
    color: var(--text);
    background: var(--surface-soft);
    font-size: .75rem;
    text-align: center;
}

.timetable-matrix thead span {
    display: block;
    margin-top: 2px;
    color: var(--text-muted);
    font-size: .68rem;
}

.timetable-matrix__day {
    width: 92px;
    padding: 8px;
    color: var(--text);
    background: var(--surface-soft);
    font-size: .75rem;
    text-align: left;
}

.timetable-cell {
    position: relative;
    min-width: 145px;
    height: 78px;
    padding: 4px;
    vertical-align: top;
    background: var(--surface);
    transition: background var(--transition-fast), box-shadow var(--transition-fast);
}

.timetable-cell--empty {
    background: color-mix(in srgb, var(--surface-soft) 75%, transparent);
}

.timetable-cell.is-drop-target {
    background: color-mix(in srgb, var(--primary-500) 10%, var(--surface));
    box-shadow: inset 0 0 0 2px var(--primary-500);
}

.timetable-cell__add {
    display: grid;
    width: 100%;
    height: 100%;
    min-height: 68px;
    place-items: center;
    border: 1px dashed var(--border-strong);
    border-radius: 7px;
    color: var(--text-muted);
    background: transparent;
    cursor: pointer;
    transition: border-color var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
}

.timetable-cell__add:hover {
    border-color: var(--primary-500);
    color: var(--primary-600);
    background: color-mix(in srgb, var(--primary-500) 6%, transparent);
}

.timetable-entry {
    position: relative;
    display: grid;
    gap: 2px;
    min-height: 68px;
    padding: 6px 22px 6px 7px;
    border: 1px solid var(--group-border, color-mix(in srgb, var(--primary-500) 32%, var(--border)));
    border-radius: 7px;
    background: var(--group-bg, color-mix(in srgb, var(--primary-500) 7%, var(--surface)));
    box-shadow: inset 3px 0 0 var(--group-accent, var(--primary-500));
    cursor: grab;
}

.timetable-entry + .timetable-entry {
    margin-top: 5px;
}

.timetable-entry.is-dragging {
    opacity: .55;
}

.timetable-entry strong {
    overflow-wrap: anywhere;
    color: var(--text);
    font-size: .74rem;
    line-height: 1.25;
}

.timetable-entry span {
    overflow-wrap: anywhere;
    color: var(--text-muted);
    font-size: .66rem;
    line-height: 1.25;
}

.timetable-entry .timetable-entry__teacher-missing {
    color: #dc2626;
    font-weight: 800;
}

.timetable-entry__edit {
    position: absolute;
    top: 5px;
    right: 5px;
    border: 0;
    color: var(--group-accent, var(--primary-600));
    background: transparent;
    cursor: pointer;
}

.timetable-group-color--0 {
    --group-accent: #2563eb;
    --group-border: color-mix(in srgb, #2563eb 38%, var(--border));
    --group-bg: color-mix(in srgb, #2563eb 8%, var(--surface));
}

.timetable-group-color--1 {
    --group-accent: #0f766e;
    --group-border: color-mix(in srgb, #0f766e 38%, var(--border));
    --group-bg: color-mix(in srgb, #0f766e 8%, var(--surface));
}

.timetable-group-color--2 {
    --group-accent: #7c3aed;
    --group-border: color-mix(in srgb, #7c3aed 38%, var(--border));
    --group-bg: color-mix(in srgb, #7c3aed 8%, var(--surface));
}

.timetable-group-color--3 {
    --group-accent: #b45309;
    --group-border: color-mix(in srgb, #b45309 38%, var(--border));
    --group-bg: color-mix(in srgb, #b45309 8%, var(--surface));
}

.timetable-group-color--4 {
    --group-accent: #be123c;
    --group-border: color-mix(in srgb, #be123c 38%, var(--border));
    --group-bg: color-mix(in srgb, #be123c 8%, var(--surface));
}

.timetable-group-color--5 {
    --group-accent: #0369a1;
    --group-border: color-mix(in srgb, #0369a1 38%, var(--border));
    --group-bg: color-mix(in srgb, #0369a1 8%, var(--surface));
}

.timetable-group-color--6 {
    --group-accent: #4d7c0f;
    --group-border: color-mix(in srgb, #4d7c0f 38%, var(--border));
    --group-bg: color-mix(in srgb, #4d7c0f 8%, var(--surface));
}

.ph-toast-container {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 1000;
    display: grid;
    width: min(380px, calc(100vw - 28px));
    gap: 8px;
    pointer-events: none;
}

.ph-toast {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 9px;
    align-items: center;
    padding: 11px 12px;
    border: 1px solid var(--toast-border);
    border-radius: 8px;
    color: var(--text);
    background: color-mix(in srgb, var(--toast-accent) 7%, var(--surface));
    box-shadow: var(--shadow-lg);
    opacity: 0;
    pointer-events: auto;
    transform: translateX(18px);
    transition: opacity 180ms ease, transform 180ms ease;
}

.ph-toast.is-visible {
    opacity: 1;
    transform: translateX(0);
}

.ph-toast.is-leaving {
    opacity: 0;
    transform: translateX(18px);
}

.ph-toast--success {
    --toast-accent: #15803d;
    --toast-border: color-mix(in srgb, #15803d 42%, var(--border));
}

.ph-toast--error {
    --toast-accent: #dc2626;
    --toast-border: color-mix(in srgb, #dc2626 42%, var(--border));
}

.ph-toast--warning {
    --toast-accent: #b45309;
    --toast-border: color-mix(in srgb, #b45309 42%, var(--border));
}

.ph-toast--info {
    --toast-accent: #2563eb;
    --toast-border: color-mix(in srgb, #2563eb 42%, var(--border));
}

.ph-toast__icon {
    color: var(--toast-accent);
    font-size: 1rem;
}

.ph-toast__message {
    overflow-wrap: anywhere;
    font-size: .76rem;
    font-weight: 650;
    line-height: 1.4;
}

.ph-toast__close {
    display: grid;
    width: 25px;
    height: 25px;
    place-items: center;
    border: 0;
    border-radius: 6px;
    color: var(--text-muted);
    background: transparent;
    cursor: pointer;
}

.ph-toast__close:hover {
    color: var(--text);
    background: color-mix(in srgb, var(--toast-accent) 10%, transparent);
}

.app-modal {
    width: min(680px, calc(100vw - 24px));
    padding: 0;
    overflow: visible;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

.app-modal::backdrop {
    background: rgba(15, 23, 42, .55);
}

.app-modal .app-form {
    max-height: calc(100dvh - 24px);
    padding: 14px;
    overflow-y: auto;
}

.app-modal__header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

@media (max-width: 720px) {
    .timetable-filter-grid {
        grid-template-columns: 1fr;
    }

    .timetable-filter-actions {
        justify-content: flex-end;
        width: 100%;
        margin-bottom: 0;
    }

    .timetable-filter-actions .btn:first-child {
        flex: 1 1 auto;
        justify-content: center;
    }

    .timetable-matrix {
        min-width: 760px;
    }

    .timetable-matrix thead th,
    .timetable-matrix__day {
        padding: 6px 5px;
    }

    .timetable-matrix__day {
        width: 74px;
    }

    .timetable-cell {
        min-width: 118px;
        height: 72px;
        padding: 3px;
    }

    .timetable-cell__add,
    .timetable-entry {
        min-height: 62px;
    }

    .timetable-entry {
        padding: 5px 20px 5px 6px;
    }

    .timetable-entry strong {
        font-size: .7rem;
    }

    .timetable-entry span {
        font-size: .62rem;
    }

    .timetable-room-wrap {
        max-height: 70vh;
    }

    .timetable-room-toolbar {
        align-items: stretch;
        gap: 6px;
        padding: 7px;
    }

    .timetable-card.is-room-fullscreen {
        inset: 0;
        border-radius: 0;
    }

    .timetable-card.is-room-fullscreen .ph-card__header,
    .timetable-card:fullscreen .ph-card__header {
        align-items: flex-start;
        gap: 6px;
        padding: 8px;
    }

    .timetable-card.is-room-fullscreen .ph-card__actions,
    .timetable-card:fullscreen .ph-card__actions {
        width: 100%;
        justify-content: flex-end;
    }

    .timetable-card.is-room-fullscreen .timetable-room-toolbar,
    .timetable-card:fullscreen .timetable-room-toolbar {
        padding: 7px;
    }

    .timetable-display-options,
    .timetable-zoom-controls {
        width: 100%;
        gap: 5px;
    }

    .timetable-display-options__label,
    .timetable-display-options label,
    .timetable-zoom-value {
        min-height: 25px;
        padding: 4px 6px;
        font-size: .64rem;
    }

    .timetable-zoom-controls .btn {
        min-height: 27px;
        padding: 4px 6px;
        font-size: .66rem;
    }

    .timetable-room-matrix thead th {
        min-width: calc(82px * var(--timetable-zoom));
        padding: calc(4px * var(--timetable-zoom));
        font-size: calc(.62rem * var(--timetable-zoom));
    }

    .timetable-room-matrix thead tr:nth-child(2) th {
        top: calc(25px * var(--timetable-zoom));
    }

    .timetable-room-matrix thead th span {
        font-size: calc(.55rem * var(--timetable-zoom));
    }

    .timetable-room-matrix__room {
        width: calc(70px * var(--timetable-zoom));
        min-width: calc(70px * var(--timetable-zoom));
        max-width: calc(70px * var(--timetable-zoom));
        padding: calc(4px * var(--timetable-zoom));
        font-size: calc(.62rem * var(--timetable-zoom));
    }

    .timetable-room-matrix__room span {
        font-size: calc(.52rem * var(--timetable-zoom));
    }

    .timetable-room-cell {
        width: calc(86px * var(--timetable-zoom));
        min-width: calc(86px * var(--timetable-zoom));
        height: calc(42px * var(--timetable-zoom));
        padding: calc(2px * var(--timetable-zoom));
    }

    .timetable-room-entry,
    .timetable-room-cell__add,
    .timetable-room-cell__free {
        min-height: calc(34px * var(--timetable-zoom));
    }

    .timetable-room-entry {
        padding: calc(3px * var(--timetable-zoom)) calc(16px * var(--timetable-zoom)) calc(3px * var(--timetable-zoom)) calc(5px * var(--timetable-zoom));
        border-radius: 6px;
    }

    .timetable-room-entry strong {
        font-size: calc(.58rem * var(--timetable-zoom));
        line-height: 1.05;
    }

    .timetable-room-entry span {
        font-size: calc(.51rem * var(--timetable-zoom));
        line-height: 1.05;
    }

    .timetable-room-entry span i {
        display: none;
    }

    .timetable-room-conflict-chip {
        grid-template-columns: auto 1fr;
        padding: 2px 4px;
        font-size: .52rem;
    }

    .timetable-room-conflict-chip small {
        display: none;
    }

    .timetable-entry {
        min-height: 44px;
        padding: 4px 18px 4px 6px;
        gap: 1px;
    }

    .timetable-entry strong {
        font-size: .62rem;
        line-height: 1.08;
    }

    .timetable-entry span {
        font-size: .54rem;
        line-height: 1.08;
    }

    .timetable-entry span i {
        display: none;
    }

    .timetable-cell {
        height: 52px;
        padding: 3px;
    }

    .timetable-cell__add {
        min-height: 44px;
    }

    .filiere-groups-timetable {
        gap: 8px;
        padding: 8px;
    }

    .filiere-group-block__header {
        align-items: flex-start;
        flex-direction: column;
        gap: 6px;
        padding: 8px;
    }

    .timetable-matrix-wrap--compact {
        overflow-x: auto;
        overflow-y: visible;
    }

    .timetable-matrix--group-compact {
        min-width: 620px;
    }

    .timetable-matrix--group-compact .timetable-cell {
        height: 50px;
    }

    .timetable-detail-grid {
        grid-template-columns: 1fr;
    }

    .timetable-detail-session {
        align-items: stretch;
        flex-direction: column;
    }

    .app-modal {
        width: min(680px, calc(100vw - 12px));
        max-height: calc(100dvh - 12px);
    }

    .app-modal .app-form {
        padding: 10px;
    }

    .app-modal__header {
        gap: 8px;
        margin-bottom: 10px;
        padding-bottom: 8px;
    }
}

.ph-table-wrap--with-sync-scroll {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.ph-table-wrap--with-sync-scroll::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

.ph-table-wrap--standard::-webkit-scrollbar {
    width: 9px;
}

.ph-table-wrap--standard::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: var(--border-strong);
}

.ph-table--standard {
    width: max-content;
    min-width: 100%;
    table-layout: auto;
}

.ph-table--standard thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface);
    box-shadow: inset 0 -1px 0 var(--border);
}

.ph-xscroll {
    display: none;
    overflow-x: auto;
    overflow-y: hidden;
    height: 12px;
    border-inline: 1px solid var(--border);
    background: var(--surface-soft);
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

.ph-xscroll--top {
    border-top: 1px solid var(--border);
    border-bottom: 0;
    border-radius: 0;
}

.ph-xscroll--bottom {
    border-top: 0;
    border-bottom: 1px solid var(--border);
    border-radius: 0 0 10px 10px;
}

.ph-xscroll__inner {
    height: 1px;
}

.ph-xscroll::-webkit-scrollbar {
    height: 10px;
}

.ph-xscroll::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: var(--border-strong);
}

.ph-xscroll::-webkit-scrollbar-track {
    background: transparent;
}

.ph-card--table .ph-table-footer {
    border-top: 0;
}

.ph-card--table .ph-columns__button {
    border-color: color-mix(in srgb, var(--primary-500) 30%, var(--border));
    color: var(--primary-700);
    background: color-mix(in srgb, var(--primary-50) 70%, var(--surface));
    font-weight: 800;
}

.ph-card--table .ph-columns {
    flex: 0 0 auto;
    z-index: 20;
}

html[data-theme="dark"] .ph-table--standard thead th {
    background: var(--surface);
}

html[data-theme="dark"] .ph-card--table .ph-columns__button {
    color: var(--primary-300);
    background: color-mix(in srgb, var(--primary-800) 25%, var(--surface));
}

/* =========================
   ATTENDANCE WORKFLOW
========================= */
.ph-badge--warning {
    color: #92400e;
    background: #fef3c7;
}

html[data-theme="dark"] .ph-badge--warning {
    color: #fde68a;
    background: rgba(245, 158, 11, .18);
}

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

.attendance-context-card {
    display: grid;
    gap: 12px;
}

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

.attendance-context-grid > div {
    min-width: 0;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-soft);
}

.attendance-context-label {
    display: block;
    margin-bottom: 3px;
    color: var(--text-muted);
    font-size: .72rem;
    font-weight: 800;
    text-transform: uppercase;
}

.attendance-session-list {
    display: grid;
    gap: 8px;
    padding: 10px;
}

.attendance-session-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    text-decoration: none;
    background: var(--surface);
    transition: var(--transition-fast);
}

.attendance-session-item:hover {
    border-color: color-mix(in srgb, var(--primary-500) 35%, var(--border));
    background: var(--surface-soft);
}

.attendance-session-item > div:first-child > span {
    display: block;
    margin-top: 2px;
    color: var(--text-muted);
    font-size: .78rem;
}

.attendance-entry-table th,
.attendance-entry-table td {
    padding: 8px 10px;
}

.attendance-status-select {
    width: min(180px, 100%);
}

.attendance-action-bar,
.attendance-save-panel,
.attendance-validate-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.attendance-action-bar {
    margin-top: 14px;
}

.attendance-save-panel,
.attendance-validate-panel {
    margin-top: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
}

.attendance-validate-panel {
    border-color: color-mix(in srgb, var(--primary-500) 30%, var(--border));
    background: color-mix(in srgb, var(--primary-50) 55%, var(--surface));
}

.attendance-save-panel span,
.attendance-validate-panel span {
    display: block;
    margin-top: 2px;
    color: var(--text-muted);
    font-size: .78rem;
}

html[data-theme="dark"] .attendance-validate-panel {
    background: color-mix(in srgb, var(--primary-800) 16%, var(--surface));
}

@media (max-width: 980px) {
    .attendance-summary-grid,
    .attendance-context-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 680px) {
    .attendance-summary-grid,
    .attendance-context-grid {
        grid-template-columns: 1fr;
    }

    .attendance-action-bar,
    .attendance-save-panel,
    .attendance-validate-panel,
    .attendance-session-item {
        align-items: stretch;
        flex-direction: column;
    }
}

.report-filter-grid--wide {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.report-filter-card .app-card__header {
    align-items: flex-end;
    gap: 14px;
}

.report-details-toggle {
    align-self: end;
    margin: 0;
}

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

.dashboard-status-card {
    display: grid;
    gap: 4px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-soft);
}

.dashboard-status-card span {
    color: var(--text-muted);
    font-size: .72rem;
    font-weight: 800;
    text-transform: uppercase;
}

.dashboard-status-card strong {
    color: var(--text);
    font-size: 1.35rem;
    line-height: 1;
}

.ph-card__header--sub {
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: var(--surface-soft);
}

.app-checkbox {
    width: 16px;
    height: 16px;
    accent-color: var(--primary-600);
}

.discipline-export-toolbar {
    align-items: flex-end;
    gap: 14px;
}

.discipline-export-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(150px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

@media (max-width: 760px) {
    .discipline-export-toolbar,
    .discipline-export-toolbar .page-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .discipline-export-fields {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .timetable-room-entry [data-entry-part="teacher"] {
        display: none;
    }

    .timetable-room-cell {
        width: calc(78px * var(--timetable-zoom));
        min-width: calc(78px * var(--timetable-zoom));
    }

    .timetable-room-entry strong {
        font-size: calc(.54rem * var(--timetable-zoom));
    }

    .timetable-room-entry span {
        font-size: calc(.49rem * var(--timetable-zoom));
    }
}

/* =========================
   MOBILE SHELL
========================= */
.app-sidebar-backdrop {
    display: none;
}

.app-user-menu__identity {
    display: grid;
    gap: 2px;
    padding: 7px 9px 9px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}

.app-user-menu__identity span {
    color: var(--text-muted);
    font-size: .66rem;
}

.app-user-menu__identity strong {
    overflow-wrap: anywhere;
    color: var(--text);
    font-size: .75rem;
}

@media (max-width: 1024px) {
    .app-shell.is-sidebar-collapsed {
        --sidebar-width: 224px;
    }

    .app-shell.is-sidebar-collapsed .app-sidebar {
        padding: 14px 12px;
    }

    .app-shell.is-sidebar-collapsed .app-sidebar__brand {
        justify-content: flex-start;
    }

    .app-shell.is-sidebar-collapsed .app-sidebar__brand > div:not(.app-logo),
    .app-shell.is-sidebar-collapsed .app-nav__label,
    .app-shell.is-sidebar-collapsed .app-nav__section,
    .app-shell.is-sidebar-collapsed .app-sidebar-collapse__label {
        position: static;
        width: auto;
        height: auto;
        padding: initial;
        margin: initial;
        overflow: visible;
        clip: auto;
        white-space: normal;
        border: 0;
    }

    .app-shell.is-sidebar-collapsed .app-nav__link,
    .app-shell.is-sidebar-collapsed .app-sidebar-collapse {
        justify-content: flex-start;
        padding: 7px 9px;
    }

    body.sidebar-open {
        overflow: hidden;
    }

    .app-sidebar {
        left: 0;
        transform: translateX(-105%);
        transition: transform var(--transition-base);
    }

    .app-shell.sidebar-open .app-sidebar {
        left: 0;
        transform: translateX(0);
    }

    .app-sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 55;
        display: block;
        border: 0;
        background: rgba(15, 23, 42, .48);
        opacity: 0;
        pointer-events: none;
        transition: opacity var(--transition-base);
    }

    .app-shell.sidebar-open .app-sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }
}

@media (max-width: 680px) {
    .app-main {
        padding: 6px 7px 10px;
    }

    .app-header {
        gap: 6px;
        min-height: 42px;
        padding: 5px 7px;
        border-radius: 10px;
    }

    .app-header__left,
    .app-header__right {
        gap: 5px;
    }

    .app-header__titles {
        max-width: min(48vw, 210px);
    }

    .app-page-title {
        overflow: hidden;
        font-size: .9rem;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .app-page-subtitle {
        display: none;
    }

    .app-user-chip {
        min-height: 30px;
        padding: 3px 6px 3px 3px;
        gap: 4px;
    }

    .app-user-chip__avatar {
        width: 24px;
        height: 24px;
    }

    .app-user-chip__meta {
        display: none;
    }

    .app-user-menu__chevron {
        display: inline-block;
    }

    .app-user-menu__dropdown {
        width: min(230px, calc(100vw - 20px));
    }
}

.report-filter-card {
    gap: 10px;
}

.report-filter-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    padding-top: 2px;
}

.report-filter-actions {
    display: flex;
    align-items: end;
}

.report-filter-actions .btn {
    width: 100%;
}

@media (max-width: 980px) {
    .report-filter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 680px) {
    .report-filter-grid {
        grid-template-columns: 1fr;
    }
}

/* =========================
   ATTENDANCE SHEET
========================= */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.attendance-session-item__actions,
.attendance-sheet-submit-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.attendance-session-item__actions .btn span {
    display: inline;
    margin: 0;
    color: inherit;
    font-size: inherit;
}

.attendance-session-item__actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-width: 92px;
    min-height: 30px;
    padding: 5px 9px;
    justify-content: center;
    line-height: 1;
}

.attendance-session-item__actions .ph-badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    margin: 0;
    line-height: 1;
    white-space: nowrap;
}

.dashboard-list__item .attendance-session-item__actions > .ph-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-width: max-content;
    white-space: nowrap;
}

.dashboard-list__item .attendance-session-item__actions > .ph-badge {
    display: inline-flex;
    min-width: auto;
    gap: 5px;
}

.attendance-sheet-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 270px;
    align-items: start;
    gap: 12px;
}

.attendance-sheet-main,
.attendance-sheet-sidebar {
    display: grid;
    gap: 12px;
}

.attendance-sheet-sidebar {
    position: sticky;
    top: calc(82px + 12px);
    align-self: start;
    max-height: calc(100vh - 104px);
    overflow-y: auto;
    padding-bottom: 2px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

.attendance-entry-table th:last-child,
.attendance-entry-table td:last-child {
    width: 152px;
}

.attendance-status-actions {
    display: flex;
    align-items: center;
    gap: 5px;
}

.attendance-list-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.attendance-bulk-btn {
    border-width: 1px;
    border-style: solid;
    background: var(--surface);
}

.attendance-bulk-btn--present {
    border-color: #16a34a;
    color: #15803d;
}

.attendance-bulk-btn--absent {
    border-color: #ef4444;
    color: #dc2626;
}

.attendance-bulk-btn--late {
    border-color: #f59e0b;
    color: #b45309;
}

.attendance-bulk-btn--present:hover {
    background: #dcfce7;
}

.attendance-bulk-btn--absent:hover {
    background: #fee2e2;
}

.attendance-bulk-btn--late:hover {
    background: #fef3c7;
}

html[data-theme="dark"] .attendance-bulk-btn--present {
    color: #86efac;
}

html[data-theme="dark"] .attendance-bulk-btn--absent {
    color: #fca5a5;
}

html[data-theme="dark"] .attendance-bulk-btn--late {
    color: #fcd34d;
}

html[data-theme="dark"] .attendance-bulk-btn--present:hover {
    background: rgba(22, 163, 74, .2);
}

html[data-theme="dark"] .attendance-bulk-btn--absent:hover {
    background: rgba(239, 68, 68, .2);
}

html[data-theme="dark"] .attendance-bulk-btn--late:hover {
    background: rgba(245, 158, 11, .2);
}

.ph-badge--danger {
    border: 1px solid rgba(239, 68, 68, .24);
    color: #dc2626;
    background: rgba(239, 68, 68, .12);
}

html[data-theme="dark"] .ph-badge--danger {
    color: #fca5a5;
    background: rgba(239, 68, 68, .2);
}

.attendance-status-btn {
    display: inline-grid;
    width: 29px;
    height: 29px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--text-muted);
    background: var(--surface-soft);
    font: inherit;
    font-size: .72rem;
    font-weight: 800;
    cursor: pointer;
    transition: var(--transition-fast);
}

.attendance-status-btn:hover {
    border-color: var(--border-strong);
    color: var(--text);
}

.attendance-status-btn--present.is-active {
    border-color: #16a34a;
    color: #15803d;
    background: #dcfce7;
}

.attendance-status-btn--absent.is-active {
    border-color: #ef4444;
    color: #dc2626;
    background: #fee2e2;
}

.attendance-status-btn--late.is-active {
    border-color: #f59e0b;
    color: #b45309;
    background: #fef3c7;
}

html[data-theme="dark"] .attendance-status-btn--present.is-active {
    color: #86efac;
    background: rgba(22, 163, 74, .2);
}

html[data-theme="dark"] .attendance-status-btn--absent.is-active {
    color: #fca5a5;
    background: rgba(239, 68, 68, .2);
}

html[data-theme="dark"] .attendance-status-btn--late.is-active {
    color: #fcd34d;
    background: rgba(245, 158, 11, .2);
}

.attendance-presence-summary,
.attendance-quick-actions,
.attendance-remarks-card {
    gap: 12px;
}

.attendance-summary-item {
    display: grid;
    gap: 7px;
}

.attendance-summary-item__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: .78rem;
}

.attendance-summary-item__top span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.attendance-summary-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.attendance-summary-dot--success,
.attendance-summary-progress__bar--success {
    background: #22c55e;
}

.attendance-summary-dot--danger,
.attendance-summary-progress__bar--danger {
    background: #ef4444;
}

.attendance-summary-dot--warning,
.attendance-summary-progress__bar--warning {
    background: #f59e0b;
}

.attendance-summary-progress {
    height: 4px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--surface-soft);
}

.attendance-summary-progress__bar {
    display: block;
    height: 100%;
    border-radius: inherit;
    transition: width .2s ease;
}

.attendance-quick-actions .btn {
    justify-content: flex-start;
    width: 100%;
}

.attendance-notes {
    min-height: 86px;
    resize: vertical;
}

.attendance-remarks-text {
    margin: 0;
    color: var(--text);
    font-size: .84rem;
    line-height: 1.65;
}

.attendance-sheet-submit-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 12px;
    padding: 10px 12px;
    border: 1px solid color-mix(in srgb, var(--primary-500) 30%, var(--border));
    border-radius: 12px;
    background: color-mix(in srgb, var(--primary-50) 55%, var(--surface));
}

.attendance-sheet-submit-bar span {
    display: block;
    margin-top: 2px;
    color: inherit;
    font-size: .76rem;
}

html[data-theme="dark"] .attendance-sheet-submit-bar {
    background: color-mix(in srgb, var(--primary-800) 16%, var(--surface));
}

@media (max-width: 980px) {
    .attendance-sheet-layout {
        grid-template-columns: 1fr;
    }

    .attendance-sheet-sidebar {
        position: static;
        max-height: none;
        overflow: visible;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* =========================
   ACCOUNT MENU
========================= */
.app-user-menu {
    position: relative;
}

.app-user-menu > summary {
    list-style: none;
    cursor: pointer;
}

.app-user-menu > summary::-webkit-details-marker {
    display: none;
}

.app-user-menu__chevron {
    color: var(--text-muted);
    font-size: .72rem;
    transition: transform .18s ease;
}

.app-user-menu[open] .app-user-menu__chevron {
    transform: rotate(180deg);
}

.app-user-menu__dropdown {
    position: absolute;
    top: calc(100% + 7px);
    right: 0;
    z-index: 80;
    width: 180px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: var(--shadow-md);
}

.app-user-menu__item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 9px;
    border-radius: 7px;
    color: var(--text);
    font-size: .78rem;
    font-weight: 700;
    text-decoration: none;
}

.app-user-menu__item:hover {
    color: #dc2626;
    background: rgba(239, 68, 68, .08);
}

/* =========================
   LOGIN
========================= */
.login-page {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background: var(--bg);
}

.login-shell {
    display: grid;
    min-height: 100vh;
    grid-template-columns: minmax(330px, 42%) minmax(0, 1fr);
}

.login-brand-panel {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 32px;
    color: #fff;
    background: var(--sidebar-bg);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.login-brand__logo,
.login-card__icon {
    display: grid;
    width: 46px;
    height: 46px;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 12px;
    background: rgba(255, 255, 255, .12);
    font-size: 1.2rem;
}

.login-brand__title {
    font-size: 1.1rem;
    font-weight: 800;
}

.login-brand__subtitle {
    margin-top: 2px;
    color: rgba(255, 255, 255, .68);
    font-size: .78rem;
}

.login-brand-panel__content {
    max-width: 520px;
}

.login-brand-panel__eyebrow {
    display: block;
    margin-bottom: 12px;
    color: #bfdbfe;
    font-size: .72rem;
    font-weight: 800;
    text-transform: uppercase;
}

.login-brand-panel h1 {
    max-width: 540px;
    margin: 0;
    font-size: clamp(1.8rem, 3vw, 2.7rem);
    line-height: 1.12;
}

.login-brand-panel p {
    max-width: 500px;
    margin: 16px 0 0;
    color: rgba(255, 255, 255, .74);
    font-size: .9rem;
    line-height: 1.7;
}

.login-form-panel {
    position: relative;
    display: grid;
    place-items: center;
    padding: 28px;
    background: var(--bg);
}

.login-theme-toggle {
    position: absolute;
    top: 22px;
    right: 24px;
}

.login-card {
    width: min(100%, 440px);
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow-md);
}

.login-card__header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.login-card__icon {
    border-color: var(--border);
    color: var(--primary-700);
    background: var(--surface-soft);
}

.login-card h2,
.login-card p {
    margin: 0;
}

.login-card h2 {
    font-size: 1.1rem;
}

.login-card p {
    margin-top: 3px;
    color: var(--text-muted);
    font-size: .8rem;
}

.login-input-wrap {
    position: relative;
}

.login-input-wrap i {
    position: absolute;
    top: 50%;
    left: 12px;
    color: var(--text-muted);
    transform: translateY(-50%);
}

.login-input-wrap .app-input {
    padding-left: 36px;
}

.login-remember {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 54px;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-muted);
    background: var(--surface-soft);
    font-size: .78rem;
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.login-remember input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    padding: 0;
    opacity: 0;
    pointer-events: none;
}

.login-remember:hover {
    border-color: var(--border-strong);
    background: var(--surface);
}

.login-remember:has(input:checked) {
    border-color: color-mix(in srgb, var(--primary-500) 42%, var(--border));
    background: color-mix(in srgb, var(--primary-500) 8%, var(--surface));
}

.login-remember__control {
    position: relative;
    width: 34px;
    height: 19px;
    flex: 0 0 auto;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    background: var(--surface);
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.login-remember__control::before {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 13px;
    height: 13px;
    content: "";
    border-radius: 50%;
    background: var(--text-muted);
    transition: transform var(--transition-fast), background var(--transition-fast);
}

.login-remember input:checked + .login-remember__control {
    border-color: var(--primary-600);
    background: var(--primary-600);
}

.login-remember input:checked + .login-remember__control::before {
    background: #fff;
    transform: translateX(15px);
}

.login-remember input:focus-visible + .login-remember__control {
    outline: 3px solid color-mix(in srgb, var(--primary-500) 28%, transparent);
    outline-offset: 2px;
}

.login-remember__copy {
    display: grid;
    gap: 1px;
}

.login-remember__copy strong {
    color: var(--text);
    font-size: .78rem;
}

.login-remember__copy small {
    color: var(--text-muted);
    font-size: .7rem;
}

.login-submit {
    justify-content: center;
    width: 100%;
}

.app-logo--image {
    overflow: hidden;
    padding: 3px;
    background: rgba(255, 255, 255, .14);
}

.app-logo--image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.app-institution-brand {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    position: relative;
    width: clamp(132px, 12vw, 168px);
    flex: 0 0 clamp(132px, 12vw, 168px);
    height: 42px;
    padding: 0;
}

.app-institution-brand__image {
    display: block;
    width: 100%;
    max-height: 100%;
    object-fit: contain;
    object-position: right center;
}

.login-brand__logo--image {
    overflow: hidden;
    padding: 3px;
}

.login-brand__logo--image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.login-official-banner {
    width: min(100%, 430px);
    margin-top: 22px;
    padding: 0;
}

.login-official-banner__image {
    display: block;
    width: 100%;
    height: auto;
}

.app-institution-brand__image--dark,
.login-official-banner__image--dark {
    display: none;
}

[data-theme="dark"] .app-institution-brand__image--light,
[data-theme="dark"] .login-official-banner__image--light {
    display: none;
}

[data-theme="dark"] .app-institution-brand__image--dark,
[data-theme="dark"] .login-official-banner__image--dark {
    display: block;
}

[data-theme="dark"] .login-page,
[data-theme="dark"] .login-form-panel {
    background: var(--bg);
}

[data-theme="dark"] .login-card {
    background: var(--surface);
}

@media (max-width: 1180px) {
    .app-institution-brand {
        display: none;
    }
}

@media (max-width: 760px) {
    .login-shell {
        grid-template-columns: 1fr;
    }

    .login-brand-panel {
        min-height: 190px;
        padding: 22px;
    }

    .login-brand-panel__content {
        margin-top: 28px;
    }

    .login-official-banner {
        width: min(100%, 360px);
        margin-top: 18px;
        padding: 7px 10px;
    }

    .login-brand-panel h1 {
        font-size: 1.55rem;
    }

    .login-brand-panel p {
        display: none;
    }
}

@media (max-width: 680px) {
    .attendance-session-item__actions,
    .attendance-sheet-submit-bar,
    .attendance-sheet-submit-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .attendance-sheet-sidebar {
        grid-template-columns: 1fr;
    }

    .attendance-list-toolbar .btn {
        flex: 1 1 100%;
        justify-content: center;
    }
}
