:root {
  --bg: #f6f7f9; --card: #fff; --text: #1d2330; --muted: #6b7280; --line: #e3e6eb;
  --navy: #1f3864; --accent: #2f5aa8; --ok: #1d7a46; --warn: #b45309; --bad: #b42318;
  --ok-bg: #e6f4ec; --warn-bg: #fdf3e2; --bad-bg: #fde8e7;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c; --card: #1d2128; --text: #e6e8ec; --muted: #9aa3af; --line: #2d333c;
    --navy: #9db7e8; --accent: #8fb0f0; --ok: #6cd39a; --warn: #f0b35a; --bad: #f2867d;
    --ok-bg: #173325; --warn-bg: #3a2b14; --bad-bg: #3d1c1a;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); }
main { max-width: 1200px; margin: 0 auto; padding: 16px; }
.banner { background: var(--warn-bg); color: var(--warn); text-align: center; padding: 4px; font-weight: 600; }
header.top { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; color: var(--navy); text-decoration: none; font-size: 17px; }
.brand span { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
nav { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
nav a { text-decoration: none; color: var(--text); padding: 4px 2px; border-bottom: 2px solid transparent; }
nav a[aria-current=page] { border-color: var(--accent); color: var(--accent); }
h1 { font-size: 22px; color: var(--navy); margin: 8px 0 16px; }
h1 a { text-decoration: none; }
h2 { font-size: 17px; margin: 0 0 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; overflow-x: auto; }
.card.narrow { max-width: 440px; margin: 40px auto; }
.card.warn { border-color: var(--warn); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.grid > .card { margin-bottom: 0; }
.grid { margin-bottom: 16px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stats > div { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; }
.stats b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.stats span { color: var(--muted); font-size: 13px; }
table { width: 100%; border-collapse: collapse; }
table.card { padding: 0; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: 13px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.clos td { color: var(--muted); }
td.due { color: var(--bad); } td.credit { color: var(--ok); }
.muted { color: var(--muted); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: var(--bg); border: 1px solid var(--line); }
.tag.payée, .tag.ok, .tag.soldée { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.tag.partielle { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.tag.due, .tag.error { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.flash { background: var(--ok-bg); color: var(--ok); padding: 8px 12px; border-radius: 8px; }
.error { background: var(--bad-bg); color: var(--bad); padding: 8px 12px; border-radius: 8px; }
p.warn { color: var(--warn); }
form { margin: 0; }
form.inline { display: inline; }
label { display: block; margin: 0 0 10px; font-size: 13px; color: var(--muted); }
label.check { display: flex; gap: 6px; align-items: center; color: var(--text); font-size: 14px; }
label.check.small { display: inline-flex; font-size: 12px; margin-right: 6px; }
.row { display: flex; flex-wrap: wrap; gap: 0 12px; align-items: flex-end; }
.row label { flex: 1 1 140px; }
input, select, textarea { display: block; width: 100%; margin-top: 3px; padding: 7px 9px; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; }
input[type=checkbox] { width: auto; display: inline; margin: 0; }
input[size] { width: auto; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 10px; padding: 8px 12px; }
legend { font-size: 13px; color: var(--muted); }
button, .button { display: inline-block; padding: 8px 14px; font: inherit; font-weight: 600; color: #fff; background: var(--accent); border: 0; border-radius: 6px; cursor: pointer; text-decoration: none; margin-bottom: 10px; }
button[disabled] { opacity: .5; cursor: default; }
button.link { background: none; color: var(--accent); padding: 0; font-weight: 400; margin: 0; text-decoration: underline; }
button.link.danger { color: var(--bad); }
details { margin: 8px 0; }
summary { cursor: pointer; }
ul { padding-left: 20px; }
@media (max-width: 600px) { th, td { padding: 5px 4px; font-size: 13px; } }
.filters { margin: 0 0 12px; }
.op { padding: 12px 16px; }
.op.affecte, .op.hors_loyer, .op.doublon { opacity: .75; }
.op-head { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: baseline; }
.op-head b { min-width: 110px; }
.tag.prop-fiable { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.tag.prop-ambigu, .tag.prop-partiel, .tag.prop-plusieurs { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.tag.prop-inconnu { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
summary.danger { color: var(--bad); }
b.credit { color: var(--ok); } b.due { color: var(--bad); }
/* PWA: offline notice, installed app (notch), mobile header */
.offline { position: sticky; top: 0; z-index: 10; background: var(--bad-bg); color: var(--bad); text-align: center; padding: 8px 12px; font-weight: 600; }
.offline[hidden] { display: none; }
@media (display-mode: standalone) {
  header.top { padding-top: max(12px, env(safe-area-inset-top)); }
  main { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
}
@media (max-width: 700px) {
  header.top { gap: 6px; padding: 10px 12px 0; }
  header.top nav { flex-wrap: nowrap; overflow-x: auto; width: 100%; padding-bottom: 6px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  header.top nav::-webkit-scrollbar { display: none; }
  header.top nav a, header.top nav form { flex: none; white-space: nowrap; }
  nav a { padding: 8px 4px; }
  main { padding: 12px; }
  h1 { font-size: 20px; }
  .grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stats > div { padding: 10px 12px; }
}
/* Building plan (immo/plan.py, static/plan.js): a soft architectural model.
   Light from the top left: tops lightest, inner faces lit on the garden-side wall and
   shaded on the left wall, outer faces darker; status colours slightly muted. */
:root {
  --pl-top: #f6f2ea; --pl-wall-back: #e6ddcc; --pl-wall-left: #d7ccb8; --pl-front: #c9bba2; --pl-side: #b6a78d;
  --pl-ground: #d5e4c9; --pl-hors: #e6e3dd; --pl-edge: rgba(92, 78, 58, .28);
  --pl-loue: #d9e3ee; --pl-retard: #eed7d2; --pl-gracieux: #e2dcec; --pl-vacant: #eeede9;
  --pl-commun: #eee6d8; --pl-technique: #dfe1e4; --pl-equipement: #d3d9e3;
  --pl-f-top: #fbfaf7; --pl-f-front: #e4e0d8; --pl-f-side: #d3cec4; --pl-f-accent: #b9cbe0;
  --pl-shadow: #3b3226; --pl-light: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --pl-top: #5c5547; --pl-wall-back: #4b4539; --pl-wall-left: #403a30; --pl-front: #37322a; --pl-side: #2e2a23;
    --pl-ground: #2d3b28; --pl-hors: #2f2d2a; --pl-edge: rgba(230, 220, 200, .18);
    --pl-loue: #2b4258; --pl-retard: #573330; --pl-gracieux: #433a58; --pl-vacant: #35383c;
    --pl-commun: #4a4234; --pl-technique: #3a3f46; --pl-equipement: #353f55;
    --pl-f-top: #6a6458; --pl-f-front: #575247; --pl-f-side: #4a463d; --pl-f-accent: #4f6987;
    --pl-shadow: #000000; --pl-light: #ffffff;
  }
}
.plan-page { display: grid; grid-template-columns: 1fr; gap: 16px; }
.plan-tools { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.plan-tools h1 { margin: 0; flex: 1 1 auto; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--card); }
.seg-b { margin: 0; border-radius: 0; background: none; color: var(--text); font-weight: 500; padding: 8px 12px; min-height: 40px; border-left: 1px solid var(--line); }
.seg-b:first-child { border-left: 0; }
.seg-b[aria-pressed=true] { background: var(--accent); color: #fff; }
.plan-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; margin: 10px 0; align-items: center; }
.lg::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; border: 1px solid var(--pl-line); }
.lg.st-loue::before { background: var(--pl-loue); } .lg.st-retard::before { background: var(--pl-retard); }
.lg.st-gracieux::before { background: var(--pl-gracieux); } .lg.st-vacant::before { background: var(--pl-vacant); }
.lg.st-commun::before { background: var(--pl-commun); } .lg.st-technique::before { background: var(--pl-technique); }
.plan-scroll { overflow: auto; background: var(--card); border: 1px solid var(--line); border-radius: 10px; touch-action: pan-x pan-y pinch-zoom; }
.plan-zoom { width: 100%; transition: width .15s ease; }
.plan-level { margin: 0; padding: 8px 8px 0; }
.plan-level[hidden] { display: none; }
.plan-level figcaption { font-size: 14px; color: var(--navy); padding: 0 8px; position: sticky; left: 0; display: inline-block; }
.plan-level svg { display: block; width: 100%; height: auto; }
.plan-level polygon { stroke-linejoin: round; }
.plan-level polygon { stroke: var(--pl-edge); stroke-width: .6; }
.slab-top { fill: var(--pl-top); }
.slab-face.face-front { fill: var(--pl-front); } .slab-face.face-side { fill: var(--pl-side); }
.ground { fill: var(--pl-ground); stroke-dasharray: 4 3; }
.zone .floor, .zone .hl, .fx { stroke: none !important; }
.wall-back { fill: var(--pl-wall-back); } .wall-left { fill: var(--pl-wall-left); }
.zone .rim { fill: none; stroke: var(--pl-edge); stroke-width: .8; }
.st-loue .floor { fill: var(--pl-loue); } .st-retard .floor { fill: var(--pl-retard); }
.st-gracieux .floor { fill: var(--pl-gracieux); } .st-vacant .floor { fill: var(--pl-vacant); }
.st-commun .floor { fill: var(--pl-commun); } .st-technique .floor { fill: var(--pl-technique); }
.st-equipement .floor { fill: var(--pl-equipement); } .st-hors .floor { fill: var(--pl-hors); }
.sh-a { stop-color: var(--pl-shadow); stop-opacity: .20; } .sh-b { stop-color: var(--pl-shadow); stop-opacity: 0; }
.lit-a { stop-color: var(--pl-light); stop-opacity: .22; } .lit-b { stop-color: var(--pl-light); stop-opacity: 0; }
.grain { fill: var(--pl-shadow); fill-opacity: .07; }
.furn polygon { stroke-width: .4; }
.furn .face-top { fill: var(--pl-f-top); } .furn .face-front { fill: var(--pl-f-front); } .furn .face-side { fill: var(--pl-f-side); }
.furn .f-chair.face-top, .furn .f-couch.face-top, .furn .f-seat.face-top { fill: var(--pl-f-accent); }
.furn .f-shadow { fill: var(--pl-shadow); fill-opacity: .10; stroke: none; }
.furn .f-red.face-top { fill: #c8605a; } .furn .f-red.face-front { fill: #a9504b; } .furn .f-red.face-side { fill: #964641; }
.furn .f-blue.face-top { fill: #5b86c2; } .furn .f-blue.face-front { fill: #4b70a4; } .furn .f-blue.face-side { fill: #426392; }
.furn .f-grey.face-top { fill: #9aa0a7; } .furn .f-grey.face-front { fill: #81878e; } .furn .f-grey.face-side { fill: #72777e; }
.furn .f-ent.face-top { fill: #5f8f8a; } .furn .f-ent.face-front { fill: #4f7873; } .furn .f-ent.face-side { fill: #456a66; }
.furn .f-booth.face-top { fill: #eef0f2; } .furn .f-booth.face-front { fill: #cfd4da; } .furn .f-booth.face-side { fill: #bcc2c9; }
.zone .hl { fill: #fff; opacity: 0; transition: opacity .12s; }
a.zone { cursor: pointer; outline: none; -webkit-tap-highlight-color: transparent; }
a.zone:hover .hl, a.zone:focus-visible .hl { opacity: .16; }
a.zone.selected .hl { opacity: .34; }
a.zone:hover .rim, a.zone:focus-visible .rim { stroke: var(--accent); stroke-width: 1.6; }
a.zone.selected .rim { stroke: var(--accent); stroke-width: 2.6; }
a.zone:hover .ground, a.zone.selected .ground { stroke: var(--accent); stroke-width: 2; stroke-dasharray: none; }
.no-furn .furn, .no-fx .fx, .no-fx .furn .f-shadow { display: none; }
.plan-level text { pointer-events: none; fill: var(--text); text-anchor: middle; font-family: system-ui, -apple-system, sans-serif; }
.lbl.small { font-size: 15px; font-weight: 600; paint-order: stroke; stroke: var(--card); stroke-width: 3px; }
.lbl.tiny { font-size: 12px; }
.side { font-size: 15px; fill: var(--muted) !important; letter-spacing: .08em; text-transform: uppercase; }
.lbl-cab { pointer-events: none; }
.lbl-cab circle { fill: var(--navy); stroke: var(--card); stroke-width: 2; }
.lbl-cab .num { fill: #fff; font-size: 22px; font-weight: 700; }
@media (prefers-color-scheme: dark) { .lbl-cab .num { fill: #14171c; } }
.lbl-cab .sub { font-size: 14px; font-weight: 600; paint-order: stroke; stroke: var(--card); stroke-width: 3px; }
.plan-list h3 { font-size: 14px; margin: 12px 0 4px; color: var(--muted); }
.plan-list ul { columns: 2 220px; margin: 0; }
.plan-list li { padding: 3px 0; break-inside: avoid; }
.plan-panel { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; position: relative; }
.plan-panel[hidden] { display: none; }
.panel-close { position: absolute; top: 6px; right: 6px; background: none; color: var(--muted); font-size: 24px; line-height: 1; padding: 6px 10px; margin: 0; }
.apercu h2 { font-size: 20px; color: var(--navy); margin: 0 0 8px; }
.apercu > p.muted:first-child { margin: 0 0 4px; font-size: 13px; }
dl.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 12px 0; }
dl.kv dt { color: var(--muted); font-size: 13px; } dl.kv dd { margin: 0; }
@media (min-width: 1000px) {
  .plan-page { grid-template-columns: 1fr 340px; align-items: start; }
  .plan-panel { position: sticky; top: 16px; }
  .plan-panel[hidden] { display: block; visibility: hidden; }
}
@media (max-width: 999px) {
  .plan-panel { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; max-height: 65vh; overflow-y: auto;
    border-radius: 16px 16px 0 0; box-shadow: 0 -6px 24px rgba(0,0,0,.18); transform: translateY(100%); transition: transform .2s ease;
    padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .plan-panel.open { transform: none; }
  .plan-panel::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: -6px auto 10px; }
}
@media print { .plan-tools .seg, .plan-panel, header.top nav { display: none; } }

/* Home page as a control panel (immo/pilotage.py) */
.pilot-head { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.pilot-head h2 { margin: 0; }
.pilot-bank.ok { border-left: 4px solid var(--ok); }
.pilot-bank.alert { border: 1px solid var(--bad); border-left-width: 4px; background: var(--bad-bg); }
.pilot-bank p { margin: 8px 0; }
.actions { margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.actions .button, .pilot-plan .button { margin: 0; }
.button.secondary { background: var(--card); color: var(--accent); border: 1px solid var(--accent); }
.pilot-stats > div.bad b { color: var(--bad); } .pilot-stats > div.warn b { color: var(--warn); }
.pilot-stats b.undetermined { font-size: 16px; color: var(--warn); }
.pilot-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 16px; margin-bottom: 16px; }
.pilot-grid > .card { margin: 0; }
.pilot-grid h3 { font-size: 14px; margin: 14px 0 6px; color: var(--muted); }
.pilot-list { list-style: none; padding: 0; margin: 0; }
.pilot-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.pilot-list li:last-child { border-bottom: 0; }
.pilot-list li .num { margin-left: auto; font-variant-numeric: tabular-nums; }
.pilot-list li small { flex-basis: 100%; }
.pilot-states { list-style: none; padding: 0; margin: 0 0 4px; }
.pilot-states li { display: grid; grid-template-columns: 2.4em 1fr; align-items: baseline; padding: 5px 0; }
.pilot-states b { font-size: 20px; font-variant-numeric: tabular-nums; }
.pilot-states small { display: block; }
.pilot-due { border-color: var(--bad); border-left: 4px solid var(--bad); }
.pilot-due h2 { color: var(--bad); }
a.pilot-plan { display: flex; align-items: center; justify-content: space-between; gap: 12px; text-decoration: none; color: var(--text); }
a.pilot-plan:hover { border-color: var(--accent); }
@media (max-width: 700px) {
  .pilot-grid { grid-template-columns: 1fr; gap: 12px; }
  .actions .button, .pilot-plan .button { flex: 1 1 auto; text-align: center; padding: 12px 14px; }
  a.pilot-plan { flex-direction: column; align-items: stretch; }
  .pilot-list li { padding: 10px 0; }
}

/* Plan: the rendering (« maquette ») with clickable rooms; the drawing (« schéma ») on demand */
.plan-page.no-schema .plan-schema, .plan-page:not(.no-schema) .plan-maquette { display: none; }
.plan-page.no-schema [data-toggle=furn], .plan-page.no-schema [data-toggle=fx] { display: none; }
.plan-maquette svg { display: block; width: 100%; height: auto; }
.plan-maquette .mz polygon { fill: transparent; stroke: transparent; stroke-width: 3; stroke-linejoin: round; transition: fill .12s; }
.plan-maquette a.mz:hover polygon, .plan-maquette a.mz:focus-visible polygon { fill: rgba(255, 255, 255, .22); stroke: var(--accent); stroke-width: 2.5; }
.plan-maquette a.mz.selected polygon { fill: rgba(255, 255, 255, .30); stroke: var(--accent); stroke-width: 4; }
.plan-maquette a.mz.st-retard polygon { stroke: #b42318; stroke-width: 3; stroke-dasharray: 10 6; }
.mbadge { pointer-events: none; }
.mbadge circle { fill: #1f3864; stroke: #fff; stroke-width: 3; }
.mbadge.st-retard circle { fill: #b42318; } .mbadge.st-gracieux circle { fill: #6b4fa0; } .mbadge.st-vacant circle { fill: #7d838a; }
.mbadge .num { fill: #fff !important; font-size: 21px; font-weight: 700; }
.mbadge .cap-bg { fill: #fff; fill-opacity: .96; stroke: none; }
.mbadge .cap { fill: #1d2330 !important; font-size: 13px; font-weight: 600; }
.plan-page.no-schema .lg.st-loue::before { background: #1f3864; } .plan-page.no-schema .lg.st-retard::before { background: #b42318; }
.plan-page.no-schema .lg.st-gracieux::before { background: #6b4fa0; } .plan-page.no-schema .lg.st-vacant::before { background: #7d838a; }
.plan-page.no-schema .lg.st-commun, .plan-page.no-schema .lg.st-technique { display: none; }
.plan-page.no-schema .lg::before { border-radius: 50%; }
