/* =====================================================================
   Daara Manager — design system (mobile-first, clair/sombre)
   ===================================================================== */
:root {
  --bg: #f2f5f2; --card: #ffffff; --card-2: #f7faf8; --ink: #11221b; --muted: #66756d; --line: #e2e9e4;
  --brand: #0f766e; --brand-2: #14b8a6; --brand-ink: #ffffff; --brand-soft: #d9f2ee;
  --gold: #d99a1a; --gold-soft: #fbf0d6;
  --ok: #15803d; --ok-soft: #dcf5e4; --warn: #b45309; --warn-soft: #fdf0d3; --bad: #be123c; --bad-soft: #fde2e8;
  --shadow: 0 1px 2px rgba(17,34,27,.05), 0 8px 24px -12px rgba(17,34,27,.18);
  --shadow-lg: 0 20px 50px -12px rgba(17,34,27,.35);
  --r: 20px; --r-sm: 14px; --tab-h: 68px;
  --top-h: 58px; --kb: 0px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0a1310; --card: #111d18; --card-2: #15241e; --ink: #e8f2ed; --muted: #8aa095; --line: #1f3029;
  --brand: #14b8a6; --brand-2: #2dd4bf; --brand-ink: #04211d; --brand-soft: #0f2f2b;
  --gold: #f0b429; --gold-soft: #33290f;
  --ok: #4ade80; --ok-soft: #10301d; --warn: #fbbf24; --warn-soft: #33270b; --bad: #fb7185; --bad-soft: #3a1520;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);
  --shadow-lg: 0 20px 50px -12px rgba(0,0,0,.8);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a1310; --card: #111d18; --card-2: #15241e; --ink: #e8f2ed; --muted: #8aa095; --line: #1f3029;
    --brand: #14b8a6; --brand-2: #2dd4bf; --brand-ink: #04211d; --brand-soft: #0f2f2b;
    --gold: #f0b429; --gold-soft: #33290f;
    --ok: #4ade80; --ok-soft: #10301d; --warn: #fbbf24; --warn-soft: #33270b; --bad: #fb7185; --bad-soft: #3a1520;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);
    --shadow-lg: 0 20px 50px -12px rgba(0,0,0,.8);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }
body {
  margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}
body.noscroll { overflow: hidden; }
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
/* 16 px évite le zoom automatique de Safari iOS lorsque l'on saisit. */
input, select, textarea { font: inherit; font-size: 16px; color: inherit; }
:where(a, button, input, select, textarea):focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand) 65%, transparent);
  outline-offset: 3px;
}
svg.ic { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
.money { font-variant-numeric: tabular-nums; font-weight: 700; letter-spacing: -.01em; }
.ok { color: var(--ok); } .bad { color: var(--bad); } .warn { color: var(--warn); }
[hidden] { display: none !important; }

/* ---------- Shell ---------- */
.shell { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
.side { display: none; }
.main { min-width: 0; padding-bottom: calc(var(--tab-h) + 96px + env(safe-area-inset-bottom)); }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
}
.topbar h1 { font-size: 20px; font-weight: 800; letter-spacing: -.02em; flex: 1; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center;
  background: var(--card); box-shadow: var(--shadow); transition: transform .15s;
}
.icon-btn:active { transform: scale(.92); }
.view { max-width: 920px; margin: 0 auto; padding: 4px 16px 24px; animation: rise .35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); gap: 2px;
  background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: blur(18px) saturate(1.5);
  -webkit-backdrop-filter: blur(18px) saturate(1.5); border-top: 1px solid var(--line);
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 0 5px; border-radius: 16px;
  font-size: 11px; font-weight: 600; color: var(--muted); transition: color .2s, background .2s; position: relative;
}
.tab svg.ic { width: 23px; height: 23px; transition: transform .25s cubic-bezier(.3,1.6,.5,1); }
.tab.active { color: var(--brand); }
.tab.active svg.ic { transform: translateY(-2px) scale(1.12); }
.tab.active::after { content: ""; position: absolute; top: 2px; width: 22px; height: 3px; border-radius: 3px; background: var(--brand); }

@media (min-width: 960px) {
  .shell { grid-template-columns: 250px 1fr; }
  .side {
    display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; padding: 22px 14px;
    background: var(--card); border-right: 1px solid var(--line);
  }
  .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; padding: 4px 10px 18px; }
  .brand .logo { width: 38px; height: 38px; border-radius: 12px; }
  .side .tab { flex-direction: row; gap: 12px; font-size: 14.5px; padding: 11px 14px; justify-content: flex-start; }
  .side .tab.active { background: var(--brand-soft); }
  .side .tab.active::after { display: none; }
  .side .tab.active svg.ic { transform: none; }
  .tabbar { display: none; }
  .main { padding-bottom: 80px; }
  .topbar { padding-top: 18px; }
  .fab { right: max(24px, calc((100vw - 250px - 920px) / 2 + 270px)) !important; bottom: 28px !important; }
}

/* ---------- Cartes & typographie ---------- */
.card { background: var(--card); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); margin-top: 14px; }
.card h3, .section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.link { color: var(--brand); font-weight: 700; font-size: 13px; text-transform: none; letter-spacing: 0; }

/* ---------- Hero tableau de bord ---------- */
.hero {
  position: relative; overflow: hidden; border-radius: 28px; padding: 20px; color: #fff; margin-top: 4px;
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(255,255,255,.18), transparent 55%),
    linear-gradient(135deg, #0f766e 0%, #115e59 55%, #0b3f3a 100%);
  box-shadow: 0 18px 40px -16px rgba(15,118,110,.7);
}
.hero::before {
  content: ""; position: absolute; right: -40px; top: -40px; width: 200px; height: 200px; opacity: .14;
  background: conic-gradient(from 0deg, #fff 0 12.5%, transparent 0 25%, #fff 0 37.5%, transparent 0 50%, #fff 0 62.5%, transparent 0 75%, #fff 0 87.5%, transparent 0);
  border-radius: 50%; mask: radial-gradient(circle, transparent 38%, #000 39%); -webkit-mask: radial-gradient(circle, transparent 38%, #000 39%);
  transform: rotate(22deg);
}
.hero .pill { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,.16); padding: 5px 11px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.hero .label { font-size: 13px; opacity: .85; margin-top: 16px; }
.hero .amount { font-size: clamp(32px, 9vw, 46px); font-weight: 800; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.hero .amount small { font-size: .42em; font-weight: 600; opacity: .8; margin-left: 4px; }
.hero-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px; }
.hero-grid > div { background: rgba(255,255,255,.12); border-radius: 16px; padding: 10px 12px; backdrop-filter: blur(4px); }
.hero-grid span { display: block; font-size: 11.5px; opacity: .8; }
.hero-grid b { font-size: 15px; font-variant-numeric: tabular-nums; }

.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.quick button, .quick a {
  display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 14px 6px; border-radius: 18px;
  background: var(--card); box-shadow: var(--shadow); font-size: 12.5px; font-weight: 700; transition: transform .15s;
  color: inherit; text-decoration: none;
}
.quick button:active, .quick a:active { transform: scale(.95); }
.quick .q-ic { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.quick .q-ic.gold { background: var(--gold-soft); color: var(--gold); }
.quick .q-ic.rose { background: var(--bad-soft); color: var(--bad); }

.rings { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ring-box { display: flex; align-items: center; gap: 12px; }
.ring { width: 76px; height: 76px; flex: none; position: relative; }
.ring svg { transform: rotate(-90deg); }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 16px; font-weight: 800; }
.ring-box small { color: var(--muted); display: block; font-size: 12px; }
.ring-box strong { font-size: 13.5px; }

/* ---------- Graphiques ---------- */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--muted); font-size: 10px; font-family: var(--font); }
.chart .bar { transition: opacity .2s, transform .5s cubic-bezier(.2,.8,.2,1); transform-origin: bottom; transform-box: fill-box; animation: grow .7s cubic-bezier(.2,.8,.2,1) both; }
@keyframes grow { from { transform: scaleY(0); } }
.chart .grp { cursor: pointer; }
.chart .grp.dim .bar { opacity: .35; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.readout { min-height: 20px; margin-top: 8px; font-size: 13px; font-weight: 600; text-align: center; }
.donut-wrap { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.donut { width: 130px; height: 130px; flex: none; }
.donut circle { transition: stroke-dasharray .8s cubic-bezier(.2,.8,.2,1); }
.cat-list { flex: 1; min-width: 180px; display: grid; gap: 7px; }
.cat-list div { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.cat-list i { width: 10px; height: 10px; border-radius: 4px; flex: none; }
.cat-list span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Listes ---------- */
.list { display: grid; gap: 8px; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px; border-radius: 18px;
  background: var(--card); box-shadow: var(--shadow); transition: transform .12s, box-shadow .12s;
  animation: rise .3s ease both;
}
.row:active { transform: scale(.985); }
.row-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.row-main b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-main small { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-end { text-align: right; display: grid; gap: 3px; justify-items: end; flex: none; }
.row-end .money { font-size: 14.5px; }
.avatar {
  --h: 170; width: 44px; height: 44px; border-radius: 15px; flex: none; display: grid; place-items: center;
  font-weight: 800; font-size: 15px; color: hsl(var(--h) 55% 28%); background: hsl(var(--h) 70% 90%);
}
:root[data-theme="dark"] .avatar { color: hsl(var(--h) 70% 82%); background: hsl(var(--h) 40% 20%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .avatar { color: hsl(var(--h) 70% 82%); background: hsl(var(--h) 40% 20%); } }
.avatar.lg { width: 64px; height: 64px; border-radius: 22px; font-size: 22px; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.tag { font-size: 10.5px; font-weight: 800; padding: 2px 7px; border-radius: 99px; background: var(--brand-soft); color: var(--brand); letter-spacing: .02em; }
.tag.gold { background: var(--gold-soft); color: var(--gold); }
.tag.rose { background: var(--bad-soft); color: var(--bad); }
.tag.gray { background: var(--card-2); color: var(--muted); border: 1px solid var(--line); }
.tag.blue { background: #dbeafe; color: #1d4ed8; }
:root[data-theme="dark"] .tag.blue { background: #172554; color: #93c5fd; }

.badge { font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 99px; }
.badge.paye { background: var(--ok-soft); color: var(--ok); }
.badge.partiel { background: var(--warn-soft); color: var(--warn); }
.badge.impaye { background: var(--bad-soft); color: var(--bad); }
.progress { height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; margin-top: 4px; }
.progress > i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); transition: width .6s cubic-bezier(.2,.8,.2,1); }
.progress.warn > i { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.progress.bad > i { background: linear-gradient(90deg, #e11d48, #fb7185); }

/* ---------- Recherche / filtres ---------- */
.searchbar { position: sticky; top: calc(var(--top-h) + env(safe-area-inset-top)); z-index: 10; padding: 6px 0 8px; background: var(--bg); }
.search { display: flex; align-items: center; gap: 10px; padding: 0 14px; height: 46px; border-radius: 16px; background: var(--card); box-shadow: var(--shadow); color: var(--muted); }
.search input { flex: 1; border: 0; outline: 0; background: none; min-width: 0; color: var(--ink); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 2px 4px; scrollbar-width: none; scroll-snap-type: x proximity; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 8px 14px; border-radius: 99px; font-size: 13px; font-weight: 700; background: var(--card);
  color: var(--muted); box-shadow: var(--shadow); transition: all .2s; scroll-snap-align: start; white-space: nowrap;
}
.chip.on { background: var(--brand); color: var(--brand-ink); box-shadow: 0 6px 16px -6px var(--brand); }
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.summary > div { background: var(--card); border-radius: 16px; padding: 10px 12px; box-shadow: var(--shadow); }
.summary span { display: block; font-size: 11.5px; color: var(--muted); }
.summary b { font-size: 15px; font-variant-numeric: tabular-nums; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 6px; }
.empty .btn { margin-top: 14px; }

/* ---------- Boutons & formulaires ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px;
  border-radius: 16px; font-weight: 700; background: var(--brand); color: var(--brand-ink); transition: transform .12s, opacity .2s;
  box-shadow: 0 8px 18px -8px var(--brand);
}
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--card-2); color: var(--ink); box-shadow: none; border: 1px solid var(--line); }
.btn.danger { background: var(--bad-soft); color: var(--bad); box-shadow: none; }
.btn.sm { min-height: 38px; padding: 0 14px; font-size: 13.5px; border-radius: 12px; }
.btn-row { display: flex; gap: 10px; margin-top: 16px; }
.btn-row .btn { flex: 1; }

.fab {
  position: fixed; right: 18px; bottom: calc(var(--tab-h) + 18px + env(safe-area-inset-bottom)); z-index: 25;
  height: 56px; min-width: 56px; padding: 0 20px; border-radius: 20px; display: flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: var(--brand-ink); font-weight: 800;
  box-shadow: 0 14px 30px -8px var(--brand); transition: transform .15s; animation: pop .4s cubic-bezier(.3,1.6,.5,1) both;
}
.fab:active { transform: scale(.93); }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }

.field { display: grid; gap: 6px; margin-top: 14px; }
.field > label, .lbl { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: 0 14px; border-radius: 14px; border: 1.5px solid var(--line);
  background: var(--card-2); outline: 0; transition: border-color .2s, box-shadow .2s;
}
.textarea { padding: 12px 14px; min-height: 84px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent); }
.input.err, .select.err { border-color: var(--bad); }
.err-msg { color: var(--bad); font-size: 12px; font-weight: 600; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.input.big { font-size: 28px; font-weight: 800; height: 62px; text-align: center; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: var(--card-2); border: 1.5px solid var(--line); }
.seg input { display: none; }
.seg label { text-align: center; padding: 10px 6px; border-radius: 10px; font-weight: 700; font-size: 13px; color: var(--muted); cursor: pointer; transition: all .2s; }
.seg input:checked + label { background: var(--brand); color: var(--brand-ink); box-shadow: 0 4px 10px -4px var(--brand); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--card-2); border: 1.5px solid var(--line); margin-top: 10px; font-weight: 600; }
.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { opacity: 0; position: absolute; inset: 0; margin: 0; z-index: 2; cursor: pointer; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: var(--line); transition: background .2s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.25); transition: transform .25s cubic-bezier(.3,1.5,.5,1); }
.switch input:checked + i { background: var(--brand); }
.switch input:checked + i::after { transform: translateX(20px); }
.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.modes input { display: none; }
.modes label { display: grid; justify-items: center; gap: 4px; padding: 10px 4px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--card-2); font-size: 11.5px; font-weight: 700; color: var(--muted); cursor: pointer; transition: all .2s; text-align: center; }
.modes label .em { font-size: 20px; line-height: 1; }
.modes input:checked + label { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.quick-amt { display: flex; gap: 8px; margin-top: 8px; justify-content: center; }
.quick-amt button { padding: 7px 14px; border-radius: 99px; background: var(--card-2); border: 1px solid var(--line); font-size: 12.5px; font-weight: 700; }

/* ---------- Feuilles (bottom sheets) ---------- */
.sheet-root { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; pointer-events: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(5,15,11,.5); opacity: 0; transition: opacity .25s; pointer-events: auto; backdrop-filter: blur(2px); }
.sheet {
  position: relative; width: 100%; max-width: 560px; max-height: 92vh; max-height: 92dvh; display: flex; flex-direction: column;
  background: var(--bg); border-radius: 28px 28px 0 0; transform: translateY(100%); transition: transform .32s cubic-bezier(.2,.9,.25,1);
  pointer-events: auto; box-shadow: var(--shadow-lg); padding-bottom: env(safe-area-inset-bottom);
}
/* Sur mobile, une feuille ouverte remonte au-dessus du clavier virtuel.
   Le déplacement de glisser-fermer reste prioritaire grâce au style inline JS. */
.sheet-root.open .sheet { transform: translateY(min(var(--kb), 40%)); }
.sheet-root.open .sheet-backdrop { opacity: 1; }
.sheet.dragging { transition: none; }
.sheet-grab { width: 42px; height: 5px; border-radius: 5px; background: var(--line); margin: 10px auto 2px; flex: none; touch-action: none; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 6px 18px 10px; flex: none; touch-action: none; }
.sheet-head h2 { flex: 1; font-size: 18px; font-weight: 800; letter-spacing: -.02em; }
.sheet-body { overflow-y: auto; padding: 0 18px 22px; overscroll-behavior: contain; }
@media (min-width: 700px) {
  .sheet-root { align-items: center; }
  .sheet { border-radius: 28px; max-height: 88vh; transform: translateY(30px) scale(.97); opacity: 0; transition: transform .3s, opacity .25s; }
  .sheet-root.open .sheet { transform: none; opacity: 1; }
  .sheet-grab { display: none; }
}

/* ---------- Fiche élève ---------- */
.profile { display: flex; align-items: center; gap: 14px; }
.profile h3 { font-size: 20px; font-weight: 800; letter-spacing: -.02em; text-transform: none; color: var(--ink); margin: 0; display: block; }
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0 4px; }
.actions a, .actions button { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 11px 4px; border-radius: 16px; background: var(--card); box-shadow: var(--shadow); font-size: 12px; font-weight: 700; color: var(--ink); text-decoration: none; }
.actions .disabled { opacity: .4; pointer-events: none; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: var(--card); box-shadow: var(--shadow); margin: 14px 0; }
.tabs button { padding: 10px; border-radius: 10px; font-weight: 700; font-size: 13.5px; color: var(--muted); transition: all .2s; }
.tabs button.on { background: var(--brand); color: var(--brand-ink); }
.info { background: var(--card); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; }
.info > div { display: flex; justify-content: space-between; gap: 14px; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.info > div:last-child { border: 0; }
.info span { color: var(--muted); }
.info b { text-align: right; font-weight: 600; }
.months { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (min-width: 440px) { .months { grid-template-columns: repeat(4, 1fr); } }
.month {
  display: grid; gap: 2px; padding: 10px 6px; border-radius: 14px; text-align: center; border: 1.5px solid var(--line);
  background: var(--card); font-size: 12px; font-weight: 700; transition: transform .12s;
}
.month:active { transform: scale(.94); }
.month b { font-size: 13px; text-transform: capitalize; }
.month small { font-size: 11px; font-weight: 600; opacity: .85; font-variant-numeric: tabular-nums; }
.month.paye { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.month.partiel { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.month.impaye { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pay-row { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.pay-row:last-child { border: 0; }
.pay-row .grow { flex: 1; min-width: 0; display: grid; }
.pay-row small { color: var(--muted); }

/* ---------- Reçu ---------- */
.receipt { background: var(--card); border-radius: 22px; padding: 22px 20px; position: relative; box-shadow: var(--shadow); text-align: center; }
.receipt::before, .receipt::after { content: ""; position: absolute; left: 0; right: 0; height: 10px; background: radial-gradient(circle at 8px 0, var(--bg) 6px, transparent 6.5px) 0 0/16px 10px repeat-x; }
.receipt::before { top: -1px; } .receipt::after { bottom: -1px; transform: scaleY(-1); }
.receipt .ok-ic { width: 54px; height: 54px; margin: 0 auto 8px; border-radius: 50%; display: grid; place-items: center; background: var(--ok-soft); color: var(--ok); }
.receipt .ok-ic svg { width: 28px; height: 28px; stroke-width: 3; }
.receipt .amt { font-size: 34px; font-weight: 800; letter-spacing: -.03em; margin: 6px 0 10px; }
.receipt dl { margin: 12px 0 0; text-align: left; border-top: 1px dashed var(--line); padding-top: 10px; display: grid; gap: 7px; font-size: 13.5px; }
.receipt dl div { display: flex; justify-content: space-between; gap: 12px; }
.receipt dt { color: var(--muted); } .receipt dd { margin: 0; font-weight: 700; text-align: right; }

/* ---------- Divers ---------- */
.toasts { position: fixed; left: 0; right: 0; top: calc(12px + env(safe-area-inset-top)); z-index: 200; display: grid; gap: 8px; justify-items: center; pointer-events: none; padding: 0 16px; }
.toast { background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 16px; font-weight: 600; font-size: 14px; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 8px; animation: drop .35s cubic-bezier(.3,1.4,.5,1) both; max-width: 440px; }
.toast.ok svg { color: #4ade80; } .toast.err { background: var(--bad); color: #fff; }
.toast.out { opacity: 0; transform: translateY(-10px); transition: all .3s; }
@keyframes drop { from { transform: translateY(-24px) scale(.9); opacity: 0; } }
.skeleton { border-radius: 18px; height: 68px; margin-top: 8px; background: linear-gradient(100deg, var(--card) 30%, var(--card-2) 50%, var(--card) 70%); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
@keyframes shimmer { to { background-position: -200% 0; } }
.date-sep { font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 14px 4px 2px; }
.sect { margin-top: 22px; }
.setting-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); width: 100%; text-align: left; }
.setting-row:last-child { border: 0; }
.dot { width: 14px; height: 14px; border-radius: 5px; flex: none; }

/* ---------- Pédagogie ---------- */
.bars { display: grid; gap: 10px; }
.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-lbl { width: 52px; flex: none; font-weight: 800; font-size: 13.5px; }
.bar-track { flex: 1; height: 14px; border-radius: 8px; background: var(--card-2); border: 1px solid var(--line); overflow: hidden; }
.bar-track i { display: block; height: 100%; border-radius: 8px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); transition: width .6s cubic-bezier(.2,.8,.2,1); }
.bar-row b { width: 34px; text-align: right; font-variant-numeric: tabular-nums; font-size: 14px; }
.alerte-card { border-radius: var(--r); }
.alerte-card.gold { background: var(--gold-soft); box-shadow: var(--shadow); }
.alerte-card.rose { background: var(--bad-soft); box-shadow: var(--shadow); }
.alerte-card.gold .q-ic { background: color-mix(in srgb, var(--gold) 18%, transparent); color: var(--gold); }
.alerte-card.rose .q-ic { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); }
.prog-txt { font-style: italic; }

/* ---------- Utilisateur connecté (sidebar) ---------- */
.side-user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 10px 2px; border-top: 1px solid var(--line); }
.side-user .avatar { width: 34px; height: 34px; border-radius: 12px; font-size: 14px; }
.side-user-txt { min-width: 0; display: grid; }
.side-user-txt b { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-txt small { color: var(--muted); font-size: 11.5px; }

/* ---------- Connexion ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background:
  radial-gradient(90% 60% at 50% 0%, color-mix(in srgb, var(--brand) 30%, transparent), transparent 70%), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--card); border-radius: 28px; padding: 28px 22px; box-shadow: var(--shadow-lg); animation: rise .5s ease both; }
.login-card .logo { width: 68px; height: 68px; border-radius: 22px; margin: 0 auto 14px; display: block; box-shadow: 0 14px 30px -10px var(--brand); }
.login-card h1 { text-align: center; font-size: 24px; letter-spacing: -.03em; }
.login-card p.sub { text-align: center; color: var(--muted); margin-top: 4px; font-size: 14px; }
.login-err { color: var(--bad); background: var(--bad-soft); padding: 10px 12px; border-radius: 12px; font-weight: 600; font-size: 13.5px; margin-top: 14px; }

/* ---------- Impression (reçus) ---------- */
@media print {
  body > *:not(.sheet-root) { display: none !important; }
  .sheet-root { position: static; }
  .sheet-backdrop, .sheet-head, .sheet-grab, .no-print { display: none !important; }
  .sheet { box-shadow: none; max-height: none; transform: none !important; background: #fff; }
  .receipt { box-shadow: none; border: 1px solid #ccc; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* =====================================================================
   CGE — sous-navigation, présence, calendrier, notes, documents A4
   ===================================================================== */
.subnav { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -2px 12px; padding: 2px; }
.subnav::-webkit-scrollbar { display: none; }
.subnav .chip { flex: none; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.subnav .chip .ic { width: 15px; height: 15px; }
.tabs.n3 { grid-template-columns: repeat(3, 1fr); } .tabs.n4 { grid-template-columns: repeat(4, 1fr); } .tabs.n4 button, .tabs.n3 button { padding: 10px 4px; font-size: 12.5px; }
.stack { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
.stack > * { min-width: 0; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mt { margin-top: 12px; } .mt2 { margin-top: 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.badge.gray { background: var(--card-2); color: var(--muted); border: 1px solid var(--line); }
.badge.blue { background: #dbeafe; color: #1d4ed8; } :root[data-theme="dark"] .badge.blue { background: #172554; color: #93c5fd; }
.badge.gold { background: var(--gold-soft); color: var(--gold); }
.kpi { background: var(--card); border-radius: var(--r-sm); padding: 12px; box-shadow: var(--shadow); }
.kpi span { display: block; font-size: 11.5px; color: var(--muted); font-weight: 600; } .kpi b { font-size: 19px; letter-spacing: -.02em; }
.kpi b.bad { color: var(--bad); } .kpi b.ok { color: var(--ok); }
.tbl-scroll { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; background: var(--card); border-radius: var(--r-sm); overflow: hidden; }
.tbl th, .tbl td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--card-2); }
.tbl .r { text-align: right; font-variant-numeric: tabular-nums; } .tbl tr.click { cursor: pointer; } .tbl tr.click:hover td { background: var(--card-2); }
.tbl td.low { color: var(--bad); font-weight: 700; } .tbl td.high { color: var(--ok); font-weight: 700; }

/* ----- Appel (présences) ----- */
.att-row { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: var(--r-sm); padding: 10px 12px; box-shadow: var(--shadow); }
.att-row .nm { flex: 1; min-width: 0; font-weight: 700; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-btns { display: flex; gap: 5px; flex: none; }
.att-btns button { width: 38px; height: 38px; border-radius: 12px; font-weight: 800; font-size: 14px; background: var(--card-2); color: var(--muted); border: 1.5px solid var(--line); transition: all .15s; }
.att-btns button.on[data-s="present"] { background: var(--ok); color: #fff; border-color: var(--ok); }
.att-btns button.on[data-s="absent"] { background: var(--bad); color: #fff; border-color: var(--bad); }
.att-btns button.on[data-s="retard"] { background: #f59e0b; color: #fff; border-color: #f59e0b; }
.att-btns button.on[data-s="excuse"] { background: #3b82f6; color: #fff; border-color: #3b82f6; }
.savebar { position: sticky; bottom: calc(var(--tab-h) + 10px + env(safe-area-inset-bottom)); z-index: 5; margin-top: 14px; }
@media (min-width: 900px) { .savebar { bottom: 16px; } }
.legend-inline { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 12.5px; color: var(--muted); margin: 6px 2px; }

/* ----- Calendrier & emploi du temps ----- */
.ev { display: flex; gap: 12px; align-items: stretch; background: var(--card); border-radius: var(--r-sm); padding: 10px 12px; box-shadow: var(--shadow); text-align: left; width: 100%; }
.ev .datebox { flex: none; width: 52px; border-radius: 12px; display: grid; place-items: center; text-align: center; padding: 6px 0; background: var(--brand-soft); color: var(--brand); line-height: 1.1; }
.ev .datebox b { font-size: 20px; } .ev .datebox small { font-size: 10.5px; font-weight: 800; text-transform: uppercase; }
.ev.vacances .datebox { background: var(--gold-soft); color: var(--gold); } .ev.ferie .datebox { background: var(--bad-soft); color: var(--bad); }
.ev.examen .datebox { background: #ede9fe; color: #6d28d9; } .ev.reunion .datebox { background: #dbeafe; color: #1d4ed8; }
.ev .nfo { min-width: 0; flex: 1; } .ev .nfo b { display: block; } .ev .nfo small { color: var(--muted); }
.tt { display: grid; gap: 10px; }
.tt-day h4 { font-size: 12.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 6px; }
.tt-slot { display: flex; gap: 10px; align-items: center; background: var(--card); border-radius: var(--r-sm); padding: 9px 12px; box-shadow: var(--shadow); width: 100%; text-align: left; margin-bottom: 6px; }
.tt-slot .hr { flex: none; font-variant-numeric: tabular-nums; font-weight: 800; font-size: 13px; color: var(--brand); width: 92px; }
.tt-slot .tx { min-width: 0; flex: 1; } .tt-slot small { color: var(--muted); display: block; }
.tt-grid { display: grid; grid-template-columns: 58px repeat(6, minmax(92px, 1fr)); gap: 4px; min-width: 640px; font-size: 12px; }
.tt-grid .h { font-weight: 800; text-align: center; color: var(--muted); padding: 6px 0; font-size: 11.5px; text-transform: uppercase; }
.tt-grid .t { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 700; padding-top: 6px; text-align: right; padding-right: 6px; }
.tt-grid .c { min-height: 46px; border-radius: 10px; background: var(--card-2); border: 1px dashed var(--line); padding: 4px 6px; }
.tt-grid .c.full { background: var(--brand-soft); border: 1px solid transparent; color: var(--brand); font-weight: 700; cursor: pointer; }
.tt-grid .c small { display: block; font-weight: 500; opacity: .8; }

/* ----- Notes ----- */
.note-row { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: var(--r-sm); padding: 8px 12px; box-shadow: var(--shadow); }
.note-row .nm { flex: 1; min-width: 0; font-weight: 700; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-row input.nv { width: 74px; text-align: center; font-size: 18px; font-weight: 800; padding: 8px 6px; }
.note-row .abs { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 700; }
.moy { display: inline-block; min-width: 46px; text-align: center; padding: 3px 8px; border-radius: 99px; font-weight: 800; font-size: 13px; background: var(--card-2); }
.moy.good { background: var(--ok-soft); color: var(--ok); } .moy.mid { background: var(--warn-soft); color: var(--warn); } .moy.low { background: var(--bad-soft); color: var(--bad); }
.rank { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--gold-soft); color: var(--gold); font-weight: 800; font-size: 12.5px; }
.piece { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.piece:last-child { border-bottom: 0; } .piece .grow { flex: 1; min-width: 0; } .piece small { color: var(--muted); display: block; }
.dot-st { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--line); }
.dot-st.present { background: var(--ok); } .dot-st.absent { background: var(--bad); } .dot-st.retard { background: #f59e0b; } .dot-st.excuse, .dot-st.conge { background: #3b82f6; }
.hint { font-size: 12.5px; color: var(--muted); margin: 6px 2px; }
.pwd-box { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 22px; font-weight: 800; letter-spacing: .08em; text-align: center; padding: 14px; border-radius: 14px; background: var(--brand-soft); color: var(--brand); user-select: all; }

/* ----- Documents A4 (aperçu + impression) ----- */
.docs { display: grid; gap: 18px; }
.doc { background: #fff; color: #111; border-radius: 10px; padding: 26px 24px; font-size: 13px; line-height: 1.45; box-shadow: var(--shadow); font-family: Georgia, "Times New Roman", serif; }
.doc { overflow-x: auto; max-width: 100%; }
@media (max-width: 600px) { .doc { padding: 16px 14px; font-size: 12px; } .doc-title h1 { font-size: 18px; } .doc-head { flex-direction: column; } .doc-school { text-align: left; margin-left: 0; } .doc-two { gap: 8px; } .doc-table th, .doc-table td { padding: 5px 5px; } }
.doc * { color: inherit; } .doc small { font-size: 11.5px; color: #555; display: block; } .doc .muted { color: #666; }
.doc-head { display: flex; justify-content: space-between; gap: 14px; border-bottom: 2px solid #111; padding-bottom: 10px; margin-bottom: 14px; }
.doc-rep { text-align: center; font-size: 11.5px; display: grid; gap: 1px; } .doc-rep b { font-size: 12px; }
.doc-school { text-align: right; margin-left: auto; } .doc-school b { font-size: 16px; display: block; }
.doc-title { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; margin: 6px 0 14px; }
.doc-title h1 { font-size: 22px; letter-spacing: .06em; margin: 0; } .doc-title > div { text-align: right; }
.doc-title.center { justify-content: center; margin: 26px 0; } .doc-title.center h1 { text-decoration: underline; }
.doc-two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.doc-two > div { border: 1px solid #bbb; border-radius: 6px; padding: 8px 10px; display: grid; gap: 1px; align-content: start; }
.doc-two.sm > div { padding: 6px 10px; } .doc-two.sign2 > div { min-height: 70px; }
.doc-table { width: 100%; border-collapse: collapse; margin: 6px 0 12px; }
.doc-table th, .doc-table td { border: 1px solid #999; padding: 6px 8px; text-align: left; vertical-align: top; }
.doc-table th { background: #eee; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; } .doc-table .r { text-align: right; }
.doc-table tfoot td { font-weight: 700; background: #fafafa; } .doc-table tr.grand td { background: #e8e8e8; font-size: 14px; }
.doc-table .det { font-size: 10.5px; color: #666; font-weight: 400; }
.doc-kv { width: 100%; border-collapse: collapse; margin-bottom: 8px; } .doc-kv th { width: 36%; text-align: left; font-weight: 600; padding: 5px 8px; border: 1px solid #ccc; background: #f6f6f6; } .doc-kv td { padding: 5px 8px; border: 1px solid #ccc; }
.doc h2 { font-size: 13.5px; margin: 14px 0 6px; text-transform: uppercase; letter-spacing: .04em; }
.doc-note { margin: 8px 0; font-size: 12px; } .doc-note.warn { border: 1px solid #c2410c; background: #fff7ed; padding: 8px 10px; border-radius: 6px; }
.doc-box { border: 1px solid #999; border-radius: 6px; padding: 8px 10px; margin: 10px 0; min-height: 56px; } .doc-box p { margin: 4px 0 0; }
.doc-sign { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-top: 28px; }
.doc-sign .sig { text-align: center; min-width: 190px; min-height: 80px; display: grid; gap: 2px; align-content: start; }
.doc-body { font-size: 14.5px; line-height: 1.8; margin: 12px 0; text-align: justify; } .doc-body.center { text-align: center; } .doc-body.big { font-size: 20px; }
.doc-right { text-align: right; margin: 10px 0; } .doc-left { margin: 6px 0; } .doc-letter { min-height: 220px; margin: 16px 0; font-size: 14px; line-height: 1.7; text-align: justify; }

@media print {
  body.printing-doc .sheet-root:not(.print-target) { display: none !important; }
  .sheet-root.print-target .sheet-body { padding: 0 !important; overflow: visible !important; }
  .sheet-root.print-target .sheet { width: 100% !important; max-width: none !important; border-radius: 0 !important; position: static !important; }
  .docs { display: block; } .doc { box-shadow: none; border-radius: 0; padding: 0; page-break-after: always; break-after: page; min-height: 0; }
  .doc { overflow: visible; font-size: 13px; padding: 0 !important; } .doc-head { flex-direction: row !important; } .doc-school { text-align: right !important; margin-left: auto !important; }
  .doc:last-child { page-break-after: auto; break-after: auto; }
  @page { size: A4; margin: 14mm; }
}
@media (min-width: 900px) { .doc { padding: 36px 40px; } }
.ic.flip { transform: scaleX(-1); }
