/* CODA CRM : barre blanche et menus texte, onglets arrondis, accueil en grille d'icones (style valide pour la box). */
:root {
  --bg: #f4f6fa; --surface: #ffffff; --surface-2: #eef2f8; --line: #dde3ec;
  --fg: #1a2333; --muted: #5d6879; --brand: #1e437d; --brand-soft: #e3ebf7; --on-brand: #ffffff;
  --ok: #1f7a4d; --ok-soft: #e1f3e9; --warn: #a15c00; --warn-soft: #fbefdc;
  --bad: #b3261e; --bad-soft: #fbe4e2; --mail: #0b6aa8; --mail-soft: #e0f0fa;
  --shadow: 0 10px 30px rgba(20, 30, 50, .18);
  /* Contrat : le papier reste blanc dans les deux themes, comme le PDF. */
  --paper: #ffffff; --ink: #1b1f27; --ink-soft: #555c68; --paper-line: #c9ced8; --paper-accent: #1e437d;
  --var: #e8eefb; --var-ink: #1e437d; --miss: #fdecc8; --miss-ink: #7a4500; --desk: #dde2ea;
  --c-devis: #7a4fb5; --c-devis-soft: #efe8f8;
  --font: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141c; --surface: #171e29; --surface-2: #1f2835; --line: #2c3746;
    --fg: #e6ebf2; --muted: #9aa6b8; --brand: #8fb3ec; --brand-soft: #1f3253; --on-brand: #0f141c;
    --ok: #5fcf95; --ok-soft: #173326; --warn: #f0b562; --warn-soft: #3a2a12;
    --bad: #f08a82; --bad-soft: #3d1b19; --mail: #6cc0f2; --mail-soft: #12304a;
    --shadow: 0 10px 30px rgba(0, 0, 0, .5);
    --desk: #0b0f15;
    --c-devis: #c3a4ef; --c-devis-soft: #2c2140;
    color-scheme: dark;
  }
}

* { box-sizing: border-box }
html, body { margin: 0 }
body { background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 15px; line-height: 1.45 }
button, input, select, textarea { font: inherit; color: inherit }
button { cursor: pointer }
a { color: var(--brand) }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px }
.num { font-variant-numeric: tabular-nums }
.muted { color: var(--muted) }
.small { font-size: 13px }
[hidden] { display: none !important }

/* Barre */
header.bar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding: 10px 16px }
.logo { font-weight: 700; letter-spacing: .02em; color: var(--brand); font-size: 17px; white-space: nowrap; background: none; border: 0; padding: 0 }
.logo span { color: var(--fg); font-weight: 400 }
nav.menus { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; min-width: 0 }
nav.menus button { background: none; border: 0; padding: 6px 10px; border-radius: 8px; color: var(--muted); position: relative }
nav.menus button:hover { background: var(--surface-2); color: var(--fg) }
nav.menus button.on { color: var(--brand); font-weight: 700 }
nav.menus .badge { position: absolute; top: 0; right: 0; min-width: 16px; height: 16px; border-radius: 8px; background: var(--mail); color: var(--on-brand); font-size: 10.5px; line-height: 16px; padding: 0 4px; font-weight: 700 }
.search-btn { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; color: var(--muted); background: var(--bg); min-width: 0 }
.search-btn kbd, kbd { font-family: var(--mono); font-size: 11px; border: 1px solid var(--line); border-radius: 4px; padding: 0 4px }
.user-btn { background: none; border: 0; color: var(--muted); font-size: 13.5px }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 10px 16px 0 }
.tab { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 10px 10px 0 0; padding: 5px 8px 5px 12px; white-space: nowrap; color: var(--muted); font-size: 14px; max-width: 260px }
.tab .t { overflow: hidden; text-overflow: ellipsis; background: none; border: 0; padding: 0; color: inherit; font-weight: inherit }
.tab.on { background: var(--surface); color: var(--fg); font-weight: 700 }
.tab .x { background: none; border: 0; color: var(--muted); padding: 0 4px; border-radius: 4px; line-height: 1; font-size: 16px }
.tab .x:hover { background: var(--line) }

main { padding: 20px 16px 48px; max-width: 1320px; margin: 0 auto }
h1 { font-size: 24px; margin: 0 0 4px; text-wrap: balance }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 10px; font-weight: 700 }
h3 { font-size: 16px; margin: 0 }
.sub { color: var(--muted); margin: 0 0 18px }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; min-width: 0 }
.stack { display: grid; gap: 16px; align-content: start; min-width: 0 }
.row-between { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap }
.empty { color: var(--muted); padding: 18px 4px; text-align: center }
.loading { color: var(--muted); padding: 30px; text-align: center }

/* Accueil */
.home { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 24px }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 18px; margin-bottom: 22px }
.tile { display: flex; gap: 12px; align-items: flex-start; text-align: left; background: none; border: 0; padding: 10px; border-radius: 10px }
.tile:hover:not([disabled]) { background: var(--surface) }
.tile[disabled] { opacity: .6; cursor: default }
.ico { flex: none; width: 40px; height: 40px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center }
.ico svg, .fi svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round }
.tile b { display: block } .tile small { color: var(--muted); font-size: 13px }
.list { list-style: none; margin: 0; padding: 0 }
.list > li { display: flex; gap: 10px; align-items: baseline; padding: 9px 0; border-top: 1px solid var(--line) }
.list > li:first-child { border-top: 0 }
.list > li .end { margin-left: auto; color: var(--muted); font-size: 13px; white-space: nowrap; text-align: right }
.list > li .grow { min-width: 0; overflow-wrap: anywhere }
.list > li.link { cursor: pointer } .list > li.link:hover .grow b { text-decoration: underline }
.notice { border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 14px }
.notice.warn { background: var(--warn-soft); color: var(--warn) }
.notice.bad { background: var(--bad-soft); color: var(--bad) }
.notice.ok { background: var(--ok-soft); color: var(--ok) }
.notice.info { background: var(--mail-soft); color: var(--mail) }

/* Etiquettes */
.chip { display: inline-block; font-size: 12px; border-radius: 999px; padding: 1px 9px; font-weight: 700; white-space: nowrap; vertical-align: 1px }
.c-brand { background: var(--brand-soft); color: var(--brand) } .c-ok { background: var(--ok-soft); color: var(--ok) }
.c-warn { background: var(--warn-soft); color: var(--warn) } .c-bad { background: var(--bad-soft); color: var(--bad) }
.c-mail { background: var(--mail-soft); color: var(--mail) } .c-grey { background: var(--surface-2); color: var(--muted) }

/* Tableaux */
.tw { overflow-x: auto }
table { width: 100%; border-collapse: collapse; font-size: 14px }
th { text-align: left; color: var(--muted); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top }
tr:last-child td { border-bottom: 0 }
tr.link { cursor: pointer } tr.link:hover td { background: var(--surface-2) }
td.r, th.r { text-align: right }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px }
.toolbar .spacer { flex: 1 }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 6px 12px; font-size: 14px; white-space: nowrap }
.btn:hover { border-color: var(--muted) }
.btn.pri { background: var(--brand); border-color: var(--brand); color: var(--on-brand); font-weight: 700 }
.btn.danger { color: var(--bad) }
.btn.small { padding: 3px 9px; font-size: 13px }
a.btn { text-decoration: none; color: inherit; display: inline-block }
.btn[disabled] { opacity: .55; cursor: default }
.filter { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 3px 11px; font-size: 13px; color: var(--muted) }
.filter.on { border-color: var(--brand); color: var(--brand); font-weight: 700 }
.input, input[type=text], input[type=email], input[type=search], input[type=number], input[type=date], input[type=time], input[type=datetime-local], input[type=password], select, textarea {
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 6px 10px; width: 100%; min-width: 0 }
textarea { resize: vertical; min-height: 70px }
.toolbar input[type=search] { width: min(320px, 100%) }

/* Fiches */
.fiche { display: grid; grid-template-columns: minmax(0, 320px) minmax(0, 1fr); gap: 20px }
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 12px; font-size: 14px; margin: 0 }
.kv dt { color: var(--muted) } .kv dd { margin: 0; overflow-wrap: anywhere; white-space: pre-line }
.person { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); cursor: pointer }
.person:first-of-type { border-top: 0 }
.person:hover b { text-decoration: underline }
.av { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none }
.person small { display: block; color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere }
.subtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto }
.subtabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 12px; color: var(--muted); white-space: nowrap }
.subtabs button.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 700 }
.subtabs button[disabled] { opacity: .55; cursor: default }
.compose { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; align-items: center }
.compose .spacer { flex: 1 }
.feed { list-style: none; margin: 0; padding: 0 }
.feed > li { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; padding: 12px 0; border-top: 1px solid var(--line) }
.feed > li:first-child { border-top: 0 }
.fi { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center }
.fi svg { width: 17px; height: 17px }
.meta { font-size: 13px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center }
.feed p { margin: 4px 0 0; white-space: pre-line; overflow-wrap: anywhere }
.quote { margin-top: 6px; padding: 8px 12px; border-left: 3px solid var(--mail); background: var(--mail-soft); border-radius: 0 8px 8px 0; font-size: 14px; white-space: pre-line; overflow-wrap: anywhere }
.mailbody { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; max-height: 60vh; overflow: auto }
.linkish { background: none; border: 0; padding: 0; color: var(--brand); text-decoration: underline; font-size: inherit }
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px }
.files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px }
.file { display: inline-flex; gap: 6px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 2px 8px; font-size: 13px; background: var(--surface) }
.file button { background: none; border: 0; padding: 0; color: var(--muted) }

/* Pipeline */
.kanban { display: grid; grid-template-columns: repeat(6, minmax(200px, 1fr)); gap: 10px; overflow-x: auto; padding-bottom: 6px }
.col { background: var(--surface-2); border-radius: 12px; padding: 10px; min-width: 0; min-height: 120px; transition: background .12s }
.col.over { background: var(--brand-soft) }
.col > header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; gap: 6px }
.col > header b { font-size: 14px } .col > header span { color: var(--muted); font-size: 12.5px }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px; font-size: 13.5px; cursor: grab }
.card.dragging { opacity: .5 }
.card b { display: block; font-size: 14px }
.card .row { display: flex; justify-content: space-between; color: var(--muted); margin-top: 6px; gap: 6px }
.card .late { color: var(--bad); font-weight: 700 }
.card.won { border-color: var(--ok) } .card.lost { border-color: var(--bad) }
.card select { margin-top: 6px; font-size: 12.5px; padding: 2px 6px; display: none }
@media (hover: none) { .card select { display: block } }

/* Devis */
.devis { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 20px; align-items: start }
.lines td { padding: 4px 4px; vertical-align: middle }
.lines td:first-child { width: 100%; min-width: 220px }
.lines td.num { white-space: nowrap }
.lines input, .lines select, .lines textarea { padding: 4px 6px; font-size: 13.5px }
.lines .w-qty { width: 58px } .lines .w-price { width: 92px } .lines .w-pct { width: 52px } .lines .w-unit { width: 56px }
.lines tr.section input.desig { font-weight: 700 }
.lines tr.text input.desig { font-style: italic }
.lines .tools { white-space: nowrap }
.lines .tools button { background: none; border: 0; color: var(--muted); padding: 2px 4px }
.lines textarea.desc { min-height: 30px; margin-top: 3px; font-size: 12.5px }
.totals { margin-left: auto; width: min(320px, 100%); font-size: 14px }
.totals div { display: flex; justify-content: space-between; padding: 3px 0 }
.totals .ttc { border-top: 2px solid var(--fg); font-weight: 700; font-size: 16px; margin-top: 4px; padding-top: 6px }
.pdf { width: 100%; height: 78vh; border: 1px solid var(--line); border-radius: 8px; background: var(--surface) }

/* Contrats : formulaire a gauche, papier a droite (meme structure que le PDF) */
.contrat { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 20px; align-items: start }
.sep { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; margin: 14px 0 8px; padding-top: 10px; border-top: 1px solid var(--line) }
.desk { background: var(--desk); border-radius: 12px; padding: 18px; min-width: 0 }
.paper { background: var(--paper); color: var(--ink); font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 12.5px; line-height: 1.5; max-width: 780px; margin: 0 auto; padding: 40px 48px 28px; box-shadow: var(--shadow); border-radius: 2px }
.paper .dh { display: flex; justify-content: space-between; gap: 16px; border-bottom: 2px solid var(--paper-accent); padding-bottom: 10px; margin-bottom: 20px }
.paper .dh .co { font-weight: 700; color: var(--paper-accent); font-size: 15px }
.paper .dh .ref { text-align: right; font-size: 11px; color: var(--ink-soft) }
.paper h1.dt { font-size: 18px; text-align: center; margin: 0 0 4px; color: var(--paper-accent); text-transform: uppercase; letter-spacing: .02em }
.paper .ds { text-align: center; color: var(--ink-soft); margin: 0 0 18px; font-size: 12px }
.paper .between { font-size: 11px; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .06em; margin: 0 0 6px; text-align: left }
.paper .party { border-left: 3px solid var(--paper-line); padding-left: 10px; margin-bottom: 8px }
.paper .and { text-align: center; font-weight: 700; margin: 4px 0 8px }
.paper .agreed { font-style: italic }
.paper h4 { font-size: 12.5px; margin: 16px 0 5px; color: var(--paper-accent) }
.paper p { margin: 0 0 7px; text-align: justify; hyphens: auto }
.paper ul { margin: 0 0 7px; padding-left: 18px; list-style: "–  " }
.paper li { margin-bottom: 3px; text-align: justify }
.paper table.sla { margin: 6px 0 10px; font-size: 11.5px }
.paper table.sla th, .paper table.sla td { border: 1px solid var(--paper-line); padding: 5px 6px; color: var(--ink); text-transform: none; letter-spacing: 0; font-size: 11.5px; white-space: normal }
.paper table.sla th { background: #eef2f8 }
.paper .v { background: var(--var); color: var(--var-ink); border-radius: 3px; padding: 0 2px }
.paper .m { background: var(--miss); color: var(--miss-ink); border-radius: 3px; padding: 0 2px; font-weight: 700 }
.paper .optmark { font-size: 10px; font-weight: 700; color: #1f7a4d; border: 1px solid #1f7a4d; border-radius: 3px; padding: 0 3px; margin-left: 6px; vertical-align: 1px }
.paper .closing { margin-top: 16px }
.paper .sign { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 12px }
.paper .sigbox { border: 1px solid var(--paper-line); padding: 10px; min-height: 140px; font-size: 11.5px; display: flex; flex-direction: column }
.paper .sigbox .lu { color: var(--ink-soft); margin-top: auto; border-top: 1px dotted var(--paper-line); padding-top: 4px }
.paper .foot { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 22px; padding-top: 8px; border-top: 1px solid var(--paper-line); font-size: 10.5px; color: var(--ink-soft) }
.paper .foot .par { white-space: nowrap }
.steps-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 }
.step { border-top: 4px solid var(--line); padding: 6px 6px 0 0; font-size: 13px; color: var(--muted); min-width: 0 }
.step b { display: block; color: var(--fg); font-size: 14px }
.step.done { border-color: var(--ok) }
.doc { display: flex; gap: 10px; align-items: center; padding: 6px 0; font-size: 14px }
.doc .grow { flex: 1; min-width: 0; overflow-wrap: anywhere }
.fi.pdf { width: 30px; height: 36px; border-radius: 4px; border: 1px solid var(--line); font-size: 9px; font-weight: 700; color: var(--bad); background: var(--surface-2) }
.art { display: flex; gap: 10px; align-items: center; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; font-size: 14px; background: var(--surface); flex-wrap: wrap }
.art.open { border-color: var(--brand) }
.art .n { color: var(--muted); min-width: 1.6em }
.art .grow { flex: 1; min-width: 0 }
.art .tools button { background: none; border: 0; color: var(--muted); padding: 2px 4px }
.arted { margin: 0 0 12px; padding: 12px; border: 1px solid var(--brand); border-top: 0; border-radius: 0 0 8px 8px; margin-top: -8px }
.arted textarea { min-height: 180px; line-height: 1.5 }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px }
.chip-var { font-family: var(--mono); font-size: 12px; border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; background: var(--brand-soft); color: var(--brand) }
@media (max-width: 1100px) { .contrat { grid-template-columns: minmax(0, 1fr) } }
@media (max-width: 600px) { .steps-row { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 10px } .paper { padding: 24px 16px 18px } .paper .sign { grid-template-columns: 1fr } .desk { padding: 8px } }

/* Documents : depot, filtres par type, vignettes, visionneuse */
.drop { border: 2px dashed var(--line); border-radius: 12px; padding: 12px 14px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; background: var(--surface-2) }
.drop.over { border-color: var(--brand); background: var(--brand-soft) }
.drop p { margin: 0; flex: 1; min-width: 200px; color: var(--muted); font-size: 13.5px }
.drop-ico svg { width: 28px; height: 28px; fill: none; stroke: var(--brand); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; display: block }
.filters { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 12px }
.filters .spacer { flex: 1 }
.filters input[type=search] { width: min(220px, 100%) }
.viewmode { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden }
.viewmode button { border: 0; background: var(--surface); padding: 4px 10px; font-size: 13px; color: var(--muted) }
.viewmode button.on { background: var(--brand-soft); color: var(--brand); font-weight: 700 }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px }
.doc-card { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow: hidden; text-align: left; padding: 0; display: flex; flex-direction: column; min-width: 0 }
.doc-card:hover { border-color: var(--brand) }
.doc-card .thumb { aspect-ratio: 4 / 3; max-width: 100%; background: var(--surface-2); border-bottom: 1px solid var(--line); display: grid; place-items: center; position: relative; overflow: hidden }
.doc-card .thumb img { width: 100%; height: 100%; object-fit: cover }
.big { font-family: var(--mono); font-weight: 700; font-size: 18px; color: var(--muted); border: 2px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--surface) }
.big.is-pdf { color: var(--bad); border-color: var(--bad-soft) }
.doc-card .chip { max-width: 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis }
.thumb .ext { position: absolute; left: 6px; bottom: 6px; font-family: var(--mono); font-size: 11px; font-weight: 700; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; color: var(--muted) }
.thumb .ver { position: absolute; top: 6px; right: 6px }
.doc-card .info { padding: 8px 10px 10px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; min-width: 0; font-size: 12.5px }
.doc-card .info b { font-size: 13.5px; overflow-wrap: anywhere }
.doc-card .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: 12px }
.k-devis { background: var(--c-devis-soft); color: var(--c-devis) } .k-plan { background: var(--ok-soft); color: var(--ok) } .k-syn { background: var(--mail-soft); color: var(--mail) }
.k-photo { background: var(--warn-soft); color: var(--warn) } .k-tech { background: var(--surface-2); color: var(--fg) } .k-autre { background: var(--surface-2); color: var(--muted) }
.mails { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px }
.mailrow { display: flex; gap: 10px; align-items: center; padding: 7px 0; border-top: 1px solid var(--line); font-size: 14px; flex-wrap: wrap }
.mailrow:first-of-type { border-top: 0 }
.mailrow .grow { flex: 1; min-width: 180px; overflow-wrap: anywhere }
.uprow { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: 10px; align-items: center; padding: 10px 18px; border-top: 1px solid var(--line) }
.uprow small { display: block } .bad-text { color: var(--bad) !important }
dialog.viewer-dlg { width: min(1180px, calc(100vw - 24px)); height: min(860px, calc(100vh - 32px)) }
.viewer { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 300px); height: 100% }
.viewer .stage { background: var(--surface-2); position: relative; display: grid; place-items: center; min-height: 0; overflow: hidden }
.viewer .stage iframe { width: 100%; height: 100%; border: 0; background: var(--surface) }
.viewer .stage img { max-width: 100%; max-height: 100%; object-fit: contain }
.viewer .noview { text-align: center; padding: 24px; display: grid; gap: 12px; justify-items: center; color: var(--muted) }
.viewer .nav { position: absolute; top: 50%; transform: translateY(-50%); border: 1px solid var(--line); background: var(--surface); border-radius: 50%; width: 38px; height: 38px; font-size: 20px; line-height: 1; z-index: 1 }
.viewer .prev { left: 10px } .viewer .next { right: 10px }
.viewer .details { padding: 16px; display: grid; gap: 12px; align-content: start; overflow: auto; border-left: 1px solid var(--line) }
.versions { list-style: none; margin: 0; padding: 0; font-size: 13.5px }
.versions li { display: flex; gap: 8px; padding: 5px 0; border-top: 1px solid var(--line); align-items: baseline } .versions li:first-child { border-top: 0 }
.versions .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; color: var(--muted) }
@media (max-width: 900px) { .viewer { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(260px, 55%) auto } .viewer .details { border-left: 0; border-top: 1px solid var(--line) } dialog.viewer-dlg { height: calc(100vh - 32px) } }
@media (max-width: 560px) { .uprow { grid-template-columns: minmax(0, 1fr) } .doc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) } }

/* Parametres */
.settings { display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr); gap: 20px; align-items: start }
.side { display: grid; gap: 2px }
.side button { text-align: left; background: none; border: 0; padding: 8px 12px; border-radius: 8px; color: var(--muted) }
.side button.on { background: var(--surface); color: var(--brand); font-weight: 700 }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14px }
.opt:first-of-type { border-top: 0 }
.opt input[type=checkbox] { margin-top: 4px }
.opt small { display: block; color: var(--muted) }
.status { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 12px; border-radius: 10px; margin-bottom: 12px; font-size: 14px }
.status.ok { background: var(--ok-soft); color: var(--ok) } .status.off { background: var(--surface-2); color: var(--muted) } .status.bad { background: var(--bad-soft); color: var(--bad) }
.code { font-family: var(--mono); font-size: 26px; letter-spacing: .12em; font-weight: 700; color: var(--brand) }
.steps { margin: 0; padding-left: 20px } .steps li { margin: 6px 0 }

/* Formulaires et dialogues */
dialog { border: 0; border-radius: 14px; padding: 0; background: var(--surface); color: var(--fg); box-shadow: var(--shadow); width: min(680px, calc(100vw - 24px)); max-height: calc(100vh - 32px) }
dialog.wide { width: min(980px, calc(100vw - 24px)) }
dialog::backdrop { background: rgba(10, 16, 28, .45) }
dialog form, dialog .dlg { display: flex; flex-direction: column; max-height: calc(100vh - 32px) }
dialog header { padding: 16px 18px 6px; display: flex; justify-content: space-between; gap: 10px; align-items: center }
dialog header h3 { font-size: 18px }
dialog .body { padding: 8px 18px 12px; overflow: auto }
dialog footer { padding: 12px 18px 16px; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; border-top: 1px solid var(--line) }
dialog footer .spacer { flex: 1 }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px }
.field { display: grid; gap: 4px; min-width: 0; align-content: start }
.field.full { grid-column: 1 / -1 }
.field > span { font-size: 13px; color: var(--muted); font-weight: 700 }
.field > small { color: var(--muted); font-size: 12.5px }
.field.check { display: flex; gap: 8px; align-items: flex-start }
.field.check > span { font-weight: 400; color: var(--fg); font-size: 14px }
.form-error { color: var(--bad); font-size: 14px; margin: 0 18px }
.repeat { display: grid; gap: 6px }
.repeat .item { display: flex; gap: 6px; align-items: center }
.repeat .item > * { min-width: 0 }

/* Palette Ctrl+K */
.palette { position: fixed; inset: 0; background: rgba(10, 16, 28, .45); z-index: 50; display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px }
.palette .box { background: var(--surface); border-radius: 14px; width: min(620px, 100%); box-shadow: var(--shadow); overflow: hidden }
.palette input { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 14px 16px; font-size: 17px }
.palette ul { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow: auto }
.palette li { display: flex; gap: 10px; align-items: baseline; padding: 8px 10px; border-radius: 8px; cursor: pointer }
.palette li.sel { background: var(--brand-soft) }
.palette li small { color: var(--muted); margin-left: auto; text-align: right }

/* Messages */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: grid; gap: 8px; max-width: min(420px, calc(100vw - 32px)) }
.toast { background: var(--fg); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); font-size: 14px }
.toast.bad { background: var(--bad); color: #fff }

@media (max-width: 960px) {
  .home, .fiche, .devis, .settings { grid-template-columns: minmax(0, 1fr) }
  .side { display: flex; flex-wrap: wrap }
}
@media (max-width: 760px) {
  header.bar { gap: 6px 12px; padding-bottom: 4px }
  nav.menus { order: 3; flex: 1 1 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none }
  nav.menus button { white-space: nowrap }
  .search-btn { margin-left: auto }
  header.bar { position: static }
}
@media (max-width: 600px) {
  .grid, .fields { grid-template-columns: minmax(0, 1fr) }
  .search-btn span { display: none }
  main { padding-top: 14px }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important } }
