:root {
  --rl-nav-h: 72px;
  --blue: #0b3a6e;
  --blue-2: #0e4d92;
  --green: #16a34a;
  --ink: #122033;
  --muted: #5c6b80;
  --line: #d7e0ea;
  --bg: #eef3f8;
  --card: #ffffff;
  --danger: #b91c1c;
  --warn: #c2410c;
  --radius: 16px;
  color-scheme: light;
  font-family: "Segoe UI", "Avenir Next", "Trebuchet MS", sans-serif;
}
html.dark {
  --ink: #e7eef6;
  --muted: #b7c3d4;
  --line: #2a3b52;
  --bg: #0d1724;
  --card: #152536;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: var(--text-size, 16px);
  line-height: 1.45;
}
a { color: var(--blue-2); }
.topbar {
  background: linear-gradient(135deg, var(--blue), var(--blue-2));
  color: white;
  padding: 14px 16px 18px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { margin: 0; font-size: 1.25rem; letter-spacing: 0.01em; }
.topbar p { margin: 4px 0 0; opacity: 0.85; font-size: 0.9rem; }
.tools { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.tools button, .ghost {
  background: rgba(255,255,255,0.14);
  color: white;
  border: 0;
  border-radius: 999px;
  min-height: 36px;
  padding: 0 12px;
}
.wrap { width: min(860px, 100%); margin: 0 auto; padding: 16px 16px calc(108px + env(safe-area-inset-bottom)); }
.rl-interface-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(238, 243, 248, 0.2), rgba(238, 243, 248, 0.96) 24%, #eef3f8 40%);
  border-top: 2px solid var(--blue);
  box-shadow: 0 -8px 24px rgba(11, 58, 110, 0.12);
}
html.dark .rl-interface-footer {
  background: linear-gradient(180deg, rgba(13, 23, 36, 0.2), rgba(13, 23, 36, 0.96) 24%, #0d1724 40%);
}
.rl-interface-footer__form {
  width: min(860px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
}
.rl-interface-footer__label {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--blue);
  white-space: nowrap;
}
.rl-interface-footer__select {
  min-height: 48px;
  font-size: 1rem;
  font-weight: 600;
  border: 2px solid var(--blue);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  padding: 0 14px;
}
@media (min-width: 900px) {
  body.desk .rl-interface-footer {
    left: 212px;
  }
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 8px 24px rgba(11, 58, 110, 0.05);
}
.card h2, .card h3 { margin: 0 0 8px; }
.muted { color: var(--muted); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grid { display: grid; gap: 10px; }
label { display: grid; gap: 6px; font-weight: 600; font-size: 0.92rem; }
input, select, textarea {
  width: 100%;
  min-height: 48px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  padding: 10px 12px;
  font: inherit;
}
textarea { min-height: 96px; }
button, .btn {
  appearance: none;
  border: 0;
  background: var(--button-bg, var(--green));
  color: var(--button-text, white);
  min-height: 48px;
  padding: 0 16px;
  border-radius: 12px;
  font: inherit;
  font-weight: 700;
  font-size: var(--button-size, 1rem);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.btn.blue { background: var(--blue); color: white; }
.btn.quiet { background: transparent; color: var(--blue-2); border: 1px solid var(--line); }
.btn.danger { background: var(--danger); color: white; }
.btn.full { width: 100%; }
.pills { display: flex; gap: 8px; flex-wrap: wrap; padding-bottom: 4px; }
.pill {
  border-radius: 999px;
  padding: 8px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
}
.pill.on { background: var(--blue); color: white; border-color: var(--blue); }
.badge { border-radius: 999px; padding: 2px 8px; font-size: 0.78rem; background: #e8eef6; color: var(--blue); }
html.dark .badge { background: #24364c; }
.sev-critique { border-left: 6px solid #b91c1c; }
.sev-urgente { border-left: 6px solid #c2410c; }
.sev-normale { border-left: 6px solid #0e4d92; }
.sev-basse { border-left: 6px solid #64748b; }
.sev-previsionnelle { border-left: 6px solid #0f766e; }
.dest-fournisseur { background: #e5e7eb; color: #111; }
html.dark .dest-fournisseur { background: #3f4b5b; color: white; }
.blink { animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.45; } }
.alert { padding: 12px 14px; border-radius: 12px; margin-bottom: 12px; }
.alert.ok { background: #dcfce7; color: #14532d; }
.alert.err { background: #fee2e2; color: #7f1d1d; }
.nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  background: var(--card); border-top: 1px solid var(--line);
  z-index: 30;
}
.nav a, .nav summary {
  min-width: 0;
  text-align: center; text-decoration: none; color: var(--muted);
  padding: 8px 2px 10px; font-size: 0.68rem; font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav .ico { display: block; font-size: 1.15rem; line-height: 1.2; color: var(--blue); }
.nav summary { list-style: none; cursor: pointer; }
.nav summary::-webkit-details-marker { display: none; }
.more { position: relative; }
.more-panel {
  position: absolute; right: 6px; bottom: 62px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 12px 32px rgba(11, 58, 110, 0.16);
  min-width: 180px; padding: 6px; display: grid; z-index: 40;
}
.more-panel a {
  text-align: left; white-space: normal; padding: 12px; font-size: 1rem;
  border-radius: 10px; color: var(--ink);
}
.statgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--card); border-radius: 14px; padding: 12px; border: 1px solid var(--line); }
.stat b { display: block; font-size: 1.4rem; color: var(--blue); }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
body.guest {
  min-height: 100vh;
  background:
    radial-gradient(700px 320px at 85% 0%, rgba(22, 163, 74, 0.45), transparent 60%),
    linear-gradient(155deg, #0b3a6e 0%, #0e4d92 48%, #0f3d2e 100%);
}
body.guest .topbar { background: transparent; }
body.guest .wrap { width: min(1080px, 100%); padding-bottom: 32px; }
.login-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 36px;
  align-items: center;
  min-height: calc(100vh - 140px);
}
.login-hero { color: #fff; }
.login-hero .eyebrow { letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.78rem; opacity: 0.85; margin: 0 0 8px; }
.login-hero h2 { font-size: clamp(1.8rem, 3vw, 2.6rem); line-height: 1.15; margin: 0 0 12px; }
.login-hero p { font-size: 1.05rem; max-width: 36rem; }
.login-hero ul { padding-left: 1.1rem; }
.login-hero li { margin: 6px 0; }
.auth-card { width: 420px; max-width: 100%; margin: 0; }
@media (max-width: 800px) {
  .login-shell { grid-template-columns: 1fr; min-height: 0; }
  .auth-card { width: 100%; }
}
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.bell { position: relative; }
.bell summary {
  list-style: none;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.16);
  color: white;
  border-radius: 999px;
  min-height: 40px;
  padding: 8px 14px;
  font-weight: 700;
}
.bell summary::-webkit-details-marker { display: none; }
#alert-count {
  display: inline-block;
  background: #b91c1c;
  color: white;
  border-radius: 999px;
  min-width: 1.3rem;
  padding: 0 6px;
  margin-left: 6px;
  font-size: 0.8rem;
  text-align: center;
}
.topbar:has(#alert-bell[open]) { z-index: 60; overflow: visible; }
.alert-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: transparent;
}
.alert-backdrop[hidden] { display: none !important; }
.alert-pop {
  position: fixed;
  z-index: 80;
  left: 0;
  right: 0;
  top: calc(4.6rem + env(safe-area-inset-top, 0px));
  bottom: auto;
  width: auto;
  max-height: min(78vh, calc(100dvh - 4.6rem - var(--rl-nav-h, 72px) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 8px));
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 12px 32px rgba(11, 58, 110, 0.18);
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.alert-pop[hidden] { display: none !important; }
.alert-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}
.alert-head strong { color: var(--blue); }
.alert-head button {
  background: transparent;
  color: var(--blue);
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  text-align: right;
  cursor: pointer;
}
.alert-scroll {
  flex: 1 1 auto;
  min-height: 0;
  max-height: min(62vh, calc(100dvh - 9rem - var(--rl-nav-h, 72px) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 4px 8px;
}
.alert-scroll a {
  display: grid;
  gap: 2px;
  padding: 10px 8px;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  overflow-wrap: anywhere;
}
.alert-scroll a:hover { background: #e8eef6; }
.alert-scroll a span { font-weight: 500; color: var(--muted); }
.alert-all {
  flex: 0 0 auto;
  display: block;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  background: var(--card);
}
html.alert-lock, html.alert-lock body { overflow: hidden; }
@media (min-width: 900px) {
  :root { --rl-nav-h: 0px; }
  .alert-pop {
    top: 76px;
    right: 16px;
    left: auto;
    width: min(420px, calc(100vw - 32px));
    max-height: min(70vh, calc(100dvh - 96px));
    border-radius: 16px;
  }
}
.ping {
  display: inline-block;
  min-width: 1.1rem;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 999px;
  background: #b91c1c;
  color: white;
  font-style: normal;
  font-size: 0.7rem;
  line-height: 1.35;
  vertical-align: super;
}
.badge.ok { background: #dcfce7; color: #14532d; }
.badge.warn { background: #ffedd5; color: #9a3412; }
.stop-docs { margin: 8px 0 16px; padding: 10px 0 4px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.doc-zoom { overflow: auto; max-height: 70vh; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.doc-zoom img, .doc-zoom iframe { display: block; width: 100%; transform-origin: top left; background: #fff; }
.doc-zoom iframe { height: 70vh; border: 0; }
.sign-preview { width: min(280px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.sign-pad {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: #fff;
  color: #122033;
  display: flex;
  flex-direction: column;
}
.sign-pad[hidden] { display: none !important; }
.sign-draw { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.sign-draw[hidden], .sign-name[hidden] { display: none !important; }
.sign-lead { margin: 0; padding: 12px 16px 0; font-weight: 700; }
.sign-pad canvas {
  flex: 1;
  width: 100%;
  min-height: 180px;
  touch-action: none;
  background: #fff;
}
.sign-tools, .sign-name {
  display: flex;
  gap: 8px;
  padding: 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}
.sign-tools { align-items: center; }
.sign-msg { margin: 0; color: #9a3412; font-weight: 700; }
.sign-name { flex-direction: column; }
.sign-name h2 { margin: 8px 0 0; }
@media (orientation: landscape) and (max-height: 500px) {
  .sign-draw { flex-direction: row; }
  .sign-tools { flex-direction: column; width: 148px; justify-content: center; }
  .sign-pad canvas { min-height: 0; }
}
.chat-log { display: grid; gap: 8px; max-height: 52vh; overflow: auto; }
.bubble { background: #e8eef6; border-radius: 14px; padding: 10px 12px; }
.bubble.mine { background: #dcfce7; margin-left: 12%; }
.bubble:not(.mine) { margin-right: 12%; }
@media (min-width: 900px) {
  .wrap { padding-bottom: 40px; }
  .nav { position: sticky; top: 72px; bottom: auto; display: flex; flex-direction: column; width: 180px; height: calc(100vh - 88px); border: 1px solid var(--line); border-radius: 16px; margin: 16px; overflow: visible; }
  body.desk { display: grid; grid-template-columns: 212px 1fr; }
  body.desk .topbar, body.desk main.wrap { grid-column: 2; }
  body.desk .topbar { grid-column: 1 / -1; }
  body.desk .nav a, body.desk .nav summary { text-align: left; white-space: normal; padding: 12px 14px; font-size: 0.95rem; }
  body.desk .nav .ico { display: inline; margin-right: 8px; }
  body.desk .more-panel { position: static; box-shadow: none; border: 0; padding: 0; min-width: 0; }
}
.vehicle-inventory-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 12px;
}
.vehicle-inventory-toolbar .grow { flex: 1 1 200px; }
.driver-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 640px) {
  .driver-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1024px) and (orientation: landscape) {
  .driver-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.driver-card { position: relative; padding-top: 8px; }
.driver-status {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  color: #fff;
}
.driver-status.is-online { background: #16a34a; }
.driver-status.is-offline { background: #64748b; }
.driver-card-body {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding-top: 8px;
}
.driver-avatar-wrap { flex-shrink: 0; }
.driver-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--line);
}
.driver-avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 700;
  background: var(--button-bg);
  color: var(--button-text);
}
.driver-meta h2 { margin: 0 0 4px; font-size: 1.1rem; }
.driver-tractor { margin: 8px 0 0; font-size: 0.9rem; }
.driver-tractor div { display: grid; grid-template-columns: auto 1fr; gap: 4px 8px; margin: 2px 0; }
.driver-tractor dt { font-weight: 700; color: var(--muted, #64748b); }
.driver-tractor dd { margin: 0; }
.tag-warn { color: #b45309; font-weight: 700; font-size: 0.85rem; margin: 0 0 4px; }
.driver-register-card { max-height: none; }
.small { font-size: 0.85rem; }
