/* Alliatech · VoucherWifi — feuille de style du tableau de bord */

:root {
  color-scheme: light;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;

  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f6;
  --border: #e2e7ee;
  --border-strong: #cfd6e0;
  --text: #16202c;
  --text-2: #475467;
  --muted: #6b7788;

  --accent: #2a78d6;
  --accent-hover: #1f63b8;
  --accent-soft: #e8f1fc;
  --accent-text: #ffffff;
  --focus: 0 0 0 3px rgba(42, 120, 214, 0.28);

  --good: #177a3a;       --good-bg: #e7f5ec;
  --warning: #8a5a00;    --warning-bg: #fff3d6;
  --critical: #b42318;   --critical-bg: #fdecea;
  --neutral: #5b6574;    --neutral-bg: #eef1f5;

  --side-bg: #0e1a2b;
  --side-text: #c8d3e3;
  --side-muted: #7e8ea6;
  --side-active: #1b2c45;

  --chart-bar: #2a78d6;
  --chart-grid: #e6eaf0;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.14);
  --paper: #fffdf7;
  --paper-ink: #1f1f1f;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d1219;
    --surface: #151c26;
    --surface-2: #19212d;
    --surface-3: #202a38;
    --border: #253041;
    --border-strong: #334155;
    --text: #e6ebf2;
    --text-2: #b4bfcd;
    --muted: #8a97a8;
    --accent: #3987e5;
    --accent-hover: #5a9cec;
    --accent-soft: #16263d;
    --good: #5fcf86;       --good-bg: #12301f;
    --warning: #f0b84a;    --warning-bg: #33260b;
    --critical: #f47c70;   --critical-bg: #3a1714;
    --neutral: #a3adbb;    --neutral-bg: #222b37;
    --side-bg: #0a111b;
    --side-active: #17233a;
    --chart-bar: #3987e5;
    --chart-grid: #253041;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
    --paper: #f7f3e8;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1219;
  --surface: #151c26;
  --surface-2: #19212d;
  --surface-3: #202a38;
  --border: #253041;
  --border-strong: #334155;
  --text: #e6ebf2;
  --text-2: #b4bfcd;
  --muted: #8a97a8;
  --accent: #3987e5;
  --accent-hover: #5a9cec;
  --accent-soft: #16263d;
  --good: #5fcf86;       --good-bg: #12301f;
  --warning: #f0b84a;    --warning-bg: #33260b;
  --critical: #f47c70;   --critical-bg: #3a1714;
  --neutral: #a3adbb;    --neutral-bg: #222b37;
  --side-bg: #0a111b;
  --side-active: #17233a;
  --chart-bar: #3987e5;
  --chart-grid: #253041;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
  --paper: #f7f3e8;
}

/* --- Base ------------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -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; letter-spacing: -0.01em; }
h2 { font-size: 15px; font-weight: 600; }
h3 { font-size: 13px; font-weight: 600; }
p { margin: 0 0 8px; }
code, .mono { font-family: var(--mono); font-size: 0.92em; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.hidden, [hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.icon { flex: none; vertical-align: middle; }
.num { font-variant-numeric: tabular-nums; }

/* --- Structure --------------------------------------------------------------- */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px;
  flex: none;
  background: var(--side-bg);
  color: var(--side-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 18px;
  color: #fff;
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #2a78d6, #1b4f96);
  color: #fff;
}
.brand-mark img { width: 34px; height: 34px; border-radius: 9px; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: 0.01em; line-height: 1.15; }
.brand-sub { display: block; font-size: 11.5px; font-weight: 500; color: var(--side-muted); letter-spacing: 0.02em; }

.nav { padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-label { padding: 14px 10px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--side-muted); }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--side-text);
  font-weight: 500;
}
.nav a:hover { background: rgba(255, 255, 255, 0.05); text-decoration: none; color: #fff; }
.nav a[aria-current="page"] { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 #3987e5; }
.sidebar-foot { margin-top: auto; padding: 14px 20px; font-size: 11.5px; color: var(--side-muted); border-top: 1px solid rgba(255, 255, 255, 0.06); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px;
  display: flex; align-items: center; gap: 12px;
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar .crumbs { flex: 1; min-width: 0; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .crumbs a { color: var(--muted); }
.topbar .crumbs strong { color: var(--text); font-weight: 600; }
.user-chip { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  font-weight: 700; font-size: 12px; text-transform: uppercase;
}
.btn.menu-toggle { display: none; }

.content { padding: 28px; max-width: 1280px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-editor { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 160px; }

/* --- Cartes ---------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.card-head .title { display: flex; align-items: center; gap: 8px; }
.card-head .title .icon { color: var(--muted); }
.card-body { padding: 18px; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.card-flush { padding: 0; }

.kpi { padding: 16px 18px; display: flex; gap: 14px; align-items: center; }
.kpi-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.kpi-icon.accent { background: var(--accent-soft); color: var(--accent); }
.kpi-icon.good { background: var(--good-bg); color: var(--good); }
.kpi-icon.critical { background: var(--critical-bg); color: var(--critical); }
.kpi-icon.neutral { background: var(--neutral-bg); color: var(--neutral); }
.kpi-label { color: var(--muted); font-size: 12.5px; }
.kpi-value { font-size: 26px; font-weight: 650; line-height: 1.15; letter-spacing: -0.01em; }

.status-card { padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.status-card .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.status-card .label { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-weight: 600; }
.status-card > div:last-child:not(.top) { margin-top: auto; }
.status-card .big { font-size: 18px; font-weight: 650; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* --- Pastilles ------------------------------------------------------------- */

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  font-size: 12px; font-weight: 600;
  white-space: nowrap;
  line-height: 1.5;
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-good { background: var(--good-bg); color: var(--good); }
.pill-good .dot { box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 22%, transparent); }
.pill-warning { background: var(--warning-bg); color: var(--warning); }
.pill-critical { background: var(--critical-bg); color: var(--critical); }
.pill-neutral { background: var(--neutral-bg); color: var(--neutral); }
.pill-accent { background: var(--accent-soft); color: var(--accent); }

/* --- Boutons et champs -------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: 600 13.5px/1 var(--font);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
  text-decoration: none;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--critical); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-3); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn-icon { width: 32px; padding: 0; }
.btn .spinner { display: none; }
.btn.is-busy .spinner { display: inline-block; }
.btn.is-busy .icon { display: none; }
.spinner {
  width: 15px; height: 15px;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; min-width: 0; }
.field > span, .field-label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); font-weight: 400; }
.input, .select, textarea.input {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: 14px var(--font);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.select { padding-right: 28px; }
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.input::placeholder { color: var(--muted); }
.input-sm { height: 30px; font-size: 13px; }
.input-group { display: flex; align-items: center; }
.input-group .input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .addon {
  height: 36px; display: grid; place-items: center; padding: 0 10px;
  border: 1px solid var(--border-strong); border-left: 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--surface-2); color: var(--muted); font-size: 13px;
}
.search { position: relative; }
.search .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 34px; }

.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; margin-bottom: 14px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track {
  width: 38px; height: 22px; border-radius: 999px; flex: none;
  background: var(--border-strong); position: relative; transition: background 0.15s;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); transition: transform 0.15s;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: var(--focus); }
.switch .text strong { display: block; font-weight: 600; }
.switch .text small { color: var(--muted); }

.segmented { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.segmented button {
  height: 30px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text-2); font: 600 12.5px var(--font); cursor: pointer;
}
.segmented button:hover { background: var(--surface-3); }
.segmented button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

details.more { border-top: 1px dashed var(--border); padding-top: 10px; margin-top: 4px; }
details.more summary { cursor: pointer; color: var(--text-2); font-weight: 600; font-size: 13px; list-style: none; display: flex; align-items: center; gap: 6px; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary .icon { transition: transform 0.15s; }
details.more[open] summary .icon { transform: rotate(90deg); }
details.more > div { padding-top: 12px; }

/* --- Onglets ----------------------------------------------------------------- */

.tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 12px;
  border: 0; border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font: 600 13.5px var(--font);
  cursor: pointer;
  white-space: nowrap;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tab .count { background: var(--surface-3); color: var(--text-2); border-radius: 999px; padding: 0 7px; font-size: 11.5px; }
[data-panel][hidden] { display: none !important; }

/* --- Tableaux ------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-size: 11.5px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 10px 16px; background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover td { background: var(--surface-2); }
.table .primary { font-weight: 600; color: var(--text); }
.table .secondary { color: var(--muted); font-size: 12.5px; }
.table .error-cell { color: var(--critical); max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table td.actions { text-align: right; white-space: nowrap; }

.empty { padding: 48px 24px; text-align: center; color: var(--muted); }
.empty .icon-wrap {
  width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 14px;
  display: grid; place-items: center; background: var(--surface-3); color: var(--muted);
}
.empty h3 { color: var(--text); font-size: 15px; margin-bottom: 6px; }
.empty p { max-width: 420px; margin: 0 auto 14px; }

/* --- Alertes et notifications ------------------------------------------------ */

.alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radius-sm);
  margin-bottom: 16px; font-size: 13.5px;
  border: 1px solid transparent;
}
.alert .icon { margin-top: 1px; }
.alert-critical { background: var(--critical-bg); color: var(--critical); }
.alert-warning { background: var(--warning-bg); color: var(--warning); }
.alert-info { background: var(--accent-soft); color: var(--accent); }
.alert .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.alert strong { display: block; }

.toasts {
  position: fixed; right: 20px; top: 72px; z-index: 100;
  display: flex; flex-direction: column; gap: 10px;
  width: min(380px, calc(100vw - 32px));
}
.toast {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  padding: 12px 14px; font-size: 13.5px;
  animation: toast-in 0.18s ease-out;
}
.toast.good { border-left-color: var(--good); }
.toast.good .icon { color: var(--good); }
.toast.critical { border-left-color: var(--critical); }
.toast.critical .icon { color: var(--critical); }
.toast .grow { flex: 1; overflow-wrap: anywhere; }
.toast button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0; }
@keyframes toast-in { from { transform: translateY(-8px); opacity: 0; } }

.live-dot {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted);
}
.live-dot::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--good);
  animation: pulse 2s infinite;
}
.live-dot[hidden] { display: none; }
.live-dot.stale::before { background: var(--warning); animation: none; }
@keyframes pulse { 50% { opacity: 0.35; } }

/* --- Barre d'enregistrement ----------------------------------------------------- */

.savebar {
  position: fixed; bottom: 16px; left: calc(248px + 28px); right: 28px; z-index: 30;
  max-width: 1224px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--side-bg); color: #fff;
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  transform: translateY(calc(100% + 24px)); opacity: 0; pointer-events: none;
  transition: transform 0.2s, opacity 0.2s;
}
.savebar.visible { transform: none; opacity: 1; pointer-events: auto; }
body.has-savebar .content { padding-bottom: 96px; }
.savebar .msg { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.savebar .msg .dot { width: 8px; height: 8px; border-radius: 50%; background: #f0b84a; }
.savebar .input { flex: 1; min-width: 180px; background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.16); color: #fff; }
.savebar .input::placeholder { color: rgba(255, 255, 255, 0.55); }
.savebar .btn-ghost { color: #fff; }
.savebar .btn-ghost:hover { background: rgba(255, 255, 255, 0.1); }

/* --- Éditeur du ticket ----------------------------------------------------------- */

.blocks { display: flex; flex-direction: column; gap: 8px; }
.block {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.block-kind {
  width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.block-main { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 8px; align-items: center; min-width: 0; }
.block-main .label { font-weight: 600; font-size: 12.5px; color: var(--text-2); }
.block-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-width: 0; }
.block-controls .input, .block-controls .select { height: 32px; font-size: 13px; }
.block-controls .input.text { flex: 1 1 100%; min-width: 0; }
.block-controls .input.narrow { width: 72px; }
.block-controls .select { width: auto; }
.block-controls label.check { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text-2); }
.block-tools { display: flex; gap: 2px; }
.add-block { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip {
  font-family: var(--mono); font-size: 12px;
  padding: 2px 8px; border-radius: 6px;
  background: var(--surface-3); color: var(--text-2);
  border: 1px solid var(--border); cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

.receipt-wrap { position: sticky; top: 76px; }
.receipt {
  background: var(--paper); color: var(--paper-ink);
  border-radius: 4px;
  padding: 22px 16px 26px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.16), 0 1px 0 rgba(0, 0, 0, 0.05);
  position: relative;
  --tooth: 8px;
  -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / calc(2 * var(--tooth)) 100%;
          mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / calc(2 * var(--tooth)) 100%;
}
.receipt pre {
  margin: 0;
  font: 11.5px/1.45 var(--mono);
  white-space: pre;
  overflow-x: auto;
  min-height: 160px;
}
.receipt .receipt-error { color: #b42318; font: 12.5px var(--font); white-space: normal; }

/* --- Graphique ------------------------------------------------------------------ */

.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .grid-line { stroke: var(--chart-grid); stroke-width: 1; }
.chart .baseline { stroke: var(--border-strong); stroke-width: 1; }
.chart .bar { fill: var(--chart-bar); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart .col:hover .bar { filter: brightness(1.12); }
.chart .col:hover .hover-band { fill: var(--surface-3); }
.chart .hover-band { fill: transparent; }
.chart text { fill: var(--muted); font: 11px var(--font); font-variant-numeric: tabular-nums; }
.chart text.value { fill: var(--text); font-weight: 600; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--side-bg); color: #fff;
  padding: 6px 9px; border-radius: 6px; font-size: 12px; white-space: nowrap;
  transform: translate(-50%, calc(-100% - 8px));
  box-shadow: var(--shadow-lg);
}
.chart-total { font-size: 22px; font-weight: 650; }
.chart-range { color: var(--muted); font-size: 12.5px; font-weight: 400; }
details.data-table summary { cursor: pointer; color: var(--muted); font-size: 12.5px; margin-top: 8px; }

/* --- Liste des agents -------------------------------------------------------- */

.agent-row {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(0, 2.2fr) auto;
  gap: 16px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.agent-row:last-child { border-bottom: 0; }
.agent-id { display: flex; flex-direction: column; min-width: 0; }
.agent-id .primary { font-weight: 600; }
.agent-id .secondary, .agent-state .secondary { color: var(--muted); font-size: 12.5px; }
.agent-state { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.agent-state .pills { display: flex; flex-wrap: wrap; gap: 6px; }
.agent-error {
  display: flex; align-items: center; gap: 6px;
  color: var(--critical); font-size: 12.5px; min-width: 0;
}
.agent-error span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-actions { display: flex; gap: 6px; justify-content: flex-end; }
.btn-sm.btn-icon { width: 30px; }

/* --- Journal ---------------------------------------------------------------------- */

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--border); align-items: flex-start; }
.timeline li:last-child { border-bottom: 0; }
.timeline .body { flex: 1; min-width: 0; }
.timeline .body strong { font-weight: 600; display: block; }
.timeline .body .detail { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.timeline time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.event-icon { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.event-good { background: var(--good-bg); color: var(--good); }
.event-critical { background: var(--critical-bg); color: var(--critical); }
.event-info { background: var(--accent-soft); color: var(--accent); }

/* --- Connexion ---------------------------------------------------------------------- */

.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(42, 120, 214, 0.18), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(27, 79, 150, 0.16), transparent 60%),
    var(--bg);
}
.auth-card { width: 100%; max-width: 400px; padding: 32px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.auth-brand .brand-name { color: var(--text); font-size: 17px; }
.auth-brand .brand-sub { color: var(--muted); }
.auth h1 { font-size: 20px; margin-bottom: 4px; }
.auth .lead { color: var(--muted); margin-bottom: 22px; }
.auth .btn { width: 100%; height: 40px; }
.auth-foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 18px; }

.code-box {
  font-family: var(--mono); font-size: 26px; font-weight: 700; letter-spacing: 0.08em;
  padding: 14px 18px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px dashed var(--border-strong);
  display: inline-block; margin: 6px 0 12px;
}
.cmd {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 12.5px;
  background: var(--side-bg); color: #dbe6f5;
  padding: 10px 12px; border-radius: var(--radius-sm);
  overflow-x: auto;
}
.cmd code { flex: 1; white-space: nowrap; }
.cmd button { color: #dbe6f5; }

/* --- Adaptation mobile ---------------------------------------------------------- */

@media (max-width: 1100px) {
  .grid-editor { grid-template-columns: minmax(0, 1fr); }
  .receipt-wrap { position: static; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .grid-3, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 50;
    transform: translateX(-100%); transition: transform 0.2s;
  }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.nav-open .scrim { display: block; }
  .scrim { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 40; }
  .btn.menu-toggle { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .content { padding: 20px 16px; }
  .user-chip .email { display: none; }
  .hide-sm { display: none; }
  .block { grid-template-columns: minmax(0, 1fr); }
  .savebar { left: 16px; right: 16px; }
  .savebar .input { order: 3; flex-basis: 100%; }
  body.has-savebar .content { padding-bottom: 150px; }
  .block-kind { display: none; }
  .block-main { grid-template-columns: minmax(0, 1fr); }
  .agent-row { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .agent-actions { justify-content: flex-start; }
  .block-tools { justify-content: flex-end; }
}

@media (max-width: 520px) {
  .grid-4 { grid-template-columns: minmax(0, 1fr); }
  h1 { font-size: 19px; }
  .kpi-value { font-size: 22px; }
  .chart text { font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
