/* Style iPhone « Liquid Glass » : SF, grands titres, listes groupées arrondies,
   surfaces en verre dépoli, barre d'onglets flottante. */
:root {
    --bg: #F2F2F7;
    --cell: #FFFFFF;
    --label: #000000;
    --secondary: #8A8A8E;
    --sep: rgba(60, 60, 67, 0.22);
    --fill: rgba(118, 118, 128, 0.12);
    --tint: #007AFF;
    --green: #34C759;
    --orange: #FF9500;
    --red: #FF3B30;
    --glass: rgba(255, 255, 255, 0.66);
    --glass-line: rgba(255, 255, 255, 0.75);
    --glass-shadow: 0 8px 30px rgba(0, 0, 0, 0.10), 0 1px 3px rgba(0, 0, 0, 0.06);
    --radius: 22px;
    --pad: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overscroll-behavior: none; }
body {
    background: var(--bg);
    color: var(--label);
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display', 'Helvetica Neue', Inter, system-ui, sans-serif;
    font-size: 17px;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button, input, select { font-family: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- Cadre de l'appli : colle exactement à l'écran visible ---------- */
.app {
    position: fixed; top: 0; bottom: 0; left: 0; right: 0;
    display: flex; flex-direction: column;
    background: var(--bg);
    overflow: hidden;
}
.main { order: 1; flex: 1; min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.app:not(.has-nav) .main { width: 100%; max-width: 480px; margin: 0 auto; }

/* ---------- Barre d'onglets flottante (téléphone) ---------- */
.side { order: 2; flex: none; padding: 6px 14px calc(8px + env(safe-area-inset-bottom)); }
.side .brand, .side .side-user { display: none; }
.nav {
    display: flex; height: 64px; padding: 6px; border-radius: 32px;
    background: var(--glass); border: 1px solid var(--glass-line); box-shadow: var(--glass-shadow);
    -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px);
}
.nav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; color: #3C3C43; font-size: 10px; font-weight: 500; border-radius: 26px;
}
.nav a.on { color: var(--tint); background: rgba(0, 122, 255, 0.12); font-weight: 600; }

/* ---------- Recherche ---------- */
.topbar { display: none; flex: none; align-items: center; gap: 12px; padding: 8px var(--pad) 4px; order: -1; }
.topbar.has-search { display: flex; }
.topbar-search { flex: 1; min-width: 0; }
.avatar {
    display: none; width: 36px; height: 36px; border-radius: 50%; flex: none;
    background: var(--fill); color: var(--secondary); font-size: 14px; font-weight: 600;
    align-items: center; justify-content: center;
}
.search { position: relative; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--secondary); pointer-events: none; }
.search input {
    width: 100%; height: 44px; padding: 0 16px 0 42px; border: 0; border-radius: 22px;
    background: var(--fill); font-size: 17px; outline: none; -webkit-appearance: none; appearance: none;
}
.search input::placeholder { color: rgba(60, 60, 67, 0.6); }
.search input:focus { box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.25); }

/* ---------- Barre « Stock en direct » (verre) ---------- */
.livebar {
    order: -3; flex: none; display: flex; align-items: center; gap: 10px;
    margin: 8px var(--pad) 0; padding: 9px 16px; border-radius: 22px;
    background: var(--glass); border: 1px solid var(--glass-line);
    -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px);
    font-size: 12px; color: var(--secondary); white-space: nowrap;
    overflow-x: auto; scrollbar-width: none;
}
.livebar::-webkit-scrollbar { display: none; }
.livebar .live { display: flex; align-items: center; gap: 6px; color: var(--label); font-weight: 600; }
.livebar .pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: pulse 2s ease-out infinite; }
.livebar b { font-size: 13px; font-weight: 700; }
.livebar .n-stock { color: #248A3D; }
.livebar .n-out { color: #C93400; }
.livebar .n-panne { color: #D70015; }
.livebar .n-ev { color: var(--tint); }
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(52, 199, 89, 0.5); }
    70% { box-shadow: 0 0 0 6px rgba(52, 199, 89, 0); }
    100% { box-shadow: 0 0 0 0 rgba(52, 199, 89, 0); }
}
@media (prefers-reduced-motion: reduce) { .livebar .pulse { animation: none; } }

/* ---------- Grands titres ---------- */
.head { order: -2; padding: 14px calc(var(--pad) + 4px) 0; display: flex; flex-direction: column; gap: 2px; flex: none; }
.head-split { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }
.eyebrow { font-size: 13px; color: var(--secondary); }
.title { margin: 0; font-size: 34px; font-weight: 700; letter-spacing: 0.35px; line-height: 1.15; }
.row-head { flex-direction: row; align-items: center; gap: 12px; padding-left: var(--pad); }
.h2 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: 0.2px; }
.back {
    width: 44px; height: 44px; border-radius: 50%; flex: none; color: var(--tint);
    display: flex; align-items: center; justify-content: center;
    background: var(--glass); border: 1px solid var(--glass-line); box-shadow: var(--glass-shadow);
    -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px);
}
.nav-add {
    flex: none; height: 44px; padding: 0 16px 0 12px; border-radius: 22px; color: var(--tint);
    display: inline-flex; align-items: center; gap: 4px; font-size: 16px; font-weight: 600; white-space: nowrap;
    background: var(--glass); border: 1px solid var(--glass-line); box-shadow: var(--glass-shadow);
    -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px);
}

/* ---------- Boutons ---------- */
.btn {
    width: 100%; height: 52px; border: 0; border-radius: 26px; cursor: pointer;
    background: var(--tint); color: #fff; font-size: 17px; font-weight: 600;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    box-shadow: 0 6px 18px rgba(0, 122, 255, 0.32);
}
.btn:active { opacity: 0.85; }
.btn.wait { background: var(--fill); color: var(--secondary); cursor: default; box-shadow: none; }
.btn.sm { height: 44px; font-size: 16px; }
.pill {
    flex: none; min-height: 44px; padding: 0 4px; border: 0; background: transparent; color: var(--tint);
    font-size: 17px; font-weight: 500; cursor: pointer; display: flex; align-items: center; gap: 4px;
}
.link { background: none; border: 0; padding: 12px 8px; font-size: 17px; color: var(--tint); cursor: pointer; }
.link-danger { background: none; border: 0; padding: 14px 4px; color: var(--red); font-size: 17px; cursor: pointer; text-align: left; }
.icon-btn { background: none; border: 0; padding: 8px; border-radius: 50%; color: var(--secondary); cursor: pointer; display: flex; }
.cta { order: 5; padding: 10px var(--pad) 4px; flex: none; }

/* ---------- Filtres (capsules) ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 14px var(--pad) 2px; flex: none; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips.tight { padding-top: 0; padding-bottom: 6px; }
.chip {
    flex: none; min-height: 40px; padding: 0 16px; border-radius: 20px; border: 0;
    background: var(--cell); color: var(--label); font-size: 15px; font-weight: 500; white-space: nowrap; cursor: pointer;
    display: flex; align-items: center; gap: 6px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.chip.on { background: var(--tint); color: #fff; }
.chip .n { opacity: 0.55; }

/* ---------- Listes groupées ---------- */
.scroll {
    flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
    padding: 14px var(--pad) 0; display: flex; flex-direction: column;
    overscroll-behavior: contain;
}
.section { margin-bottom: 22px; flex: none; }
.group-title { margin: 0 0 6px 16px; font-size: 13px; font-weight: 400; text-transform: uppercase; letter-spacing: 0.2px; color: var(--secondary); }
.group { background: var(--cell); border-radius: var(--radius); overflow: hidden; flex: none; margin-bottom: 16px; }
.section > .group { margin-bottom: 0; }
.spacer { height: 16px; flex: none; }
.empty { color: var(--secondary); font-size: 15px; padding: 24px 8px; margin: 0; text-align: center; }
.grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.name { font-size: 17px; font-weight: 400; }
.sub { font-size: 13px; color: var(--secondary); }
.sub .bad { color: #D70015; font-weight: 500; }
.sub.trace { margin: 4px 0 0; line-height: 1.5; }
.sub.trace b { color: var(--label); font-weight: 600; }
.qty { font-size: 17px; color: var(--secondary); white-space: nowrap; }

/* Une ligne (matériel, checklist, événement…) */
.cell, .row, .ev, .act {
    position: relative; display: flex; align-items: center; gap: 12px; flex: none;
    width: 100%; min-height: 56px; padding: 10px 16px;
    border: 0; background: transparent; text-align: left; cursor: pointer;
}
.cell + .cell::before, .row + .row::before, .ev + .ev::before, .act + .act::before {
    content: ''; position: absolute; top: 0; right: 0; left: 16px; height: 0.5px; background: var(--sep);
}
.cell + .cell::before { left: 62px; }
.cell:active, .row:active, .ev:active { background: rgba(60, 60, 67, 0.08); }
.row:disabled { cursor: default; }

.icon-tile {
    width: 34px; height: 34px; border-radius: 9px; flex: none; color: #fff; background: var(--secondary);
    display: flex; align-items: center; justify-content: center;
}
.icon-tile svg { width: 20px; height: 20px; }
.t-informatique { background: #007AFF; }
.t-ecrans { background: #AF52DE; }
.t-video { background: #FF3B30; }
.t-audio { background: #FF9500; }
.t-cables { background: #8E8E93; }
.t-none { background: #34C759; }
.cell-title { font-size: 17px; line-height: 1.25; }
.cell-sub { font-size: 13px; color: var(--secondary); }
.cell-trail { display: flex; align-items: center; gap: 6px; flex: none; color: var(--secondary); }
.cell-trail b { font-size: 17px; font-weight: 600; color: var(--label); }
.cell-trail small { font-size: 15px; }
.cell-trail.zero b { color: #D70015; }
.chev { color: #C7C7CC; display: flex; }
.chev svg { width: 14px; height: 14px; }
.st { font-weight: 500; }
.st.ok { color: #248A3D; }
.st.warn { color: #C93400; }
.st.bad { color: #D70015; }

/* ---------- Pastilles ---------- */
.tag {
    display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 12px;
    font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--fill); color: var(--secondary);
}
.tag.ok { background: rgba(52, 199, 89, 0.16); color: #248A3D; }
.tag.warn { background: rgba(255, 149, 0, 0.18); color: #B25000; }
.tag.bad { background: rgba(255, 59, 48, 0.14); color: #D70015; }
.tag.info { background: rgba(0, 122, 255, 0.13); color: #0062CC; }

/* ---------- Événements ---------- */
.ev { flex-direction: column; align-items: stretch; gap: 8px; padding: 14px 16px; }
.ev-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ev-name { font-size: 17px; font-weight: 600; }
.bar { display: block; height: 4px; border-radius: 2px; background: var(--fill); }
.bar > span { display: block; height: 4px; border-radius: 2px; background: var(--tint); }

/* ---------- Journal d'activité ---------- */
.act { flex-direction: column; align-items: stretch; gap: 3px; padding: 12px 16px; cursor: default; }
.act-msg { font-size: 15px; line-height: 1.35; }
.whoami { display: flex; align-items: center; justify-content: space-between; padding: 8px 4px; flex: none; }

/* ---------- Progression ---------- */
.prog {
    order: -1; margin: 16px var(--pad) 0; padding: 16px; display: flex; flex-direction: column; gap: 10px; flex: none;
    background: var(--cell); border-radius: var(--radius);
}
.prog-top { display: flex; align-items: baseline; justify-content: space-between; }
.big { font-size: 28px; font-weight: 700; letter-spacing: 0.3px; }
.big small { font-size: 17px; font-weight: 400; color: var(--secondary); }
.miss { font-size: 13px; color: #D70015; font-weight: 600; }
.track { height: 6px; border-radius: 3px; background: var(--fill); overflow: hidden; }
.track > div { height: 6px; border-radius: 3px; background: var(--tint); transition: width 0.2s; }
.hint { padding: 14px calc(var(--pad) + 4px) 6px; margin: 0; font-size: 13px; color: var(--secondary); flex: none; }

/* ---------- Cases rondes ---------- */
.check {
    width: 26px; height: 26px; border-radius: 50%; flex: none; background: transparent;
    border: 1.5px solid #C7C7CC; color: #fff;
    display: flex; align-items: center; justify-content: center;
}
.check svg { display: none; }
[data-state="on"] .check, [data-state="ok"] .check { background: var(--tint); border-color: var(--tint); }
[data-state="missing"] .check { background: var(--red); border-color: var(--red); }
[data-state="on"] .ic-check, [data-state="ok"] .ic-check { display: block; }
[data-state="missing"] .ic-x { display: block; }
.sr { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.pick { position: relative; }
.pick-main { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; cursor: pointer; }
.pick input:checked + .check { background: var(--tint); border-color: var(--tint); }
.pick input:checked + .check .ic-check { display: block; }
.pick input:focus-visible + .check { outline: 2px solid var(--tint); outline-offset: 2px; }
.lab-ok, .lab-missing { display: none; font-size: 15px; white-space: nowrap; }
[data-state="ok"] .lab-ok { display: block; color: #248A3D; font-weight: 500; }
[data-state="missing"] .lab-missing { display: block; color: #D70015; font-weight: 500; }
.qty-in {
    width: 60px; height: 38px; flex: none; text-align: center; font-size: 17px;
    border: 0; border-radius: 10px; background: var(--fill); outline: none;
}
.qty-in:focus { box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.25); }
.qty-in.bad { background: rgba(255, 59, 48, 0.12); color: #D70015; }
.grow > .err { margin-top: 2px; line-height: 1.35; }

/* ---------- Formulaires : groupes à l'iOS ---------- */
.form {
    display: flex; flex-direction: column; gap: 0; flex: none;
    margin: 16px var(--pad) 0; padding: 0; background: var(--cell); border-radius: var(--radius); overflow: hidden;
}
.form.flush { margin: 0; }
.form > * + * { border-top: 0.5px solid var(--sep); }
.form > .sub { padding: 10px 16px; }
.evform { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.pair { display: flex; gap: 0; }
.pair .field { flex: 1; min-width: 0; }
.form > .pair > .field + .field { border-top: 0; border-left: 0.5px solid var(--sep); }
.field { display: flex; flex-direction: column; gap: 2px; padding: 9px 16px 8px; }
.field label { font-size: 12px; color: var(--secondary); }
.field input, .field select {
    width: 100%; height: 30px; padding: 0; border: 0; border-radius: 0; background: transparent;
    font-size: 17px; outline: none;
}
.field input::placeholder { color: #C7C7CC; }
.err { font-size: 13px; color: #D70015; }
.sechead { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px calc(var(--pad) + 4px) 6px; flex: none; }
.sec-title { font-size: 13px; font-weight: 400; text-transform: uppercase; letter-spacing: 0.2px; color: var(--secondary); }
.sechead .sub { display: block; }
.quick {
    display: flex; flex-direction: column; gap: 12px; flex: none;
    margin: 0 0 16px; padding: 16px; border-radius: var(--radius); background: var(--cell);
}
.quick .field { padding: 0; }
.quick .field input, .quick .field select { height: 40px; padding: 0 12px; border-radius: 10px; background: var(--fill); }
.quick .pair { gap: 12px; }
.quick-actions { display: flex; align-items: center; gap: 12px; }
.quick-actions .btn { flex: 1; }

/* ---------- Messages ---------- */
.flash { margin: 10px var(--pad) 0; padding: 12px 16px; border-radius: 16px; background: rgba(52, 199, 89, 0.16); color: #1E6E36; font-size: 15px; flex: none; }
.flash.err { background: rgba(255, 59, 48, 0.14); color: #A8140B; }

/* =====================  GRAND ÉCRAN : barre latérale à la iPadOS  ===================== */
@media (min-width: 900px) {
    :root { --pad: 28px; }

    .app { flex-direction: row; }
    .side {
        order: 0; width: 264px; display: flex; flex-direction: column; padding: 20px 14px;
        background: rgba(255, 255, 255, 0.55); border-right: 0.5px solid var(--sep);
        -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px);
    }
    .side .brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px; }
    .brand .logo {
        width: 38px; height: 38px; border-radius: 10px; background: var(--tint); color: #fff;
        font-weight: 700; display: flex; align-items: center; justify-content: center;
    }
    .brand-text { display: flex; flex-direction: column; line-height: 1.2; }
    .brand-text b { font-size: 17px; }
    .brand-text small { font-size: 12px; color: var(--secondary); }
    .nav { flex-direction: column; height: auto; padding: 0; gap: 2px; margin-top: 24px; background: none; border: 0; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; border-radius: 0; }
    .nav a { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 0 12px; min-height: 44px; font-size: 17px; font-weight: 400; color: var(--label); border-radius: 10px; }
    .nav a:hover { background: rgba(60, 60, 67, 0.06); }
    .nav a.on { background: rgba(0, 122, 255, 0.14); color: var(--tint); font-weight: 600; }
    .side .side-user { display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 12px 8px 0; border-top: 0.5px solid var(--sep); }
    .side-user .avatar { display: flex; }
    .side-user .who { flex: 1; min-width: 0; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    .main { align-items: center; }
    .main > * { width: 100%; max-width: 760px; }
    .main > .livebar, .main > .flash, .main > .prog, .main > .form { width: calc(100% - 2 * var(--pad)); max-width: calc(760px - 2 * var(--pad)); }
    .head, .topbar, .livebar { order: 0; }
    .topbar .avatar { display: none; }
    .cta .btn { max-width: 380px; }
    .whoami { display: none; }
}
