/* =====================================================================
   Leatheen · même palette que l'app (fond #0D1238, indigo, bleu, turquoise, menthe)
   ===================================================================== */
:root {
  --bg: #0D1238;
  --indigo: #2F39A9;
  --blue: #2E6FA0;
  --teal: #49A4BB;
  --mint: #15D8B3;
  --text: #F4F6FF;
  --text-2: rgba(244, 246, 255, 0.74);
  --text-3: rgba(244, 246, 255, 0.52);
  --glass: rgba(255, 255, 255, 0.065);
  --glass-strong: rgba(255, 255, 255, 0.1);
  --line: rgba(255, 255, 255, 0.13);
  --field: rgba(7, 10, 36, 0.55);
  --danger: #FF6B7A;
  --warn: #FFB547;
  --ok: var(--mint);
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 18px 50px rgba(3, 5, 25, 0.45);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font: 15px/1.5 var(--font);
  color: var(--text);
  background:
    radial-gradient(1100px 700px at 8% -10%, rgba(47, 57, 169, 0.55), transparent 60%),
    radial-gradient(900px 600px at 105% 110%, rgba(73, 164, 187, 0.32), transparent 60%),
    radial-gradient(700px 500px at 80% 0%, rgba(21, 216, 179, 0.12), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
a { color: var(--mint); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 28px; font-weight: 750; letter-spacing: -0.02em; }
h2 { font-size: 18px; font-weight: 700; margin-bottom: 14px; }
p { margin: 0; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; }
/* Texte sélectionné : bleu ciel classique, texte foncé (lisible sur fond sombre comme sur les documents blancs) */
::selection { background: #B3D7FF; color: #0D1238; }

.mono { font-family: var(--mono); font-size: 0.93em; }
.strong { font-weight: 650; }
.muted { color: var(--text-3); }
/* L'attribut hidden l'emporte toujours (sinon display: flex/grid des composants l'annule). */
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  backdrop-filter: blur(24px) saturate(150%);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.boot { padding: 80px 20px; text-align: center; color: var(--text-2); }

/* ---------------------------------------------------------------------
   Connexion
   --------------------------------------------------------------------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card {
  width: min(440px, 100%);
  border-radius: 28px;
  padding: 32px 28px;
  display: flex; flex-direction: column; gap: 16px;
}
.auth-card h1 { font-size: 24px; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 20px; }
.auth-brand .logo-mark { width: 40px; height: 40px; }
.auth-foot { font-size: 13px; color: var(--text-3); text-align: center; }
.auth-card .btn-primary { width: 100%; }
.subtitle { color: var(--text-2); margin-top: 6px; }

/* ---------------------------------------------------------------------
   Barre du haut
   --------------------------------------------------------------------- */
.topbar {
  position: sticky; top: 12px; z-index: 20;
  margin: 12px auto 0; width: min(1240px, calc(100% - 24px));
  border-radius: 22px;
  padding: 10px 12px 10px 16px;
  display: flex; align-items: center; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 750; font-size: 18px; }
.brand:hover { text-decoration: none; }
.logo-mark { width: 32px; height: 32px; border-radius: 9px; display: block; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav-link {
  color: var(--text-2); padding: 8px 14px; border-radius: 999px; white-space: nowrap; font-weight: 600;
  transition: background 0.2s, color 0.2s;
}
.nav-link:hover { color: var(--text); background: var(--glass); text-decoration: none; }
.nav-link.active { color: var(--bg); background: var(--mint); }
.top-right { display: flex; align-items: center; gap: 10px; }
.who { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; color: var(--text); }
.who:hover { text-decoration: none; }
.who-name { font-weight: 650; font-size: 14px; }
.who-role { font-size: 12px; color: var(--text-3); }

.main { width: min(1240px, calc(100% - 24px)); margin: 0 auto; padding: 28px 0 80px; outline: none; }
.page { display: flex; flex-direction: column; gap: 18px; animation: rise 0.35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .page { animation: none; } }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.loading { display: flex; align-items: center; gap: 12px; color: var(--text-2); padding: 60px 0; justify-content: center; }
.spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid var(--line); border-top-color: var(--mint);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------------
   Cartes, grilles, champs
   --------------------------------------------------------------------- */
.card { border-radius: var(--radius); padding: 20px; min-width: 0; }
.card > * + * { margin-top: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.card-head h2 { margin-bottom: 0; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.grid-2.tight { gap: 10px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 18px; align-items: start; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field-hint { font-size: 12px; color: var(--text-3); }
.input {
  width: 100%; min-height: 44px;
  font: inherit; color: var(--text);
  background: var(--field);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input::placeholder { color: var(--text-3); }
.input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(73, 164, 187, 0.25); }
.input:invalid:not(:placeholder-shown):not(:focus) { border-color: rgba(255, 107, 122, 0.6); }
textarea.input { resize: vertical; min-height: 80px; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
select.input option { color: #0D1238; background: #fff; }
select.input option:checked { color: #0D1238; background: #B3D7FF; }
/* Champs remplis par le navigateur ou le trousseau : bleu ciel, texte foncé (lisible) */
.input:-webkit-autofill,
.input:-webkit-autofill:hover,
.input:-webkit-autofill:focus {
  -webkit-text-fill-color: #0D1238;
  caret-color: #0D1238;
  -webkit-box-shadow: 0 0 0 1000px #E8F0FE inset;
  box-shadow: 0 0 0 1000px #E8F0FE inset;
  border-color: rgba(73, 164, 187, 0.6);
}
.input:autofill {
  color: #0D1238;
  caret-color: #0D1238;
  box-shadow: 0 0 0 1000px #E8F0FE inset;
  border-color: rgba(73, 164, 187, 0.6);
}
.input-num { text-align: right; font-variant-numeric: tabular-nums; }
.input-group { display: flex; gap: 8px; align-items: center; }
.input-group .input { flex: 1; }

.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 14px; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--mint); flex: none; }
.check.strong { font-weight: 650; }
.consent { padding: 12px; border-radius: var(--radius-sm); background: var(--glass); border: 1px solid var(--line); }

/* ---------------------------------------------------------------------
   Boutons
   --------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px;
  border-radius: 999px; border: 1px solid transparent;
  font: inherit; font-weight: 650; cursor: pointer; white-space: nowrap;
  text-decoration: none !important;
  transition: transform 0.12s, filter 0.15s, background 0.15s, opacity 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn-small { min-height: 34px; padding: 6px 12px; font-size: 13px; }
.btn-icon { font-size: 1.05em; line-height: 1; }
.btn-primary { color: #fff; background: linear-gradient(135deg, var(--indigo), var(--blue)); box-shadow: 0 8px 22px rgba(47, 57, 169, 0.45); }
.btn-primary:hover { filter: brightness(1.12); }
.btn-accent { color: var(--bg); background: linear-gradient(135deg, var(--mint), var(--teal)); box-shadow: 0 8px 22px rgba(21, 216, 179, 0.3); }
.btn-accent:hover { filter: brightness(1.08); }
.btn-secondary { color: var(--text); background: var(--glass-strong); border-color: var(--line); }
.btn-secondary:hover { background: rgba(255, 255, 255, 0.15); }
.btn-ghost { color: var(--text-2); background: transparent; }
.btn-ghost:hover { color: var(--text); background: var(--glass); }
.btn-danger { color: #fff; background: rgba(255, 107, 122, 0.85); }
.btn-danger:hover { background: #ff5265; }
.btn-ghost-danger { color: var(--danger); background: transparent; min-height: 34px; padding: 6px 12px; font-size: 13px; }
.btn-ghost-danger:hover { background: rgba(255, 107, 122, 0.12); }
.icon-btn {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--glass); color: var(--text-2);
  font: inherit; cursor: pointer; display: inline-grid; place-items: center;
}
.icon-btn:hover:not(:disabled) { color: var(--text); background: var(--glass-strong); }
.icon-btn:disabled { opacity: 0.3; cursor: default; }

/* ---------------------------------------------------------------------
   Badges, filtres, messages
   --------------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; white-space: nowrap; border: 1px solid transparent;
}
.badge-muted { color: var(--text-2); background: rgba(255, 255, 255, 0.08); border-color: var(--line); }
.badge-info { color: #bfefff; background: rgba(73, 164, 187, 0.2); border-color: rgba(73, 164, 187, 0.45); }
.badge-ok { color: var(--mint); background: rgba(21, 216, 179, 0.14); border-color: rgba(21, 216, 179, 0.4); }
.badge-warn { color: var(--warn); background: rgba(255, 181, 71, 0.13); border-color: rgba(255, 181, 71, 0.4); }
.badge-bad { color: var(--danger); background: rgba(255, 107, 122, 0.12); border-color: rgba(255, 107, 122, 0.4); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px;
  color: var(--text-2); background: var(--glass); border: 1px solid var(--line); font-weight: 600; font-size: 14px;
}
.chip:hover { color: var(--text); text-decoration: none; }
.chip.active { color: var(--bg); background: var(--mint); border-color: var(--mint); }
.chip-count { font-size: 12px; opacity: 0.75; font-variant-numeric: tabular-nums; }

.notice { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 14px; border: 1px solid; }
.notice-info { color: #d6f6ff; background: rgba(73, 164, 187, 0.14); border-color: rgba(73, 164, 187, 0.4); }
.notice-ok { color: var(--mint); background: rgba(21, 216, 179, 0.12); border-color: rgba(21, 216, 179, 0.35); }
.notice-warn { color: #ffe0ad; background: rgba(255, 181, 71, 0.12); border-color: rgba(255, 181, 71, 0.4); }
.notice-bad { color: #ffd2d7; background: rgba(255, 107, 122, 0.13); border-color: rgba(255, 107, 122, 0.45); }

.empty { padding: 28px 12px; text-align: center; color: var(--text-2); display: flex; flex-direction: column; align-items: center; gap: 14px; }

/* ---------------------------------------------------------------------
   Tableaux
   --------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; margin: 0 -8px; padding: 0 8px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-3); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 12px 10px; border-bottom: 1px solid rgba(255, 255, 255, 0.06); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tr.clickable { cursor: pointer; transition: background 0.15s; }
.table tr.clickable:hover td { background: rgba(255, 255, 255, 0.04); }
.stack-tight { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.row-tools { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: nowrap; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters .input { flex: 1 1 220px; width: auto; }

/* ---------------------------------------------------------------------
   Fiche devis / contrat
   --------------------------------------------------------------------- */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.detail-grid > * { min-width: 0; }
.side { position: sticky; top: 96px; display: flex; flex-direction: column; gap: 16px; }
.side-status { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.side-line { color: var(--text-2); font-size: 14px; }
.side-actions { display: flex; flex-direction: column; gap: 10px; }
.side-actions .btn { width: 100%; }
.pdf { display: flex; flex-direction: column; gap: 6px; }
.pdf .btn { width: 100%; }
.summary { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-radius: var(--radius-sm); background: rgba(0, 0, 0, 0.22); border: 1px solid var(--line); }
.summary-row { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.summary-row strong { color: var(--text); }
.summary-row.grand { font-size: 17px; color: var(--text); padding-top: 6px; border-top: 1px solid var(--line); }
.summary-row.grand strong { color: var(--mint); }
.plain-list { margin: 6px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
.facts dt { color: var(--text-3); }
.facts dd { margin: 0; }
.people { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.people li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------------------
   Éditeur de devis
   --------------------------------------------------------------------- */
.editor { display: flex; flex-direction: column; gap: 18px; }
.lines { display: flex; flex-direction: column; gap: 12px; }
.line {
  border-radius: var(--radius-sm); padding: 14px; background: rgba(0, 0, 0, 0.2); border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 12px;
}
.line-option { border-color: rgba(21, 216, 179, 0.4); background: rgba(21, 216, 179, 0.05); }
.line-head { display: flex; justify-content: space-between; align-items: center; }
.line-index { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); }
.line-option .line-index { color: var(--mint); }
.line-tools { display: flex; gap: 6px; }
.line-main { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 12px; }
.line-nums { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.line-total { min-height: 44px; display: flex; align-items: center; justify-content: flex-end; font-weight: 700; font-variant-numeric: tabular-nums; }
.line-flags { display: flex; gap: 22px; flex-wrap: wrap; }
.editor-totals { display: flex; flex-direction: column; gap: 6px; margin-left: auto; width: min(420px, 100%); padding: 12px 14px; border-radius: var(--radius-sm); background: rgba(0, 0, 0, 0.22); border: 1px solid var(--line); }
.equip-pick { display: flex; flex-direction: column; gap: 12px; }
.equip-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.equip-item { padding: 10px 12px; border-radius: var(--radius-sm); background: rgba(0, 0, 0, 0.18); border: 1px solid var(--line); }
.equip-item .badge { margin-left: 6px; }
.editor-bar {
  position: sticky; bottom: 12px; z-index: 5;
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; border-radius: 22px;
  background: rgba(13, 18, 56, 0.85); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}
.editor-bar > div:first-child { flex: 1; min-width: 200px; }

.inline-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; align-items: end; }
.inline-submit { display: flex; align-items: flex-end; }
.inline-submit .btn { width: 100%; }

/* ---------------------------------------------------------------------
   Fenêtres et notifications
   --------------------------------------------------------------------- */
.modal {
  width: min(520px, calc(100% - 24px)); max-height: calc(100vh - 40px);
  border-radius: 24px; padding: 0; color: var(--text);
  background: rgba(16, 22, 66, 0.96);
}
.modal-wide { width: min(760px, calc(100% - 24px)); }
.modal::backdrop { background: rgba(4, 6, 24, 0.6); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 20px 20px 0; }
.modal-head h2 { margin: 0; }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 0 20px 20px; flex-wrap: wrap; }

.toasts { position: fixed; z-index: 100; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; width: min(460px, calc(100% - 24px)); pointer-events: none; }
.toast {
  padding: 12px 16px; border-radius: 16px; font-weight: 600; font-size: 14px;
  background: rgba(16, 22, 66, 0.95); border: 1px solid var(--line); box-shadow: var(--shadow);
  animation: rise 0.25s ease both; transition: opacity 0.4s, transform 0.4s;
}
.toast-ok { border-color: rgba(21, 216, 179, 0.5); }
.toast-bad { border-color: rgba(255, 107, 122, 0.6); color: #ffd2d7; }
.toast.leaving { opacity: 0; transform: translateY(6px); }

/* ---------------------------------------------------------------------
   Document papier (devis / contrat) : blanc à l'écran comme à l'impression
   --------------------------------------------------------------------- */
.paper-wrap { min-width: 0; }
.paper {
  background: #fff; color: #141833;
  border-radius: 10px; box-shadow: var(--shadow);
  padding: 44px 48px; max-width: 210mm; margin: 0 auto;
  font-size: 13px; line-height: 1.45;
  display: flex; flex-direction: column; gap: 22px;
}
.paper a { color: var(--indigo); }
.paper .muted { color: #6b7090; }
.doc-head { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; padding-bottom: 18px; border-bottom: 3px solid var(--indigo); }
.doc-issuer { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; color: #4a4f6e; font-size: 12px; }
/* Logos carrés ou en largeur : on garde les proportions dans un cadre de 150 × 56 */
.doc-logo { width: auto; height: auto; max-width: 150px; max-height: 56px; object-fit: contain; border-radius: 6px; }
.doc-issuer-name { font-size: 18px; font-weight: 800; color: #141833; margin-bottom: 2px; }
.doc-title-block { text-align: right; }
.doc-kind { font-size: 26px; font-weight: 850; letter-spacing: 0.08em; color: var(--indigo); }
.doc-number { font-family: var(--mono); font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.doc-meta { display: grid; grid-template-columns: auto auto; gap: 2px 12px; margin: 0; justify-content: end; font-size: 12px; }
.doc-meta dt { color: #6b7090; }
.doc-meta dd { margin: 0; font-weight: 600; }
.doc-parties { display: grid; grid-template-columns: 1fr 1.3fr; gap: 18px; }
.doc-client, .doc-object { padding: 14px 16px; border-radius: 10px; background: #f3f5fb; border: 1px solid #e3e6f2; }
.doc-object .doc-meta { justify-content: start; margin-top: 6px; }
.doc-label { font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--blue); margin-bottom: 4px; }
.doc-client-name, .doc-object-title { font-size: 15px; font-weight: 750; }
.doc-hint { padding: 10px 12px; border-radius: 8px; background: #e7fbf6; color: #0b6b59; font-weight: 600; }
.doc-table { width: 100%; border-collapse: collapse; }
.doc-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: #fff; background: var(--indigo); padding: 8px 10px; }
.doc-table th:first-child { border-radius: 6px 0 0 6px; }
.doc-table th:last-child { border-radius: 0 6px 6px 0; }
.doc-table td { padding: 10px; border-bottom: 1px solid #e6e8f2; vertical-align: top; }
.doc-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.doc-table tr.off td { color: #9aa0bb; }
.doc-table tr.off .doc-line-label { text-decoration: line-through; text-decoration-color: rgba(0, 0, 0, 0.25); }
.doc-table-compact td { padding: 6px 10px; }
.doc-line-label { font-weight: 650; }
.doc-line-desc { color: #6b7090; font-size: 12px; margin-top: 2px; }
.doc-option { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--blue); }
.doc-option-live { cursor: pointer; padding: 4px 10px 4px 6px; border-radius: 999px; background: #e7fbf6; color: #0b6b59; }
.doc-option-live input { width: 18px; height: 18px; margin: 0; accent-color: #0fb495; }
.doc-totals { display: flex; justify-content: flex-end; }
.doc-totals-table { border-collapse: collapse; min-width: 280px; font-variant-numeric: tabular-nums; }
.doc-totals-table th { text-align: left; font-weight: 500; color: #4a4f6e; padding: 5px 12px; }
.doc-totals-table td { text-align: right; padding: 5px 12px; font-weight: 650; }
.doc-totals-table tr.grand th, .doc-totals-table tr.grand td { background: var(--indigo); color: #fff; font-size: 15px; font-weight: 800; padding: 10px 12px; }
.doc-totals-table tr.grand th { border-radius: 8px 0 0 8px; }
.doc-totals-table tr.grand td { border-radius: 0 8px 8px 0; }
.doc-section h3, .doc-conditions h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--blue); margin-bottom: 8px; }
.doc-notes { white-space: pre-wrap; }
.doc-foot { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; padding-top: 16px; border-top: 1px solid #e3e6f2; align-items: start; }
.doc-conditions ul { margin: 0; padding-left: 18px; color: #4a4f6e; font-size: 12px; }
.doc-stamp { border: 1.5px dashed #b9bfd8; border-radius: 10px; padding: 12px 14px; font-size: 12px; color: #4a4f6e; }
.doc-stamp strong { display: block; color: #141833; font-size: 13px; margin-bottom: 4px; }
.doc-stamp-ok { border-style: solid; border-color: #15b897; background: #ecfbf7; color: #0b6b59; }
.doc-stamp-ok strong { color: #0b6b59; }
.doc-stamp-bad { border-style: solid; border-color: #e85d6d; background: #fff1f3; color: #a3283a; }
.doc-sign { height: 54px; }

/* ---------------------------------------------------------------------
   Étiquettes QR (planche A4 3 × 7, 63,5 × 38,1 mm)
   --------------------------------------------------------------------- */
.labels { display: grid; grid-template-columns: repeat(auto-fill, 63.5mm); gap: 4mm 2.5mm; justify-content: center; }
.label {
  width: 63.5mm; height: 38.1mm; padding: 3mm; overflow: hidden;
  display: flex; gap: 3mm; align-items: center;
  background: #fff; color: #111; border-radius: 6px; box-shadow: var(--shadow);
}
.qr { width: 30mm; height: 30mm; flex: none; display: block; }
.label-text { min-width: 0; display: flex; flex-direction: column; gap: 1mm; }
.label-code { font-family: var(--mono); font-weight: 800; font-size: 10pt; word-break: break-all; }
.label-name { font-size: 8pt; font-weight: 650; line-height: 1.2; }
.label-loc { font-size: 7pt; color: #444; line-height: 1.2; }
.label-contract { font-size: 7pt; font-weight: 700; white-space: nowrap; }
.label-brand { font-size: 6.5pt; color: #2F39A9; font-weight: 700; margin-top: 1mm; line-height: 1.2; }
.qr-missing { font-size: 10px; color: #a00; }

/* ---------------------------------------------------------------------
   Fiche publique d'un équipement (QR scanné avec n'importe quel téléphone)
   --------------------------------------------------------------------- */
.public {
  min-height: 100vh;
  width: min(520px, 100%);
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 16px;
}
.pub-head { display: flex; align-items: center; gap: 12px; padding: 4px 4px 0; }
.pub-head .logo-mark { width: 44px; height: 44px; border-radius: 12px; }
.pub-brand { font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
.pub-kicker { font-size: 13px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; }
.pub-main { display: flex; flex-direction: column; gap: 14px; animation: rise 0.4s ease both; }
.pub-card { border-radius: 26px; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.pub-card .btn { width: 100%; min-height: 52px; font-size: 16px; }
.pub-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--mint); }
.pub-hero h1 { font-size: 30px; line-height: 1.15; word-break: break-word; }
.pub-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.pub-chip { padding: 6px 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.09); border: 1px solid var(--line); font-size: 14px; color: var(--text-2); }
.pub-company { font-size: 22px; font-weight: 750; }
.pub-facts { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; margin: 0; font-size: 15px; }
.pub-facts dt { color: var(--text-3); }
.pub-facts dd { margin: 0; text-align: right; font-weight: 600; }

.pub-status {
  border-radius: 26px; padding: 20px;
  display: flex; align-items: center; gap: 16px;
  border: 1px solid var(--line);
  background: var(--glass);
}
.pub-status-icon {
  width: 54px; height: 54px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-size: 28px; font-weight: 900;
}
.pub-status-title { font-size: 20px; font-weight: 800; line-height: 1.2; }
.pub-status-sub { font-size: 15px; color: var(--text-2); margin-top: 4px; }
.pub-ok { border-color: rgba(21, 216, 179, 0.55); background: linear-gradient(135deg, rgba(21, 216, 179, 0.2), rgba(73, 164, 187, 0.08)); box-shadow: 0 16px 40px rgba(21, 216, 179, 0.18); }
.pub-ok .pub-status-icon { background: var(--mint); color: var(--bg); box-shadow: 0 0 0 6px rgba(21, 216, 179, 0.18); }
.pub-ok .pub-status-title { color: var(--mint); }
.pub-warn { border-color: rgba(255, 181, 71, 0.55); background: linear-gradient(135deg, rgba(255, 181, 71, 0.18), rgba(255, 107, 122, 0.06)); }
.pub-warn .pub-status-icon { background: var(--warn); color: var(--bg); box-shadow: 0 0 0 6px rgba(255, 181, 71, 0.18); }
.pub-warn .pub-status-title { color: #ffd08a; }
.pub-muted .pub-status-icon { background: rgba(255, 255, 255, 0.14); color: var(--text); }
.nowrap { white-space: nowrap; }
.pub-foot { text-align: center; padding-top: 4px; font-size: 14px; }
.pub-foot a { color: var(--text-2); }

/* ---------------------------------------------------------------------
   Rapports d'intervention et logos
   --------------------------------------------------------------------- */
.state-banner { display: flex; gap: 14px; align-items: center; padding: 4px 2px; }
.state-dot { width: 14px; height: 14px; border-radius: 50%; flex: none; box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.06); }
.state-ok .state-dot { background: var(--mint); box-shadow: 0 0 0 5px rgba(21, 216, 179, 0.18); }
.state-warn .state-dot { background: var(--warn); box-shadow: 0 0 0 5px rgba(255, 181, 71, 0.18); }
.state-bad .state-dot { background: var(--danger); box-shadow: 0 0 0 5px rgba(255, 107, 122, 0.18); }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.checks { list-style: none; margin: 0; padding: 0; }
.checks li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
.checks li:last-child { border-bottom: 0; }
.checks .badge { flex: none; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.photo { margin: 0; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.photo a, .photo-missing { display: block; aspect-ratio: 4 / 3; border-radius: var(--radius-sm); overflow: hidden; background: rgba(255, 255, 255, 0.06); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.25s ease; }
.photo a:hover img { transform: scale(1.04); }
.photo-missing { display: grid; place-items: center; color: var(--text-3); font-size: 13px; }
.photo figcaption { font-size: 12px; color: var(--text-3); overflow-wrap: anywhere; }
.sig-box, .logo-box { display: grid; place-items: center; padding: 12px; border-radius: var(--radius-sm); background: #fff; }
.sig-box { min-height: 90px; }
.sig-box img { max-width: 100%; max-height: 110px; }
.logo-box { min-height: 120px; max-width: 420px; }
.logo-box img { max-width: 100%; max-height: 96px; object-fit: contain; }
.logo-empty { color: #6B7090; font-size: 14px; }

/* ---------------------------------------------------------------------
   Mon entreprise, modèles de points, abonnés
   --------------------------------------------------------------------- */
.sub-title { font-size: 14px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.06em; margin: 8px 0 0; }
.templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.template { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: var(--radius-sm); background: var(--glass); border: 1px solid var(--line); }
.template-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.template-items { margin: 0; padding-left: 18px; font-size: 13px; color: var(--text-2); display: flex; flex-direction: column; gap: 2px; flex: 1; }
.template-items .muted { list-style: none; margin-left: -18px; }
.doc-powered { text-align: center; font-size: 9px; color: #8a8fa8; margin-top: 4px; }

/* ---------------------------------------------------------------------
   Espace Entreprise : tableau de bord, échéances, documents
   --------------------------------------------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.kpi {
  border-radius: var(--radius); padding: 16px 18px;
  display: flex; flex-direction: column; gap: 2px; color: var(--text);
  transition: background 0.15s, transform 0.15s;
}
.kpi:hover { text-decoration: none; background: var(--glass-strong); transform: translateY(-1px); }
.kpi-value { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.kpi-ok .kpi-value { color: var(--mint); }
.kpi-warn { border-color: rgba(255, 181, 71, 0.45); }
.kpi-warn .kpi-value { color: var(--warn); }
.kpi-bad { border-color: rgba(255, 107, 122, 0.5); background: linear-gradient(135deg, rgba(255, 107, 122, 0.14), var(--glass)); }
.kpi-bad .kpi-value { color: var(--danger); }
.alerts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.alert { display: flex; align-items: center; gap: 12px; padding: 12px 2px; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
.alert:last-child { border-bottom: 0; }
.alert-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--text-3); }
.alert-bad .alert-dot { background: var(--danger); box-shadow: 0 0 0 4px rgba(255, 107, 122, 0.18); }
.alert-warn .alert-dot { background: var(--warn); box-shadow: 0 0 0 4px rgba(255, 181, 71, 0.18); }
.alert-info .alert-dot { background: var(--teal); box-shadow: 0 0 0 4px rgba(73, 164, 187, 0.18); }
.alert-ok .alert-dot { background: var(--mint); box-shadow: 0 0 0 4px rgba(21, 216, 179, 0.16); }
.alert-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.alert-title { font-weight: 650; }
.alert-bad .alert-title { color: #ffc2c9; }
.alert-sub { font-size: 13px; color: var(--text-2); overflow-wrap: anywhere; }
.alert-when { font-size: 13px; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 10px; color: var(--text-2); }
.steps strong { color: var(--text); }
.steps li.done { color: var(--text-3); }
.steps li.done strong { color: var(--mint); text-decoration: line-through; text-decoration-color: rgba(21, 216, 179, 0.5); }
.steps .btn { vertical-align: middle; }
.doc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.doc-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: rgba(0, 0, 0, 0.18); border: 1px solid var(--line); }
.doc-icon { width: 36px; height: 36px; flex: none; border-radius: 9px; display: grid; place-items: center; font-size: 10px; font-weight: 800; letter-spacing: 0.04em; color: #ffc2c9; background: rgba(255, 107, 122, 0.16); }
.doc-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.contact-name { display: block; font-size: 20px; font-weight: 750; color: var(--text); line-height: 1.2; }
.photo figcaption.row { justify-content: space-between; flex-wrap: nowrap; }
.photo figcaption.row > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.equip-list .check { align-items: center; }
.equip-list .check[hidden] { display: none; }
.equip-list .badge { margin-left: 6px; }

/* ---------------------------------------------------------------------
   Petits écrans
   --------------------------------------------------------------------- */
@media (max-width: 1000px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .detail-grid > * { min-width: 0; }
  .side { position: static; order: -1; }
  .grid-main { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  body { font-size: 15px; }
  h1 { font-size: 23px; }
  .topbar { flex-wrap: wrap; top: 8px; margin-top: 8px; width: calc(100% - 16px); gap: 8px 12px; }
  .nav { order: 3; flex-basis: 100%; }
  .who { display: none; }
  .main { width: calc(100% - 32px); padding-top: 20px; }
  .grid-2, .line-main { grid-template-columns: 1fr; }
  .line-nums { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { padding: 16px; }
  .paper { padding: 22px 16px; font-size: 12px; border-radius: 8px; }
  .doc-head { flex-direction: column; }
  .doc-title-block { text-align: left; }
  .doc-meta { justify-content: start; }
  .doc-parties, .doc-foot { grid-template-columns: 1fr; }
  .doc-table th, .doc-table td { padding: 7px 5px; }
  .doc-totals-table { min-width: 0; width: 100%; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
}

/* ---------------------------------------------------------------------
   Impression / PDF
   --------------------------------------------------------------------- */
@page { size: A4; margin: 12mm; }
@page labels { size: A4; margin: 15.1mm 7.2mm 0; }
@media print {
  :root { color-scheme: light; }
  html, body { background: #fff !important; color: #000; }
  .no-print, .topbar, .toasts, .modal { display: none !important; }
  .main { width: auto; padding: 0; margin: 0; }
  .page { animation: none; gap: 0; }
  .detail-grid { display: block; }
  .paper { box-shadow: none; border-radius: 0; padding: 0; max-width: none; margin: 0; gap: 16px; font-size: 11pt; }
  .doc-table tr, .doc-foot, .doc-totals, .doc-stamp { break-inside: avoid; }
  .doc-table thead { display: table-header-group; }
  .doc-option-live { background: none; padding: 0; color: #0b6b59; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .labels { page: labels; display: grid; grid-template-columns: repeat(3, 63.5mm); grid-auto-rows: 38.1mm; gap: 0 2.5mm; justify-content: start; }
  .label { box-shadow: none; border-radius: 0; break-inside: avoid; }
  .card { background: none; border: 0; box-shadow: none; padding: 0; }
}
