/* ==========================================================================
   NEXTRAK — Suivi de foration · feuille de style
   Pensée pour le terrain : gros boutons, fort contraste, lisible au soleil,
   utilisable avec des gants. Couleurs de marque modifiables par le client.
   © 2026 Cyprien Baudon de Mony (NEXTRAK) — Tous droits réservés
   ========================================================================== */

@font-face { font-family: 'Barlow'; font-weight: 400; font-display: swap; src: url('../fonts/barlow-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 500; font-display: swap; src: url('../fonts/barlow-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 600; font-display: swap; src: url('../fonts/barlow-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 700; font-display: swap; src: url('../fonts/barlow-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 600; font-display: swap; src: url('../fonts/barlow-condensed-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 700; font-display: swap; src: url('../fonts/barlow-condensed-latin-700-normal.woff2') format('woff2'); }

:root {
  --brand: #13233F;          /* bleu nuit — couleur principale du client */
  --accent: #F27A1A;         /* orange taillant — actions de forage */
  --bg: #ECEFF3;             /* gris granite clair */
  --surface: #FFFFFF;
  --sunk: #F5F7F9;
  --line: #D6DCE4;
  --ink: #16233A;
  --muted: #5B6B80;
  --ok: #1F8F63;
  --warn: #B97C06;
  --danger: #C8423A;
  --teal: #2A8C9E;
  --r-sm: 8px; --r: 12px; --r-lg: 18px;
  --tap: 52px;
  --font: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --cond: 'Barlow Condensed', 'Barlow', system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --on-brand: #FFFFFF;
  --on-accent: #FFFFFF;
  --brand-panel: var(--brand);
  --info-bg: #E6EDF6; --info-ink: var(--brand);
  --warn-bg: #FDF0D8; --warn-ink: #7A5205;
  --teal-bg: #E7F1F4; --teal-ink: #1D5E6B;
  --ok-bg: #E3F3EC;
  --err-bg: #FBE7E5; --err-ink: #8E2A23;
  --chip-base: white;
  --bar-track: #E3E8EE;
  --bore: #DCE2EA;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 17px; line-height: 1.45; color: var(--ink); background: var(--bg); -webkit-tap-highlight-color: transparent; }
body.no-scroll { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
h1 { font-family: var(--cond); font-weight: 700; font-size: clamp(28px, 6.5vw, 38px); letter-spacing: .2px; }
p { margin: 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.ic { width: 22px; height: 22px; flex: none; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: 14px; }
.mt { margin-top: 22px; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- Structure */
.shell { min-height: 100vh; min-height: 100dvh; }
.main { width: 100%; max-width: 760px; margin: 0 auto; padding: 16px 16px calc(96px + var(--safe-b)); }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; min-width: 0; flex: 1; }
.brand img { height: 26px; width: auto; max-width: 180px; object-fit: contain; }
.brand b { font-family: var(--cond); font-size: 22px; color: var(--brand); }
.sync { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.sync .ic { width: 18px; height: 18px; }
.sync.on { background: var(--ok-bg); color: var(--ok); }
.sync.off { background: var(--warn-bg); color: var(--warn); }

.tabbar { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--brand-panel); padding: 6px 6px calc(6px + var(--safe-b)); }
.tabbar button { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 58px; border: 0; background: none; color: color-mix(in srgb, var(--on-brand) 62%, transparent); font-size: 13px; font-weight: 600; border-radius: var(--r); }
.tabbar button .ic { width: 26px; height: 26px; }
.tabbar button.on { color: var(--on-brand); background: rgba(255,255,255,.1); }
.tabbar button.on .ic { color: var(--accent); }

/* ---------------------------------------------------------------- Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); padding: 0 20px; border-radius: var(--r); border: 2px solid transparent; font-weight: 700; font-size: 17px; text-decoration: none; transition: transform .08s ease, background-color .15s ease; touch-action: manipulation; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-accent { background: var(--accent); color: var(--on-accent); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-text { color: var(--danger); }
.btn-sm { min-height: 40px; padding: 0 14px; font-size: 15px; }
.btn-lg { min-height: 58px; font-size: 18px; }
.btn-xl { min-height: 68px; font-size: 20px; border-radius: var(--r-lg); }
.btn-block { width: 100%; }
.grow { flex: 1; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: var(--ink); }
.icon-btn:hover { background: var(--sunk); }
.link-btn { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 8px 0; color: var(--brand); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.stack { display: grid; gap: 10px; margin: 18px 0; }
.row-btns { display: flex; gap: 10px; margin: 14px 0; }
.back { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; margin: -4px 0 8px -6px; padding: 0 8px; border: 0; background: none; color: var(--muted); font-weight: 600; }

/* ---------------------------------------------------------------- Connexion */
.shell-login { background: var(--brand); color: var(--on-brand); }
.shell-login .main { padding-bottom: 32px; }
.login { min-height: calc(100dvh - 48px); display: flex; flex-direction: column; padding-top: 6vh; }
.login-brand { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.login-logo { height: 44px; width: auto; background: #fff; padding: 8px 12px; border-radius: var(--r-sm); }
.login-name { font-family: var(--cond); font-size: 34px; font-weight: 700; }
.login-app { color: color-mix(in srgb, var(--on-brand) 70%, transparent); font-weight: 600; }
.login-title { margin: 8vh 0 16px; font-size: clamp(34px, 9vw, 48px); }
.who-grid { display: grid; gap: 12px; }
.who { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 14px; align-items: center; text-align: left; padding: 16px; border-radius: var(--r-lg); border: 2px solid rgba(255,255,255,.14); background: rgba(255,255,255,.06); color: var(--on-brand); }
.who:hover, .who:focus-visible { border-color: var(--accent); background: rgba(255,255,255,.1); }
.who .avatar { grid-row: span 2; }
.who-name { font-size: 21px; font-weight: 700; }
.who-sub { color: color-mix(in srgb, var(--on-brand) 65%, transparent); font-size: 15px; }
.avatar { display: inline-grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-family: var(--cond); font-weight: 700; font-size: 22px; }
.avatar-lg { width: 64px; height: 64px; font-size: 26px; }
.login-admin { margin-top: auto; padding-top: 32px; color: color-mix(in srgb, var(--on-brand) 75%, transparent); align-self: flex-start; }
.shell-login .empty { color: color-mix(in srgb, var(--on-brand) 70%, transparent); }

.pin-dots { display: flex; justify-content: center; gap: 16px; margin: 6px 0 22px; }
.pin-dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--brand); }
.pin-dots i.on { background: var(--brand); }
.pin-dots.shake { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 320px; margin: 0 auto 10px; }
.pin-key { height: 64px; border-radius: var(--r); border: 1px solid var(--line); background: var(--sunk); font-family: var(--cond); font-size: 28px; font-weight: 700; }

/* ---------------------------------------------------------------- Journée */
.hero { padding: 26px 20px 22px; border-radius: var(--r-lg); background: var(--brand-panel); color: var(--on-brand); margin-bottom: 16px; position: relative; overflow: hidden; }
.hero::after { content: ''; position: absolute; inset: auto -10% -40% 30%; height: 70%; background: repeating-linear-gradient(-8deg, transparent 0 14px, rgba(255,255,255,.05) 14px 16px); pointer-events: none; }
.hero-date { color: color-mix(in srgb, var(--on-brand) 70%, transparent); font-weight: 600; text-transform: capitalize; }
.hero h1 { margin: 4px 0 6px; }
.hero-sub { color: color-mix(in srgb, var(--on-brand) 80%, transparent); margin-bottom: 20px; max-width: 38ch; }
.hero .btn { position: relative; z-index: 1; width: 100%; background: var(--accent); color: var(--on-accent); }

.day-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; padding: 18px 18px 16px; margin-bottom: 14px; border-radius: var(--r-lg); background: var(--brand-panel); color: var(--on-brand); }
.eyebrowless { color: color-mix(in srgb, var(--on-brand) 70%, transparent); font-weight: 600; font-size: 15px; }
.day-machine { display: flex; align-items: center; gap: 6px; margin-top: 6px; color: color-mix(in srgb, var(--on-brand) 85%, transparent); font-weight: 600; }
.big-metric { text-align: right; }
.big-metric b { display: block; font-family: var(--cond); font-size: 44px; line-height: 1; color: var(--accent); }
.big-metric span { font-size: 13px; color: color-mix(in srgb, var(--on-brand) 75%, transparent); }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.tile { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center; text-align: left; padding: 16px; min-height: 84px; border-radius: var(--r-lg); border: 2px solid var(--line); background: var(--surface); }
.tile .ic { grid-row: span 2; width: 30px; height: 30px; color: var(--brand); }
.tile-title { font-weight: 700; font-size: 18px; }
.tile-sub { color: var(--muted); font-size: 14px; }
.tile-main { grid-column: span 2; background: var(--accent); border-color: var(--accent); color: var(--on-accent); min-height: 96px; }
.tile-main .ic, .tile-main .tile-sub { color: var(--on-accent); }
.tile-main .tile-title { font-size: 22px; font-family: var(--cond); }
.tile-todo { border-color: #E9B24A; background: color-mix(in srgb, #E9B24A 12%, var(--surface)); }
.tile-todo .tile-sub { color: var(--warn); font-weight: 700; }
.tile-done .tile-sub { color: var(--ok); font-weight: 700; }

/* ---------------------------------------------------------------- Cartes et listes */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; margin-bottom: 14px; }
.card-title { font-size: 17px; font-weight: 700; margin-bottom: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.card-head .card-title { margin: 0; }
.kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.kv-grid > div { display: flex; flex-direction: column; }
.kv-grid span { font-size: 14px; color: var(--muted); }
.kv-grid b { font-size: 17px; }
.kv-grid .span2 { grid-column: span 2; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 4px 0 14px; flex-wrap: wrap; }
.list-title { font-size: 15px; font-weight: 700; color: var(--muted); margin: 20px 0 8px; }
.list { display: grid; gap: 8px; }
.row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 64px; padding: 12px 14px; text-align: left; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); }
.row:hover { border-color: var(--brand); }
.row.static:hover { border-color: var(--line); }
.row:disabled { opacity: 1; cursor: default; }
.row-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.row-main b { font-size: 17px; }
.row-main span { color: var(--muted); font-size: 14px; }
.row-chev { color: var(--muted); }
.empty { color: var(--muted); padding: 14px 2px; }
.banner { display: flex; align-items: center; gap: 10px; padding: 12px 14px; margin-bottom: 14px; border-radius: var(--r); background: var(--info-bg); color: var(--info-ink); font-weight: 600; font-size: 15px; }
.banner span { flex: 1; }
.banner-warn { background: var(--warn-bg); color: var(--warn-ink); }
.banner-info { background: var(--teal-bg); color: var(--teal-ink); }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap; background: color-mix(in srgb, var(--c, #8A97A8) 16%, var(--chip-base)); color: color-mix(in srgb, var(--c, #5B6B80) 80%, var(--ink)); }
.chip-ok { --c: var(--ok); }
.chip-warn { --c: #D9930B; }
.chip-accent { --c: var(--accent); }
.chip-muted { --c: #8A97A8; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); margin-right: 6px; vertical-align: middle; }
.dot-lg { width: 18px; height: 18px; margin: 0; }

/* ---------------------------------------------------------------- Tir */
.tir-head { padding: 18px 18px 0; margin-bottom: 14px; border-radius: var(--r-lg); background: var(--brand-panel); color: var(--on-brand); overflow: hidden; }
.tir-head .muted { color: color-mix(in srgb, var(--on-brand) 72%, transparent); }
.tir-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0 12px; }
.tir-stats b { display: block; font-family: var(--cond); font-size: 32px; line-height: 1; }
.tir-stats span { font-size: 13px; color: color-mix(in srgb, var(--on-brand) 72%, transparent); }
.profile-wrap { margin: 0 -18px; padding: 0 18px 16px; }
.profile { display: block; width: 100%; height: 92px; }
.profile .prof-bar { fill: var(--accent); }
.profile .prof-ground { stroke: rgba(255,255,255,.4); stroke-width: 1; }
.card .profile .prof-bar { fill: var(--brand); }
.card .profile .prof-ground { stroke: var(--line); }
.card .profile-wrap { margin: 14px 0 0; padding: 0; }
.sticky-cta { position: sticky; top: 64px; z-index: 10; box-shadow: 0 6px 18px -8px color-mix(in srgb, var(--accent) 70%, transparent); }

.holes { display: grid; gap: 8px; }
.hole { display: grid; grid-template-columns: 16px 44px 1fr auto; align-items: center; gap: 10px; width: 100%; padding: 10px 14px 10px 10px; text-align: left; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); }
.hole:hover:not(:disabled) { border-color: var(--brand); }
.hole:disabled { cursor: default; opacity: 1; }
.bore .bore-body { fill: var(--bore); }
.hole-no { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; background: var(--sunk); font-family: var(--cond); font-weight: 700; font-size: 22px; color: var(--brand); }
.hole-main { display: flex; flex-direction: column; min-width: 0; }
.hole-main b { font-family: var(--cond); font-size: 24px; line-height: 1.05; }
.hole-main span { color: var(--muted); font-size: 14px; }
.hole-tags { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.dep { display: inline-flex; align-items: center; gap: 2px; font-size: 14px; color: var(--muted); font-weight: 600; }
.dep .ic { width: 16px; height: 16px; }
.end-tir { margin-top: 18px; }

/* ---------------------------------------------------------------- Formulaires */
.form { display: grid; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; border: 0; padding: 0; margin: 0; }
.field.compact { margin-bottom: 12px; }
.field-label { font-weight: 700; font-size: 15px; }
legend.field-label { margin-bottom: 8px; padding: 0; }
.field-hint { color: var(--muted); font-size: 14px; }
.form-sub { font-size: 16px; font-weight: 700; color: var(--brand); padding: 0; margin: 4px 0 0; }
input:not([type="radio"]):not([type="checkbox"]):not([type="color"]), select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 14px; border-radius: var(--r-sm); border: 2px solid var(--line); background: var(--surface); font-size: 18px; }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
input[type="color"] { width: 100%; height: var(--tap); padding: 4px; border-radius: var(--r-sm); border: 2px solid var(--line); background: var(--surface); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-error { padding: 12px 14px; border-radius: var(--r-sm); background: var(--err-bg); color: var(--err-ink); font-weight: 600; border-left: 4px solid var(--danger); }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 4px; }

.field-hero .hero-input { position: relative; display: block; }
.field-hero input { min-height: 84px !important; font-family: var(--cond); font-weight: 700; font-size: 48px !important; padding-right: 52px !important; text-align: center; border-color: var(--accent) !important; }
.field-hero i, .dir-dist i { position: absolute; right: 18px; top: 50%; transform: translateY(-50%); font-style: normal; font-weight: 700; color: var(--muted); font-size: 20px; }

.stepper { display: grid; grid-template-columns: var(--tap) 1fr var(--tap); align-items: center; gap: 6px; }
.stepper input { text-align: center; font-family: var(--cond); font-weight: 700; font-size: 24px !important; padding: 8px 4px !important; }
.step-btn { height: var(--tap); border-radius: var(--r-sm); border: 2px solid var(--line); background: var(--sunk); display: grid; place-items: center; }
.step-unit { grid-column: 1 / -1; font-size: 14px; color: var(--muted); }

.chips-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.chips-grid.brands { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
.pick { position: relative; }
.pick input { position: absolute; opacity: 0; inset: 0; }
.pick span { display: flex; flex-direction: column; justify-content: center; min-height: 56px; padding: 6px 10px; border-radius: var(--r-sm); border: 2px solid var(--line); background: var(--surface); font-size: 13px; color: var(--muted); line-height: 1.2; border-left: 6px solid var(--c, var(--line)); }
.pick span b { font-size: 17px; color: var(--ink); }
.pick input:checked + span { border-color: var(--c, var(--brand)); background: color-mix(in srgb, var(--c, var(--brand)) 14%, var(--surface)); color: var(--ink); }
.pick input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.ann-detail { margin-top: 12px; display: grid; gap: 12px; }

.dir-pad { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-areas: ". av ." "g dist d" ". ar ."; gap: 8px; max-width: 360px; }
.dir { position: relative; }
.dir-G { grid-area: g; } .dir-D { grid-area: d; } .dir-Av { grid-area: av; } .dir-Ar { grid-area: ar; }
.dir input { position: absolute; opacity: 0; inset: 0; }
.dir span { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 64px; border-radius: var(--r); border: 2px solid var(--line); background: var(--surface); }
.dir span small { font-size: 12px; color: var(--muted); font-weight: 600; }
.dir .ic { width: 26px; height: 26px; }
.dir input:checked + span { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.dir input:checked + span small { color: color-mix(in srgb, var(--on-brand) 80%, transparent); }
.dir input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.dir-dist { grid-area: dist; position: relative; }
.dir-dist input { height: 64px; text-align: center; font-family: var(--cond); font-weight: 700; font-size: 26px !important; padding-right: 30px !important; }
.dir-dist i { right: 10px; font-size: 16px; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; padding: 4px; border-radius: var(--r); background: var(--sunk); border: 1px solid var(--line); }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg label span, .seg button { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 0 10px; border-radius: var(--r-sm); border: 0; background: none; font-weight: 700; font-size: 15px; text-align: center; color: var(--muted); }
.seg input:checked + span, .seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(22,35,58,.18); }
.seg input:focus-visible + span { outline: 3px solid var(--accent); }
.seg-sm button { min-height: 38px; font-size: 14px; }

.checks { display: grid; gap: 8px; }
.check { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 14px; border-radius: var(--r-sm); border: 2px solid var(--line); background: var(--surface); }
.check input { width: 22px; height: 22px; accent-color: var(--brand); }

.fluid-list { display: grid; gap: 14px; }
.fluid { padding: 12px; border-radius: var(--r); background: var(--sunk); display: grid; gap: 8px; }
.fluid-name { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.fluid-name .ic { color: var(--teal); }
.fluid .field-label { font-size: 13px; font-weight: 600; color: var(--muted); }

/* ---------------------------------------------------------------- Fenêtres */
.sheet-wrap { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(13,22,38,.5); opacity: 0; transition: opacity .2s; }
.sheet { position: relative; width: 100%; max-width: 640px; max-height: 94dvh; display: flex; flex-direction: column; background: var(--surface); border-radius: 20px 20px 0 0; transform: translateY(24px); opacity: 0; transition: transform .22s ease, opacity .22s ease; }
.sheet-wrap.open .sheet-backdrop { opacity: 1; }
.sheet-wrap.open .sheet { transform: none; opacity: 1; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 10px 10px 18px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-family: var(--cond); font-size: 24px; }
.sheet-body { padding: 16px 18px calc(22px + var(--safe-b)); overflow-y: auto; overscroll-behavior: contain; }
.sheet-actions { display: flex; gap: 10px; padding: 12px 18px calc(14px + var(--safe-b)); border-top: 1px solid var(--line); }
.sheet-actions .btn { flex: 1; }
.lead { font-size: 18px; }
.done-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; text-align: center; }
.done-stats b { display: block; font-family: var(--cond); font-size: 30px; color: var(--brand); }
.done-stats span { font-size: 14px; color: var(--muted); }

.toasts { position: fixed; z-index: 200; left: 50%; bottom: calc(86px + var(--safe-b)); transform: translateX(-50%); display: grid; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--r); background: var(--ink); color: #fff; font-weight: 600; box-shadow: 0 10px 30px -10px rgba(0,0,0,.4); animation: toastIn .2s ease; }
.toast .ic { color: #6FD3A6; }
.toast-err .ic { color: #FF8A80; }
.toast-warn .ic { color: #FFC857; }
.toast.out { opacity: 0; transform: translateY(6px); transition: all .3s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* ---------------------------------------------------------------- Récapitulatif */
.recap-head { margin-bottom: 12px; }
.recap-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.recap-kpis b { display: block; font-family: var(--cond); font-size: 30px; line-height: 1; color: var(--brand); }
.recap-kpis span { font-size: 13px; color: var(--muted); }
.table-card { padding: 0; overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 2px solid var(--line); white-space: nowrap; background: var(--sunk); }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl-click tbody tr { cursor: pointer; }
.tbl-click tbody tr:hover { background: var(--sunk); }
.send-state { display: flex; align-items: center; gap: 14px; }
.send-state .ic { width: 34px; height: 34px; }
.send-state .ic.ok { color: var(--ok); }
.send-state .ic.warn { color: var(--warn); }
.send-state div { display: flex; flex-direction: column; }
.send-state span { color: var(--muted); font-size: 14px; }
.layout { width: 100%; max-height: 320px; display: block; }
.lay-line { stroke: var(--line); stroke-width: .25; stroke-dasharray: .6 .5; }
.lay-hole { fill: var(--brand); }
.lay-num { fill: var(--muted); text-anchor: middle; font-family: var(--cond); font-weight: 700; }

/* ---------------------------------------------------------------- Pièces */
.pieces { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.piece { display: flex; flex-direction: column; gap: 4px; padding: 14px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); }
.piece-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; flex-wrap: wrap; }
.piece h3 { font-size: 17px; }
.piece-brand { color: var(--muted); font-weight: 600; }
.piece-m { margin: 6px 0 2px; }
.piece-m b { font-family: var(--cond); font-size: 34px; color: var(--brand); }
.piece .btn { margin-top: auto; min-height: 46px; font-size: 15px; }
.piece-empty { border-style: dashed; background: transparent; }
.gauge { display: block; height: 10px; border-radius: 999px; background: var(--bar-track); overflow: hidden; }
.gauge i { display: block; height: 100%; border-radius: inherit; background: var(--ok); }
.gauge.warm i { background: #E3A21A; }
.gauge.hot i { background: var(--danger); }

.me-card { display: flex; align-items: center; gap: 14px; }
.me-card div { display: flex; flex-direction: column; }
.me-card b { font-size: 20px; }
.sync-line { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 4px; }
.sync-line .ic.ok { color: var(--ok); } .sync-line .ic.warn { color: var(--warn); }
.about { text-align: center; color: var(--muted); font-size: 13px; margin-top: 30px; }

/* ---------------------------------------------------------------- Administration */
.shell-admin .main { max-width: 1180px; padding-bottom: 48px; }
.side { display: none; }
.admin-tabs { position: sticky; top: 65px; z-index: 15; display: flex; gap: 4px; overflow-x: auto; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--line); scrollbar-width: none; }
.admin-tabs button { display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 44px; padding: 0 14px; border: 0; border-radius: 999px; background: none; color: var(--muted); font-weight: 700; font-size: 15px; }
.admin-tabs button.on { background: var(--brand); color: var(--on-brand); }
.admin-tabs .ic { width: 18px; height: 18px; }
.admin-head h1 { font-size: clamp(28px, 4vw, 36px); }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.kpi { display: flex; flex-direction: column; padding: 16px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); }
.kpi span { font-size: 14px; color: var(--muted); font-weight: 600; }
.kpi b { font-family: var(--cond); font-size: 40px; line-height: 1.05; color: var(--ink); font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); font-size: 13px; }
.kpi-hero { background: var(--brand-panel); border-color: var(--brand-panel); }
.kpi-hero span, .kpi-hero small { color: color-mix(in srgb, var(--on-brand) 75%, transparent); }
.kpi-hero b { color: var(--accent); font-size: 48px; }
.kpi-warn b { color: var(--warn); }
.dash-grid { display: grid; gap: 14px; }
.dash-grid .card { margin: 0; }
.chart-box { position: relative; height: 240px; }
.chart-box.tall { height: 280px; }
.wear { display: grid; gap: 10px; }
.wear-row { display: grid; grid-template-columns: minmax(0, 1.3fr) 2fr auto; align-items: center; gap: 12px; }
.wear-name { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wear-m { font-family: var(--cond); font-weight: 700; font-size: 18px; min-width: 64px; text-align: right; }
.range { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.export-btns { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }
.export-btns .btn { min-height: 46px; font-size: 15px; }
.ref-grid { display: grid; gap: 14px; }
.ref-grid .card { margin: 0; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 6px 6px 6px 12px; border-radius: 999px; background: var(--sunk); border: 1px solid var(--line); font-weight: 600; }
.tag button { display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 50%; background: none; color: var(--muted); }
.tag .ic { width: 16px; height: 16px; }
.inline-add { display: flex; gap: 8px; }
.inline-add input { min-height: 44px !important; font-size: 16px !important; }
.seuils { grid-template-columns: repeat(2, 1fr); align-items: end; }
.logo-edit { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px; border-radius: var(--r-sm); border: 2px dashed var(--line); }
.logo-edit img { height: 40px; width: auto; }

@media (min-width: 720px) {
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .dash-grid { grid-template-columns: 1fr 1fr; }
  .dash-grid .wide { grid-column: span 2; }
  .ref-grid { grid-template-columns: 1fr 1fr; }
  .seuils { grid-template-columns: repeat(4, 1fr) auto; }
  .range { grid-template-columns: 220px 220px 1fr; align-items: end; }
  .export-btns { grid-column: auto; justify-content: flex-end; }
  .pieces { grid-template-columns: repeat(4, 1fr); }
  .sheet-wrap { align-items: center; }
  .sheet { border-radius: 20px; max-height: 88vh; }
  .sheet-wide { max-width: 860px; }
  .toasts { bottom: 32px; }
}
@media (min-width: 1000px) {
  .shell-admin { display: grid; grid-template-columns: 248px 1fr; }
  .shell-admin .admin-top, .shell-admin .admin-tabs { display: none; }
  .side { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; padding: 22px 14px; background: var(--brand-panel); color: var(--on-brand); }
  .side .brand { flex: none; padding: 10px 12px; margin-bottom: 8px; background: #fff; border-radius: var(--r); }
  .side .brand b { color: var(--brand); }
  .side-role { display: flex; align-items: center; gap: 6px; padding: 6px 12px 14px; color: color-mix(in srgb, var(--on-brand) 60%, transparent); font-size: 14px; font-weight: 600; }
  .side-role .ic { width: 16px; height: 16px; }
  .side-link { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 14px; border: 0; border-radius: var(--r); background: none; color: color-mix(in srgb, var(--on-brand) 75%, transparent); font-weight: 600; text-align: left; }
  .side-link:hover { background: rgba(255,255,255,.08); color: var(--on-brand); }
  .side-link.on { background: rgba(255,255,255,.12); color: var(--on-brand); }
  .side-link.on .ic { color: var(--accent); }
  .side-out { margin-top: auto; }
  .shell-admin .main { padding: 28px 32px 48px; }
}
@media (max-width: 380px) {
  .chips-grid { grid-template-columns: repeat(2, 1fr); }
  .recap-kpis { grid-template-columns: repeat(2, 1fr); }
  .tiles { grid-template-columns: 1fr; }
  .tile-main { grid-column: auto; }
  .pieces { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------------------------------------------------------------- Foratrak : marque et connexion */
.fx-mark { font-family: var(--cond); font-weight: 700; letter-spacing: 1px; color: inherit; }
.fx-mark b { color: var(--accent); font-weight: 700; }
.login-title { margin: 6vh 0 18px; }
.login-form { gap: 16px; }
.login-form .field-label { color: color-mix(in srgb, var(--on-brand) 85%, transparent); }
.login-form input { border-color: transparent !important; }
.login-form .form-error { background: #FBE7E5; color: #8E2A23; }
.pwd { position: relative; display: block; }
.pwd input { padding-right: 52px !important; }
.pwd .icon-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.login-note { color: color-mix(in srgb, var(--on-brand) 65%, transparent); font-size: 14px; text-align: center; }
.login-test { margin-top: 28px; padding: 12px 14px; border-radius: var(--r); background: rgba(255,255,255,.08); color: color-mix(in srgb, var(--on-brand) 80%, transparent); font-size: 14px; line-height: 1.5; }
.login-test b { color: var(--on-brand); }
.gauge.neutral i { background: var(--brand); opacity: .75; }

/* ---------------------------------------------------------------- Mode sombre */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0D1522; --surface: #162133; --sunk: #1B2940; --line: #2A3A55;
  --ink: #E7ECF4; --muted: #9AA9BF;
  --ok: #3CC48A; --warn: #F0B53A; --danger: #F0675E;
  --brand-panel: color-mix(in srgb, var(--brand) 78%, #2A3A55);
  --brand-soft: color-mix(in srgb, var(--brand) 55%, #8FA6C8);
  --on-brand: #FFFFFF;
  --info-bg: #1B2A44; --info-ink: #BFD0EA;
  --warn-bg: #3A2D12; --warn-ink: #F5D08A;
  --teal-bg: #12323A; --teal-ink: #9FD9E4;
  --ok-bg: #12362A;
  --err-bg: #3D1C1C; --err-ink: #FFB4AD;
  --chip-base: var(--surface);
  --bar-track: #26354D;
  --bore: #34465F;
}
:root[data-theme="dark"] .btn-primary { background: var(--brand-panel); color: #fff; border-color: color-mix(in srgb, var(--brand) 50%, #5A7099); }
:root[data-theme="dark"] .dir input:checked + span, :root[data-theme="dark"] .admin-tabs button.on { background: var(--brand-soft); color: #fff; }
:root[data-theme="dark"] .card .profile .prof-bar, :root[data-theme="dark"] .lay-hole { fill: var(--brand-soft); }
:root[data-theme="dark"] .pin-dots i { border-color: var(--ink); } :root[data-theme="dark"] .pin-dots i.on { background: var(--ink); }
:root[data-theme="dark"] .brand img { background: #fff; padding: 3px 8px; border-radius: 6px; }
:root[data-theme="dark"] .brand-own-dark img { background: none; padding: 0; }
:root[data-theme="dark"] .hole-no, :root[data-theme="dark"] .form-sub, :root[data-theme="dark"] .piece-m b, :root[data-theme="dark"] .recap-kpis b, :root[data-theme="dark"] .done-stats b, :root[data-theme="dark"] .brand b { color: var(--ink); }
:root[data-theme="dark"] .tile .ic { color: var(--brand-soft); }
:root[data-theme="dark"] .tile-main .ic { color: var(--on-accent); }
:root[data-theme="dark"] .toast { background: #F1F4F9; color: #16233A; }
:root[data-theme="dark"] .link-btn { color: var(--brand-soft); }
:root[data-theme="dark"] .shell-login .link-btn { color: rgba(255,255,255,.75); }
:root[data-theme="dark"] input[type="color"] { background: var(--sunk); }
:root[data-theme="dark"] .logo-edit img { background: #fff; padding: 4px 8px; border-radius: 6px; }
:root[data-theme="dark"] .logo-edit-dark img { background: none; }

/* ---------------------------------------------------------------- Grand texte et plein soleil */
:root[data-size="lg"] .main, :root[data-size="lg"] .sheet { zoom: 1.13; }
:root[data-size="lg"] .tabbar button span { font-size: 14px; }
:root[data-contrast="high"] { --line: #7D8A9C; --muted: #2E3A4C; --ink: #000; --bar-track: #C9D1DB; }
:root[data-contrast="high"][data-theme="dark"] { --line: #6E82A3; --muted: #D3DCEA; --ink: #fff; }
:root[data-contrast="high"] body { font-weight: 500; }
:root[data-contrast="high"] .card, :root[data-contrast="high"] .row, :root[data-contrast="high"] .hole, :root[data-contrast="high"] .tile, :root[data-contrast="high"] .kpi, :root[data-contrast="high"] .piece { border-width: 2px; }
:root[data-contrast="high"] .field-hint, :root[data-contrast="high"] .row-main span, :root[data-contrast="high"] .hole-main span { font-weight: 600; }

/* ---------------------------------------------------------------- Apparence (admin) */
.presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.preset { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 4px; border-radius: var(--r-sm); border: 2px solid var(--line); background: var(--surface); }
.preset.on { border-color: var(--accent); }
.preset .sw { position: relative; width: 44px; height: 30px; border-radius: 6px; overflow: hidden; }
.preset .sw i { position: absolute; right: 0; bottom: 0; width: 45%; height: 45%; border-top-left-radius: 6px; }
.preset small { font-size: 12px; color: var(--muted); font-weight: 600; text-align: center; line-height: 1.2; }
.preview { border-radius: var(--r); overflow: hidden; border: 1px solid var(--line); }
.pv-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 12px 14px; background: var(--brand-panel); color: var(--on-brand); }
.pv-head b { font-family: var(--cond); font-size: 22px; }
.pv-head span { color: color-mix(in srgb, var(--on-brand) 75%, transparent); font-size: 14px; }
.pv-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 14px; background: var(--surface); }
.pv-row .btn { pointer-events: none; }
.logo-edit-dark { background: #16233A; color: #9AA9BF; }
.switch { align-items: flex-start; }
.switch span { display: flex; flex-direction: column; }
.switch small { color: var(--muted); font-size: 14px; }
.seg label span .ic { width: 18px; height: 18px; }
:root[data-theme="dark"] .btn-dark { background: #E7ECF4; color: #16233A; }
:root[data-theme="dark"] .btn-ghost { background: var(--sunk); }
.hero-warn { background: color-mix(in srgb, var(--brand-panel) 82%, #B97C06); }
.hero-warn .btn { background: #fff; color: #16233A; position: relative; z-index: 1; width: 100%; }
.chip-danger { --c: var(--danger); }
.code-box { display: grid; gap: 4px; justify-items: center; text-align: center; padding: 18px; margin-bottom: 14px; border-radius: var(--r-lg); background: var(--sunk); border: 2px dashed var(--line); }
.code-id { font-size: 20px; margin-bottom: 8px; }
.code-val { font-family: var(--cond); font-size: 46px; letter-spacing: 4px; color: var(--accent); line-height: 1.1; }
.code-msg { width: 100%; margin-top: 12px; font-size: 15px !important; }
.acc-state { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.admin-row .row-main .chip { align-self: flex-start; margin-top: 4px; }
.tbl td .chip { margin: 2px 2px 0 0; }
.code-ent { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; border-radius: var(--r-sm); background: var(--sunk); }
.code-ent b { font-family: var(--cond); font-size: 22px; letter-spacing: 2px; }
.empty-dash { display: flex; align-items: center; gap: 16px; }
.empty-dash .ic { width: 40px; height: 40px; color: var(--muted); }
.empty-dash div { display: flex; flex-direction: column; gap: 4px; }
.empty-dash span { color: var(--muted); }

/* ---------------------------------------------------------------- Champs : texte toujours lisible */
input, select, textarea { color: var(--ink); }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.login-form input:not([type="checkbox"]) { background: #fff !important; color: #16233A !important; }
.login-form input::placeholder { color: #8A97A8; }
.login-form .field-hint { color: color-mix(in srgb, var(--on-brand) 72%, transparent); }
.login-tagline { display: none; }

/* ---------------------------------------------------------------- Mise à jour disponible */
.update-bar { position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); top: calc(10px + env(safe-area-inset-top, 0px)); display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; border-radius: 999px; background: var(--ink); color: var(--surface); font-weight: 600; font-size: 15px; box-shadow: 0 10px 30px -10px rgba(0,0,0,.45); max-width: calc(100vw - 24px); }
.update-bar .btn { min-height: 38px; padding: 0 14px; font-size: 14px; }

/* ---------------------------------------------------------------- Grand écran (ordinateur, tablette paysage) */
@media (min-width: 900px) {
  /* Connexion : deux colonnes */
  .shell-login .main { max-width: 1120px; padding: 0 48px; }
  .login { display: grid; grid-template-columns: minmax(0, 1fr) 440px; gap: 72px; align-items: center; min-height: 100dvh; padding: 48px 0; }
  .login-side { align-self: center; }
  .login-logo { height: 64px; padding: 12px 18px; }
  .login-app { font-size: 20px; margin-top: 6px; }
  .login-tagline { display: block; margin-top: 36px; max-width: 18ch; font-family: var(--cond); font-weight: 700; font-size: clamp(40px, 4.2vw, 58px); line-height: 1.02; color: var(--on-brand); }
  .login-panel { padding: 36px; border-radius: 22px; background: color-mix(in srgb, var(--on-brand) 6%, transparent); border: 1px solid color-mix(in srgb, var(--on-brand) 14%, transparent); }
  .login-title { margin: 0 0 22px; font-size: 40px; }
  .login-test { margin-top: 20px; }

  /* Foreur : navigation à gauche, contenu plus large */
  .shell-foreur { padding-left: 104px; }
  .shell-foreur .tabbar { top: 0; bottom: 0; right: auto; width: 104px; grid-template-columns: 1fr; grid-auto-rows: 84px; align-content: start; gap: 6px; padding: 84px 10px 10px; }
  .shell-foreur .tabbar button { min-height: 84px; font-size: 14px; }
  .shell-foreur .main { max-width: 1100px; padding: 28px 36px 56px; }
  .shell-foreur .tiles { grid-template-columns: 2fr 1fr 1fr; }
  .shell-foreur .tile-main { grid-column: auto; }
  .shell-foreur .holes { grid-template-columns: 1fr 1fr; }
  .shell-foreur .sticky-cta { position: static; }
  .shell-foreur .stack { grid-template-columns: 1fr 1fr; }
  .shell-foreur .hero { padding: 40px 40px 36px; }
  .shell-foreur .hero .btn { width: auto; min-width: 360px; }
  .shell-foreur .kv-grid { grid-template-columns: repeat(4, 1fr); }
  .shell-foreur .kv-grid .span2 { grid-column: span 2; }
  .toasts { bottom: 32px; }
}
@media (min-width: 900px) and (pointer: fine) {
  .btn, input:not([type="radio"]):not([type="checkbox"]):not([type="color"]), select { min-height: 48px; }
  input:not([type="radio"]):not([type="checkbox"]):not([type="color"]), select, textarea { font-size: 16px; }
}
.banner .btn { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn:not([class*="btn-"]) { background: var(--surface); color: var(--ink); border-color: var(--line); }
/* Fenêtre installée sur ordinateur : la barre de titre laisse la place aux boutons du système */
@media (display-mode: window-controls-overlay) {
  .topbar, .side { padding-top: max(10px, env(titlebar-area-height, 0px)); -webkit-app-region: drag; app-region: drag; }
  .topbar button, .topbar a, .side button { -webkit-app-region: no-drag; app-region: no-drag; }
}
.send-code { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
