/* ==========================================================================
   UniGest — système de design
   ========================================================================== */
:root {
  --bg: #f3f5fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;

  --primary: #1f8f43;
  --primary-600: #17733a;
  --primary-50: #ecf8f0;
  --primary-100: #d3efdc;
  --success: #059669;
  --success-50: #ecfdf5;
  --warning: #d97706;
  --warning-50: #fffbeb;
  --danger: #dc2626;
  --danger-50: #fef2f2;
  --info: #0284c7;
  --info-50: #f0f9ff;
  --violet: #7c3aed;
  --violet-50: #f5f3ff;
  --neutral-50: #f1f5f9;

  --sidebar: #0c2415;
  --sidebar-2: #123621;
  --sidebar-text: #c3dccb;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .07);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, .14);
  --sidebar-w: 264px;
  --topbar-h: 64px;
  --font: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
/* Filet de sécurité : un mot insécable très long (email, URL, matricule) revient à la ligne
   au lieu de déborder de son conteneur. N'affecte pas le texte qui peut se couper normalement. */
body { margin: 0; font-family: var(--font); font-size: 14.5px; line-height: 1.5; color: var(--text); background: var(--bg); overflow-wrap: break-word; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-600); text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
p { margin: 0 0 .75rem; }
img { max-width: 100%; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
code { background: var(--neutral-50); padding: .1rem .35rem; border-radius: 5px; font-size: .85em; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
[hidden] { display: none !important; }

/* --- Structure ------------------------------------------------------------ */
.app { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 50;
  background: linear-gradient(180deg, var(--sidebar) 0%, #0f2e1b 100%); color: var(--sidebar-text);
  display: flex; flex-direction: column; transition: transform .25s ease;
}
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1.1rem .9rem; }
.brand { display: flex; align-items: center; gap: .75rem; color: #fff; text-decoration: none !important; min-width: 0; }
.brand-mark { flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 1.25rem;
  background: #fff; box-shadow: 0 6px 16px rgba(0, 0, 0, .25); }
.brand-mark img { width: 30px; height: auto; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 1.05rem; letter-spacing: .01em; }
.brand-text small { color: var(--sidebar-text); font-size: .74rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .25rem .75rem 1rem; scrollbar-width: thin; scrollbar-color: #2c5a3b transparent; }
.nav-section { margin-top: 1rem; }
.nav-section-title { font-size: .68rem; text-transform: uppercase; letter-spacing: .09em; color: #7fae8e; padding: 0 .75rem .35rem; font-weight: 600; }
.nav-link { display: flex; align-items: center; gap: .75rem; padding: .55rem .75rem; border-radius: 10px; color: var(--sidebar-text);
  font-size: .9rem; font-weight: 500; text-decoration: none !important; transition: background .15s, color .15s; }
.nav-link i { font-size: 1.05rem; width: 1.2rem; text-align: center; opacity: .9; }
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-link.active { background: linear-gradient(90deg, rgba(46, 157, 71, .38), rgba(46, 157, 71, .08)); color: #fff; box-shadow: inset 3px 0 0 #5cc27a; }
.sidebar-footer { padding: .9rem 1.25rem; font-size: .78rem; border-top: 1px solid rgba(255, 255, 255, .07); color: #9cc4a8; }
.sidebar-close { display: none; color: #fff; }
.sidebar-backdrop { display: none; }

.main { margin-left: var(--sidebar-w); min-width: 0; min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: 1rem;
  padding: 0 1.5rem; background: rgba(255, 255, 255, .88); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.topbar-spacer { flex: 1; }
.topbar-search { flex: 1; max-width: 520px; position: relative; }
.topbar-search i { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.topbar-search input { width: 100%; height: 40px; padding: 0 .9rem 0 2.4rem; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface-2); font: inherit; color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s, background .15s; }
.topbar-search input:focus { background: #fff; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-50); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.menu-btn { display: none; }
.child-switcher { display: flex; align-items: center; gap: .5rem; background: var(--primary-50); border: 1px solid var(--primary-100);
  padding: .25rem .5rem .25rem .75rem; border-radius: 999px; color: var(--primary-600); }
.child-switcher select { border: 0; background: transparent; font: inherit; font-weight: 600; color: var(--primary-600); max-width: 240px; cursor: pointer; outline: none; }

.icon-btn { position: relative; width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent; display: grid; place-items: center;
  font-size: 1.2rem; color: var(--text-2); cursor: pointer; transition: background .15s; }
.icon-btn:hover { background: var(--neutral-50); }
.dot-count { position: absolute; top: 4px; right: 3px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--danger);
  color: #fff; font-size: .68rem; font-weight: 700; display: grid; place-items: center; border: 2px solid #fff; }
.user-btn { display: flex; align-items: center; gap: .6rem; border: 0; background: transparent; padding: .3rem .5rem; border-radius: 12px; cursor: pointer; font: inherit; color: var(--text); text-align: left; }
.user-btn:hover { background: var(--neutral-50); }
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-meta small { color: var(--muted); font-size: .74rem; max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .8rem;
  background: linear-gradient(135deg, #dcf3e3, #bfe6cb); color: var(--primary-600); overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 84px; height: 84px; font-size: 1.6rem; }

.content { padding: 1.5rem 1.75rem 3rem; width: 100%; max-width: 1480px; margin: 0 auto; flex: 1; }

/* --- Dropdowns ------------------------------------------------------------- */
.dropdown { position: relative; }
.dropdown-menu { display: none; position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; background: #fff; border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-lg); padding: .4rem; z-index: 60; }
.dropdown.open .dropdown-menu { display: block; animation: pop .14s ease-out; }
.dropdown-menu > a, .dropdown-menu > form > button { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .55rem .7rem; border-radius: 8px;
  color: var(--text-2); background: none; border: 0; font: inherit; cursor: pointer; text-align: left; text-decoration: none; }
.dropdown-menu > a:hover, .dropdown-menu > form > button:hover { background: var(--neutral-50); color: var(--text); text-decoration: none; }
.dropdown-wide { width: 380px; max-width: calc(100vw - 2rem); padding: 0; overflow: hidden; }
.dropdown-header { display: flex; justify-content: space-between; align-items: center; padding: .8rem 1rem; border-bottom: 1px solid var(--border); }
.dropdown-footer { display: block; text-align: center; padding: .7rem; border-top: 1px solid var(--border); font-weight: 600; font-size: .85rem; }
.dropdown-empty { padding: 1.5rem; text-align: center; color: var(--muted); }
.notif-item { display: flex; gap: .75rem; width: 100%; text-align: left; border: 0; background: #fff; padding: .75rem 1rem; cursor: pointer; font: inherit;
  border-bottom: 1px solid var(--neutral-50); }
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: #f3fbf5; }
.notif-item.unread strong::after { content: ""; display: inline-block; width: 7px; height: 7px; background: var(--primary); border-radius: 50%; margin-left: .4rem; vertical-align: middle; }
.notif-item > i { font-size: 1.15rem; margin-top: .1rem; }
.notif-item span { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.notif-item strong { font-size: .86rem; color: var(--text); }
.notif-item small { font-size: .78rem; color: var(--text-2); }
.link-btn { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; font-size: .82rem; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* --- En-têtes de page --------------------------------------------------------- */
.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.4rem; }
.page-title { font-size: 1.55rem; font-weight: 700; letter-spacing: -.01em; }
.page-subtitle { color: var(--muted); margin: .3rem 0 0; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.breadcrumb { font-size: .82rem; color: var(--muted); margin-bottom: .3rem; }
.breadcrumb a { color: var(--muted); }
.section-title { font-size: 1.05rem; font-weight: 650; margin: 0 0 .75rem; display: flex; align-items: center; gap: .5rem; }

/* --- Grilles ----------------------------------------------------------------- */
.grid { display: grid; gap: 1.1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid-side { grid-template-columns: minmax(260px, 1fr) minmax(0, 2.4fr); }
.stack { display: flex; flex-direction: column; gap: 1.1rem; }
.flex { display: flex; align-items: center; gap: .6rem; }
.flex-wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.mt-0 { margin-top: 0 !important; } .mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0 !important; } .mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; }
.me-auto { margin-right: auto; } .ms-auto { margin-left: auto; }
.w-100 { width: 100%; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.text-right, .num { text-align: right; }
.text-center { text-align: center; }
.text-danger { color: var(--danger) !important; } .text-success { color: var(--success) !important; } .text-warning { color: var(--warning) !important; }
.nowrap { white-space: nowrap; }
.strong { font-weight: 650; }
.mono { font-variant-numeric: tabular-nums; }

/* --- Cartes ------------------------------------------------------------------ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: 1rem 1.2rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-title { font-size: 1rem; font-weight: 650; display: flex; align-items: center; gap: .5rem; }
.card-title i { color: var(--primary); }
.card-body { padding: 1.2rem; }
.card-body.p-0 { padding: 0; }
.card-footer { padding: .9rem 1.2rem; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.card-link { font-size: .84rem; font-weight: 600; }
.form-card { max-width: 980px; }

/* Statistiques */
.stat { display: flex; align-items: center; gap: 1rem; padding: 1.1rem 1.2rem; }
.stat > div { min-width: 0; }
.stat-icon { flex: none; width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; font-size: 1.3rem; }
.stat-label { color: var(--muted); font-size: .8rem; font-weight: 500; }
.stat-value { font-size: 1.45rem; font-weight: 750; letter-spacing: -.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-meta { font-size: .78rem; color: var(--muted); }
.tone-blue, .tone-info { background: #eaf1ff; color: #2563eb; }
.tone-green, .tone-success { background: var(--success-50); color: var(--success); }
.tone-amber, .tone-warning { background: var(--warning-50); color: var(--warning); }
.tone-red, .tone-danger { background: var(--danger-50); color: var(--danger); }
.tone-violet { background: var(--violet-50); color: var(--violet); }
.tone-gray { background: var(--neutral-50); color: var(--muted); }
i.tone-info, i.tone-success, i.tone-warning, i.tone-danger { background: none; }

/* --- Boutons ------------------------------------------------------------------ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; height: 38px; padding: 0 1rem; border-radius: 10px;
  border: 1px solid transparent; font: inherit; font-weight: 600; font-size: .88rem; cursor: pointer; text-decoration: none !important; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s, color .15s; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--primary-100); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(31, 143, 67, .3); }
.btn-primary:hover { background: var(--primary-600); color: #fff; }
.btn-secondary { background: #fff; color: var(--text-2); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--neutral-50); color: var(--text); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #047857; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; }
.btn-outline-danger { background: #fff; color: var(--danger); border-color: #fecaca; }
.btn-outline-danger:hover { background: var(--danger-50); color: var(--danger); }
.btn-warning { background: var(--warning); color: #fff; }
.btn-sm { height: 32px; padding: 0 .75rem; font-size: .8rem; border-radius: 8px; }
.btn-xs { height: 26px; padding: 0 .55rem; font-size: .74rem; border-radius: 7px; }
.btn-block { width: 100%; height: 44px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-group { display: inline-flex; gap: .4rem; flex-wrap: wrap; }
form.inline { display: inline; }

/* --- Badges ------------------------------------------------------------------ */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .6rem; border-radius: 999px; font-size: .73rem; font-weight: 650; white-space: nowrap; border: 1px solid transparent; }
.badge-success { background: var(--success-50); color: #047857; border-color: #a7f3d0; }
.badge-warning { background: var(--warning-50); color: #b45309; border-color: #fde68a; }
.badge-danger { background: var(--danger-50); color: #b91c1c; border-color: #fecaca; }
.badge-info { background: var(--info-50); color: #0369a1; border-color: #bae6fd; }
.badge-primary { background: var(--primary-50); color: var(--primary-600); border-color: var(--primary-100); }
.badge-neutral { background: var(--neutral-50); color: #475569; border-color: var(--border); }
.badge-violet { background: var(--violet-50); color: var(--violet); border-color: #ddd6fe; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }

/* --- Alertes ------------------------------------------------------------------ */
.messages { display: flex; flex-direction: column; gap: .6rem; margin-bottom: 1.2rem; }
.alert { display: flex; align-items: flex-start; gap: .7rem; padding: .8rem 1rem; border-radius: 12px; border: 1px solid; font-size: .9rem; transition: opacity .4s; }
.alert > i { font-size: 1.1rem; margin-top: .05rem; }
.alert > div { flex: 1; }
.alert.fade { opacity: 0; }
.alert-success { background: var(--success-50); border-color: #a7f3d0; color: #065f46; }
.alert-info { background: var(--info-50); border-color: #bae6fd; color: #075985; }
.alert-warning { background: var(--warning-50); border-color: #fde68a; color: #92400e; }
.alert-danger { background: var(--danger-50); border-color: #fecaca; color: #991b1b; }
.alert ul { margin: .25rem 0 0; padding-left: 1.1rem; }
.alert-close { background: none; border: 0; font-size: 1.2rem; line-height: 1; cursor: pointer; color: inherit; opacity: .6; }
.alert-close:hover { opacity: 1; }

/* --- Formulaires ----------------------------------------------------------------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.25rem; }
.form-grid.cols-1 { grid-template-columns: minmax(0, 1fr); }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field > label { font-weight: 600; font-size: .84rem; color: var(--text-2); }
.req { color: var(--danger); }
.help { color: var(--muted); font-size: .78rem; }
.error { color: var(--danger); font-size: .8rem; font-weight: 500; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger) !important; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time], input[type=search],
input[type=tel], input[type=url], select, textarea {
  width: 100%; min-height: 40px; padding: .5rem .75rem; border: 1px solid var(--border-strong); border-radius: 10px; background: #fff;
  font: inherit; color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 80px; resize: vertical; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16'%3E%3Cpath fill='%2364748b' d='M1.6 5.3 8 11.7l6.4-6.4-1.1-1.1L8 9.5 2.7 4.2z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .7rem center; padding-right: 2rem; }
select[multiple] { background-image: none; padding-right: .75rem; min-height: 120px; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-50); }
input[disabled], select[disabled], textarea[disabled] { background: var(--surface-2); color: var(--muted); }
input.invalid { border-color: var(--danger); background: var(--danger-50); }
input[type=file] { font: inherit; font-size: .85rem; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--primary); }
.field-check > label { display: flex; align-items: center; gap: .55rem; font-weight: 500; cursor: pointer; }
.field ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .35rem .9rem; }
.field ul label { display: flex; align-items: center; gap: .5rem; font-weight: 500; cursor: pointer; }
.form-actions { display: flex; justify-content: flex-end; gap: .6rem; flex-wrap: wrap; }
.form-section-title { grid-column: 1 / -1; font-weight: 700; font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding-top: .5rem; border-top: 1px dashed var(--border); }

/* Filtres */
.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; padding: .9rem 1.2rem; border-bottom: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; }
.filter-field { flex: 1 1 170px; min-width: 150px; max-width: 280px; }
.filter-field.filter-q { flex: 2 1 240px; max-width: 360px; }
.filter-field input, .filter-field select { min-height: 36px; padding-top: .35rem; padding-bottom: .35rem; font-size: .86rem; }
.filter-actions { display: flex; gap: .4rem; }

/* --- Tableaux ------------------------------------------------------------------ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th { text-align: left; font-weight: 650; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
  padding: .7rem 1rem; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: .7rem 1rem; border-bottom: 1px solid var(--neutral-50); vertical-align: middle; }
.table tbody tr:hover td { background: #f6fbf7; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.actions { text-align: right; white-space: nowrap; }
.table tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--border); }
.table-compact td, .table-compact th { padding: .45rem .7rem; }
.row-danger td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.row-warning td:first-child { box-shadow: inset 3px 0 0 var(--warning); }
.row-success td:first-child { box-shadow: inset 3px 0 0 var(--success); }
.row-muted td { color: var(--muted); }
.row-muted td del, del { color: var(--muted); }
.person { display: flex; align-items: center; gap: .65rem; min-width: 0; }
.person .avatar { width: 34px; height: 34px; font-size: .75rem; }
.person-name { font-weight: 600; color: var(--text); }
.person-meta { font-size: .76rem; color: var(--muted); }
.sticky-col { position: sticky; left: 0; background: #fff; z-index: 1; }
.table th.sticky-col { background: var(--surface-2); }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem 1.2rem; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pager { display: flex; align-items: center; gap: .3rem; }
.pager-current { font-size: .84rem; padding: 0 .5rem; color: var(--text-2); }

/* Onglets */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.2rem; overflow-x: auto; }
.tab { padding: .7rem 1rem; color: var(--muted); font-weight: 600; font-size: .88rem; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none !important; display: flex; gap: .4rem; align-items: center; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
/* Sur petit écran la série de filtres dépasse la carte : elle défile au lieu de déborder. */
.pills { display: inline-flex; max-width: 100%; overflow-x: auto; background: var(--neutral-50); border-radius: 10px; padding: 3px; gap: 2px; }
.pill { padding: .35rem .85rem; border-radius: 8px; font-size: .82rem; font-weight: 600; color: var(--text-2); text-decoration: none !important; }
.pill.active { background: #fff; color: var(--primary); box-shadow: var(--shadow); }

/* Listes */
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: center; gap: .8rem; padding: .75rem 1.2rem; border-bottom: 1px solid var(--neutral-50); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
/* .title est parfois un lien : sans display:block, la troncature (inline) n'a aucun effet et le texte déborde de la carte. */
.list-item .title { display: block; font-weight: 600; font-size: .9rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .meta { display: block; font-size: .78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-icon { flex: none; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-size: 1.1rem; }
/* La colonne des valeurs doit pouvoir se réduire (minmax(0, 1fr)) : avec un simple "1fr",
   sa largeur minimale reste celle du contenu et une valeur longue déborde de la carte. */
dl.details { display: grid; grid-template-columns: minmax(110px, 38%) minmax(0, 1fr); gap: .55rem 1rem; margin: 0; font-size: .9rem; }
dl.details dt { color: var(--muted); min-width: 0; }
dl.details dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }

/* Vide */
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty i { font-size: 2.2rem; display: block; margin-bottom: .5rem; color: #b6c2d9; }

/* Progression */
.progress { height: 8px; background: #e8edf5; border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 99px; background: var(--primary); }
.progress.success > span { background: var(--success); }
.progress.warning > span { background: var(--warning); }
.progress.danger > span { background: var(--danger); }

/* Profil */
.profile-head { display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap; }
.profile-head h2 { font-size: 1.35rem; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .4rem; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0 0 0 1.1rem; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 0 0 1rem 1rem; }
.timeline li::before { content: ""; position: absolute; left: -1.55rem; top: .3rem; width: 11px; height: 11px; border-radius: 50%; background: #fff; border: 2px solid var(--primary); }
.timeline .when { font-size: .75rem; color: var(--muted); }

/* Graphiques */
.chart-box { position: relative; height: 290px; }
.chart-box.sm { height: 230px; }

/* Segmented control (appel) */
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 9px; overflow: hidden; background: #fff; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { padding: .38rem .7rem; font-size: .78rem; font-weight: 600; cursor: pointer; color: var(--text-2); border-right: 1px solid var(--border); user-select: none; }
.seg label:last-of-type { border-right: 0; }
.seg input:checked + label.s-present { background: var(--success); color: #fff; }
.seg input:checked + label.s-absent { background: var(--danger); color: #fff; }
.seg input:checked + label.s-late { background: var(--warning); color: #fff; }
.seg input:checked + label.s-excused { background: var(--info); color: #fff; }
.seg input:focus-visible + label { box-shadow: inset 0 0 0 2px var(--primary); }
.input-sm { min-height: 32px !important; padding: .25rem .5rem !important; font-size: .84rem !important; }
.input-score { width: 92px !important; text-align: right; font-variant-numeric: tabular-nums; }
.input-minutes { width: 80px !important; }

/* --- Calendrier --------------------------------------------------------------------- */
.cal-toolbar { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; justify-content: space-between; margin-bottom: 1rem; }
.cal-nav { display: flex; align-items: center; gap: .4rem; }
.cal-label { font-weight: 700; font-size: 1.05rem; margin-left: .4rem; }
.cal-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.cal-grid { display: grid; grid-template-columns: 58px repeat(var(--days), minmax(128px, 1fr)); min-width: calc(58px + var(--days) * 128px); }
.cal-head { position: sticky; top: 0; z-index: 2; background: var(--surface-2); border-bottom: 1px solid var(--border); padding: .6rem .5rem; text-align: center; font-size: .8rem; }
.cal-head strong { display: block; font-size: 1.05rem; color: var(--text); }
.cal-head.today { color: var(--primary); }
.cal-head.today strong { color: #fff; background: var(--primary); border-radius: 99px; display: inline-block; min-width: 30px; padding: 0 .4rem; }
.cal-hours, .cal-col { position: relative; height: calc(14 * 58px); }
.cal-col { border-left: 1px solid var(--neutral-50);
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 57px, var(--neutral-50) 57px, var(--neutral-50) 58px); }
.cal-col.today { background-color: #f6fbf7; }
.cal-hour { position: absolute; right: .45rem; transform: translateY(-50%); font-size: .7rem; color: var(--muted); }
.cal-hour:first-child { transform: none; }
.cal-event { position: absolute; margin: 0 3px; padding: .3rem .45rem; border-radius: 8px; font-size: .74rem; line-height: 1.25; overflow: hidden;
  border-left: 3px solid; text-decoration: none !important; box-shadow: 0 1px 2px rgba(0, 0, 0, .06); transition: transform .12s, box-shadow .12s; }
.cal-event:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); z-index: 3; }
.cal-event strong { display: block; font-size: .76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-event span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .85; }
.ev-blue { background: #eef2ff; border-color: #4f6ef7; color: #1e3a8a; }
.ev-green { background: #ecfdf5; border-color: #10b981; color: #065f46; }
.ev-violet { background: #f5f3ff; border-color: #8b5cf6; color: #4c1d95; }
.ev-red { background: #fef2f2; border-color: #ef4444; color: #7f1d1d; }
.ev-amber { background: #fffbeb; border-color: #f59e0b; color: #78350f; }
.ev-gray { background: #f1f5f9; border-color: #94a3b8; color: #64748b; text-decoration: line-through !important; }
.cal-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-month .cal-head { position: static; }
.cal-cell { min-height: 112px; border-right: 1px solid var(--neutral-50); border-bottom: 1px solid var(--neutral-50); padding: .35rem; }
.cal-cell.out { background: var(--surface-2); }
.cal-cell.out .cal-daynum { color: #b6c2d9; }
.cal-daynum { font-size: .8rem; font-weight: 700; color: var(--text-2); margin-bottom: .2rem; display: inline-block; min-width: 24px; text-align: center; border-radius: 99px; }
.cal-cell.today .cal-daynum { background: var(--primary); color: #fff; }
.cal-chip { display: block; font-size: .7rem; padding: .12rem .35rem; border-radius: 5px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 3px solid; text-decoration: none !important; }
.cal-agenda { display: none; }
.agenda-day { font-weight: 700; font-size: .85rem; padding: .7rem 1rem .3rem; color: var(--primary-600); }
.legend { display: flex; gap: .9rem; flex-wrap: wrap; font-size: .78rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: .35rem; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; border-left: 3px solid; }

/* --- Authentification ------------------------------------------------------------ */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: #fff; }
.auth-aside { position: relative; overflow: hidden; color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(1200px 600px at -10% -20%, #2e9d47 0%, transparent 60%), radial-gradient(900px 500px at 120% 120%, #0f6b31 0%, transparent 55%), #0b2414; }
.auth-aside h2 { font-size: 2.1rem; line-height: 1.2; max-width: 30rem; letter-spacing: -.02em; }
.auth-aside p { color: #cfe8d6; max-width: 32rem; }
.auth-features { list-style: none; padding: 0; margin: 2rem 0 0; display: grid; gap: .8rem; }
.auth-features li { display: flex; gap: .7rem; align-items: center; color: #e3f3e8; }
.auth-features i { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: rgba(255, 255, 255, .1); }
.auth-main { display: grid; place-items: center; padding: 2rem; }
.auth-card { width: 100%; max-width: 410px; }
.auth-card h1 { font-size: 1.7rem; margin-bottom: .3rem; }
.auth-card .form-grid { grid-template-columns: minmax(0, 1fr); margin: 1.5rem 0 1.2rem; }
.auth-brand-card { align-self: flex-start; background: #fff; border-radius: 18px; padding: 14px 20px; box-shadow: 0 14px 36px rgba(0, 0, 0, .3); }
.auth-brand-card img { display: block; height: 92px; width: auto; }
.auth-campus { display: flex; gap: .6rem; align-items: flex-start; margin-top: 1rem; color: #cfe8d6; font-size: .86rem; max-width: 32rem; }
.auth-legal { color: #9cc4a8; font-size: .74rem; line-height: 1.45; }
.auth-logo-mobile { display: none; height: 70px; width: auto; margin-bottom: 1.2rem; }

/* --- Divers ---------------------------------------------------------------------- */
.kpi-line { display: flex; justify-content: space-between; align-items: baseline; padding: .45rem 0; border-bottom: 1px dashed var(--border); font-size: .9rem; }
.kpi-line:last-child { border-bottom: 0; }
.kpi-line strong { font-variant-numeric: tabular-nums; }
.big-number { font-size: 2.1rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.hero { background: linear-gradient(120deg, #1f8f43, #0f6b31); color: #fff; border: 0; }
.hero .muted, .hero small { color: #d7f0de; }
.hero a { color: #fff; }
.quick-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.quick-action { display: flex; flex-direction: column; gap: .45rem; padding: .9rem; border: 1px solid var(--border); border-radius: 12px; color: var(--text-2);
  font-weight: 600; font-size: .84rem; text-decoration: none !important; transition: border-color .15s, background .15s, transform .15s; }
.quick-action i { font-size: 1.3rem; color: var(--primary); }
.quick-action:hover { border-color: var(--primary-100); background: var(--primary-50); color: var(--primary-600); transform: translateY(-1px); }
.doc-card { display: flex; gap: .9rem; padding: 1rem; border: 1px solid var(--border); border-radius: 12px; background: #fff; transition: border-color .15s, box-shadow .15s; }
.doc-card:hover { border-color: var(--primary-100); box-shadow: var(--shadow); }
.doc-icon { flex: none; width: 46px; height: 54px; border-radius: 9px; display: grid; place-items: center; font-size: 1.5rem; background: var(--primary-50); color: var(--primary); }
.doc-icon.pdf { background: #fef2f2; color: #dc2626; }
.doc-card h3 { font-size: .95rem; margin-bottom: .2rem; }
.checklist { max-height: 460px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; }
.checklist label { display: flex; align-items: center; gap: .6rem; padding: .55rem .8rem; border-bottom: 1px solid var(--neutral-50); cursor: pointer; font-weight: 500; }
.checklist label:hover { background: var(--surface-2); }
.score-good { color: var(--success); font-weight: 700; }
.score-bad { color: var(--danger); font-weight: 700; }
.error-page { text-align: center; padding: 4rem 1rem; }
.error-page .code { font-size: 4.5rem; font-weight: 800; color: var(--primary); letter-spacing: -.04em; }

/* --- Responsive -------------------------------------------------------------------- */
@media (max-width: 1280px) {
  .grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1080px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .app.sidebar-open .sidebar { transform: none; }
  .app.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 45; }
  .sidebar-close { display: grid; }
  .main { margin-left: 0; }
  .menu-btn { display: grid; }
  /* minmax(0, 1fr) et non 1fr : sinon la colonne garde la largeur minimale de son contenu
     (un tableau large, un long intitulé) et la carte déborde de l'écran. */
  .grid-main, .grid-side, .grid-3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 768px) {
  body { font-size: 14px; }
  .content { padding: 1rem 1rem 2.5rem; }
  .topbar { padding: 0 .75rem; gap: .5rem; }
  .topbar-search { display: none; }
  .hide-sm { display: none !important; }
  .grid-2, .grid-4, .grid-5, .form-grid, .form-grid.cols-3 { grid-template-columns: minmax(0, 1fr); }
  .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .page-title { font-size: 1.3rem; }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-aside { display: none; }
  .auth-logo-mobile { display: block; }
  .cal-hide-mobile { display: none; }
  .cal-agenda { display: block; }
  .child-switcher select { max-width: 150px; }
  dl.details { grid-template-columns: minmax(0, 1fr); gap: .1rem; }
  dl.details dd { margin-bottom: .5rem; }
  .filters { padding: .75rem; }
  .filter-field, .filter-field.filter-q { max-width: none; flex-basis: 100%; }
}

@media (max-width: 480px) {
  /* Les montants sont insécables (espace fine insécable) : sur un écran étroit, deux colonnes
     de statistiques ne peuvent pas les contenir, on repasse à une seule. */
  .grid-stats { grid-template-columns: minmax(0, 1fr) !important; }
}

/* --- Impression --------------------------------------------------------------------- */
@media print {
  .sidebar, .topbar, .page-actions, .filters, .pagination, .no-print { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; }
  .card { box-shadow: none; border-color: #ccc; }
  body { background: #fff; }
}
