/* Typographies de la charte MLOCTET+ : DIN Pro (textes), Roketto (titre principal, avec parcimonie) */
@font-face { font-family: "DIN Pro"; src: url("/fonts/dinpro-300.woff2") format("woff2"); font-weight: 300; font-display: swap; }
@font-face { font-family: "DIN Pro"; src: url("/fonts/dinpro-400.woff2") format("woff2"); font-weight: 400 500; font-display: swap; }
@font-face { font-family: "DIN Pro"; src: url("/fonts/dinpro-700.woff2") format("woff2"); font-weight: 600 800; font-display: swap; }
@font-face { font-family: "Roketto"; src: url("/fonts/roketto.woff2") format("woff2"); font-display: swap; }
.brand-title { font-family: "Roketto", "DIN Pro", system-ui, sans-serif; font-weight: 400; letter-spacing: .01em; }

:root {
  /* Charte MLOCTET+ : bleu #16417b, crème #fff0db, blanc */
  --blue: #16417b;
  --cream: #fff0db;
  --bg: #fdf8f0;
  --surface: #ffffff;
  --surface-2: #fff4e4;
  --text: #0f2747;
  --muted: #5d6c83;
  --border: #eadfcc;
  --brand: #16417b;
  --brand-ink: #fff0db;
  --brand-soft: #fff0db;
  --nav-bg: #16417b;
  --nav-ink: #fff0db;
  --ok: #18794e;
  --ok-soft: #e3f4ea;
  --warn: #a35200;
  --warn-soft: #fde9cf;
  --bad: #c42b2b;
  --bad-soft: #fbe5e5;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(22, 65, 123, .06), 0 2px 6px rgba(22, 65, 123, .06);
  --nav-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a182c;
    --surface: #10243f;
    --surface-2: #17304f;
    --text: #fff6ea;
    --muted: #a9b6cb;
    --border: #213d63;
    --brand: #fff0db;
    --brand-ink: #16417b;
    --brand-soft: #1b3a63;
    --nav-bg: #0d1f38;
    --nav-ink: #fff0db;
    --ok: #4cc38a;
    --ok-soft: #12301f;
    --warn: #f0a548;
    --warn-soft: #33240f;
    --bad: #ff7b7b;
    --bad-soft: #3a1a1d;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15.5px/1.45 "DIN Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--brand); text-decoration: none; }
h1 { font-size: 24px; font-weight: 700; margin: 0 0 4px; color: var(--brand); }
@media (prefers-color-scheme: dark) { h1 { color: var(--text); } }
h2 { font-size: 16px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13.5px; }

/* --- layout --- */
.app { display: flex; min-height: 100vh; }
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--nav-h); z-index: 20;
  display: flex; background: var(--nav-bg); border-top: 0;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav .brand { display: none; }
.nav .brand img { width: 168px; display: block; }
.topbar { display: flex; align-items: center; justify-content: center; background: var(--nav-bg); padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top)); }
.topbar img { height: 34px; }
.nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--nav-ink); opacity: .72; font-size: 11.5px; font-weight: 600; position: relative;
}
.nav a svg { width: 22px; height: 22px; }
.nav a.active { color: var(--nav-ink); opacity: 1; }
.nav a.active svg { stroke-width: 2.4; }
.nav .badge { position: absolute; top: 6px; left: calc(50% + 6px); }
main { flex: 1; min-width: 0; padding: 16px 16px calc(var(--nav-h) + 24px); max-width: 1100px; margin: 0 auto; }
@media (min-width: 900px) {
  .nav { position: sticky; top: 0; height: 100vh; width: 220px; flex-direction: column; border-top: 0; border-right: 1px solid var(--border); padding: 16px 10px; gap: 2px; }
  .nav .brand { display: block; padding: 8px 10px 26px; }
  .topbar { display: none; }
  .nav a { flex: none; flex-direction: row; justify-content: flex-start; gap: 10px; font-size: 14.5px; padding: 10px 12px; border-radius: 8px; }
  .nav a:hover { opacity: 1; background: rgba(255, 240, 219, .08); }
  .nav a.active { background: rgba(255, 240, 219, .16); }
  .nav .who { margin-top: auto; color: var(--nav-ink); opacity: .7; font-size: 12.5px; padding: 8px 12px; }
  .nav .badge { position: static; margin-left: auto; }
  main { padding: 28px 32px 40px; }
}

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }

/* --- surfaces --- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card, .stack > * + * { margin-top: 12px; }
.grid > .card + .card { margin-top: 0; }
.grid { display: grid; gap: 12px; }
.grid.kpis { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 700px) { .grid.kpis { grid-template-columns: repeat(4, 1fr); } .grid.two { grid-template-columns: 1fr 1fr; } }
.kpi { padding: 14px 16px; }
.kpi .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: 13px; }
.kpi.alert { border-color: var(--warn); background: var(--warn-soft); }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.list > li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.list a.row { display: flex; align-items: center; gap: 12px; color: inherit; width: 100%; }
.qty { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 17px; text-align: right; white-space: nowrap; }

/* --- controls --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; padding: 10px 16px; border-radius: 10px; cursor: pointer; min-height: 44px;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { min-height: 34px; padding: 6px 12px; font-size: 13.5px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions.end { justify-content: flex-end; }

label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); width: 100%;
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; accent-color: var(--brand); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; }

.scan { display: flex; gap: 8px; }
.scan input { font-size: 17px; }
.scan .btn { flex: none; }
.search-big { position: relative; }
.search-big input { padding-left: 42px; font-size: 17px; min-height: 52px; }
.search-big svg { position: absolute; left: 13px; top: 15px; width: 22px; height: 22px; color: var(--muted); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: var(--surface); padding: 6px 12px; border-radius: 99px; font: inherit; font-size: 13.5px; cursor: pointer; color: var(--text); }
.chip.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; font-size: 11.5px; font-weight: 700; background: var(--bad); color: #fff; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.brand { background: var(--brand-soft); color: var(--brand); }

.notice { padding: 12px 14px; border-radius: 10px; background: var(--brand-soft); font-size: 14px; }
.notice.warn { background: var(--warn-soft); }

/* --- stepper / tabs --- */
.stepper { display: flex; gap: 6px; margin-bottom: 14px; }
.stepper button {
  flex: 1; display: flex; align-items: center; gap: 8px; justify-content: center; padding: 10px; font: inherit; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted); border-radius: 10px; cursor: pointer;
}
.stepper button .n { width: 22px; height: 22px; border-radius: 50%; background: var(--surface-2); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; }
.stepper button.on { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.stepper button.on .n { background: var(--brand); color: var(--brand-ink); }
.stepper button:disabled { cursor: default; }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.tabs button { text-align: left; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; font: inherit; color: var(--text); }
.tabs button .v { font-size: 24px; font-weight: 700; display: block; font-variant-numeric: tabular-nums; }
.tabs button .l { font-size: 12.5px; color: var(--muted); }
.tabs button.ok.on { border-color: var(--ok); background: var(--ok-soft); }
.tabs button.missing.on { border-color: var(--warn); background: var(--warn-soft); }
.tabs button.unexpected.on { border-color: var(--bad); background: var(--bad-soft); }
.tabs button.ok .v { color: var(--ok); } .tabs button.missing .v { color: var(--warn); } .tabs button.unexpected .v { color: var(--bad); }

.sn-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sn-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border-radius: 8px; padding: 6px 6px 6px 10px; }
.sn-chip button { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 2px 4px; }
.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--brand); transition: width .2s; }
.progress.done > div { background: var(--ok); }

/* --- toast / modal --- */
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 16px); z-index: 60; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); }
@media (min-width: 900px) { #toasts { bottom: 24px; } }
.toast { padding: 12px 14px; border-radius: 10px; background: var(--text); color: var(--bg); font-weight: 500; box-shadow: 0 6px 24px rgba(0,0,0,.2); animation: pop .15s ease-out; }
.toast.ok { background: var(--ok); color: #fff; } .toast.bad { background: var(--bad); color: #fff; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal .sheet { background: var(--surface); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 16px 16px 0 0; padding: 18px; }
@media (min-width: 700px) { .modal { align-items: center; } .modal .sheet { border-radius: 16px; } }
.camera video { width: 100%; border-radius: 10px; background: #000; aspect-ratio: 4/3; object-fit: cover; }
.camera .last { margin-top: 10px; min-height: 22px; font-weight: 600; text-align: center; }

.empty { text-align: center; color: var(--muted); padding: 28px 10px; }
.skeleton { color: var(--muted); padding: 30px; text-align: center; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12.5px; padding: 6px 8px; border-bottom: 1px solid var(--border); }
table.t td { padding: 9px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.scroll-x { overflow-x: auto; }
.login { max-width: 380px; margin: 14vh auto 0; text-align: center; }
.login img { width: 240px; margin: 4px auto 14px; display: block; }
.login form { text-align: left; }
.nav .who { display: none; }
@media (min-width: 900px) { .nav .who { display: block; } }
.kpi .v { color: var(--brand); }
@media (prefers-color-scheme: dark) { .kpi .v { color: var(--text); } }
.nav:empty { display: none; }
