/* InfraElec Terrain — palette tirée de la marque : bleu marine (structure), orange (action), acier (secondaire). */
:root {
  --navy: #003070;
  --navy-2: #0b3f86;
  --navy-ink: #0f1e33;
  --orange: #e86800;
  --orange-2: #c95a00;
  --steel: #707070;
  --steel-2: #9aa3ae;
  --line: #d9dfe7;
  --paper: #f2f4f7;
  --surface: #ffffff;
  --live: #1f8a4c;
  --live-bg: #e3f3e9;
  --warn: #9a5b00;
  --warn-bg: #fff1dc;
  --bad: #b3261e;
  --bad-bg: #fbe7e5;
  --text: #13233a;
  --blue-bg: #e5edf8;
  --blue: #003070;
  --grey-bg: #e8eaed;
  --text-2: #55627a;
  --radius-s: 6px;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 30, 70, .08), 0 2px 8px rgba(0, 30, 70, .06);
  --display: 'Barlow Semi Condensed', 'Arial Narrow', Arial, sans-serif;
  --body: Barlow, system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  --tab-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0b1526; --surface: #12203a; --line: #24344f; --text: #e6ecf5; --text-2: #9fb0c8;
    --navy-ink: #e6ecf5; --live-bg: #12351f; --blue-bg: #1d3359; --blue: #b9d0f5; --grey-bg: #2a3548; --warn-bg: #3a2a10; --bad-bg: #3d1614; --steel-2: #6b7a90;
    --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--text); font: 400 16px/1.45 var(--body); font-variant-numeric: tabular-nums; }
a { color: var(--navy-2); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) a { color: #8fb6ff; } }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
[hidden] { display: none !important; }
.boot { padding: 40vh 0 0; text-align: center; color: var(--text-2); }

/* ───────── structure */
#app { min-height: 100dvh; }
#main { padding: 0 0 calc(var(--tab-h) + var(--safe-b) + 24px); outline: none; }
.page { max-width: 980px; margin: 0 auto; padding: 0 16px; }
.page.wide { max-width: none; }
.topbar { position: sticky; top: 0; z-index: 20; background: var(--navy); color: #fff; padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px; display: flex; align-items: center; gap: 10px; min-height: 56px; }
.topbar h1 { font: 600 21px/1.15 var(--display); margin: 0; flex: 1; letter-spacing: .01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .sub { display: block; font: 400 13px/1.2 var(--body); opacity: .75; }
.topbar .icon-btn { color: #fff; }
.topbar .btn { padding: 8px 14px; min-height: 40px; }
.icon-btn { background: none; border: 0; width: 44px; height: 44px; border-radius: 50%; display: inline-grid; place-items: center; cursor: pointer; color: var(--text); flex: none; }
.icon-btn:hover { background: rgba(127,127,127,.15); }
.icon-btn svg, .btn svg { width: 22px; height: 22px; }

#tabbar { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b); background: var(--surface); border-top: 1px solid var(--line); display: flex; }
#tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--text-2); font: 500 12px/1 var(--body); position: relative; }
#tabbar a svg { width: 24px; height: 24px; }
#tabbar a.on { color: var(--navy); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) #tabbar a.on { color: #fff; } }
#tabbar a.on::before { content: ''; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; background: var(--orange); border-radius: 0 0 3px 3px; }
.badge { position: absolute; top: 8px; left: calc(50% + 6px); min-width: 18px; height: 18px; border-radius: 9px; background: var(--orange); color: #fff; font: 600 11px/18px var(--body); text-align: center; padding: 0 5px; }

#rail { display: none; }
@media (min-width: 1000px) {
  #rail:not([hidden]) { display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; width: 220px; background: var(--navy); color: #fff; padding: 18px 12px; z-index: 30; }
  #tabbar { display: none !important; }
  #main { margin-left: 220px; padding-bottom: 40px; }
  .topbar { padding-top: 14px; padding-bottom: 14px; }
  .rail-brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; padding: 0 8px 22px; }
  .rail-brand .mark { width: 38px; height: 38px; border-radius: 8px; background: var(--orange); display: grid; place-items: center; font: 700 17px var(--display); }
  .rail-name { font: 600 17px/1.05 var(--display); } .rail-name small { font: 400 13px var(--body); opacity: .7; }
  .rail-links a { display: flex; align-items: center; gap: 12px; color: rgba(255,255,255,.78); text-decoration: none; padding: 10px 12px; border-radius: 8px; font-weight: 500; position: relative; }
  .rail-links a svg { width: 20px; height: 20px; }
  .rail-links a:hover { background: rgba(255,255,255,.08); color: #fff; }
  .rail-links a.on { background: rgba(255,255,255,.12); color: #fff; box-shadow: inset 3px 0 0 var(--orange); }
  .rail-links .badge { position: static; margin-left: auto; }
  .rail-links hr { border: 0; border-top: 1px solid rgba(255,255,255,.14); margin: 10px 4px; }
  .mobile-only { display: none !important; }
}
@media (max-width: 999px) { .desktop-only { display: none !important; } }

/* ───────── typographie & blocs */
h2.sec { font: 600 18px/1.2 var(--display); color: var(--navy-ink); margin: 26px 0 10px; display: flex; align-items: baseline; gap: 10px; }
h2.sec .count { font: 500 14px var(--body); color: var(--text-2); }
h2.sec a, h2.sec button { margin-left: auto; font: 500 14px var(--body); }
.muted { color: var(--text-2); }
.small { font-size: 14px; }
.num { font-family: var(--display); font-weight: 600; }
.empty { text-align: center; padding: 36px 16px; color: var(--text-2); border: 1.5px dashed var(--line); border-radius: var(--radius); margin: 12px 0; }
.empty .btn { margin-top: 12px; }
.panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel.pad { padding: 16px; }
.notice { padding: 12px 14px; border-radius: var(--radius-s); margin: 12px 0; font-size: 15px; }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
.notice.bad { background: var(--bad-bg); color: var(--bad); }
.notice.ok { background: var(--live-bg); color: var(--live); }
.notice.info { background: var(--surface); border-left: 4px solid var(--navy); box-shadow: var(--shadow); }

/* listes : rangées séparées plutôt que des cartes identiques */
.list { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list > .row + .row { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; text-decoration: none; color: inherit; min-height: 56px; }
a.row:hover, button.row:hover { background: rgba(0,48,112,.04); }
button.row { width: 100%; background: none; border: 0; text-align: left; cursor: pointer; }
.row .main { flex: 1; min-width: 0; }
.row .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .s { font-size: 14px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .end { text-align: right; flex: none; }
.row .time { font: 600 17px/1.1 var(--display); color: var(--navy-ink); min-width: 52px; }
.row .time small { display: block; font: 400 13px var(--body); color: var(--text-2); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.avatars { display: flex; }
.av { width: 28px; height: 28px; border-radius: 50%; color: #fff; font: 600 12px/28px var(--body); text-align: center; border: 2px solid var(--surface); margin-left: -6px; flex: none; }
.av:first-child { margin-left: 0; }
.av.lg { width: 40px; height: 40px; line-height: 40px; font-size: 15px; }

.pill { display: inline-flex; align-items: center; gap: 5px; font: 600 12.5px/1 var(--body); padding: 5px 9px; border-radius: 99px; white-space: nowrap; background: var(--paper); color: var(--text-2); }
/* ───────── boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 18px; border-radius: var(--radius-s); border: 1.5px solid var(--line); background: var(--surface); color: var(--text); font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--steel-2); }
.btn.primary { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn.primary:hover { background: var(--orange-2); border-color: var(--orange-2); }
.btn.navy { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.danger { color: var(--bad); border-color: transparent; background: transparent; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--navy-2); }
.btn.small { min-height: 38px; padding: 6px 12px; font-size: 14px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0; }
.actions .grow { flex: 1; }
.sticky-actions { position: sticky; bottom: calc(var(--tab-h) + var(--safe-b)); z-index: 10; background: linear-gradient(transparent, var(--paper) 22%); padding: 22px 0 12px; margin: 0; display: flex; gap: 10px; }
.sticky-actions .btn { flex: 1; }
@media (min-width: 1000px) { .sticky-actions { bottom: 0; } }

/* ───────── formulaires */
.form { display: grid; gap: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .grid3 { grid-template-columns: 1fr 1fr; } }
.field { display: grid; gap: 5px; min-width: 0; }
.field > span { font-size: 14px; font-weight: 600; color: var(--text-2); }
.field input, .field select, .field textarea { width: 100%; min-height: 48px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: var(--radius-s); background: var(--surface); }
.field textarea { min-height: 110px; resize: vertical; line-height: 1.4; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--navy-2); outline: none; box-shadow: 0 0 0 3px rgba(11,63,134,.18); }
.field .hint { font-size: 13px; color: var(--text-2); }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--navy); }
.seg { display: inline-flex; background: var(--paper); border: 1.5px solid var(--line); border-radius: var(--radius-s); padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 8px 12px; border-radius: 4px; font-weight: 600; font-size: 14px; color: var(--text-2); cursor: pointer; min-height: 38px; }
.seg button.on { background: var(--surface); color: var(--navy-ink); box-shadow: var(--shadow); }
.seg.tri button.on[data-v="ok"] { background: var(--live); color: #fff; }
.seg.tri button.on[data-v="nok"] { background: var(--bad); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 6px 14px 6px 6px; border-radius: 99px; border: 1.5px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 500; }
.chip .av { margin: 0; border: 0; }
.chip.on { border-color: var(--navy); background: #e5edf8; color: var(--navy); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip.on { background: #1d3359; color: #fff; } }
.chip.warn { border-style: dashed; }
.stepper { display: flex; align-items: stretch; border: 1.5px solid var(--line); border-radius: var(--radius-s); overflow: hidden; background: var(--surface); }
.stepper button { width: 44px; border: 0; background: var(--paper); font-size: 20px; font-weight: 600; cursor: pointer; color: var(--navy-ink); }
.stepper input { border: 0 !important; text-align: center; min-height: 44px !important; width: 100%; min-width: 0; box-shadow: none !important; }

/* lignes éditables (main-d'œuvre, matériel, circuits) */
.lines { display: grid; gap: 10px; }
.line { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; display: grid; gap: 10px; position: relative; }
.line .del { position: absolute; top: 4px; right: 4px; }
.line-lab { display: grid; grid-template-columns: 1fr 150px 40px; gap: 10px; align-items: end; }
.line-mat { display: grid; grid-template-columns: 1fr 120px 90px 40px; gap: 10px; align-items: end; }
@media (max-width: 600px) { .line-mat { grid-template-columns: 1fr 1fr 40px; } .line-mat .f-des { grid-column: 1 / -1; } }
.line .del-inline { align-self: end; }

/* ───────── feuille modale (bas de l'écran sur mobile) */
.sheet-back { position: fixed; inset: 0; background: rgba(5, 18, 40, .45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease-out; }
.sheet { background: var(--paper); width: 100%; max-width: 640px; max-height: 92dvh; overflow: auto; border-radius: 16px 16px 0 0; padding: 8px 16px calc(20px + var(--safe-b)); animation: up .2s ease-out; }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--steel-2); margin: 4px auto 10px; }
.sheet h3 { font: 600 20px var(--display); margin: 4px 0 14px; display: flex; align-items: center; }
.sheet h3 .icon-btn { margin-left: auto; }
@media (min-width: 700px) { .sheet-back { align-items: center; } .sheet { border-radius: 14px; padding-bottom: 20px; } .sheet .grab { display: none; } }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(30px); opacity: .6; } }
@media (prefers-reduced-motion: reduce) { .sheet-back, .sheet { animation: none; } }

#toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 14px); transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; width: min(92vw, 460px); pointer-events: none; }
#toast .t { background: var(--navy-ink); color: var(--paper); padding: 12px 16px; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.25); font-weight: 500; animation: up .2s ease-out; }
#toast .t.err { background: var(--bad); color: #fff; }
#toast .t.warn { background: #6b4300; color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) #toast .t:not(.err):not(.warn) { background: #e6ecf5; color: #0b1526; } }

/* ───────── connexion */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: var(--navy); }
.login-box { width: min(100%, 400px); }
.login-brand { color: #fff; margin-bottom: 28px; }
.login-brand .wm { font: 700 34px/1 var(--display); letter-spacing: .03em; }
.login-brand .tag { font: 500 12px/1 var(--body); letter-spacing: .14em; opacity: .7; margin-top: 6px; }
.login-brand p { margin: 18px 0 0; opacity: .85; }
.login .panel { padding: 22px; }

/* ───────── accueil : le disjoncteur de timbrage */
.hello { padding: 18px 0 4px; }
.hello h2 { font: 600 26px/1.15 var(--display); margin: 0; color: var(--navy-ink); }
.hello p { margin: 4px 0 0; color: var(--text-2); }
.clock-panel { display: grid; grid-template-columns: auto 1fr; gap: 22px; align-items: center; padding: 18px; margin-top: 14px; }
.breaker { --w: 96px; width: var(--w); height: calc(var(--w) * 1.75); border-radius: 10px; background: linear-gradient(#f7f8fa, #e4e8ee); border: 1px solid #c3cbd6; box-shadow: inset 0 -3px 0 rgba(0,0,0,.06), var(--shadow); position: relative; cursor: pointer; padding: 0; flex: none; -webkit-tap-highlight-color: transparent; }
.breaker .rail { position: absolute; left: 50%; top: 22%; bottom: 22%; width: 42%; transform: translateX(-50%); border-radius: 6px; background: #2a3342; box-shadow: inset 0 2px 5px rgba(0,0,0,.5); }
.breaker .lever { position: absolute; left: 50%; width: 52%; height: 30%; transform: translateX(-50%); border-radius: 6px; background: linear-gradient(#ff8a2b, var(--orange)); box-shadow: 0 2px 0 var(--orange-2), 0 4px 8px rgba(0,0,0,.25); transition: top .22s cubic-bezier(.5,1.6,.5,1); top: 52%; display: grid; place-items: center; color: #fff; font: 700 15px var(--display); }
.breaker.on .lever { top: 18%; }
.breaker .win { position: absolute; left: 50%; bottom: 7%; transform: translateX(-50%); width: 34%; height: 9%; border-radius: 3px; background: #b9c1cc; box-shadow: inset 0 1px 2px rgba(0,0,0,.3); }
.breaker.on .win { background: #2bbf62; }
.breaker .lbl { position: absolute; left: 0; right: 0; font: 700 13px var(--display); color: #5d6878; text-align: center; }
.breaker .lbl.i { top: 6%; } .breaker .lbl.o { bottom: 17%; }
.breaker:active .lever { filter: brightness(.95); }
@media (prefers-reduced-motion: reduce) { .breaker .lever { transition: none; } }
.clock-state { min-width: 0; }
.clock-state .st { font: 600 15px var(--body); color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.clock-state .st .dot { background: var(--steel-2); }
.clock-state.on .st { color: var(--live); }
.clock-state.on .st .dot { background: var(--live); box-shadow: 0 0 0 4px var(--live-bg); }
.clock-state .big { font: 600 54px/1 var(--display); color: var(--navy-ink); margin: 6px 0 4px; letter-spacing: -.01em; }
.clock-state .proj { font-size: 15px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; }
.clock-state .proj b { color: var(--text); font-weight: 600; }
.clock-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
@media (max-width: 380px) { .breaker { --w: 80px; } .clock-state .big { font-size: 44px; } }

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.kpi { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; }
.kpi .v { font: 600 26px/1.1 var(--display); color: var(--navy-ink); }
.kpi .v.neg { color: var(--bad); }
.kpi .v.pos { color: var(--live); }
.kpi .l { font-size: 13px; color: var(--text-2); }
@media (max-width: 420px) { .kpi .v { font-size: 22px; } .kpi { padding: 10px; } }

/* ───────── planning */
.week-nav { display: flex; align-items: center; gap: 6px; padding: 12px 0; flex-wrap: wrap; }
.week-nav .lbl { font: 600 18px var(--display); color: var(--navy-ink); min-width: 0; flex: 1; }
.board-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.board { display: grid; min-width: 860px; }
.board .h { font: 600 14px var(--body); padding: 10px 8px; border-bottom: 2px solid var(--navy); position: sticky; top: 0; background: var(--surface); color: var(--navy-ink); }
.board .h small { display: block; font-weight: 400; color: var(--text-2); }
.board .h.today { color: var(--orange); border-bottom-color: var(--orange); }
.board .h.off { color: var(--steel-2); }
.board .who { padding: 10px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; position: sticky; left: 0; background: var(--surface); z-index: 1; }
.board .cell { border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); padding: 5px; min-height: 76px; display: flex; flex-direction: column; gap: 5px; }
.board .cell.off { background: repeating-linear-gradient(-45deg, transparent 0 6px, rgba(112,112,112,.07) 6px 12px); }
.board .cell.drop { background: #fff3e8; outline: 2px dashed var(--orange); outline-offset: -3px; }
.board .cell.add { cursor: copy; }
.board .cell.add:hover { background: rgba(0,48,112,.03); }
.jcard { display: block; text-decoration: none; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--navy); border-radius: 5px; padding: 5px 7px; font-size: 13px; line-height: 1.25; cursor: pointer; }
.jcard[draggable="true"] { cursor: grab; }
.jcard .jt { font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.jcard .jm { color: var(--text-2); font-size: 12px; }
.jcard.en_cours { border-left-color: var(--live); }
.jcard.termine { opacity: .6; }
.jcard.annule { opacity: .5; text-decoration: line-through; }
.abs-tag { font-size: 12px; font-weight: 600; color: var(--warn); background: var(--warn-bg); border-radius: 4px; padding: 3px 6px; }
.dayhead { font: 600 16px var(--display); color: var(--navy-ink); margin: 20px 0 8px; display: flex; gap: 8px; align-items: baseline; }
.dayhead.today { color: var(--orange); }
.dayhead small { font: 400 13px var(--body); color: var(--text-2); }

/* détail mission */
.facts { display: grid; gap: 0; }
.fact { display: flex; gap: 12px; padding: 12px 14px; align-items: flex-start; }
.fact + .fact { border-top: 1px solid var(--line); }
.fact svg { width: 20px; height: 20px; color: var(--steel); flex: none; margin-top: 2px; }
.fact .fv { flex: 1; min-width: 0; }
.fact .fl { font-size: 13px; color: var(--text-2); }
.desc { white-space: pre-wrap; }
.status-flow { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 16px 0; }
.status-flow .btn { white-space: normal; text-align: center; }

/* rapports */
.sum-line { display: flex; justify-content: space-between; padding: 10px 14px; font-weight: 600; }
.sig-pad { background: #fff; border: 2px dashed var(--steel-2); border-radius: var(--radius); touch-action: none; width: 100%; height: 220px; display: block; }
.sig-img { background: #fff; border-radius: var(--radius-s); max-height: 120px; padding: 6px; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: var(--radius-s); overflow: hidden; background: var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .x { position: absolute; top: 4px; right: 4px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(0,0,0,.55); color: #fff; cursor: pointer; font-size: 16px; }
.thumb.pdf { display: grid; place-items: center; font-weight: 700; color: var(--navy); text-decoration: none; }
.add-photo { aspect-ratio: 1; border: 2px dashed var(--line); border-radius: var(--radius-s); display: grid; place-items: center; color: var(--text-2); cursor: pointer; text-align: center; font-size: 13px; font-weight: 600; background: var(--surface); }
.add-photo svg { width: 26px; height: 26px; display: block; margin: 0 auto 4px; }
.add-photo input { display: none; }

/* heures */
.days { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.dayrow { display: grid; grid-template-columns: 74px 1fr auto; gap: 10px; align-items: center; padding: 10px 14px; border: 0; background: none; width: 100%; text-align: left; cursor: pointer; color: inherit; }
.dayrow + .dayrow { border-top: 1px solid var(--line); }
.dayrow:hover { background: rgba(0,48,112,.04); }
.dayrow .d { font: 600 15px var(--display); }
.dayrow .d small { display: block; font: 400 12px var(--body); color: var(--text-2); }
.dayrow.off { background: var(--paper); color: var(--text-2); }
.dayrow.today { box-shadow: inset 4px 0 0 var(--orange); }
.dayrow .h { font: 600 17px var(--display); text-align: right; }
.dayrow .h small { display: block; font: 400 12px var(--body); color: var(--text-2); }
.bar-day { height: 6px; border-radius: 3px; background: var(--paper); overflow: hidden; margin-top: 4px; }
.bar-day > i { display: block; height: 100%; background: var(--navy); border-radius: 3px; }
.bar-day > i.over { background: var(--orange); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 6px 0 14px; overflow-x: auto; }
.tabs a, .tabs button { padding: 12px 14px; text-decoration: none; color: var(--text-2); font-weight: 600; border: 0; background: none; border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs .on { color: var(--navy-ink); border-bottom-color: var(--orange); }

/* OIBT */
.circuit { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; display: grid; gap: 10px; border-left: 4px solid var(--line); }
.circuit.ok { border-left-color: var(--live); }
.circuit.bad { border-left-color: var(--bad); }
.circuit .ch { display: flex; align-items: center; gap: 8px; }
.circuit .ch .n { font: 600 15px var(--display); color: var(--text-2); min-width: 24px; }
.circuit .ch input { flex: 1; font-weight: 600; }
.circuit .meas { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (max-width: 560px) { .circuit .meas { grid-template-columns: repeat(2, 1fr); } }
.field.flag input { border-color: var(--bad); background: var(--bad-bg); }
.vis { display: flex; align-items: center; gap: 12px; padding: 10px 14px; flex-wrap: wrap; }
.vis + .vis { border-top: 1px solid var(--line); }
.vis .vl { flex: 1; min-width: 200px; font-size: 15px; }

/* divers */
.table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); font-size: 15px; }
.table th { text-align: left; font-size: 13px; color: var(--text-2); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table tr:last-child td { border-bottom: 0; }
.table .n { text-align: right; font-family: var(--display); font-weight: 600; }
.search { position: relative; margin: 12px 0; }
.search input { width: 100%; min-height: 46px; padding: 10px 12px 10px 40px; border: 1.5px solid var(--line); border-radius: var(--radius-s); background: var(--surface); }
.search svg { position: absolute; left: 12px; top: 13px; width: 20px; height: 20px; color: var(--steel); }
.offline { position: fixed; top: 0; left: 0; right: 0; z-index: 70; background: var(--warn); color: #fff; text-align: center; font-size: 14px; padding: calc(env(safe-area-inset-top,0px) + 4px) 8px 4px; }

@media (max-width: 560px) { .row.wrap { flex-wrap: wrap; } .row.wrap .main { flex-basis: 100%; } .row.wrap .btn { flex: 1; } }
.row > svg { width: 22px; height: 22px; flex: none; color: var(--steel); }

/* ───────── v2 : tons des étiquettes */
.pill.t-blue { background: var(--blue-bg); color: var(--blue); }
.pill.t-green { background: var(--live-bg); color: var(--live); }
.pill.t-amber { background: var(--warn-bg); color: var(--warn); }
.pill.t-red { background: var(--bad-bg); color: var(--bad); }
.pill.t-grey { background: var(--grey-bg); color: var(--text-2); }
.pill.urgent { background: var(--bad); color: #fff; }
.btn.danger-fill { background: var(--bad); border-color: var(--bad); color: #fff; }
.sheet.wide { max-width: 860px; }
.bell { position: relative; }
.dotbadge { position: absolute; top: 6px; right: 4px; min-width: 17px; height: 17px; border-radius: 9px; background: var(--orange); color: #fff; font: 600 10.5px/17px var(--body); text-align: center; padding: 0 4px; }
.mode-switch { display: flex; margin: 12px 8px 0; background: rgba(255,255,255,.08); border-radius: 8px; padding: 3px; }
.mode-switch button { flex: 1; border: 0; background: transparent; color: rgba(255,255,255,.75); padding: 7px; border-radius: 6px; font-weight: 600; cursor: pointer; }
.mode-switch button.on { background: #fff; color: var(--navy); }
.mode-inline { margin: 12px 0 0; background: var(--paper); border: 1.5px solid var(--line); }
.mode-inline button { color: var(--text-2); }
.mode-inline button.on { background: var(--surface); color: var(--navy-ink); box-shadow: var(--shadow); }
.rail-search { display: flex; align-items: center; gap: 10px; width: calc(100% - 8px); margin: 0 4px 12px; padding: 9px 12px; border-radius: 8px; border: 0; background: rgba(255,255,255,.1); color: rgba(255,255,255,.8); cursor: pointer; font: inherit; }
.rail-search svg { width: 18px; height: 18px; }
@media (min-width: 1000px) { .rail-links { overflow-y: auto; flex: 1; } }

/* tableau de bord bureau */
.dash { display: grid; gap: 16px; grid-template-columns: 1fr; margin-top: 14px; }
@media (min-width: 1100px) { .dash { grid-template-columns: 1fr 1fr; } .dash .full { grid-column: 1 / -1; } }
.dash h2.sec { margin-top: 4px; }
.people { display: flex; flex-wrap: wrap; gap: 8px; }
.person { display: flex; align-items: center; gap: 8px; background: var(--surface); border-radius: 99px; padding: 4px 12px 4px 4px; box-shadow: var(--shadow); font-size: 14px; font-weight: 500; }
.person .st { width: 9px; height: 9px; border-radius: 50%; background: var(--steel-2); }
.person.on .st { background: var(--live); box-shadow: 0 0 0 3px var(--live-bg); }
.person.abs { opacity: .7; }
.person.abs .st { background: var(--orange); }
.kpis.k4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 700px) { .kpis.k4 { grid-template-columns: repeat(2, 1fr); } }
a.kpi { text-decoration: none; color: inherit; }
a.kpi:hover { outline: 2px solid var(--line); }
.kpi.alert .v { color: var(--orange); }

/* barres horizontales (statistiques, budgets) */
.hbar { height: 8px; border-radius: 4px; background: var(--paper); overflow: hidden; position: relative; min-width: 80px; }
.hbar > i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--navy); border-radius: 4px; }
.hbar > i.b2 { background: var(--orange); opacity: .85; }
.hbar.over > i { background: var(--bad); }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--text-2); margin: 6px 0; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.progress { height: 10px; border-radius: 5px; background: var(--paper); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--live); border-radius: 5px; }

/* sélection en masse */
.row .sel { width: 22px; height: 22px; accent-color: var(--navy); flex: none; }
.bulkbar { position: sticky; bottom: calc(var(--tab-h) + var(--safe-b) + 8px); z-index: 12; display: flex; gap: 8px; align-items: center; background: var(--navy-ink); color: var(--paper); padding: 10px 12px; border-radius: 10px; margin-top: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.bulkbar .grow { flex: 1; font-weight: 600; }
@media (min-width: 1000px) { .bulkbar { bottom: 12px; } }

/* semaines d'heures */
.week { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; display: grid; gap: 8px; }
.week + .week { margin-top: 10px; }
.week .wh { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.week .wh b { font: 600 16px var(--display); }
.week .nums { display: flex; gap: 16px; flex-wrap: wrap; font-size: 14px; color: var(--text-2); }
.week .nums b { color: var(--text); font-family: var(--display); font-size: 16px; }
.cat-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.cat-chips span { font-size: 12.5px; background: var(--paper); border-radius: 99px; padding: 3px 9px; color: var(--text-2); }
.dayrow .pl { font-size: 12px; color: var(--text-2); }
.dayrow .pl.diff { color: var(--warn); }

/* missions */
.jcard.planifie { border-style: dashed; background: repeating-linear-gradient(-45deg, var(--surface) 0 8px, var(--paper) 8px 16px); }
.jcard.urgent { box-shadow: inset 0 0 0 2px var(--bad); }
.busy-tag { font-size: 11.5px; color: var(--text-2); background: var(--grey-bg); border-radius: 4px; padding: 2px 6px; }
.month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.month .mh { background: var(--surface); padding: 8px; font-weight: 600; font-size: 13px; color: var(--text-2); }
.month .md { background: var(--surface); min-height: 104px; padding: 6px; display: flex; flex-direction: column; gap: 3px; cursor: pointer; }
.month .md.out { background: var(--paper); color: var(--steel-2); }
.month .md.off { background: repeating-linear-gradient(-45deg, var(--surface) 0 6px, var(--paper) 6px 12px); }
.month .md.today .dn { background: var(--orange); color: #fff; border-radius: 50%; width: 24px; height: 24px; display: grid; place-items: center; }
.month .dn { font: 600 14px var(--display); }
.month .mj { font-size: 11.5px; line-height: 1.25; padding: 2px 5px; border-radius: 3px; background: var(--blue-bg); color: var(--blue); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.month .mj.planifie { background: var(--warn-bg); color: var(--warn); }
.month .mj.depannage { background: var(--bad-bg); color: var(--bad); }
.month .more { font-size: 11.5px; color: var(--text-2); }
@media (max-width: 700px) { .month .md { min-height: 64px; } .month .mj { display: none; } .month .md .cnt { display: block; font-size: 12px; color: var(--navy-2); font-weight: 600; } }
.month .md .cnt { display: none; }
.issue { padding: 10px 12px; border-radius: var(--radius-s); font-size: 14px; }
.issue + .issue { margin-top: 6px; }
.issue.err { background: var(--bad-bg); color: var(--bad); }
.issue.crit { background: var(--bad); color: #fff; }
.issue.warn { background: var(--warn-bg); color: var(--warn); }

/* tâches */
.tk-pri { width: 4px; align-self: stretch; border-radius: 2px; background: var(--steel-2); flex: none; }
.tk-pri.haute { background: var(--orange); } .tk-pri.urgente { background: var(--bad); } .tk-pri.basse { background: var(--line); }
.comment { padding: 10px 14px; }
.comment + .comment { border-top: 1px solid var(--line); }
.comment .who { font-size: 13px; color: var(--text-2); display: flex; gap: 8px; align-items: center; }
.steps .row { min-height: 48px; }
.steps .row.done .t { text-decoration: line-through; color: var(--text-2); }

/* documents */
.docgroup + .docgroup { margin-top: 14px; }
.docgroup h3 { font: 600 15px var(--display); margin: 0 0 6px; color: var(--text-2); }
.doc-ic { width: 40px; height: 40px; border-radius: 8px; background: var(--blue-bg); color: var(--blue); display: grid; place-items: center; font: 700 11px var(--display); flex: none; overflow: hidden; }
.doc-ic img { width: 100%; height: 100%; object-fit: cover; }

/* modèles OIBT (éditeur) */
.tpl-sec { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; display: grid; gap: 10px; }
.tpl-sec + .tpl-sec { margin-top: 12px; }
.tpl-field { display: grid; grid-template-columns: 1fr 150px auto; gap: 8px; align-items: end; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius-s); }
.tpl-field .opts { grid-column: 1 / -1; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
@media (max-width: 600px) { .tpl-field { grid-template-columns: 1fr 1fr; } }
.of-field { padding: 12px 14px; display: grid; gap: 8px; }
.of-field + .of-field { border-top: 1px solid var(--line); }
.of-field .lbl { font-size: 15px; display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.of-field .lbl .req { color: var(--bad); }
.of-field .lbl .crit { font-size: 12px; font-weight: 600; color: var(--bad); }
.of-field .ctrl { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.of-field .ctrl input, .of-field .ctrl select, .of-field .ctrl textarea { min-height: 44px; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: var(--radius-s); background: var(--surface); }
.of-field .unit { color: var(--text-2); font-weight: 600; }
.audit-row .s { white-space: normal; }
code.inline { background: var(--paper); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.caps { display: grid; gap: 4px; }
.caps label { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.caps select { min-height: 36px; padding: 4px 8px; border: 1.5px solid var(--line); border-radius: 6px; background: var(--surface); }
.caps .from-role { font-size: 12px; color: var(--text-2); }

/* ───────── statistiques (palette validée : 3 séries, clair et sombre) */
.viz-root { --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --grid: var(--line); }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .viz-root { --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; } }
:root[data-theme="dark"] .viz-root { --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 14px 0 4px; }
.filters .range { display: flex; gap: 6px; align-items: center; }
.filters .range input { min-height: 38px; padding: 4px 8px; border: 1.5px solid var(--line); border-radius: 6px; background: var(--surface); }
.vtable { width: 100%; border-collapse: collapse; font-size: 14px; }
.vtable th { text-align: left; font-size: 13px; color: var(--text-2); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--grid); }
.vtable td { padding: 10px 12px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
.vtable tr:last-child td { border-bottom: 0; }
.vtable .n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.vtable a { font-weight: 600; text-decoration: none; }
.vtable .chart-col { width: 34%; min-width: 120px; }
@media (max-width: 700px) { .vtable .chart-col { display: none; } }
.gbars { display: grid; gap: 2px; }
.gbar { display: block; height: 7px; border-radius: 0 4px 4px 0; min-width: 0; outline-offset: 2px; position: relative; }
.gbar::after { content: ''; position: absolute; inset: -4px 0; }
.gbar:hover, .gbar:focus-visible { filter: brightness(1.12); }
.s1 { background: var(--series-1); } .s2 { background: var(--series-2); } .s3 { background: var(--series-3); }
.legend .sw { display: inline-block; width: 12px; height: 8px; border-radius: 0 3px 3px 0; margin-right: 6px; vertical-align: 0; }
.vtip { position: fixed; z-index: 80; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; box-shadow: 0 4px 14px rgba(0,0,0,.18); display: grid; grid-template-columns: auto auto; gap: 2px 8px; align-items: center; font-size: 13px; }
.vtip strong { grid-column: 1 / -1; font-size: 15px; }
.vtip .key { width: 12px; height: 2px; display: inline-block; }
.vtip span { color: var(--text-2); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.board-filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 0 0 10px; }
.board-filters select { min-height: 38px; padding: 4px 10px; border: 1.5px solid var(--line); border-radius: 6px; background: var(--surface); font-weight: 600; font-size: 14px; }
