:root {
  --bg: #f4f6f9; --card: #fff; --ink: #1c2433; --muted: #6b7587; --line: #e3e7ee;
  --nav: #13233a; --nav-ink: #c7d2e3; --accent: #1b6ef3;
  --in: #16875c; --in-bg: #e7f5ee; --out: #c93c4f; --out-bg: #fbecee; --warn: #b7791f; --warn-bg: #fdf4e3;
  --future: #f7f9fc; --current: #eef4ff;
  /* Graphiques : couleurs par rôle (palette validée : daltonisme, contraste sur fond blanc) */
  --viz-s1: #2a78d6;        /* série 1 : encaissements, trésorerie, CA */
  --viz-s2: #eb6834;        /* série 2 : décaissements, achats */
  --viz-critical: #d03b3b;  /* réservé aux alertes (point bas négatif) */
  --viz-ink: #1c2433; --viz-ink2: #52514e; --viz-muted: #898781;
  --viz-grid: #eceae4; --viz-axis: #c3c2b7; --viz-surface: #ffffff; --viz-future: #f6f7f9;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--in); } .neg { color: var(--out); }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: var(--nav); color: var(--nav-ink); padding: 18px 0; flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { padding: 0 18px 18px; border-bottom: 1px solid #22385a; margin-bottom: 10px; }
.sidebar .brand img { max-width: 150px; background: #fff; border-radius: 6px; padding: 4px 8px; }
.sidebar .brand div { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; margin-top: 8px; color: #8fa3c2; }
.sidebar a { display: block; color: var(--nav-ink); padding: 9px 18px; border-left: 3px solid transparent; }
.sidebar a:hover { background: #1a2f4d; text-decoration: none; }
.sidebar a.active { background: #1d3659; color: #fff; border-left-color: #4d9bff; }
.sidebar .sep { height: 1px; background: #22385a; margin: 10px 0; }
.sidebar .foot { padding: 12px 18px; font-size: 12px; color: #8fa3c2; }
.sidebar .foot a { display: inline; padding: 0; border: 0; }
.sidebar .foot a:hover { background: none; text-decoration: underline; }
.main { flex: 1; padding: 22px 28px 60px; min-width: 0; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }

/* Components */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; margin-bottom: 18px; }
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(4, 1fr); margin-bottom: 18px; }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 24px; font-weight: 600; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 1100px) { .two { grid-template-columns: 1fr; } }
.btn { display: inline-block; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 7px 12px; border-radius: 7px; cursor: pointer; font-size: 13px; }
.btn:hover { background: #f0f3f8; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #135bd0; }
.btn.danger { color: var(--out); }
.btn.small { padding: 3px 8px; font-size: 12px; }
input, select { font: inherit; padding: 6px 8px; border: 1px solid #cfd6e1; border-radius: 6px; background: #fff; }
input:focus, select:focus { outline: 2px solid #b8d3ff; border-color: var(--accent); }
form.inline { display: inline; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; background: #eef1f6; color: var(--muted); white-space: nowrap; }
.tag.reel { background: var(--in-bg); color: var(--in); }
.tag.engage { background: var(--warn-bg); color: var(--warn); }
.tag.late { background: var(--out-bg); color: var(--out); }
.tag.draft { background: transparent; color: var(--warn); border: 1px dashed var(--warn); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.flash.ok { background: var(--in-bg); color: #0d5c3e; }
.flash.error { background: var(--out-bg); color: #8c1d2c; }
.flash.warn { background: var(--warn-bg); color: #7a4d0a; }

/* Tables */
table { border-collapse: collapse; width: 100%; }
th, td { padding: 7px 9px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; background: #fafbfd; }
tbody tr:hover { background: #fafcff; }
/* Modal */
.modal { position: fixed; inset: 0; background: rgba(15, 25, 40, .45); display: none; align-items: flex-start; justify-content: center; padding: 60px 16px; z-index: 50; }
.modal.open { display: flex; }
.modal .box { background: #fff; border-radius: 12px; max-width: 1200px; width: 100%; max-height: 80vh; overflow: auto; padding: 18px 20px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }

/* Login */
.login { max-width: 360px; margin: 12vh auto; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 28px; }
.login img { max-width: 180px; display: block; margin: 0 auto 16px; }
.login input { width: 100%; margin-bottom: 12px; padding: 9px 10px; }
.login .btn { width: 100%; padding: 10px; }
.login .steps { padding-left: 20px; line-height: 1.5; }
.login .steps li { margin-bottom: 8px; }
.login .qr { display: flex; justify-content: center; margin: 10px 0; }
.login .secret { font-family: ui-monospace, monospace; font-size: 15px; letter-spacing: 1px; text-align: center;
  background: #f3f5f9; border-radius: 6px; padding: 6px; margin-top: 4px; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: #8fa3c2; text-decoration: underline; cursor: pointer; }
@media (max-width: 800px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; display: flex; flex-wrap: wrap; padding: 8px; }
  .sidebar .brand, .sidebar .sep, .sidebar .foot { display: none; }
  .sidebar a { padding: 6px 10px; border-left: 0; }
  .main { padding: 16px; }
}
[hidden] { display: none !important; }
.btn.disabled { opacity: .4; pointer-events: none; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px 16px; margin: 10px 0 6px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.form-grid input, .form-grid select { color: var(--ink); }
table tr.tot td { background: #eef1f6; font-weight: 700; }
table tr.week td { background: #f6f8fb; font-weight: 600; font-size: 13px; }
table tr.off td { color: var(--muted); }
td.name a { font-weight: 600; }
.tag.info { background: var(--current); color: var(--accent); }
.modal .box.narrow { max-width: 460px; }
.sched input[type=time] { width: 104px; }
.sched td, .sched th { padding: 5px 8px; }
code { background: #eef1f6; border-radius: 4px; padding: 1px 5px; font-size: 12px; }

/* ─── Pointeuse (page de scan, plein écran) ──────────────────────────────── */
body.kiosk { background: var(--nav); color: #fff; min-height: 100vh; display: flex; flex-direction: column; }
.k-top { display: flex; justify-content: space-between; align-items: center; padding: 18px 28px; }
.k-top img { height: 44px; background: #fff; border-radius: 6px; padding: 4px 10px; }
.k-clock { text-align: right; font-variant-numeric: tabular-nums; }
.k-clock .t { font-size: 40px; font-weight: 600; line-height: 1; }
.k-clock .d { color: #8fa3c2; margin-top: 4px; }
.k-main { flex: 1; display: flex; gap: 24px; padding: 8px 28px 20px; align-items: stretch; }
.k-panel { flex: 1.5; border-radius: 18px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 32px; min-height: 340px; background: #1a2f4d; border: 2px solid #22385a; transition: background .15s, border-color .15s; }
.k-panel .icon { font-size: 76px; line-height: 1; margin-bottom: 14px; }
.k-panel .title { font-size: 46px; font-weight: 700; line-height: 1.15; }
.k-panel .text { font-size: 23px; margin-top: 12px; color: #c7d2e3; }
.k-panel.in { background: #16875c; border-color: #3fc393; }
.k-panel.out { background: #1b6ef3; border-color: #7fb0ff; }
.k-panel.dup { background: #b7791f; border-color: #e9b65c; }
.k-panel.error { background: #c93c4f; border-color: #f08b98; }
.k-panel.in .text, .k-panel.out .text, .k-panel.dup .text, .k-panel.error .text { color: #fff; }
.k-side { flex: 1; background: #fff; color: var(--ink); border-radius: 18px; padding: 18px 20px; min-width: 280px; }
.k-side h2 { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.k-side td { padding: 10px 6px; font-size: 16px; }
.k-side td.h { text-align: right; color: var(--muted); font-size: 14px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.k-dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 10px; background: #cfd6e1; }
.k-dot.present { background: var(--in); }
.k-dot.parti { background: var(--accent); }
.k-dot.absent { background: #fff; border: 2px solid #cfd6e1; }
.k-warn { background: var(--warn-bg); color: #7a4d0a; text-align: center; padding: 12px; font-size: 18px; font-weight: 600; cursor: pointer; }
.k-foot { padding: 0 28px 14px; font-size: 12px; color: #8fa3c2; display: flex; justify-content: space-between; }
.k-foot a { color: #8fa3c2; }
@media (max-width: 900px) { .k-main { flex-direction: column; } .k-panel .title { font-size: 34px; } }

/* ─── Cartes à imprimer (format carte bancaire 85,6 × 54 mm) ─────────────── */
.cards { display: flex; flex-wrap: wrap; gap: 6mm; }
.idcard { width: 85.6mm; height: 54mm; background: #fff; border: 1px solid #b9c2d0; border-radius: 3mm; padding: 4mm 5mm 3mm;
  display: flex; flex-direction: column; justify-content: space-between; break-inside: avoid; overflow: hidden; }
.idcard .head { display: flex; justify-content: space-between; align-items: center; }
.idcard .head img { height: 9mm; }
.idcard .head span { font-size: 7pt; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.idcard .who { font-size: 15pt; font-weight: 700; line-height: 1.1; color: var(--ink); }
.idcard .bar { text-align: center; }
.idcard .bar img { max-width: 100%; display: block; margin: 0 auto; }
.idcard .bar div { font: 8pt ui-monospace, monospace; letter-spacing: .25em; color: var(--muted); }
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  .sidebar, .topbar, .flash, .noprint { display: none !important; }
  .main { padding: 0; }
  .idcard { border-color: #999; }
}
