/* Application Chantiers — Networkelec */
:root {
  --ink: #1B1F24; --ink2: #3A414B; --mute: #5B6470; --line: #E3E0DA; --line2: #D5D1CA; --line3: #EFECE7;
  --ground: #F4F2EE; --card: #FFFFFF; --seg: #E7E4DE; --accent: #C2410C; --accent-soft: #FDEBDD;
  --ok: #067647; --ok-bg: #ECFDF3; --ko: #B42318; --ko-bg: #FEE4E2; --info: #175CD3; --info-bg: #EFF8FF;
  --warn: #B54708; --warn-bg: #FEF0C7;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[x-cloak] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--ground); color: var(--ink); font: 16px/1.4 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
h1, h2 { margin: 0; font-family: Barlow, "Arial Narrow", system-ui, sans-serif; line-height: 1.1; }
h1 { font-size: 30px; font-weight: 700; }
h2 { font-size: 19px; font-weight: 700; }

/* Structure */
.app { height: 100dvh; display: flex; flex-direction: column; max-width: 720px; margin: 0 auto; position: relative; overflow: hidden; background: var(--ground); }
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 16px 110px; display: flex; flex-direction: column; gap: 12px; }
.scroll.tight { padding-bottom: 32px; }
.top { padding: calc(18px + var(--safe-t)) 20px 12px; display: flex; flex-direction: column; gap: 12px; }
.top .row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.kicker { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); }
.bar { display: flex; align-items: center; gap: 8px; padding: calc(10px + var(--safe-t)) 12px 10px 6px; background: var(--card); border-bottom: 1px solid var(--line); }
.bar .t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.bar .t b { font-family: Barlow, system-ui, sans-serif; font-size: 21px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .t small { font-size: 12px; color: var(--mute); }
.subtabs { padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); }

/* Barre d'onglets */
.nav { flex-shrink: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); background: var(--card); border-top: 1px solid var(--line); padding: 6px 4px calc(10px + var(--safe-b)); }
.nav button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--mute); padding: 4px 0; min-height: 52px; }
.nav button.on { color: var(--accent); }
.nav svg { width: 24px; height: 24px; }

/* Éléments */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.card.btn { text-align: left; cursor: pointer; width: 100%; }
.sec { display: flex; flex-direction: column; gap: 8px; }
.lbl { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); }
.hint { font-size: 12px; color: var(--mute); line-height: 1.4; }
.muted { color: var(--mute); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.big { font-family: Barlow, system-ui, sans-serif; font-size: 28px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }

input.in, select.in, textarea.in { width: 100%; height: 48px; padding: 0 12px; border: 1.5px solid var(--line2); border-radius: 10px; background: #fff; font-size: 16px; }
textarea.in { height: auto; min-height: 110px; padding: 12px; line-height: 1.45; resize: vertical; }
input.in:focus, select.in:focus, textarea.in:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.f { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; min-width: 0; }

.b { height: 48px; padding: 0 16px; border-radius: 12px; border: 1.5px solid var(--line2); background: #fff; font-weight: 600; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.b.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.b.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.b.green { background: var(--ok); border-color: var(--ok); color: #fff; }
.b.red { background: var(--ko); border-color: var(--ko); color: #fff; }
.b.ghost { border-color: transparent; background: transparent; }
.b.sm { height: 40px; font-size: 13px; padding: 0 12px; border-radius: 10px; }
.b.lg { height: 56px; font-size: 16px; }
.b.full { width: 100%; }
.b:disabled { opacity: .5; }
.icon-b { width: 44px; height: 44px; border: 0; background: transparent; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.link { border: 0; background: none; padding: 8px 4px; min-height: 40px; font-size: 13px; font-weight: 600; color: var(--info); text-decoration: underline; }
.fab { position: absolute; left: 16px; right: 16px; bottom: calc(84px + var(--safe-b)); z-index: 3; }
.fab.up { bottom: calc(140px + var(--safe-b)); }
.fab .b { width: 100%; height: 54px; box-shadow: 0 6px 18px rgba(27,31,36,.18); }

.seg { display: grid; gap: 4px; background: var(--seg); padding: 4px; border-radius: 10px; }
.seg button { height: 40px; border: 0; border-radius: 7px; background: transparent; color: var(--ink2); font-weight: 600; font-size: 14px; padding: 0 4px; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(27,31,36,.15); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex-shrink: 0; height: 40px; padding: 0 14px; border-radius: 999px; border: 1.5px solid var(--line2); background: #fff; font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip small { opacity: .7; font-weight: 500; }
.pill { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.count { font-size: 13px; font-weight: 600; color: var(--ink2); background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; }
.av { width: 44px; height: 44px; border-radius: 999px; background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: center; font-family: Barlow, system-ui, sans-serif; font-weight: 700; font-size: 17px; flex-shrink: 0; }
.av.sq { border-radius: 12px; }
.progress { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.progress span { height: 4px; border-radius: 2px; background: var(--line); }
.empty { padding: 32px 16px; text-align: center; color: var(--mute); font-size: 14px; }

/* Interrupteur */
.sw { width: 48px; height: 30px; border-radius: 999px; border: 0; padding: 3px; display: flex; align-items: center; background: #C9C5BE; justify-content: flex-start; flex-shrink: 0; }
.sw::after { content: ""; width: 24px; height: 24px; border-radius: 999px; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.sw.on { background: var(--ok); justify-content: flex-end; }

/* Case à cocher */
.check { min-height: 52px; display: flex; align-items: center; gap: 12px; padding: 0 14px; border-radius: 12px; border: 1.5px solid var(--line2); background: #fff; font-weight: 600; font-size: 15px; text-align: left; width: 100%; }
.check .box { width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid #9AA1AB; display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: #fff; }
.check.on .box { background: var(--c, var(--ok)); border-color: var(--c, var(--ok)); }
.check.on { border-color: var(--c, var(--ok)); color: var(--c, var(--ok)); background: var(--cbg, var(--ok-bg)); }

/* Étapes */
.steps { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.step { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 10px; border: 0; border-radius: 9px; background: transparent; text-align: left; }
.step .dot { width: 26px; height: 26px; border-radius: 999px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; border: 1.5px solid #C9C5BE; color: var(--mute); background: #fff; flex-shrink: 0; }
.step.done .dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.step .name { flex: 1; font-size: 15px; color: var(--mute); }
.step.done .name { color: var(--ink2); }
.step.cur .name { font-weight: 700; }

/* Bandeaux */
.banner { border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; border: 1.5px solid; }
.banner.red { background: #FFF4ED; border-color: #E62E05; }
.banner.red .bt { color: #97180C; }
.banner.blue { background: var(--info-bg); border-color: var(--info); }
.banner.blue .bt { color: #1849A9; }
.banner .bt { font-weight: 700; font-size: 15px; }
.offline { flex-shrink: 0; background: #3A414B; color: #fff; padding: calc(8px + var(--safe-t)) 16px 8px; font-size: 13px; display: flex; gap: 8px; align-items: center; }
.chronobar { flex-shrink: 0; height: 56px; border: 0; background: var(--ok); color: #fff; display: flex; align-items: center; gap: 12px; padding: 0 16px; text-align: left; width: 100%; }
.dotw { width: 10px; height: 10px; border-radius: 999px; background: #fff; flex-shrink: 0; animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .35; } }

.toast { position: absolute; left: 16px; right: 16px; bottom: calc(150px + var(--safe-b)); z-index: 20; background: var(--ink); color: #fff; border-radius: 12px; padding: 12px 14px; box-shadow: 0 8px 24px rgba(27,31,36,.25); display: flex; flex-direction: column; gap: 2px; }
.toast b { font-size: 14px; } .toast span { font-size: 13px; color: #D0D5DD; }
.modal { position: absolute; inset: 0; z-index: 30; background: rgba(27,31,36,.55); display: flex; align-items: flex-end; padding: 16px; }
.sheet { width: 100%; background: #fff; border-radius: 18px; padding: 20px; display: flex; flex-direction: column; gap: 14px; max-height: 90%; overflow-y: auto; }

/* Photos */
.photos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.photos.three { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ph { position: relative; border-radius: 12px; overflow: hidden; background: #D9D4CC; aspect-ratio: 1 / 1; border: 0; padding: 0; }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph .tag { position: absolute; left: 8px; top: 8px; font-size: 11px; font-weight: 700; color: #fff; border-radius: 6px; padding: 3px 7px; }
.ph .x { position: absolute; top: 6px; right: 6px; width: 36px; height: 36px; border: 0; border-radius: 999px; background: rgba(27,31,36,.65); color: #fff; display: flex; align-items: center; justify-content: center; }
.ph .when { position: absolute; left: 8px; bottom: 8px; font-size: 11px; color: #fff; background: rgba(27,31,36,.65); border-radius: 6px; padding: 2px 6px; }
.ph.sel { outline: 3px solid var(--ok); } .ph.unsel { opacity: .5; }
.ph .pend { position: absolute; right: 8px; bottom: 8px; font-size: 11px; color: #fff; background: var(--warn); border-radius: 6px; padding: 2px 6px; }
.file-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* Signature */
.sigpad { width: 100%; height: 180px; display: block; border: 1.5px dashed #9AA1AB; border-radius: 12px; background: #fff; touch-action: none; }
.sigimg { border: 1.5px solid var(--ok); border-radius: 12px; background: #fff; height: 180px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.sigimg img { max-width: 100%; max-height: 100%; }

/* Tableau notifications */
.matrix { display: grid; grid-template-columns: 1fr 60px 76px; align-items: center; row-gap: 4px; font-size: 14px; }
.matrix .h { font-size: 12px; color: var(--mute); text-align: center; }
.matrix .h:first-child { text-align: left; }
.matrix .sw { justify-self: center; }

/* Connexion */
.login { flex: 1; background: var(--ink); color: #fff; display: flex; flex-direction: column; justify-content: center; gap: 24px; padding: calc(24px + var(--safe-t)) 24px calc(24px + var(--safe-b)); overflow-y: auto; }
.login h1 { font-size: 40px; color: #fff; }
.login .kicker { color: #FDBA8C; }
.login .in { background: #2A3038; border-color: #3A414B; color: #fff; }
.login .note { background: #2A3038; color: #D0D5DD; border-radius: 12px; padding: 14px; font-size: 13px; }
.login .note b { color: #fff; font-size: 14px; display: block; }
.login .note.ok { background: var(--ok-bg); color: var(--ok); } .login .note.ok b { color: var(--ok); }
.login .link { color: #D0D5DD; }
.codebox { display: grid; grid-template-columns: minmax(0, 1fr) 20px minmax(0, 1fr); align-items: center; gap: 6px; }
.codebox input { height: 60px; text-align: center; font-family: ui-monospace, Menlo, monospace; font-size: 26px; letter-spacing: .25em; }
.userbtn { min-height: 64px; display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 1.5px solid #3A414B; border-radius: 12px; background: #2A3038; color: #fff; text-align: left; width: 100%; }
.err { color: #FDA29B; font-size: 13px; }
.err.dark { color: var(--ko); }
.okmsg { color: var(--ok); font-size: 13px; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media (min-width: 721px) { .app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); } }
