/* ============ Aramex Tunisie Hub — design tokens ============ */
:root {
  --red: #E1251B;
  --red-600: #C41D14;
  --red-700: #9E160F;
  --red-50: #FDECEA;
  --ink: #15161A;
  --ink-2: #1E2026;
  --ink-3: #2A2D35;

  --bg: #F5F3F0;
  --surface: #FFFFFF;
  --surface-2: #FAF8F6;
  --border: #E8E3DE;
  --text: #17181C;
  --muted: #6E6A66;
  --faint: #A29D98;
  --shadow: 0 1px 2px rgba(20, 16, 12, .04), 0 8px 24px -12px rgba(20, 16, 12, .12);
  --shadow-lg: 0 24px 60px -20px rgba(20, 16, 12, .35);

  --s-created: #8A8580;  --s-created-bg: #F0EDEA;
  --s-picked: #7C3AED;   --s-picked-bg: #F1EAFE;
  --s-transit: #2563EB;  --s-transit-bg: #E8EFFD;
  --s-out: #D97706;      --s-out-bg: #FDF3E2;
  --s-deliv: #16A34A;    --s-deliv-bg: #E5F6EB;
  --s-exc: #E1251B;      --s-exc-bg: #FDECEA;
  --s-paid: #0D9488;     --s-paid-bg: #DDF4F1;
  --s-return: #92400E;   --s-return-bg: #FDF0E2;

  --radius: 18px;
  --radius-sm: 12px;
  --font: 'Outfit', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1013; --surface: #17181D; --surface-2: #1C1E24; --border: #2A2C33;
    --text: #F2F0ED; --muted: #A09B96; --faint: #6D6964; --red-50: #3A1512;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.6); --shadow-lg: 0 24px 60px -20px rgba(0,0,0,.8);
    --s-created-bg: #24252A; --s-picked-bg: #2A2140; --s-transit-bg: #1A2540; --s-out-bg: #3A2A12; --s-deliv-bg: #133321; --s-exc-bg: #3A1512;
    --s-picked: #A78BFA; --s-transit: #60A5FA; --s-out: #FBBF24; --s-deliv: #4ADE80; --s-exc: #FF6B61; --s-created: #A09B96; --s-paid: #2DD4BF; --s-paid-bg: #123330;
    --s-return: #FB923C; --s-return-bg: #3A2412;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1013; --surface: #17181D; --surface-2: #1C1E24; --border: #2A2C33;
  --text: #F2F0ED; --muted: #A09B96; --faint: #6D6964; --red-50: #3A1512;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.6); --shadow-lg: 0 24px 60px -20px rgba(0,0,0,.8);
  --s-created-bg: #24252A; --s-picked-bg: #2A2140; --s-transit-bg: #1A2540; --s-out-bg: #3A2A12; --s-deliv-bg: #133321; --s-exc-bg: #3A1512;
  --s-picked: #A78BFA; --s-transit: #60A5FA; --s-out: #FBBF24; --s-deliv: #4ADE80; --s-exc: #FF6B61; --s-created: #A09B96; --s-paid: #2DD4BF; --s-paid-bg: #123330;
  --s-return: #FB923C; --s-return-bg: #3A2412;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
.mono { font-family: var(--mono); font-size: .88em; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
::selection { background: var(--red); color: #fff; }

/* ============ Brand ============ */
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark { width: 40px; height: 40px; border-radius: 12px; background: var(--red); display: grid; place-items: center; box-shadow: 0 8px 20px -6px rgba(225, 37, 27, .7); flex: none; }
.brand-mark svg { width: 30px; height: 30px; }
.brand-word { line-height: 1.05; }
.brand-word b { display: block; font-size: 22px; font-weight: 800; letter-spacing: -.04em; color: #fff; }
.brand-word b span { color: var(--red); }
.brand-word small { font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: #9A968F; font-weight: 500; }

/* ============ Login ============ */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.15fr 1fr; }
.login-art { position: relative; overflow: hidden; background: radial-gradient(120% 90% at 0% 0%, #F2433A 0%, var(--red) 35%, var(--red-700) 100%); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.login-art .brand-word b span { color: var(--ink); }
.login-art .brand-mark { background: #fff; box-shadow: none; }
.login-art .brand-word small { color: rgba(255,255,255,.75); }
.login-art h1 { font-size: clamp(34px, 4.2vw, 58px); line-height: 1.02; letter-spacing: -.04em; font-weight: 700; margin: 0; max-width: 12ch; position: relative; z-index: 1; }
.login-art p { max-width: 42ch; opacity: .85; font-size: 17px; position: relative; z-index: 1; }
.login-map { position: absolute; top: 4%; bottom: 4%; right: 2%; width: 55%; opacity: .95; }
.login-map .route-svg { width: 100%; height: 100%; }
.login-art .city text { font-size: 9px; }
.login-stats { display: flex; gap: 32px; position: relative; z-index: 1; }
.login-stats div b { display: block; font-size: 28px; font-weight: 700; letter-spacing: -.03em; }
.login-stats div span { font-size: 13px; opacity: .75; }
.login-form-wrap { display: grid; place-items: center; padding: 32px 16px; background: var(--bg); }
.login-form { width: 100%; max-width: 380px; }
.login-form h2 { font-size: 30px; letter-spacing: -.03em; margin: 0 0 4px; }
.login-form .hint { margin-top: 24px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface); border: 1px dashed var(--border); font-size: 13px; color: var(--muted); }

/* ============ Shell ============ */
.shell { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }
.sidebar { background: var(--ink); color: #D8D4CF; padding: 24px 16px; display: flex; flex-direction: column; gap: 28px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar::after { content: ''; position: absolute; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-label { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: #6D6964; padding: 0 12px 6px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; text-decoration: none; color: #BDB8B2; font-weight: 500; transition: background .15s, color .15s; position: relative; }
.nav a svg { width: 20px; height: 20px; flex: none; opacity: .85; }
.nav a:hover { background: var(--ink-2); color: #fff; }
.nav a.active { background: linear-gradient(90deg, rgba(225,37,27,.22), rgba(225,37,27,.04)); color: #fff; }
.nav a.active::before { content: ''; position: absolute; left: -16px; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: var(--red); }
.nav a .count { margin-left: auto; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 99px; }
.side-foot { margin-top: auto; background: var(--ink-2); border-radius: 16px; padding: 14px; display: flex; align-items: center; gap: 12px; }
.avatar { width: 38px; height: 38px; border-radius: 12px; background: linear-gradient(135deg, var(--red), #FF7A45); display: grid; place-items: center; font-weight: 700; color: #fff; flex: none; }
.side-foot .who { min-width: 0; flex: 1; }
.side-foot .who b { display: block; color: #fff; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-foot .who span { font-size: 12px; color: #8C8781; }
.icon-btn { width: 38px; height: 38px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface); display: grid; place-items: center; cursor: pointer; color: var(--muted); transition: all .15s; flex: none; }
.icon-btn:hover { color: var(--text); border-color: var(--faint); }
.icon-btn svg { width: 18px; height: 18px; }
.side-foot .icon-btn { background: transparent; border-color: var(--ink-3); color: #8C8781; }
.side-foot .icon-btn:hover { color: #fff; border-color: #55524D; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 18px 32px; position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid transparent; }
.topbar.scrolled { border-bottom-color: var(--border); }
.topbar h1 { font-size: 24px; letter-spacing: -.03em; margin: 0; font-weight: 700; }
.topbar .crumb { font-size: 13px; color: var(--muted); }
.topbar .spacer { flex: 1; }
.menu-btn { display: none; }
.live-pill { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 99px; background: var(--surface); border: 1px solid var(--border); font-size: 13px; font-weight: 500; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--s-deliv); position: relative; }
.live-dot::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--s-deliv); animation: ping 1.8s ease-out infinite; }
.live-pill.off .live-dot { background: var(--faint); }
.live-pill.off .live-dot::after { display: none; }
@keyframes ping { from { transform: scale(.5); opacity: 1; } to { transform: scale(1.8); opacity: 0; } }
.content { padding: 8px 32px 48px; display: flex; flex-direction: column; gap: 24px; }

/* ============ Cards & grids ============ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 12px; padding: 18px 22px 0; }
.card-h h3 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.card-h .sub { font-size: 13px; color: var(--muted); }
.card-b { padding: 18px 22px 22px; }
.grid { display: grid; gap: 24px; }
.g-kpi { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* Hero */
.hero { position: relative; overflow: hidden; border-radius: 18px; color: #fff; padding: 14px 24px; min-height: 0; background: linear-gradient(115deg, var(--ink) 0%, var(--ink-2) 45%, #3B0F0C 100%); display: grid; grid-template-columns: 1fr 150px; gap: 16px; align-items: center; }
.hero::before { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(-45deg, transparent 0 22px, rgba(255,255,255,.025) 22px 44px); }
.hero > * { position: relative; }
.hero .eyebrow { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: #FF8B83; font-weight: 600; }
.hero h2 { font-size: clamp(18px, 2vw, 24px); line-height: 1.1; letter-spacing: -.03em; margin: 2px 0 4px; font-weight: 700; }
.hero h2 em { font-style: normal; color: var(--red); background: linear-gradient(90deg, #FF5A4F, #FF9A5C); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { margin: 0; color: #B6B1AB; max-width: none; font-size: 13.5px; }
.hero-actions { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.hero-actions .btn { padding: 6px 12px; font-size: 13px; }
.hero-map .route-svg { display: block; width: 100%; height: 130px; margin: 0; }

/* Route animation */
.route-line { fill: none; stroke: rgba(255,255,255,.28); stroke-width: 2; stroke-dasharray: 2 8; stroke-linecap: round; }
.route-line.hot { stroke: #FF5A4F; stroke-dasharray: 10 10; animation: dash 1.2s linear infinite; stroke-width: 2.5; }
@keyframes dash { to { stroke-dashoffset: -40; } }
.city circle.core { fill: #fff; }
.city circle.halo { fill: rgba(255,90,79,.25); animation: halo 2.4s ease-out infinite; transform-box: fill-box; transform-origin: center; }
.city text { fill: rgba(255,255,255,.82); font-size: 10.5px; font-family: var(--font); font-weight: 500; letter-spacing: .04em; }
@keyframes halo { 0% { transform: scale(.4); opacity: 1; } 100% { transform: scale(2.2); opacity: 0; } }
/* Carte de la page de connexion : tracé blanc pour rester lisible sur le fond rouge */
.login-art .route-line { stroke: rgba(255,255,255,.35); }
.login-art .route-line.hot { stroke: #fff; stroke-opacity: .9; }
.login-art .city circle.halo { fill: rgba(255,255,255,.28); }
.login-art .city text { fill: #fff; }

/* KPI */
.kpi { padding: 20px 22px; position: relative; overflow: hidden; }
.kpi[data-view] { transition: transform .15s, box-shadow .15s; }
.kpi[data-view]:hover, .kpi[data-view]:focus-visible { transform: translateY(-2px); box-shadow: var(--shadow-lg); outline: none; }
.kpi .k-top { display: flex; align-items: center; justify-content: space-between; }
.kpi .k-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi .k-icon { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; }
.kpi .k-icon svg { width: 18px; height: 18px; }
.kpi .k-value { font-size: 38px; font-weight: 700; letter-spacing: -.045em; margin-top: 10px; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi .k-foot { font-size: 12.5px; color: var(--muted); margin-top: 8px; display: flex; align-items: center; gap: 6px; }
.kpi.accent { background: var(--red); color: #fff; border-color: var(--red); }
.kpi.accent .k-label, .kpi.accent .k-foot { color: rgba(255,255,255,.8); }
.kpi.accent .k-icon { background: rgba(255,255,255,.18); color: #fff; }
.kpi.accent::after { content: ''; position: absolute; right: -40px; bottom: -60px; width: 160px; height: 160px; border-radius: 50%; border: 22px solid rgba(255,255,255,.08); }
.bump { animation: bump .6s cubic-bezier(.3,1.6,.5,1); }
@keyframes bump { 40% { transform: scale(1.12); } }

/* Chart */
.bars { display: grid; grid-template-columns: repeat(24, 1fr); align-items: end; gap: 5px; height: 170px; padding-top: 8px; }
.bars .bar { background: var(--red-50); border-radius: 6px 6px 3px 3px; position: relative; min-height: 4px; transition: height .5s cubic-bezier(.2,.8,.2,1), background .2s; cursor: default; }
.bars .bar.now { background: var(--red); }
.bars .bar:hover { background: var(--red-600); }
.bars .bar:hover .tip { opacity: 1; transform: translate(-50%, -4px); }
.bar .tip { position: absolute; bottom: 100%; left: 50%; transform: translate(-50%, 4px); background: var(--ink); color: #fff; font-size: 11px; padding: 4px 8px; border-radius: 8px; white-space: nowrap; opacity: 0; pointer-events: none; transition: all .15s; z-index: 2; }
.bars-x { display: flex; justify-content: space-between; font-size: 11px; color: var(--faint); margin-top: 8px; }

/* Status pipeline */
.pipeline { display: flex; flex-direction: column; gap: 12px; }
.pipe-row { display: grid; grid-template-columns: 150px 1fr 44px; align-items: center; gap: 12px; font-size: 14px; }
.pipe-track { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--border); }
.pipe-fill { height: 100%; border-radius: 99px; transition: width .6s cubic-bezier(.2,.8,.2,1); }
.pipe-row b { text-align: right; font-variant-numeric: tabular-nums; }

/* Feed */
.feed { display: flex; flex-direction: column; }
.feed-item { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; padding: 12px 22px; border-top: 1px solid var(--border); cursor: pointer; transition: background .15s; }
.feed-item:hover { background: var(--surface-2); }
.feed-item.new { animation: slidein .7s cubic-bezier(.2,.8,.2,1); }
@keyframes slidein { from { opacity: 0; transform: translateY(-10px); background: var(--red-50); } }
.feed-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; }
.feed-ico svg { width: 18px; height: 18px; }
.feed-item .t1 { font-weight: 600; font-size: 14px; }
.feed-item .t2 { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-item .t3 { font-size: 12px; color: var(--faint); text-align: right; white-space: nowrap; }

/* Accounts mini list */
.acc-row { display: grid; grid-template-columns: 10px 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--border); }
.acc-row:first-child { border-top: 0; }
.acc-dot { width: 10px; height: 10px; border-radius: 50%; }
.acc-row b { font-weight: 600; font-size: 14px; }
.acc-row small { display: block; color: var(--muted); font-size: 12px; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-created { color: var(--s-created); background: var(--s-created-bg); }
.st-picked_up { color: var(--s-picked); background: var(--s-picked-bg); }
.st-in_transit { color: var(--s-transit); background: var(--s-transit-bg); }
.st-out_for_delivery { color: var(--s-out); background: var(--s-out-bg); }
.st-delivered { color: var(--s-deliv); background: var(--s-deliv-bg); }
.st-exception { color: var(--s-exc); background: var(--s-exc-bg); }
.st-returned { color: var(--s-return); background: var(--s-return-bg); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 8px; font-size: 12px; font-weight: 500; background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; }
.chip .acc-dot { width: 7px; height: 7px; }

/* Buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); font-weight: 600; font-size: 14px; cursor: pointer; transition: all .15s; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--faint); }
.btn svg { width: 17px; height: 17px; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; box-shadow: 0 8px 20px -8px rgba(225,37,27,.8); }
.btn.primary:hover { background: var(--red-600); }
.btn.dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.ghost-light { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.16); color: #fff; }
.btn.ghost-light:hover { background: rgba(255,255,255,.15); }
.btn.danger { color: var(--s-exc); }
.btn.danger:hover { background: var(--s-exc-bg); border-color: var(--s-exc); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; padding: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 13px; font-weight: 600; }
.field .help { font-size: 12.5px; color: var(--muted); }
.input, .select { width: 100%; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s; }
.input:focus, .select:focus { border-color: var(--red); box-shadow: 0 0 0 4px color-mix(in srgb, var(--red) 15%, transparent); }
.input-group { display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.input-group:focus-within { border-color: var(--red); box-shadow: 0 0 0 4px color-mix(in srgb, var(--red) 15%, transparent); }
.input-group .input { border: 0; box-shadow: none !important; border-radius: 0; min-width: 0; }
.input-group .addon { display: flex; align-items: center; padding: 0 12px; background: var(--surface-2); color: var(--muted); font-size: 13px; border-right: 1px solid var(--border); white-space: nowrap; }
.input-group button { border: 0; border-left: 1px solid var(--border); background: var(--surface-2); padding: 0 12px; cursor: pointer; color: var(--muted); display: grid; place-items: center; }
.input-group button:hover { color: var(--red); }
.input-group button svg { width: 17px; height: 17px; }
.error-msg { color: var(--s-exc); font-size: 13px; min-height: 20px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }

/* Switch */
.switch { position: relative; display: inline-block; vertical-align: middle; width: 48px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--s-exc); border-radius: 99px; cursor: pointer; transition: .2s; }
.switch span::before { content: ''; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 2px 4px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--s-deliv); }
.switch input:checked + span::before { transform: translateX(20px); }
.switch.yn { width: 54px; }
.switch.yn span { background: var(--s-exc); }
.switch.yn span::after { content: '✕'; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 13px; font-weight: 800; line-height: 1; color: #fff; }
.switch.yn input:checked + span { background: var(--s-deliv); }
.switch.yn input:checked + span::after { content: '✓'; right: auto; left: 10px; color: #fff; }
.switch.yn input:checked + span::before { transform: translateX(26px); }

/* Webhook page */
.endpoint { border-radius: 20px; padding: 24px; background: var(--ink); color: #fff; position: relative; overflow: hidden; }
.endpoint::after { content: ''; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%; background: radial-gradient(circle, rgba(225,37,27,.45), transparent 70%); }
.endpoint > * { position: relative; z-index: 1; }
.endpoint .label { font-size: 12px; letter-spacing: .18em; text-transform: uppercase; color: #8C8781; }
.endpoint .url { display: flex; align-items: center; gap: 12px; margin-top: 10px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); border-radius: 14px; padding: 12px 12px 12px 16px; }
.endpoint .url code { font-family: var(--mono); font-size: 14px; flex: 1; word-break: break-all; }
.endpoint .method { background: var(--red); color: #fff; font-family: var(--mono); font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 6px; }
.endpoint .icon-btn { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.12); color: #fff; }
.code { background: var(--ink); color: #E8E4DF; border-radius: 14px; padding: 16px 18px; font-family: var(--mono); font-size: 12.5px; line-height: 1.7; overflow-x: auto; white-space: pre; margin: 0; position: relative; }
.code .k { color: #FF8B83; } .code .s { color: #A5E3B5; } .code .c { color: #6D6964; }
.code-wrap { position: relative; }
.code-wrap .icon-btn { position: absolute; top: 10px; right: 10px; background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.12); color: #fff; }
.steps { counter-reset: s; display: flex; flex-direction: column; gap: 14px; margin: 0; padding: 0; list-style: none; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 30px 1fr; gap: 12px; font-size: 14px; }
.steps li::before { content: counter(s); width: 30px; height: 30px; border-radius: 10px; background: var(--red-50); color: var(--red); font-weight: 700; display: grid; place-items: center; font-size: 13px; }
.log-row { display: grid; grid-template-columns: 58px 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); font-size: 13px; }
.log-row:first-child { border-top: 0; }
.code-pill { font-family: var(--mono); font-weight: 600; font-size: 12px; padding: 2px 8px; border-radius: 6px; text-align: center; }
.code-pill.ok { background: var(--s-deliv-bg); color: var(--s-deliv); }
.code-pill.ko { background: var(--s-exc-bg); color: var(--s-exc); }

/* Table */
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; padding: 18px 22px; }
.toolbar .input-group { flex: 1; min-width: 220px; }
.toolbar .select { width: auto; min-width: 170px; }
.table-wrap { overflow-x: auto; }
/* En-tête fixe : le tableau défile dans sa zone, l'en-tête reste visible */
.table-wrap.sticky-head { overflow: auto; max-height: max(420px, calc(100vh - 150px)); }
.table-wrap.sticky-head th { position: sticky; top: 0; z-index: 2; }
.seg button { padding: 7px 14px; border: 0; border-radius: 9px; background: transparent; font: inherit; font-size: 14px; font-weight: 500; color: var(--muted); cursor: pointer; white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* Réclamations : chat client ↔ back-office */
.drawer.chat { display: flex; flex-direction: column; overflow: hidden; position: relative; }
.drawer.chat .drawer-head { flex: none; padding-right: 64px; }
.chat-log { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; background: var(--surface-2); }
.bubble { max-width: 84%; align-self: flex-start; padding: 10px 14px; border-radius: 16px 16px 16px 4px; background: var(--surface); border: 1px solid var(--border); font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.bubble.me { align-self: flex-end; border-radius: 16px 16px 4px 16px; background: #E1251B; color: #fff; border-color: transparent; }
.bubble .meta { font-size: 11.5px; opacity: .75; margin-bottom: 4px; }
.sys { align-self: center; font-size: 12px; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px 12px; }
.att { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; white-space: normal; }
.att img { display: block; max-width: 220px; max-height: 170px; border-radius: 10px; cursor: zoom-in; }
.att .chip.file { text-decoration: none; color: inherit; }
.bubble.me .att .chip { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.3); color: #fff; }
.composer { flex: none; display: flex; flex-direction: column; gap: 8px; padding: 12px 16px 16px; border-top: 1px solid var(--border); background: var(--surface); }
.composer textarea { resize: none; }
/* Chat façon Messenger */
.chat-log { gap: 3px; }
.msg-row { display: flex; align-items: flex-end; gap: 8px; }
.msg-row.me { justify-content: flex-end; }
.msg-row .bubble { align-self: auto; max-width: 78%; }
.msg-row.them .bubble { background: var(--surface); }
.av { flex: none; width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--ink); color: #fff; font-size: 11px; font-weight: 700; overflow: hidden; }
.av svg { width: 16px; height: 16px; }
.av.team { background: #E1251B; }
.av.ghost { visibility: hidden; }
.msg-time { font-size: 11px; color: var(--muted); margin: 0 0 10px 36px; }
.msg-time.me { margin: 0 4px 10px 0; text-align: right; }
.msg-time b { color: var(--s-deliv); font-weight: 600; }
.typing-bar { flex: none; display: flex; align-items: center; gap: 8px; padding: 6px 18px; font-size: 12.5px; color: var(--muted); background: var(--surface-2); }
.typing-bar[hidden] { display: none; }
.dots { display: inline-flex; gap: 3px; padding: 6px 9px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite both; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
#chat-fab.unread { animation: fabpulse 1.6s infinite; }
@keyframes fabpulse { 0% { box-shadow: 0 0 0 0 rgba(225,37,27,.55); } 70% { box-shadow: 0 0 0 16px rgba(225,37,27,0); } 100% { box-shadow: 0 0 0 0 rgba(225,37,27,0); } }
#chat-preview { position: fixed; right: 20px; bottom: 92px; z-index: 90; width: min(340px, calc(100vw - 24px)); display: flex; align-items: center; gap: 12px; padding: 12px 36px 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); cursor: pointer; transform: translateY(16px); opacity: 0; pointer-events: none; transition: transform .25s, opacity .25s; }
#chat-preview.show { transform: none; opacity: 1; pointer-events: auto; }
#chat-preview .av { width: 40px; height: 40px; font-size: 13px; }
#chat-preview .av svg { width: 22px; height: 22px; }
#chat-preview .cpv-txt { min-width: 0; display: flex; flex-direction: column; }
#chat-preview .cpv-txt span { color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#chat-preview .cpv-x { position: absolute; top: 4px; right: 8px; border: 0; background: none; font-size: 20px; cursor: pointer; color: var(--muted); line-height: 1; }

/* Chat direct */
.chat-view { display: flex; flex-direction: column; height: 100%; min-height: 0; }
#chat-fab { position: fixed; right: 20px; bottom: 20px; z-index: 70; height: 56px; min-width: 56px; padding: 0 20px; gap: 10px; grid-auto-flow: column; border-radius: 28px; font: inherit; font-weight: 600; font-size: 15px; border: 0; background: #E1251B; color: #fff; display: grid; place-items: center; cursor: pointer; box-shadow: 0 8px 24px rgba(225,37,27,.4); }
#chat-fab svg { width: 24px; height: 24px; }
#chat-fab.open .fab-label { display: none; }
#chat-fab.open { padding: 0; width: 56px; }
@media (max-width: 640px) { #chat-fab { padding: 0; width: 56px; } #chat-fab .fab-label { display: none; } }
#chat-fab .count { position: absolute; top: -4px; right: -4px; }
#chat-panel { position: fixed; right: 20px; bottom: 88px; z-index: 70; width: min(380px, calc(100vw - 24px)); height: min(540px, calc(100vh - 110px)); display: none; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg); overflow: hidden; }
#chat-panel.open { display: flex; }
#chat-panel .cp-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; background: var(--ink); color: #fff; }
#chat-panel .cp-head small { display: block; color: #9A968F; font-size: 12px; }
#chat-panel .cp-head .icon-btn { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.15); color: #fff; }
#chat-panel .cp-body { flex: 1; min-height: 0; }
#chat-panel .cp-tabs { flex: none; display: flex; gap: 4px; padding: 8px 10px; overflow-x: auto; border-bottom: 1px solid var(--border); background: var(--surface-2); }
#chat-panel .cp-tabs button { border: 0; background: transparent; font: inherit; font-size: 13px; font-weight: 500; color: var(--muted); padding: 6px 12px; border-radius: 9px; cursor: pointer; white-space: nowrap; }
#chat-panel .cp-tabs button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.chat-page { display: grid; grid-template-columns: 320px 1fr; height: calc(100vh - 130px); min-height: 460px; overflow: hidden; padding: 0; }
.chat-list { overflow-y: auto; border-right: 1px solid var(--border); }
.cl-top { position: sticky; top: 0; z-index: 1; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--border); }
.chat-item { display: flex; gap: 10px; align-items: center; width: 100%; padding: 12px 14px; border: 0; border-bottom: 1px solid var(--border); background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.chat-item:hover, .chat-item.on { background: var(--surface-2); }
.chat-item .ci-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-item .ci-txt small { color: var(--muted); font-size: 12px; }
.chat-item .ci-last { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item .ci-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; color: var(--muted); }
.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.cm-head { flex: none; display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.cm-head .cm-back { display: none; }
.cm-body { flex: 1; min-height: 0; }
@media (max-width: 760px) {
  .chat-page { grid-template-columns: 1fr; }
  .chat-page .chat-main { display: none; }
  .chat-page.show-main .chat-list { display: none; }
  .chat-page.show-main .chat-main { display: flex; }
  .cm-head .cm-back { display: grid; }
}
.chip .x { border: 0; background: none; cursor: pointer; font-size: 16px; line-height: 1; margin-left: 4px; color: inherit; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 10px 16px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr { cursor: pointer; transition: background .12s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr.new { animation: slidein .8s; }
th:first-child, td:first-child { padding-left: 22px; }
th:last-child, td:last-child { padding-right: 22px; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 14px 22px; font-size: 13px; color: var(--muted); }
.empty { padding: 56px 22px; text-align: center; color: var(--muted); }
.empty svg { width: 56px; height: 56px; color: var(--faint); margin-bottom: 8px; }
.empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }

/* Account cards */
.acc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.acc-card { padding: 22px; position: relative; overflow: hidden; }
.acc-card .stripe { position: absolute; top: 0; left: 0; right: 0; height: 5px; }
.acc-card .num { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.acc-card h4 { margin: 4px 0 2px; font-size: 18px; letter-spacing: -.02em; }
.acc-card .meta { display: flex; gap: 18px; margin: 16px 0; }
.acc-card .meta div b { display: block; font-size: 22px; font-weight: 700; letter-spacing: -.03em; }
.acc-card .meta div span { font-size: 12px; color: var(--muted); }
.acc-card .label-box { position: absolute; right: 18px; top: 22px; width: 54px; height: 54px; border-radius: 14px; display: grid; place-items: center; font-weight: 800; font-size: 13px; letter-spacing: .04em; color: #fff; }
.add-card { border: 2px dashed var(--border); border-radius: var(--radius); display: grid; place-items: center; min-height: 200px; cursor: pointer; color: var(--muted); font-weight: 600; background: transparent; transition: all .15s; }
.add-card:hover { border-color: var(--red); color: var(--red); background: var(--red-50); }
.add-card svg { width: 28px; height: 28px; display: block; margin: 0 auto 6px; }

/* Checkbox list */
.check-list { display: flex; flex-direction: column; gap: 8px; max-height: 240px; overflow-y: auto; }
.check-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; transition: all .15s; }
.check-item:hover { border-color: var(--faint); }
.check-item input { accent-color: var(--red); width: 18px; height: 18px; }
.check-item:has(input:checked) { border-color: var(--red); background: var(--red-50); }
.check-item small { color: var(--muted); display: block; font-size: 12px; font-family: var(--mono); }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 3px; }
.seg label { padding: 7px 14px; border-radius: 9px; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--muted); }
.seg input { display: none; }
.seg label:has(input:checked) { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.color-row { display: flex; gap: 8px; flex-wrap: wrap; }
.color-row label { width: 30px; height: 30px; border-radius: 10px; cursor: pointer; border: 3px solid transparent; box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); }
.color-row input { display: none; }
.color-row label:has(input:checked) { border-color: var(--text); }

/* Modal & drawer */
.overlay { position: fixed; inset: 0; background: rgba(12, 10, 8, .5); backdrop-filter: blur(4px); z-index: 80; display: grid; place-items: center; padding: 16px; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.modal { width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow-y: auto; background: var(--surface); border-radius: 22px; box-shadow: var(--shadow-lg); animation: pop .25s cubic-bezier(.2,.9,.3,1.2); }
@keyframes pop { from { transform: translateY(12px) scale(.97); opacity: 0; } }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 22px 24px 6px; }
.modal-h h3 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.modal-b { padding: 12px 24px 24px; }
.drawer-ov { place-items: stretch end; padding: 0; }
.drawer { width: min(560px, 100vw); height: 100vh; background: var(--surface); overflow-y: auto; box-shadow: var(--shadow-lg); animation: slide .3s cubic-bezier(.2,.8,.2,1); }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.drawer-head { padding: 24px; background: var(--ink); color: #fff; position: relative; overflow: hidden; }
.drawer-head::before { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(-45deg, transparent 0 18px, rgba(255,255,255,.03) 18px 36px); }
.drawer-head > * { position: relative; }
.drawer-head .awb { font-family: var(--mono); font-size: 26px; font-weight: 600; letter-spacing: .02em; margin: 6px 0 12px; }
.drawer-head .icon-btn { position: absolute; top: 18px; right: 18px; background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.15); color: #fff; }
.drawer-body { padding: 24px; display: flex; flex-direction: column; gap: 24px; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
.kv div span { display: block; font-size: 12px; color: var(--muted); }
.kv div b { font-weight: 600; font-size: 14px; word-break: break-word; }
.timeline { position: relative; padding-left: 26px; display: flex; flex-direction: column; gap: 18px; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: repeating-linear-gradient(var(--border) 0 6px, transparent 6px 10px); }
.tl-item { position: relative; }
.tl-item::before { content: ''; position: absolute; left: -26px; top: 4px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); border: 3px solid currentColor; box-sizing: border-box; }
.tl-item.current::before { background: currentColor; box-shadow: 0 0 0 5px color-mix(in srgb, currentColor 20%, transparent); }
.tl-item b { color: var(--text); font-size: 14px; display: block; }
.tl-item span { color: var(--muted); font-size: 12.5px; }
h5 { margin: 0 0 12px; font-size: 12px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); }

/* Toasts */
#toasts { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 14px; box-shadow: var(--shadow-lg); font-size: 14px; display: flex; align-items: center; gap: 10px; animation: pop .3s cubic-bezier(.2,.9,.3,1.2); max-width: 380px; border-left: 4px solid var(--red); }
.toast.ok { border-left-color: var(--s-deliv); }
.toast.out { opacity: 0; transform: translateY(8px); transition: all .3s; }

/* Banner */
.banner { display: flex; gap: 12px; align-items: center; padding: 14px 18px; border-radius: 14px; background: var(--s-out-bg); color: var(--text); border: 1px solid color-mix(in srgb, var(--s-out) 30%, transparent); font-size: 14px; }
.banner svg { width: 20px; height: 20px; color: var(--s-out); flex: none; }
.banner .btn { margin-left: auto; }

/* Responsive */
@media (max-width: 1180px) {
  .g-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main, .g-2 { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr; }
  .hero .hero-map { display: none; }
}
@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login-art { min-height: 340px; padding: 28px 20px; }
  .login-stats { gap: 20px; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 264px; z-index: 60; transform: translateX(-100%); transition: transform .25s; }
  .shell.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .shell.nav-open::after { content: ''; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 55; }
  .menu-btn { display: grid; }
  .topbar { padding: 14px 16px; }
  .topbar h1 { font-size: 20px; }
  .topbar .crumb, .live-pill .lbl { display: none; }
  .content { padding: 4px 16px 32px; }
  .hero { padding: 14px 16px; }
  .kv { grid-template-columns: 1fr; }
  .pipe-row { grid-template-columns: 120px 1fr 36px; }
  .hide-sm { display: none; }
}
@media (max-width: 520px) {
  .g-kpi { grid-template-columns: 1fr 1fr; gap: 12px; }
  .kpi { padding: 16px; }
  .kpi .k-value { font-size: 30px; }
  .toolbar .select { flex: 1; min-width: 0; }
}

/* ============ Carte dynamique ============ */
.hero-map, .login-map { display: flex; flex-direction: column; align-items: center; }
.login-map .route-svg { flex: 1; min-height: 0; }
.route-svg .traveller { opacity: 0; transition: opacity .3s; }
.route-line.hot.draw { animation: dash 1.2s linear infinite, route-in .6s ease-out; }
@keyframes route-in { from { opacity: 0; } }
.city circle.core, .city text { transition: fill .4s, opacity .4s, transform .4s; transform-box: fill-box; transform-origin: center; }
.route-svg[data-map] .city text { opacity: .55; }
.route-svg[data-map] .city.on text { opacity: 1; font-weight: 700; }
.city.on circle.core { fill: #FF5A4F; }
.city.end circle.core { transform: scale(1.9); }
.city.end circle.halo { fill: rgba(255, 90, 79, .45); }
.login-art .city.on circle.core { fill: #fff; }
.login-art .city.end circle.halo { fill: rgba(255, 255, 255, .45); }
.map-caption { margin-top: 4px; display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 99px; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .14); color: #fff; font-size: 12px; font-weight: 600; white-space: nowrap; backdrop-filter: blur(6px); }
.map-caption .live-dot { background: #FF5A4F; }
.map-caption .live-dot::after { border-color: #FF5A4F; }
.login-art .map-caption { background: rgba(0, 0, 0, .18); }
.login-art .map-caption .live-dot { background: #fff; }
.login-art .map-caption .live-dot::after { border-color: #fff; }
@media (max-width: 860px) {
  .login-map { opacity: .35; width: 70%; }
  .login-map .map-caption { display: none; }
}

/* ============ Tableau de bord détaillé ============ */
.st-paid { color: var(--s-paid); background: var(--s-paid-bg); }
.dash-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: -8px; }
.sec-title { margin: 0; font-size: 22px; letter-spacing: -.03em; }
.seg.sm label { padding: 5px 10px; font-size: 12.5px; }
.g-fin { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.fin-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.fin-item { padding: 14px 16px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); border-top: 3px solid var(--text); min-width: 0; }
.fin-item.c-deliv { border-top-color: var(--s-deliv); }
.fin-item.c-paid { border-top-color: var(--s-paid); }
.fin-item.c-out { border-top-color: var(--s-out); }
.fin-item span { display: block; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.fin-item b { display: block; font-size: 21px; letter-spacing: -.03em; margin: 4px 0 2px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fin-item small { font-size: 12px; color: var(--muted); }
.stack { display: flex; height: 12px; border-radius: 99px; overflow: hidden; margin-top: 20px; background: var(--surface-2); gap: 2px; }
.stack span { height: 100%; transition: width .6s cubic-bezier(.2,.8,.2,1); min-width: 3px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend b { color: var(--text); font-weight: 600; margin-left: 4px; }
.ind { display: flex; flex-direction: column; gap: 18px; }
.ring-wrap { display: flex; align-items: center; gap: 16px; }
.ring-wrap b { display: block; font-size: 15px; }
.ring-wrap small { color: var(--muted); font-size: 12.5px; }
.ring { --p: 0; width: 76px; height: 76px; border-radius: 50%; flex: none; display: grid; place-items: center; background: conic-gradient(var(--s-deliv) calc(var(--p) * 1%), var(--surface-2) 0); position: relative; }
.ring::before { content: ''; position: absolute; inset: 9px; border-radius: 50%; background: var(--surface); }
.ring b { position: relative; font-size: 16px !important; letter-spacing: -.02em; }
.ind-list { display: flex; flex-direction: column; }
.ind-list div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--border); font-size: 14px; }
.ind-list span { color: var(--muted); }
.ind-list b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.bars .bar.m-delivered { background: var(--s-deliv-bg); }
.bars .bar.m-delivered.now, .bars .bar.m-delivered:hover { background: var(--s-deliv); }
.bars .bar.m-amount { background: var(--s-paid-bg); }
.bars .bar.m-amount.now, .bars .bar.m-amount:hover { background: var(--s-paid); }
.gov-row { display: grid; grid-template-columns: 26px 1fr auto; gap: 12px; align-items: center; padding: 9px 0; }
.gov-rank { width: 26px; height: 26px; border-radius: 8px; background: var(--red-50); color: var(--red); font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.gov-top { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; }
.gov-top span { color: var(--muted); font-size: 12px; white-space: nowrap; }
.gov-track { position: relative; height: 6px; border-radius: 99px; background: var(--surface-2); margin-top: 6px; overflow: hidden; }
.gov-track span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 99px; background: color-mix(in srgb, var(--red) 30%, transparent); transition: width .6s; }
.gov-track span.d { background: var(--red); }
.gov-amt { font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
.acc-table td { white-space: nowrap; }
.total-row td { background: var(--surface-2); font-weight: 700; border-bottom: 0; }
@media (max-width: 1180px) { .g-fin { grid-template-columns: 1fr; } }
@media (max-width: 860px) { .fin-grid { grid-template-columns: 1fr 1fr; } .fin-item b { font-size: 18px; } }
.bars .bar:nth-child(-n+3) .tip { left: 0; transform: translate(0, 4px); }
.bars .bar:nth-child(-n+3):hover .tip { transform: translate(0, -4px); }
.bars .bar:nth-last-child(-n+3) .tip { left: auto; right: 0; transform: translate(0, 4px); }
.bars .bar:nth-last-child(-n+3):hover .tip { transform: translate(0, -4px); }
.main { overflow-x: clip; }

/* Filtre de période personnalisée */
.period-ctl { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.seg label svg { width: 14px; height: 14px; vertical-align: -2px; margin-right: 5px; }
.range { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); animation: pop .25s cubic-bezier(.2,.9,.3,1.2); }
.range label { display: flex; flex-direction: column; gap: 3px; }
.range label span { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.range .input { padding: 7px 10px; font-size: 14px; width: 150px; }
.range .btn { height: 36px; }
@media (max-width: 860px) {
  .period-ctl { align-items: stretch; width: 100%; }
  .period-ctl .seg { overflow-x: auto; }
  .range .input { width: 100%; }
  .range label { flex: 1; min-width: 130px; }
}

/* API Client Info (comptes Aramex) */
.api-box { border: 1px solid var(--border); border-radius: 14px; padding: 6px 16px 14px; margin: 0 0 16px; background: var(--surface-2); }
.api-box legend { display: inline-flex; align-items: center; gap: 6px; padding: 0 6px; font-size: 13px; font-weight: 700; }
.api-box legend svg { width: 16px; height: 16px; color: var(--red); }
.api-box .field { margin-bottom: 12px; }
.api-box .help svg { width: 13px; height: 13px; vertical-align: -2px; }
.api-state { display: inline-flex; align-items: center; gap: 6px; margin-top: 4px; padding: 3px 10px; border-radius: 8px; font-size: 12px; font-weight: 600; background: var(--s-out-bg); color: var(--s-out); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.api-state.ok { background: var(--s-deliv-bg); color: var(--s-deliv); }
.api-state svg { width: 13px; height: 13px; flex: none; }
.acc-card h4 { padding-right: 64px; }

/* ============ Codes SH ============ */
.g-codes { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); }
.drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; padding: 28px 22px; border: 2px dashed var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; transition: all .15s; min-height: 210px; }
.drop:hover, .drop.over { border-color: var(--red); background: var(--red-50); }
.drop.busy { opacity: .6; pointer-events: none; }
.drop b { font-size: 16px; }
.drop > span:not(.drop-ico), .drop small { color: var(--muted); font-size: 13px; }
.drop-ico { width: 52px; height: 52px; border-radius: 16px; background: var(--red); color: #fff; display: grid; place-items: center; box-shadow: 0 10px 24px -10px rgba(225,37,27,.8); margin-bottom: 6px; }
.drop-ico svg { width: 24px; height: 24px; }
.drop-last { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; padding: 4px 10px; border-radius: 8px; background: var(--s-deliv-bg); color: var(--s-deliv) !important; font-weight: 600; }
.status-legend { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.legend-chip { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; transition: all .15s; }
.legend-chip:hover { border-color: var(--faint); }
.legend-chip.on { border-color: var(--text); background: var(--surface); box-shadow: var(--shadow); }
.legend-chip b { font-variant-numeric: tabular-nums; }
.code-tag { font-weight: 600; background: var(--ink); color: #fff; padding: 2px 8px; border-radius: 6px; font-size: 12px; }
.codes-table td { vertical-align: middle; }
.status-select { appearance: none; -webkit-appearance: none; border: 0; border-radius: 99px; padding: 5px 30px 5px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer; outline: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
.status-select:focus-visible { box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 30%, transparent); }
.status-select.st-created { background-color: var(--s-created-bg); color: var(--s-created); }
.status-select.st-picked_up { background-color: var(--s-picked-bg); color: var(--s-picked); }
.status-select.st-in_transit { background-color: var(--s-transit-bg); color: var(--s-transit); }
.status-select.st-out_for_delivery { background-color: var(--s-out-bg); color: var(--s-out); }
.status-select.st-delivered { background-color: var(--s-deliv-bg); color: var(--s-deliv); }
.status-select.st-exception { background-color: var(--s-exc-bg); color: var(--s-exc); }
.status-select.st-paid { background-color: var(--s-paid-bg); color: var(--s-paid); }
.status-select option { background: var(--surface); color: var(--text); }

/* ============ Nouvelle expédition ============ */
.g-ship { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
.ship-main, .ship-side { display: flex; flex-direction: column; gap: 24px; min-width: 0; }
.ship-side { position: sticky; top: 90px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-grid .field { margin-bottom: 14px; }
.ship-summary { background: var(--ink); color: #fff; border-color: var(--ink); }
.ship-summary .sum-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,.1); font-size: 14px; }
.ship-summary .sum-row span { color: #9A968F; }
.ship-summary .sum-row.total { border: 0; margin: 6px 0 14px; }
.ship-summary .sum-row.total b { font-size: 22px; letter-spacing: -.02em; }
.ship-summary .error-msg { color: #FF8B83; }
.done-head { text-align: center; padding: 28px 24px 10px; }
.done-head h3 { margin: 10px 0 2px; font-size: 22px; }
.done-head p { margin: 0; font-size: 13px; }
.done-ico { width: 56px; height: 56px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--s-deliv-bg); color: var(--s-deliv); }
.done-ico svg { width: 28px; height: 28px; }
.awb-big { font-size: 30px; font-weight: 600; letter-spacing: .04em; margin-top: 10px; padding: 10px 16px; border-radius: 14px; background: var(--surface-2); border: 1px dashed var(--border); }
textarea.input { resize: vertical; min-height: 90px; }
@media (max-width: 1180px) { .g-codes, .g-ship { grid-template-columns: 1fr; } .ship-side { position: static; } }
@media (max-width: 520px) { .form-grid { grid-template-columns: 1fr; } }

/* ============ Création multiple ============ */
.bulk-cta { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 16px 20px; border-radius: var(--radius); background: linear-gradient(100deg, var(--red-50), var(--surface) 70%); border: 1px solid color-mix(in srgb, var(--red) 25%, var(--border)); }
.bulk-cta b { display: block; font-size: 15px; }
.bulk-cta span { font-size: 13px; color: var(--muted); }
.stepper { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stepper i { flex: 1; min-width: 16px; height: 2px; background: var(--border); border-radius: 2px; }
.stp { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; color: var(--muted); }
.stp span { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; background: var(--surface); border: 2px solid var(--border); }
.stp span svg { width: 14px; height: 14px; }
.stp.on { color: var(--text); }
.stp.on span { background: var(--red); border-color: var(--red); color: #fff; box-shadow: 0 6px 16px -6px rgba(225,37,27,.8); }
.stp.done span { background: var(--s-deliv); border-color: var(--s-deliv); color: #fff; }
.map-grid { display: grid; grid-template-columns: minmax(160px, 1fr) minmax(180px, 1.2fr) minmax(0, 1.2fr); gap: 10px 16px; align-items: center; margin-bottom: 16px; }
.map-head { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding-bottom: 4px; border-bottom: 1px solid var(--border); }
.map-label { font-weight: 600; font-size: 14px; }
.map-sample { font-size: 12.5px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bulk-table td { vertical-align: middle; }
.bulk-table tr.skipped td { opacity: .45; }
.bulk-table tr.done { background: color-mix(in srgb, var(--s-deliv-bg) 55%, transparent); }
.bulk-table .st-cell { min-width: 190px; }
.city-ok { display: inline-flex; align-items: center; gap: 4px; color: var(--s-deliv); font-weight: 600; white-space: nowrap; }
.city-fix { display: flex; flex-direction: column; gap: 4px; min-width: 150px; }
.city-raw { font-size: 11.5px; color: var(--s-exc); text-decoration: line-through; }
.city-input { padding: 6px 10px; font-size: 13px; }
.city-input.sugg { border-color: var(--s-out); background: var(--s-out-bg); }
.city-input.bad { border-color: var(--s-exc); background: var(--s-exc-bg); }
.res-ok { display: inline-flex; align-items: center; gap: 8px; color: var(--s-deliv); }
.res-ok .btn { padding: 4px 7px; }
.res-run { display: inline-flex; align-items: center; gap: 8px; color: var(--s-transit); font-weight: 600; font-size: 13px; }
.res-err { color: var(--s-exc); font-size: 12px; margin-top: 4px; max-width: 280px; }
.spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { height: 6px; background: var(--surface-2); margin: 0 22px 12px; border-radius: 99px; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--red), #FF7A45); transition: width .3s; }
@media (max-width: 860px) { .map-grid { grid-template-columns: 1fr 1fr; } }
button.stp { border: 0; background: none; padding: 4px 8px 4px 4px; margin: -4px; border-radius: 99px; cursor: pointer; font: inherit; font-weight: 600; font-size: 14px; }
button.stp:hover { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.acc-shipper { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12.5px; color: var(--text); min-width: 0; }
.acc-shipper svg { width: 14px; height: 14px; color: var(--muted); flex: none; }
.acc-shipper span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.api-box legend svg { flex: none; }

/* ============ Langues (FR / EN / AR) ============ */
.lang-sel { width: auto; min-width: 108px; height: 36px; padding: 4px 10px; font-size: 13px; }
[dir="rtl"] { --font: 'Noto Sans Arabic', 'Outfit', system-ui, 'Segoe UI', Tahoma, sans-serif; }
[dir="rtl"] body, [dir="rtl"] input, [dir="rtl"] select, [dir="rtl"] button, [dir="rtl"] textarea { font-family: var(--font); }
[dir="rtl"] .mono, [dir="rtl"] .code, [dir="rtl"] pre { direction: ltr; unicode-bidi: plaintext; }
[dir="rtl"] th, [dir="rtl"] td { text-align: right; }
[dir="rtl"] .num { text-align: left; }
[dir="rtl"] .hero h2, [dir="rtl"] .hero p { letter-spacing: 0; }
[dir="rtl"] .drawer-ov { justify-content: flex-start; }
[dir="rtl"] .toast { border-left: 0; border-right: 4px solid var(--red); }

/* ============ Responsive : téléphone et tablette ============ */
.seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg > * { flex: none; }
.topbar > div:not(.spacer) { min-width: 0; }
.topbar h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 860px) {
  .topbar { gap: 10px; }
  .topbar > div:not(.spacer) { flex: 1 1 auto; }
  .topbar .spacer { display: none; }
  .lang-sel { min-width: 0; width: 92px; }
  .toolbar { padding: 14px 16px; }
  .toolbar .input-group { min-width: 0; flex: 1 1 100%; }
  .toolbar .select, .toolbar .btn { flex: 1 1 auto; }
  .card-h { padding: 16px 16px 0; flex-wrap: wrap; }
  .card-b { padding: 16px; }
  .modal { max-width: calc(100vw - 24px); }
  .modal-b { padding: 12px 16px 20px; }
  .drawer { width: 100vw; }
  .drawer-head { padding: 20px 16px; }
  .drawer-body { padding: 18px 16px; }
  .dash-head { align-items: flex-start; }
  .period-ctl { align-items: stretch; width: 100%; }
  .period-ctl .select, .period-ctl .btn { width: 100%; }
  th, td { padding-left: 10px; padding-right: 10px; }
  .code { font-size: 11.5px; }
  .pager { flex-wrap: wrap; gap: 10px; }
}
@media (max-width: 520px) {
  .live-pill { display: none; }
  .topbar h1 { font-size: 18px; }
  .lang-sel { width: 78px; padding: 4px 6px; }
  .content { gap: 18px; }
  .sec-title { font-size: 19px; }
  .bulk-cta { flex-direction: column; align-items: stretch; }
  #chat-panel { right: 8px; left: 8px; width: auto; bottom: 80px; }
  #chat-fab { right: 14px; bottom: 14px; }
  #chat-preview { right: 8px; left: 8px; width: auto; bottom: 80px; }
  .chat-page { height: calc(100vh - 110px); }
}
.grid > *, .card, .code-wrap, .api-box { min-width: 0; }
.code-wrap { max-width: 100%; }
.code { max-width: 100%; }
