/* Milla – main courante électronique */
:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --border: #dde3ec;
  --text: #142033;
  --muted: #5f6b7d;
  --brand: #0f2340;
  --brand-2: #1b3a66;
  --primary: #2563eb;
  --primary-ink: #ffffff;
  --success: #15803d;
  --success-bg: #e8f6ee;
  --warn: #b45309;
  --warn-bg: #fdf3e2;
  --danger: #c81e1e;
  --danger-bg: #fdeaea;
  --info: #1d5fc4;
  --info-bg: #e8f0fd;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 2px 8px rgb(16 24 40 / 6%);
  --radius: 12px;
  --topbar: 56px;
  --tabbar: 64px;
  --nav: 232px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --surface: #131c2e;
    --surface-2: #18233a;
    --border: #26334d;
    --text: #e6ebf3;
    --muted: #93a0b6;
    --brand: #0a1730;
    --brand-2: #1b3a66;
    --primary: #3b82f6;
    --success: #34c77b;
    --success-bg: #11291d;
    --warn: #f0a53a;
    --warn-bg: #2d2211;
    --danger: #f45b5b;
    --danger-bg: #331617;
    --info: #6aa5ff;
    --info-bg: #14233d;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.25; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .5em; }
a { color: var(--primary); }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small, small { font-size: .82rem; }
.block { display: block; }
.center { text-align: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; }
.pre { white-space: pre-wrap; word-break: break-word; }
.hash { font-family: ui-monospace, monospace; font-size: .75rem; word-break: break-all; color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.danger-text { color: var(--danger) !important; }
[hidden] { display: none !important; }

.icon { width: 1.15em; height: 1.15em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: -.2em; }
.icon.xl { width: 56px; height: 56px; }

/* --- Structure ------------------------------------------------------------- */
#app { min-height: 100vh; }
.boot { display: grid; place-items: center; min-height: 100vh; }
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--topbar); z-index: 30;
  display: flex; align-items: center; gap: 12px; padding: 0 12px;
  background: var(--brand); color: #fff;
  padding-top: env(safe-area-inset-top);
}
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.brand .icon { color: #6aa5ff; width: 24px; height: 24px; }
.spacer { flex: 1; }
.site-select, .site-name {
  max-width: min(40vw, 340px); background: rgb(255 255 255 / 10%); color: #fff; border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 8px; padding: 6px 8px; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.site-select option { color: #000; }
.site-select:disabled { opacity: .85; }
.user { display: flex; flex-direction: column; line-height: 1.15; text-align: right; }
.user small { opacity: .7; }
.icon-btn { background: none; border: 0; color: inherit; padding: 8px; border-radius: 8px; cursor: pointer; display: inline-grid; place-items: center; }
.icon-btn:hover { background: rgb(127 127 127 / 15%); }
.menu-btn { display: none; }
.conn {
  display: flex; align-items: center; gap: 6px; border: 0; border-radius: 999px; padding: 4px 10px;
  font-size: .8rem; cursor: pointer; color: #fff; background: rgb(255 255 255 / 12%);
}
.conn.online .icon { color: #4ade80; }
.conn.pending { background: #b45309; }
.conn.offline { background: #c81e1e; }

.sidenav {
  position: fixed; top: var(--topbar); bottom: 0; left: 0; width: var(--nav); z-index: 25;
  background: var(--surface); border-right: 1px solid var(--border); padding: 12px 8px; overflow-y: auto;
}
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: var(--text); text-decoration: none; font-weight: 500;
}
.nav-link:hover { background: var(--surface-2); }
.nav-link.active { background: var(--info-bg); color: var(--info); }
.scrim { display: none; }
main {
  margin-left: var(--nav); padding: calc(var(--topbar) + 20px) 24px 96px;
  max-width: calc(1200px + var(--nav)); outline: none;
}
.tabbar { display: none; }

/* --- Composants --------------------------------------------------------------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head p { margin: 0; }
.head-actions, .row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.section { margin-top: 24px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 16px 0 8px; flex-wrap: wrap; }
.section-head h2, .section-head h3 { margin: 0; }
.link { text-decoration: none; font-weight: 500; }
.back { display: inline-block; margin-bottom: 8px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 12px; }
.card.success { background: var(--success-bg); border-color: transparent; color: var(--success); }
.card.warn { background: var(--warn-bg); border-color: transparent; color: var(--warn); }
.card.error { background: var(--danger-bg); border-color: transparent; color: var(--danger); }
.card.info { background: var(--info-bg); border-color: transparent; color: var(--info); box-shadow: none; }
.card.inactive { opacity: .6; }
.card h2 .icon { color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px;
  border-radius: 10px; border: 1px solid transparent; background: var(--surface-2); color: var(--text);
  font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: var(--primary-ink); }
.btn.success { background: var(--success); color: #fff; }
.btn.warn { background: #d97706; color: #fff; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: var(--border); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { min-height: 32px; padding: 4px 10px; font-size: .85rem; }
.btn.lg { min-height: 52px; font-size: 1.05rem; padding: 12px 20px; }
.btn.block { display: flex; width: 100%; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge.success { background: var(--success-bg); color: var(--success); border-color: transparent; }
.badge.warn, .badge.prio-haute { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.error, .badge.prio-critique { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.badge.info { background: var(--info-bg); color: var(--info); border-color: transparent; }
.badge.prio-basse { opacity: .8; }
.company { display: inline-flex; align-items: center; gap: 6px; padding: 1px 9px 1px 7px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--success-bg); color: var(--success); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.company::before { content: ''; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.companies .row-item { align-items: flex-start; }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); margin-right: 4px; }
.dot.live { background: #22c55e; box-shadow: 0 0 0 0 rgb(34 197 94 / 60%); animation: pulse 2s infinite; }
.dot.warn { background: #f59e0b; }
.dot.danger { background: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgb(34 197 94 / 50%); } 70% { box-shadow: 0 0 0 8px rgb(34 197 94 / 0%); } 100% { box-shadow: 0 0 0 0 rgb(34 197 94 / 0%); } }

.spinner { width: 28px; height: 28px; margin: 24px auto; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.empty .icon { width: 32px; height: 32px; margin-bottom: 6px; }

/* Formulaires */
.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.field .label { font-weight: 600; font-size: .88rem; }
.field small { color: var(--muted); }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); min-height: 42px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible, .entry:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
select[multiple] { min-height: 120px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 200px; }
.row.align-end { align-items: flex-end; }
.row.align-end > .btn { flex: 0 0 auto; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 18px; height: 18px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.actions.stack { flex-direction: column; }
.form-error { color: var(--danger); min-height: 1.2em; margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { border: 1px solid var(--border); background: var(--surface-2); border-radius: 999px; padding: 4px 10px; font-size: .82rem; cursor: pointer; }
.chip:hover { border-color: var(--primary); color: var(--primary); }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.cat-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: .82rem; font-weight: 600;
}
.cat-btn .icon { width: 22px; height: 22px; }
.cat-btn.active { border-color: var(--primary); background: var(--info-bg); color: var(--info); }
.photo-picker { display: flex; flex-direction: column; gap: 8px; }
.photo-picker > .btn { align-self: flex-start; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumb { position: relative; margin: 0; width: 76px; height: 76px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.thumb-remove { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--danger); color: #fff; display: grid; place-items: center; cursor: pointer; padding: 0; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters > * { flex: 1 1 160px; }
.search { position: relative; flex: 2 1 220px; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 36px !important; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab { display: flex; align-items: center; gap: 6px; padding: 10px 14px; border: 0; border-bottom: 2px solid transparent; background: none; cursor: pointer; font-weight: 600; color: var(--muted); white-space: nowrap; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Modales et toasts */
.modal { border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgb(0 0 0 / 35%); }
.modal.wide { width: min(820px, calc(100vw - 24px)); }
.modal::backdrop { background: rgb(8 15 30 / 55%); }
.modal header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal header h2 { margin: 0; font-size: 1.05rem; }
.modal-body { padding: 16px; }
#toasts { position: fixed; right: 16px; top: calc(var(--topbar) + 12px); z-index: 100; display: flex; flex-direction: column; gap: 6px; width: min(400px, calc(100vw - 24px)); pointer-events: none; }
.toast:nth-last-child(n+4) { display: none; }
.modal .toasts { position: fixed; right: 16px; top: 16px; z-index: 1; display: flex; flex-direction: column; gap: 6px; width: min(400px, calc(100vw - 24px)); pointer-events: none; }
.toast { padding: 10px 14px; border-radius: 10px; font-size: .9rem; background: var(--text); color: var(--surface); box-shadow: var(--shadow); font-weight: 500; transition: opacity .3s, transform .3s; pointer-events: auto; }
.toast.success { background: var(--success); color: #fff; }
.toast.warn { background: #b45309; color: #fff; }
.toast.error { background: var(--danger); color: #fff; }
.toast.out { opacity: 0; transform: translateY(-8px); }

/* --- Connexion ----------------------------------------------------------------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, var(--brand) 0%, var(--brand-2) 100%); }
.login-card { width: min(400px, 100%); background: var(--surface); border-radius: 18px; padding: 28px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 24px 60px rgb(0 0 0 / 35%); }
.login-brand { text-align: center; }
.login-brand .icon { color: var(--primary); }
.login-brand h1 { margin: 6px 0 0; font-size: 1.8rem; }
.login-brand p { color: var(--muted); }

/* --- Accueil ------------------------------------------------------------------- */
.hero { display: flex; flex-direction: column; gap: 12px; }
.handover { background: var(--warn-bg); border-radius: 10px; padding: 12px; }
.handover-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--warn); }
.handover-head small { color: var(--muted); }
.shift-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
@keyframes blink { to { box-shadow: 0 0 0 3px var(--danger); } }
.actions-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.action { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 104px; padding: 12px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); cursor: pointer; font-weight: 600; }
.action .icon { width: 30px; height: 30px; color: var(--primary); }
.action.primary { background: var(--primary); color: #fff; border-color: transparent; }
.action.primary .icon { color: #fff; }
.action.warn .icon { color: #d97706; }
.resume { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; border-color: var(--primary); }
.resume > div { flex: 1; display: flex; flex-direction: column; }

/* --- Main courante ----------------------------------------------------------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.day-sep { font-weight: 700; text-transform: capitalize; color: var(--muted); font-size: .85rem; margin: 12px 0 0; }
.entry { display: flex; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border); border-radius: 10px; padding: 12px; cursor: pointer; }
.entry:hover { border-color: var(--primary); }
.entry.prio-haute { border-left-color: #f59e0b; }
.entry.prio-critique { border-left-color: var(--danger); background: linear-gradient(90deg, var(--danger-bg), var(--surface) 40%); }
.entry-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); flex: none; }
.cat-incident .entry-icon, .cat-alarme .entry-icon { color: var(--danger); background: var(--danger-bg); }
.cat-ronde .entry-icon { color: var(--info); background: var(--info-bg); }
.cat-alerte .entry-icon { color: #db2777; background: rgb(219 39 119 / 12%); }
.cat-prise_service .entry-icon, .cat-fin_service .entry-icon, .cat-passation .entry-icon { color: var(--success); background: var(--success-bg); }
.cat-rectificatif .entry-icon { color: var(--warn); background: var(--warn-bg); }
.entry-main { flex: 1; min-width: 0; }
.entry-main h3 { margin: 2px 0; font-size: .98rem; }
.entry-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); }
.entry-time { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.entry-seq { margin-left: auto; font-family: ui-monospace, monospace; }
.entry-body { color: var(--muted); margin: 0; white-space: pre-line; font-size: .9rem; }
.entry-foot { display: flex; gap: 12px; font-size: .78rem; color: var(--muted); margin-top: 4px; flex-wrap: wrap; }
.detail-head { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.detail-title { font-size: 1.15rem; }
.meta-grid { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 12px 0; }
.meta-grid dt { color: var(--muted); font-size: .85rem; }
.meta-grid dd { margin: 0; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin: 12px 0; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; }
.gps { display: inline-flex; align-items: center; gap: 4px; }

/* --- Rondes ------------------------------------------------------------------ */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.tour { display: flex; flex-direction: column; }
.tour .btn { margin-top: auto; }
.row-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; text-align: left; width: 100%; cursor: default; }
button.row-item { cursor: pointer; }
.row-item > div:first-child { min-width: 0; }
.row-end { display: flex; align-items: center; gap: 8px; }
.row-item.key.out { border-left: 4px solid #f59e0b; }

/* --- Incidents --------------------------------------------------------------- */
.incident { display: block; text-decoration: none; color: inherit; border-left: 4px solid var(--border); margin: 0; }
.incident.sev-elevee { border-left-color: #f59e0b; }
.incident.sev-critique { border-left-color: var(--danger); }
.incident-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.incident-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.timeline { list-style: none; padding: 0 0 0 16px; border-left: 2px solid var(--border); margin: 0 0 16px; }
.timeline li { position: relative; padding: 0 0 14px 8px; }
.timeline li::before { content: ""; position: absolute; left: -23px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--primary); border: 2px solid var(--surface); }

/* --- Consignes --------------------------------------------------------------- */
.consigne { border-left: 4px solid var(--border); margin: 0; }
.consigne.prio-haute { border-left-color: #f59e0b; }
.consigne.prio-critique { border-left-color: var(--danger); }
.consigne.acked { opacity: .8; }
.consigne-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.consigne-head h3 { margin: 0; }
.consigne-foot { display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; }
ul.plain { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }

/* --- Supervision ------------------------------------------------------------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.tile-value { font-size: 1.7rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.tile-label { color: var(--muted); font-size: .85rem; font-weight: 600; }
.tile small { color: var(--muted); }
.tile.danger { background: var(--danger-bg); border-color: transparent; }
.tile.danger .tile-value { color: var(--danger); }
.tile.warn .tile-value { color: var(--warn); }
.tile.ok .tile-value { color: var(--success); }
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.dash-grid .card { margin: 0; }
.span-2 { grid-column: span 2; }
.alert-item { display: flex; gap: 12px; padding: 12px; border-radius: 10px; background: var(--surface-2); align-items: flex-start; }
.alert-item.new { background: var(--danger-bg); animation: blink 1s infinite alternate; }
.alert-item > .icon { color: var(--danger); width: 24px; height: 24px; margin-top: 2px; }
.alert-item p { margin: 2px 0; }
.grow { flex: 1; min-width: 0; }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 32px; gap: 8px; align-items: center; font-size: .85rem; }
.bar { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.bar-n { text-align: right; font-weight: 700; }

/* --- Tableaux, rapports, QR ---------------------------------------------------- */
.table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: .9rem; }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--surface-2); }
.report { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.report-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-bottom: 2px solid var(--brand); padding-bottom: 12px; margin-bottom: 16px; }
.report-head h1 { font-size: 1.3rem; }
.report-head h2 { font-size: 1.05rem; color: var(--primary); }
.report-date { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.report-date strong { text-transform: capitalize; }
.report h3 { margin-top: 20px; padding-bottom: 4px; border-bottom: 1px solid var(--border); }
.report-tiles .tile { box-shadow: none; }
.report-foot { margin-top: 20px; padding: 10px; border-radius: 8px; font-size: .8rem; word-break: break-all; }
.report-foot.ok { background: var(--success-bg); color: var(--success); }
.report-foot.ko { background: var(--danger-bg); color: var(--danger); }
.signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 24px; }
.signatures div { border: 1px dashed var(--border); border-radius: 8px; height: 90px; padding: 8px; color: var(--muted); font-size: .85rem; }

/* --- Mobile ------------------------------------------------------------------ */
@media (max-width: 900px) {
  .menu-btn { display: inline-grid; }
  .user { display: none; }
  .sidenav { transform: translateX(-100%); transition: transform .2s; width: 270px; bottom: 0; z-index: 40; box-shadow: 0 0 40px rgb(0 0 0 / 30%); }
  .nav-open .sidenav { transform: none; }
  .nav-open .scrim { display: block; position: fixed; inset: 0; background: rgb(0 0 0 / 40%); z-index: 39; }
  main { margin-left: 0; padding: calc(var(--topbar) + 14px) 14px calc(var(--tabbar) + 100px); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; inset: auto 0 0 0; z-index: 30;
    height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--border);
  }
  .tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .7rem; color: var(--muted); text-decoration: none; background: none; border: 0; cursor: pointer; }
  .tabbar .icon { width: 22px; height: 22px; }
  .tabbar a.active { color: var(--primary); }
  #toasts { top: auto; right: 12px; left: 12px; width: auto; bottom: calc(var(--tabbar) + 12px + env(safe-area-inset-bottom)); flex-direction: column-reverse; }
  .dash-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .conn span { display: none; }
  .site-select, .site-name { max-width: 46vw; }
  .table { display: block; overflow-x: auto; }
  .modal { max-height: calc(100vh - 16px); }
  h1 { font-size: 1.3rem; }
}

/* --- Impression ---------------------------------------------------------------- */
@media print {
  .topbar, .sidenav, .tabbar, #toasts, .no-print, .scrim { display: none !important; }
  main { margin: 0; padding: 0; max-width: none; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .card, .report { box-shadow: none; border: 0; padding: 0; }
  .entry, .tile { break-inside: avoid; }
  .table th { background: #eee; color: #000; }
  .modal { position: static; box-shadow: none; width: 100%; max-height: none; }
  .modal header { display: none; }
}

/* --- Planning des rondes ---------------------------------------------------- */
.plan .plan-time { font-weight: 750; font-variant-numeric: tabular-nums; font-size: 1.05rem; min-width: 52px; }
.plan.plan-a_faire { border-color: var(--primary); box-shadow: 0 0 0 2px var(--info-bg); }
.plan.plan-manquee { border-left: 4px solid var(--danger); }
.plan.plan-anomalie { border-left: 4px solid #f59e0b; }
.plan.plan-effectuee { opacity: .85; }
.run-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-top: 8px; }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.day { position: relative; }
.day input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.day span { display: inline-grid; place-items: center; min-width: 48px; height: 40px; border-radius: 10px; border: 1px solid var(--border); font-weight: 600; background: var(--surface); }
.day input:checked + span { background: var(--primary); color: #fff; border-color: var(--primary); }
.day input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 1px; }
.fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 10px; margin: 0; }
.fieldset legend { font-weight: 700; padding: 0 6px; }
.warn-text { color: var(--warn); }

/* --- Carte des agents ------------------------------------------------------- */
.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 12px; }
.map { height: min(68vh, 640px); border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; background: var(--surface-2); z-index: 0; }
.map-side { margin: 0; max-height: min(68vh, 640px); overflow-y: auto; }
.map-side .row-item:disabled { opacity: .6; cursor: default; }
.map-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; }
.legend-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: -1px; }
.legend-dot.fresh, .dot.fresh { background: #16a34a; }
.legend-dot.aging, .dot.aging { background: #f59e0b; }
.legend-dot.stale, .dot.stale { background: #94a3b8; }
.legend-dot.site { background: var(--brand-2); border-radius: 3px; }
.legend-dot.incident { background: var(--danger); }
.mk-agent { display: grid !important; place-items: center; border-radius: 50%; color: #fff; font: 700 12px/1 system-ui, sans-serif; border: 3px solid #fff; box-shadow: 0 2px 6px rgb(0 0 0 / 35%); }
.mk-agent.fresh { background: #16a34a; }
.mk-agent.aging { background: #f59e0b; }
.mk-agent.stale { background: #94a3b8; }
.mk-agent.round { outline: 3px solid var(--primary); }
.mk-site { background: #1b3a66; border: 2px solid #fff; border-radius: 3px; box-shadow: 0 1px 4px rgb(0 0 0 / 35%); }
.mk-incident { display: grid !important; place-items: center; background: var(--danger); color: #fff; font-weight: 800; border-radius: 50%; border: 2px solid #fff; }
.mk-popup { display: flex; flex-direction: column; gap: 2px; min-width: 180px; }
.leaflet-container { font: inherit; }
@media (max-width: 900px) {
  .map-layout { grid-template-columns: 1fr; }
  .map { height: 55vh; }
  .map-side { max-height: none; }
}

/* Menu déroulant à sélection multiple (essais : agents en poste) */
.multi { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.multi-summary { cursor: pointer; padding: 10px 12px; }
.multi-list { border-top: 1px solid var(--border); max-height: 220px; overflow-y: auto; padding: 6px 12px; }
.multi-opt { display: flex; align-items: center; gap: 6px; padding: 8px 0; cursor: pointer; }

.error-text { color: var(--danger); font-weight: 600; }
