/* R158 — interface mobile-first. Aucune dépendance externe (polices système, pas de CDN). */
:root {
  --bg: #f3f5f9; --surface: #ffffff; --surface-2: #f7f9fc; --text: #0f172a; --muted: #5a6577; --border: #e2e8f0;
  --primary: #1d4ed8; --primary-ink: #ffffff; --primary-soft: #e0e9ff;
  --ok: #15803d; --ok-bg: #dcfce7; --ok-solid: #16a34a;
  --warn: #b45309; --warn-bg: #fef3c7; --warn-solid: #f59e0b;
  --danger: #b91c1c; --danger-bg: #fee2e2; --danger-solid: #dc2626;
  --radius: 18px; --radius-sm: 12px; --tabbar-h: 66px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 6px 20px rgba(15, 23, 42, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a1020; --surface: #121b2e; --surface-2: #17223a; --text: #e8edf7; --muted: #9aa8bf; --border: #25314b;
    --primary: #7aa7ff; --primary-ink: #0a1020; --primary-soft: #1b2a4d;
    --ok: #4ade80; --ok-bg: #0d2a1a; --ok-solid: #22c55e;
    --warn: #fbbf24; --warn-bg: #33250a; --warn-solid: #f59e0b;
    --danger: #f87171; --danger-bg: #3a1313; --danger-solid: #ef4444;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; font: 16px/1.5 var(--font); background: var(--bg); color: var(--text); min-height: 100vh; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
img { max-width: 100%; height: auto; }
a { color: var(--primary); text-underline-offset: 2px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h2 { font-size: 1.1rem; }
p { margin: 0 0 .75rem; }
code { font: .9em ui-monospace, Menlo, Consolas, monospace; background: var(--surface-2); padding: .1em .35em; border-radius: 6px; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.text-ok { color: var(--ok); } .text-warn { color: var(--warn); } .text-danger { color: var(--danger); }
.skip { position: absolute; left: -999px; top: 0; background: var(--primary); color: var(--primary-ink); padding: .6rem 1rem; z-index: 100; }
.skip:focus { left: 8px; top: 8px; border-radius: 8px; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 6px; }

/* ---- Structure ---- */
.topbar { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border); padding-top: env(safe-area-inset-top); }
.topbar-in { max-width: 880px; margin: 0 auto; display: flex; align-items: center; gap: 12px; padding: 10px 16px; min-height: 56px; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-size: 1.15rem; }
.brand-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--danger-solid); box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger-solid) 25%, transparent); }
.brand-sub { color: var(--muted); font-size: .85rem; }
.topnav { display: none; margin-left: auto; gap: 4px; }
.topnav a { padding: 8px 12px; border-radius: 10px; text-decoration: none; color: var(--muted); font-weight: 600; }
.topnav a:hover { background: var(--surface-2); color: var(--text); }
.topnav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }
.topbar-end { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.topnav + .topbar-end { margin-left: 0; }
.langsw { font-size: .85rem; font-weight: 600; text-decoration: none; padding: 6px 10px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); }
.container { max-width: 880px; margin: 0 auto; padding: 16px 16px calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom)); }
.footer { max-width: 880px; margin: 0 auto; padding: 0 16px calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom)); text-align: center; color: var(--muted); font-size: .85rem; }
.footer p { margin: 0 0 .3rem; }
.page-title { font-size: 1.6rem; margin: .5rem 0 1rem; }

/* ---- Barre d'onglets mobile ---- */
.tabbar { position: fixed; inset: auto 0 0 0; z-index: 40; display: grid; grid-template-columns: repeat(4, 1fr); background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(14px); border-top: 1px solid var(--border); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); min-height: var(--tabbar-h); }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted);
  font-size: .72rem; font-weight: 600; border-radius: 14px; padding: 4px 2px; min-height: 48px; }
.tabbar a[aria-current="page"] { color: var(--primary); background: var(--primary-soft); }
.tabbar .tab-primary { background: var(--primary); color: var(--primary-ink); }
.tabbar .tab-primary[aria-current="page"] { background: var(--primary); color: var(--primary-ink); box-shadow: 0 0 0 3px var(--primary-soft); }
.ic { display: block; }

@media (min-width: 760px) {
  .topnav { display: flex; margin-left: auto; }
  .topnav + .topbar-end { margin-left: 8px; }
  .tabbar { display: none; }
  .container, .footer { padding-bottom: 40px; }
  .container { padding-top: 24px; }
}

/* ---- Menu utilisateur ---- */
.usermenu { position: relative; }
.usermenu summary { list-style: none; cursor: pointer; }
.usermenu summary::-webkit-details-marker { display: none; }
.avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--primary); color: var(--primary-ink); font-weight: 700; }
.menu { position: absolute; right: 0; top: 46px; min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); padding: 8px; display: grid; gap: 2px; z-index: 50; }
.menu a, .menu-logout { display: block; width: 100%; text-align: left; padding: 12px; border-radius: 8px; color: var(--text); text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer; }
.menu a:hover, .menu-logout:hover { background: var(--surface-2); }
.menu-name { padding: 8px 12px; font-weight: 700; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu-logout { color: var(--danger); font-weight: 600; }

/* ---- Cartes & composants ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 0 0 16px; box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.empty { color: var(--muted); text-align: center; padding: 12px 0; margin: 0; }
.cta { margin: 14px 0 0; }
.badge { display: inline-block; min-width: 1.6em; padding: 0 .5em; border-radius: 999px; background: var(--primary); color: var(--primary-ink); font-size: .8rem; text-align: center; vertical-align: middle; }
.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; line-height: 1.3; }
.pill-ok { background: var(--ok-bg); color: var(--ok); } .pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-danger { background: var(--danger-bg); color: var(--danger); } .pill-info { background: var(--primary-soft); color: var(--primary); }
.chip { display: inline-block; padding: 3px 10px; border-radius: 8px; font-weight: 700; font-size: .85rem; }
.chip-a { background: #dbeafe; color: #1e40af; } .chip-b { background: #ede9fe; color: #5b21b6; }
@media (prefers-color-scheme: dark) { .chip-a { background: #1e3a8a; color: #dbeafe; } .chip-b { background: #4c1d95; color: #ede9fe; } }

/* ---- Bandeau d'état (accueil) ---- */
.hero { display: flex; align-items: center; gap: 16px; padding: 20px; border-radius: 24px; margin-bottom: 14px; color: #fff; box-shadow: var(--shadow); }
.hero-ok { background: linear-gradient(135deg, #15803d, #22c55e); }
.hero-warn { background: linear-gradient(135deg, #b45309, #f59e0b); }
.hero-danger { background: linear-gradient(135deg, #991b1b, #ef4444); }
.hero-icon { font-size: clamp(3rem, 16vw, 4.5rem); line-height: 1; flex: none; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .25)); }
.hero h1 { font-size: clamp(1.5rem, 6.5vw, 2.3rem); margin: 0 0 .25rem; }
.hero p { margin: 0; opacity: .95; }
.hero .hero-kicker { font-size: .8rem; letter-spacing: .04em; text-transform: uppercase; opacity: .85; margin-bottom: .25rem; }

.zones { display: grid; gap: 12px; margin-bottom: 16px; }
@media (min-width: 600px) { .zones { grid-template-columns: 1fr 1fr; } }
.zone { background: var(--surface); border: 1px solid var(--border); border-left: 6px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.zone-ok { border-left-color: var(--ok-solid); } .zone-warn { border-left-color: var(--warn-solid); } .zone-danger { border-left-color: var(--danger-solid); }
.zone header { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 12px; }
.zone h2 { margin: 0; font-size: 1.25rem; }
.tl { position: relative; height: 14px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.tl-seg { position: absolute; top: 0; bottom: 0; background: var(--danger-solid); border-radius: 999px; min-width: 6px; }
.tl-now { position: absolute; top: -5px; bottom: -5px; width: 3px; margin-left: -1.5px; background: var(--text); border-radius: 2px; }
.tl-unknown { background: repeating-linear-gradient(45deg, var(--danger-bg), var(--danger-bg) 6px, transparent 6px, transparent 12px); }
.tl-axis { display: flex; justify-content: space-between; font-size: .7rem; color: var(--muted); margin-top: 6px; }

.slots { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.slot { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; align-items: center; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.slot.is-live { border-color: var(--danger-solid); background: var(--danger-bg); }
.slot-time { font-size: 1.2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.slot-main { display: flex; gap: 6px; flex-wrap: wrap; }
.slot-meta { grid-column: 1 / -1; }
.slot.is-none { grid-template-columns: 1fr; }
.slot-del { grid-column: 1 / -1; margin: 4px 0 0; }

.map { margin: 12px 0; } .map img { border-radius: var(--radius-sm); border: 1px solid var(--border); display: block; margin: 0 auto; max-width: 420px; width: 100%; }
.map figcaption { text-align: center; margin-top: 6px; }
.acc { border-top: 1px solid var(--border); padding: 4px 0; }
.acc:first-child { border-top: 0; }
.acc summary { cursor: pointer; font-weight: 700; padding: 10px 0; list-style: none; display: flex; justify-content: space-between; align-items: center; min-height: 44px; }
.acc summary::-webkit-details-marker { display: none; }
.acc summary::after { content: "+"; font-size: 1.4rem; color: var(--muted); }
.acc[open] summary::after { content: "–"; }
.legend { list-style: none; padding: 0; display: grid; gap: 6px; }

.chart-box { position: relative; height: 200px; }

/* ---- Boutons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; border-radius: 14px; border: 1px solid transparent;
  font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; background: var(--surface-2); color: var(--text); }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.btn-sm { min-height: 40px; padding: 0 14px; font-size: .9rem; border-radius: 12px; }
.btn-block { display: flex; width: 100%; }
.btn.is-disabled { opacity: .5; pointer-events: none; }
.btn-link { background: none; border: 0; padding: 8px 0; font: inherit; font-weight: 600; color: var(--primary); cursor: pointer; text-decoration: underline; min-height: 40px; }
.btn-link.danger { color: var(--danger); }
.inline { display: inline-block; margin: 0 6px 6px 0; }

/* ---- Formulaires ---- */
.form { display: grid; gap: 14px; min-width: 0; }
.form > *, .row2 > *, .slot-card > *, .field { min-width: 0; }
input[type=time] { min-width: 0; }
.field { display: grid; gap: 6px; font-weight: 600; }
.field small, .check small { font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=time], input[type=date] {
  width: 100%; min-height: 50px; padding: 10px 14px; font: inherit; font-size: 16px; color: var(--text); background: var(--surface);
  border: 1.5px solid var(--border); border-radius: 12px; }
input:focus { border-color: var(--primary); outline: 3px solid var(--primary-soft); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pw { position: relative; display: block; }
.pw input { padding-right: 86px; }
.pw-toggle { position: absolute; right: 6px; top: 6px; bottom: 6px; padding: 0 12px; border: 0; border-radius: 8px; background: var(--surface-2); color: var(--muted); font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1.5px solid var(--border); border-radius: 12px; cursor: pointer; }
.check input { width: 22px; height: 22px; margin-top: 2px; flex: none; accent-color: var(--primary); }
.check span { display: grid; gap: 2px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.auth { max-width: 440px; margin: 8px auto 0; }
.auth h1 { font-size: 1.7rem; }
.auth .form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin: 16px 0; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--surface-2); border: 1px solid var(--border); padding: 4px; border-radius: 14px; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 46px; text-align: center; border-radius: 10px; font-weight: 700; padding: 0 6px; }
.seg input:checked + span { background: var(--surface); box-shadow: var(--shadow); color: var(--primary); }
.seg input:focus-visible + span { outline: 3px solid var(--primary); }
.seg-mode { margin-bottom: 14px; }
.slot-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px 8px; margin: 0 0 12px; display: grid; gap: 12px; background: var(--surface-2); min-width: 0; }
.slot-card legend { font-weight: 800; padding: 0 6px; }
.slot-card .field input { background: var(--surface); font-size: 1.3rem; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.local-hint { margin: -4px 0 0; min-height: 1.2em; }
.sticky-actions { position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px); padding: 10px 0 0; margin-top: 14px; z-index: 5;
  background: linear-gradient(to top, var(--surface) 70%, transparent); }
@media (min-width: 760px) { .sticky-actions { bottom: 8px; } }
.card .sticky-actions { margin-bottom: -4px; }

.flash { padding: 12px 14px; border-radius: 12px; margin: 0 0 14px; font-weight: 600; border: 1px solid transparent; }
.flash ul { margin: 0; padding-left: 1.1rem; }
.flash-success { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.flash-error { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.notice { padding: 12px 14px; border-radius: 12px; }
.notice-ok { background: var(--ok-bg); color: var(--ok); } .notice-warn { background: var(--warn-bg); color: var(--warn); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0 0 12px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 600; word-break: break-word; }

.list { list-style: none; margin: 0; padding: 0; }
.list-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; align-items: center; padding: 12px 0; border-top: 1px solid var(--border); }
.list-row:first-child { border-top: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.actions .inline { margin: 0; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { text-align: left; padding: 8px 10px; border-top: 1px solid var(--border); white-space: nowrap; }
.table td.small { white-space: normal; }

/* ---- Radar ---- */
.status-line { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 12px; font-size: 1.1rem; }
.status-ok { background: var(--ok-bg); color: var(--ok); } .status-warn { background: var(--warn-bg); color: var(--warn); } .status-danger { background: var(--danger-bg); color: var(--danger); }
.status-emoji { font-size: 1.8rem; }
.daynav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 14px; }
.waterfall { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 10px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.wf-labels { position: sticky; left: 0; z-index: 2; display: grid; grid-template-rows: 26px minmax(70px, auto) 120px 120px; gap: 6px; background: var(--surface); padding-right: 6px; font-size: .75rem; font-weight: 700; color: var(--muted); }
.wf-labels span { display: flex; align-items: center; }
.wf-col { display: grid; grid-template-rows: 26px minmax(70px, auto) 120px 120px; gap: 6px; flex: none; width: 120px; scroll-snap-align: start; }
.wf-time { text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; font-size: .85rem; }
.wf-codes { font-size: .72rem; line-height: 1.3; padding: 4px; border-radius: 8px; background: var(--surface-2); font-variant-numeric: tabular-nums; text-align: center; }
.wf-img { border-radius: 8px; overflow: hidden; border: 3px solid transparent; background: var(--surface-2); }
.wf-img img { display: block; width: 100%; height: 100%; object-fit: cover; }
.wf-img.is-act { border-color: var(--danger-solid); } .wf-img.is-inact { border-color: var(--ok-solid); }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin: 0 4px 0 12px; vertical-align: middle; }
.dot-ok { background: var(--ok-solid); } .dot-danger { background: var(--danger-solid); }
.legend-inline { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 8px; }
.mc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.mc { position: relative; display: block; border-radius: 10px; overflow: hidden; border: 3px solid transparent; cursor: pointer; background: var(--surface-2); }
.mc.is-act { border-color: var(--danger-solid); } .mc.is-inact { border-color: var(--ok-solid); }
.mc input { position: absolute; opacity: 0; }
.mc img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.mc-time { display: block; font-size: .72rem; text-align: center; padding: 4px 2px; font-weight: 600; }
.mc-flip { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(15, 23, 42, .7); color: #fff; font-weight: 800; }
.mc input:checked ~ .mc-flip { display: flex; }
.mc input:focus-visible ~ .mc-time { outline: 3px solid var(--primary); }

/* ---- Stats ---- */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.kpi strong { display: block; font-size: 2rem; line-height: 1.1; }
.kpi span { color: var(--muted); font-size: .85rem; }
.heat { display: flex; gap: 3px; overflow-x: auto; padding-bottom: 4px; }
.heat-col { display: grid; gap: 3px; flex: none; }
.heat-cell { display: inline-block; width: 14px; height: 14px; border-radius: 3px; background: var(--surface-2); border: 1px solid var(--border); }
.heat-cell.empty { visibility: hidden; }
.heat-cell.lv1 { background: #fecaca; border-color: transparent; } .heat-cell.lv2 { background: #f87171; border-color: transparent; }
.heat-cell.lv3 { background: #dc2626; border-color: transparent; } .heat-cell.lv4 { background: #7f1d1d; border-color: transparent; }

/* ---- Pages légales & RGPD ---- */
.footer-legal { margin-top: .5rem; }
.footer-legal a { color: var(--muted); }
.prose { max-width: 70ch; }
.prose h2 { font-size: 1.2rem; margin: 1.6rem 0 .5rem; }
.prose h3 { font-size: 1.02rem; margin: 1.1rem 0 .3rem; }
.prose ul, .prose ol { padding-left: 1.3rem; margin: 0 0 .9rem; }
.prose li { margin-bottom: .3rem; }
.prose .table-wrap { margin: .5rem 0 1rem; }
.prose .table th { background: var(--surface-2); }
.prose .table td, .prose .table th { white-space: normal; vertical-align: top; }
.toc { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 16px; margin: 0 0 1rem; }
.toc ol { margin: 0; padding-left: 1.2rem; }
.todo { background: #fde68a; color: #78350f; padding: 0 .35em; border-radius: 4px; font-weight: 700; }
.notice-info { background: var(--primary-soft); color: var(--text); }
.danger-zone { border-top: 1px solid var(--border); margin-top: 12px; }
.danger-zone summary { color: var(--danger); }
.updated { color: var(--muted); font-size: .9rem; margin: -.4rem 0 1rem; }

.check > .check-text { display: block; }
.table-wide { min-width: 40rem; }
.prose .table-wrap { -webkit-overflow-scrolling: touch; }
