:root{
  --bg:#f2f5f9;
  --card:#ffffff;
  --text:#1f2933;
  --muted:#6b7280;
  --border:#e5e7eb;
  --shadow:0 6px 18px rgba(10,20,40,.05);
  --shadow-soft:0 2px 10px rgba(10,20,40,.04);

  --primary:#2fae9b;
  --primary-dark:#238c7c;
  --green:#2fbf90;
  --green-dark:#1f8f6b;
  --blue:#7fdcc8;
  --blue-dark:#58c5ae;

  --danger:#c2410c;
  --warn:#b45309;
  --ok:#0f8a64;
  --danger-bg:#fff1f2;
  --warn-bg:#fff7e6;
  --ok-bg:#f1fdf4;

  --radius:16px;
  --radius-sm:12px;
}

*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{
  font-family:"Segoe UI","Inter",system-ui,-apple-system,"Helvetica Neue",Arial,sans-serif;
  background:var(--bg); color:var(--text); line-height:1.45;
}

/* App header */
.app-header{
  background:var(--card);
  border-bottom:1px solid var(--border);
  box-shadow:var(--shadow-soft);
  padding:14px 16px 12px;
}
.brand{
  max-width:980px; margin:0 auto;
  display:flex; flex-direction:column; gap:6px;
}
.brand-top{display:flex; align-items:baseline; gap:10px}
.brand-school{font-size:20px; font-weight:800; letter-spacing:.2px}
.brand-app{font-size:14px; font-weight:700; color:var(--primary)}
.brand-row{display:flex; align-items:center; gap:10px}
.brand-subtitle{color:var(--muted); font-weight:600}
.page-chip{
  display:inline-flex; align-items:center; padding:4px 10px;
  border-radius:999px; background:#eef2ff; color:#3b4b6a;
  font-size:12px; font-weight:700;
}

/* Header / nav onglets */
.duo-header{
  position:sticky; top:0; z-index:20;
  background:#fff; border-bottom:1px solid var(--border);
  display:flex; align-items:center; justify-content:space-between;
  padding:10px 16px;
}
.duo-brand{display:flex; align-items:center; gap:10px}
.duo-logo{font-size:22px}
.duo-title{font-weight:700}

.duo-nav{display:flex; gap:14px; align-items:flex-end}
.duo-nav a{
  text-decoration:none; color:#6b7280; font-weight:600; padding:8px 2px; position:relative;
}
.duo-nav a.active{color:var(--primary)}
.duo-nav a.active::after{
  content:""; position:absolute; left:0; right:0; bottom:-12px; height:3px; background:var(--primary); border-radius:3px;
}

/* API box */
.api-box{display:flex; gap:8px; align-items:center}
.api-box input{
  height:36px; padding:8px 10px; border:1px solid #d1d5db; border-radius:10px; min-width:220px;
}
.api-box button{
  height:36px; padding:0 12px; border:0; border-radius:10px; background:var(--blue); color:#fff; font-weight:700; cursor:pointer;
}
.api-box button:hover{background:var(--blue-dark)}
.status{font-size:12px; color:var(--muted)}
.status.ok{color:var(--ok); font-weight:700}
.api-key-hidden{display:none}
.api-key-toggle{
  display:block;
  margin:8px 16px 0 auto;
  padding:6px 10px;
  font-size:12px;
  font-weight:700;
  color:var(--muted);
  background:#f1f5f9;
  border:1px solid var(--border);
  border-radius:999px;
  cursor:pointer;
}
.api-key-toggle:hover{background:#e7edf7; color:#374151}

/* Layout */
.container{max-width:980px; margin:0 auto; padding:20px 16px}
h1{font-size:26px; margin:6px 0 12px}
h2{font-size:19px; margin:12px 0}

/* Dashboard (index) */
.dashboard{
  background:var(--card);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:14px;
  margin:12px 0;
}
.dashboard.muted{color:var(--muted)}
.dash-empty{font-weight:600}
.dashboard-head{margin-bottom:10px}
.dashboard-title{font-weight:800}
.dashboard-grid{
  display:grid; gap:10px;
  grid-template-columns:repeat(auto-fit, minmax(140px, 1fr));
}
.dash-item{
  background:#f8fafc; border:1px solid var(--border); border-radius:var(--radius-sm);
  padding:10px 12px;
}
.dash-label{color:var(--muted); font-size:12px; font-weight:700; text-transform:uppercase; letter-spacing:.04em}
.dash-value{font-size:20px; font-weight:800; margin-top:4px}
.dash-value.bad{color:var(--danger)}
.dash-value.warn{color:var(--warn)}
.dash-value.ok{color:var(--ok)}
.mini-dist{margin-top:12px}
.dist-label{font-size:12px; text-transform:uppercase; letter-spacing:.04em; color:var(--muted); font-weight:700}
.mini-dist-bar{
  display:flex; height:8px; border-radius:999px; overflow:hidden; margin:6px 0 4px;
  background:#eef2f7;
}
.mini-dist-bar .seg{height:100%}
.seg-0{background:#ef4444}
.seg-1{background:#f59e0b}
.seg-2{background:#7aa7ff}
.seg-3{background:#16a34a}
.dist-legend{font-size:11px; color:var(--muted)}

/* Cards / élèves */
.card{
  background:var(--card); border-radius:var(--radius); box-shadow:var(--shadow);
  padding:12px; margin:10px 0;
}
.panel{
  background:var(--card); border-radius:var(--radius); box-shadow:var(--shadow);
  padding:12px; margin:10px 0;
}
.card .row{display:flex; justify-content:space-between; align-items:center; gap:10px}
.card .row .right{display:flex; align-items:center; gap:8px}
.card .name{font-weight:700}
.card .points{font-weight:800}
.card .points.blocked{color:var(--danger)}

/* News (home) */
.news-card{
  border:1px solid var(--border);
  box-shadow:var(--shadow-soft);
}
.news-head{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:10px;
  margin-bottom:6px;
  flex-wrap:wrap;
}
.news-title{margin:0}
.news-subtitle{color:var(--muted); font-size:12.5px}
.news-list{list-style:none; padding:0; margin:0}
.news-item{
  display:flex; gap:12px; padding:10px 0; border-top:1px solid var(--border);
  align-items:flex-start;
}
.news-item:first-child{border-top:none}
.news-date{
  min-width:84px; color:var(--muted); font-size:12.5px; font-variant-numeric:tabular-nums;
}
.news-body{display:flex; align-items:center; gap:8px; flex-wrap:wrap}
.news-text{color:var(--text)}
.news-item.news-empty{border-top:none; padding:6px 0 2px}
.news-item.news-empty .news-text{color:var(--muted)}

.chip{
  display:inline-flex; align-items:center; padding:4px 8px; border-radius:999px;
  font-size:12px; border:1px solid var(--border); background:#fff; font-weight:700;
}
.chip-ui{background:#eef6ff; border-color:#d7e7ff; color:#2f4b7c}
.chip-regles{background:#f1fdf4; border-color:#ccefdc; color:#0f8a64}
.chip-admin{background:#fff7ed; border-color:#fde7c7; color:#9a3412}
.chip-bugfix{background:#fff1f2; border-color:#ffd6dc; color:#9f1239}

/* Élèves compacts */
.student-card{padding:10px 12px; margin:6px 0; border:1px solid var(--border)}
.card.blocked{background:#fff1f2; border-color:#f9c8d0}
.card.warn{background:#fff6e6; border-color:#f6dfb8}
.card.ok{background:#eefbf7; border-color:#c9efe2}
.student-card.blocked{background:#fff1f2; border-color:#f9c8d0}
.student-card.warn{background:#fff6e6; border-color:#f6dfb8}
.student-card.ok{background:#eefbf7; border-color:#c9efe2}

.student-card .row{align-items:center}
.student-card .left{display:flex; flex-direction:column; gap:4px}
.student-card .name{font-weight:800; font-size:1.05em}
.student-card .meta{display:flex; flex-wrap:wrap; gap:6px; align-items:center}
.student-card .right{display:flex; align-items:center; gap:8px; flex-wrap:wrap; justify-content:flex-end}
.student-card .score{font-weight:900; font-size:1.35em; line-height:1}
.student-card .score.blocked{color:var(--danger)}
.student-card.warn .score{color:var(--warn)}
.student-card.ok .score{color:var(--ok)}

.badge{
  display:inline-flex; align-items:center; font-size:10px; font-weight:800;
  padding:2px 6px; border-radius:999px; letter-spacing:.02em;
}
.badge.blocked{background:#ffe4ea; color:#9f1239}
.badge.warn{background:#fff1cc; color:#a16207}
.badge.ok{background:#e1f8f1; color:#0f8a64}
.badge-warned{background:#eef6ff; color:#2f4b7c; border:1px solid #d7e7ff}
.badge-count{background:#f1f5f9; color:#0f172a; border:1px solid #e2e8f0}

.blocked-meta{margin-top:6px; min-height:18px}
.blocked-actions{display:flex; gap:8px; flex-wrap:wrap; margin-top:8px}
.blocked-actions .unblockBtn{margin-top:0}
.blocked-class{color:var(--muted); font-size:12px; margin-top:4px}
.blocked-class-meta{color:var(--muted); font-size:11px; margin-top:2px}
.parentsWarnBtn{
  background:#f7f9fc; color:var(--text); border:1px solid #e2e8f0;
  border-radius:999px; padding:6px 10px; font-weight:700; cursor:pointer;
  font-size:0.85em; line-height:1; height:28px;
  box-shadow:0 2px 6px rgba(16,24,40,.08);
}
.parentsWarnBtn:hover{background:#e2e8f0; box-shadow:0 4px 10px rgba(16,24,40,.12)}
.parentsWarnBtn:disabled{opacity:.6; cursor:default; box-shadow:none}
.teamMeetingBtn{
  background:#eef6ff; color:#24538a; border:1px solid #d7e7ff;
  border-radius:999px; padding:6px 10px; font-weight:700; cursor:pointer;
  font-size:0.85em; line-height:1; height:28px;
  box-shadow:0 2px 6px rgba(16,24,40,.08);
}
.teamMeetingBtn:hover{background:#dbeafe; box-shadow:0 4px 10px rgba(16,24,40,.12)}
.teamMeetingBtn:disabled{opacity:.6; cursor:default; box-shadow:none}

.repeat-blocked-card{
  background:#fff;
  border-radius:14px;
  padding:10px 12px;
  border:1px solid var(--border);
  box-shadow:var(--shadow-soft);
  margin:8px 0;
}
.repeat-blocked-card .row{justify-content:space-between; align-items:center}

.tags{display:flex; flex-wrap:wrap; gap:4px}
.tag{
  background:#e5e7eb; color:#374151; font-size:10px; font-weight:700;
  padding:2px 6px; border-radius:999px;
}

.bar{background:#eef2ff; height:8px; border-radius:999px; overflow:hidden; margin:8px 0 4px}
.student-card .bar{height:5px; margin:6px 0 4px}
.fill{height:100%}
.fill.ok{background:var(--green)}
.fill.mid{background:#f59e0b}
.fill.low{background:#ef4444}

.card.student.blocked{opacity:.75; filter:grayscale(.35)}
.card .actions{display:flex; justify-content:flex-end; gap:8px}
.student-card .actions{display:flex; justify-content:flex-end; gap:6px; margin-top:6px}
.applyBtn{
  background:var(--green); color:#fff; border:0; border-radius:999px; padding:8px 12px; font-weight:800; cursor:pointer;
  box-shadow:0 2px 6px rgba(16,24,40,.12);
}
.applyBtn:hover{background:var(--green-dark); box-shadow:0 4px 10px rgba(16,24,40,.16)}
.histBtn{
  background:#eef2f7; color:#111827; border:0; border-radius:999px; padding:6px 10px; font-weight:700; cursor:pointer;
  font-size:0.85em; line-height:1; height:28px;
  box-shadow:0 2px 6px rgba(16,24,40,.08);
}
.histBtn:hover{background:#e2e8f0; box-shadow:0 4px 10px rgba(16,24,40,.12)}
.setPointsBtn{
  background:#eef2f7; color:#111827; border:0; border-radius:999px; padding:6px 10px; font-weight:700; cursor:pointer;
  font-size:0.8em; line-height:1; height:28px;
  box-shadow:0 2px 6px rgba(16,24,40,.08);
}
.setPointsBtn:hover{background:#e2e8f0; box-shadow:0 4px 10px rgba(16,24,40,.12)}
.student-card .applyBtn{padding:6px 10px; font-size:0.82em; height:26px}
.student-card .histBtn,.student-card .setPointsBtn{padding:4px 8px; height:26px}

/* Teacher: denser student cards */
body[data-page="teacher"] .student-card{
  padding:8px 10px;
  margin:4px 0;
}
body[data-page="teacher"] .student-card .name{font-size:1em}
body[data-page="teacher"] .student-card .score{font-size:1.15em}
body[data-page="teacher"] .student-card .meta{gap:4px}
body[data-page="teacher"] .student-card .bar{margin:5px 0 3px}
body[data-page="teacher"] .student-card .actions{margin-top:4px}
body[data-page="teacher"] .student-card .applyBtn{padding:5px 8px; height:24px}
body[data-page="teacher"] .student-card .histBtn,
body[data-page="teacher"] .student-card .setPointsBtn{height:24px}
body[data-page="teacher"] .student-card .right{gap:6px}

.history-panel{max-height:380px; overflow:auto}
.history-panel .history{box-shadow:none; background:#f8fafc}

/* Hero (home) */
.hero-card{
  border:1px solid var(--border);
  box-shadow:var(--shadow-soft);
  padding:20px;
  background:
    linear-gradient(135deg, rgba(47,174,155,0.10), rgba(127,220,200,0.06) 55%, #ffffff 100%);
}
.hero-grid{
  display:grid;
  grid-template-columns:1.2fr 0.8fr;
  gap:16px;
  align-items:center;
}
.hero-title{margin:0 0 6px; font-size:24px; letter-spacing:.2px}
.hero-subtitle{font-weight:700; color:#1f3b4d; margin-bottom:8px}
.hero-text{margin:0 0 10px; color:var(--text)}
.hero-footer{color:var(--muted); font-size:12.5px}
.quick-actions{
  display:grid;
  grid-template-columns:repeat(2, minmax(0, 1fr));
  gap:10px;
}
.btn-qa{
  display:inline-flex; align-items:center; justify-content:center;
  padding:10px 12px; border-radius:12px; text-decoration:none; font-weight:700;
  border:1px solid transparent; box-shadow:0 2px 8px rgba(10,20,40,.06);
  transition:transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.btn-qa:hover{transform:translateY(-1px); box-shadow:0 6px 14px rgba(10,20,40,.10)}
.btn-primary{background:var(--primary); color:#fff}
.btn-secondary{background:#f7f9fc; color:var(--text); border-color:#e2e8f0}
.quick-actions .btn-qa:last-child{grid-column:1 / -1}

/* Lists / grid */
.controls{display:flex; gap:10px; flex-wrap:wrap; margin:8px 0 16px}
select{height:40px; border:1px solid #d1d5db; border-radius:10px; padding:0 12px; min-width:220px}

/* Admin */
.admin-dashboard{
  display:grid;
  grid-template-columns:repeat(2, minmax(0, 1fr));
  gap:14px;
  margin-bottom:14px;
}
.admin-block{
  background:var(--card);
  border-radius:var(--radius);
  border:1px solid var(--border);
  box-shadow:var(--shadow-soft);
  padding:14px;
}
.admin-block-header{
  display:flex;
  justify-content:space-between;
  align-items:flex-end;
  gap:12px;
  margin-bottom:8px;
}
.admin-subsection{margin-top:10px}
.admin-subhead{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  margin-bottom:6px;
}
.admin-item{margin:8px 0}
.blocked-card{background:#fff; border-radius:14px; padding:12px; box-shadow:var(--shadow); margin:10px 0}
.blocked-card .points{color:var(--danger); font-weight:800}
.blocked-card .row{display:flex; justify-content:space-between; align-items:flex-start; gap:12px}
.blocked-card .right{display:flex; flex-direction:column; align-items:flex-end; gap:6px; flex-wrap:wrap}
.blocked-card .muted{font-size:12px}
.admin-dashboard .blocked-actions{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  justify-content:flex-end;
}
.admin-dashboard .blocked-actions button{
  height:30px;
  padding:6px 12px;
  font-size:0.85em;
  font-weight:700;
  margin-top:0;
  border-radius:999px;
}
.unblockBtn{
  margin-top:8px; background:var(--primary); color:#fff; border:0; border-radius:999px; padding:8px 12px; font-weight:700; cursor:pointer;
  box-shadow:0 2px 6px rgba(16,24,40,.12);
}
.unblockBtn:hover{background:var(--primary-dark); box-shadow:0 4px 10px rgba(16,24,40,.16)}
.alert-card{
  background:#fff;
  border-radius:12px;
  padding:7px 10px;
  border:1px solid var(--border);
  box-shadow:var(--shadow-soft);
  margin:6px 0;
}
.alert-card .row{display:flex; justify-content:space-between; align-items:center}
.alert-card .meta-row{display:flex; flex-wrap:wrap; gap:6px; margin:4px 0}
.alert-card .name{font-size:0.95em}
.history{background:#fff; border-radius:14px; padding:10px; box-shadow:var(--shadow)}
.history-group{margin-bottom:12px}
.history-group:last-child{margin-bottom:0}
.history-day{
  font-size:11px; font-weight:800; color:var(--muted); letter-spacing:.04em;
  text-transform:uppercase; margin:6px 0 4px;
}
.h-row{
  display:grid; grid-template-columns:56px 22px 1fr 56px; gap:8px; align-items:center;
  padding:6px 0; border-bottom:1px solid #f1f5f9; font-size:0.92em;
}
.h-row:last-child{border-bottom:0}
.h-time{font-size:12px; color:var(--muted); font-variant-numeric:tabular-nums}
.h-icon{text-align:center; font-size:14px}
.h-lib{font-weight:600}
.h-code{font-size:11px; color:var(--muted); font-weight:600}
.h-delta{text-align:right; font-variant-numeric:tabular-nums}
.h-delta.neg{color:#ef4444; font-weight:800}
.h-delta.pos{color:var(--ok); font-weight:800}

/* Toast + flash */
.toast{
  position:fixed; right:16px; bottom:16px; background:#111827; color:#fff;
  padding:10px 14px; border-radius:12px; display:none; box-shadow:0 8px 22px rgba(0,0,0,.2); z-index:50;
}
.flash-ok{animation:flash .9s ease}
@keyframes flash{0%{box-shadow:0 0 0 0 rgba(22,163,74,.8)}100%{box-shadow:0 0 0 16px rgba(22,163,74,0)}}

/* Modal */
.modal-overlay{
  position:fixed; inset:0; background:rgba(15,23,42,.45); display:none;
  align-items:center; justify-content:center; z-index:45; padding:16px;
}
.modal-overlay.open{display:flex}
.modal{
  background:#fff; border-radius:14px; padding:16px; width:min(420px, 92vw);
  box-shadow:0 12px 28px rgba(15,23,42,.25);
}
.modal h3{margin:0 0 10px}
.modal .field{margin-bottom:10px}
.modal input,.modal textarea{
  width:100%; border:1px solid #d1d5db; border-radius:10px; padding:8px 10px; font-size:1em;
}
.modal textarea{resize:vertical}
.modal-actions{display:flex; justify-content:flex-end; gap:8px; margin-top:6px}
.modal-error{color:var(--danger); font-size:13px; min-height:18px; display:none}

/* Hero (home) */
.hero{background:#fff; padding:30px 16px; border-bottom:1px solid #eef2f7}
.cta{display:flex; gap:10px; flex-wrap:wrap}
.btn{
  display:inline-block; background:var(--green); color:#fff; border-radius:999px; padding:12px 18px; text-decoration:none; font-weight:800;
}
.btn.secondary{background:var(--blue)}
.btn.gray{background:#e5e7eb; color:#111827}

/* CTA modern */
.cta-vertical{
  display:flex;
  flex-direction:column;
  gap:16px;
  width:100%;
  margin-top:20px;
}

.btn.cta{
  display:block;
  width:100%;
  text-align:center;
  padding:14px 20px;
  font-size:17px;
  font-weight:600;
  border-radius:8px;
  transition:all 0.25s ease;
  box-shadow:0 3px 6px rgba(0,0,0,0.1);
}

.btn.cta.primary{
  background:var(--green);
  color:#fff;
}

.btn.cta.secondary{
  background:#f1f3f4;
  color:var(--text);
}

.btn.cta:hover{
  transform:translateY(-3px) scale(1.02);
  box-shadow:0 6px 12px rgba(0,0,0,0.15);
}

/* Mobile */
@media (max-width:720px){
  .app-header{padding:12px 14px 8px}
  .brand-school{font-size:18px}
  .brand-app{font-size:13px}
  .brand-subtitle{font-size:0.9em}
  .page-chip{display:none}
  .duo-nav a.active::after{bottom:-10px}
  .h-row{grid-template-columns:70px 24px 1fr 52px}
  .hero-grid{grid-template-columns:1fr}
  .admin-dashboard{grid-template-columns:1fr}
  .admin-block-header{flex-direction:column; align-items:flex-start}
}

@media (max-width:520px){
  .news-item{flex-direction:column; gap:6px}
  .news-date{min-width:auto}
  .quick-actions{grid-template-columns:1fr}
  .quick-actions .btn-qa:last-child{grid-column:auto}
}
