/* Console EasyDoor : jetons de couleur (clair / sombre), mise en page, composants. */
:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eef1f5;
  --border: #e2e6ec;
  --border-strong: #cfd5de;
  --text: #121821;
  --text-2: #475162;
  --muted: #6b7486;
  --accent: #2a76a0;
  --accent-hover: #236589;
  --accent-soft: #e4f1f6;
  --accent-ink: #ffffff;
  --brand-1: #50bcba;
  --brand-2: #3a80b4;
  --brand-on-dark: #5cc0c9;
  --sidebar: #0e1828;
  --sidebar-2: #16233a;
  --sidebar-text: #b9c4d6;
  --sidebar-strong: #ffffff;
  --good: #137a43;
  --good-soft: #e4f4ea;
  --warn: #9a5b00;
  --warn-soft: #fdf1dc;
  --bad: #b42d2d;
  --bad-soft: #fbe7e7;
  --info: #2a76a0;
  --info-soft: #e4f1f6;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --radius: 10px;
  --radius-sm: 6px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d121a;
    --surface: #151c27;
    --surface-2: #1a2230;
    --surface-3: #212a3a;
    --border: #273143;
    --border-strong: #344055;
    --text: #e9edf3;
    --text-2: #b6bfcd;
    --muted: #8b95a7;
    --accent: #4fb3c2;
    --accent-hover: #6cc4cf;
    --accent-soft: #15303a;
    --accent-ink: #0b1a22;
    --sidebar: #0a0f17;
    --sidebar-2: #131b29;
    --good: #4cc282;
    --good-soft: #14301f;
    --warn: #e2a33d;
    --warn-soft: #33260f;
    --bad: #ef7070;
    --bad-soft: #3a1818;
    --info: #6cc4cf;
    --info-soft: #15303a;
    --series-1: #3987e5;
    --series-2: #d95926;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d121a;
  --surface: #151c27;
  --surface-2: #1a2230;
  --surface-3: #212a3a;
  --border: #273143;
  --border-strong: #344055;
  --text: #e9edf3;
  --text-2: #b6bfcd;
  --muted: #8b95a7;
  --accent: #4fb3c2;
  --accent-hover: #6cc4cf;
  --accent-soft: #15303a;
  --accent-ink: #0b1a22;
  --sidebar: #0a0f17;
  --sidebar-2: #131b29;
  --good: #4cc282;
  --good-soft: #14301f;
  --warn: #e2a33d;
  --warn-soft: #33260f;
  --bad: #ef7070;
  --bad-soft: #3a1818;
  --info: #6cc4cf;
  --info-soft: #15303a;
  --series-1: #3987e5;
  --series-2: #d95926;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 620; }
h3 { font-size: 14px; font-weight: 620; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack > *, .cols-2 > *, .kpis > * { min-width: 0; }
.stack > .banner { margin-bottom: 0; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.right { margin-left: auto; }

/* Démarrage */
.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Connexion */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.login-side { background: linear-gradient(160deg, #0e1828 0%, #123049 70%, #1c4f6b 100%); color: #dbe4f3; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.login-side h1 { color: #fff; font-size: 30px; max-width: 420px; }
.login-side ul { margin: 24px 0 0; padding: 0; list-style: none; display: grid; gap: 12px; max-width: 420px; }
.login-side li { display: flex; gap: 10px; align-items: flex-start; }
.login-side li svg { flex: none; margin-top: 2px; color: var(--brand-on-dark); }
.login-side .logo { align-self: flex-start; }
.login-logo { display: none; }
.login-main { display: grid; place-items: center; padding: 32px 16px; }
.login-card { width: 100%; max-width: 400px; }
.login-card h2 { font-size: 22px; margin-bottom: 6px; }
.login-card .lead { color: var(--text-2); margin-bottom: 24px; }
.channel-choice { display: grid; gap: 10px; }
.channel { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; text-align: left; width: 100%; }
.channel:hover { border-color: var(--accent); }
.channel[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: var(--accent-soft); }
.channel svg { flex: none; color: var(--accent); margin-top: 1px; }
.channel strong { display: block; }
.code-input { font-size: 28px; letter-spacing: 10px; text-align: center; font-variant-numeric: tabular-nums; padding: 12px; }
.hint-box { display: flex; gap: 10px; padding: 12px; border-radius: var(--radius-sm); background: var(--surface-3); color: var(--text-2); font-size: 13px; }
.hint-box svg { flex: none; color: var(--accent); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: inherit; }
.brand:hover { text-decoration: none; }
.brand-tag { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--brand-on-dark); border: 1px solid #25405a; border-radius: 4px; padding: 1px 6px; }
.logo { display: block; }
.logo-themed .logo-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-themed .logo-light { display: none; }
  :root:not([data-theme="light"]) .logo-themed .logo-dark { display: block; }
}
:root[data-theme="dark"] .logo-themed .logo-light { display: none; }
:root[data-theme="dark"] .logo-themed .logo-dark { display: block; }
@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login-side { display: none; }
  .login-logo { display: block; margin-bottom: 8px; }
}

/* Mise en page de l'application */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { color: var(--sidebar-strong); padding: 18px 18px 14px; }
.org-brand { display: flex; align-items: center; gap: 10px; margin: 0 12px 10px; padding: 10px; border-radius: var(--radius); background: var(--sidebar-2); }
.org-brand .meta { min-width: 0; display: flex; flex-direction: column; }
.org-brand strong { color: var(--sidebar-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.org-brand .small { color: var(--sidebar-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.org-logo { flex: none; width: 40px; height: 40px; border-radius: 8px; object-fit: contain; background: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; background-color: var(--brand-2); }
img.org-logo { background: #fff; padding: 3px; }
.org-logo.platform { background: linear-gradient(135deg, var(--brand-1), var(--brand-2)); }
.org-switch { margin: 0 12px 12px; }
.org-switch select { width: 100%; background: var(--sidebar-2); color: var(--sidebar-strong); border: 1px solid #263552; border-radius: var(--radius-sm); padding: 8px 10px; }
.nav { padding: 4px 8px 16px; display: flex; flex-direction: column; gap: 2px; }
.nav-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #7586a3; padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; color: var(--sidebar-text); padding: 8px 10px; border-radius: var(--radius-sm); }
.nav a:hover { background: var(--sidebar-2); color: var(--sidebar-strong); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--sidebar-2); color: var(--sidebar-strong); box-shadow: inset 3px 0 0 var(--brand-on-dark); }
.nav a[aria-current="page"] svg { color: var(--brand-on-dark); }
.nav a .count { margin-left: auto; background: var(--brand-2); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; font-variant-numeric: tabular-nums; }
.sidebar-foot { margin-top: auto; padding: 12px; border-top: 1px solid #1d2a42; display: flex; align-items: center; gap: 10px; }
.sidebar-foot .who { min-width: 0; flex: 1; }
.sidebar-foot .who strong { display: block; color: var(--sidebar-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot button { background: none; border: 0; color: var(--sidebar-text); cursor: pointer; padding: 6px; border-radius: var(--radius-sm); }
.sidebar-foot button:hover { background: var(--sidebar-2); color: #fff; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.content { padding: 28px 32px 48px; max-width: 1320px; width: 100%; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.banner { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid transparent; }
.banner.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.banner.bad { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.banner.info { background: var(--info-soft); color: var(--info); }
.banner p { color: var(--text); }
@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .shell.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; }
  .content { padding: 20px 16px 40px; }
  .shell.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 35; }
}
.scrim { display: none; }

/* Cartes et indicateurs */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head .sub { color: var(--muted); font-size: 12.5px; }
.card-body { padding: 16px; }
.card-body.flush { padding: 0; }
.grid { display: grid; gap: 16px; }
.kpis { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.kpi { padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.kpi .label { color: var(--text-2); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.kpi .label svg { color: var(--muted); }
.kpi .value { font-size: 28px; font-weight: 680; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi .foot { color: var(--muted); font-size: 12.5px; }
.cols-2 { display: grid; gap: 16px; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
@media (max-width: 1100px) { .cols-2 { grid-template-columns: 1fr; } }

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); border-radius: var(--radius-sm); padding: 7px 12px; cursor: pointer; font-weight: 550; white-space: nowrap; min-height: 34px; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--border)); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { padding: 4px 9px; min-height: 28px; font-size: 13px; }
.btn.block { width: 100%; min-height: 40px; }
.icon-btn { border: 0; background: none; padding: 6px; border-radius: var(--radius-sm); cursor: pointer; color: var(--text-2); display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

/* Formulaires */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > .label { font-weight: 560; font-size: 13px; color: var(--text-2); }
.field .help { color: var(--muted); font-size: 12px; }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--border-strong); background: var(--surface); border-radius: var(--radius-sm); padding: 8px 10px; min-height: 36px; }
textarea.input { min-height: 80px; resize: vertical; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.toolbar .input { width: auto; min-width: 140px; }
.toolbar .search { flex: 1; min-width: 200px; max-width: 360px; }
.form-error { color: var(--bad); font-size: 13px; }

/* Onglets */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 10px 12px; cursor: pointer; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 560; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tabs .count { background: var(--surface-3); color: var(--text-2); border-radius: 10px; padding: 0 7px; font-size: 11.5px; margin-left: 6px; }

/* Tableaux */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
.table td.wrap { white-space: normal; min-width: 140px; }
.table th:first-child, .table td:first-child { padding-left: 16px; }
.table th:last-child, .table td:last-child { padding-right: 16px; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.clickable { cursor: pointer; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }
.empty svg { color: var(--border-strong); margin-bottom: 8px; }
.pager { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.pager .right { display: flex; gap: 6px; }

/* Pastilles, avatars */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 580; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pills { display: flex; gap: 4px; flex-wrap: wrap; }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person .meta { min-width: 0; }
.person .meta strong { display: block; font-weight: 580; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 650; font-size: 12px; flex: none; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }
.grade { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; font-weight: 700; font-size: 13px; background: var(--surface-3); color: var(--text-2); }
.grade.A, .grade.B { background: var(--good-soft); color: var(--good); }
.grade.C, .grade.D { background: var(--warn-soft); color: var(--warn); }
.grade.E, .grade.F { background: var(--bad-soft); color: var(--bad); }

/* Listes d'actions */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { min-width: 0; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }

/* Graphique */
.chart { position: relative; }
.chart { min-height: 220px; }
.chart svg { display: block; overflow: visible; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font-size: 11px; }
.chart .bar-ontime { fill: var(--series-1); }
.chart .bar-late { fill: var(--series-2); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .hover-band, .chart .hover-band.on { fill: var(--surface-3); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend i.ontime { background: var(--series-1); }
.legend i.late { background: var(--series-2); }
.tooltip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); border-radius: var(--radius-sm); padding: 8px 10px; font-size: 12.5px; min-width: 140px; z-index: 5; color: var(--text); }
.tooltip .t { font-weight: 620; margin-bottom: 4px; }
.tooltip .r { display: flex; justify-content: space-between; gap: 12px; }
.tooltip .r i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 6px; }

/* Fenêtres, notifications */
.modal-back { position: fixed; inset: 0; background: rgba(9, 14, 22, .5); display: grid; place-items: center; padding: 16px; z-index: 50; animation: fade .12s ease-out; }
.modal { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.modal.wide { max-width: 820px; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }
@keyframes fade { from { opacity: 0; } }
#toasts { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; max-width: calc(100vw - 32px); }
.toast { background: var(--text); color: var(--surface); padding: 10px 14px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); display: flex; gap: 8px; align-items: center; animation: fade .15s ease-out; max-width: 420px; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.good { background: var(--good); color: #fff; }
.big-code { font-size: 40px; font-weight: 700; letter-spacing: 8px; text-align: center; padding: 20px; background: var(--surface-3); border-radius: var(--radius); font-variant-numeric: tabular-nums; }
.schedule td { padding: 6px 8px; }
.schedule .input { min-height: 32px; padding: 4px 8px; }
.skeleton { background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 6px; height: 14px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); display: inline-block; box-shadow: 0 0 0 0 var(--good); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 6px transparent; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
