/* Boxnel Express — tableau de bord. Mêmes couleurs, rayons et police que l'application (lib/core/theme.dart). */
:root {
  --primary: #FF6A00;
  --primary-dark: #E25C00;
  --primary-soft: #FFF1E6;
  --ink: #0E1A2B;
  --ink-soft: #475569;
  --muted: #94A3B8;
  --line: #E6E8EC;
  --background: #F5F6F8;
  --surface: #FFFFFF;
  --success: #16A34A;
  --success-soft: #E8F7EE;
  --warning: #F59E0B;
  --warning-soft: #FEF5E4;
  --danger: #DC2626;
  --danger-soft: #FDECEC;
  --info: #2563EB;
  --info-soft: #EAF1FE;
  --wave: #1DC4FF;
  --orange-money: #FF7900;
  --radius: 16px;
  --radius-lg: 22px;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }
body {
  background: var(--surface);
  color: var(--ink);
  font: 500 15px/1.45 "Plus Jakarta Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; letter-spacing: -0.3px; }
h1 { font-size: 26px; font-weight: 800; }
h2 { font-size: 18px; font-weight: 800; }
h3 { font-size: 15px; font-weight: 700; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
.muted { color: var(--ink-soft); }
small, .small { font-size: 13px; color: var(--muted); }

.ms {
  font-family: "Material Symbols Rounded";
  font-style: normal;
  font-weight: normal;
  font-size: 22px;
  line-height: 1;
  display: inline-block;
  -webkit-font-feature-settings: "liga";
  font-feature-settings: "liga";
  user-select: none;
}

/* ── Logo (BxLogo) ─────────────────────────────────────────────── */
.logo { display: flex; align-items: center; gap: 12px; }
.logo img { width: 44px; height: 44px; border-radius: 12px; }
.logo div { display: flex; flex-direction: column; }
.logo strong { font-size: 20px; font-weight: 800; letter-spacing: -0.5px; line-height: 1; }
.logo span { font-size: 10.5px; font-weight: 800; color: var(--primary); letter-spacing: 3px; line-height: 1.4; }
.logo-lg img { width: 56px; height: 56px; border-radius: 16px; }
.logo-lg strong { font-size: 26px; }
.logo-lg span { font-size: 13px; }

/* ── Boutons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px;
  border: 1.5px solid transparent; border-radius: var(--radius);
  font: 700 15px "Plus Jakarta Sans", sans-serif;
  cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn .ms { font-size: 20px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-outline:hover { border-color: var(--muted); }
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--background); color: var(--ink); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(.95); }
.btn-danger-soft { background: var(--danger-soft); color: var(--danger); }
.btn-danger-soft:hover { border-color: var(--danger); }
.btn-sm { height: 36px; padding: 0 12px; font-size: 13.5px; border-radius: 12px; }
.btn-block { width: 100%; height: 56px; }
.btn:disabled { background: var(--line); color: var(--muted); border-color: var(--line); cursor: default; }
.btn:focus-visible, .icon-btn:focus-visible, input:focus-visible, select:focus-visible, nav a:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px;
}
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  border: 0; border-radius: 12px; background: var(--background); color: var(--ink); cursor: pointer;
}

/* ── Champs (InputDecorationTheme) ─────────────────────────────── */
.field { display: grid; gap: 6px; font-size: 13.5px; font-weight: 600; color: var(--ink-soft); }
.input {
  display: flex; align-items: center; gap: 10px;
  height: 56px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  color: var(--ink-soft);
}
.input:focus-within { border: 1.6px solid var(--primary); }
.input input, .input select {
  flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent;
  font: 600 16px "Plus Jakarta Sans", sans-serif; color: var(--ink);
}
.input input::placeholder { color: var(--muted); font-weight: 500; }
.input-sm { height: 44px; }
.input-sm input { font-size: 14.5px; }
.form-error { color: var(--danger); background: var(--danger-soft); padding: 10px 14px; border-radius: 12px; font-size: 14px; }

/* ── Connexion ─────────────────────────────────────────────────── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 400px; display: grid; gap: 18px; }
.login-card .logo { margin-bottom: 16px; }
.login-card h1 { margin-top: 8px; }

/* ── Mise en page ──────────────────────────────────────────────── */
.layout { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 28px;
  padding: 24px 16px; border-right: 1px solid var(--line); background: var(--surface);
}
.sidebar .logo { padding: 0 8px; }
nav { display: grid; gap: 4px; }
nav a {
  display: flex; align-items: center; gap: 12px;
  height: 48px; padding: 0 14px; border-radius: 14px;
  color: var(--ink-soft); font-weight: 600;
}
nav a .ms { color: var(--muted); }
nav a:hover { background: var(--background); color: var(--ink); }
nav a.active { background: var(--primary-soft); color: var(--ink); font-weight: 700; }
nav a.active .ms { color: var(--primary); }
nav a span { flex: 1; }
.badge {
  min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px;
  background: var(--primary); color: #fff; font-size: 12px; font-weight: 800;
  display: inline-grid; place-items: center;
}
.sidebar-foot { margin-top: auto; display: grid; gap: 10px; }
.me { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.me strong { display: block; font-size: 14px; }

.content { min-width: 0; padding: 28px 32px 48px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.topbar p { margin-top: 4px; }

/* ── Cartes, chiffres clés ─────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 16px; }
.kpi { display: grid; gap: 10px; }
.kpi-icon { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; }
.kpi-value { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-label { color: var(--ink-soft); font-size: 14px; font-weight: 600; }
.kpi-hint { font-size: 13px; color: var(--muted); }
.kpi.highlight { background: var(--primary); border-color: var(--primary); color: #fff; }
.kpi.highlight .kpi-label, .kpi.highlight .kpi-hint { color: rgba(255,255,255,.85); }
.kpi.highlight .kpi-icon { background: rgba(255,255,255,.2); color: #fff; }
a.kpi:hover { border-color: var(--muted); }
.two-cols { grid-template-columns: 1.6fr 1fr; align-items: start; }

.tone-primary { background: var(--primary-soft); color: var(--primary); }
.tone-success { background: var(--success-soft); color: var(--success); }
.tone-warning { background: var(--warning-soft); color: var(--warning); }
.tone-danger { background: var(--danger-soft); color: var(--danger); }
.tone-info { background: var(--info-soft); color: var(--info); }
.tone-muted { background: var(--background); color: var(--ink-soft); }

/* ── Graphique ─────────────────────────────────────────────────── */
.chart { width: 100%; height: 220px; display: block; overflow: visible; }
.chart text { font: 600 11px "Plus Jakarta Sans", sans-serif; fill: var(--muted); }
.chart .bar-all { fill: var(--primary-soft); }
.chart .bar-done { fill: var(--primary); }
.chart .grid-line { stroke: var(--line); }
.chart g:hover .bar-all { fill: #FFE0C7; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ── Barre d'outils, onglets ───────────────────────────────────── */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; }
.toolbar .input { flex: 1 1 260px; max-width: 420px; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab {
  height: 38px; padding: 0 14px; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--surface); color: var(--ink-soft);
  font: 700 13.5px "Plus Jakarta Sans", sans-serif; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.tab:hover { border-color: var(--muted); }
.tab.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-dark); }
.tab b { font-weight: 800; }

/* ── Tableaux ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-lg); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; padding: 12px 16px; white-space: nowrap;
  font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px;
  border-bottom: 1px solid var(--line); background: var(--surface);
}
td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover td { background: #FAFBFC; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.actions { display: flex; gap: 8px; justify-content: flex-end; white-space: nowrap; }
.person { display: flex; align-items: center; gap: 12px; min-width: 180px; }
.person strong { display: block; font-weight: 700; }
.avatar {
  flex: none; width: 38px; height: 38px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary-dark);
  display: grid; place-items: center; font-weight: 800; font-size: 14px;
}
.route { display: grid; gap: 2px; max-width: 320px; }
.route span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.route span::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; vertical-align: 1px; }
.route span:first-child::before { background: var(--primary); }
.route span:last-child::before { background: var(--ink); }
.empty { padding: 48px 16px; text-align: center; color: var(--ink-soft); }
.empty .ms { font-size: 40px; color: var(--muted); display: block; margin: 0 auto 8px; }
.loading { padding: 48px; text-align: center; color: var(--muted); }

/* ── Pastilles de statut ───────────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px;
  border-radius: 999px; font-size: 12.5px; font-weight: 700; white-space: nowrap;
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.no-dot::before { display: none; }
.chip-wave { background: #E3F8FF; color: #0A8DBD; }
.chip-om { background: #FFF0E3; color: var(--orange-money); }
.stars { color: var(--warning); font-weight: 800; white-space: nowrap; }

/* ── Liste compacte (vue d'ensemble) ───────────────────────────── */
.list { display: grid; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; padding-bottom: 0; }
.list-row > div { flex: 1; min-width: 0; }
.list-row strong { display: block; }

/* ── Tiroir de détail ──────────────────────────────────────────── */
.drawer { position: fixed; inset: 0; z-index: 20; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(14, 26, 43, .35); }
.drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(520px, 100%);
  background: var(--surface); overflow-y: auto; padding: 28px 24px;
  border-radius: 28px 0 0 28px; box-shadow: -12px 0 40px rgba(14, 26, 43, .12);
}
.drawer-close { position: absolute; top: 20px; right: 20px; }
.detail { display: grid; gap: 20px; }
.detail dl { display: grid; grid-template-columns: 140px 1fr; gap: 10px 12px; margin: 0; font-size: 14px; }
.detail dt { color: var(--muted); font-weight: 600; }
.detail dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.timeline { display: grid; gap: 0; }
.timeline-item { display: grid; grid-template-columns: 20px 1fr; gap: 12px; position: relative; padding-bottom: 16px; }
.timeline-item::before { content: ""; position: absolute; left: 9px; top: 18px; bottom: 0; width: 2px; background: var(--line); }
.timeline-item:last-child::before { display: none; }
.timeline-dot { width: 20px; height: 20px; border-radius: 50%; border: 5px solid var(--primary-soft); background: var(--primary); }

/* ── Confirmation, toast ───────────────────────────────────────── */
.confirm { border: 0; border-radius: 28px; padding: 28px; width: min(420px, calc(100% - 32px)); color: var(--ink); }
.confirm::backdrop { background: rgba(14, 26, 43, .35); }
.confirm form { display: grid; gap: 10px; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30;
  background: var(--ink); color: #fff; padding: 14px 20px; border-radius: var(--radius);
  font-weight: 600; box-shadow: 0 10px 30px rgba(14, 26, 43, .2); max-width: calc(100% - 32px);
}
.toast.error { background: var(--danger); }

/* ── Petits écrans : la barre latérale devient une barre du haut ─ */
@media (max-width: 960px) {
  .two-cols { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky; top: 0; z-index: 10; height: auto; gap: 12px;
    padding: 12px 16px 0; border-right: 0; border-bottom: 1px solid var(--line);
  }
  .sidebar .logo img { width: 36px; height: 36px; }
  nav { display: flex; overflow-x: auto; gap: 4px; padding-bottom: 10px; scrollbar-width: none; }
  nav a { flex: none; height: 40px; padding: 0 12px; }
  .sidebar-foot { position: absolute; top: 12px; right: 16px; margin: 0; }
  .sidebar-foot .me { display: none; }
  .sidebar-foot .btn { width: auto; height: 36px; padding: 0 10px; }
  .content { padding: 20px 16px 40px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
  .kpi { padding: 16px; }
  .kpi-value { font-size: 20px; }
  h1 { font-size: 22px; }
  .topbar .btn span { display: none; }
  .topbar .btn { width: 44px; padding: 0; }
  .detail dl { grid-template-columns: 1fr; gap: 2px; }
  .detail dd { margin-bottom: 8px; }
}
@media (max-width: 520px) {
  .sidebar-foot .btn { font-size: 0; gap: 0; }
  .sidebar-foot .btn .ms { font-size: 20px; }
}
