/* =====================================================================
   DZ EXPRESS — feuille de style unique.
   Systeme « modernist » : grille visible, filets 2 px, aucun arrondi,
   libelles fer a gauche, accent utilise avec parcimonie.
   Bidirectionnel : les proprietes logiques (inline-start/end) portent
   le passage LTR <-> RTL sans feuille separee.
   ===================================================================== */

:root {
  --ink:        #201e1d;
  --bg:         #f3f2f2;
  --surface:    #eae9e9;
  --accent:     #ec3013;
  --accent-600: #dd2b0f;
  --accent-700: #ae1800;
  --accent-200: #ffe0d9;
  --accent-100: #fff2ef;
  --divider:    rgba(32, 30, 29, .4);
  --hairline:   rgba(32, 30, 29, .16);
  --muted:      rgba(32, 30, 29, .55);
  --muted-2:    rgba(32, 30, 29, .7);
  --n-200:      #eae7e7;
  --n-300:      #d7d3d3;
  --n-400:      #bab6b6;
  --ok:         #0f766e;

  --font:    "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-ar: "Noto Kufi Arabic", "Archivo", system-ui, sans-serif;
  --mono:    ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s6: 24px; --s8: 32px; --s12: 48px;

  --rule: 2px solid var(--divider);
  --thin: 1px solid var(--hairline);
  --sidebar-w: 252px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  font-weight: 400;
}

body[dir="rtl"] { font-family: var(--font-ar); }

h1, h2, h3, h4, h5 {
  font-family: inherit;
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -.025em;
  margin: 0 0 var(--s2);
}
h1 { font-size: 30px; }
h2 { font-size: 24px; }
h3 { font-size: 19px; }
h4 { font-size: 16px; }

a { color: var(--accent-700); text-underline-offset: 3px; }
a:hover { color: var(--accent); }

::selection { background: rgba(236, 48, 19, .28); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--n-300); }

/* ---------------------------------------------------------------- */
/* Utilitaires                                                       */
.kicker {
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); margin-bottom: var(--s1);
}
.mono { font-family: var(--mono); letter-spacing: .02em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny  { font-size: 11px; }
.strong { font-weight: 600; }
.num { font-variant-numeric: tabular-nums; }
.hr { border: 0; border-top: var(--rule); margin: var(--s6) 0; }
.grayscale { filter: grayscale(1) contrast(1.08); }
.nowrap { white-space: nowrap; }
.right { text-align: end; }
.center { text-align: center; }
.flex { display: flex; align-items: center; gap: var(--s3); }
.flex-1 { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }
.stack > * + * { margin-top: var(--s3); }
.hide { display: none !important; }
.ar-sub {
  display: block; font-family: var(--font-ar); font-size: 11px;
  opacity: .55; direction: rtl; margin-top: 2px;
}

/* ---------------------------------------------------------------- */
/* Grille de l'application                                           */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  border-inline-end: var(--rule);
  display: flex; flex-direction: column; background: var(--bg);
  position: sticky; top: 0; height: 100vh;
}
.sidebar-head { padding: 24px 20px 20px; border-bottom: var(--rule); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand-mark { width: 22px; height: 22px; background: var(--accent); flex: 0 0 22px; }
.brand-name { font-weight: 800; font-size: 19px; letter-spacing: -.02em; line-height: 1; }
.brand-sub {
  margin-top: var(--s2); font-size: 11px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
}

.nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.nav-group {
  padding: 14px 18px 6px; font-size: 10px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted);
}
.nav-item {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: start;
  border: 0; border-inline-start: 3px solid transparent; background: none;
  color: var(--ink); cursor: pointer; font: inherit; text-decoration: none;
  padding: 10px 18px 10px 15px;
}
body[dir="rtl"] .nav-item { padding: 10px 15px 10px 18px; }
.nav-item:hover { background: var(--surface); color: var(--ink); }
.nav-item.is-active {
  border-inline-start-color: var(--accent);
  background: var(--accent-100); font-weight: 600;
}
.nav-label { display: block; font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
.nav-count { font-size: 11px; font-weight: 600; opacity: .6; font-variant-numeric: tabular-nums; }

.sidebar-foot {
  border-top: var(--rule); padding: 14px 18px;
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 32px; height: 32px; background: var(--ink); color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; flex: 0 0 32px;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  border-bottom: var(--rule); padding: 18px 28px;
  display: flex; align-items: flex-end; gap: 24px; flex: 0 0 auto;
  background: var(--bg);
}
.topbar h1 { margin: 0; }
.content { padding: 24px 28px 64px; }

/* ---------------------------------------------------------------- */
/* Boutons — libelle fer a gauche, jamais centre                     */
.btn {
  display: inline-flex; align-items: center; gap: var(--s2);
  padding: 10px 16px; border: 2px solid var(--ink); background: none;
  color: var(--ink); font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; text-decoration: none; text-align: start;
  border-radius: 0; transition: background .12s, color .12s;
}
.btn:hover { background: var(--ink); color: var(--bg); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-disabled { opacity: .45; pointer-events: none; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-600); border-color: var(--accent-600); color: #fff; }

.btn-ghost { border-color: var(--divider); }
.btn-ghost:hover { background: var(--surface); color: var(--ink); }

.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-block { width: 100%; justify-content: flex-start; }
.btn-icon { padding: 8px; }

.btn-row { display: flex; gap: var(--s2); flex-wrap: wrap; }

/* ---------------------------------------------------------------- */
/* Etiquettes de statut                                              */
.tag {
  display: inline-block; padding: 3px 9px; font-size: 11px; font-weight: 600;
  letter-spacing: .01em; border: 1px solid transparent; white-space: nowrap;
}
.tag-solid   { background: var(--accent); color: #fff; }
.tag-soft    { background: var(--accent-200); color: var(--accent-700); }
.tag-neutral { background: #e0dcdc; color: var(--ink); }
.tag-outline { background: none; color: var(--muted-2); border-color: var(--divider); }
.tag-ok      { background: var(--ok); color: #fff; }

/* ---------------------------------------------------------------- */
/* Cartes et indicateurs                                             */
.grid { display: grid; gap: var(--s4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.panel { border: var(--rule); background: var(--bg); }
.panel-head {
  padding: 14px 18px; border-bottom: var(--rule);
  display: flex; align-items: center; gap: var(--s3);
}
.panel-head h3 { margin: 0; font-size: 15px; }
.panel-body { padding: 18px; }

.kpi { border: var(--rule); padding: 18px; }
.kpi-label {
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); margin-bottom: var(--s2);
}
.kpi-value {
  font-size: 34px; font-weight: 800; letter-spacing: -.03em; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.kpi-delta { margin-top: var(--s2); font-size: 12px; color: var(--muted-2); }
.kpi-delta.is-alert { color: var(--accent); font-weight: 600; }

/* ---------------------------------------------------------------- */
/* Tableaux                                                          */
.table-wrap { border: var(--rule); overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table thead th {
  text-align: start; font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; padding: 11px 14px;
  border-bottom: var(--rule); white-space: nowrap; background: var(--bg);
}
.table tbody td { padding: 12px 14px; border-bottom: var(--thin); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface); }
.table .num { text-align: end; font-variant-numeric: tabular-nums; }
.table a { color: inherit; font-weight: 600; text-decoration: none; }
.table a:hover { color: var(--accent); text-decoration: underline; }

.empty { padding: 48px 18px; text-align: center; color: var(--muted); }

/* ---------------------------------------------------------------- */
/* Formulaires                                                       */
.field { margin-bottom: var(--s4); }
.field > label {
  display: block; font-size: 12px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted-2); margin-bottom: 6px;
}
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field.is-error .input, .field.is-error select, .field.is-error textarea { border-color: var(--accent); }
.field .error { font-size: 12px; color: var(--accent-700); margin-top: 4px; font-weight: 600; }

.input, select, textarea {
  width: 100%; padding: 10px 12px; border: 2px solid var(--divider);
  background: #fff; color: var(--ink); font: inherit; font-size: 15px;
  border-radius: 0; appearance: none;
}
.input:focus, select:focus, textarea:focus { border-color: var(--ink); }
textarea { min-height: 96px; resize: vertical; }
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%),
                    linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
  padding-inline-end: 34px;
}
body[dir="rtl"] select {
  background-position: 13px 50%, 18px 50%;
  background-image: linear-gradient(135deg, transparent 50%, var(--ink) 50%),
                    linear-gradient(45deg, var(--ink) 50%, transparent 50%);
}

.check { display: flex; align-items: flex-start; gap: var(--s2); font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin-top: 2px; }

.seg { display: inline-flex; border: 2px solid var(--divider); }
.seg-opt {
  padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
  border-inline-end: 2px solid var(--divider); background: none; color: var(--muted-2);
}
.seg-opt:last-child { border-inline-end: 0; }
.seg-opt.is-on { background: var(--ink); color: var(--bg); }

.filters {
  display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center;
  padding-bottom: var(--s4); margin-bottom: var(--s4); border-bottom: var(--rule);
}
.chip {
  padding: 6px 12px; font-size: 13px; font-weight: 600; text-decoration: none;
  border: 2px solid var(--divider); color: var(--muted-2);
}
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip.is-on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip .n { opacity: .6; margin-inline-start: 4px; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- */
/* Chronologie de suivi — element signature                          */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  display: grid; grid-template-columns: 62px 18px 1fr; gap: var(--s3);
  align-items: start; padding: 14px 0; border-bottom: var(--thin);
}
.timeline li:last-child { border-bottom: 0; }
.tl-time { font-family: var(--mono); font-size: 12px; color: var(--muted); padding-top: 2px; }
.tl-rail { position: relative; height: 100%; }
.tl-dot {
  width: 10px; height: 10px; background: var(--ink); margin-top: 5px;
  position: relative; z-index: 1;
}
.tl-dot.is-now { background: var(--accent); width: 14px; height: 14px; margin-top: 3px; }
.tl-dot.is-future { background: var(--n-400); }
.tl-rail::after {
  content: ""; position: absolute; inset-inline-start: 4px; top: 15px; bottom: -14px;
  width: 2px; background: var(--n-300);
}
.timeline li:last-child .tl-rail::after { display: none; }
.tl-title { font-weight: 600; font-size: 14px; }
.tl-place { font-size: 12px; color: var(--muted); }

/* ---------------------------------------------------------------- */
/* Barres (repartition par wilaya, volumes)                          */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 150px; }
.bar-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.bar { background: var(--n-300); width: 100%; }
.bar.is-now { background: var(--accent); }
.bar-label { font-size: 11px; color: var(--muted); margin-top: 6px; text-align: start; }

.rank { list-style: none; margin: 0; padding: 0; }
.rank li { padding: 10px 0; border-bottom: var(--thin); }
.rank li:last-child { border-bottom: 0; }
.rank-row { display: flex; align-items: baseline; gap: var(--s3); }
.rank-name { flex: 1; font-weight: 600; font-size: 14px; }
.rank-val { font-variant-numeric: tabular-nums; font-weight: 600; }
.rank-bar { height: 4px; background: var(--ink); margin-top: 6px; }

/* ---------------------------------------------------------------- */
/* Messages                                                          */
.flash { border: 2px solid var(--ink); padding: 12px 16px; margin-bottom: var(--s4); font-size: 14px; }
.flash-ok    { border-color: var(--ok); background: rgba(15, 118, 110, .08); }
.flash-error { border-color: var(--accent); background: var(--accent-100); color: var(--accent-700); }
.flash-info  { border-color: var(--divider); background: var(--surface); }

/* ---------------------------------------------------------------- */
/* Site public                                                       */
.pub-nav {
  display: flex; align-items: center; gap: var(--s6);
  padding: 18px 28px; border-bottom: var(--rule); background: var(--bg);
  position: sticky; top: 0; z-index: 20;
}
.pub-links { display: flex; gap: var(--s4); flex: 1; flex-wrap: wrap; }
.pub-links a {
  color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 600;
}
.pub-links a:hover { color: var(--accent); }

.hero { padding: 64px 28px; border-bottom: var(--rule); }
.hero-inner { max-width: 1180px; margin: 0 auto; }
.hero h1 {
  font-size: clamp(36px, 6vw, 68px); line-height: 1.02; letter-spacing: -.035em;
  max-width: 16ch; margin-bottom: var(--s4);
}
.hero p { font-size: 18px; color: var(--muted-2); max-width: 54ch; margin: 0 0 var(--s8); }

.track-box { border: var(--rule); background: var(--bg); max-width: 620px; }
.track-box .panel-body { display: flex; gap: 0; }
.track-box .input { border: 0; border-inline-end: var(--rule); }
.track-box .btn { border: 0; }

.section { padding: 56px 28px; border-bottom: var(--rule); }
.section-inner { max-width: 1180px; margin: 0 auto; }
.section h2 { font-size: clamp(26px, 3.6vw, 40px); letter-spacing: -.03em; margin-bottom: var(--s6); }

.cells { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.cell {
  padding: var(--s6); border-inline-end: var(--rule); border-bottom: var(--rule);
}
.cell:last-child { border-inline-end: 0; }
.cell h3 { font-size: 17px; margin-bottom: var(--s2); }
.cell p { font-size: 14px; color: var(--muted-2); margin: 0; }

.poster {
  background: var(--accent); color: #fff; padding: 72px 28px; border-bottom: var(--rule);
}
.poster h2 { font-size: clamp(30px, 5vw, 56px); letter-spacing: -.035em; max-width: 18ch; }
.poster p { font-size: 17px; opacity: .92; max-width: 52ch; }
.poster .btn { border-color: #fff; color: #fff; }
.poster .btn:hover { background: #fff; color: var(--accent); }

.footer { padding: 48px 28px; font-size: 14px; }
.footer-inner {
  max-width: 1180px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--s8);
}
.footer h4 { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.footer a { display: block; color: var(--ink); text-decoration: none; padding: 3px 0; }
.footer a:hover { color: var(--accent); }

/* Selecteur de langue */
.langs { display: flex; gap: 6px; }
.lang-pill {
  padding: 4px 10px; font-size: 12px; font-weight: 600; text-decoration: none;
  border: 1px solid var(--divider); color: var(--muted-2);
}
.lang-pill.is-on { background: var(--ink); border-color: var(--ink); color: var(--bg); }

/* ---------------------------------------------------------------- */
/* Etiquette colis (impression)                                      */
.label-sheet { width: 100mm; border: 2px solid #000; padding: 6mm; background: #fff; color: #000; }
.label-head { display: flex; justify-content: space-between; align-items: flex-start;
              border-bottom: 2px solid #000; padding-bottom: 4mm; margin-bottom: 4mm; }
.label-block { margin-bottom: 4mm; }
.label-block .k { font-size: 8pt; letter-spacing: .1em; text-transform: uppercase; color: #555; }
.label-block .v { font-size: 12pt; font-weight: 700; }
.label-cod { border: 2px solid #000; padding: 3mm; text-align: center; margin-top: 3mm; }
.label-cod .v { font-size: 18pt; font-weight: 800; }

@media print {
  .no-print, .sidebar, .topbar, .pub-nav, .footer { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; }
  .label-sheet { border: 0; page-break-after: always; }
}

/* ---------------------------------------------------------------- */
/* Mobile                                                            */
.mobile-bar { display: none; }

@media (max-width: 1080px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .sidebar { display: none; }
  .topbar { padding: 14px 16px; }
  .content { padding: 16px 16px 88px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .hero { padding: 40px 16px; }
  .section { padding: 36px 16px; }
  .cell { border-inline-end: 0; }
  .track-box .panel-body { flex-direction: column; }
  .track-box .input { border-inline-end: 0; border-bottom: var(--rule); }

  .mobile-bar {
    display: flex; position: fixed; inset-inline: 0; bottom: 0; z-index: 40;
    background: var(--bg); border-top: var(--rule);
  }
  .mobile-bar a {
    flex: 1; padding: 10px 4px 12px; text-align: center; text-decoration: none;
    color: var(--muted-2); font-size: 10px; font-weight: 600;
    border-inline-end: var(--thin);
  }
  .mobile-bar a:last-child { border-inline-end: 0; }
  .mobile-bar a.is-active { color: var(--accent); }
  .mobile-bar .ico { display: block; font-size: 17px; margin-bottom: 2px; }
  .table thead { display: none; }
  .table tbody td {
    display: flex; justify-content: space-between; gap: var(--s3);
    padding: 8px 14px; border-bottom: var(--thin);
  }
  .table tbody td::before {
    content: attr(data-label); font-size: 11px; text-transform: uppercase;
    letter-spacing: .08em; color: var(--muted); font-weight: 600;
  }
  .table tbody tr { display: block; border-bottom: var(--rule); padding: 6px 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
