/* ANEN École Digitale — styles */
:root {
  --bg: #f4f6f8; --card: #fff; --ink: #1b2430; --muted: #5f6b7a; --line: #e2e7ee;
  --brand: #0b5d3b; --brand-2: #0f7a4e; --brand-soft: #e6f3ec;
  --gold: #c99a2e; --red: #c0392b; --red-soft: #fbeceb; --orange: #d9822b; --orange-soft: #fdf2e6;
  --blue: #1f5fa8; --blue-soft: #e9f1fb; --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font: 15px/1.45 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--brand); }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* Mise en page */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 236px; background: var(--brand); color: #fff; flex-shrink: 0; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .logo { padding: 18px 18px 14px; font-weight: 700; font-size: 17px; letter-spacing: .2px; border-bottom: 1px solid rgba(255,255,255,.12); }
.sidebar .logo small { display: block; font-weight: 400; font-size: 12px; opacity: .75; margin-top: 2px; }
.sidebar nav { padding: 8px; flex: 1; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; color: #e8f3ed; text-decoration: none; padding: 9px 12px; border-radius: 8px; margin: 1px 0; font-size: 14.5px; }
.sidebar nav a:hover { background: rgba(255,255,255,.08); }
.sidebar nav a.active { background: rgba(255,255,255,.16); color: #fff; font-weight: 600; }
.sidebar nav .sep { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; opacity: .55; padding: 12px 12px 4px; }
.sidebar .foot { padding: 12px 16px; font-size: 12px; opacity: .7; border-top: 1px solid rgba(255,255,255,.12); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: var(--card); border-bottom: 1px solid var(--line); padding: 10px 20px; display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 20; }
.topbar .school { font-weight: 600; }
.topbar .spacer { flex: 1; }
.topbar .burger { display: none; background: none; border: 0; font-size: 22px; cursor: pointer; }
.content { padding: 20px; max-width: 1280px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }

/* Cartes et grilles */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .label { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.kpi .value { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.kpi.good .value { color: var(--brand); } .kpi.bad .value { color: var(--red); } .kpi.warn .value { color: var(--orange); }

/* Tableaux */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); background: #fafbfc; position: sticky; top: 0; }
tr:hover td { background: #fafcfb; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.clickable { cursor: pointer; }
tfoot td { font-weight: 700; background: #fafbfc; }

/* Formulaires */
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid #cfd6df; border-radius: 8px; font: inherit; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand-2); }
input[type=checkbox] { width: auto; }
textarea { min-height: 90px; resize: vertical; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1; min-width: 160px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; border-radius: 8px; border: 1px solid transparent; font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap; background: var(--brand); color: #fff; }
.btn:hover { background: var(--brand-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.sec { background: #fff; color: var(--ink); border-color: #cfd6df; }
.btn.sec:hover { background: #f3f5f7; }
.btn.danger { background: var(--red); } .btn.danger:hover { background: #a93226; }
.btn.wa { background: #1fa855; } .btn.wa:hover { background: #178a45; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.lg { padding: 13px 20px; font-size: 16px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.b-ok { background: var(--brand-soft); color: var(--brand); }
.b-bad { background: var(--red-soft); color: var(--red); }
.b-warn { background: var(--orange-soft); color: var(--orange); }
.b-info { background: var(--blue-soft); color: var(--blue); }
.b-mute { background: #eef1f4; color: var(--muted); }

/* Alertes */
.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.alert.err { background: var(--red-soft); color: #8e2a20; }
.alert.ok { background: var(--brand-soft); color: var(--brand); }
.alert.warn { background: var(--orange-soft); color: #8a5016; }
.alert.info { background: var(--blue-soft); color: #174a83; }

/* Modale */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,32,.45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 12px; z-index: 100; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 640px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.wide { max-width: 960px; }
.modal-h { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-h h2 { margin: 0; }
.modal-b { padding: 18px; max-height: 70vh; overflow-y: auto; }
.modal-f { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.x { background: none; border: 0; font-size: 24px; cursor: pointer; color: var(--muted); line-height: 1; }

/* Toast */
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1b2430; color: #fff; padding: 11px 18px; border-radius: 8px; z-index: 200; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.25); opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw; }
#toast.show { opacity: 1; }
#toast.err { background: var(--red); }

/* Connexion */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(135deg, #0b5d3b 0%, #0f7a4e 55%, #c99a2e 140%); }
.login { background: #fff; border-radius: 14px; padding: 28px; width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login h1 { color: var(--brand); }

/* Graphiques */
.chart { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 56px; align-items: center; gap: 10px; font-size: 13.5px; margin: 6px 0; }
.bar { height: 10px; background: #eef1f4; border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 99px; }

/* Recherche élève (caisse) */
.search-results { border: 1px solid var(--line); border-radius: 8px; margin-top: 4px; max-height: 280px; overflow-y: auto; background: #fff; }
.search-results div { padding: 9px 12px; border-bottom: 1px solid var(--line); cursor: pointer; display: flex; justify-content: space-between; gap: 10px; }
.search-results div:hover { background: var(--brand-soft); }
.pay-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 12px 0; }
.pay-summary div { background: #fafbfc; border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.pay-summary b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; padding: 9px 14px; font: inherit; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600; }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }
.grade-input { width: 80px; text-align: right; padding: 6px 8px; }
.empty { text-align: center; padding: 30px; color: var(--muted); }

@media (max-width: 900px) {
  .sidebar { position: fixed; left: -260px; z-index: 50; transition: left .2s; }
  .sidebar.open { left: 0; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .topbar .burger { display: block; }
  .g2, .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pay-summary { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 14px; }
}
@media (max-width: 560px) {
  .g2, .g3 { grid-template-columns: 1fr; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .topbar .badge { display: none; }
  .kpi { padding: 10px 12px; }
  .kpi .value { font-size: 20px; }
  .hide-m { display: none; }
}
