/* PILOT'SÉCURITÉS — interface sobre, angles droits, marine et doré. */
/* Fonte du livre de marque : Roboto (fichiers servis par l'application). */
@font-face { font-family: "Roboto"; font-style: normal; font-weight: 400; font-display: swap; src: url("/vendor/fonts/roboto-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Roboto"; font-style: normal; font-weight: 500; font-display: swap; src: url("/vendor/fonts/roboto-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Roboto"; font-style: normal; font-weight: 700; font-display: swap; src: url("/vendor/fonts/roboto-latin-700-normal.woff2") format("woff2"); }

/* Couleurs de l'administration : bleu France, rouge Marianne, gris. */
:root {
  --blue: #000091;
  --blue-hover: #1212FF;
  --blue-light: #ECECFE;
  --red: #E1000F;
  --accent-text: #000091;
  --focus: #0A76F6;
  --warn: #B34000;
  --sand: #F5F5FE;
  --bg: #F6F6F6;
  --surface: #FFFFFF;
  --text: #161616;
  --muted: #666666;
  --line: #DDDDDD;
  --line-soft: #EEEEEE;
  --danger: #CE0500;
  --ok: #18753C;
  --check-bg: #FFE9E6;
  --primary-bg: #000091;
  --primary-fg: #FFFFFF;
  --bar: #000091;
  --tab-h: 64px;
  --font: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --blue: #8585F6;
    --blue-hover: #A1A1F8;
    --blue-light: #1B1B35;
    --red: #F95C5E;
    --accent-text: #8585F6;
    --focus: #8585F6;
    --warn: #FC5D00;
    --sand: #1B1B35;
    --bg: #161616;
    --surface: #1E1E1E;
    --text: #CECECE;
    --muted: #929292;
    --line: #353535;
    --line-soft: #2A2A2A;
    --danger: #FF5655;
    --ok: #27A658;
    --check-bg: #2D1814;
    --primary-bg: #8585F6;
    --primary-fg: #000091;
    --bar: #8585F6;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
[hidden] { display: none !important; }

.ico { display: inline-flex; flex-shrink: 0; }

/* ---------- Boutons : angles droits, pas de gras ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 0;
  background: var(--surface); color: var(--text);
  font-weight: 500; font-size: 15px; text-decoration: none; cursor: pointer;
}
.btn:active { background: var(--sand); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--primary-bg); border-color: var(--primary-bg); color: var(--primary-fg); }
.btn.primary:active { background: var(--blue-hover); border-color: var(--blue-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-ghost { color: var(--danger); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.icon-btn { width: 40px; height: 40px; border: 1px solid var(--line); background: var(--surface); display: inline-flex; align-items: center; justify-content: center; border-radius: 0; }
.linklike { background: none; border: 0; padding: 0; color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px; font-size: 14px; cursor: pointer; }

/* ---------- Verrouillage ---------- */
.lock-screen {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  background: var(--blue);
}
.lock-card {
  width: 100%; max-width: 380px; background: var(--surface); padding: 28px 22px;
  border-top: 4px solid var(--blue); display: flex; flex-direction: column; gap: 14px;
}
.lock-brand { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 6px; }
.lock-brand img { display: block; }
.lock-brand h1 { font-size: 22px; letter-spacing: .04em; color: var(--text); }
.lock-brand p { color: var(--muted); font-size: 14px; }
.lock-intro { color: var(--muted); font-size: 14.5px; }
.lock-form { display: flex; flex-direction: column; gap: 10px; }
.code-input {
  width: 100%; height: 52px; border: 1px solid var(--line); border-radius: 0; background: var(--surface);
  text-align: center; font-size: 22px; letter-spacing: .3em; padding: 0 12px;
}
.code-input:focus { outline: 2px solid var(--focus); outline-offset: -1px; }
.code-input::placeholder { letter-spacing: normal; font-size: 16px; color: var(--muted); }
.lock-msg { color: var(--danger); font-size: 14px; min-height: 1em; text-align: center; }
.lock-msg:empty { display: none; }
.lock-note { font-size: 13px; color: var(--muted); text-align: center; }
.lock-sep { height: 1px; background: var(--line-soft); margin: 4px 0; }
.lock-icon { display: flex; justify-content: center; color: var(--blue); }
.lock-card h2 { text-align: center; font-size: 19px; }

/* ---------- Coquille ---------- */
.app { min-height: 100dvh; }
main {
  max-width: 720px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 18px) 16px calc(var(--tab-h) + env(safe-area-inset-bottom) + 28px);
  display: flex; flex-direction: column; gap: 18px; outline: none;
}
.demo-banner {
  position: sticky; top: 0; z-index: 20; background: var(--blue-light); color: var(--accent-text);
  padding: calc(env(safe-area-inset-top) + 6px) 16px 6px; font-size: 13px;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.demo-banner .linklike { color: var(--accent-text); }
.demo-banner + main { padding-top: 16px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--muted); font-size: 11px;
}
.tab.active { color: var(--accent-text); box-shadow: inset 0 2px 0 var(--blue); }
.tab-primary { color: var(--primary-fg); background: var(--primary-bg); }
.tab-primary.active { color: var(--primary-fg); box-shadow: inset 0 3px 0 var(--red); }

.page-head { display: flex; flex-direction: column; gap: 4px; }
.page-head h1 { font-size: 26px; line-height: 1.15; }
.page-head h1.numero { font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--accent-text); font-weight: 500; }
.eyebrow::first-letter { text-transform: uppercase; }
.lead { color: var(--muted); font-size: 16px; }
.intro { color: var(--muted); font-size: 15px; }
.back {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 4px;
  background: none; border: 0; padding: 4px 0; color: var(--accent-text); font-size: 15px; cursor: pointer; margin-bottom: 4px;
}

.block { display: flex; flex-direction: column; gap: 10px; }
.block > h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 500; }
.block-head { display: flex; justify-content: space-between; align-items: baseline; }
.block-head h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 500; }
.panel { background: var(--surface); border: 1px solid var(--line); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.empty { color: var(--muted); padding: 18px 0; text-align: center; font-size: 15px; }
.notice {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px;
  background: var(--check-bg); border: 1px solid var(--line); color: var(--text); font-size: 14.5px; text-decoration: none;
}
.notice .ico { color: var(--warn); margin-top: 1px; }

/* Accueil */
.quick { display: flex; flex-direction: column; gap: 8px; }
.quick-main {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 72px; padding: 0 20px;
  background: var(--primary-bg); color: var(--primary-fg); border: 0; border-radius: 0;
  font-size: 18px; font-weight: 500; text-align: left; cursor: pointer; border-left: 4px solid var(--red);
}
.quick-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kpis.four { grid-template-columns: repeat(2, 1fr); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-top: 2px solid var(--blue); padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.kpi strong { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi span { font-size: 12.5px; color: var(--muted); line-height: 1.25; }

/* Listes */
.rows { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); }
.row {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; text-decoration: none;
  border-bottom: 1px solid var(--line-soft);
}
.row:last-child { border-bottom: 0; }
.row:active { background: var(--sand); }
.row.muted { opacity: .6; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-top { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.num { font-weight: 600; font-variant-numeric: tabular-nums; font-size: 14.5px; }
.row-title { font-size: 15px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.row-sub { font-size: 13px; color: var(--muted); }
.row > .ico { color: var(--muted); }
.tag { font-size: 11.5px; padding: 1px 6px; border: 1px solid var(--line); color: var(--muted); letter-spacing: .02em; }
.tag.urgent { border-color: var(--danger); color: var(--danger); }

.searchbar { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); padding: 0 12px; }
.searchbar input { flex: 1; border: 0; background: transparent; height: 46px; outline: none; font-size: 16px; }
.searchbar .ico { color: var(--muted); }
.filters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.filter { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.filter select { height: 40px; border: 1px solid var(--line); border-radius: 0; background: var(--surface); padding: 0 8px; font-size: 14px; -webkit-appearance: none; appearance: none; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; height: 34px; padding: 0 12px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip.on { background: var(--primary-bg); color: var(--primary-fg); border-color: var(--primary-bg); }
.list-head { display: flex; justify-content: space-between; align-items: center; }
.count { font-size: 14px; color: var(--muted); }

/* Choix de saisie */
.choices { display: flex; flex-direction: column; gap: 8px; }
.choice {
  display: flex; gap: 14px; align-items: flex-start; text-align: left; padding: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 0; cursor: pointer;
}
.choice.primary { border-left: 4px solid var(--blue); }
.choice .ico { color: var(--blue); margin-top: 2px; }
.choice-text { display: flex; flex-direction: column; gap: 3px; }
.choice-text strong { font-weight: 600; font-size: 16px; }
.choice-text span { color: var(--muted); font-size: 14px; }

/* Formulaires */
.fields { display: flex; flex-direction: column; gap: 14px; background: var(--surface); border: 1px solid var(--line); padding: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.inline { flex-direction: row; justify-content: space-between; align-items: center; }
.field-label { font-size: 13.5px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.field-hint { font-size: 12.5px; color: var(--muted); }
.field input[type=text], .field input[type=date], .field input[type=datetime-local], .field input[type=number],
.field textarea, .field select, .stack input, .modal input, textarea.paste, .field-sub input {
  width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 0; background: var(--surface);
  padding: 10px 12px; font-size: 16px; -webkit-appearance: none; appearance: none;
}
.field textarea, textarea.paste { resize: vertical; line-height: 1.4; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--focus); outline-offset: -1px; }
.field.to-check { background: var(--check-bg); margin: -6px; padding: 6px; border-left: 3px solid var(--warn); }
.flag { font-size: 11px; padding: 1px 6px; letter-spacing: .02em; }
.flag.check { background: var(--warn); color: #FFFFFF; }
.flag.ok { border: 1px solid var(--line); color: var(--muted); }
.field-sub { margin-top: 8px; }
.form-msg { color: var(--danger); font-size: 14px; }
.form-msg:empty { display: none; }
.stack { display: flex; flex-direction: column; gap: 10px; }

.switch { -webkit-appearance: none; appearance: none; width: 50px; height: 30px; border: 1px solid var(--line); background: var(--bg); position: relative; cursor: pointer; border-radius: 0; flex-shrink: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; background: var(--muted); transition: transform .15s; }
.switch:checked { background: var(--primary-bg); border-color: var(--primary-bg); }
.switch:checked::after { transform: translateX(20px); background: var(--primary-fg); }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg-btn { min-height: 40px; padding: 0 12px; border: 1px solid var(--line); background: var(--surface); border-radius: 0; font-size: 14.5px; cursor: pointer; }
.seg-btn.on { background: var(--primary-bg); color: var(--primary-fg); border-color: var(--primary-bg); }

.pieces { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.piece { display: grid; grid-template-columns: 72px 1fr 40px; gap: 6px; width: 100%; }
.piece input, .piece select { min-height: 40px; border: 1px solid var(--line); border-radius: 0; background: var(--surface); padding: 0 8px; font-size: 16px; -webkit-appearance: none; appearance: none; }

.photo-preview { background: var(--surface); border: 1px solid var(--line); padding: 10px 12px; }
.photo-preview summary { cursor: pointer; font-size: 14px; color: var(--muted); }
.photo-preview img { display: block; width: 100%; max-height: 60vh; object-fit: contain; margin: 10px 0 6px; background: #000; }

.progress { height: 6px; background: var(--line-soft); }
.progress-fill { height: 100%; width: 0; background: var(--blue); transition: width .2s; }
.progress-label { font-size: 14px; color: var(--muted); }

/* Fiche */
.facts { margin: 0; background: var(--surface); border: 1px solid var(--line); }
.fact { display: grid; grid-template-columns: 42% 1fr; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line-soft); }
.fact:last-child { border-bottom: 0; }
.fact dt { color: var(--muted); font-size: 14px; }
.fact dd { margin: 0; font-size: 15px; word-break: break-word; }
.timeline { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); }
.timeline li { padding: 12px 14px 12px 18px; border-bottom: 1px solid var(--line-soft); position: relative; display: flex; flex-direction: column; gap: 3px; }
.timeline li::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--line); }
.timeline li:first-child::before { background: var(--blue); }
.timeline li:last-child { border-bottom: 0; }
.tl-head { display: flex; justify-content: space-between; gap: 8px; }
.tl-head span { font-size: 13px; color: var(--muted); }
.history { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); }
.history li { padding: 10px 14px; border-bottom: 1px solid var(--line-soft); display: flex; flex-direction: column; gap: 4px; }
.history li:last-child { border-bottom: 0; }
.diff { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 14px; }
.diff-f { color: var(--muted); min-width: 110px; }
.diff-a { text-decoration: line-through; color: var(--muted); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions .btn.primary { grid-column: 1 / -1; }

/* Analyses */
.chart { width: 100%; height: auto; background: var(--surface); border: 1px solid var(--line); }
.chart .grid { stroke: var(--line-soft); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 9px; font-family: var(--font); }
.chart .val { fill: var(--text); font-size: 9px; font-family: var(--font); }
.chart .bar { fill: var(--bar); }
.chart .bar.current { fill: var(--red); }
.hbars { display: flex; flex-direction: column; gap: 8px; background: var(--surface); border: 1px solid var(--line); padding: 14px; }
.hbar { display: grid; grid-template-columns: 120px 1fr 34px; gap: 10px; align-items: center; font-size: 14px; }
.hbar-l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 12px; background: var(--line-soft); }
.hbar-fill { display: block; height: 100%; background: var(--bar); }
.hbar-v { text-align: right; font-variant-numeric: tabular-nums; }

/* Réglages */
.settings { background: var(--surface); border: 1px solid var(--line); }
.set-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line-soft); }
.set-row:last-child { border-bottom: 0; }
.set-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.set-text small { color: var(--muted); font-size: 13px; }
.set-row select { height: 36px; border: 1px solid var(--line); border-radius: 0; background: var(--surface); padding: 0 8px; font-size: 14px; }
.journal { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); }
.journal li { padding: 10px 14px; border-bottom: 1px solid var(--line-soft); display: flex; flex-direction: column; gap: 2px; }
.j-when { font-size: 12.5px; color: var(--muted); }
.about { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 18px 0 6px; color: var(--muted); font-size: 13px; text-align: center; }
.about .colombo img { display: block; height: 28px; width: auto; }
@media (prefers-color-scheme: dark) { .about .colombo { background: #fff; padding: 6px 10px; } }

/* Doublons */
.dup-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.dup { display: flex; gap: 10px; padding: 10px; border: 1px solid var(--line); align-items: flex-start; }
.dup span { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.dup input { margin-top: 3px; accent-color: var(--blue); }

/* Modale, message, mise à jour */
.modal-wrap { position: fixed; inset: 0; z-index: 50; background: rgba(5, 15, 25, .55); display: flex; align-items: flex-end; justify-content: center; }
.modal {
  width: 100%; max-width: 520px; background: var(--surface); border-top: 4px solid var(--blue);
  padding: 20px 16px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px;
  max-height: 90dvh; overflow: auto;
}
@media (min-width: 600px) { .modal-wrap { align-items: center; } }
.modal-title { font-size: 18px; }
.modal-body { display: flex; flex-direction: column; gap: 10px; color: var(--text); font-size: 15px; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 12px);
  z-index: 60; background: #161616; color: #fff; padding: 12px 14px; font-size: 14.5px;
  border-left: 4px solid #8585F6; opacity: 0; transform: translateY(8px); transition: all .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }
.toast.error { border-left-color: #FF5655; }
.toast.ok { border-left-color: #27A658; }
.lock-screen ~ .toast, body > .toast { max-width: 520px; margin: 0 auto; }
.update-bar {
  position: fixed; left: 0; right: 0; top: 0; z-index: 70; background: var(--blue-light); color: var(--accent-text);
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px; display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 14px;
}
.view-inner { display: flex; flex-direction: column; gap: 18px; }
