/* Blender · même langage visuel que Palais : neutre, la couleur n'existe que dans les données */
:root {
  --bg: #F5F5F2; --card: #FFFFFF; --text: #0F1012; --muted: #55585F; --faint: #9A9DA4;
  --line: #DCDDE0; --fill: #EFEFEC; --accent: #5B4BFF; --accent-ink: #FFFFFF;
  --accent-soft: rgba(91, 75, 255, 0.10); --ok: #1F7A4A; --warn: #B4570C; --stop: #C62828;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1012; --card: #17181B; --text: #F2F2EE; --muted: #A2A5AC; --faint: #6B6E76;
    --line: #2C2E33; --fill: #202226; --accent: #8E82FF; --accent-ink: #0F1012;
    --accent-soft: rgba(142, 130, 255, 0.16); --ok: #4CC38A; --warn: #F0A050; --stop: #EF5350; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1012; --card: #17181B; --text: #F2F2EE; --muted: #A2A5AC; --faint: #6B6E76;
  --line: #2C2E33; --fill: #202226; --accent: #8E82FF; --accent-ink: #0F1012;
  --accent-soft: rgba(142, 130, 255, 0.16); --ok: #4CC38A; --warn: #F0A050; --stop: #EF5350; color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-family: var(--font); font-size: 17px; line-height: 1.4; letter-spacing: -0.01em; -webkit-font-smoothing: antialiased; min-height: 100dvh; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
h2 { font-size: 26px; font-weight: 600; margin: 0; letter-spacing: -0.03em; }
h3 { font-size: 17px; font-weight: 600; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.err { color: var(--stop); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row.between { justify-content: space-between; align-items: center; }
.grow { flex: 1 1 90px; }

main { max-width: 760px; margin: 0 auto; padding: 8px 16px calc(96px + env(safe-area-inset-bottom)); }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--bg); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 20px; letter-spacing: -0.03em; }
.pill { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--card);
  border-radius: 999px; padding: 6px 12px; font-size: 14px; cursor: pointer; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); }
.pill.ok .dot { background: var(--ok); }
.pill.busy .dot { background: var(--warn); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.head { margin: 18px 0 12px; }
.head p { margin: 4px 0 0; }
.sub { margin: 22px 0 8px; }
.sub.inline { display: inline; margin: 0; }
.sub-details { margin-top: 22px; }
.sub-details summary { cursor: pointer; list-style: none; margin-bottom: 8px; }
.sub-details summary::-webkit-details-marker { display: none; }
.sub-details summary::before { content: '▸ '; color: var(--muted); }
.sub-details[open] summary::before { content: '▾ '; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.list { display: grid; gap: 10px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.empty { color: var(--muted); text-align: center; padding: 30px 10px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); cursor: pointer; font-weight: 500;
  text-decoration: none; color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.stop { background: var(--stop); border-color: var(--stop); color: #fff; font-weight: 700; letter-spacing: .05em; }
.btn.small { min-height: 34px; padding: 0 10px; font-size: 14px; }
.btn.wide { width: 100%; margin-top: 14px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); margin-bottom: 10px; }
.field input, .field select, .targets input, .targets select {
  min-height: 44px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); padding: 0 10px; color: var(--text); font-size: 17px; width: 100%; }
input[type=range] { width: 100%; accent-color: var(--accent); min-height: 32px; }

/* Vins */
.vin { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; cursor: pointer; }
.pump { width: 40px; height: 40px; border-radius: 8px; display: grid; place-items: center; font-family: var(--mono);
  font-weight: 600; background: var(--fill); font-size: 15px; }
.pump.none { color: var(--faint); }
.pump.dup { background: var(--warn); color: #fff; }
.vin .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vin .meta { font-size: 13px; color: var(--muted); font-family: var(--mono); }
.vin .vol { text-align: right; font-family: var(--mono); font-size: 15px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }

/* Cible */
.targets { display: grid; gap: 4px; padding: 6px 14px; }
.target { display: grid; grid-template-columns: 1fr 92px 132px; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.target:last-child { border-bottom: 0; }
.target .lbl { font-size: 15px; }
.target .lbl small { display: block; color: var(--faint); font-size: 12px; }
.target .range { font-size: 12px; color: var(--faint); font-family: var(--mono); }
.target.off .lbl { color: var(--faint); }
.target select { font-size: 14px; }

/* Assemblages */
.variant h3 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.variant .score { font-size: 13px; font-weight: 400; color: var(--muted); font-family: var(--mono); }
.bar { display: flex; height: 14px; border-radius: 4px; overflow: hidden; margin: 10px 0; background: var(--fill); }
.bar span { display: block; height: 100%; }
.parts { width: 100%; border-collapse: collapse; font-size: 15px; }
.parts td { padding: 4px 0; }
.parts td.n { text-align: right; font-family: var(--mono); white-space: nowrap; padding-left: 10px; }
.prof { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 8px; }
.prof th { text-align: left; font-weight: 400; color: var(--muted); font-size: 12px; padding: 4px 0; }
.prof td { padding: 3px 0; border-top: 1px solid var(--line); }
.prof td.n, .prof th.n { text-align: right; font-family: var(--mono); padding-left: 8px; }
.delta.good { color: var(--ok); }
.delta.mid { color: var(--warn); }
.delta.bad { color: var(--stop); }
.variant .btns { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.variant .btns .btn { flex: 1 1 auto; }
details.more summary { cursor: pointer; color: var(--accent); font-size: 14px; margin-top: 8px; }

/* Éditeur */
.slider { display: grid; grid-template-columns: 1fr 64px; gap: 4px 10px; align-items: center; margin: 8px 0; }
.slider .lbl { font-size: 15px; }
.slider input[type=range] { grid-column: 1 / -1; }
.slider .pct { font-family: var(--mono); text-align: right; }

/* Service */
.serve td { padding: 6px 0; border-bottom: 1px solid var(--line); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 12px; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 14px; cursor: pointer; font-family: var(--mono); }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.warn { color: var(--warn); font-size: 14px; }

/* Barre de travail en cours */
.jobbar { position: sticky; top: 57px; z-index: 4; display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.jobinfo { display: flex; flex-direction: column; }
.progress { grid-column: 1; height: 6px; border-radius: 3px; background: var(--fill); overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.jobbar .stop { grid-row: 1 / 3; grid-column: 2; min-height: 52px; padding: 0 22px; }
.pumps { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 10px; }
.pumpcell { border: 1px solid var(--line); border-radius: 8px; padding: 8px; font-size: 13px; }
.pumpcell.run { border-color: var(--accent); background: var(--accent-soft); }
.pumpcell.done { color: var(--muted); }
.pumpcell b { font-family: var(--mono); }

/* Calibration */
.calib { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.calcell { border: 1px solid var(--line); border-radius: 8px; padding: 8px; display: grid; gap: 6px; font-size: 13px; }
.calcell .top2 { display: flex; justify-content: space-between; }
.calcell input { min-height: 36px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); padding: 0 8px; width: 100%; }
.calcell.missing { border-color: var(--warn); }

/* Navigation basse */
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs button { border: 0; background: none; padding: 14px 4px; font-size: 14px; color: var(--muted); cursor: pointer; }
.tabs button.on { color: var(--accent); font-weight: 600; }

/* Feuille modale */
.sheet { border: 0; padding: 0; background: var(--card); color: var(--text); width: min(640px, 100vw); max-width: 100vw;
  max-height: 92dvh; border-radius: 14px 14px 0 0; margin: auto auto 0; }
@media (min-width: 700px) { .sheet { border-radius: 14px; margin: auto; } }
.sheet::backdrop { background: rgba(0,0,0,.45); }
.sheet > div { padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
.sheet .sheethead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.sheet .close { border: 0; background: var(--fill); border-radius: 50%; width: 36px; height: 36px; cursor: pointer; font-size: 18px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.fields .full { grid-column: 1 / -1; }

.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login form { width: min(360px, 100%); display: grid; gap: 12px; }
.login input { min-height: 48px; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; background: var(--bg); font-size: 17px; }

.toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 15px; max-width: calc(100vw - 32px); }

/* Écran du Pi 1024x600 : plus dense */
@media (min-width: 900px) and (max-height: 640px) {
  body { font-size: 16px; }
  .head { margin: 10px 0 8px; }
}
