/* Vigie · back office — charte VIGIE 360, identique à l'appli (vert #08765F, marine #19354B). */
:root {
  color-scheme: light dark;
  --green: #08765F; --green-ink: #065C4A; --green-soft: #E5F3ED;
  --navy: #19354B; --muted: #526A7D; --line: #DFE7ED; --shell: #F7F9FB; --card: #FFFFFF;
  --danger: #B42318; --danger-soft: #FDECEA; --warn: #805417; --warn-soft: #FFF3DF;
  --radius: 16px; --shadow: 0 1px 2px rgba(25, 53, 75, .06), 0 4px 16px rgba(25, 53, 75, .05);
  --side: 264px; --on-green: #FFFFFF;
}
@media (prefers-color-scheme: dark) {
  :root {
    --green: #4FC3A1; --green-ink: #8FE0C6; --green-soft: #12352D;
    --navy: #E6EEF4; --muted: #9DB1C1; --line: #24384A; --shell: #0E1A23; --card: #142431;
    --danger: #FF8A80; --danger-soft: #3A1A18; --warn: #F5C77E; --warn-soft: #3A2E16;
    --shadow: none; --on-green: #06261E;
  }
}
* { box-sizing: border-box }
html { -webkit-text-size-adjust: 100% }
body { margin: 0; background: var(--shell); color: var(--navy); font: 15px/1.55 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif }
a { color: var(--green); text-underline-offset: 3px }
a:hover { color: var(--green-ink) }
.ico { flex: none; vertical-align: middle }

/* ---------- Structure : menu latéral + contenu ---------- */
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--card); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column }
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 0 6px 18px }
.brand { display: flex; align-items: center; gap: 10px; color: var(--navy); text-decoration: none }
.brand b { display: block; font-size: 17px; letter-spacing: .28em; line-height: 1.1 }
.brand small { display: block; color: var(--muted); font-size: 12px; letter-spacing: .02em }
.brand-mark { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--green-soft); color: var(--green) }
.menu-btn, .menu-toggle { display: none }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1 }
.nav-group { margin-bottom: 10px }
.nav-group p { margin: 10px 10px 6px; font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted) }
.nav a { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 12px; color: var(--navy); text-decoration: none; font-weight: 500 }
.nav a .ico { color: var(--muted) }
.nav a:hover { background: var(--shell) }
.nav a.active { background: var(--green-soft); color: var(--green-ink); font-weight: 650 }
.nav a.active .ico { color: var(--green) }
.me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid var(--line) }
.me form { margin: 0 0 0 auto }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--navy); color: var(--card); font-weight: 700; font-size: 13px }
.me-text { display: flex; flex-direction: column; min-width: 0 }
.me-text b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.me-text small { color: var(--muted); font-size: 12px }
.main { padding: 32px clamp(16px, 4vw, 48px) 72px; max-width: 1280px; width: 100%; min-width: 0 }
.page-head { margin-bottom: 20px }
h1 { font-size: 28px; line-height: 1.2; letter-spacing: -.01em; margin: 0 }
.lead { color: var(--muted); margin: 6px 0 0; max-width: 72ch }
h2 { font-size: 18px; margin: 32px 0 12px; letter-spacing: -.005em }
h3 { font-size: 16px; margin: 0 0 8px }
main > p, .card > p { max-width: 80ch }

/* ---------- Cartes et indicateurs ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 14px 0; box-shadow: var(--shadow) }
.card > h2:first-child { margin-top: 0 }
.narrow { max-width: 440px }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px }
.stat { position: relative; display: flex; flex-direction: column; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 18px 16px; color: var(--navy); text-decoration: none; box-shadow: var(--shadow); transition: border-color .15s, transform .15s }
a.stat:hover { border-color: var(--green); transform: translateY(-1px); color: var(--navy) }
.stat .ico { width: 40px; height: 40px; padding: 9px; border-radius: 12px; background: var(--green-soft); color: var(--green); margin-bottom: 6px }
.stat.alert .ico { background: var(--warn-soft); color: var(--warn) }
.stat span:last-child { color: var(--muted); font-size: 14px }
.big { font-size: 32px; font-weight: 750; line-height: 1; letter-spacing: -.02em }

/* ---------- Tableaux ---------- */
table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; font-size: 14px; box-shadow: var(--shadow) }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle }
tbody tr:last-child td { border-bottom: 0 }
th { background: var(--shell); color: var(--muted); font-weight: 650; font-size: 12px; letter-spacing: .04em; text-transform: uppercase }
tbody tr:hover td { background: color-mix(in srgb, var(--green-soft) 35%, transparent) }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums } .nowrap { white-space: nowrap }
tr.off td { color: var(--muted); opacity: .7 }
td form { margin: 0 }

/* ---------- Formulaires et boutons ---------- */
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; color: var(--navy) }
.row-form > label { flex: 1 1 200px }
label.check { flex-direction: row; align-items: center; gap: 8px; flex: 0 0 auto }
input, select, textarea { font: inherit; font-weight: 400; color: var(--navy); padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); min-height: 44px; width: 100% }
input[type=checkbox] { width: 18px; height: 18px; min-height: 0; accent-color: var(--green) }
input:focus, select:focus, textarea:focus { border-color: var(--green); outline: 3px solid color-mix(in srgb, var(--green) 22%, transparent); outline-offset: 0 }
button { font: inherit; font-weight: 600; font-size: 14px; padding: 9px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--navy); cursor: pointer; min-height: 42px; transition: background .15s, border-color .15s }
button:hover { border-color: var(--green); color: var(--green-ink) }
button.primary { background: var(--green); border-color: var(--green); color: var(--on-green) }
button.primary:hover { background: var(--green-ink); border-color: var(--green-ink); color: var(--on-green) }
button.ghost, button.link { border: 0; background: none; color: var(--muted); padding: 6px 8px; min-height: 0 }
button.ghost:hover, button.link:hover { color: var(--danger) }
button:focus-visible, a:focus-visible { outline: 3px solid color-mix(in srgb, var(--green) 45%, transparent); outline-offset: 2px }
.row-form { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end }
.row-form > button { flex: 0 0 auto }
.stacked { display: flex; flex-direction: column; gap: 14px; margin-top: 8px }
.stacked > button { align-self: flex-start }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center }
.actions form { margin: 0 } .inline { display: inline }
details { margin-top: 6px }
details summary { cursor: pointer; color: var(--green); font-weight: 600; padding: 6px 0 }

/* ---------- Messages et pastilles ---------- */
.pill { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--shell); color: var(--muted); border: 1px solid var(--line) }
.pill.ok { background: var(--green-soft); color: var(--green-ink); border-color: transparent }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent }
.pill.mid { background: var(--danger-soft); color: var(--danger); border-color: transparent }
.flash { display: flex; align-items: center; gap: 10px; background: var(--green-soft); color: var(--green-ink); padding: 12px 16px; border-radius: 14px; font-weight: 600; margin: 0 0 18px; overflow-wrap: anywhere }
.error { background: var(--danger-soft); color: var(--danger); padding: 12px 16px; border-radius: 14px; font-weight: 600 }
.hint { color: var(--muted); font-size: 13px; font-weight: 400 }
code { font: 12px/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace; background: var(--shell); padding: 2px 6px; border-radius: 6px; overflow-wrap: anywhere }
.qr { display: flex; justify-content: center; margin: 16px 0; padding: 16px; background: #fff; border-radius: var(--radius) } .qr svg { max-width: 100%; height: auto }
.codes { columns: 2; font: 16px/1.6 ui-monospace, Menlo, Consolas, monospace; padding-left: 20px } .codes li { margin: 4px 0 }
.bar { display: inline-block; height: 10px; border-radius: 5px; background: var(--green); margin-right: 8px; vertical-align: middle }

/* ---------- Connexion ---------- */
body.auth { min-height: 100vh; background: radial-gradient(1200px 600px at 50% -10%, var(--green-soft), var(--shell) 70%) }
.auth-main { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px }
.auth-card { width: 100%; max-width: 440px; background: var(--card); border: 1px solid var(--line); border-radius: 24px; padding: 32px 28px; box-shadow: 0 12px 40px rgba(25, 53, 75, .10) }
.auth-card .brand { margin-bottom: 26px }
.auth-card h1 { font-size: 22px; margin-bottom: 4px }
.auth-card .card { border: 0; box-shadow: none; padding: 0; margin: 18px 0 0; max-width: none; background: none }
.auth-card form { display: flex; flex-direction: column; gap: 14px }
.auth-card form button.primary { min-height: 48px; margin-top: 4px }
.auth-foot { color: var(--muted); font-size: 13px; margin-top: 18px }

/* ---------- Petits écrans : menu repliable sans script ---------- */
@media (max-width: 920px) {
  .shell { grid-template-columns: 1fr }
  .side { position: sticky; z-index: 10; height: auto; padding: 12px 14px; border-right: 0; border-bottom: 1px solid var(--line) }
  .side-top { padding: 0 }
  .menu-btn { display: inline-flex; flex-direction: column; gap: 4px; padding: 10px; cursor: pointer; border-radius: 10px }
  .menu-btn span { width: 20px; height: 2px; background: var(--navy); border-radius: 2px }
  .nav { display: none; padding-top: 12px }
  .menu-toggle:checked + .nav { display: flex }
  .main { padding-top: 20px }
  table { display: block; overflow-x: auto }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important } }
