/* ==========================================================================
   EduManager — feuille de style unique (palette teal / slate / coral)
   ========================================================================== */

/* ---------- Fonts (self-hosted) ---------- */
@font-face { font-family: 'Sora'; font-style: normal; font-weight: 300; font-display: swap; src: url('../fonts/sora-300.woff2') format('woff2'); }
@font-face { font-family: 'Sora'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/sora-400.woff2') format('woff2'); }
@font-face { font-family: 'Sora'; font-style: normal; font-weight: 500; font-display: swap; src: url('../fonts/sora-500.woff2') format('woff2'); }
@font-face { font-family: 'Sora'; font-style: normal; font-weight: 600; font-display: swap; src: url('../fonts/sora-600.woff2') format('woff2'); }
@font-face { font-family: 'Lora'; font-style: italic; font-weight: 400; font-display: swap; src: url('../fonts/lora-400-italic.woff2') format('woff2'); }

/* ---------- Tokens ---------- */
:root {
    --teal-900: #0d3d3a;
    --teal-800: #124a46;
    --teal-700: #165c57;
    --teal-500: #1e8c84;
    --teal-300: #7fe3c8;
    --teal-100: #c8f0e8;
    --teal-50:  #f0faf8;

    --slate-800: #1e2e2d;
    --slate-600: #3c5654;
    --slate-500: #4a6b68;
    --slate-400: #6b8a87;
    --slate-300: #9ab5b2;
    --slate-200: #b5ceca;
    --slate-100: #dcecea;
    --slate-50:  #f3f7f6;

    --coral-500: #e07a5f;
    --coral-100: #fff0ee;
    --coral-900: #7a2e1a;

    --amber-500: #d9a23b;
    --amber-100: #fff6e3;
    --amber-900: #6b4a0b;

    --font: 'Sora', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    --font-serif: 'Lora', Georgia, serif;

    --radius-sm: 6px;
    --radius-md: 9px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(13, 61, 58, .05);
    --shadow-md: 0 8px 24px rgba(13, 61, 58, .08);
    --shadow-lg: 0 20px 60px rgba(13, 61, 58, .22);

    --sidebar-w: 256px;
    --topbar-h: 58px;
    --gutter: 32px;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    font-family: var(--font);
    font-size: 14.5px;
    line-height: 1.55;
    color: var(--slate-800);
    background: var(--slate-50);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}
body.modal-open, body.sidebar-open { overflow: hidden; }
a { color: var(--teal-700); text-decoration: none; }
a:hover { color: var(--teal-500); }
img, svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--teal-500); outline-offset: 2px; border-radius: 4px; }

.icon { width: 18px; height: 18px; flex-shrink: 0; display: inline-block; vertical-align: middle; }
.muted, .muted.icon { color: var(--slate-400); }
.hint { font-size: 12px; color: var(--slate-400); display: flex; gap: 6px; align-items: flex-start; margin-top: 6px; }
.hint .icon { width: 15px; height: 15px; margin-top: 2px; }
.skip-link { position: absolute; left: -999px; top: 8px; background: #fff; padding: 8px 12px; border-radius: 6px; z-index: 300; }
.skip-link:focus { left: 8px; }

/* ---------- Layout ---------- */
.layout { min-height: 100vh; }
.main-content {
    margin-left: var(--sidebar-w);
    padding: 28px var(--gutter) 64px;
    max-width: calc(1480px + var(--sidebar-w));
    min-width: 0;
}

/* ---------- Sidebar ---------- */
.sidebar {
    position: fixed; inset: 0 auto 0 0;
    width: var(--sidebar-w);
    height: 100vh; height: 100dvh;
    background: var(--teal-900);
    display: flex; flex-direction: column;
    padding: 20px 12px 12px;
    z-index: 120;
    overflow-y: auto; overscroll-behavior: contain;
    scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent;
}
.sidebar-head { display: flex; align-items: flex-start; justify-content: space-between; padding: 0 8px 16px; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 10px; }
.sidebar-brand .name { font-family: var(--font-serif); font-style: italic; font-size: 20px; color: var(--teal-300); line-height: 1.2; word-break: break-word; }
.sidebar-brand .sub { font-size: 10px; letter-spacing: .09em; text-transform: uppercase; color: rgba(255,255,255,.35); margin-top: 3px; }
.sidebar .sidebar-close { display: none; color: var(--teal-300); }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 12px; border-radius: var(--radius-md);
    color: rgba(255,255,255,.62); font-size: 13.5px;
    transition: background .15s, color .15s;
}
.sidebar-nav a .nav-icon { width: 18px; height: 18px; opacity: .75; }
.sidebar-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav a.active { background: rgba(127,227,200,.13); color: #fff; box-shadow: inset 2px 0 0 var(--teal-300); }
.sidebar-nav a.active .nav-icon { color: var(--teal-300); opacity: 1; }
.sidebar-divider { height: 1px; background: rgba(255,255,255,.08); margin: 8px 4px; }
.sidebar-user { display: flex; align-items: center; gap: 6px; padding: 12px 4px 4px; margin-top: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-user .icon-btn { color: rgba(255,255,255,.6); }
.sidebar-user .icon-btn:hover { color: #fff; background: rgba(255,255,255,.08); }
.who-link { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 6px; border-radius: var(--radius-md); }
.who-link:hover { background: rgba(255,255,255,.06); }
.who { display: flex; flex-direction: column; min-width: 0; }
.who strong { color: #fff; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who small { color: rgba(255,255,255,.4); font-size: 11px; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--teal-300); color: var(--teal-900); font-weight: 600; font-size: 13px;
}
.avatar-soft { background: var(--teal-50); color: var(--teal-700); }
.avatar-danger { background: var(--coral-100); color: var(--coral-900); }
.avatar .icon { width: 17px; height: 17px; }

.mobile-topbar, .sidebar-overlay { display: none; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 18px; min-height: 40px;
    background: var(--teal-900); color: var(--teal-300);
    border: 1px solid var(--teal-900); border-radius: var(--radius-md);
    font-size: 13.5px; font-weight: 500; letter-spacing: .01em; white-space: nowrap;
    cursor: pointer; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--teal-700); border-color: var(--teal-700); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn .icon { width: 17px; height: 17px; }
.btn-secondary { background: #fff; color: var(--teal-700); border-color: var(--slate-200); }
.btn-secondary:hover { background: var(--teal-50); color: var(--teal-900); border-color: var(--slate-300); }
.btn-sm { padding: 6px 12px; min-height: 32px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn-light { background: var(--teal-300); color: var(--teal-900); border-color: var(--teal-300); }
.btn-light:hover { background: #fff; border-color: #fff; color: var(--teal-900); }
.btn-ghost-light { background: transparent; color: #fff; border-color: rgba(255,255,255,.3); }
.btn-ghost-light:hover { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.5); }
.btn-group { display: flex; gap: 6px; flex-wrap: wrap; }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
    content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid var(--teal-300); border-right-color: transparent; animation: spin .7s linear infinite;
}
.btn-secondary.is-loading::after { border-color: var(--teal-700); border-right-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: var(--radius-md);
    border: none; background: transparent; color: var(--slate-500); cursor: pointer;
    transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--teal-50); color: var(--teal-700); }
.icon-btn.danger:hover { background: var(--coral-100); color: var(--coral-900); }
.icon-btn.is-loading { opacity: .4; pointer-events: none; }
.inline-form { display: inline-flex; }

/* ---------- Alerts ---------- */
.alert {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 14px; margin-bottom: 18px;
    border-radius: var(--radius-md); font-size: 13.5px;
    border: 1px solid transparent; transition: opacity .35s, transform .35s;
}
.alert > span { flex: 1; }
.alert .icon { margin-top: 1px; }
.alert-success { background: #edfaf5; color: #0a4731; border-color: #bfeadb; }
.alert-error { background: var(--coral-100); color: var(--coral-900); border-color: #f6d1c7; }
.alert-warn { background: var(--amber-100); color: var(--amber-900); border-color: #f2dfb3; }
.alert-close { background: none; border: none; cursor: pointer; color: inherit; opacity: .6; }
.alert-close:hover { opacity: 1; }
.alert.is-hiding { opacity: 0; transform: translateY(-6px); }

/* ---------- Page header & hero ---------- */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-header h1 { font-family: var(--font-serif); font-style: italic; font-weight: 400; font-size: 27px; color: var(--teal-900); line-height: 1.2; }
.page-header p { color: var(--slate-400); font-size: 13px; margin-top: 4px; max-width: 760px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.hero {
    display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
    background: linear-gradient(135deg, var(--teal-900) 0%, var(--teal-700) 100%);
    color: #fff; border-radius: var(--radius-lg); padding: 26px 28px; margin-bottom: 20px;
    position: relative; overflow: hidden;
}
.hero::after { content: ''; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%; background: rgba(127,227,200,.08); }
.hero h1 { font-family: var(--font-serif); font-style: italic; font-weight: 400; font-size: 28px; color: #fff; }
.hero p { color: rgba(255,255,255,.7); font-size: 13.5px; margin-top: 4px; }
.eyebrow { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--teal-300); }
.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; position: relative; z-index: 1; }

/* ---------- KPIs ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi-grid.kpi-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi {
    display: flex; align-items: center; gap: 14px;
    background: #fff; border: 1px solid var(--slate-100); border-radius: var(--radius-lg);
    padding: 16px 18px; min-width: 0;
}
.kpi-icon { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: var(--teal-50); color: var(--teal-700); flex-shrink: 0; }
.kpi-icon .icon { width: 21px; height: 21px; }
.kpi > div { min-width: 0; }
.kpi small { display: block; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--slate-400); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi strong { display: block; font-size: 20px; font-weight: 600; color: var(--teal-900); line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi strong.kpi-text { font-size: 16px; }
.kpi-accent { background: var(--teal-900); border-color: var(--teal-900); }
.kpi-accent .kpi-icon { background: rgba(127,227,200,.14); color: var(--teal-300); }
.kpi-accent small { color: rgba(255,255,255,.55); }
.kpi-accent strong { color: #fff; }
.kpi-danger .kpi-icon { background: var(--coral-100); color: var(--coral-900); }
.kpi-danger strong { color: var(--coral-900); }

.alert-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.strip-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius-md); background: #fff; border: 1px solid var(--slate-100); color: var(--slate-800); }
.strip-item:hover { border-color: var(--slate-200); box-shadow: var(--shadow-sm); color: var(--slate-800); }
.strip-item .icon { color: var(--teal-500); width: 22px; height: 22px; }
.strip-item strong { display: block; font-size: 14px; font-weight: 600; }
.strip-item small { color: var(--slate-400); font-size: 12px; }
.strip-danger { background: var(--coral-100); border-color: #f6d1c7; }
.strip-danger .icon { color: var(--coral-500); }
.strip-warn { background: var(--amber-100); border-color: #f2dfb3; }
.strip-warn .icon { color: var(--amber-500); }

/* ---------- Cards & grids ---------- */
.card { background: #fff; border: 1px solid var(--slate-100); border-radius: var(--radius-lg); padding: 20px 22px; margin-bottom: 20px; min-width: 0; }
.card.narrow { max-width: 520px; }
.card h2 { font-family: var(--font-serif); font-style: italic; font-weight: 400; font-size: 19px; color: var(--teal-900); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head > a { font-size: 13px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; align-items: start; }
.grid-wide-left { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.span-all { grid-column: 1 / -1; }

/* ---------- Lists ---------- */
.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 11px 6px; border-bottom: 1px solid var(--slate-100); color: var(--slate-800); }
.list-row:last-child { border-bottom: none; }
.list-link { border-radius: var(--radius-sm); }
.list-link:hover { background: var(--teal-50); color: var(--slate-800); }
.list-row.is-muted { opacity: .55; }
.list-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.list-main strong { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-main small { color: var(--slate-400); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.amount { font-weight: 600; white-space: nowrap; color: var(--teal-900); }
.amount-danger { color: var(--coral-900); }
.amount-ok { color: var(--teal-700); }
.time-chip, .date-chip {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-width: 54px; padding: 5px 6px; border-radius: var(--radius-sm);
    background: var(--teal-50); color: var(--teal-900); font-weight: 600; font-size: 13px; line-height: 1.2;
}
.time-chip small, .date-chip small { font-weight: 400; color: var(--slate-400); font-size: 11px; text-transform: uppercase; }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 26px 12px; color: var(--slate-400); font-size: 13px; }
.empty-state .icon { width: 30px; height: 30px; color: var(--slate-200); }
.note-box { margin-top: 14px; padding: 12px 14px; border-radius: var(--radius-md); background: var(--slate-50); color: var(--slate-600); font-size: 13px; }

/* ---------- Badges & chips ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 99px; font-size: 11.5px; font-weight: 500; white-space: nowrap; line-height: 1.5; }
a.badge:hover { filter: brightness(.96); }
.badge-teal { background: var(--teal-100); color: var(--teal-700); }
.badge-coral { background: var(--coral-100); color: var(--coral-900); }
.badge-slate { background: var(--slate-100); color: var(--slate-500); }
.badge-amber { background: var(--amber-100); color: var(--amber-900); }
.badge-outline { background: #fff; color: var(--teal-700); box-shadow: inset 0 0 0 1px var(--slate-200); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--slate-50); border: 1px solid var(--slate-100); font-size: 12px; color: var(--slate-600); white-space: nowrap; }
.chips-lg { margin-bottom: 16px; gap: 6px; }
.chips-lg .chip { padding: 5px 12px; font-size: 13px; background: #fff; }
.chip-accent { background: var(--teal-50) !important; color: var(--teal-700); border-color: var(--teal-100); }
.due-chip { display: inline-block; padding: 3px 9px; border-radius: 6px; background: var(--slate-50); border: 1px solid var(--slate-100); font-size: 12.5px; white-space: nowrap; }
.due-chip.is-today { background: var(--amber-100); border-color: #f2dfb3; color: var(--amber-900); }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 14px; min-width: 0; }
.form-group > label, .form-section legend, fieldset > label {
    display: block; font-size: 11px; font-weight: 500; letter-spacing: .07em; text-transform: uppercase;
    color: var(--teal-900); margin-bottom: 6px;
}
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time],
input[type=tel], input[type=search], select, textarea {
    width: 100%; min-height: 42px; padding: 9px 12px;
    background: #fff; border: 1px solid var(--slate-200); border-radius: var(--radius-md);
    font-size: 14px; color: var(--slate-800); outline: none;
    transition: border-color .15s, box-shadow .15s;
    -webkit-appearance: none; appearance: none;
}
select {
    padding-right: 34px; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%234a6b68' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6l6 -6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--teal-500); box-shadow: 0 0 0 3px rgba(30,140,132,.12); }
input::placeholder, textarea::placeholder { color: var(--slate-300); }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; accent-color: var(--teal-700); flex-shrink: 0; }
.input-lg { font-size: 18px !important; font-weight: 600; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.span-2 { grid-column: span 2; }
.form-section { border: none; border-top: 1px solid var(--slate-100); padding-top: 14px; margin-bottom: 4px; }
.form-section:first-of-type { border-top: none; padding-top: 0; }
.form-section legend { display: flex; align-items: center; gap: 6px; float: left; width: 100%; margin-bottom: 12px; color: var(--teal-700); }
.form-section legend + * { clear: both; }
.form-actions { display: flex; justify-content: flex-end; }
.password-wrapper { position: relative; }
.password-wrapper input { padding-right: 44px; }
.password-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border: none; background: none; color: var(--slate-400); cursor: pointer; display: flex; align-items: center; justify-content: center; border-radius: 6px; }
.password-toggle:hover, .password-toggle.is-visible { color: var(--teal-700); }

.check-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; max-height: 260px; overflow-y: auto; padding: 2px; }
.check-card, .check-row, .radio-card {
    display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px;
    border: 1px solid var(--slate-100); border-radius: var(--radius-md); cursor: pointer; background: #fff;
    transition: border-color .15s, background .15s;
}
.check-card:hover, .check-row:hover, .radio-card:hover { border-color: var(--slate-200); }
.check-card:has(input:checked), .check-row:has(input:checked), .radio-card:has(input:checked) { border-color: var(--teal-500); background: var(--teal-50); }
.check-card span, .check-row span, .radio-card span { display: flex; flex-direction: column; min-width: 0; font-size: 13.5px; }
.check-card small, .check-row small, .radio-card small { color: var(--slate-400); font-size: 12px; }
.check-list { display: flex; flex-direction: column; gap: 6px; max-height: 46vh; overflow-y: auto; margin-bottom: 8px; padding: 2px; }
.radio-card { margin-bottom: 8px; }
.form-group > label.radio-card, .form-group > label.check-inline { display: flex; font-size: 13.5px; font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--slate-800); }
.check-inline { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; margin-bottom: 8px; }

/* ---------- Toolbar & filters ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar select { width: auto; min-width: 160px; }
.search-field { position: relative; flex: 1; min-width: 220px; }
.search-field .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--slate-400); pointer-events: none; }
.search-field input { padding-left: 38px; }
.filter-bar { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.filter-bar .form-group { margin-bottom: 0; flex: 1; min-width: 150px; }
.filter-bar > .btn { flex-shrink: 0; }
.card:has(> .filter-bar) { padding: 16px 20px; }
.filter-empty { text-align: center; color: var(--slate-400); padding: 18px; font-size: 13px; }
.segmented { display: flex; gap: 4px; padding: 4px; background: var(--slate-50); border-radius: 10px; margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.segmented::-webkit-scrollbar { display: none; }
.segmented button { flex: 1 0 auto; border: none; background: none; padding: 8px 14px; border-radius: 7px; font-size: 13px; color: var(--slate-500); cursor: pointer; white-space: nowrap; }
.segmented button.active { background: #fff; color: var(--teal-900); font-weight: 500; box-shadow: var(--shadow-sm); }
.segmented .count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--slate-100); font-size: 11px; margin-left: 4px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--slate-100); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs a { display: inline-flex; align-items: center; gap: 6px; padding: 10px 16px; color: var(--slate-500); border-bottom: 2px solid transparent; white-space: nowrap; font-size: 13.5px; }
.tabs a.active { color: var(--teal-900); border-bottom-color: var(--teal-500); font-weight: 500; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
    font-size: 11px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--slate-400);
    text-align: left; padding: 0 12px 10px; border-bottom: 1px solid var(--slate-100); white-space: nowrap;
}
.table td { padding: 11px 12px; border-bottom: 1px solid var(--slate-100); vertical-align: middle; white-space: nowrap; }
.table td.wrap { white-space: normal; min-width: 160px; max-width: 320px; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: var(--teal-50); }
.table tbody tr:last-child td { border-bottom: none; }
.table tfoot td { font-weight: 600; padding: 12px; border-top: 2px solid var(--slate-100); }
.table .num { text-align: right; }
.table .actions-col { text-align: right; width: 1%; }
.table tr.row-danger td:first-child { box-shadow: inset 3px 0 0 var(--coral-500); }
.table tr.empty-row:hover { background: none; }
.cell-title { font-weight: 500; color: var(--slate-800); }
a.cell-title:hover { color: var(--teal-500); }
.cell-sub { display: block; color: var(--slate-400); font-size: 12px; }
.row-actions { display: inline-flex; align-items: center; gap: 2px; justify-content: flex-end; }
.link-phone { white-space: nowrap; }

/* ---------- Modals ---------- */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(13,61,58,.45); opacity: 0; transition: opacity .18s; backdrop-filter: blur(2px); }
.modal-panel {
    position: relative; width: 100%; max-width: 620px; max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px);
    background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg);
    display: flex; flex-direction: column; outline: none;
    opacity: 0; transform: translateY(14px) scale(.98); transition: opacity .18s, transform .18s;
}
.modal.modal-lg .modal-panel { max-width: 820px; }
.modal.is-open .modal-backdrop { opacity: 1; }
.modal.is-open .modal-panel { opacity: 1; transform: none; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--slate-100); }
.modal-head h2 { font-family: var(--font-serif); font-style: italic; font-weight: 400; font-size: 21px; color: var(--teal-900); }
.modal-body { padding: 18px 22px 0; overflow-y: auto; overscroll-behavior: contain; }
.modal-actions {
    position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 8px;
    padding: 14px 22px; margin: 6px -22px 0; background: #fff; border-top: 1px solid var(--slate-100);
    border-radius: 0 0 16px 16px;
}
.pay-summary { padding: 10px 12px; border-radius: var(--radius-md); background: var(--teal-50); color: var(--teal-900); font-size: 13px; margin-bottom: 14px; }

/* ---------- Schedules board ---------- */
.week-board { display: grid; grid-template-columns: repeat(7, minmax(128px, 1fr)); gap: 10px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 20px; }
.day-col { background: #fff; border: 1px solid var(--slate-100); border-radius: var(--radius-lg); min-width: 0; display: flex; flex-direction: column; }
.day-col.is-today { border-color: var(--teal-500); box-shadow: 0 0 0 1px var(--teal-500); }
.day-head { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; padding: 12px 12px 8px; font-weight: 600; color: var(--teal-900); font-size: 13.5px; }
.day-head .badge { font-size: 10.5px; padding: 1px 7px; }
.day-head small { margin-left: auto; color: var(--slate-400); font-weight: 400; }
.day-body { display: flex; flex-direction: column; gap: 8px; padding: 0 8px 10px; }
.day-empty { color: var(--slate-300); text-align: center; padding: 14px 0; }
.slot { background: var(--teal-50); border-radius: 10px; padding: 10px; border-left: 3px solid var(--teal-500); position: relative; }
.slot.is-muted { opacity: .5; border-left-color: var(--slate-300); }
.slot-time { display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--teal-700); }
.slot-time .icon { width: 14px; height: 14px; }
.slot-title { display: block; font-weight: 500; color: var(--teal-900); margin: 2px 0 4px; line-height: 1.3; }
.slot-meta { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--slate-500); }
.slot-meta span { display: flex; align-items: center; gap: 4px; }
.slot-meta .icon { width: 13px; height: 13px; }
.slot-actions { display: flex; justify-content: flex-end; margin-top: 4px; }
.slot-actions .icon-btn { width: 30px; height: 30px; }
.slot-link { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; margin-top: 6px; font-weight: 500; }
.slot-link .icon { width: 14px; height: 14px; }

/* ---------- Attendance ---------- */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.tile { display: flex; flex-direction: column; gap: 6px; padding: 14px; border-radius: var(--radius-lg); border: 1px solid var(--slate-100); color: var(--slate-800); align-items: flex-start; }
.tile:hover { border-color: var(--teal-500); color: var(--slate-800); box-shadow: var(--shadow-sm); }
.tile.is-done { background: var(--teal-50); }
.tile-time { font-size: 12px; color: var(--slate-400); }
.session-banner { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--radius-lg); margin-bottom: 14px; border: 1px solid; }
.session-banner .icon { width: 24px; height: 24px; }
.session-banner small { display: block; font-size: 12.5px; opacity: .85; }
.session-banner.is-saved { background: #edfaf5; border-color: #bfeadb; color: #0a4731; }
.session-banner.is-pending { background: var(--amber-100); border-color: #f2dfb3; color: var(--amber-900); }
.attendance-counter { font-size: 13px; color: var(--slate-500); margin-bottom: 10px; }
.attendance-counter span { font-weight: 600; color: var(--teal-900); }
.roll-list { list-style: none; display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.roll-item {
    display: grid; grid-template-columns: 28px minmax(0, 1fr) auto minmax(160px, 260px); align-items: center; gap: 12px;
    padding: 8px 10px; border-radius: var(--radius-md); border: 1px solid var(--slate-100); transition: background .15s, border-color .15s;
}
.roll-item.is-present { background: #f2fbf7; border-color: #cdeedf; }
.roll-item.is-absent { background: var(--coral-100); border-color: #f6d1c7; }
.roll-num { color: var(--slate-300); font-size: 12px; text-align: center; }
.roll-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.roll-toggle { display: flex; gap: 6px; }
.pill { position: relative; cursor: pointer; }
.pill input { position: absolute; opacity: 0; pointer-events: none; }
.pill span {
    display: inline-flex; align-items: center; gap: 4px; padding: 7px 12px; min-height: 36px;
    border-radius: 99px; border: 1px solid var(--slate-200); background: #fff; color: var(--slate-500);
    font-size: 13px; font-weight: 500; transition: all .12s; user-select: none;
}
.pill span .icon { width: 15px; height: 15px; }
.pill input:focus-visible + span { outline: 2px solid var(--teal-500); outline-offset: 2px; }
.pill-present input:checked + span { background: var(--teal-700); border-color: var(--teal-700); color: #fff; }
.pill-absent input:checked + span { background: var(--coral-500); border-color: var(--coral-500); color: #fff; }
.roll-note { min-height: 36px !important; padding: 6px 10px !important; font-size: 13px !important; }
.sticky-actions { display: flex; justify-content: flex-end; }

/* ---------- Details, charts ---------- */
.details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; }
.details dt { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--slate-400); }
.details dd { font-weight: 500; word-break: break-word; }
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-label { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; margin-bottom: 4px; }
.bar-track { height: 8px; background: var(--slate-50); border-radius: 99px; overflow: hidden; }
.bar-track span { display: block; height: 100%; background: linear-gradient(90deg, var(--teal-500), var(--teal-300)); border-radius: 99px; }
.mini-chart { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; height: 200px; align-items: end; }
.mini-col { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; font-size: 11px; color: var(--slate-400); }
.mini-track { width: 100%; max-width: 44px; height: 140px; background: var(--slate-50); border-radius: 8px; display: flex; align-items: flex-end; overflow: hidden; }
.mini-track span { display: block; width: 100%; background: var(--teal-700); border-radius: 8px 8px 0 0; }
.duo-chart { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; height: 220px; align-items: end; }
.duo-col { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.duo-bars { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 3px; }
.duo-bars span { width: 40%; max-width: 16px; border-radius: 4px 4px 0 0; min-height: 2px; }
.duo-bars .in { background: var(--teal-500); }
.duo-bars .out { background: var(--coral-500); }
.duo-col small { font-size: 11px; color: var(--slate-400); }
.legend { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--slate-500); }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-left: 8px; }
.dot-in { background: var(--teal-500); }
.dot-out { background: var(--coral-500); }

/* ---------- Receipt ---------- */
.receipt-toolbar { display: flex; gap: 8px; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; }
.receipt { max-width: 780px; margin: 0 auto 30px; background: #fff; border: 1px solid var(--slate-100); border-radius: var(--radius-lg); padding: 36px 40px; }
.receipt-head { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 20px; border-bottom: 2px solid var(--teal-900); flex-wrap: wrap; }
.receipt-brand { font-family: var(--font-serif); font-style: italic; font-size: 26px; color: var(--teal-900); }
.receipt-sub { font-size: 12.5px; color: var(--slate-500); }
.receipt-no { text-align: right; }
.receipt-no span { display: block; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--slate-400); }
.receipt-no strong { display: block; font-size: 22px; color: var(--teal-900); }
.receipt-no small { color: var(--slate-500); }
.receipt-party { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 24px; padding: 20px 0; }
.receipt-party span { display: block; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--slate-400); }
.receipt-party strong { font-weight: 500; }
.receipt-table { width: 100%; border-collapse: collapse; margin-bottom: 18px; font-size: 14px; }
.receipt-table th { text-align: left; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--slate-400); padding: 8px 10px; border-bottom: 1px solid var(--slate-100); }
.receipt-table td { padding: 10px; border-bottom: 1px solid var(--slate-100); }
.receipt-table .num { text-align: right; white-space: nowrap; }
.receipt-table tfoot td { font-weight: 600; font-size: 16px; color: var(--teal-900); border-bottom: none; border-top: 2px solid var(--teal-900); }
.receipt-balance { padding: 10px 14px; border-radius: var(--radius-md); font-size: 13.5px; font-weight: 500; }
.receipt-balance.is-ok { background: #edfaf5; color: #0a4731; }
.receipt-balance.is-due { background: var(--coral-100); color: var(--coral-900); }
.receipt-note { margin-top: 10px; font-size: 13px; color: var(--slate-600); }
.receipt-sign { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-top: 30px; }
.receipt-sign span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--slate-400); }
.sign-box { width: 220px; height: 90px; border: 1px dashed var(--slate-200); border-radius: var(--radius-md); display: flex; align-items: flex-end; justify-content: center; padding-bottom: 8px; font-size: 11px; color: var(--slate-300); }

/* ---------- Login ---------- */
.login-page { display: flex; align-items: center; justify-content: center; padding: 20px; background: radial-gradient(circle at 20% 10%, var(--teal-50), var(--slate-50) 60%); }
.login-card { width: 100%; max-width: 410px; background: #fff; border: 1px solid var(--slate-100); border-radius: 18px; padding: 36px 32px; box-shadow: var(--shadow-md); }
.login-logo { width: 52px; height: 52px; border-radius: 14px; background: var(--teal-900); color: var(--teal-300); display: flex; align-items: center; justify-content: center; margin-bottom: 16px; }
.login-logo .icon { width: 26px; height: 26px; }
.login-card h1 { font-family: var(--font-serif); font-style: italic; font-weight: 400; font-size: 28px; color: var(--teal-900); line-height: 1.2; }
.login-tagline { color: var(--slate-400); font-size: 13px; margin: 4px 0 24px; }
.login-card .btn { margin-top: 6px; min-height: 46px; }

/* ---------- Scroll to top ---------- */
.scroll-top {
    position: fixed; right: 18px; bottom: 18px; z-index: 150;
    width: 44px; height: 44px; border-radius: 50%; border: none; cursor: pointer;
    background: var(--teal-900); color: var(--teal-300); box-shadow: var(--shadow-md);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .2s, transform .2s;
}
.scroll-top.is-visible { opacity: 1; transform: none; pointer-events: auto; }
.scroll-top:hover { background: var(--teal-700); }


/* ==========================================================================
   VERSION 4 — niveaux, paiement par matière, notes, journal, logo
   ========================================================================== */

/* ---------- Logo ---------- */
.sidebar-logo { width: 44px; height: 44px; object-fit: contain; border-radius: 10px; background: #fff; padding: 3px; margin-bottom: 8px; }
.login-logo-img { width: 72px; height: 72px; object-fit: contain; margin-bottom: 14px; }
.receipt-id { display: flex; align-items: center; gap: 14px; }
.doc-logo { width: 64px; height: 64px; object-fit: contain; flex-shrink: 0; }
.logo-field { display: flex; align-items: center; gap: 14px; }
.logo-field > div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.logo-preview { width: 64px; height: 64px; object-fit: contain; border-radius: var(--radius-md); border: 1px solid var(--slate-100); background: #fff; flex-shrink: 0; }
.logo-preview.is-empty { display: flex; align-items: center; justify-content: center; color: var(--slate-300); }
input[type=file] { width: 100%; font-size: 13px; padding: 8px; border: 1px dashed var(--slate-200); border-radius: var(--radius-md); background: var(--slate-50); cursor: pointer; }
input[type=file]::file-selector-button { font: inherit; border: none; border-radius: 6px; padding: 6px 12px; margin-right: 10px; background: var(--teal-900); color: var(--teal-300); cursor: pointer; }
.form-actions-start { justify-content: flex-start; }
.inline-filter { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-filter select { width: auto; min-width: 180px; }

/* ---------- Attendance: 4 statuses ---------- */
.roll-toggle { flex-wrap: wrap; }
.pill-late input:checked + span { background: var(--amber-500); border-color: var(--amber-500); color: #fff; }
.pill-excused input:checked + span { background: var(--slate-500); border-color: var(--slate-500); color: #fff; }
.roll-item.is-late { background: var(--amber-100); border-color: #f2dfb3; }
.roll-item.is-excused { background: var(--slate-50); border-color: var(--slate-200); }

/* ---------- Échéancier par matière ---------- */
.due-months { display: flex; flex-direction: column; gap: 12px; }
.due-month { border: 1px solid var(--slate-100); border-radius: var(--radius-lg); overflow: hidden; background: #fff; }
.due-month.state-late { border-color: #f6d1c7; box-shadow: inset 3px 0 0 var(--coral-500); }
.due-month.state-today { box-shadow: inset 3px 0 0 var(--amber-500); }
.due-month.state-paid { background: var(--slate-50); }
.due-month-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px; flex-wrap: wrap; }
.due-month-head .list-main { min-width: 180px; }
.due-month-total { display: flex; flex-direction: column; align-items: flex-end; text-align: right; }
.due-month-total strong { font-size: 16px; font-weight: 600; color: var(--teal-900); white-space: nowrap; }
.due-month-total small { font-size: 11.5px; color: var(--slate-400); white-space: nowrap; }
.due-lines { list-style: none; border-top: 1px solid var(--slate-100); }
.due-line {
    display: grid; grid-template-columns: minmax(150px, 1.6fr) repeat(4, minmax(84px, .8fr)) minmax(96px, auto) auto;
    align-items: center; gap: 10px; padding: 8px 14px 8px 80px; border-bottom: 1px dashed var(--slate-100); font-size: 13px;
}
.due-line:last-child { border-bottom: none; }
.due-line.is-late .due-line-name strong { color: var(--coral-900); }
.due-line-name { display: flex; flex-direction: column; min-width: 0; }
.due-line-name strong { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.due-line-name small { color: var(--slate-400); font-size: 11.5px; }
.due-line-num { text-align: right; white-space: nowrap; }
.due-line .row-actions { justify-content: flex-end; }

/* Pay modal: subjects picker */
.picker-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.picker-head label { margin: 0; display: block; font-size: 11px; font-weight: 500; letter-spacing: .07em; text-transform: uppercase; color: var(--teal-900); }
.due-picker { max-height: 34vh; }
.due-picker-month { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--slate-400); padding: 6px 2px 0; }
.due-picker .check-row { align-items: center; }
.due-picker .check-row > span:nth-of-type(1) { flex: 1; }
.picker-amount { font-weight: 600; white-space: nowrap; color: var(--teal-900); }
.check-row.is-checked { border-color: var(--teal-500); background: var(--teal-50); }
.bar-inline { width: 90px; display: inline-block; vertical-align: middle; margin-right: 6px; }

/* ---------- Notes ---------- */
.grade-list { list-style: none; display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.grade-item {
    display: grid; grid-template-columns: 28px minmax(0, 1fr) auto auto minmax(160px, 300px); align-items: center; gap: 12px;
    padding: 8px 10px; border-radius: var(--radius-md); border: 1px solid var(--slate-100);
}
.grade-item:focus-within { border-color: var(--teal-500); background: var(--teal-50); }
.grade-score { display: inline-flex; align-items: center; gap: 6px; }
.grade-score input { width: 84px !important; min-height: 38px; text-align: center; font-weight: 600; font-size: 15px; }
.grade-score small { color: var(--slate-400); white-space: nowrap; }
.grade-absent { margin: 0; font-size: 12.5px; color: var(--slate-500); }
.grade-matrix th .cell-sub { text-transform: none; letter-spacing: 0; font-weight: 400; }
.grade-matrix td:first-child { position: sticky; left: 0; background: #fff; z-index: 1; }
.bulletin { margin-bottom: 24px; }
.bulletin-table td { vertical-align: top; }
.bulletin-obs { margin-top: 18px; }
.bulletin-obs > span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--slate-400); margin-bottom: 6px; }
.obs-box { height: 70px; border: 1px dashed var(--slate-200); border-radius: var(--radius-md); }
.print-only { display: none; }
.print-title { font-family: var(--font-serif); font-style: italic; font-size: 20px; color: var(--teal-900); margin-bottom: 10px; }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

/* Large tablets / small laptops: icon rail sidebar */
@media (max-width: 1180px) {
    :root { --sidebar-w: 72px; --gutter: 24px; }
    .sidebar { padding: 16px 10px; }
    .sidebar-head { justify-content: center; padding: 0 0 12px; }
    .sidebar-brand .name { font-size: 0; }
    .sidebar-brand .name::first-letter { font-size: 22px; }
    .sidebar-brand .sub, .sidebar-nav a span, .who { display: none; }
    .sidebar-nav a { justify-content: center; padding: 11px; }
    .sidebar-nav a .nav-icon { width: 20px; height: 20px; }
    .sidebar-nav a { position: relative; }
    .sidebar-user { flex-direction: column; }
    .who-link { justify-content: center; flex: none; }
    .kpi-grid, .alert-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .week-board { grid-template-columns: repeat(7, minmax(150px, 1fr)); }
}

@media (max-width: 960px) {
    .grid-2, .grid-wide-left { grid-template-columns: minmax(0, 1fr); }
    .roll-item { grid-template-columns: 24px minmax(0, 1fr) auto; }
    .roll-note { grid-column: 2 / -1; }
    .grade-item { grid-template-columns: 24px minmax(0, 1fr) auto auto; }
    .grade-item .roll-note { grid-column: 2 / -1; }
    .due-line { grid-template-columns: minmax(0, 1fr) repeat(4, auto); padding-left: 14px; }
    .due-line-state, .due-line .row-actions { grid-column: 1 / -1; justify-self: end; }
}

/* Phones & small tablets: off-canvas sidebar, card tables, bottom-sheet modals */
@media (max-width: 760px) {
    :root { --gutter: 14px; }
    body { font-size: 14px; }

    .mobile-topbar {
        display: flex; align-items: center; justify-content: space-between; gap: 8px;
        position: sticky; top: 0; z-index: 100;
        height: var(--topbar-h); padding: 0 8px;
        padding-top: env(safe-area-inset-top);
        background: rgba(255,255,255,.94); backdrop-filter: blur(8px);
        border-bottom: 1px solid var(--slate-100);
    }
    .mobile-topbar .icon-btn { width: 42px; height: 42px; color: var(--teal-900); }
    .mobile-topbar .icon { width: 22px; height: 22px; }
    .mobile-brand { font-family: var(--font-serif); font-style: italic; font-size: 19px; color: var(--teal-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

    .sidebar {
        width: min(300px, 86vw); left: 0; transform: translateX(-105%);
        transition: transform .25s ease; padding: 18px 12px 14px; box-shadow: var(--shadow-lg);
    }
    body.sidebar-open .sidebar { transform: none; }
    .sidebar-overlay { display: block; position: fixed; inset: 0; z-index: 110; background: rgba(13,61,58,.45); opacity: 0; pointer-events: none; transition: opacity .25s; }
    body.sidebar-open .sidebar-overlay { opacity: 1; pointer-events: auto; }
    .sidebar-head { justify-content: space-between; padding: 0 8px 14px; }
    .sidebar .sidebar-close { display: inline-flex; }
    .sidebar-brand .name { font-size: 20px; }
    .sidebar-brand .sub, .sidebar-nav a span, .who { display: block; }
    .who { display: flex; }
    .sidebar-nav a { justify-content: flex-start; padding: 11px 12px; font-size: 14.5px; }
    .sidebar-user { flex-direction: row; }
    .who-link { flex: 1; justify-content: flex-start; }

    .main-content { margin-left: 0; padding: 16px var(--gutter) 90px; }
    .page-header { margin-bottom: 16px; align-items: flex-start; }
    .page-header h1 { font-size: 23px; }
    .page-actions { width: 100%; }
    .page-actions .btn { flex: 1 1 auto; }
    .hero { padding: 20px; }
    .hero h1 { font-size: 23px; }
    .hero-actions { width: 100%; }
    .hero-actions .btn { flex: 1; }

    .kpi-grid, .kpi-grid.kpi-3, .alert-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .kpi { padding: 12px; gap: 10px; flex-direction: column; align-items: flex-start; }
    .kpi-icon { width: 34px; height: 34px; border-radius: 10px; }
    .kpi strong { font-size: 16px; }
    .strip-item { padding: 10px; gap: 8px; }
    .strip-item strong { font-size: 13px; }

    .card { padding: 16px 14px; border-radius: 12px; margin-bottom: 14px; }
    .toolbar { flex-direction: column; }
    .toolbar select { width: 100%; }
    .search-field { min-width: 0; }
    .filter-bar .form-group { min-width: calc(50% - 6px); }
    .filter-bar > .btn { width: 100%; }

    .form-grid, .details, .check-grid, .receipt-party { grid-template-columns: minmax(0, 1fr); }
    .span-2 { grid-column: auto; }
    input, select, textarea { font-size: 16px !important; } /* no iOS zoom */

    /* Tables become cards */
    .table-cards thead { display: none; }
    .table-cards, .table-cards tbody, .table-cards tr, .table-cards td, .table-cards tfoot { display: block; width: 100%; }
    .table-cards tbody tr {
        border: 1px solid var(--slate-100); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; background: #fff;
    }
    .table-cards tbody tr:hover { background: #fff; }
    .table-cards tbody tr.row-danger { border-left: 3px solid var(--coral-500); }
    .table-cards tr.row-danger td:first-child { box-shadow: none; }
    .table-cards td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0; border: none; white-space: normal; text-align: right; }
    .table-cards td::before { content: attr(data-label); font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--slate-400); text-align: left; flex-shrink: 0; }
    .table-cards td:first-child { display: block; text-align: left; padding: 2px 0 8px; border-bottom: 1px solid var(--slate-100); margin-bottom: 4px; font-size: 15px; }
    .table-cards td:first-child::before { display: none; }
    .table-cards td.wrap { max-width: none; min-width: 0; }
    .table-cards td.num { text-align: right; }
    .table-cards td.actions-col { width: 100%; padding-top: 8px; margin-top: 4px; border-top: 1px solid var(--slate-100); }
    .table-cards td.actions-col::before { display: none; }
    .table-cards .row-actions { width: 100%; justify-content: flex-end; gap: 4px; }
    .table-cards .row-actions .btn { flex: 1; }
    .table-cards .icon-btn { width: 40px; height: 40px; background: var(--slate-50); }
    .table-cards tr.empty-row { border: none; padding: 0; }
    .table-cards tr.empty-row td { display: block; text-align: center; }
    .table-cards tr.empty-row td::before { display: none; }
    .table-cards tfoot tr { display: flex; flex-direction: column; padding: 10px 12px; background: var(--teal-50); border-radius: 12px; }
    .table-cards tfoot td { border: none; padding: 3px 0; display: flex; justify-content: space-between; }
    .table-cards .chips { justify-content: flex-end; }
    .table-wrap { overflow: visible; margin: 0; padding: 0; }

    /* Bottom-sheet modals */
    .modal { align-items: flex-end; padding: 0; }
    .modal-panel, .modal.modal-lg .modal-panel {
        max-width: none; max-height: 92vh; max-height: 92dvh;
        border-radius: 18px 18px 0 0; transform: translateY(100%);
    }
    .modal.is-open .modal-panel { transform: none; }
    .modal-head { padding: 14px 16px; position: relative; }
    .modal-head::before { content: ''; position: absolute; top: 6px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: var(--slate-200); }
    .modal-body { padding: 14px 16px 0; }
    .modal-actions { margin: 6px -16px 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-radius: 0; }
    .modal-actions .btn { flex: 1; min-height: 46px; }

    /* Schedules: stacked days */
    .week-board { grid-template-columns: minmax(0, 1fr); overflow: visible; }
    .day-col:not(.is-today) .day-body:has(.day-empty) { display: none; }

    /* Attendance */
    .roll-item { grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 10px; }
    .roll-num { display: none; }
    .roll-name { white-space: normal; font-size: 15px; }
    .roll-toggle { display: grid; grid-template-columns: 1fr 1fr; }
    .pill span { width: 100%; justify-content: center; min-height: 44px; font-size: 14px; }
    .roll-note { grid-column: auto; }
    .roll-toggle { grid-template-columns: 1fr 1fr; }
    .grade-item { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 10px; }
    .grade-item .roll-num { display: none; }
    .grade-item .roll-name { grid-column: 1 / -1; }
    .grade-item .roll-note { grid-column: 1 / -1; }

    /* Échéancier par matière */
    .due-month-head { gap: 10px; }
    .due-month-head .list-main { flex: 1 1 calc(100% - 70px); }
    .due-month-total { align-items: flex-start; text-align: left; flex: 1; }
    .due-month-head > .btn { flex: 1 1 100%; }
    .due-line { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 10px 14px; }
    .due-line-name { flex: 1 1 100%; }
    .due-line-num { flex: 1 1 40%; display: flex; justify-content: space-between; font-size: 13px; }
    .due-line-num::before { content: attr(data-label); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--slate-400); }
    .due-line-state { flex: 1; }
    .due-line .row-actions { flex: 1 1 100%; }
    .due-line .row-actions .btn { flex: 1; }
    .logo-field { align-items: flex-start; }
    .inline-filter, .inline-filter select { width: 100%; }
    .sticky-actions {
        position: sticky; bottom: 0; margin: 0 -14px -16px; padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
        background: rgba(255,255,255,.96); backdrop-filter: blur(6px); border-top: 1px solid var(--slate-100); border-radius: 0 0 12px 12px;
    }
    .sticky-actions .btn { width: 100%; min-height: 48px; }

    .duo-chart { gap: 3px; height: 180px; }
    .duo-bars span { width: 45%; }
    .mini-chart { height: 170px; }
    .mini-track { height: 110px; }

    .receipt { padding: 20px 16px; }
    .receipt-head { flex-direction: column; }
    .receipt-no { text-align: left; }
    .receipt-sign { flex-direction: column; align-items: stretch; }
    .sign-box { width: 100%; }
    .scroll-top { bottom: calc(16px + env(safe-area-inset-bottom)); right: 14px; }
    body:has(.sticky-actions) .scroll-top { bottom: 86px; }
}

@media (max-width: 380px) {
    .kpi-grid, .kpi-grid.kpi-3, .alert-strip { grid-template-columns: minmax(0, 1fr); }
    .kpi { flex-direction: row; align-items: center; }
}

/* ---------- Print (receipts) ---------- */
@media print {
    @page { margin: 12mm; }
    body { background: #fff; font-size: 12px; }
    .sidebar, .mobile-topbar, .sidebar-overlay, .scroll-top, .alert, .no-print, .receipt-toolbar, .page-actions, .skip-link { display: none !important; }
    .main-content { margin: 0; padding: 0; max-width: none; }
    .receipt { border: none; padding: 0; max-width: none; }
    .card { border: none; padding: 0; }
    a { color: inherit; }
    .print-only { display: block !important; }
    body:has(.print-title) .page-header { display: none; }
    .page-header p { display: none; }
    .kpi-grid, .filter-bar, .toolbar, .tabs, .hero, .actions-col, .row-actions, .slot-actions, .slot-link, .day-empty { display: none !important; }
    .week-board { display: grid !important; grid-template-columns: repeat(7, minmax(0, 1fr)) !important; gap: 4px; overflow: visible; }
    .day-col { break-inside: avoid; border: 1px solid #ccc; }
    .day-col:not(.is-today) .day-body:has(.day-empty) { display: flex !important; }
    .slot { border-left-width: 2px; padding: 5px; font-size: 10px; background: #f3f3f3; }
    .bulletin { break-after: page; page-break-after: always; margin: 0; }
    .bulletin:last-of-type { break-after: auto; page-break-after: auto; }
    .grade-matrix { font-size: 11px; }
    .grade-matrix td:first-child { position: static; }
    .table-wrap { overflow: visible; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------- v4.1 : paiements par mois, journal ---------- */
.kpi small.kpi-sub { text-transform: none; letter-spacing: 0; font-size: 11.5px; margin-top: 2px; }
.kpi-warn .kpi-icon { background: var(--amber-100); color: var(--amber-900); }
.kpi-warn strong { color: var(--amber-900); }
.alert-static { margin-bottom: 16px; }
.pay-month { display: flex; flex-direction: column; gap: 4px; }
.pay-month + .pay-month { margin-top: 4px; }
.pay-month-head strong { font-size: 14px; }
.check-row.check-sub { margin-left: 28px; padding-top: 6px; padding-bottom: 6px; }
.due-month.is-virtual { border-style: dashed; background: transparent; }
.cell-sub .badge, .cell-title + .badge { margin-left: 4px; }
td .badge + .cell-sub { margin-top: 4px; }
.log-day { background: var(--slate-50); }
.log-day td { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--slate-500); padding-top: 10px; padding-bottom: 10px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip-link { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--slate-100); background: #fff; color: var(--slate-600); font-size: 13px; text-decoration: none; }
.chip-link:hover { border-color: var(--slate-200); }
.chip-link.active { background: var(--teal-500); border-color: var(--teal-500); color: #fff; }
.chip-link .count { font-size: 11px; opacity: .75; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; flex-wrap: wrap; }
.pager .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.cell-stack { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
@media (max-width: 720px) { .table-cards .cell-stack { align-items: flex-end; text-align: right; } }
.toolbar select { min-width: 140px; }
.toolbar .inline-form select { min-width: 150px; }
.alert-receipt { align-items: center; }
.alert-receipt .btn { margin-left: auto; }
.due-details summary { cursor: pointer; padding: 8px 16px; font-size: 12.5px; color: var(--slate-500); list-style: none; }
.due-details summary::-webkit-details-marker { display: none; }
.due-details summary::before { content: '▸ '; }
.due-details[open] summary::before { content: '▾ '; }
.pay-more > summary { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; padding: 8px 4px; font-size: 13px; color: var(--teal-700); list-style: none; }
.pay-more > summary::-webkit-details-marker { display: none; }
.pay-more[open] > summary { margin-bottom: 4px; }
.pay-more .pay-month + .pay-month { margin-top: 4px; }
tr.is-new td { background: var(--teal-50); }
.table td .cell-stack { white-space: normal; max-width: 250px; }
.table td .cell-stack .cell-sub { line-height: 1.35; }
