
/* ══════════════════════════════════════════════════════════════════
   PORTAIL DE CONFIGURATION ANNUELLE — DESIGN SYSTEM SAAS
   Inspiré directement des design tokens et règles du panneau Admin
   ══════════════════════════════════════════════════════════════════ */

:root {
    /* Nuances de Bleus (Design System Admin) */
    --blue-950: #0f1f4b;
    --blue-900: #1e3a8a;
    --blue-800: #1e40af; /* Couleur signature sidebar */
    --blue-700: #1d4ed8;
    --blue-600: #2563eb; /* Couleur primaire d'action */
    --blue-500: #3b82f6;
    --blue-400: #60a5fa;
    --blue-300: #93c5fd;
    --blue-200: #bfdbfe;
    --blue-100: #dbeafe;
    --blue-50:  #eff6ff;

    /* Neutres & Ardoise */
    --sl-950: #020617;
    --sl-900: #0f172a;
    --sl-800: #1e293b;
    --sl-700: #334155;
    --sl-600: #475569;
    --sl-500: #64748b;
    --sl-400: #94a3b8;
    --sl-300: #cbd5e1;
    --sl-200: #e2e8f0;
    --sl-150: #edf2f7;
    --sl-100: #f1f5f9;
    --sl-50:  #f8fafc;
    --white:  #ffffff;

    /* Couleurs d'état / Sémantiques */
    --gr-700: #047857;  --gr-600: #059669;  --gr-500: #10b981;  --gr-100: #d1fae5;  --gr-50: #ecfdf5;
    --am-700: #b45309;  --am-600: #d97706;  --am-500: #f59e0b;  --am-100: #fef3c7;  --am-50: #fffbeb;
    --re-700: #b91c1c;  --re-600: #dc2626;  --re-500: #ef4444;  --re-100: #fee2e2;  --re-50: #fef2f2;
    --cy-700: #0369a1;  --cy-600: #0284c7;  --cy-500: #0ea5e9;  --cy-100: #e0f2fe;  --cy-50: #f0f9ff;
    --pu-700: #6d28d9;  --pu-600: #7c3aed;  --pu-500: #8b5cf6;  --pu-100: #ede9fe;  --pu-50: #f5f3ff;

    /* Variables de mise en page */
    --bg-app:         var(--sl-100);
    --bg-sidebar:     var(--blue-800);
    --bg-topbar:      var(--white);
    --bg-surface:     var(--white);
    --bg-card:        var(--white);
    --bg-subtle:      var(--sl-50);
    --border:         var(--sl-200);
    --border-hover:   var(--blue-300);
    --text-main:      var(--sl-900);
    --text-body:      var(--sl-700);
    --text-muted:     var(--sl-500);
    --primary:        var(--blue-600);
    --primary-dark:   var(--blue-700);

    /* Typographie */
    --font-base: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    --font-mono: 'Fira Code', 'SF Mono', Consolas, Monaco, monospace;

    /* Rayons de bordure */
    --r-xs: 4px;
    --r-s:  6px;
    --r:    8px;
    --r-m:  10px;
    --r-l:  12px;
    --r-xl: 16px;
    --r-full: 9999px;

    /* Ombres */
    --sh-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
    --sh-s:  0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
    --sh:    0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -1px rgba(15, 23, 42, 0.04);
    --sh-m:  0 10px 15px -3px rgba(15, 23, 42, 0.1), 0 4px 6px -2px rgba(15, 23, 42, 0.05);
    --sh-l:  0 20px 25px -5px rgba(15, 23, 42, 0.12), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
    --ring:  0 0 0 3px rgba(37, 99, 235, 0.18);
}

/* ══════════════════════════════════════════════════════════════════
   RESET & STRUCTURE DE BASE
   ══════════════════════════════════════════════════════════════════ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    color-scheme: light;
    font-size: 14px;
    background-color: var(--bg-app);
}

body {
    font-family: var(--font-base);
    background-color: var(--bg-app);
    color: var(--text-body);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Accessibilité */
.skip-link {
    position: absolute;
    left: -9999px;
    top: -9999px;
}
.skip-link:focus {
    left: 1rem;
    top: 1rem;
    z-index: 9999;
    background: var(--primary);
    color: #fff;
    padding: 0.5rem 1rem;
    border-radius: var(--r-s);
    font-weight: 600;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-main);
    letter-spacing: -0.015em;
    font-weight: 600;
}

p { color: var(--text-body); }
small, .small { font-size: 0.8rem; color: var(--text-muted); }

code {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    background: var(--blue-50);
    color: var(--blue-700);
    padding: 0.15rem 0.45rem;
    border-radius: var(--r-xs);
    border: 1px solid var(--blue-200);
}

/* Icônes SVG Inline */
.icon {
    display: inline-block;
    width: 1.15rem;
    height: 1.15rem;
    stroke-width: 2;
    stroke: currentColor;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: middle;
    flex-shrink: 0;
}
.icon-xs { width: 0.85rem; height: 0.85rem; }
.icon-sm { width: 1rem; height: 1rem; }
.icon-lg { width: 1.5rem; height: 1.5rem; }

/* Scrollbars personnalisées */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--sl-300) transparent;
}
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--sl-300); border-radius: 999px; }
*::-webkit-scrollbar-thumb:hover { background: var(--sl-400); }

/* ══════════════════════════════════════════════════════════════════
   APP SHELL & BARRE LATÉRALE (SIDEBAR)
   ══════════════════════════════════════════════════════════════════ */
.app-shell {
    display: flex;
    min-height: 100vh;
    position: relative;
}

.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 1030;
    flex-shrink: 0;
    box-shadow: 2px 0 8px rgba(30, 64, 175, 0.25);
    transition: width 0.2s ease, transform 0.25s ease;
    overflow-x: hidden;
}

.sidebar-header {
    padding: 1.1rem 0.875rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 0.5rem;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    text-decoration: none;
    color: #fff;
    min-width: 0;
    flex: 1;
}

.brand-mark {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--r-xs);
    display: grid;
    place-items: center;
    color: #fff;
    flex-shrink: 0;
}

.brand-stack {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    line-height: 1.2;
}

.brand-text {
    font-size: 0.85rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand-env {
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--blue-200);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.sidebar-collapse-btn {
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--r-xs);
    color: rgba(255, 255, 255, 0.8);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.12s;
}
.sidebar-collapse-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* Carte de contexte dans la sidebar */
.sidebar-context-card {
    margin: 0.85rem 0.75rem 0.25rem;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--r-m);
}

.context-label {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--blue-200);
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.2rem;
}

.context-value {
    font-size: 0.85rem;
    font-weight: 700;
    color: #fff;
}

.context-subtext {
    font-size: 0.68rem;
    color: rgba(219, 234, 254, 0.65);
}

/* Liens de navigation */
.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    overflow-y: auto;
}

.sidebar-group {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.sidebar-group-label {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(191, 219, 254, 0.45);
    padding: 0.3rem 0.65rem;
}

.sidebar-links {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.48rem 0.75rem;
    border-radius: var(--r-s);
    color: rgba(219, 234, 254, 0.75);
    font-size: 0.83rem;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.12s, color 0.12s;
    position: relative;
    white-space: nowrap;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.sidebar-link.active {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    font-weight: 600;
}

.sidebar-link.active::after {
    content: '';
    position: absolute;
    left: 0;
    top: 20%;
    bottom: 20%;
    width: 3px;
    background: var(--blue-300);
    border-radius: 999px;
}

.nav-badge {
    margin-left: auto;
    font-size: 0.65rem;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}
.nav-badge.warning {
    background: var(--am-500);
    color: #fff;
}

.nav-count {
    margin-left: auto;
    font-size: 0.72rem;
    color: rgba(219, 234, 254, 0.6);
}

/* Pied de la sidebar */
.sidebar-footer {
    padding: 0.875rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.4rem 0.5rem;
    border-radius: var(--r-s);
    background: rgba(0, 0, 0, 0.15);
}

.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: var(--r-xs);
    background: var(--blue-500);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 0.75rem;
}

.user-meta {
    line-height: 1.25;
}

.user-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: #fff;
}

.user-role {
    font-size: 0.68rem;
    color: var(--blue-200);
}

.btn-logout {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(219, 234, 254, 0.8);
    font-size: 0.78rem;
    font-weight: 500;
    padding: 0.4rem 0.65rem;
    border-radius: var(--r-s);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}
.btn-logout:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.35);
}

/* État réduit (Collapsed) */
.app-shell.sidebar-collapsed .sidebar {
    width: 68px;
}
.app-shell.sidebar-collapsed .brand-text,
.app-shell.sidebar-collapsed .brand-env,
.app-shell.sidebar-collapsed .sidebar-context-card,
.app-shell.sidebar-collapsed .sidebar-group-label,
.app-shell.sidebar-collapsed .link-text,
.app-shell.sidebar-collapsed .nav-badge,
.app-shell.sidebar-collapsed .nav-count,
.app-shell.sidebar-collapsed .user-meta,
.app-shell.sidebar-collapsed .btn-logout span {
    display: none !important;
}
.app-shell.sidebar-collapsed .sidebar-brand {
    justify-content: center;
}
.app-shell.sidebar-collapsed .sidebar-collapse-btn {
    display: inline-flex;
    transform: rotate(180deg);
}
.app-shell.sidebar-collapsed .sidebar-brand {
    display: none;
}
.app-shell.sidebar-collapsed .sidebar-brand-wrapper {
    justify-content: center;
}
.app-shell.sidebar-collapsed .sidebar-link {
    justify-content: center;
    padding: 0.6rem 0;
}

/* ══════════════════════════════════════════════════════════════════
   EN-TÊTE SUPÉRIEUR (TOPBAR)
   ══════════════════════════════════════════════════════════════════ */
.content-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-app);
}

.content-header {
    background: var(--bg-topbar);
    border-bottom: 1px solid var(--border);
    padding: 0.65rem 1.5rem;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--sh-xs);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-width: 0;
}

.sidebar-toggle-btn {
    width: 34px;
    height: 34px;
    background: var(--sl-50);
    border: 1px solid var(--border);
    color: var(--sl-600);
    border-radius: var(--r-s);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.workspace-meta {
    display: flex;
    flex-direction: column;
}

.workspace-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.01em;
}

.workspace-subtitle {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

/* Badge Environnement / Statut */
.env-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    background: var(--blue-50);
    border: 1px solid var(--blue-200);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--blue-800);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--blue-600);
    flex-shrink: 0;
}
.status-dot.warning { background: var(--am-500); }
.status-dot.pulse {
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.5);
    animation: pulse-ring 1.8s infinite;
}

@keyframes pulse-ring {
    0% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(37, 99, 235, 0); }
    100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}

/* Sélecteur d'année scolaire */
.academic-year-switcher {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.2rem 0.4rem 0.2rem 0.75rem;
    background: var(--sl-50);
    border: 1px solid var(--border);
    border-radius: 999px;
}

.academic-year-switcher-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--blue-700);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
}

.academic-year-select-shell {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.academic-year-select-shell select {
    appearance: none;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.2rem 1.6rem 0.2rem 0.6rem;
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--blue-800);
    cursor: pointer;
    outline: none;
}

.academic-year-select-shell .chevron {
    position: absolute;
    right: 0.5rem;
    pointer-events: none;
    color: var(--blue-600);
}

/* ══════════════════════════════════════════════════════════════════
   ZONE PRINCIPALE & PAGES
   ══════════════════════════════════════════════════════════════════ */
.main-content {
    flex: 1;
    padding: 1.5rem;
    max-width: 1560px;
    width: 100%;
    margin: 0 auto;
}

.view-content {
    display: none;
}
.view-content.active {
    display: block;
    animation: fadeIn 0.18s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.admin-title-block h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.02em;
    margin-bottom: 0.2rem;
}

.admin-title-block p {
    font-size: 0.845rem;
    color: var(--text-muted);
}

.admin-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ══════════════════════════════════════════════════════════════════
   COMPOSANTS : BOUTONS, BADGES, ALERTES
   ══════════════════════════════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font-family: inherit;
    font-size: 0.845rem;
    font-weight: 500;
    padding: 0.45rem 0.9rem;
    border-radius: var(--r-s);
    border: 1px solid transparent;
    cursor: pointer;
    line-height: 1.4;
    transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
    text-decoration: none;
    white-space: nowrap;
}

.btn-xs { font-size: 0.72rem; padding: 0.2rem 0.55rem; border-radius: var(--r-xs); }
.btn-sm { font-size: 0.78rem; padding: 0.32rem 0.7rem; }
.btn-lg { font-size: 0.92rem; padding: 0.6rem 1.2rem; }

.btn-primary {
    background: var(--blue-600);
    border-color: var(--blue-600);
    color: #fff;
}
.btn-primary:hover:not(:disabled) {
    background: var(--blue-700);
    border-color: var(--blue-700);
    box-shadow: 0 1px 4px rgba(37, 99, 235, 0.3);
}

.btn-secondary {
    background: #fff;
    border-color: var(--sl-300);
    color: var(--sl-700);
    box-shadow: var(--sh-xs);
}
.btn-secondary:hover:not(:disabled) {
    background: var(--sl-50);
    border-color: var(--sl-400);
}

.btn-outline-primary {
    background: #fff;
    border-color: var(--blue-300);
    color: var(--blue-600);
}
.btn-outline-primary:hover:not(:disabled) {
    background: var(--blue-50);
    border-color: var(--blue-500);
}

.btn-outline-secondary {
    background: #fff;
    border-color: var(--sl-300);
    color: var(--sl-600);
}
.btn-outline-secondary:hover:not(:disabled) {
    background: var(--sl-50);
    border-color: var(--sl-400);
    color: var(--sl-800);
}

.btn-success { background: var(--gr-600); border-color: var(--gr-600); color: #fff; }
.btn-success:hover:not(:disabled) { background: var(--gr-700); }

.btn-warning { background: var(--am-500); border-color: var(--am-500); color: #fff; }
.btn-warning:hover:not(:disabled) { background: var(--am-600); }

.btn-danger { background: var(--re-600); border-color: var(--re-600); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--re-700); }

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    border-radius: var(--r-xs);
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.badge-success { background: var(--gr-100); color: var(--gr-700); border: 1px solid rgba(16, 185, 129, 0.2); }
.badge-warning { background: var(--am-100); color: var(--am-700); border: 1px solid rgba(245, 158, 11, 0.2); }
.badge-danger  { background: var(--re-100); color: var(--re-700); border: 1px solid rgba(239, 68, 68, 0.2); }
.badge-info    { background: var(--cy-100); color: var(--cy-700); border: 1px solid rgba(14, 165, 233, 0.2); }
.badge-primary { background: var(--blue-100); color: var(--blue-700); border: 1px solid rgba(37, 99, 235, 0.2); }
.badge-neutral { background: var(--sl-150); color: var(--sl-700); border: 1px solid var(--border); }

/* Alertes */
.alert {
    border-radius: var(--r);
    font-size: 0.845rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}
.alert-info { background: var(--blue-50); border-color: var(--blue-200); color: var(--blue-900); }
.alert-warning { background: var(--am-50); border-color: var(--am-100); color: var(--am-700); }
.alert-danger { background: var(--re-50); border-color: var(--re-100); color: var(--re-700); }
.alert-secondary { background: var(--sl-50); border-color: var(--border); color: var(--text-body); }

/* ══════════════════════════════════════════════════════════════════
   CARTES & PANELS
   ══════════════════════════════════════════════════════════════════ */
.card, .admin-panel {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--r-l);
    box-shadow: var(--sh-xs);
    overflow: hidden;
}

.card-header, .admin-panel-header {
    background: var(--sl-50);
    border-bottom: 1px solid var(--border);
    padding: 0.875rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.header-title, .admin-panel-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main);
}

.admin-panel-subtitle {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    background: var(--sl-50);
    border-top: 1px solid var(--border);
    padding: 0.75rem 1.25rem;
}

/* ══════════════════════════════════════════════════════════════════
   STEPPER DE PROGRESSION (SETUP WORKFLOW)
   ══════════════════════════════════════════════════════════════════ */
.setup-stepper {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.75rem;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.75rem;
    border-radius: var(--r-m);
    border: 1px solid var(--border);
    background: var(--sl-50);
}

.step-marker {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.step-item.is-complete {
    background: var(--gr-50);
    border-color: var(--gr-200);
}
.step-item.is-complete .step-marker {
    background: var(--gr-500);
    color: #fff;
}

.step-item.is-warning {
    background: var(--am-50);
    border-color: var(--am-100);
}
.step-item.is-warning .step-marker {
    background: var(--am-500);
    color: #fff;
}

.step-item.is-pending {
    opacity: 0.75;
}
.step-item.is-pending .step-marker {
    background: var(--sl-200);
    color: var(--sl-600);
}

.step-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
}

.step-subtitle {
    font-size: 0.68rem;
    color: var(--text-muted);
}

/* ══════════════════════════════════════════════════════════════════
   KPI CARDS
   ══════════════════════════════════════════════════════════════════ */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.dashboard-kpi-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--r-l);
    padding: 1.15rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    box-shadow: var(--sh-xs);
    transition: border-color 0.15s;
}
.dashboard-kpi-card:hover {
    border-color: var(--blue-300);
}

.kpi-label {
    font-size: 0.74rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.2rem;
}

.kpi-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.kpi-trend {
    font-size: 0.72rem;
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.kpi-icon-wrap {
    width: 46px;
    height: 46px;
    border-radius: var(--r-m);
    display: grid;
    place-items: center;
    color: #fff;
    flex-shrink: 0;
}
.kpi-icon-wrap.bg-blue { background: linear-gradient(135deg, var(--blue-700), var(--blue-500)); }
.kpi-icon-wrap.bg-purple { background: linear-gradient(135deg, var(--pu-700), var(--pu-500)); }
.kpi-icon-wrap.bg-amber { background: linear-gradient(135deg, var(--am-700), var(--am-500)); }
.kpi-icon-wrap.bg-emerald { background: linear-gradient(135deg, var(--gr-700), var(--gr-500)); }
.kpi-icon-wrap.bg-red { background: linear-gradient(135deg, var(--re-700), var(--re-500)); }

/* ══════════════════════════════════════════════════════════════════
   GRILLES 2 COLONNES & LISTES DIAGNOSTIC
   ══════════════════════════════════════════════════════════════════ */
.layout-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.progress {
    height: 7px;
    background: var(--sl-200);
    border-radius: 999px;
    display: flex;
    overflow: hidden;
}
.progress-bar { height: 100%; }

.quality-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.quality-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.8rem;
    border-radius: var(--r);
    background: var(--sl-50);
    border: 1px solid var(--border);
}

.quality-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 0.72rem;
    font-weight: 800;
    flex-shrink: 0;
}
.quality-item.is-valid .quality-icon { background: var(--gr-100); color: var(--gr-700); }
.quality-item.is-warning .quality-icon { background: var(--am-100); color: var(--am-700); }
.quality-item.is-danger .quality-icon { background: var(--re-100); color: var(--re-700); }

.quality-text {
    flex: 1;
    min-width: 0;
    font-size: 0.82rem;
}

.action-checklist {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.action-item {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.65rem;
    border-radius: var(--r);
    border: 1px solid var(--border);
    background: var(--sl-50);
}
.action-item.urgent {
    border-color: var(--am-200);
    background: var(--am-50);
}

.action-label {
    flex: 1;
    cursor: pointer;
}

.action-title {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-main);
}

.action-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ══════════════════════════════════════════════════════════════════
   SOURCE CARDS (LES 4 FICHIERS)
   ══════════════════════════════════════════════════════════════════ */
.source-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
}

.source-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--r-l);
    padding: 1.25rem;
    box-shadow: var(--sh-xs);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 1rem;
    position: relative;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.source-card:hover {
    border-color: var(--blue-300);
    box-shadow: var(--sh);
}

.source-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--r-l) var(--r-l) 0 0;
}
.source-card.is-complete::before { background: var(--gr-500); }
.source-card.is-warning::before { background: var(--am-500); }
.source-card.is-empty::before { background: var(--sl-300); }

.source-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.source-icon-wrap {
    width: 42px;
    height: 42px;
    border-radius: var(--r-m);
    display: grid;
    place-items: center;
    color: #fff;
}
.source-icon-wrap.bg-blue { background: var(--blue-600); }
.source-icon-wrap.bg-purple { background: var(--pu-600); }
.source-icon-wrap.bg-emerald { background: var(--gr-600); }
.source-icon-wrap.bg-amber { background: var(--am-600); }

.source-title {
    font-size: 0.92rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
    color: var(--text-main);
}

.source-desc {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin-bottom: 0.65rem;
}

.source-meta-row {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.72rem;
    color: var(--text-body);
}

.source-card-footer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border);
}

.file-label {
    cursor: pointer;
}

/* ══════════════════════════════════════════════════════════════════
   TABLES & FILTRES DE GESTION
   ══════════════════════════════════════════════════════════════════ */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.845rem;
    color: var(--text-body);
}

.table thead th {
    background: var(--sl-50);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table tbody tr {
    transition: background 0.1s;
}
.table tbody tr:hover {
    background: var(--blue-50);
}
.table tbody tr:last-child td {
    border-bottom: none;
}

.admin-filter-panel {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--r-l);
    padding: 1rem 1.25rem;
    box-shadow: var(--sh-xs);
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.85rem;
    align-items: flex-end;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--sl-600);
}

.form-control, .form-select {
    width: 100%;
    height: 38px;
    padding: 0.45rem 0.75rem;
    font-size: 0.845rem;
    font-family: inherit;
    color: var(--text-main);
    background: #fff;
    border: 1px solid var(--sl-300);
    border-radius: var(--r-s);
    box-shadow: var(--sh-xs);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--blue-500);
    box-shadow: var(--ring);
}

.form-control-sm, .form-select-sm {
    height: 32px;
    font-size: 0.78rem;
    padding: 0.25rem 0.6rem;
}

.form-check-input {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1.5px solid var(--sl-300);
    accent-color: var(--primary);
    cursor: pointer;
}

/* Onglets Analytiques & Tabs */
.analytics-tabs {
    display: inline-flex;
    gap: 0.25rem;
    background: var(--sl-150);
    padding: 3px;
    border-radius: var(--r-m);
    border: 1px solid var(--border);
}

.analytics-tabs .nav-link {
    background: transparent;
    border: none;
    padding: 0.38rem 0.85rem;
    border-radius: var(--r-s);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.12s;
    display: inline-flex;
    align-items: center;
    gap: 0.38rem;
}
.analytics-tabs .nav-link:hover {
    color: var(--text-main);
}
.analytics-tabs .nav-link.active {
    background: #fff;
    color: var(--blue-700);
    box-shadow: var(--sh-xs);
}

/* ══════════════════════════════════════════════════════════════════
   CLASSES GRID
   ══════════════════════════════════════════════════════════════════ */
.class-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.25rem;
}

.admin-class-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--r-l);
    box-shadow: var(--sh-xs);
    overflow: hidden;
    position: relative;
    transition: transform 0.15s, box-shadow 0.15s;
    display: flex;
    flex-direction: column;
}
.admin-class-card::before {
    content: '';
    display: block;
    height: 3px;
    background: linear-gradient(90deg, var(--blue-600), var(--blue-400));
}
.admin-class-card:hover {
    box-shadow: var(--sh-m);
}

.class-card-body {
    padding: 1.15rem;
    flex: 1;
}

.class-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.85rem;
}

.class-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
}

.class-filiere {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.class-metrics-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    background: var(--sl-50);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 0.65rem 0.5rem;
    text-align: center;
    margin-bottom: 0.85rem;
}

.class-metric-val {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.1;
}

.class-metric-lbl {
    font-size: 0.62rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.class-teachers-preview {
    font-size: 0.74rem;
    color: var(--text-body);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.class-card-footer {
    background: var(--sl-50);
    border-top: 1px solid var(--border);
    padding: 0.65rem 1.15rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ══════════════════════════════════════════════════════════════════
   DRAWERS (PANNEAUX LATÉRAUX COULISSANTS)
   ══════════════════════════════════════════════════════════════════ */
.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(3px);
    z-index: 1040;
    display: none;
}
.drawer-overlay.active {
    display: block;
}

.drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(520px, 92vw);
    background: #fff;
    box-shadow: -4px 0 24px rgba(15, 23, 42, 0.15);
    z-index: 1050;
    transform: translateX(100%);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}
.drawer.active {
    transform: translateX(0);
}

.drawer-header {
    background: var(--sl-50);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.drawer-title {
    font-size: 1rem;
    font-weight: 700;
}

.drawer-close-btn {
    background: transparent;
    border: none;
    color: var(--sl-400);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--r-xs);
}
.drawer-close-btn:hover {
    color: var(--text-main);
    background: var(--sl-200);
}

.drawer-body {
    flex: 1;
    padding: 1.25rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.drawer-footer {
    background: var(--sl-50);
    border-top: 1px solid var(--border);
    padding: 0.85rem 1.25rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* ══════════════════════════════════════════════════════════════════
   MODALS CENTRÉS
   ══════════════════════════════════════════════════════════════════ */
.modal-backdrop-custom {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(3px);
    z-index: 1060;
    display: none;
}
.modal-backdrop-custom.active {
    display: block;
}

.modal-custom {
    position: fixed;
    inset: 0;
    z-index: 1070;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-custom.active {
    display: flex;
}

.modal-dialog-custom {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    box-shadow: var(--sh-l);
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalIn 0.2s ease-out;
}
.modal-dialog-custom.modal-sm { max-width: 440px; }
.modal-dialog-custom.modal-md { max-width: 580px; }
.modal-dialog-custom.modal-lg { max-width: 820px; }

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.97) translateY(-8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header-custom {
    background: var(--sl-50);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title-custom {
    font-size: 1rem;
    font-weight: 700;
}

.modal-close-custom {
    background: transparent;
    border: none;
    color: var(--sl-400);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--r-xs);
}
.modal-close-custom:hover {
    color: var(--text-main);
    background: var(--sl-200);
}

.modal-body-custom {
    padding: 1.25rem;
    overflow-y: auto;
}

.modal-footer-custom {
    background: var(--sl-50);
    border-top: 1px solid var(--border);
    padding: 0.85rem 1.25rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.recap-box {
    background: var(--sl-50);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 0.85rem 1rem;
}

.recap-row {
    display: flex;
    justify-content: space-between;
    padding: 0.35rem 0;
    font-size: 0.845rem;
    border-bottom: 1px dashed var(--sl-200);
}
.recap-row:last-child {
    border-bottom: none;
}

/* ══════════════════════════════════════════════════════════════════
   TOASTS NOTIFICATIONS
   ══════════════════════════════════════════════════════════════════ */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--r-m);
    box-shadow: var(--sh-l);
    padding: 0.75rem 1rem;
    min-width: 290px;
    max-width: 420px;
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    animation: toastSlide 0.25s ease-out;
    transition: opacity 0.25s, transform 0.25s;
}
.toast.toast-success { border-left: 4px solid var(--gr-500); }
.toast.toast-warning { border-left: 4px solid var(--am-500); }
.toast.toast-info    { border-left: 4px solid var(--blue-600); }

@keyframes toastSlide {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ══════════════════════════════════════════════════════════════════
   RESPONSIVE (MOBILE À 4K)
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    .sidebar-backdrop.active {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        backdrop-filter: blur(3px);
        z-index: 1025;
    }
    .layout-grid-2 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 575.98px) {
    .main-content {
        padding: 1rem;
    }
    .content-header {
        padding: 0.6rem 1rem;
    }
    .academic-year-switcher-label span {
        display: none;
    }
    .env-badge .env-text {
        display: none;
    }
    .setup-stepper {
        grid-template-columns: 1fr;
    }
}

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

/* Real setup portal integration: preserve the Gemini design while hardening dense import controls. */
body.live-loading #appShell { visibility: hidden; }
.source-cards-grid > *, .source-card, .source-card-footer, .source-card-footer > * { min-width: 0; }
.source-card-footer { flex-wrap: wrap; align-items: stretch; }
.source-card-footer .btn, .source-card-footer .file-label { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.source-card-footer .btn { flex: 1 1 10rem; justify-content: center; }
.source-card-footer .file-label { display: inline-flex; align-items: center; justify-content: center; }
.source-card.is-loading { opacity: .65; pointer-events: none; }
.source-card .source-meta-row code { overflow-wrap: anywhere; white-space: normal; }
.setup-login-overlay { position: fixed; inset: 0; z-index: 3000; display: grid; place-items: center; padding: 1.25rem; background: radial-gradient(circle at 15% 15%, rgba(37, 99, 235, .16), transparent 28rem), linear-gradient(135deg, #eff6ff 0%, #f8fafc 58%, #dbeafe 100%); }
.setup-login-card { width: min(100%, 27rem); padding: 2rem; background: #fff; border: 1px solid var(--border); border-radius: var(--r-l); box-shadow: var(--sh-l); }
.setup-login-mark { display: grid; place-items: center; width: 2.75rem; height: 2.75rem; margin-bottom: 1rem; border-radius: .85rem; background: var(--blue-700); color: #fff; font-weight: 800; letter-spacing: .04em; box-shadow: 0 .5rem 1.25rem rgba(29, 78, 216, .22); }
.setup-login-kicker { margin-bottom: .35rem; color: var(--blue-700); font-size: .72rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.setup-login-card h1 { margin: 0 0 .35rem; color: var(--blue-800); font-size: 1.35rem; }
.setup-login-card p { margin: 0 0 1.5rem; color: var(--text-muted); font-size: .88rem; }
.setup-login-card .form-group { margin-bottom: 1rem; }
.setup-login-feedback { min-height: 1.25rem; margin-top: .85rem; color: var(--re-700); font-size: .82rem; }
.setup-login-card .btn:disabled { cursor: wait; opacity: .72; }

/* Staff directory: compact, stable action rows on both wide and narrow screens. */
.staff-gender-icon { display: inline-grid; place-items: center; width: 1.85rem; height: 1.85rem; border-radius: 999px; }
.staff-gender-icon.is-female { color: #be185d; background: #fce7f3; }
.staff-gender-icon.is-male { color: #1d4ed8; background: #dbeafe; }
.staff-gender-icon.is-unknown { color: var(--text-muted); background: var(--sl-100); font-size: .8rem; font-weight: 700; }
.staff-row-actions { display: inline-flex; align-items: center; justify-content: flex-end; gap: .35rem; min-width: max-content; white-space: nowrap; }
.staff-row-actions .btn { flex: 0 0 auto; }
.staff-action-icon { display: inline-grid; place-items: center; width: 1.95rem; height: 1.95rem; padding: 0; border: 1px solid var(--border); border-radius: var(--r-xs); background: #fff; color: var(--sl-600); transition: .16s ease; }
.staff-action-icon:hover { border-color: var(--blue-300); background: var(--blue-50); color: var(--blue-700); transform: translateY(-1px); }
.staff-action-icon.is-danger:hover { border-color: var(--re-200); background: var(--re-50); color: var(--re-700); }
#view-staff .table tbody td { vertical-align: middle; }
.fet-review-actions { display: flex; align-items: center; justify-content: flex-end; gap: .4rem; min-width: 19rem; }
.fet-review-actions .form-select { min-width: 13rem; }
.staff-fet-detail { display: block; max-width: 18rem; margin-top: .22rem; color: var(--blue-700); font-size: .7rem; line-height: 1.35; }
.teacher-classes-list { display: flex; flex-wrap: wrap; gap: .5rem; }
.teacher-class-selection { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .55rem; }
.teacher-class-choice { display: flex; align-items: center; gap: .48rem; min-height: 2.35rem; padding: .55rem .65rem; border: 1px solid var(--border); border-radius: var(--r-xs); color: var(--text-main); cursor: pointer; transition: .16s ease; }
.teacher-class-choice:hover { border-color: var(--blue-300); background: var(--blue-50); }
.teacher-class-choice.is-selected { border-color: var(--blue-500); background: var(--blue-100); color: var(--blue-800); font-weight: 700; }
.teacher-class-choice input { accent-color: var(--blue-600); }
.subject-editor-field { margin-top: 1rem; }
.teacher-subject-selection { display: flex; flex-wrap: wrap; gap: .5rem; padding: .7rem; border: 1px solid var(--border); border-radius: var(--r-xs); background: var(--sl-50); }
.teacher-subject-choice { display: inline-flex; align-items: center; gap: .4rem; padding: .42rem .55rem; border: 1px solid var(--border); border-radius: 999px; background: #fff; cursor: pointer; font-size: .78rem; transition: .16s ease; }
.teacher-subject-choice:hover { border-color: var(--blue-300); background: var(--blue-50); }
.teacher-subject-choice.is-selected { border-color: var(--blue-500); background: var(--blue-100); color: var(--blue-800); font-weight: 700; }
.teacher-subject-choice input { accent-color: var(--blue-600); }
@media (max-width: 575px) { .teacher-class-selection { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Logout confirmation uses the portal's dialog language instead of a browser alert. */
.setup-logout-modal { z-index: 3070; }
.setup-logout-modal .modal-dialog-custom { border-color: rgba(37, 99, 235, .18); box-shadow: 0 1.5rem 4.5rem rgba(15, 23, 42, .24); }
.setup-logout-banner { display: flex; align-items: center; gap: .85rem; padding: 1.35rem 1.35rem 1rem; background: linear-gradient(135deg, var(--blue-50), #fff); border-bottom: 1px solid var(--border); }
.setup-logout-icon { display: grid; flex: 0 0 auto; place-items: center; width: 2.85rem; height: 2.85rem; border-radius: .9rem; background: var(--blue-700); color: #fff; box-shadow: 0 .55rem 1.2rem rgba(29, 78, 216, .2); }
.setup-logout-icon .icon { width: 1.35rem; height: 1.35rem; }
.setup-logout-eyebrow { margin-bottom: .15rem; color: var(--blue-700); font-size: .68rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.setup-logout-banner h3 { margin: 0; color: var(--sl-900); font-size: 1.12rem; }
.setup-logout-body { padding: 1.25rem 1.35rem; }
.setup-logout-body > p { margin: 0 0 1rem; color: var(--text-muted); line-height: 1.55; }
.setup-logout-note { display: flex; gap: .6rem; align-items: flex-start; padding: .8rem .85rem; border: 1px solid var(--blue-100); border-radius: var(--r-m); background: var(--blue-50); color: var(--blue-800); font-size: .78rem; line-height: 1.45; }
.setup-logout-note .icon { flex: 0 0 auto; margin-top: .05rem; color: var(--blue-600); }
.setup-logout-actions { justify-content: flex-end; gap: .65rem; }
.setup-logout-actions .btn { min-width: 9.5rem; }
@media (max-width: 480px) {
  .setup-logout-banner, .setup-logout-body { padding-left: 1.1rem; padding-right: 1.1rem; }
  .setup-logout-actions { flex-direction: column-reverse; padding: 1rem 1.1rem; }
  .setup-logout-actions .btn { width: 100%; }
}
.live-notice { margin-top: 1rem; padding: .75rem 1rem; border-radius: var(--r); font-size: .84rem; line-height: 1.45; }
.live-notice.success { background: var(--gr-50); border: 1px solid var(--gr-200); color: var(--gr-700); }
.live-notice.warning { background: var(--am-50); border: 1px solid var(--am-200); color: var(--am-700); }
@media (max-width: 575.98px) {
  .source-cards-grid, .class-cards-grid { grid-template-columns: minmax(0, 1fr); }
  .source-card-footer .btn, .source-card-footer .file-label { flex-basis: 100%; width: 100%; }
  .setup-login-card { padding: 1.5rem; }
}

/* Spacing repair: Gemini markup uses familiar admin utility classes without Bootstrap. */
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: .25rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.me-1 { margin-right: .25rem !important; }
.me-3 { margin-right: 1rem !important; }
.ms-1 { margin-left: .25rem !important; }
.p-4 { padding: 1.5rem !important; }
.d-flex { display: flex !important; }
.d-none { display: none !important; }
.w-100 { width: 100% !important; }
.align-items-center { align-items: center !important; }
.align-items-start { align-items: flex-start !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-end { justify-content: flex-end !important; }
.gap-2 { gap: .5rem !important; }
.gap-3 { gap: 1rem !important; }
.text-end { text-align: right !important; }
.text-success { color: var(--gr-700) !important; }
.text-warning { color: var(--am-700) !important; }
.text-danger { color: var(--re-700) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-primary { color: var(--blue-700) !important; }
.fw-semibold { font-weight: 600 !important; }
.fw-bold { font-weight: 700 !important; }

/* Keep each operational block distinct without making the interface feel sparse. */
.view-content.active > .card,
.view-content.active > .admin-panel,
.view-content.active > .alert,
.view-content.active > .admin-filter-panel,
.view-content.active > .kpi-grid,
.view-content.active > .layout-grid-2,
.view-content.active > .source-cards-grid,
.view-content.active > .class-cards-grid { margin-bottom: 1.5rem; }

.card-header, .admin-panel-header { min-height: 3.5rem; }
.card-header > *, .admin-panel-header > *, .source-card-header > *, .source-card-footer > * { min-width: 0; }
.kpi-grid { gap: 1.25rem; }
.layout-grid-2 { gap: 1.5rem; }
.source-cards-grid { gap: 1.5rem; }
.class-cards-grid { gap: 1.5rem; }
.source-card { padding: 1.35rem; gap: 1.15rem; }
.source-card-body { display: grid; gap: .7rem; }
.source-card-footer { margin-top: auto; gap: .75rem; }
.admin-filter-panel { margin-bottom: 1.5rem; }
.table-responsive { border-radius: 0 0 var(--r-l) var(--r-l); }

@media (min-width: 768px) { .d-md-inline-flex { display: inline-flex !important; } }
@media (max-width: 767.98px) { .d-md-inline-flex { display: none !important; } }
@media (max-width: 575.98px) {
  .main-content { padding: 1.15rem; }
  .page-header { margin-bottom: 1.5rem; }
  .view-content.active > .card,
  .view-content.active > .admin-panel,
  .view-content.active > .alert,
  .view-content.active > .admin-filter-panel,
  .view-content.active > .kpi-grid,
  .view-content.active > .layout-grid-2,
  .view-content.active > .source-cards-grid,
  .view-content.active > .class-cards-grid { margin-bottom: 1.15rem; }
  .card-header, .admin-panel-header { padding: .8rem 1rem; align-items: flex-start; flex-wrap: wrap; }
  .source-card { padding: 1.1rem; }
}

/* Student and guardian editing stays grouped in one readable, scrollable form. */
.student-editor-section + .student-editor-section {
    margin-top: 1.4rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}
.student-editor-section-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.85rem;
}
.student-editor-section-title h4 {
    margin: 0;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-main);
}
.student-editor-section-title span {
    color: var(--sl-500);
    font-size: 0.74rem;
}
.student-contact-card {
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--r-l);
    background: var(--sl-50);
}
.student-contact-card + .student-contact-card { margin-top: 0.8rem; }
.student-contact-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.85rem;
}
.student-contact-heading h4 { margin: 0 0 0.15rem; font-size: 0.88rem; }
.student-contact-heading p { margin: 0; color: var(--sl-500); font-size: 0.75rem; line-height: 1.4; }
.contact-responsible { white-space: nowrap; color: var(--sl-700); font-size: 0.78rem; font-weight: 600; }
.contact-responsible input { vertical-align: -1px; }
@media (max-width: 575px) {
    .student-contact-heading { flex-direction: column; gap: 0.55rem; }
    .contact-responsible { white-space: normal; }
}

/* Keep the long student/contact form inside the dialog instead of scrolling the page behind it. */
#setupStudentEditor { overflow: hidden; }
#setupStudentEditor .modal-dialog-custom {
    /* Wide workspace: the student block stays above the parent blocks. */
    width: min(92vw, 1400px);
    max-width: calc(100vw - 2rem);
    max-height: calc(100dvh - 2rem);
}
#setupStudentEditor form {
    display: flex;
    min-height: 0;
    flex: 1 1 auto;
    flex-direction: column;
}
#setupStudentEditor .modal-body-custom {
    min-height: 0;
    flex: 1 1 auto;
    overscroll-behavior: contain;
}
@media (max-width: 575px) {
    #setupStudentEditor { padding: 0.5rem; }
    #setupStudentEditor .modal-dialog-custom { max-width: calc(100vw - 1rem); max-height: calc(100dvh - 1rem); }
}

/* Desktop student editor: one horizontal workspace with vertical form columns. */
#setupStudentEditor .modal-dialog-custom {
    width: calc(100vw - 2rem);
    max-width: none;
}
#setupStudentEditor .student-editor-layout {
    display: grid;
    grid-template-columns: minmax(270px, 0.82fr) repeat(2, minmax(300px, 1fr));
    align-items: start;
    gap: 1rem;
}
#setupStudentEditor .student-editor-section,
#setupStudentEditor .student-contact-card {
    margin: 0;
    min-width: 0;
    height: 100%;
}
#setupStudentEditor .student-editor-section + .student-editor-section,
#setupStudentEditor .student-contact-card + .student-contact-card {
    margin-top: 0;
}
#setupStudentEditor .student-editor-section {
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--r-l);
    background: #fff;
}
#setupStudentEditor .student-editor-layout .filter-grid {
    grid-template-columns: 1fr;
}
#setupStudentEditor .student-contact-card { background: var(--sl-50); }
@media (max-width: 1050px) {
    #setupStudentEditor .student-editor-layout { grid-template-columns: repeat(2, minmax(260px, 1fr)); }
    #setupStudentEditor .student-editor-student { grid-column: 1 / -1; }
    #setupStudentEditor .student-editor-student .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
    #setupStudentEditor .student-editor-layout { grid-template-columns: 1fr; }
    #setupStudentEditor .student-editor-student { grid-column: auto; }
    #setupStudentEditor .student-editor-student .filter-grid { grid-template-columns: 1fr; }
}

/* Do not reserve an empty third column when a student has one contact only. */
#setupStudentEditor .student-editor-layout.contacts-1 {
    grid-template-columns: minmax(300px, 0.9fr) minmax(360px, 1.1fr);
    max-width: 980px;
}
#setupStudentEditor .student-editor-layout.contacts-2 {
    grid-template-columns: minmax(270px, 0.82fr) repeat(2, minmax(300px, 1fr));
}
@media (max-width: 1050px) {
    #setupStudentEditor .student-editor-layout.contacts-1,
    #setupStudentEditor .student-editor-layout.contacts-2 { max-width: none; }
}

/* Resize the dialog itself as well; otherwise its white surface remains empty. */
#setupStudentEditor .modal-dialog-custom.contacts-1 {
    width: min(980px, calc(100vw - 2rem));
}

/* Class inspection uses a centered desktop dialog rather than the legacy side drawer. */
#classInspectorModal .class-inspection-modal {
    width: min(94vw, 1440px);
    max-width: calc(100vw - 2rem);
    max-height: calc(100dvh - 2rem);
}
#classInspectorModal .modal-body-custom { min-height: 0; flex: 1 1 auto; overscroll-behavior: contain; }
.class-inspector-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.8rem;
    margin-bottom: 1.1rem;
}
.class-inspector-metrics > div { padding: 0.9rem 1rem; border: 1px solid var(--border); border-radius: var(--r-l); background: var(--sl-50); }
.class-inspector-metrics strong { display: block; color: var(--blue-700); font-size: 1.25rem; line-height: 1.1; }
.class-inspector-metrics span { display: block; margin-top: 0.25rem; color: var(--sl-600); font-size: 0.72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.class-inspector-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, .85fr); gap: 1rem; align-items: start; }
.class-inspector-section { overflow: hidden; border: 1px solid var(--border); border-radius: var(--r-l); background: #fff; }
.class-inspector-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding: 0.9rem 1rem; border-bottom: 1px solid var(--border); background: var(--sl-50); }
.class-inspector-heading h4 { margin: 0; font-size: 0.9rem; }
.class-inspector-heading span { color: var(--sl-500); font-size: 0.75rem; }
.class-inspector-table { margin: 0; font-size: 0.79rem; }
.class-inspector-table th, .class-inspector-table td { white-space: nowrap; }
.class-inspector-teachers { display: grid; gap: 0.65rem; padding: 0.85rem; }
.class-inspector-teacher { padding: 0.8rem; border: 1px solid var(--border); border-radius: var(--r); background: var(--sl-50); color: var(--sl-600); font-size: 0.78rem; }
.class-inspector-teacher-name { margin-bottom: 0.25rem; color: var(--text-main); font-weight: 700; }
.class-inspector-teacher small { display: block; margin-top: 0.35rem; color: var(--sl-500); }
@media (max-width: 800px) {
    .class-inspector-layout { grid-template-columns: 1fr; }
    .class-inspector-metrics { grid-template-columns: 1fr; }
}
