:root {
  --ink: #202124; --muted: #5f6368; --line: #dadce0; --bg: #f8f9fa; --paper: #fff;
  --brand: #188038; --brand-ink: #fff; --danger: #c5221f;
  --head-green: #93c47d; --head-yellow: #f1e84b; --head-orange: #e6b85c;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 13px/1.4 Roboto, Arial, "Noto Sans Arabic", sans-serif; color: var(--ink); background: var(--bg); }
a { color: #1a73e8; text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 12px 0; } h1 small { font-size: 14px; color: var(--muted); font-weight: 400; }
h2 { font-size: 16px; margin: 20px 0 8px; }
code { background: #eef; padding: 1px 5px; border-radius: 4px; }

.top { display: flex; align-items: center; gap: 18px; padding: 0 14px; height: 44px; background: var(--paper); border-bottom: 1px solid var(--line); }
.brand { font-size: 16px; color: var(--ink); } .brand b { color: var(--brand); }
.top nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.top nav a { padding: 6px 10px; border-radius: 6px; color: var(--ink); white-space: nowrap; }
.top nav a.on { background: #e6f4ea; color: var(--brand); font-weight: 600; }
.who { display: flex; gap: 8px; align-items: center; color: var(--muted); }
.who button { border: 0; background: none; color: #1a73e8; cursor: pointer; font: inherit; }

.btn { display: inline-block; padding: 6px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--ink); font: inherit; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f1f3f4; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.ghost { border-color: transparent; color: #1a73e8; background: none; }
.btn.danger { color: var(--danger); }
input, select, textarea { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--ink); }
:focus-visible { outline: 2px solid #1a73e8; outline-offset: 1px; }

.msgs { padding: 8px 14px; } .msg { padding: 8px 12px; border-radius: 6px; background: #e6f4ea; }
.wrap { max-width: 1300px; margin: 0 auto; padding: 8px 16px 40px; }
.empty { color: var(--muted); padding: 24px; text-align: center; }
.hint { color: var(--muted); }

/* ---- the sheet ---- */
.sheetpage { display: flex; flex-direction: column; overflow: hidden; }
.toolbar { display: flex; gap: 12px; align-items: center; padding: 6px 12px; background: var(--paper); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tools { display: flex; gap: 6px; align-items: center; flex: 1; min-width: 300px; }
.tools input[type=search] { width: 300px; max-width: 40vw; }
.save { min-width: 110px; color: var(--muted); } .save.ok { color: var(--brand); } .save.err { color: var(--danger); font-weight: 600; }
.pager { color: var(--muted); } .pager a { margin: 0 6px; }

.gridwrap { flex: 1; overflow: auto; background: var(--paper); }
.grid { border-collapse: separate; border-spacing: 0; table-layout: fixed; width: max-content; }
.grid th, .grid td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); height: 21px; padding: 1px 4px; overflow: hidden; white-space: nowrap; text-overflow: clip; }
.grid thead th { position: sticky; z-index: 3; }
.grid .letters th { top: 0; height: 22px; background: #f8f9fa; color: var(--muted); font-weight: 400; text-align: center; }
.grid .heads th { top: 22px; height: 50px; white-space: normal; text-align: center; font-weight: 700; border-bottom: 2px solid #6aa84f; }
.hg { background: var(--head-green); } .hy { background: var(--head-yellow); } .ho { background: var(--head-orange); }
.grid .rn { position: sticky; left: 0; z-index: 2; width: 46px; min-width: 46px; background: #f8f9fa; color: var(--muted); font-weight: 400; text-align: center; cursor: pointer; }
.grid thead .rn { z-index: 4; }
.w-id { width: 100px; } .w-name { width: 100px; } .w-phone { width: 100px; } .w-addr { width: 320px; } .w-prod { width: 76px; }
.w-qty { width: 58px; } .w-var { width: 40px; } .w-price { width: 60px; } .w-date { width: 150px; } .w-st { width: 104px; }
.w-vers { width: 104px; } .w-com { width: 256px; } .w-ville { width: 104px; } .w-liv { width: 110px; } .w-hist { width: 230px; }
.w-track { width: 110px; } .w-sent { width: 110px; }
.grid td.num { text-align: right; } .grid td.ctr { text-align: center; }
.grid td[contenteditable]:focus { outline: 2px solid #1a73e8; outline-offset: -2px; background: #fff !important; color: #000 !important; white-space: normal; overflow: visible; position: relative; z-index: 1; }
.grid td.bad, .grid .bad { outline: 2px solid var(--danger); outline-offset: -2px; }
.grid td.sel { padding: 1px 3px; }
.grid td.sel select, .grid td.sel input { width: 100%; height: 19px; padding: 0 6px; border: 0; border-radius: 10px; background: #e8eaed; font-size: 12px; }
.grid td.sel input { border-radius: 10px; }
.grid td.hist a { color: var(--ink); }
.grid tr.flash td { animation: flash 1.6s; } @keyframes flash { from { box-shadow: inset 0 0 0 99px #fff59d; } }

/* Row colour by statut on columns A–I, as in the sheet; the statut chip keeps the same colour. */
.grid tr td.c, .pill { background: var(--row, transparent); color: var(--row-ink, inherit); }
.grid tr td.sel select[data-f=statut] { background: var(--chip, #e8eaed); color: var(--chip-ink, inherit); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; }
.st-livre { --row: #4caf50; --chip: #d4edbc; --chip-ink: #11734b; }
.st-confirme { --row: #b7e1cd; --chip: #b7e1cd; }
.st-expedie { --row: #9fc5e8; --chip: #bfe1f6; --chip-ink: #0a53a8; }
.st-ameex-envoye { --row: #a4c2f4; --chip: #a4c2f4; }
.st-en-attente { --row: #ff00ff; --chip: #e6cff2; --chip-ink: #5a3286; }
.st-reporte, .st-expreporte { --row: #ffe599; --chip: #ffe5a0; --chip-ink: #473821; }
.st-pas-de-reponse, .st-injoignable, .st-expinjoignable { --row: #f9cb9c; --chip: #ffc8aa; --chip-ink: #753800; }
.st-annulee { --row: #dd4b39; --chip: #ffcfc9; --chip-ink: #b10202; }
.st-pdr2 { --row: #f1c232; --chip: #ffe5a0; }
.st-pdr3 { --row: #e8a600; --chip: #e8a600; }
.st-expretourne, .st-expannulee, .st-exppdr { --row: #ea9999; --chip: #b10202; --chip-ink: #fff; }
.st-fake { --row: #dd4b39; --chip: #3d3d3d; --chip-ink: #fff; }
.st-double { --row: #b4a7d6; --chip: #b4a7d6; }
.st-black-liste, .st-inexistant { --row: #666; --row-ink: #fff; --chip: #3d3d3d; --chip-ink: #fff; }
.st-change { --row: #76d7ea; --chip: #c6dbe1; }
.st-facture-par-livreur { --row: #d9ead3; --chip: #d9ead3; }
.grid td.sel select.vers:not(:has(option[value=""]:checked)) { background: #d4edbc; color: #11734b; }

.tabs { display: flex; gap: 0; align-items: stretch; height: 36px; background: #f8f9fa; border-top: 1px solid var(--line); overflow-x: auto; flex: none; }
.tabs a { padding: 9px 16px; color: var(--ink); white-space: nowrap; border-right: 1px solid var(--line); }
.tabs a.on { background: #e1e9f7; color: #188038; font-weight: 700; border-bottom: 2px solid #188038; }
.tabs a.old { color: var(--muted); font-style: italic; } .tabs a.more { color: #1a73e8; }
dialog { border: 1px solid var(--line); border-radius: 10px; max-width: 640px; } dialog p { margin: 4px 0; }

/* ---- lists and cards ---- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.chk { display: inline-flex; gap: 6px; align-items: center; }
.list { width: 100%; border-collapse: collapse; background: var(--paper); border: 1px solid var(--line); }
.list.narrow { max-width: 420px; }
.list th { background: #202124; color: #fff; text-align: left; padding: 7px 10px; font-weight: 500; }
.list td { padding: 6px 10px; border-top: 1px solid var(--line); vertical-align: top; }
.list .r { text-align: right; font-variant-numeric: tabular-nums; }
.seg { display: inline-block; padding: 1px 8px; border-radius: 10px; background: #e8eaed; white-space: nowrap; }
.seg-vip { background: #fce8b2; } .seg-fidele { background: #d4edbc; } .seg-acheteur { background: #e6f4ea; }
.seg-retour { background: #ffcfc9; } .seg-annule { background: #ffe5a0; } .seg-blacklist { background: #3d3d3d; color: #fff; }
.kpis { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.kpis div { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; min-width: 130px; color: var(--muted); }
.kpis b { display: block; font-size: 20px; color: var(--ink); }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin: 12px 0; display: grid; gap: 10px; max-width: 720px; }
.card label { display: grid; gap: 4px; } .card label.chk { display: flex; } .card h2 { margin: 0; }
.card .btn { justify-self: start; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; align-items: start; }
.periods { display: flex; gap: 6px; align-items: center; }
.login { max-width: 340px; margin: 12vh auto; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 24px; }
.login form { display: grid; gap: 12px; } .login label { display: grid; gap: 4px; } .err { color: var(--danger); }
@media (max-width: 700px) { .list { display: block; overflow-x: auto; } .tools input[type=search] { width: 100%; max-width: none; } }

/* Livraison: the delivery men's sheet (Viperx_gotechnology layout). */
.sumbar { padding: 5px 12px; background: #fff8e1; border-bottom: 1px solid var(--line); flex: none; }
.sumbar a { margin-left: 10px; }
.tools label { color: var(--muted); }
.w-day { width: 84px; } .w-name2 { width: 150px; } .w-prod2 { width: 220px; } .w-var2 { width: 90px; } .w-st2 { width: 150px; } .w-tot { width: 80px; }
.grid td.wrap { white-space: normal; }
.grid td.c a { color: inherit; text-decoration: underline; }
.grid tr td.sel select[data-f=statut_livraison] { background: var(--chip, #e8eaed); color: var(--chip-ink, inherit); height: 24px; }
.si-livre, .si-livre-region { --row: #b7e1cd; --chip: #d4edbc; --chip-ink: #11734b; }
.si-facture-par-livreur { --row: #d9ead3; --chip: #11734b; --chip-ink: #fff; }
.si-reporte { --row: #ffe599; --chip: #ffe5a0; --chip-ink: #473821; }
.si-pas-de-reponse { --row: #f9cb9c; --chip: #ffc8aa; --chip-ink: #753800; }
.si-annule { --row: #ea9999; --chip: #ffcfc9; --chip-ink: #b10202; }
@media (max-width: 700px) { .toolbar .tools { flex-wrap: wrap; } }

/* Same look as the sheet Viperx_gotechnology: teal header, whole row A–I coloured by SITUATION, black line between factures. */
.grid.liv .heads th { background: #46bdc6; border-bottom: 2px solid #999; font-size: 14px; height: 24px; white-space: nowrap; }
.grid.liv .heads th.l { text-align: left; }
.grid.liv .letters th { top: 0; } .grid.liv .heads th { top: 22px; }
.w-qty2 { width: 36px; } .w-cour { width: 96px; } .w-frais { width: 150px; }
.grid.liv td.com { text-align: center; font-weight: 700; font-size: 11px; }
.grid.liv td.k-total { font-weight: 700; } .grid.liv td.small { font-size: 11px; color: var(--muted); }
.grid.liv tr[class^="si-"]:not(.si-vide) td.c { font-weight: 700; }
.grid.liv td.c.sel select { background: transparent; color: inherit; font-weight: 700; border-radius: 0; }
.grid.liv tr.si-vide td.c.sel select { background: #e8eaed; border-radius: 10px; }
.grid.liv .si-livre, .grid.liv .si-livre-region { --row: #6aa84f; --row-ink: #fff; }
.grid.liv .si-facture-par-livreur { --row: #9966ff; --row-ink: #fff; }
.grid.liv .si-annule { --row: #ff0000; --row-ink: #fff; }
.grid.liv .si-reporte { --row: #ffe599; --row-ink: #000; }
.grid.liv .si-pas-de-reponse { --row: #f9cb9c; --row-ink: #000; }
.grid.liv tr.blk td { background: #000; height: 16px; } .grid.liv tr.tot td.c { font-weight: 400; font-style: italic; }
.grid.liv select option { color: #000; background: #fff; }
.sumbar form.inl { display: inline; margin: 0 6px; } .sumbar .sep { color: var(--line); margin: 0 8px; }
.grid.liv .si-refuse { --row: #cc0000; --row-ink: #fff; } .grid.liv .si-doublee { --row: #b4a7d6; --row-ink: #000; }

/* ---- App look: dark sidebar on the left, same pages and grids ---- */
:root { --side: #1e2a44; --side-ink: #c9d3e8; --brand: #2f9e6f; --bg: #f3f5f9; --line: #e3e7ee; }
body:has(.top) { padding-left: 190px; }
body { font-family: Inter, Roboto, "Noto Sans Arabic", Arial, sans-serif; }
.top { position: fixed; left: 0; top: 0; bottom: 0; width: 190px; z-index: 20; flex-direction: column; align-items: stretch; gap: 6px; height: auto; padding: 14px 10px; background: var(--side); border: 0; }
.brand { display: flex; align-items: center; gap: 9px; color: #fff; font-size: 15px; font-weight: 600; padding: 2px 8px 14px; }
.brand b { color: #6fd3a6; } .brand .logo { width: 28px; height: 28px; border-radius: 8px; background: var(--brand); display: flex; align-items: center; justify-content: center; font-size: 17px; }
.top nav { flex-direction: column; gap: 3px; flex: 1; overflow: auto; }
.top nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--side-ink); font-size: 13.5px; }
.top nav a i { font-size: 18px; }
.top nav a:hover { background: #2a3857; text-decoration: none; color: #fff; }
.top nav a.on { background: var(--brand); color: #fff; font-weight: 600; }

.who { flex-direction: column; align-items: stretch; gap: 4px; border-top: 1px solid #34425f; padding-top: 10px; color: var(--side-ink); }
.who span { padding: 0 10px; } .who button { text-align: left; padding: 6px 10px; border-radius: 8px; color: var(--side-ink); }
.who button:hover { background: #2a3857; color: #fff; }
.btn { border-radius: 8px; } .btn.primary { background: var(--brand); border-color: var(--brand); }
input, select, textarea { border-radius: 8px; border-color: #d9dee8; }
.toolbar { padding: 10px 14px; border-bottom: 1px solid var(--line); }
.gridwrap { background: var(--bg); padding: 0; }
.grid { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; }
.grid .letters th { background: #eef1f6; }
.tabs { background: var(--paper); height: 40px; padding: 4px 10px; gap: 4px; align-items: center; }
.tabs a { border: 0; border-radius: 8px; padding: 6px 12px; color: #6b7280; }
.tabs a.on { background: #e4f4ec; color: #11734b; border-bottom: 0; }
.list, .card, .kpis div { border-radius: 10px; }
.list th { background: #1e2a44; }
.wrap { padding-top: 16px; }
@media (max-width: 800px) {
  body:has(.top) { padding-left: 0; padding-top: 48px; }
  .top { right: 0; bottom: auto; width: auto; height: 48px; flex-direction: row; align-items: center; padding: 0 8px; }
  .brand { padding: 0 6px; } .brand span { display: none; }
  .top nav { flex-direction: row; } .top nav a span { display: none; } .top nav a[href="/admin/"] { margin-top: 0; }
  .who { flex-direction: row; border: 0; padding: 0; } .who span { display: none; }
}

/* No page-level scrollbar (login and sheet pages); the grid keeps its own thin one. Product tabs: blue with white text. */
html, body { overflow-x: hidden; scrollbar-width: none; } html::-webkit-scrollbar, body::-webkit-scrollbar { display: none; }
.sheetpage { overflow: hidden; }
.login { margin: 8vh auto; }
.gridwrap { scrollbar-width: thin; scrollbar-color: #b6bfd0 transparent; }
.tabs { background: #1e3a8a; scrollbar-width: none; } .tabs::-webkit-scrollbar { display: none; }
.tabs a { background: #2f55c4; color: #fff; }
.tabs a:hover { background: #3b66e0; text-decoration: none; }
.tabs a.on { background: #fff; color: #1e3a8a; font-weight: 700; }
.tabs a.old { color: #dbe4ff; } .tabs a.more { color: #fff; background: #3b66e0; }

.mini { margin:0; } .list td .btn { padding: 3px 10px; } .list tr.off td { color: var(--muted); }
.ctx { position: fixed; z-index: 50; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.18); padding: 4px; } .ctx[hidden] { display: none; } .ctx button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 12px; font: inherit; cursor: pointer; border-radius: 6px; } .ctx button:hover { background: #eef1f6; }
.brand .logo { background: #fff; padding: 4px 3px; } .brand .logo img { width: 100%; height: 100%; object-fit: contain; }
.login .biglogo { display: block; width: 190px; margin: 0 auto 14px; }


/* ---- WhatsApp inbox (like WhatsApp Web) ---- */
.top nav a .badge, .wa-item .badge { margin-left: auto; background: #25d366; color: #fff; font-style: normal; font-size: 11px; font-weight: 700; border-radius: 10px; padding: 1px 7px; }
.grid .rn { width: 62px; min-width: 62px; } .grid .rn .wab { margin-left: 4px; color: #25d366; font-size: 14px; vertical-align: -2px; }
.wa { flex: 1; min-height: 0; display: grid; grid-template-columns: 340px 1fr; background: var(--paper); }
.wa-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.wa-search { padding: 8px; border-bottom: 1px solid var(--line); } .wa-search input { width: 100%; }
.wa-items { overflow: auto; flex: 1; }
.wa-item { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-bottom: 1px solid #f0f2f6; color: var(--ink); }
.wa-item:hover { background: #f6f8fb; text-decoration: none; } .wa-item.on { background: #e4f4ec; }
.av { width: 38px; height: 38px; border-radius: 50%; background: #25d366; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: none; text-transform: uppercase; }
.wa-item .tx { display: grid; min-width: 0; flex: 1; } .wa-item small { color: var(--muted); } .wa-item em { font-style: normal; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-item .mt { display: grid; justify-items: end; gap: 4px; color: var(--muted); font-size: 11px; }
.wa-chat { display: flex; flex-direction: column; min-height: 0; background: #efeae2; }
.wa-head { display: flex; gap: 12px; align-items: center; padding: 8px 14px; background: var(--paper); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.wa-orders { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.wa-orders .pill { background: var(--chip, #e8eaed); color: var(--chip-ink, #333); font-size: 11px; }
.wa-msgs { flex: 1; overflow: auto; padding: 14px 18px; display: flex; flex-direction: column; gap: 6px; }
.wa-msgs .m { max-width: 68%; padding: 6px 10px; border-radius: 10px; background: #fff; align-self: flex-start; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.wa-msgs .m.out { background: #d9fdd3; align-self: flex-end; }
.wa-msgs .b { white-space: pre-wrap; word-break: break-word; display: block; }
.wa-msgs small { display: block; color: var(--muted); font-size: 10.5px; text-align: right; margin-top: 2px; }
.wa-msgs .e { display: block; color: var(--danger); font-size: 11px; font-style: normal; }
.wa-note { padding: 8px 14px; background: #fff8e1; border-top: 1px solid var(--line); }
.wa-compose { display: flex; gap: 8px; padding: 10px; background: #f3f5f9; } .wa-compose textarea { flex: 1; resize: none; }
#err { padding: 0 14px; background: #f3f5f9; }
@media (max-width: 800px) { .wa { grid-template-columns: 1fr; } .wa-list { max-height: 35vh; } }
