/* NewTonne — design system (sobre, lisible, rapide). Aucune dépendance externe. */
:root {
  --blue-700: #1d4380;
  --blue-600: #234f96;
  --blue-500: #2e63b8;
  --blue-50: #eef3fb;
  --green-700: #2f6b31;
  --green-600: #3d7a3c;
  --green-50: #edf6ec;
  --ink: #1b2129;
  --ink-2: #3a434f;
  --muted: #687280;
  --line: #dde2e8;
  --line-2: #eef1f4;
  --bg: #f5f7f9;
  --surface: #ffffff;
  --danger: #b42318;
  --danger-50: #fdeceb;
  --warn: #9a5b00;
  --warn-50: #fff4e0;
  --ok: #2f6b31;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .05);
  --sidebar: 248px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--bg); }
a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; letter-spacing: -.01em; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
small, .muted { color: var(--muted); }
code, .mono { font-family: var(--mono); font-size: .92em; }
:focus-visible { outline: 3px solid #8fb2ea; outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }

/* ---------- coque applicative ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { background: #12233f; color: #c9d4e5; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px 12px; color: #fff; }
.brand img { width: 44px; height: 44px; object-fit: contain; background: #fff; border-radius: 10px; padding: 3px; }
.brand strong { display: block; font-size: 1.05rem; letter-spacing: .02em; }
.brand span { font-size: .78rem; color: #93a4bf; }
.nav { padding: 6px 10px 20px; }
.nav .section { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #7d90ad; margin: 16px 10px 6px; }
.nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: #d5deeb; padding: 8px 10px; border-radius: 8px; font-size: .93rem; }
.nav a:hover { background: #1c3258; text-decoration: none; }
.nav a.active { background: #2a4a7d; color: #fff; }
.nav .count { background: #e8a33a; color: #1b2129; font-size: .72rem; font-weight: 700; border-radius: 999px; padding: 1px 7px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar .left, .topbar .right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.menu-toggle { display: none; }
.content { padding: 22px 24px 48px; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head p { margin: 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- composants ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card > h2:first-child, .card > h3:first-child { margin-bottom: 12px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2 { padding: 16px 18px 0; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .label { font-size: .8rem; color: var(--muted); }
.kpi .value { font-size: 1.55rem; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.kpi .hint { font-size: .8rem; color: var(--muted); }
.kpi.warn { border-color: #f1c27a; background: var(--warn-50); }
.kpi.danger { border-color: #f2b8b5; background: var(--danger-50); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: var(--radius-sm); padding: 8px 14px; font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer; text-decoration: none; min-height: 38px; line-height: 1.2; }
.btn:hover { background: var(--line-2); text-decoration: none; }
.btn.primary { background: var(--blue-600); border-color: var(--blue-600); color: #fff; }
.btn.primary:hover { background: var(--blue-700); }
.btn.success { background: var(--green-600); border-color: var(--green-600); color: #fff; }
.btn.success:hover { background: var(--green-700); }
.btn.danger { background: var(--surface); border-color: #f0b4af; color: var(--danger); }
.btn.danger:hover { background: var(--danger-50); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { min-height: 30px; padding: 4px 10px; font-size: .85rem; }
.btn.lg { min-height: 52px; padding: 12px 22px; font-size: 1.05rem; }
.btn[disabled], .btn.is-loading { opacity: .6; pointer-events: none; }
.inline { display: inline; }

.badge { display: inline-block; font-size: .76rem; font-weight: 700; border-radius: 999px; padding: 2px 9px; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.badge.PENDING, .badge.warn, .badge.DRAFT, .badge.pending { background: var(--warn-50); color: var(--warn); }
.badge.VALIDATED, .badge.ok, .badge.ISSUED, .badge.printed, .badge.SENT, .badge.SIMULATED { background: var(--green-50); color: var(--green-700); }
.badge.REJECTED, .badge.CANCELLED, .badge.danger, .badge.error, .badge.ERROR, .badge.CREDITED { background: var(--danger-50); color: var(--danger); }
.badge.info, .badge.printing { background: var(--blue-50); color: var(--blue-700); }

.alert { border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 12px; border: 1px solid var(--line); background: var(--surface); }
.alert.success { border-color: #b9dcb6; background: var(--green-50); }
.alert.error { border-color: #f2b8b5; background: var(--danger-50); }
.alert.warning { border-color: #f1c27a; background: var(--warn-50); }
.alert.info { border-color: #c4d5f1; background: var(--blue-50); }

/* tableaux */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafbfc; white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:hover td { background: #fafcff; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .nowrap { white-space: nowrap; }
.table tfoot td { font-weight: 700; background: #fafbfc; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* formulaires */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-weight: 600; font-size: .88rem; }
.field .help { font-size: .8rem; color: var(--muted); }
.field .error, .errorlist { color: var(--danger); font-size: .85rem; margin: 0; padding: 0; list-style: none; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=month], input[type=search], input[type=tel], input[type=url], input[type=datetime-local], select, textarea {
  font: inherit; color: var(--ink); background: #fff; border: 1px solid #c9d0d9; border-radius: var(--radius-sm); padding: 8px 10px; min-height: 40px; width: 100%;
}
textarea { min-height: 84px; }
input:focus, select:focus, textarea:focus { border-color: var(--blue-500); outline: 3px solid #d6e3f8; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: 18px; height: 18px; }
/* Liste de cases à cocher (sites d'un code, d'un bulliste…) : le titre au-dessus, une case par ligne */
.field .label { display: block; font-weight: 600; margin-bottom: 6px; }
.check-list label { display: flex; align-items: center; gap: 8px; font-weight: 500; padding: 3px 0; }
.check-list input { width: 18px; height: 18px; flex: none; }
select[multiple] { min-height: 110px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.filters .field { min-width: 150px; }
.filters .field.grow { flex: 1; min-width: 220px; }

/* détails */
dl.kv { display: grid; grid-template-columns: minmax(140px, 220px) 1fr; gap: 6px 14px; margin: 0; }
dl.kv dt { color: var(--muted); font-size: .88rem; }
dl.kv dd { margin: 0; font-weight: 600; }
.weights { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.weights div { background: var(--blue-50); border-radius: var(--radius-sm); padding: 10px 12px; text-align: center; }
.weights b { display: block; font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.weights .net { background: var(--blue-600); color: #fff; }
.secret { font-family: var(--mono); font-size: 1.3rem; letter-spacing: .06em; background: var(--warn-50); border: 1px dashed #e5ad55; border-radius: 8px; padding: 10px 14px; display: inline-block; user-select: all; }
.pagination { display: flex; gap: 6px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.bar { height: 8px; background: var(--line-2); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--green-600); }
.bar.warn > span { background: #e0982e; }
.bar.danger > span { background: var(--danger); }
.hbar { display: grid; grid-template-columns: minmax(120px, 220px) 1fr 110px; gap: 10px; align-items: center; margin: 6px 0; font-size: .9rem; }
.hbar .track { height: 12px; background: var(--line-2); border-radius: 99px; overflow: hidden; }
.hbar .track span { display: block; height: 100%; background: var(--blue-500); border-radius: 99px; }
.hbar .num { text-align: right; font-variant-numeric: tabular-nums; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0; border-bottom: 1px solid var(--line-2); font-size: .9rem; }

/* ---------- authentification ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: linear-gradient(160deg, #eef3fb 0%, #f5f7f9 55%, #edf6ec 100%); }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 10px 30px rgba(18, 35, 63, .08); padding: 28px; }
.auth-card .logo { display: block; width: 150px; margin: 0 auto 8px; }
.auth-card h1 { text-align: center; font-size: 1.25rem; }
.auth-card .sub { text-align: center; color: var(--muted); margin-bottom: 18px; }
.auth-links { display: flex; justify-content: space-between; margin-top: 14px; font-size: .9rem; }

/* ---------- borne chauffeur (tablette) ---------- */
.kiosk { background: #f2f5f8; min-height: 100vh; font-size: 17px; }
.kiosk-top { display: flex; align-items: center; justify-content: space-between; padding: 10px 18px; background: #fff; border-bottom: 1px solid var(--line); }
.kiosk-top img { height: 46px; }
.kiosk-main { max-width: 860px; margin: 0 auto; padding: 18px 16px 60px; }
.kiosk input, .kiosk select { min-height: 52px; font-size: 1.1rem; }
.kiosk .btn { min-height: 52px; font-size: 1.05rem; }
.kiosk .code-input { font-size: 1.8rem; text-align: center; letter-spacing: .12em; text-transform: uppercase; font-family: var(--mono); }
.steps { display: flex; gap: 6px; margin: 4px 0 16px; }
.steps span { flex: 1; height: 6px; border-radius: 99px; background: var(--line); }
.steps span.on { background: var(--blue-500); }
.funnel-question { font-size: 1.25rem; margin: 4px 0 12px; }
.funnel-trail { color: var(--muted, #667); font-size: .95rem; margin-bottom: 6px; }
.funnel-answers { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin-bottom: 10px; }
.kiosk .funnel-answer { min-height: 76px; flex-direction: column; align-items: flex-start; justify-content: center; text-align: left; white-space: normal; font-size: 1.1rem; }
.funnel-answer small { font-weight: 400; color: var(--muted, #667); font-size: .88rem; }
.funnel-result { border: 2px solid var(--green-600); border-radius: var(--radius-sm); padding: 16px; background: #fff; display: grid; gap: 6px; justify-items: start; }
.funnel-code { font-family: var(--mono); font-size: 2.2rem; font-weight: 700; line-height: 1; }
.funnel-name { font-size: 1.15rem; }
.op-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.op-choice button { min-height: 120px; font-size: 1.3rem; }
.weight-live { font-size: 3rem; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; color: var(--blue-700); }
.weight-state { text-align: center; color: var(--muted); }
canvas.signature { width: 100%; height: 200px; border: 2px dashed #b7c2cf; border-radius: 10px; background: #fff; touch-action: none; }
.big-ok { text-align: center; padding: 40px 10px; }
.big-ok .tick { width: 84px; height: 84px; border-radius: 50%; background: var(--green-600); color: #fff; font-size: 48px; line-height: 84px; margin: 0 auto 14px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 40; transform: translateX(-100%); transition: transform .2s ease; }
  .shell.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); }
  .menu-toggle { display: inline-flex; }
  .content { padding: 16px 16px 40px; }
  .topbar { padding: 8px 16px; }
  .grid.cols-2, .grid.cols-3, .form-grid { grid-template-columns: 1fr; }
  dl.kv { grid-template-columns: 1fr; }
  .hbar { grid-template-columns: 1fr 90px; }
  .hbar .track { grid-column: 1 / -1; order: 3; }
  .op-choice { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .grid.cols-4 { grid-template-columns: 1fr 1fr; }
  .weights { grid-template-columns: 1fr; }
  .table th, .table td { padding: 8px; }
}
@media print {
  .sidebar, .topbar, .actions, .filters { display: none !important; }
  .shell { display: block; }
}
.quotes-inbox tr.unread td { font-weight: 700; }
.quotes-inbox tr.unread td small { font-weight: 400; }
.quotes-inbox .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--blue-600); }
.quotes-inbox .muted-link { color: var(--ink-2); font-weight: inherit; }
.chat { display: grid; gap: 8px; }
.chat .msg { max-width: 80%; padding: 8px 12px; border-radius: 12px; background: var(--line-2); white-space: pre-wrap; }
.chat .msg.client { justify-self: start; }
.chat .msg.ia, .chat .msg.humain { justify-self: end; background: #e7f0fb; }
.chat .msg small { display: block; color: var(--muted); font-size: .75rem; margin-bottom: 2px; }
.quote-summary { white-space: pre-wrap; font-size: 1.02rem; }
.vehicle-card { margin-top: 14px; padding: 14px 16px; border: 2px solid var(--blue-600); border-radius: var(--radius-sm); background: #f5f8fd; }
.vehicle-card h3 { margin: 0 0 8px; }
.vehicle-card p { margin: 10px 0 8px; }
.site-modes-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; }
.site-modes-head h3 { margin: 0; }
.site-modes fieldset.modes { border: 0; padding: 0; margin: 14px 0 6px; }
.site-modes legend { font-weight: 700; margin-bottom: 6px; }
.site-modes label.mode { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 6px; cursor: pointer; }
.site-modes label.mode:has(input:checked) { border-color: var(--blue-600); background: #f5f8fd; }
.site-modes label.mode input { margin-top: 3px; }
.site-modes label.mode small { display: block; color: var(--muted); font-weight: 400; }
.table .neg, .kpi .neg { color: var(--danger); }

/* ------------------------------------------------------------------ Espace du personnel : couleurs du logo NewTonne
   Bleu nuit #0E2A52, bleu canard #0780A4, cyan #35D0EE. Le fond de travail reste clair.
   La borne, l'espace bulliste, le portail client et la page de connexion ne portent pas cette classe. */
body.nt-staff {
  --blue-700: #0e2a52;
  --blue-600: #06769a;
  --blue-500: #0780a4;
  --blue-50: #e6f6fb;
  --ink: #13233d;
  --ink-2: #33435c;
  --muted: #5a6a82;
  --line: #dbe2ec;
  --line-2: #edf1f6;
  --bg: #f3f6fa;
}
body.nt-staff .btn.primary:hover { background: #055f7c; border-color: #055f7c; }
body.nt-staff :focus-visible { outline-color: #35d0ee; }
body.nt-staff input:focus, body.nt-staff select:focus, body.nt-staff textarea:focus { outline-color: #c5eef8; }
body.nt-staff .sidebar { background: #0e2a52; color: #c6d3e6; }
body.nt-staff .brand img { background: none; padding: 0; border-radius: 0; }
body.nt-staff .brand span { color: #9fb3d1; }
body.nt-staff .brand strong { font-size: 1.2rem; font-weight: 800; letter-spacing: 0; }
body.nt-staff .brand strong b { color: #35d0ee; font-weight: inherit; }
body.nt-staff .nav .section { color: #86a0c4; }
body.nt-staff .nav a { color: #dbe5f3; border-left: 3px solid transparent; }
body.nt-staff .nav a:hover { background: #16386a; }
body.nt-staff .nav a.active { background: #1b3d6e; color: #fff; border-left-color: #35d0ee; }
body.nt-staff .nav .count { background: #35d0ee; color: #0e2a52; }
body.nt-staff .topbar { border-bottom-color: var(--line); }
body.nt-staff .weights .net { background: #0e2a52; }
body.nt-staff .alert.info { border-color: #a9dff0; }
body.nt-staff .table tr:hover td { background: #f6fbfd; }
body.nt-staff .vehicle-card, body.nt-staff .site-modes label.mode:has(input:checked) { background: #f1fafd; }
body.nt-staff .chat .msg.ia, body.nt-staff .chat .msg.humain { background: #e0f4fa; }

