/* =========================================================================
   Pilotage Cantal — feuille de styles unique
   Couleurs pilotées par des variables : thème clair / sombre via [data-theme]
   ========================================================================= */

:root {
  --jaune: #ffc800;
  --jaune-fort: #f0b400;
  --bleu: #003da5;
  --marine: #0a1a3c;
  --marine-2: #11244f;

  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --surface-3: #eef1f6;
  --border: #e2e6ee;
  --border-strong: #cfd5e1;
  --text: #121a2e;
  --text-2: #4e586d;
  --text-3: #8790a3;
  --accent: #0b4fc4;
  --accent-soft: #e8effc;
  --ok: #0e8a5f;
  --ok-soft: #e4f5ee;
  --bad: #c8312b;
  --bad-soft: #fcebea;
  --warn: #a8690a;
  --warn-soft: #fdf3e1;
  --focus: 0 0 0 3px rgba(11, 79, 196, .28);

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 2px 6px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 40px rgba(10, 26, 60, .18);
  --font: "Inter", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #121a2c;
  --surface-2: #162036;
  --surface-3: #1c2740;
  --border: #243150;
  --border-strong: #31405f;
  --text: #e8ecf5;
  --text-2: #a7b1c6;
  --text-3: #75809a;
  --accent: #5b93ff;
  --accent-soft: #1a2a4d;
  --ok: #3ccb93;
  --ok-soft: #12302a;
  --bad: #ff7468;
  --bad-soft: #3a1c1f;
  --warn: #f2b347;
  --warn-soft: #362a14;
  --focus: 0 0 0 3px rgba(91, 147, 255, .35);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1, "cv11" 1;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
[hidden] { display: none !important; }
svg.i { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }

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

/* ---------- Structure : bandeau + onglets en haut ---------- */
.app { min-height: 100dvh; display: flex; flex-direction: column; }

.header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--marine);
  color: #c9d3ea;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .04), 0 6px 20px rgba(10, 26, 60, .18);
}
.header-inner { max-width: 1560px; margin: 0 auto; padding: 0 28px; }
.header-top { display: flex; align-items: center; gap: 14px; height: 60px; }
.header-spacer { flex: 1; }

.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--jaune);
  color: var(--marine);
  display: grid;
  place-items: center;
  flex: none;
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-title { font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.brand-sub { font-size: 12px; color: #8e9bbd; }

/* Onglets */
.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 -10px;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 14px;
  color: #aab6d3;
  font-weight: 600;
  font-size: 13.5px;
  white-space: nowrap;
  text-decoration: none;
  border-radius: 8px 8px 0 0;
  transition: color .15s, background .15s;
}
.tabs a svg { width: 17px; height: 17px; opacity: .8; }
.tabs a:hover { color: #fff; background: rgba(255, 255, 255, .05); }
.tabs a[aria-current="page"] { color: #fff; }
.tabs a[aria-current="page"] svg { color: var(--jaune); opacity: 1; }
.tabs a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--jaune);
}
.tabs .tab-sep { width: 1px; margin: 12px 6px; background: rgba(255, 255, 255, .12); flex: none; }

/* Contrôles sur fond sombre */
.header .btn-ghost { color: #c9d3ea; }
.header .btn-ghost:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.header .presence-count, .header .live { color: #aab6d3; }
.header .avatar { border-color: var(--marine); }
.header .user-btn:hover { background: rgba(255, 255, 255, .08); }
.header .user-btn .who b { color: #fff; }
.header .user-btn .who small { color: #8e9bbd; }
.header .menu { color: var(--text); }

.view { padding: 26px 28px 48px; max-width: 1560px; width: 100%; margin: 0 auto; flex: 1; }
.view-enter { animation: enter .22s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(4px); } }
.page-title { font-size: 22px; font-weight: 750; letter-spacing: -.02em; margin-bottom: 18px; }

/* Mode réunion : plein écran, bandeau compact, textes plus grands */
.app.presenting .header-top { display: none; }
.app.presenting .view { max-width: none; font-size: 15px; }

/* ---------- Boutons & champs ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--jaune); border-color: var(--jaune); color: var(--marine); }
.btn-primary:hover { background: var(--jaune-fort); border-color: var(--jaune-fort); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-danger { color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-icon { width: 36px; padding: 0; }
.btn-sm.btn-icon { width: 30px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--text-2); }
.input, .select, .textarea {
  height: 36px;
  width: 100%;
  padding: 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
.select { padding-right: 30px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238790a3' stroke-width='2.5' 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 10px center; }
.textarea { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.6; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: var(--focus); outline: none; }
.select-sm { height: 30px; font-size: 13px; }

.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-3);
  border-radius: 10px;
}
.seg button {
  height: 28px;
  padding: 0 11px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-2);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 18px; }
.toolbar .grow { flex: 1; }

/* ---------- 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: 16px 18px 0;
}
.card-title { font-size: 15px; font-weight: 700; }
.card-sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.card-body { padding: 16px 18px 18px; }
.card-body.flush { padding: 8px 0 4px; }

.grid { display: grid; gap: 18px; }
.stack { display: flex; flex-direction: column; gap: 18px; }

/* ---------- Tuiles ---------- */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.tile { display: flex; align-items: center; gap: 14px; padding: 16px 18px; color: inherit; transition: border-color .15s, transform .15s; }
.tile:hover { text-decoration: none; border-color: var(--border-strong); transform: translateY(-1px); }
.tile-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent); }
.tile-icon svg { width: 20px; height: 20px; }
.tile small { display: block; color: var(--text-3); font-size: 12.5px; }
.placeholder { padding: 72px 16px; text-align: center; color: var(--text-3); }
.placeholder svg { width: 34px; height: 34px; opacity: .6; }
.placeholder h2 { font-size: 18px; color: var(--text); margin: 8px 0 6px; }

/* ---------- Accueil ---------- */
.welcome { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.welcome h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.welcome p { margin-top: 2px; }
.welcome-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.headline { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-bottom: 18px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.stat-label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.stat-label svg { width: 16px; height: 16px; color: var(--text-3); }
.stat-value { font-size: 30px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.stat-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 12.5px; min-height: 22px; }
.stat-by { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; }
.stat-by svg { width: 13px; height: 13px; }
.stat-accent { background: linear-gradient(135deg, var(--marine), #173a86); border-color: transparent; color: #fff; }
.stat-accent .stat-label, .stat-accent .stat-label svg, .stat-accent .faint { color: #b9c5e3; }
.stat-accent .stat-value { color: var(--jaune); }
.live-tag { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #63e0ad; }
.live-tag .live-dot { width: 7px; height: 7px; border-radius: 50%; background: #3ccb93; animation: pulse 2.4s infinite; }

.delta { display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px; border-radius: 20px; font-weight: 700; font-size: 12px; white-space: nowrap; }
.delta svg { width: 12px; height: 12px; }
.delta.good { color: var(--ok); background: var(--ok-soft); }
.delta.bad { color: var(--bad); background: var(--bad-soft); }
.delta.flat { color: var(--text-2); background: var(--surface-3); }
.stat-accent .delta.good { background: rgba(60, 203, 147, .18); color: #63e0ad; }
.stat-accent .delta.bad { background: rgba(255, 116, 104, .18); color: #ff9a90; }
.stat-accent .delta.flat { background: rgba(255, 255, 255, .1); color: #dbe3f5; }

.home-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(320px, 1fr); gap: 20px; align-items: start; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.section-head h2 { font-size: 17px; font-weight: 700; }
.feed { display: flex; flex-direction: column; gap: 14px; }

.post { padding: 16px 18px; border-left: 4px solid var(--border-strong); }
.post-important { border-left-color: var(--jaune); }
.post-urgent { border-left-color: var(--bad); }
.post-big { border-left-width: 5px; }
.post-big.post-info { border-left-color: var(--accent); }
.post-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.post-head .grow { flex: 1; }
.post-head .badge svg { width: 12px; height: 12px; }
.post-meta { display: flex; flex-direction: column; line-height: 1.25; font-size: 13px; }
.post-meta span { color: var(--text-3); font-size: 12px; }
.post-title { font-size: 16px; font-weight: 700; }
.post-big .post-title { font-size: 18px; }
.post-body { margin-top: 6px; color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.post-image { display: block; margin-top: 12px; padding: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface-2); cursor: zoom-in; width: 100%; }
.post-image img { display: block; width: 100%; max-height: 420px; object-fit: contain; }

.bars { width: 100%; height: auto; display: block; }
.bars .bar-real { fill: var(--accent); opacity: .85; }
.bars .bar-today { fill: var(--jaune); }
.bars .bar-fc { fill: color-mix(in srgb, var(--jaune) 18%, transparent); stroke: var(--jaune-fort); stroke-width: 1.5; stroke-dasharray: 4 3; }
.bars rect:hover { opacity: 1; filter: brightness(1.08); }
.bars .grid { stroke: var(--border); stroke-dasharray: 2 4; }
.bars .sep { stroke: var(--text-3); stroke-dasharray: 3 3; }
.bars text { font-family: var(--font); text-anchor: middle; fill: var(--text-3); }
.bars .lbl { font-size: 10.5px; font-weight: 600; }
.bars .lbl-today { font-size: 10.5px; font-weight: 800; fill: var(--text); }
.bars .lbl-sm { font-size: 9.5px; }
.bars .lbl-axis { font-size: 9.5px; text-anchor: end; }
.legend { display: flex; gap: 16px; padding: 0 18px 16px; font-size: 12px; 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; }
.lg-real { background: var(--accent); }
.lg-today { background: var(--jaune); }
.lg-fc { border: 1.5px dashed var(--jaune-fort); }

.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; color: var(--text-2); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.dropzone { display: flex; align-items: center; gap: 10px; padding: 14px; border: 1.5px dashed var(--border-strong); border-radius: 10px; color: var(--text-2); cursor: pointer; font-size: 13px; }
.dropzone:hover { border-color: var(--accent); color: var(--accent); }
.dropzone svg { width: 20px; height: 20px; }
.preview { max-height: 180px; border-radius: 8px; object-fit: contain; border: 1px solid var(--border); }
dialog.lightbox { width: auto; max-width: 94vw; max-height: 94vh; padding: 0; background: transparent; border: 0; box-shadow: none; }
dialog.lightbox img { display: block; max-width: 94vw; max-height: 90vh; border-radius: 10px; }
dialog.lightbox::backdrop { background: rgba(5, 10, 25, .85); }
.lightbox-close { position: fixed; top: 16px; right: 16px; background: rgba(255, 255, 255, .15); color: #fff; border: 0; }

@media (max-width: 1180px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .stat-grid { grid-template-columns: minmax(0, 1fr); }
  .headline { grid-template-columns: minmax(0, 1fr); }
  .welcome-actions { width: 100%; }
  .welcome-actions .btn { flex: 1; }
}

/* ---------- Trafic ---------- */
.grid-2col { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.bars.wk .bar-prev { fill: color-mix(in srgb, var(--accent) 22%, transparent); }
.bars.wk .bar-realise { fill: var(--accent); }
.bars.wk .bar-realise.ok { fill: var(--ok); }
.bars.wk .bar-realise.warn { fill: var(--jaune-fort); }
.bars.wk .bar-realise.bad { fill: var(--bad); }
.bars.wk .sel { fill: var(--accent-soft); }
.bars.wk .hit { fill: transparent; }
.bars.wk.clickable .hit { cursor: pointer; }
.bars.wk.clickable .hit:hover { fill: color-mix(in srgb, var(--accent) 6%, transparent); }
.lg-prev { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.lg-realise { background: var(--accent); }
.lg-realise.ok { background: var(--ok); }
.lg-realise.warn { background: var(--jaune-fort); }
.lg-realise.bad { background: var(--bad); }
.legend { flex-wrap: wrap; }
.rate { display: flex; align-items: center; gap: 8px; min-width: 150px; }
.rate .badge { min-width: 64px; justify-content: center; }
.rate-track { flex: 1; height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.rate-fill { display: block; height: 100%; border-radius: 6px; background: var(--accent); }
.rate-fill.ok { background: var(--ok); }
.rate-fill.warn { background: var(--jaune-fort); }
.rate-fill.bad { background: var(--bad); }
.txt-ok { color: var(--ok); }
.txt-warn { color: var(--warn); }
.txt-bad { color: var(--bad); }
.row-link { cursor: pointer; }
.row-sel td { background: var(--accent-soft) !important; }
.row-muted td { color: var(--text-3); }
.badge.cat-courrier { background: var(--accent-soft); color: var(--accent); }
.badge.cat-colis { background: var(--warn-soft); color: var(--warn); }
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.imp-log { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.imp-log div { display: flex; gap: 6px; align-items: flex-start; }
.imp-log svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.imp-log .ok svg { color: var(--ok); }
.imp-log .bad { color: var(--bad); }
@media (max-width: 1180px) { .grid-2col { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Flexi (tableau blanc) ---------- */
.flexi-wrap { overflow: auto; border-radius: var(--radius); }
.flexi { --fx-row: 34px; }
.flexi { border-collapse: separate; border-spacing: 0; font-size: 13px; min-width: 100%; }
.flexi th, .flexi td { border-bottom: 1px solid var(--border); padding: 0; text-align: center; background: var(--surface); }
.flexi thead th { position: sticky; z-index: 2; color: var(--text-2); font-weight: 600; }
.flexi thead tr:first-child th { top: 0; height: 40px; }
.flexi thead tr:nth-child(2) th { top: 40px; height: 24px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; }
.flexi .wk { border-left: 2px solid var(--border-strong); padding: 2px 4px; white-space: nowrap; }
.flexi .wk b { font-size: 14px; color: var(--text); margin-right: 6px; }
.flexi .wk small { color: var(--text-3); font-weight: 500; }
.flexi .wk .badge { margin-left: 6px; height: 18px; font-size: 10.5px; }
.flexi .first { border-left: 2px solid var(--border-strong); }
.flexi .cur { background: color-mix(in srgb, var(--jaune) 12%, var(--surface)); }
.flexi thead .cur { background: color-mix(in srgb, var(--jaune) 22%, var(--surface)); }
.flexi .wk.cur { border-top: 3px solid var(--jaune); }
.flexi .sticky-col { position: sticky; left: 0; z-index: 3; text-align: left; padding: 0 14px; min-width: 170px; max-width: 230px; border-right: 1px solid var(--border-strong); }
.flexi thead .sticky-col { z-index: 4; vertical-align: middle; }
.flexi .row-label { font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; height: var(--fx-row); font-size: 13px; }
.flexi tbody tr:hover td, .flexi tbody tr:hover th { background: var(--surface-2); }
.flexi tbody tr:hover td.cur { background: color-mix(in srgb, var(--jaune) 18%, var(--surface)); }
.flexi tfoot th, .flexi tfoot td { position: sticky; bottom: 0; z-index: 2; font-weight: 800; height: var(--fx-row); border-top: 2px solid var(--border-strong); background: var(--surface-2); }
.flexi tfoot .sticky-col { z-index: 4; }
.fx { width: 54px; height: calc(var(--fx-row) - 6px); margin: 3px; line-height: 1; padding: 0 6px; text-align: center; font-weight: 700; font-size: 14px; border: 1px solid transparent; border-radius: 7px; background: transparent; font-variant-numeric: tabular-nums; transition: background .3s, border-color .15s; }
.fx:hover:not(:disabled) { border-color: var(--border-strong); background: var(--surface); }
.fx:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: var(--focus); }
.fx:disabled { color: inherit; opacity: 1; }
.fx.saving { border-color: var(--warn); }
.fx.saved { border-color: var(--ok); }
.fx.error { border-color: var(--bad); background: var(--bad-soft); }
.fx.remote { animation: remote 1.6s ease-out; }
@keyframes remote { 0% { background: rgba(255, 200, 0, .6); } 100% { background: transparent; } }
.k-prev, .fx.k-prev { color: var(--text); }
.k-real, .fx.k-real { color: var(--accent); }
.k-dette, .fx.k-dette { color: var(--ok); }
.flexi-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; font-weight: 600; align-items: center; }
.flexi-legend span { display: inline-flex; align-items: center; gap: 6px; }
.flexi-legend i { width: 14px; height: 3px; border-radius: 2px; background: currentColor; }
.rows-list { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow: auto; }
.row-edit { display: flex; gap: 6px; align-items: center; }
.row-edit .input { flex: 1; }
dialog:has(.rows-list) { width: min(560px, calc(100vw - 32px)); }
.view:has(.flexi) { padding-bottom: 12px; }
.view:has(.flexi) .toolbar { margin-bottom: 12px; }
@media (max-height: 820px) {
  .view:has(.flexi) { padding-top: 14px; }
  .view:has(.flexi) .page-title { display: none; }
  .flexi .fx { font-size: 13px; }
  .flexi .row-label { font-size: 12.5px; }
}
@media (max-width: 700px) { .flexi .sticky-col { min-width: 110px; max-width: 130px; padding: 0 10px; font-size: 12px; } .fx { width: 46px; } }

/* ---------- Tableaux ---------- */
.table-wrap { overflow: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .r { text-align: right; }

/* ---------- Badges, avatars, présence ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 20px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--accent-soft); color: var(--accent); }
.badge.demo { background: var(--warn-soft); color: var(--warn); }

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  flex: none;
  border: 2px solid var(--bg);
  user-select: none;
}
.avatar.sm { width: 26px; height: 26px; font-size: 11px; }
.presence { display: flex; align-items: center; gap: 10px; }
.presence-stack { display: flex; }
.presence-stack .avatar + .avatar { margin-left: -8px; }
.presence-count { font-size: 12.5px; color: var(--text-2); font-weight: 600; white-space: nowrap; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); font-weight: 600; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.live[data-state="on"] .live-dot { background: var(--ok); box-shadow: 0 0 0 0 rgba(14, 138, 95, .5); animation: pulse 2.4s infinite; }
.live[data-state="off"] .live-dot { background: var(--bad); }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(14, 138, 95, 0); } 100% { box-shadow: 0 0 0 0 rgba(14, 138, 95, 0); } }

/* ---------- Menu utilisateur ---------- */
.user-menu { position: relative; }
.user-btn { display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; border-radius: 30px; border: 1px solid transparent; background: transparent; cursor: pointer; }
.user-btn:hover { background: var(--surface-3); }
.user-btn .who { text-align: left; line-height: 1.2; }
.user-btn .who b { display: block; font-size: 13px; }
.user-btn .who small { color: var(--text-3); font-size: 11.5px; }
.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 220px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 50;
}
.menu button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 0; border-radius: 8px; background: none; text-align: left; cursor: pointer; }
.menu button:hover { background: var(--surface-3); }
.menu svg { width: 16px; height: 16px; color: var(--text-2); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }

/* ---------- Toasts & dialogues ---------- */
#toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 380px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--marine);
  color: #fff;
  box-shadow: var(--shadow-lg);
  font-weight: 500;
  animation: toast-in .2s ease-out;
}
.toast.error { background: #8f1d18; }
.toast.ok svg { color: #63e0ad; }
.toast svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

dialog {
  width: min(480px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(8, 15, 32, .5); backdrop-filter: blur(2px); }
dialog[open] { animation: enter .18s ease-out; }
.dialog-head { padding: 20px 22px 0; }
.dialog-head h2 { font-size: 17px; }
.dialog-body { padding: 16px 22px; display: flex; flex-direction: column; gap: 14px; }
.dialog-foot { padding: 14px 22px 20px; display: flex; justify-content: flex-end; gap: 10px; }
.secret {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface-3);
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .04em;
}

/* ---------- États ---------- */
.empty { padding: 36px 16px; text-align: center; color: var(--text-3); }
.empty svg { width: 30px; height: 30px; margin-bottom: 8px; opacity: .6; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; font-size: 13.5px; }
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.info { background: var(--accent-soft); color: var(--accent); }
.alert.bad { background: var(--bad-soft); color: var(--bad); }

/* ---------- Connexion ---------- */
.login-page {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(420px, 1fr);
}
.login-hero {
  position: relative;
  overflow: hidden;
  background: var(--marine);
  color: #fff;
  padding: 48px 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.login-hero::after {
  content: "";
  position: absolute;
  right: -160px;
  bottom: -160px;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 200, 0, .28), rgba(255, 200, 0, 0) 65%);
}
.login-hero h1 { font-size: 40px; font-weight: 800; letter-spacing: -.03em; max-width: 520px; line-height: 1.1; }
.login-hero h1 em { font-style: normal; color: var(--jaune); }
.login-hero p { color: #a9b6d6; max-width: 440px; margin-top: 16px; font-size: 15px; }
.hero-points { display: flex; flex-direction: column; gap: 12px; position: relative; z-index: 1; }
.hero-points div { display: flex; gap: 12px; align-items: center; color: #c9d3ea; }
.hero-points svg { width: 18px; height: 18px; color: var(--jaune); }
.login-side { display: grid; place-items: center; padding: 32px; background: var(--bg); }
.login-card { width: min(400px, 100%); padding: 32px; }
.login-card h2 { font-size: 22px; margin-bottom: 4px; }
.login-card form { display: flex; flex-direction: column; gap: 16px; margin-top: 24px; }
.login-card .btn { height: 42px; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 42px; }
.pw-wrap .btn { position: absolute; right: 3px; top: 3px; height: 30px; width: 34px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .header-inner { padding: 0 14px; }
  .header-top { height: 56px; gap: 6px; }
  .brand-sub { display: none; }
  .tabs { margin: 0 -4px; }
  .tabs a { padding: 10px 10px 12px; }
  .view { padding: 18px 14px 40px; }
  .hide-sm { display: none !important; }
  .login-page { grid-template-columns: minmax(0, 1fr); }
  .login-hero { display: none; }
}

/* ---------- Trafic : graphique prévision / réalisé / TMH ---------- */
.tc-body { display: flex; }
.tc-axis { flex: none; }
.tc-scroll { flex: 1; min-width: 0; overflow-x: auto; overflow-y: hidden; padding-bottom: 6px; }
.tc-scroll svg { display: block; }
.tc { font-family: var(--font); }
.tc .tc-grid { stroke: var(--border); }
.tc .tc-ax { fill: var(--text-3); }
.tc .tc-cur { fill: color-mix(in srgb, var(--jaune) 30%, transparent); }
.tc .tc-sel { fill: var(--accent-soft); }
.tc .tc-curtxt { fill: var(--accent); }
.tc .tc-over { fill: var(--bad); }
.tc .tc-under { fill: var(--ok); }
.tc .tc-neutral { fill: var(--text-3); }
.tc .tc-in { fill: #fff; }
.tc-over-txt { fill: var(--bad); color: var(--bad); }
.tc-under-txt { fill: var(--ok); color: var(--ok); }
.tc .tc-tmh { stroke: var(--text); stroke-width: 2.5; stroke-dasharray: 8 5; }
.tc .tc-tmhtxt { fill: var(--text); paint-order: stroke; stroke: var(--surface); stroke-width: 3; }
.tc .tc-halo { fill: none; stroke: var(--surface); stroke-width: 6; stroke-linejoin: round; stroke-linecap: round; }
.tc .tc-real { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.tc .tc-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.tc .tc-hit { fill: transparent; cursor: pointer; }
.tc .tc-hit:hover { fill: color-mix(in srgb, var(--accent) 7%, transparent); }
.tc-legend em { font-style: normal; }
.tc-legend i { width: 11px; height: 11px; border-radius: 3px; }
.tc-lg-under { background: var(--ok); }
.tc-lg-over { background: var(--bad); margin-left: -4px; }
.tc-lg-real { width: 20px !important; height: 3px !important; border-radius: 2px; background: var(--accent); }
.tc-lg-tmh { width: 22px !important; height: 0 !important; border-top: 2.5px dashed var(--text); border-radius: 0 !important; }
.tc-fit { display: block; }
.tc-fit .tc-hit { cursor: default; }
.tr-print { display: flex; gap: 8px; align-items: center; }
.stat.tr-flag.over { border-color: var(--bad); }
.stat.tr-flag.over .stat-value, .stat.tr-flag.over .stat-foot { color: var(--bad); }
.stat.tr-flag.under { border-color: var(--ok); }
.stat.tr-flag.under .stat-value, .stat.tr-flag.under .stat-foot { color: var(--ok); }
.tr-total td { font-weight: 700; background: var(--surface-2); border-top: 2px solid var(--border-strong); }
.tr-form .input { height: 32px; width: 132px; text-align: right; }
.tr-form .input::placeholder { font-size: 12px; color: var(--text-3); }
.tr-form .select { min-width: 150px; }
.tr-form td { padding-top: 6px; padding-bottom: 6px; }
.tr-rules { margin: 0 0 14px; padding-left: 18px; font-size: 13.5px; color: var(--text-2); line-height: 1.7; }
.tr-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 10px; }
.tr-actions label.btn { cursor: pointer; }
.mono { font-family: var(--mono); }

/* ---------- Trafic : impression (A4 paysage) ---------- */
#tc-print { display: none; }
@media print {
  @page { size: A4 landscape; margin: 9mm; }
  body.tc-printing > *:not(#tc-print) { display: none !important; }
  body.tc-printing { background: #fff; }
  body.tc-printing #tc-print {
    display: block; color: #0f172a; background: #fff;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
    --bad: #b91c1c; --ok: #15803d; --text: #111827; --text-2: #334155; --text-3: #475569;
    --accent: #1d4ed8; --accent-soft: #e8effc; --surface: #fff; --border: #e2e8f0; --jaune: #ffc800;
  }
  #tc-print .tcp-head h1 { font-size: 17pt; color: #0a1a3c; margin-bottom: 2px; }
  #tc-print .tcp-head p { font-size: 8.5pt; color: #475569; margin-bottom: 8px; }
  #tc-print .tcp-boxes { display: flex; gap: 10px; margin-bottom: 8px; }
  #tc-print .tcp-box { border: 1.5px solid #cbd5e1; border-radius: 8px; padding: 6px 12px; min-width: 150px; }
  #tc-print .tcp-box.over { border-color: #b91c1c; } #tc-print .tcp-box.over .tcp-v, #tc-print .tcp-box.over .tcp-s { color: #b91c1c; }
  #tc-print .tcp-box.under { border-color: #15803d; } #tc-print .tcp-box.under .tcp-v, #tc-print .tcp-box.under .tcp-s { color: #15803d; }
  #tc-print .tcp-l { font-size: 7.5pt; text-transform: uppercase; letter-spacing: .05em; color: #475569; font-weight: 700; }
  #tc-print .tcp-v { font-size: 17pt; font-weight: 900; color: #0a1a3c; }
  #tc-print .tcp-s { font-size: 8pt; font-weight: 700; }
  #tc-print .legend { padding: 0; margin-bottom: 2px; font-size: 8.5pt; color: #334155; }
  #tc-print .tcp-tbl { width: 100%; border-collapse: collapse; margin-top: 6px; table-layout: fixed; }
  #tc-print .tcp-tbl th, #tc-print .tcp-tbl td { border: 1px solid #e2e8f0; padding: 3px 2px; text-align: center; font-variant-numeric: tabular-nums; }
  #tc-print .tcp-tbl tr > th:first-child { text-align: left; width: 70px; background: #f8fafc; }
  #tc-print .tcp-tbl .cur { background: #fef08a; }
}
