/* =====================================================================
   KassTech Cloud — système de design
   Une seule source pour les couleurs, l'espacement, la typographie et les
   composants. Toutes les pages s'y réfèrent par variables : changer une
   valeur ici la change partout.
   ===================================================================== */

:root {
  /* Identité KassTech : bleu nuit et orange, repris du logo */
  --nuit-900: #080f1c; --nuit-800: #0e1a2e; --nuit-700: #16263f; --nuit-600: #1f3454; --nuit-500: #2b4468;
  --orange-700: #c2410c; --orange-600: #d9481b; --orange-500: #f0561d; --orange-400: #f4773f; --orange-100: #fde8de;
  --cyan-500: #19b5d5; --cyan-100: #dff6fb;

  /* Sémantique : une seule signification chacune */
  --ok: #0e9f6e; --ok-bg: #e6f6ef; --ok-fg: #0b7a55;
  --warn: #d97706; --warn-bg: #fdf3e3; --warn-fg: #9a5b06;
  --crit: #d64545; --crit-bg: #fdeceb; --crit-fg: #a92e2e;
  --info: #2f6fd0; --info-bg: #eaf2ff; --info-fg: #234f97;

  /* Neutres, teintés vers le bleu nuit */
  --bg: #eef2f7; --surface: #ffffff; --surface-2: #f6f8fb; --surface-3: #eef2f7;
  --ink: #111c2e; --text: #2b3648; --muted: #64748b; --faint: #94a3b8;
  --line: #e2e8f0; --line-strong: #cbd5e1;
  --sidebar-bg: var(--nuit-800); --sidebar-fg: #c7d2e3; --sidebar-active: rgba(240, 86, 29, .16);
  --topbar-bg: #ffffff;
  --ring: rgba(240, 86, 29, .35);

  --shadow-1: 0 1px 2px rgba(15, 28, 48, .06), 0 1px 3px rgba(15, 28, 48, .04);
  --shadow-2: 0 4px 14px rgba(15, 28, 48, .08);
  --shadow-3: 0 18px 44px rgba(15, 28, 48, .18);

  /* Rythme */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 28px; --s7: 40px;
  --r-s: 8px; --r: 12px; --r-l: 16px;
  --sidebar-w: 248px; --sidebar-w-min: 64px; --topbar-h: 56px;
  --font: system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Roboto Mono", monospace;
  --t: .16s cubic-bezier(.4, 0, .2, 1);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0b1322; --surface: #121c2f; --surface-2: #172238; --surface-3: #1c2a44;
  --ink: #edf2f9; --text: #cfd8e6; --muted: #8e9bb0; --faint: #64748b;
  --line: #22304a; --line-strong: #2f3f5c;
  --sidebar-bg: #0a1220; --sidebar-fg: #b6c2d6; --sidebar-active: rgba(240, 86, 29, .22);
  --topbar-bg: #121c2f;
  --ok-bg: #12301f; --ok-fg: #5ad4a2; --warn-bg: #3a2a0f; --warn-fg: #f2b45c;
  --crit-bg: #3d1b1b; --crit-fg: #f38a8a; --info-bg: #172848; --info-fg: #8fb4f2;
  --orange-100: #3a2416; --cyan-100: #0f2f38;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .35); --shadow-2: 0 4px 14px rgba(0, 0, 0, .35); --shadow-3: 0 18px 44px rgba(0, 0, 0, .55);
  --ring: rgba(244, 119, 63, .45);
  color-scheme: dark;
}

/* ----- Base ---------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; color: var(--ink); line-height: 1.25; text-wrap: balance; }
p { margin: 0; }
svg { display: block; }
.icon { width: 18px; height: 18px; flex: none; }
.icon-sm { width: 15px; height: 15px; flex: none; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: .93em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.strong { font-weight: 600; color: var(--ink); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
:focus-visible { outline: 2px solid var(--orange-500); outline-offset: 2px; }
[hidden] { display: none !important; }
[x-cloak] { display: none !important; }

/* ----- Coque : barre latérale, barre supérieure, contenu ---------------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100dvh; transition: grid-template-columns var(--t); }
.shell.is-collapsed { grid-template-columns: var(--sidebar-w-min) minmax(0, 1fr); }
.sidebar {
  background: var(--sidebar-bg); color: var(--sidebar-fg); position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column; overflow: hidden; z-index: 40;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 14px 14px; height: var(--topbar-h); border-bottom: 1px solid rgba(255, 255, 255, .06); }
.sidebar-brand img { width: 32px; height: 32px; flex: none; }
.sidebar-brand .brand-text { display: flex; flex-direction: column; line-height: 1.1; white-space: nowrap; overflow: hidden; }
.sidebar-brand .brand-name { color: #fff; font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.sidebar-brand .brand-sub { font-size: 11px; color: var(--faint); letter-spacing: .08em; text-transform: uppercase; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 10px 20px; scrollbar-width: thin; }
.nav-section { margin-top: 14px; }
.nav-section-title {
  display: flex; align-items: center; justify-content: space-between; width: 100%; background: none; border: 0;
  padding: 6px 10px; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); cursor: pointer; border-radius: 6px;
}
.nav-section-title:hover { color: #fff; }
.nav-section-title .icon-sm { transition: transform var(--t); }
.nav-section.is-open .nav-section-title .icon-sm { transform: rotate(180deg); }
.nav-section-items { display: none; }
.nav-section.is-open .nav-section-items { display: block; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 8px; color: var(--sidebar-fg);
  text-decoration: none; font-size: 13.5px; white-space: nowrap; transition: background var(--t), color var(--t);
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.is-active { background: var(--sidebar-active); color: #fff; box-shadow: inset 3px 0 0 var(--orange-500); }
.nav-item.is-soon { opacity: .55; }
.nav-item .icon { color: currentColor; opacity: .9; }
.nav-item .nav-badge { margin-left: auto; font-size: 10.5px; padding: 1px 7px; border-radius: 999px; background: rgba(255, 255, 255, .1); color: #fff; }
.sidebar-foot { padding: 10px; border-top: 1px solid rgba(255, 255, 255, .06); font-size: 11.5px; color: var(--faint); white-space: nowrap; overflow: hidden; }
.shell.is-collapsed .brand-text, .shell.is-collapsed .nav-section-title span, .shell.is-collapsed .nav-item span,
.shell.is-collapsed .nav-badge, .shell.is-collapsed .sidebar-foot span { display: none; }
.shell.is-collapsed .nav-item { justify-content: center; padding: 10px; }
.shell.is-collapsed .nav-section-title { justify-content: center; }
.shell.is-collapsed .nav-section-items { display: block; }
.sidebar-overlay { display: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h); background: var(--topbar-bg); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px; padding: 0 var(--s5);
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 4px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 8px; border: 0;
  background: transparent; color: var(--muted); cursor: pointer; position: relative; transition: background var(--t), color var(--t);
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn .dot { position: absolute; top: 7px; right: 7px; min-width: 8px; height: 8px; border-radius: 999px; background: var(--orange-500); border: 2px solid var(--topbar-bg); }
.icon-btn .count { position: absolute; top: 3px; right: 3px; font-size: 10px; font-weight: 700; padding: 0 5px; min-width: 16px; height: 16px; line-height: 16px; border-radius: 999px; background: var(--orange-500); color: #fff; text-align: center; }
.icon-btn.is-spinning .icon { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.site-switch { display: flex; align-items: center; gap: 8px; min-width: 0; }
.site-switch select {
  appearance: none; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 30px 7px 12px;
  font-weight: 600; color: var(--ink); max-width: 260px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
}
.avatar {
  width: 32px; height: 32px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--nuit-600), var(--nuit-800)); color: #fff; font-size: 12px; font-weight: 700; letter-spacing: .02em;
}
.menu { position: relative; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 240px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow-3); padding: 6px; z-index: 50;
}
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 8px;
  text-align: left; text-decoration: none; color: var(--text); cursor: pointer; font-size: 13.5px;
}
.menu-item:hover { background: var(--surface-2); color: var(--ink); }
.menu-item.is-danger { color: var(--crit); }
.menu-empty { padding: 24px 12px; text-align: center; color: var(--muted); font-size: 13px; }

.admin-banner {
  background: var(--nuit-700); color: #fff; padding: 8px var(--s5); display: flex; align-items: center; gap: 12px; font-size: 13px;
}
.admin-banner .btn { padding: 4px 10px; }

/* ----- Bandeau de titre identique partout -------------------------------- */
.page-header {
  background: var(--surface); border-bottom: 1px solid var(--line); padding: 14px var(--s5) 14px;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.page-header .eyebrow { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--orange-600); font-weight: 700; }
.page-header h1 { font-size: 20px; font-weight: 700; letter-spacing: -.01em; margin-top: 2px; }
.page-header .desc { color: var(--muted); font-size: 13px; margin-top: 2px; }
.page-header .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.content { padding: var(--s5); display: flex; flex-direction: column; gap: var(--s4); max-width: 1480px; width: 100%; margin: 0 auto; }

/* ----- Grille et cartes --------------------------------------------------- */
.grid { display: grid; gap: var(--s4); grid-template-columns: repeat(12, minmax(0, 1fr)); align-items: stretch; }
.col-3 { grid-column: span 3; } .col-4 { grid-column: span 4; } .col-5 { grid-column: span 5; } .col-6 { grid-column: span 6; }
.col-7 { grid-column: span 7; } .col-8 { grid-column: span 8; } .col-9 { grid-column: span 9; } .col-12 { grid-column: span 12; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-1);
  display: flex; flex-direction: column; min-width: 0; overflow: hidden;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 10px; }
.card-head h2 { font-size: 14px; font-weight: 700; }
.card-head .sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.card-body { padding: 0 16px 16px; flex: 1; min-width: 0; }
.card-body.flush { padding: 0; }
.card-foot { padding: 10px 16px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-foot a { color: var(--orange-600); font-weight: 600; text-decoration: none; }

/* ----- Tuiles de chiffres ------------------------------------------------- */
.stat { padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; justify-content: space-between; }
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.stat-icon { width: 30px; height: 30px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; background: var(--orange-100); color: var(--orange-600); }
.stat-icon.cyan { background: var(--cyan-100); color: #0e8fa8; }
.stat-icon.ok { background: var(--ok-bg); color: var(--ok-fg); }
.stat-icon.info { background: var(--info-bg); color: var(--info-fg); }
.stat-value { font-size: 24px; font-weight: 700; color: var(--ink); letter-spacing: -.02em; line-height: 1.1; }
.stat-value small { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: 0; margin-left: 4px; }
.stat-foot { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; min-height: 18px; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 700; padding: 1px 6px; border-radius: 999px; font-size: 11.5px; white-space: nowrap; flex: none; }
.delta.up { background: var(--ok-bg); color: var(--ok-fg); }
.delta.down { background: var(--crit-bg); color: var(--crit-fg); }
.delta.flat { background: var(--surface-3); color: var(--muted); }

/* ----- Pastilles d'état ---------------------------------------------------- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: 999px; white-space: nowrap; letter-spacing: .02em; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.pill.ok { background: var(--ok-bg); color: var(--ok-fg); }
.pill.warn { background: var(--warn-bg); color: var(--warn-fg); }
.pill.crit { background: var(--crit-bg); color: var(--crit-fg); }
.pill.info { background: var(--info-bg); color: var(--info-fg); }
.pill.neutral { background: var(--surface-3); color: var(--muted); }
.pill.no-dot::before { display: none; }
.tag { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--surface-3); color: var(--text); }

/* ----- Boutons ------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 14px; border-radius: 8px; border: 1px solid transparent;
  font-weight: 600; font-size: 13.5px; cursor: pointer; text-decoration: none; transition: background var(--t), border-color var(--t), color var(--t), box-shadow var(--t);
  white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--orange-500); color: #fff; }
.btn-primary:hover { background: var(--orange-600); }
.btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-3); color: var(--ink); }
.btn-danger { background: var(--crit); color: #fff; }
.btn-danger:hover { filter: brightness(.92); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn .spinner { display: none; }
.btn.is-loading .spinner { display: inline-block; }
.btn.is-loading .label { opacity: .6; }
.spinner { width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, .4); border-top-color: #fff; border-radius: 999px; animation: spin .7s linear infinite; }
.btn-secondary .spinner, .btn-ghost .spinner { border-color: var(--line-strong); border-top-color: var(--ink); }

/* ----- Formulaires ------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink); }
.field .hint { font-size: 12px; color: var(--muted); }
.field .error { font-size: 12.5px; color: var(--crit-fg); display: flex; align-items: center; gap: 5px; }
.input, .select, .textarea {
  width: 100%; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink); transition: border-color var(--t), box-shadow var(--t); min-height: 40px;
}
.input::placeholder { color: var(--faint); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--orange-500); box-shadow: 0 0 0 3px var(--ring); }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea { border-color: var(--crit); }
.field.is-valid .input { border-color: var(--ok); }
.input-group { position: relative; }
.input-group .input { padding-right: 40px; }
.input-group .icon-btn { position: absolute; right: 2px; top: 2px; width: 34px; height: 34px; }
.input-affix { display: flex; align-items: stretch; }
.input-affix .input { border-radius: 8px 0 0 8px; }
.input-affix .affix { display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--line-strong); border-left: 0; border-radius: 0 8px 8px 0; background: var(--surface-2); color: var(--muted); font-size: 13px; white-space: nowrap; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--text); }
.check input { margin-top: 3px; accent-color: var(--orange-500); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.alert { display: flex; gap: 10px; padding: 10px 12px; border-radius: 8px; font-size: 13px; align-items: flex-start; }
.alert.crit { background: var(--crit-bg); color: var(--crit-fg); }
.alert.ok { background: var(--ok-bg); color: var(--ok-fg); }
.alert.info { background: var(--info-bg); color: var(--info-fg); }
.alert.warn { background: var(--warn-bg); color: var(--warn-fg); }

/* ----- Tableaux ---------------------------------------------------------- */
.table-tools { display: flex; align-items: center; gap: 8px; padding: 0 16px 10px; flex-wrap: wrap; }
.table-tools .search { position: relative; flex: 1; min-width: 160px; max-width: 320px; }
.table-tools .search .input { padding-left: 34px; min-height: 34px; padding-top: 6px; padding-bottom: 6px; }
.table-tools .search .icon-sm { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 9px 12px; text-align: left; vertical-align: middle; border-top: 1px solid var(--line); white-space: nowrap; }
.table th:first-child, .table td:first-child { padding-left: 16px; }
.table th:last-child, .table td:last-child { padding-right: 16px; }
.table thead th { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; background: var(--surface-2); border-top: 0; user-select: none; }
.table thead th.sortable { cursor: pointer; }
.table thead th.sortable:hover { color: var(--ink); }
.table thead th .sort-ind { display: inline-block; width: 0; height: 0; margin-left: 5px; vertical-align: middle; border: 4px solid transparent; opacity: .35; border-top-color: currentColor; transform: translateY(2px); }
.table thead th.sorted-asc .sort-ind { opacity: 1; border-top-color: transparent; border-bottom-color: currentColor; transform: translateY(-2px); }
.table thead th.sorted-desc .sort-ind { opacity: 1; }
.table tbody tr:hover { background: var(--surface-2); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .cell-main { font-weight: 600; color: var(--ink); }
.table .cell-sub { font-size: 12px; color: var(--muted); }
.table tr.is-hidden { display: none; }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.pager { display: flex; align-items: center; gap: 4px; }
.pager .btn { min-width: 30px; padding: 4px 8px; }
.page-size { padding: 4px 26px 4px 8px; min-height: 30px; font-size: 12.5px; }
.col-chooser { position: relative; }
.col-chooser-panel { position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-3); padding: 8px; z-index: 20; }
.col-chooser-panel label { display: flex; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 6px; font-size: 13px; cursor: pointer; }
.col-chooser-panel label:hover { background: var(--surface-2); }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--line); }
.list-item:first-child { border-top: 0; }
.list-item .body { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; color: var(--ink); font-size: 13.5px; }
.list-item .meta { font-size: 12px; color: var(--muted); }

/* ----- États vides et squelettes ------------------------------------------- */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 28px 16px; gap: 6px; color: var(--muted); }
.empty .icon { width: 28px; height: 28px; color: var(--faint); margin-bottom: 4px; }
.empty .title { font-weight: 600; color: var(--text); font-size: 13.5px; }
.empty .desc { font-size: 12.5px; max-width: 32ch; }
.skeleton { position: relative; overflow: hidden; background: var(--surface-3); border-radius: 6px; min-height: 12px; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent); animation: shimmer 1.4s infinite; }
:root[data-theme="dark"] .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .08), transparent); }
@keyframes shimmer { to { transform: translateX(100%); } }
.page-loading .content > * { opacity: .5; pointer-events: none; }

/* ----- Modales ------------------------------------------------------------- */
dialog.modal { border: 0; padding: 0; background: transparent; max-width: min(560px, calc(100vw - 32px)); width: 100%; margin: auto; }
dialog.modal::backdrop { background: rgba(8, 15, 28, .55); backdrop-filter: blur(2px); }
.modal-box { background: var(--surface); border-radius: var(--r-l); box-shadow: var(--shadow-3); display: flex; flex-direction: column; max-height: calc(100dvh - 32px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px 12px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 16px; }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-foot { padding: 12px 20px 16px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
body.modal-open { overflow: hidden; }

/* ----- Toasts -------------------------------------------------------------- */
.toasts { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: calc(100vw - 32px); }
.toast { background: var(--nuit-800); color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow-3); font-size: 13.5px; display: flex; gap: 10px; align-items: center; animation: toast-in .2s ease-out; min-width: 240px; }
.toast.ok { border-left: 3px solid var(--ok); }
.toast.crit { border-left: 3px solid var(--crit); }
.toast.warn { border-left: 3px solid var(--warn); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* ----- Graphique (SVG rendu côté serveur) ----------------------------------- */
.chart { width: 100%; height: auto; }
.chart .bar { fill: var(--orange-500); }
.chart .bar.is-today { fill: var(--orange-700); }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis-text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .value-text { fill: var(--ink); font-size: 11px; font-weight: 600; font-family: var(--font); }
.chart .bar-hit:hover + .bar, .bar:hover { fill: var(--orange-400); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); align-items: center; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--orange-500); margin-right: 5px; vertical-align: -1px; }

/* ----- Pages hors connexion ------------------------------------------------- */
.guest { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.guest-side { background: linear-gradient(160deg, var(--nuit-900), var(--nuit-700) 60%, var(--nuit-600)); color: #fff; padding: 40px; display: flex; flex-direction: column; justify-content: space-between; }
.guest-side .brand { display: flex; align-items: center; gap: 12px; }
.guest-side .brand img { width: 40px; height: 40px; }
.guest-side .brand b { font-size: 18px; }
.guest-side h2 { color: #fff; font-size: 28px; font-weight: 700; letter-spacing: -.02em; max-width: 18ch; }
.guest-side p { color: #b6c2d6; margin-top: 12px; max-width: 42ch; font-size: 14.5px; }
.guest-side ul { list-style: none; padding: 0; margin: 22px 0 0; display: flex; flex-direction: column; gap: 10px; color: #dbe3ef; font-size: 14px; }
.guest-side li { display: flex; gap: 10px; align-items: flex-start; }
.guest-side li .icon-sm { color: var(--orange-400); margin-top: 3px; }
.guest-side .foot { font-size: 12px; color: var(--faint); }
.guest-main { display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.guest-card { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 18px; }
.guest-card h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.guest-card .lead { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.guest-card form { display: flex; flex-direction: column; gap: 14px; }
.guest-links { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); flex-wrap: wrap; gap: 8px; }
.guest-links a { color: var(--orange-600); font-weight: 600; text-decoration: none; }
.guest-top { display: flex; justify-content: flex-end; gap: 4px; }

/* ----- Divers ---------------------------------------------------------------- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--ink); font-weight: 500; }
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.progress { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--orange-500); border-radius: 999px; }
.progress.cyan i { background: var(--cyan-500); }
.divider { height: 1px; background: var(--line); }

/* ----- Responsive ------------------------------------------------------------ */
@media (max-width: 1200px) {
  .col-3 { grid-column: span 6; } .col-4 { grid-column: span 6; } .col-5, .col-7, .col-8, .col-9 { grid-column: span 12; }
}
@media (max-width: 960px) {
  .shell, .shell.is-collapsed { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; width: var(--sidebar-w); transform: translateX(-100%); transition: transform var(--t); }
  .shell.is-collapsed .brand-text, .shell.is-collapsed .nav-section-title span, .shell.is-collapsed .nav-item span, .shell.is-collapsed .nav-badge, .shell.is-collapsed .sidebar-foot span { display: initial; }
  .shell.is-collapsed .nav-item { justify-content: flex-start; padding: 9px 10px; }
  .shell.is-collapsed .nav-section-title { justify-content: space-between; }
  .shell.nav-open .sidebar { transform: translateX(0); box-shadow: var(--shadow-3); }
  .sidebar-overlay { display: block; position: fixed; inset: 0; background: rgba(8, 15, 28, .5); z-index: 35; opacity: 0; pointer-events: none; transition: opacity var(--t); }
  .shell.nav-open .sidebar-overlay { opacity: 1; pointer-events: auto; }
  .guest { grid-template-columns: minmax(0, 1fr); }
  .guest-side { display: none; }
  .topbar { padding: 0 12px; }
  .content { padding: 12px; gap: 12px; }
  .page-header { padding: 12px; }
}
@media (max-width: 640px) {
  .col-3, .col-4, .col-6 { grid-column: span 12; }
  .stat-grid .col-3 { grid-column: span 6; }
  .stat-value { font-size: 20px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2 { grid-column: span 1; }
  .site-switch .icon-sm { display: none; }
  .site-switch select { max-width: 150px; padding-left: 10px; }
  .topbar-left { gap: 4px; }
  .topbar-right { gap: 0; }
  .topbar-right .hide-mobile, .hide-mobile { display: none !important; }
  .page-header h1 { font-size: 18px; }
  .table-tools { padding: 0 12px 10px; }
  .table th:first-child, .table td:first-child { padding-left: 12px; }
  .table th:last-child, .table td:last-child { padding-right: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media print {
  .sidebar, .topbar, .page-header .actions, .table-tools, .table-foot { display: none !important; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .card { box-shadow: none; break-inside: avoid; }
}
