/*
 * Lagom — interface du bureau et du terrain.
 * Mise en page : barre latérale sur ordinateur, barre d'onglets en bas sur iPhone.
 * Identité : Fjord (bleu profond), Bulle (jaune), Lin (fond). Police Figtree, coins doux, peu de traits.
 */
@font-face {
  font-family: "Figtree";
  src: url("/fonts/figtree.woff2") format("woff2");
  font-weight: 300 900;
  font-style: normal;
  font-display: swap;
}
:root {
  --bg: #f4f3ef;
  --surface: #ffffff;
  --surface-2: #efede7;
  --ink: #172233;
  --muted: #5a6372;
  --line: #e6e3db;
  --accent: #24466e;
  --accent-strong: #1a3554;
  --accent-ink: #ffffff;
  --accent-soft: #e6ecf3;
  --bulle: #e9b949;
  --bulle-soft: #f6e3ae;
  --lac: #8ec5d6;
  --ok: #2f6347;
  --ok-soft: #ddede3;
  --warn: #85560a;
  --warn-soft: #f8ebcb;
  --danger: #a63f29;
  --danger-soft: #f8e2dc;
  --shadow: 0 1px 2px rgba(23, 34, 51, .05), 0 6px 20px rgba(23, 34, 51, .06);
  --shadow-lift: 0 2px 4px rgba(23, 34, 51, .06), 0 14px 32px rgba(23, 34, 51, .10);
  --radius: 18px;
  --radius-sm: 12px;
  --font: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --tabbar-h: 62px;
  --lac-soft: #dcedf2;
  --lac-ink: #1d5566;
  --cta-hover: #ddaa35;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1620;
    --surface: #172131;
    --surface-2: #1f2b3d;
    --ink: #e8ecf2;
    --muted: #9ba7b9;
    --line: #2a3649;
    --accent: #e9b949;
    --accent-strong: #f2cd72;
    --accent-ink: #172233;
    --accent-soft: #3a3016;
    --bulle: #e9b949;
    --bulle-soft: #3b3115;
    --lac: #5d9fb3;
    --ok: #7cc79a;
    --ok-soft: #1a3326;
    --warn: #f0c36a;
    --warn-soft: #3a2e14;
    --danger: #f19a86;
    --danger-soft: #3d231d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    --shadow-lift: 0 2px 4px rgba(0, 0, 0, .35), 0 14px 32px rgba(0, 0, 0, .35);
    color-scheme: dark;
    --lac-soft: #173540;
    --lac-ink: #9fd3e2;
    --cta-hover: #f2cd72;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1620;
  --surface: #172131;
  --surface-2: #1f2b3d;
  --ink: #e8ecf2;
  --muted: #9ba7b9;
  --line: #2a3649;
  --accent: #e9b949;
  --accent-strong: #f2cd72;
  --accent-ink: #172233;
  --accent-soft: #3a3016;
  --bulle: #e9b949;
  --bulle-soft: #3b3115;
  --lac: #5d9fb3;
  --ok: #7cc79a;
  --ok-soft: #1a3326;
  --warn: #f0c36a;
  --warn-soft: #3a2e14;
  --danger: #f19a86;
  --danger-soft: #3d231d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, .35), 0 14px 32px rgba(0, 0, 0, .35);
  color-scheme: dark;
  --lac-soft: #173540;
  --lac-ink: #9fd3e2;
  --cta-hover: #f2cd72;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15.5px/1.5 var(--font);
  font-feature-settings: "tnum" 0;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.2; text-wrap: balance; }
h1 { font-size: 1.75rem; font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: 1.12rem; font-weight: 700; letter-spacing: -.005em; }
h3 { font-size: 1rem; font-weight: 700; }
.num, td.num, .tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.boot { display: grid; place-items: center; min-height: 100%; }
.boot-msg { color: var(--muted); }

/* ---------- Coquille ---------- */
.shell {
  display: grid; grid-template-columns: 272px 1fr; min-height: 100%; background: var(--bg);
  --side: #24466e; --side-ink: #ffffff; --side-text: #d2ddea; --side-active: rgba(255, 255, 255, .14); --side-card: rgba(255, 255, 255, .09);
  --side-shadow: 0 10px 30px rgba(36, 70, 110, .25);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .shell { --side: #1b3150; --side-text: #b9c7da; --side-active: rgba(255, 255, 255, .10); --side-card: rgba(255, 255, 255, .06); --side-shadow: 0 0 0 1px rgba(255, 255, 255, .04); }
}
:root[data-theme="dark"] .shell { --side: #1b3150; --side-text: #b9c7da; --side-active: rgba(255, 255, 255, .10); --side-card: rgba(255, 255, 255, .06); --side-shadow: 0 0 0 1px rgba(255, 255, 255, .04); }
.sidebar {
  display: flex; flex-direction: column; padding: 26px 14px 16px; gap: 2px;
  position: sticky; top: 14px; height: calc(100vh - 28px); align-self: start; margin: 14px 0 14px 14px;
  background: var(--side); color: var(--side-ink); border-radius: 26px; box-shadow: var(--side-shadow); overflow-y: auto;
}
.brand { padding: 0 10px 28px; }
/* Logo unifié : la capsule du niveau encadre le mot, la bulle fait le « o ». */
.lockup { display: inline-flex; align-items: center; border: 3px solid currentColor; border-radius: 999px; padding: 5px 17px 8px; color: inherit; text-decoration: none; }
.lockup .w { font-size: 33px; font-weight: 800; letter-spacing: -1.5px; line-height: .9; }
.lockup .o { display: flex; align-items: center; gap: 4px; margin: 0 4px; transform: translateY(4px); }
.lockup .o i { width: 2.5px; height: 19px; border-radius: 2px; background: currentColor; }
.lockup .o b { width: 17px; height: 17px; border-radius: 50%; background: var(--bulle); }
.nav { display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 14px;
  color: var(--side-text); text-decoration: none; font-weight: 550;
}
.nav a::before { content: ""; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.nav a:hover { background: var(--side-card); color: var(--side-ink); }
.nav a[aria-current="page"] { background: var(--side-active); color: var(--side-ink); font-weight: 750; }
.nav a[aria-current="page"]::before { background: var(--bulle); }
.nav svg { display: none; }
.nav .badge { margin-left: auto; background: var(--bulle); color: #172233; }
.sidebar-foot { margin-top: auto; padding-top: 14px; }
.org { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 16px; background: var(--side-card); color: var(--side-ink); text-decoration: none; }
.org:hover { background: var(--side-active); }
.org-badge { width: 36px; height: 36px; border-radius: 11px; background: #f4f3ef; color: #24466e; display: grid; place-items: center; font-weight: 800; font-size: .88rem; flex: none; }
.org-text { display: grid; min-width: 0; }
.org-text strong { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .sync { color: var(--side-text); font-size: .78rem; gap: 6px; }
.sidebar .sync .dot { width: 7px; height: 7px; background: #7cc79a; }
.sidebar .sync.offline .dot { background: var(--bulle); }
.sidebar .sync.pending .dot { background: #ffffff; }
.main { min-width: 0; padding: 40px 40px 64px; }
.page { max-width: 1160px; margin: 0 auto; display: grid; gap: 22px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 6px; font-size: 1rem; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.tabbar { display: none; }

/* ---------- État de synchronisation ---------- */
.sync { display: flex; align-items: center; gap: 8px; font-size: .84rem; color: var(--muted); }
.sync .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); flex: none; }
.sync.offline .dot { background: var(--warn); }
.sync.pending .dot { background: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .sync.pending .dot { animation: none; } }
.offline-banner {
  background: var(--warn-soft); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  border-radius: var(--radius-sm); padding: 8px 12px; font-size: .9rem;
}

/* ---------- Boutons et champs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 650; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--bulle); border-color: var(--bulle); color: #172233; }
.btn.primary:hover { background: var(--cta-hover); border-color: var(--cta-hover); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { min-height: 32px; padding: 0 12px; font-size: .87rem; border-radius: 10px; }
.btn.icon { padding: 0; width: 36px; min-height: 36px; }
.btn svg { width: 16px; height: 16px; }

.field { display: grid; gap: 5px; min-width: 0; }
.field > span { font-size: .86rem; font-weight: 650; color: var(--muted); }
.field .hint { font-size: .8rem; color: var(--muted); }
.field .error { font-size: .82rem; color: var(--danger); }
.input, select.input, textarea.input {
  width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid color-mix(in srgb, var(--line) 70%, var(--muted)); border-radius: var(--radius-sm);
  background: var(--surface); outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.num { text-align: right; }
textarea.input { min-height: 80px; resize: vertical; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.check { display: flex; gap: 8px; align-items: center; }
.search { position: relative; flex: 1; min-width: 200px; max-width: 420px; }
.search .input { padding-left: 34px; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; color: var(--muted); }

/* ---------- Panneaux, tableaux, puces ---------- */
.panel { background: var(--surface); border: 1px solid transparent; border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 18px 22px 14px; border-bottom: 1px solid var(--line); }
.panel-body { padding: 18px 22px; display: grid; gap: 14px; }
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: .8rem; font-weight: 650; color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list th:first-child, table.list td:first-child { padding-left: 22px; }
table.list th:last-child, table.list td:last-child { padding-right: 22px; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr[data-href] { cursor: pointer; }
table.list tbody tr[data-href]:hover td { background: var(--surface-2); }
table.list .num { text-align: right; white-space: nowrap; }
.empty { padding: 34px 16px; text-align: center; color: var(--muted); display: grid; gap: 12px; justify-items: center; }

.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: .79rem; font-weight: 700; white-space: nowrap; background: var(--surface-2); color: var(--muted); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.danger { background: var(--danger-soft); color: var(--danger); }
.chip.accent { background: var(--lac-soft); color: var(--lac-ink); }
.badge { min-width: 20px; height: 20px; border-radius: 10px; padding: 0 6px; background: var(--danger); color: #fff; font-size: .74rem; font-weight: 700; display: inline-grid; place-items: center; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 12px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--accent-strong); border-bottom-color: var(--accent); }

/* ---------- Tableau de bord ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.kpi { background: var(--surface); padding: 20px 22px; display: grid; gap: 6px; border-radius: var(--radius); box-shadow: var(--shadow); color: inherit; text-decoration: none; }
a.kpi:hover { box-shadow: var(--shadow-lift); }
.kpi.feature { background: var(--accent); color: var(--accent-ink); }
.kpi.feature .label { color: color-mix(in srgb, var(--accent-ink) 75%, transparent); }
.kpi.feature .detail { color: var(--bulle); font-weight: 650; }
.kpi .label { color: var(--muted); font-size: .92rem; }
.kpi .value { font-size: 1.85rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1.15; }
.kpi .value.danger { color: var(--danger); }
.kpi .detail { font-size: .86rem; color: var(--muted); font-weight: 600; }
.kpi .detail.danger { color: var(--danger); }
.kpi .detail.ok { color: var(--ok); }
.chart { width: 100%; height: 220px; display: block; }
.chart text { fill: var(--muted); font-size: 11px; }
.chart .bar { fill: var(--accent); }
.chart .bar.paid { fill: var(--bulle); }
.chart .grid { stroke: var(--line); }
.legend { display: flex; gap: 16px; font-size: .84rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.rank { list-style: none; margin: 0; padding: 0; display: grid; }
.rank li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.rank li:last-child { border-bottom: 0; }
.cols-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.cols-main { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }

/* ---------- Fiche client ---------- */
.addr-list { display: grid; gap: 10px; }
.addr { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; display: grid; gap: 4px; }
.addr-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.addr .access { font-size: .86rem; color: var(--warn); }
.contact-links { display: flex; gap: 8px; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* ---------- Éditeur de devis / facture ---------- */
.editor-top { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.lines-head, .line {
  display: grid; align-items: start; gap: 8px;
  grid-template-columns: 28px minmax(0, 1fr) 84px 70px 104px 76px 82px 108px 34px;
}
.lines-head { font-size: .78rem; font-weight: 600; color: var(--muted); padding: 0 12px 6px; }
.lines-head .num { text-align: right; }
.lines { display: grid; }
.line { padding: 10px 12px; border-top: 1px solid var(--line); background: var(--surface); }
.line:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 45%, var(--surface)); }
.line .total { text-align: right; padding-top: 8px; font-weight: 600; font-variant-numeric: tabular-nums; }
.line .handle { display: grid; gap: 2px; padding-top: 2px; }
.line .handle button { border: 0; background: none; padding: 0; height: 16px; color: var(--muted); cursor: pointer; }
.line.kind-titre .rich-input { font-weight: 700; }
.line.kind-titre, .line.kind-texte, .line.kind-sous_total { grid-template-columns: 28px minmax(0, 1fr) 140px 34px; }
.line .line-kind { font-size: .74rem; color: var(--muted); text-align: right; padding-top: 9px; }
.line .input { min-height: 34px; padding: 5px 8px; }
.line-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.totals-box { display: grid; gap: 6px; font-variant-numeric: tabular-nums; }
.totals-box .row { display: flex; justify-content: space-between; gap: 12px; }
.totals-box .grand { font-weight: 700; font-size: 1.15rem; padding-top: 6px; border-top: 1px solid var(--line); }
.save-state { font-size: .84rem; color: var(--muted); }

/* Texte enrichi */
.rich { display: grid; gap: 4px; }
.rich-toolbar { display: none; gap: 2px; flex-wrap: wrap; }
.rich:focus-within .rich-toolbar { display: flex; }
.rich-toolbar button, .rich-toolbar label {
  min-width: 28px; height: 26px; padding: 0 6px; border: 1px solid var(--line); background: var(--surface);
  border-radius: 4px; cursor: pointer; font-size: .82rem; display: inline-grid; place-items: center; position: relative;
}
.rich-toolbar input[type="color"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.rich-input {
  min-height: 34px; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); outline: none; white-space: pre-wrap; overflow-wrap: anywhere;
}
.rich-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.rich-input:empty::before { content: attr(data-placeholder); color: var(--muted); }

/* Aperçu du document */
.preview-frame { width: 100%; height: 78vh; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.paper { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.paper iframe { position: absolute; top: 0; left: 0; width: 794px; border: 0; transform-origin: 0 0; background: #fff; }
.progress-bar { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.progress-bar span { display: block; height: 100%; background: var(--accent); }

/* ---------- Dialogues et notifications ---------- */
dialog.modal {
  border: 0; padding: 0; border-radius: 22px; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 40px);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
}
dialog.modal.wide { width: min(860px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: rgba(15, 22, 32, .45); backdrop-filter: blur(2px); }
.modal-head { padding: 22px 24px 6px; }
.modal-body { padding: 10px 24px; display: grid; gap: 14px; overflow-y: auto; max-height: calc(100vh - 190px); }
.modal-foot { padding: 16px 24px 22px; display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 50; max-width: min(420px, calc(100vw - 36px)); }
.toast { background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 14px; font-weight: 550; box-shadow: var(--shadow); font-size: .92rem; }
.toast.error { background: var(--danger); color: #fff; }
.pairing-code { font-size: 2.6rem; font-weight: 800; letter-spacing: .18em; text-align: center; font-variant-numeric: tabular-nums; color: var(--accent-strong); }

/* ---------- Écran d'appairage ---------- */
.pair-screen { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.pair-card { width: min(420px, 100%); display: grid; gap: 16px; }

/* ---------- iPhone / petits écrans ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; background: var(--bg); }
  .kpi .value { font-size: 1.2rem; }
  .sidebar { display: none; }
  .main { padding: 16px max(14px, env(safe-area-inset-right)) calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: 4px max(4px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(4px, env(safe-area-inset-left));
  }
  .tabbar a { display: grid; justify-items: center; gap: 2px; padding: 7px 2px; font-size: .7rem; color: var(--muted); text-decoration: none; font-weight: 600; position: relative; }
  .tabbar a[aria-current="page"] { color: var(--accent-strong); }
  .tabbar svg { width: 22px; height: 22px; }
  .tabbar .badge { position: absolute; top: 2px; left: 55%; transform: scale(.85); }
  .page-head h1 { font-size: 1.3rem; }
  .kpis, .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.two, .grid.three, .cols-2, .cols-main, .editor-top { grid-template-columns: 1fr; }
  .hide-mobile { display: none !important; }
  table.list.responsive thead { display: none; }
  table.list.responsive tr { display: grid; grid-template-columns: 1fr auto; padding: 10px 12px; border-bottom: 1px solid var(--line); gap: 2px 10px; }
  table.list.responsive td { border: 0; padding: 0; }
  table.list.responsive td.primary { font-weight: 600; }
  table.list.responsive td.num { grid-column: 2; grid-row: 1; }
  table.list.responsive td.secondary { grid-column: 1 / -1; color: var(--muted); font-size: .86rem; }
  .lines-head { display: none; }
  .line {
    grid-template-columns: 1fr 1fr 1fr; grid-template-areas: "desc desc desc" "qty unit price" "disc vat total" "handle . del";
  }
  .line > .handle { grid-area: handle; display: flex; gap: 12px; }
  .line > .desc { grid-area: desc; }
  .line > .qty { grid-area: qty; } .line > .unit { grid-area: unit; } .line > .price { grid-area: price; }
  .line > .disc { grid-area: disc; } .line > .vat { grid-area: vat; } .line > .total { grid-area: total; }
  .line > .del { grid-area: del; justify-self: end; }
  .line.kind-titre, .line.kind-texte, .line.kind-sous_total { grid-template-columns: 1fr auto; grid-template-areas: "desc desc" "handle del"; }
  .line .line-kind { display: none; }
  .line [data-label]::before { content: attr(data-label); display: block; font-size: .72rem; color: var(--muted); margin-bottom: 2px; }
  .preview-frame { height: 70vh; }
  .toasts { left: 14px; right: 14px; bottom: calc(var(--tabbar-h) + 14px + env(safe-area-inset-bottom)); max-width: none; }
  .btn { min-height: 42px; }
}
@media print {
  .sidebar, .tabbar, .page-head .actions { display: none !important; }
}

/* ---------- Accueil : grandes actions ---------- */
.action-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.action-card {
  display: grid; gap: 4px; padding: 18px; border-radius: var(--radius); text-decoration: none; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.action-card strong { font-size: 1.06rem; }
.action-card span { color: var(--muted); font-size: .88rem; }
.action-card:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-1px); }
.action-card.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.action-card.primary span { color: color-mix(in srgb, var(--accent-ink) 82%, transparent); }
@media (prefers-reduced-motion: reduce) { .action-card { transition: none; } .action-card:hover { transform: none; } }

/* ---------- Listes à toucher ---------- */
.pick-list { display: grid; gap: 8px; }
.pick {
  display: grid; gap: 2px; text-align: left; padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none;
}
.pick:hover { border-color: var(--accent); }
.pick[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.segmented { display: inline-flex; padding: 3px; background: var(--surface-2); border-radius: 999px; gap: 2px; justify-self: start; flex-wrap: wrap; }
.segmented button { border: 0; background: none; padding: 7px 14px; border-radius: 999px; cursor: pointer; font-weight: 600; color: var(--muted); }
.segmented button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-size: .88rem; margin-bottom: 6px; }
.back svg { width: 16px; height: 16px; }
.back:hover { color: var(--accent); }
.row-between { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.client-pill { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 38px; padding: 0 4px 0 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.progress-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.progress-row .check { flex: none; }
table.list tr.group td { background: var(--surface-2); font-weight: 650; font-size: .84rem; color: var(--muted); padding: 7px 12px; }
.template-layout { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 20px; align-items: start; }
.template-layout .preview-frame { position: sticky; top: 16px; height: calc(100vh - 60px); }
.input.color { padding: 2px; height: 38px; cursor: pointer; }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.notes { white-space: pre-wrap; margin: 0; padding: 10px 12px; background: var(--surface-2); border-radius: var(--radius-sm); }
dialog.modal[open] { animation: pop .16s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@media (prefers-reduced-motion: reduce) { dialog.modal[open] { animation: none; } }
details > summary { cursor: pointer; }
@media (max-width: 900px) {
  .action-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .action-card { padding: 14px; }
  .template-layout { grid-template-columns: 1fr; }
  .template-layout .preview-frame { position: static; height: 70vh; }
}

/* ---------- Signature ---------- */
.sign-box { position: relative; border: 1px dashed var(--accent); border-radius: var(--radius); background: #fff; }
.sign-canvas { display: block; width: 100%; height: 230px; touch-action: none; cursor: crosshair; border-radius: var(--radius); }
.sign-line { position: absolute; left: 24px; right: 24px; bottom: 46px; border-top: 1px solid #c7d4d8; padding-top: 4px; font-size: .78rem; color: #6d7f84; pointer-events: none; }
.signed-box { display: grid; gap: 6px; padding: 10px 12px; border: 1px solid var(--ok-soft); background: color-mix(in srgb, var(--ok-soft) 50%, var(--surface)); border-radius: var(--radius-sm); }
.signed-box img { max-width: 220px; max-height: 80px; background: #fff; border-radius: 4px; }
@media (max-width: 900px) { .sign-canvas { height: 46vh; } }
.grid > .chip, .panel-body > .chip { justify-self: start; }

/* --- Planning, interventions, piscine, photos, historique, comptabilité --- */
.tabs a { padding: 10px 12px; font-weight: 600; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.tabs a.active { color: var(--accent-strong); border-bottom-color: var(--accent); }
.tabs .count { background: var(--surface-2); color: var(--muted); border-radius: 999px; padding: 0 7px; font-size: .75rem; }
.tabs a.active .count { background: var(--lac-soft); color: var(--lac-ink); }
.day { display: grid; gap: 8px; }
.day-title { font-size: .95rem; color: var(--muted); margin: 6px 0 0; }
.day-title.danger { color: var(--danger); }
.visit-list { display: grid; gap: 8px; }
.visit { display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center; padding: 14px 16px; background: var(--surface); border: 1px solid transparent; border-radius: var(--radius); color: inherit; text-decoration: none; box-shadow: var(--shadow); }
.visit.next { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.visit:hover { box-shadow: var(--shadow-lift); }
.visit-time { font-weight: 800; font-size: 1.05rem; font-variant-numeric: tabular-nums; color: var(--ink); text-align: center; }
.visit-time svg { width: 20px; height: 20px; color: var(--ok); }
.visit-main { display: grid; gap: 2px; min-width: 0; }
.visit-main > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 600px) { .visit { grid-template-columns: 48px 1fr; } .visit > :last-child { grid-column: 2; } }
.simple-line { display: grid; grid-template-columns: minmax(0, 3fr) 70px 90px 100px 90px 36px; gap: 6px; align-items: center; }
.simple-line.no-price { grid-template-columns: minmax(0, 3fr) 70px 70px 36px; }
@media (max-width: 700px) {
  .simple-line { grid-template-columns: 52px minmax(0, 1fr) minmax(0, 1.2fr) 74px 32px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
  .simple-line.no-price { grid-template-columns: 52px minmax(0, 1fr) 32px; }
  .simple-line > :first-child { grid-column: 1 / -1; }
}
.pool-card { display: grid; gap: 4px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.pool-facts { display: grid; gap: 3px; padding: 10px 12px; background: var(--accent-soft); border-radius: var(--radius-sm); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.thumb { padding: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); cursor: pointer; display: grid; color: var(--muted); font-size: .75rem; }
.thumb img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.thumb span { padding: 3px 6px; text-align: left; }
details.panel > summary { cursor: pointer; list-style: none; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary h2::after { content: " ▸"; color: var(--muted); }
details.panel[open] > summary h2::after { content: " ▾"; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--line); display: grid; gap: 10px; }
.timeline li { display: grid; gap: 1px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -20px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.todo { list-style: none; margin: 0; padding: 0; display: grid; }
.todo a { display: grid; grid-template-columns: 10px 1fr auto; gap: 16px; align-items: center; padding: 14px 22px; color: inherit; text-decoration: none; border-top: 1px solid var(--line); }
.todo li:first-child a { border-top: 0; }
.todo a:hover { background: var(--surface-2); }
.todo .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.todo .dot { background: var(--lac); }
.todo .dot.urgent { background: var(--danger); }
.todo .dot.soon { background: var(--bulle); }
.todo .go { font-size: .87rem; font-weight: 700; padding: 7px 12px; border-radius: 10px; background: var(--surface-2); color: var(--ink); white-space: nowrap; }
.todo a:hover .go { background: var(--accent); color: var(--accent-ink); }
.todo .t { display: grid; gap: 1px; }
.contract { display: grid; gap: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.contract.stopped { opacity: .6; }
.list.vat-table td, .list.vat-table th { text-align: right; }
.list.vat-table td:first-child, .list.vat-table th:first-child { text-align: left; }
.downloads { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.download { display: grid; gap: 4px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); text-align: left; cursor: pointer; color: inherit; font: inherit; }
.download:hover { border-color: var(--accent); }
.download strong { color: var(--accent-strong); }
.map-table select { min-width: 160px; }
.import-drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 30px 16px; text-align: center; display: grid; gap: 10px; justify-items: center; }
.import-drop.over { border-color: var(--accent); background: var(--accent-soft); }
.day-title::first-letter { text-transform: uppercase; }
@media (max-width: 900px) { .cols-main > .first-mobile { order: -1; } }
.visit-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) 32px; gap: 8px; align-items: center; }
.pair-grid { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 22px; align-items: start; }
.qr { background: #fff; padding: 8px; border-radius: var(--radius); border: 1px solid var(--line); line-height: 0; }
.qr svg { width: 240px; height: 240px; }
@media (max-width: 700px) { .pair-grid { grid-template-columns: 1fr; justify-items: center; } }
.steps.big { font-size: 1.08rem; display: grid; gap: 12px; padding-left: 1.3em; }
.pair-card > img { justify-self: center; }
.share-icon { display: inline-block; color: var(--accent); font-weight: 700; }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.theme-card { display: grid; gap: 3px; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); cursor: pointer; text-align: left; font: inherit; color: inherit; }
.theme-card:hover { border-color: var(--accent); }
.theme-card.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.theme-card .small { line-height: 1.25; }
.theme-mini { background: #fff; border: 1px solid #e3e8ea; border-radius: 4px; padding: 6px; display: grid; gap: 3px; margin-bottom: 4px; }
.tm-top { display: flex; justify-content: space-between; align-items: center; }
.tm-logo { width: 14px; height: 14px; border-radius: 3px; }
.tm-title { width: 34px; height: 6px; border-radius: 2px; }
.tm-water { height: 3px; }
.tm-head { height: 9px; border-radius: 2px; border-bottom: 1px solid; display: flex; align-items: center; padding: 0 4px; }
.tm-head span, .tm-row span { height: 2px; width: 60%; border-radius: 1px; opacity: .8; }
.tm-row { height: 7px; display: flex; align-items: center; padding: 0 4px; }
.tm-row span { opacity: .35; }
.tm-total { justify-self: end; width: 45%; height: 8px; border-top: 1px solid; display: flex; align-items: center; justify-content: flex-end; }
.tm-total span { width: 50%; height: 3px; border-radius: 1px; }
/* Glisser-déposer des lignes */
.line .grip { border: 0; background: none; width: 26px; height: 32px; padding: 0; color: var(--muted); cursor: grab; touch-action: none; border-radius: 6px; font-size: 1.15rem; line-height: 1; }
.line .grip:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.line .grip:focus-visible { outline: 2px solid var(--accent); }
.line .grip:disabled { cursor: default; opacity: .35; }
.lines.drag-active .line { transition: transform .15s ease; }
.lines.drag-active, .lines.drag-active * { cursor: grabbing !important; user-select: none; }
.line.dragging { position: relative; z-index: 5; transition: none !important; box-shadow: 0 10px 28px rgba(16, 52, 61, .22); border-radius: var(--radius-sm); }
.line.dropped { animation: dropped .7s ease-out; }
@keyframes dropped { from { background: var(--accent-soft); } }
@media (prefers-reduced-motion: reduce) { .lines.drag-active .line { transition: none; } .line.dropped { animation: none; } }
.client-notice { display: flex; flex-wrap: wrap; gap: 6px; }
.client-notice p { margin: 0; white-space: normal; }
details.intl > summary { cursor: pointer; }
/* Barre de filtres */
.filter-bar { display: grid; gap: 8px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filter-row .search { flex: 1 1 260px; max-width: none; }
.filter-toggle { display: inline-flex; align-items: center; gap: 6px; }
.filter-toggle .count { background: var(--bulle); color: #172233; border-radius: 999px; padding: 0 7px; font-size: .75rem; font-weight: 700; }
.filter-toggle[aria-expanded="true"] { border-color: var(--accent); background: var(--accent-soft); }
.sort-wrap { display: inline-flex; align-items: center; gap: 6px; }
.sort-wrap .input { min-height: 40px; padding: 6px 12px; width: auto; }
.filter-panel { padding: 16px 18px; border: 0; box-shadow: var(--shadow); border-radius: var(--radius); background: var(--surface); display: grid; gap: 10px; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px 14px; align-items: end; }
.period-custom { display: flex; gap: 6px; align-items: center; margin-top: 6px; }
.period-custom .input { min-width: 0; flex: 1; }
.toggle-filter { padding: 9px 0; }
.filter-summary { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 22px; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip.removable { border: 0; cursor: pointer; font: inherit; font-size: .78rem; font-weight: 600; }
.chip.removable:hover { filter: brightness(.95); }
.list-foot { display: flex; justify-content: space-between; gap: 10px; padding: 12px 22px; border-top: 1px solid var(--line); flex-wrap: wrap; }
@media (max-width: 600px) { .sort-wrap > span { display: none; } .sort-wrap { flex: 1; } .sort-wrap .input { width: 100%; } }
.danger-text { color: var(--danger); }

/* ---------- Lagom : marque, accueil, journée sur téléphone ---------- */
.brand-mark { display: inline-flex; align-items: center; gap: 8px; }
.aplomb { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .92rem; }
.aplomb svg { width: 34px; height: 18px; flex: none; }
.home-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; }
.home-head h1 { font-size: 2.1rem; }
.home-head .sub { color: var(--muted); margin-top: 6px; font-size: 1.02rem; }
.home-head .sub::first-letter { text-transform: uppercase; }
.hero { display: none; }
.todo-panel h2 { font-size: 1.15rem; }
.panel-head.plain { border-bottom: 0; padding-bottom: 6px; }
.btn.big { min-height: 54px; font-size: 1.05rem; border-radius: 16px; }
@media (max-width: 900px) {
  .home-head { display: none; }
  .hero {
    display: grid; gap: 14px; margin: -16px calc(-1 * max(14px, env(safe-area-inset-right))) 0 calc(-1 * max(14px, env(safe-area-inset-left)));
    padding: calc(18px + env(safe-area-inset-top)) 20px 22px; background: var(--side, #24466e); color: #ffffff;
    border-radius: 0 0 28px 28px;
  }
  .hero-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
  .hero-top .brand-mark strong { font-size: 1.15rem; font-weight: 800; letter-spacing: -.02em; }
  .hero-top .brand-mark svg { width: 40px; height: 22px; }
  .hero-top .muted { color: #c9d6e6; font-size: .84rem; }
  .hero .date { color: #c9d6e6; font-size: .95rem; }
  .hero .date::first-letter { text-transform: uppercase; }
  .hero h1 { font-size: 1.9rem; color: inherit; }
  .hero-visits { display: grid; gap: 10px; }
  .hero-visits .visit { color: var(--ink); }
  .hero-actions { display: grid; }
  .hero .btn.big { background: var(--bulle); border-color: var(--bulle); color: #172233; }
  .home-kpis .kpi .value { font-size: 1.35rem; }
  .main { padding-top: 16px; }
  .tabbar { box-shadow: 0 -4px 18px rgba(23, 34, 51, .06); border-top-color: transparent; padding-top: 6px; }
  .tabbar a { font-size: .72rem; font-weight: 650; padding: 6px 2px 8px; }
  .tabbar a[aria-current="page"] { color: var(--accent); font-weight: 800; }
  .tabbar a[data-nav="new"] svg { background: var(--accent); color: var(--accent-ink); border-radius: 12px; padding: 4px; width: 32px; height: 32px; margin-top: -4px; }
  .page-head h1 { font-size: 1.5rem; }
  .panel-head { padding: 16px 16px 12px; }
  .panel-body { padding: 16px; }
  table.list th:first-child, table.list td:first-child { padding-left: 14px; }
  table.list th:last-child, table.list td:last-child { padding-right: 14px; }
  .todo a { padding: 13px 16px; grid-template-columns: 10px 1fr; }
  .todo .go { display: none; }
}
.main:focus, .main:focus-visible { outline: none; }
.rank a { color: var(--ink); text-decoration: none; font-weight: 550; }
.rank a:hover { color: var(--accent); text-decoration: underline; }
.cols-2 { align-items: start; }
.btn.ghost:hover { background: var(--surface-2); }
.kpi.feature { background: var(--bulle-soft); color: var(--ink); }
.kpi.feature .label { color: var(--muted); }
.kpi.feature .detail { color: var(--warn); }

/* Apparence : automatique, clair ou sombre (Réglages › Appareils, et petite icône sur le téléphone) */
.theme-switch { display: inline-flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--surface-2); }
.theme-switch button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px; padding: 0 12px; border: 0; border-radius: 9px; background: none; color: var(--muted); font: inherit; font-size: .86rem; font-weight: 650; cursor: pointer; }
.theme-switch button:hover { color: var(--ink); }
.theme-switch button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.theme-switch svg { width: 15px; height: 15px; }
.hero-theme { border: 0; background: rgba(255, 255, 255, .12); color: #fff; border-radius: 50%; width: 36px; height: 36px; padding: 0; display: inline-grid; place-items: center; }
.hero-theme svg { width: 17px; height: 17px; }
.hero-theme .lbl { display: none; }
.visit > .chip { justify-self: start; }
/* Présentation (premier lancement) */
dialog.modal.intro { width: min(520px, calc(100vw - 24px)); overflow: hidden; }
.intro-body { position: relative; padding: 36px 32px 14px; display: grid; gap: 12px; justify-items: center; text-align: center; min-height: 340px; align-content: start; }
.intro-body h2 { font-size: 1.45rem; font-weight: 800; letter-spacing: -.02em; margin-top: 6px; }
.intro-body p { margin: 0; color: var(--muted); font-size: 1.02rem; line-height: 1.55; max-width: 420px; }
.intro-art { width: 96px; height: 96px; border-radius: 28px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.intro-art svg { width: 44px; height: 44px; }
.intro-art.is-mark { width: 150px; background: #24466e; color: #fff; }
.intro-art.is-mark svg { width: 104px; height: 58px; }
.intro-dots { display: flex; gap: 6px; margin-top: auto; padding-top: 10px; }
.intro-dots span { width: 7px; height: 7px; border-radius: 999px; background: var(--line); transition: width .2s ease, background .2s ease; }
.intro-dots span.on { width: 22px; background: var(--bulle); }
.intro-skip { position: absolute; top: 10px; right: 10px; font-size: .86rem; min-height: 32px; }
.intro-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 24px 20px; border-top: 1px solid var(--line); }
.intro-foot .check { color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .intro-dots span { transition: none; } }
.hero-help { border: 0; background: rgba(255, 255, 255, .12); color: #fff; border-radius: 50%; width: 36px; height: 36px; font: inherit; font-weight: 800; font-size: 1rem; }
.intro-foot .actions { margin-left: auto; }
