/* ==========================================================================
   Suivi des accidents — Patrick Location
   Mise en page : en-tête blanc avec le logo et le double filet bleu du logo
   (bleu Patrick / bleu Location), contenu sur fond bleu-gris très clair.
   ========================================================================== */

@font-face { font-family: "Barlow"; font-weight: 400; font-style: normal; font-display: swap; src: url("fonts/barlow-400.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-style: normal; font-display: swap; src: url("fonts/barlow-500.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-style: normal; font-display: swap; src: url("fonts/barlow-600.woff2") format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 600; font-style: normal; font-display: swap; src: url("fonts/barlow-sc-600.woff2") format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 700; font-style: normal; font-display: swap; src: url("fonts/barlow-sc-700.woff2") format("woff2"); }

:root {
  /* Couleurs de la marque (logo) */
  --brand: #256fba;          /* « Patrick » */
  --brand-hover: #1d5c9c;
  --brand-light: #a9c5ec;    /* « Location » */
  --brand-soft: #e8f0fb;
  --on-brand: #ffffff;
  /* Neutres (légèrement bleutés) */
  --bg: #f2f5f9;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --border: #dde4ed;
  --border-strong: #c2cddb;
  --text: #15233a;
  --muted: #5d6b80;
  --label: #34445c;
  --input-border: #c9d3e0;
  --hover-row: #f4f8fd;
  /* Couleurs d'état */
  --danger: #c0392b; --danger-hover: #a5301f; --danger-soft: #fbeceb;
  --ok: #157f3b;   --ok-soft: #e4f3e9;
  --warn: #935700; --warn-soft: #fdf2df;
  --info: var(--brand); --info-soft: var(--brand-soft);
  --grey-soft: #edf1f6;
  --focus: #256fba;
  --focus-ring: rgba(37,111,186,.2);
  /* Divers */
  --savebar: rgba(255,255,255,.95);
  --toast-bg: #15233a; --toast-fg: #ffffff;
  --backdrop: rgba(15,30,55,.45);
  --shadow: 0 1px 2px rgba(21,35,58,.05), 0 2px 6px rgba(21,35,58,.06);
  --logo-light: block; --logo-dark: none;
  --radius: 10px;
  /* Typographie */
  --font-ui: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Barlow Semi Condensed", "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #6aa6e6; --brand-hover: #86b8ee; --brand-light: #3f6390; --brand-soft: #1a2d46; --on-brand: #0d1826;
    --bg: #0e1520; --surface: #151f2c; --surface-2: #1a2635; --border: #283648; --border-strong: #3a4b61;
    --text: #e5ebf3; --muted: #93a2b7; --label: #c3cedc; --input-border: #36465b; --hover-row: #1b2839;
    --danger: #ec6a5c; --danger-hover: #f2867a; --danger-soft: #3a2024;
    --ok: #5cc98a; --ok-soft: #173126; --warn: #e5a54b; --warn-soft: #362a16;
    --grey-soft: #1f2b3a; --focus: #6aa6e6; --focus-ring: rgba(106,166,230,.25);
    --savebar: rgba(21,31,44,.95); --toast-bg: #e5ebf3; --toast-fg: #0e1520; --backdrop: rgba(0,0,0,.6);
    --shadow: 0 1px 2px rgba(0,0,0,.35);
    --logo-light: none; --logo-dark: block;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --brand: #6aa6e6; --brand-hover: #86b8ee; --brand-light: #3f6390; --brand-soft: #1a2d46; --on-brand: #0d1826;
  --bg: #0e1520; --surface: #151f2c; --surface-2: #1a2635; --border: #283648; --border-strong: #3a4b61;
  --text: #e5ebf3; --muted: #93a2b7; --label: #c3cedc; --input-border: #36465b; --hover-row: #1b2839;
  --danger: #ec6a5c; --danger-hover: #f2867a; --danger-soft: #3a2024;
  --ok: #5cc98a; --ok-soft: #173126; --warn: #e5a54b; --warn-soft: #362a16;
  --grey-soft: #1f2b3a; --focus: #6aa6e6; --focus-ring: rgba(106,166,230,.25);
  --savebar: rgba(21,31,44,.95); --toast-bg: #e5ebf3; --toast-fg: #0e1520; --backdrop: rgba(0,0,0,.6);
  --shadow: 0 1px 2px rgba(0,0,0,.35);
  --logo-light: none; --logo-dark: block;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-ui); font-size: 15.5px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--font-display); text-wrap: balance; }
h1 { font-size: 1.8rem; font-weight: 700; margin: 0; letter-spacing: .005em; line-height: 1.15; }
h2 { font-size: 1.15rem; font-weight: 700; margin: 0 0 .75rem; letter-spacing: .01em; }
h3 { font-size: 1rem; font-weight: 600; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; }
.eyebrow { font-family: var(--font-display); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }

/* Logos (clair / sombre) */
.logo { display: var(--logo-light); height: 100%; width: auto; }
.logo.dark { display: var(--logo-dark); }

/* ---------------------------------------------------------------- En-tête */
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; display: flex; align-items: center; gap: 1.25rem;
  padding-block: .55rem; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: var(--surface); }
/* Double filet aux deux bleus du logo */
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 4px;
  background: linear-gradient(90deg, var(--brand) 0 62%, var(--brand-light) 62% 100%); }
.brand { display: flex; align-items: center; gap: .85rem; text-decoration: none; color: var(--text); flex: none; }
.brand-logo { height: 40px; display: block; }
.brand-text { font-family: var(--font-display); font-weight: 600; font-size: .82rem; text-transform: uppercase; letter-spacing: .14em;
  color: var(--muted); padding-left: .85rem; border-left: 1px solid var(--border); line-height: 1.2; }
.nav { display: flex; gap: .2rem; }
.nav a { text-decoration: none; padding: .45rem .8rem; border-radius: 8px; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--grey-soft); color: var(--text); }
.nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; gap: .5rem; align-items: center; }
.user-chip { border: 1px solid var(--border); background: var(--surface-2); border-radius: 999px; padding: .4rem .85rem;
  font: inherit; font-size: .88rem; cursor: pointer; color: var(--text); white-space: nowrap; }
.user-chip:hover { border-color: var(--border-strong); }

.container { max-width: 1200px; margin: 0 auto; padding-block: 1.75rem 1.5rem;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.page-head { display: flex; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.page-head .actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------------------------------------------------------------- Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); border-radius: 8px; padding: .5rem .95rem; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap; min-height: 40px; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: var(--danger-hover); }
.btn-sm { padding: .3rem .65rem; min-height: 32px; font-size: .86rem; }
.btn:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------------------------------------------------------------- Cartes et tableau de bord */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.15rem; }
.grid { display: grid; gap: 1rem; }
.kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 1rem; }
.kpi { text-decoration: none; display: block; position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--brand-light); }
.kpi .label { font-family: var(--font-display); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.kpi .value { font-family: var(--font-display); font-size: 2.4rem; font-weight: 700; line-height: 1.05; margin-top: .3rem; font-variant-numeric: tabular-nums; color: var(--text); }
.kpi .sub { color: var(--muted); font-size: .86rem; margin-top: .15rem; }
.kpi.alert::before { background: var(--danger); }
.kpi.alert .value { color: var(--danger); }
a.kpi:hover { border-color: var(--border-strong); }
.two-cols { grid-template-columns: 1fr 1fr; }

/* Badges de statut */
.badge { display: inline-block; padding: .16rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap;
  background: var(--grey-soft); color: var(--label); vertical-align: middle; font-family: var(--font-ui); letter-spacing: 0; }
.b-ouvert { background: var(--danger-soft); color: var(--danger); }
.b-encours { background: var(--brand-soft); color: var(--brand); }
.b-attente { background: var(--warn-soft); color: var(--warn); }
.b-clos { background: var(--ok-soft); color: var(--ok); }
.b-cont { background: var(--text); color: var(--surface); }
.alert-band { border: 1px solid var(--danger); background: var(--danger-soft); color: var(--text); border-radius: var(--radius); padding: .7rem .9rem; margin-bottom: 1rem; }
.alert-band strong { color: var(--danger); }
.card-alert { border-color: var(--danger); box-shadow: inset 3px 0 0 var(--danger), var(--shadow); }
.kpi-dark::before { background: var(--text); }
.simple-list li .btn { flex: none; }
.field.wide2 { grid-column: span 2; }
.hist { border: 1px solid var(--border-strong); background: var(--surface); border-radius: var(--radius); padding: .6rem .9rem; margin-bottom: .6rem; }
.hist a { color: var(--brand); font-weight: 600; }
.hist-warn { border-color: var(--warn); background: var(--warn-soft); }
.lock-band { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between; border: 1px solid var(--brand); background: var(--brand-soft);
  border-radius: var(--radius); padding: .6rem .9rem; margin-bottom: 1rem; }
.next-action { color: var(--text); }
.letters { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: center; justify-content: space-between; border: 1px solid var(--border);
  background: var(--surface-2); border-radius: var(--radius); padding: .75rem .9rem; }
.letters-btns { display: flex; gap: .5rem; flex-wrap: wrap; }
.veh-sum { margin-bottom: 1rem; padding: .75rem 1rem; }
.filters .fveh { flex: 0 1 200px; }
table.stats td { white-space: nowrap; }
.qr-edit { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.qr-prev { width: 120px; height: 120px; object-fit: contain; border: 1px solid var(--border); border-radius: 8px; background: #fff; padding: 4px; }
#askSelect { margin-bottom: .25rem; }

/* ---------------------------------------------------------------- Listes */
.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters input[type=search] { flex: 1 1 260px; }
table.list { width: 100%; border-collapse: collapse; background: var(--surface); }
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow); background: var(--surface); }
table.list th { text-align: left; font-family: var(--font-display); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
  font-weight: 600; padding: .65rem .8rem; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
table.list td { padding: .7rem .8rem; border-bottom: 1px solid var(--border); vertical-align: top; }
table.list td strong { font-family: var(--font-display); font-weight: 700; letter-spacing: .02em; }
table.list tbody tr { cursor: pointer; }
table.list tbody tr:hover { background: var(--hover-row); }
table.list tbody tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
.empty { padding: 2.5rem 1rem; text-align: center; color: var(--muted); }
.simple-list { list-style: none; margin: 0; padding: 0; }
.simple-list li { padding: .55rem 0; border-bottom: 1px solid var(--border); display: flex; gap: .75rem; align-items: baseline; }
.simple-list li:last-child { border-bottom: 0; }
.simple-list a { text-decoration: none; font-weight: 600; color: var(--brand); }
.bar-row { display: grid; grid-template-columns: 150px 1fr 40px; gap: .6rem; align-items: center; margin: .4rem 0; font-size: .92rem; }
.bar { height: 10px; background: var(--grey-soft); border-radius: 5px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand); border-radius: 5px; }

/* ---------------------------------------------------------------- Formulaires */
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--input-border);
  border-radius: 8px; padding: .5rem .65rem; width: 100%; min-height: 40px; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px var(--focus-ring); }
.filters input, .filters select { width: auto; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .85rem 1rem; }
.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field label { font-size: .84rem; font-weight: 600; color: var(--label); }
.field.wide { grid-column: 1 / -1; }
.field .hint { font-size: .78rem; color: var(--muted); }
.section-title { grid-column: 1 / -1; font-family: var(--font-display); font-size: .8rem; text-transform: uppercase; letter-spacing: .12em; color: var(--brand);
  font-weight: 700; border-bottom: 1px solid var(--border); padding-bottom: .35rem; margin-top: .6rem; }
.computed { background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: 8px; padding: .5rem .65rem; min-height: 40px; font-variant-numeric: tabular-nums; font-weight: 600; }
.computed.due { color: var(--danger); }
.computed.ok { color: var(--ok); }
.field.wide .computed { font-weight: 500; line-height: 1.5; }

/* ---------------------------------------------------------------- Facturation */
.bill { grid-column: 1 / -1; max-width: 560px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.bill-line { display: grid; grid-template-columns: minmax(0, 1fr) 190px; gap: .75rem; align-items: center; padding: .45rem .85rem; border-bottom: 1px solid var(--border); }
.bill-line label { font-weight: 500; color: var(--text); font-size: .95rem; }
.money { display: flex; align-items: center; border: 1px solid var(--input-border); border-radius: 8px; background: var(--surface); overflow: hidden; }
.money:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px var(--focus-ring); }
.money span { padding: 0 .55rem; color: var(--muted); font-size: .82rem; font-weight: 600; border-right: 1px solid var(--border); align-self: stretch; display: flex; align-items: center; background: var(--surface-2); }
.money input { border: 0; box-shadow: none !important; text-align: right; font-variant-numeric: tabular-nums; min-height: 38px; }
.bill-total { background: var(--brand-soft); border-bottom: 0; padding-block: .7rem; }
.bill-total span { font-family: var(--font-display); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: .86rem; color: var(--brand); }
.bill-total strong { text-align: right; font-family: var(--font-display); font-size: 1.35rem; padding-right: .65rem; }
.bill-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.bill-summary > div { border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem .9rem; background: var(--surface-2); display: flex; flex-direction: column; gap: .2rem; }
.bill-summary strong { font-family: var(--font-display); font-size: 1.55rem; font-weight: 700; line-height: 1.1; }
.bill-summary em { font-style: normal; font-size: .8rem; font-weight: 600; color: var(--ok); }
.bill-summary .due { border-color: var(--danger); background: var(--danger-soft); }
.bill-summary .due strong { color: var(--danger); }
.bill-summary .paid strong { color: var(--ok); }
.bill-summary .over { border-color: var(--warn); background: var(--warn-soft); }
.bill-summary .over strong { color: var(--warn); }
.regs { margin-bottom: 1rem; box-shadow: none; }
.reg-add { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; padding: .85rem; border: 1px dashed var(--input-border); border-radius: var(--radius); background: var(--surface-2); }
.reg-add .field { flex: 0 1 150px; }
.reg-add .field.grow { flex: 1 1 200px; }
.kpi .value.kpi-money { font-size: 2rem; }
.comm-add .field.full { flex: 1 1 100%; }
.comm-add textarea { min-height: 70px; }
.comms { list-style: none; margin: 1rem 0 0; padding: 0; }
.comms li { border-left: 3px solid var(--brand-light); padding: .55rem .75rem; margin-bottom: .6rem; background: var(--surface-2); border-radius: 0 8px 8px 0; }
.comm-head { display: flex; flex-wrap: wrap; gap: .4rem .75rem; align-items: center; }
.comm-head .del { margin-left: auto; }
.comm-txt { margin-top: .35rem; white-space: pre-wrap; }
.form-grid > .wide { grid-column: 1 / -1; min-width: 0; }
.regs td.r, .regs td.num { white-space: nowrap; }
#reglementsArea { max-width: 900px; }

/* ---------------------------------------------------------------- Onglets de la fiche */
.tabs { display: flex; gap: .15rem; border-bottom: 1px solid var(--border); margin-bottom: 1.1rem; overflow-x: auto; }
.tabs button { border: 0; background: none; font: inherit; font-weight: 600; color: var(--muted); padding: .7rem .75rem;
  border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }
.tabs .count { font-weight: 600; font-size: .78rem; background: var(--grey-soft); color: var(--muted); border-radius: 999px; padding: 0 .45rem; margin-left: .25rem; }
.tabs button.active .count { background: var(--brand-soft); color: var(--brand); }
.tab-panel[hidden] { display: none; }

.summary { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; margin: .4rem 0 1.1rem; color: var(--muted); font-size: .92rem; }
.summary strong { color: var(--text); font-weight: 600; }
.savebar { position: sticky; bottom: 0; z-index: 10; display: flex; gap: .75rem; align-items: center; justify-content: flex-end;
  padding: .75rem 1rem; margin: 1rem -1.15rem -1.15rem; background: var(--savebar); border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius); backdrop-filter: blur(4px); }
.savebar .dirty { color: var(--warn); font-size: .9rem; margin-right: auto; font-weight: 500; }

/* ---------------------------------------------------------------- Photos et documents */
.dropzone { border: 2px dashed var(--input-border); border-radius: var(--radius); padding: 1.2rem; text-align: center; background: var(--surface-2); }
.dropzone.over { border-color: var(--brand); background: var(--brand-soft); }
.dropzone .row { display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; margin-top: .7rem; align-items: center; }
.dropzone select { width: auto; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; margin-top: 1rem; }
.photo { position: relative; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.photo img { width: 100%; max-width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; cursor: zoom-in; background: var(--grey-soft); }
.photo .meta span:last-child { white-space: nowrap; display: flex; }
.photo .meta { padding: .35rem .5rem; font-size: .76rem; color: var(--muted); display: flex; justify-content: space-between; gap: .25rem; align-items: center; }
.photo .del, .doc .del { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1rem; padding: .1rem .3rem; border-radius: 4px; text-decoration: none; }
.photo .del:hover, .doc .del:hover { color: var(--danger); background: var(--danger-soft); }
.docs { margin-top: 1rem; }
.doc { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; padding: .6rem .25rem; border-bottom: 1px solid var(--border); }
.doc .ext { width: 42px; height: 42px; border-radius: 6px; background: var(--brand-soft); display: grid; place-items: center; font-family: var(--font-display); font-size: .74rem; font-weight: 700; color: var(--brand); flex: none; }
.doc .name { font-weight: 600; text-decoration: none; word-break: break-word; }
.doc .name:hover { text-decoration: underline; }
.doc .info { flex: 1; min-width: 0; }
.doc select { width: auto; min-height: 32px; padding: .2rem .4rem; font-size: .84rem; }
.progress { height: 6px; background: var(--grey-soft); border-radius: 3px; overflow: hidden; margin-top: .7rem; }
.progress span { display: block; height: 100%; width: 0; background: var(--brand); transition: width .15s; }

/* ---------------------------------------------------------------- Suivi */
.journal { list-style: none; padding: 0; margin: 1rem 0 0; }
.journal li { padding: .65rem 0; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: 130px 1fr auto; gap: .75rem; }
.journal li.sys { color: var(--muted); font-size: .9rem; }
.journal li:not(.sys) .txt { color: var(--text); }
.journal .when { font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.journal .who { font-weight: 600; color: var(--text); }
.journal .txt { white-space: pre-wrap; }

/* ---------------------------------------------------------------- Divers */
.toast { position: fixed; bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--toast-bg); color: var(--toast-fg); font-weight: 500;
  padding: .65rem 1rem; border-radius: 8px; opacity: 0; pointer-events: none; transition: .2s; z-index: 100; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.err { background: var(--danger); color: #fff; }
.dialog { border: 0; border-radius: 12px; padding: 1.5rem; width: min(420px, calc(100% - 32px)); box-shadow: 0 20px 50px rgba(0,0,0,.25);
  background: var(--surface); color: var(--text); }
.dialog::backdrop { background: var(--backdrop); }
.dialog h2 { font-size: 1.35rem; }
.ask-msg { margin: 0 0 1rem; font-size: 1.02rem; }
#askInput { margin-bottom: .25rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
.lightbox { position: fixed; inset: 0; background: rgba(5,10,20,.92); z-index: 200; display: flex; align-items: center; justify-content: center; }
.lightbox[hidden] { display: none; }
.lightbox figure { margin: 0; max-width: 92vw; max-height: 90vh; text-align: center; }
.lightbox img { max-width: 92vw; max-height: 82vh; object-fit: contain; }
.lightbox figcaption { color: #dfe6ef; margin-top: .5rem; font-size: .9rem; }
.lightbox button { position: absolute; background: rgba(255,255,255,.14); color: #fff; border: 0; font-size: 2rem; width: 52px; height: 52px; border-radius: 50%; cursor: pointer; }
.lb-close { top: calc(16px + env(safe-area-inset-top, 0px)); right: calc(16px + env(safe-area-inset-right, 0px)); }
.lb-prev { left: calc(16px + env(safe-area-inset-left, 0px)); top: 50%; transform: translateY(-50%); }
.lb-next { right: calc(16px + env(safe-area-inset-right, 0px)); top: 50%; transform: translateY(-50%); }
.loading { padding: 3rem; text-align: center; color: var(--muted); }
.print-only { display: none; }

/* ---------------------------------------------------------------- Connexion / installation */
body.logged-out .nav, body.logged-out .topbar-right { display: none; }
.auth { max-width: 420px; margin: 3rem auto; padding: 2rem 1.75rem 1.75rem; border-top: 4px solid var(--brand); }
.auth-logo { height: 76px; margin: 0 auto 1.1rem; display: flex; justify-content: center; }
.auth h1 { margin-bottom: .2rem; text-align: center; }
.auth > .muted { text-align: center; margin-top: 0; }
.auth form { display: flex; flex-direction: column; gap: .85rem; margin-top: 1.1rem; }
.auth-err { color: var(--danger); margin: 0; font-size: .92rem; font-weight: 500; }
.auth-msg { background: var(--warn-soft); color: var(--warn); padding: .6rem .75rem; border-radius: 8px; font-size: .92rem; }
.auth input[hidden] { display: none; }

/* ---------------------------------------------------------------- Téléphone */
@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; gap: .5rem; }
  .brand-logo { height: 34px; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
  .container { padding-block: 1.25rem; }
  .two-cols { grid-template-columns: 1fr; }
  .savebar { margin: 1rem -1.15rem -1.15rem; }
  table.list .hide-m { display: none; }
  .journal li { grid-template-columns: 1fr auto; }
  .journal .when { grid-column: 1 / -1; }
  .bar-row { grid-template-columns: 110px 1fr 32px; }
  .topbar-right { margin-left: 0; width: 100%; min-width: 0; }
  .topbar-right .btn-primary { flex: 1; }
  .user-chip { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .doc .info { flex: 1 1 calc(100% - 60px); }
  .doc select { margin-left: 54px; flex: 1; }
  h1 { font-size: 1.55rem; }
  .field.wide2 { grid-column: 1 / -1; }
  .bill-line { grid-template-columns: minmax(0, 1fr) 150px; }
  .bill-summary { grid-template-columns: 1fr; }
  .bill-summary > div { flex-direction: row; align-items: baseline; justify-content: space-between; }
  .reg-add .field, .reg-add .field.grow { flex: 1 1 100%; }
  .reg-add .btn { width: 100%; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
  .kpi .value { font-size: 2rem; }
  .kpi .sub { font-size: .8rem; }
}
@media (max-width: 480px) { .brand-text { display: none; } }

/* ---------------------------------------------------------------- Impression de la fiche */
@media print {
  .topbar, .savebar, .tabs, .dropzone, .page-head .actions, .del, .journal-form, .no-print, .demo-band { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .container { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .tab-panel[hidden] { display: block !important; }
  .tab-panel { break-inside: auto; margin-bottom: 1rem; }
  .print-only { display: block; }
  .print-logo { height: 54px; width: auto; margin-bottom: .75rem; }
  input, select, textarea { border: 0; padding: 0; min-height: 0; appearance: none; background: none; }
  textarea { resize: none; }
  .photos { grid-template-columns: repeat(3, 1fr); }
}

/* Bande de la barre système (téléphones) au-dessus de l'en-tête collant */
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--surface); }
