/* CODesk UI — one stylesheet, no build step.
   Design tokens first; components keep the class names the server already
   emits, so the redesign changes no behaviour. Logical properties (inline-start
   / inline-end) are used where direction matters, so an Arabic RTL interface
   later is a dir="rtl" switch rather than a second stylesheet. */

:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e4e7ee;
  --line-strong: #cfd5e1;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-ink: #ffffff;
  --ok: #15803d;      --ok-soft: #dcfce7;
  --warn: #b45309;    --warn-soft: #fef3c7;
  --bad: #b91c1c;     --bad-soft: #fee2e2;
  --info: #0369a1;    --info-soft: #e0f2fe;
  --side-bg: #0f172a;
  --side-ink: #cbd5e1;
  --side-muted: #64748b;
  --side-hover: #1e293b;
  --side-on: #312e81;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .05);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .12);
  --side-w: 248px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1020; --surface: #121a2b; --surface-2: #0f1626; --ink: #e5e9f2; --ink-2: #c3cad8; --muted: #8b95a8;
    --line: #222c40; --line-strong: #2f3b55; --accent: #818cf8; --accent-hover: #a5b4fc; --accent-soft: #1e1b4b; --accent-ink: #0b1020;
    --ok: #4ade80; --ok-soft: #0f2e1d; --warn: #fbbf24; --warn-soft: #33270b; --bad: #f87171; --bad-soft: #3a1414;
    --info: #38bdf8; --info-soft: #0c2a3d; --side-bg: #070b16; --side-hover: #121a2b; --side-on: #1e1b4b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 10px 30px rgba(0, 0, 0, .5);
  }
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14.5px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; line-height: 1.25; margin: 0 0 1rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 1.8rem 0 .7rem; letter-spacing: -.005em; }
h3 { font-size: .95rem; margin: 1.2rem 0 .5rem; }
p { margin: .5rem 0; }
code, pre { font-family: var(--mono); font-size: .84em; background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; word-break: break-all; }
pre { padding: 12px; overflow-x: auto; white-space: pre-wrap; }
.muted { color: var(--muted); }
.error { color: var(--bad); font-weight: 600; }
.warn { color: var(--warn); font-weight: 500; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.brand-mark { width: 26px; height: 26px; padding: 4px; border-radius: 8px; background: var(--accent); fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; }

/* ------------------------------------------------------------------ app shell */
.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.sidebar {
  position: fixed; inset-block: 0; inset-inline-start: 0; width: var(--side-w); z-index: 40;
  background: var(--side-bg); color: var(--side-ink); display: flex; flex-direction: column;
  overflow-y: auto; padding: 14px 12px 20px;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 750; font-size: 1.08rem; padding: 4px 8px 14px; text-decoration: none; }
.workspace { display: flex; align-items: center; gap: 10px; padding: 9px 10px; margin: 0 0 12px; border: 1px solid #1e293b; border-radius: var(--radius-sm); background: rgba(255,255,255,.03); }
.ws-dot { width: 26px; height: 26px; border-radius: 7px; background: #334155; color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .8rem; flex: none; }
.ws-name { color: #e2e8f0; font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-group { margin-bottom: 10px; }
.nav-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--side-muted); padding: 10px 10px 4px; font-weight: 600; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--side-ink); font-weight: 500; font-size: .92rem; text-decoration: none; }
.nav-item:hover { background: var(--side-hover); color: #fff; text-decoration: none; }
.nav-item.on { background: var(--side-on); color: #fff; }
.nav-item.on .i { color: #a5b4fc; }
.nav-item span { flex: 1; }
.count { background: #4f46e5; color: #fff; font-size: .72rem; padding: 1px 7px; border-radius: 999px; font-weight: 700; }
.shell-main { min-height: 100vh; }
body.app .shell-main { margin-inline-start: var(--side-w); }
.topbar {
  position: sticky; top: 0; z-index: 30; height: 60px; display: flex; align-items: center; gap: 12px;
  padding: 0 28px; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
}
.tb-title { font-weight: 650; font-size: 1rem; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-right { display: flex; align-items: center; gap: 12px; }
.chip { font-size: .78rem; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; white-space: nowrap; }
.chip:hover { text-decoration: none; filter: brightness(.97); }
.chip-bad { background: var(--bad-soft); color: var(--bad); }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 8px; cursor: pointer; color: var(--ink-2); }
.icon-btn:hover { background: var(--surface-2); }
.menu-btn { display: none; }
.usermenu { position: relative; margin: 0; }
.usermenu > summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 6px; border-radius: 8px; color: var(--ink); }
.usermenu > summary::-webkit-details-marker { display: none; }
.usermenu > summary:hover { background: var(--surface-2); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .8rem; }
.um-name { font-weight: 550; font-size: .9rem; }
.um-pop { position: absolute; inset-inline-end: 0; top: calc(100% + 6px); min-width: 240px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; z-index: 50; }
.um-head { display: flex; flex-direction: column; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; font-size: .88rem; }
.menu-link { display: flex; gap: 8px; align-items: center; justify-content: flex-start; width: 100%; background: none; border: 0; color: var(--ink); padding: 8px 10px; border-radius: 6px; cursor: pointer; font: 500 .9rem var(--font); }
.menu-link:hover { background: var(--surface-2); }
.content { max-width: 1280px; margin: 0 auto; padding: 26px 28px 60px; }
.nav-scrim { display: none; }

@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  .nav-toggle:checked ~ .sidebar { transform: none; }
  .nav-toggle:checked ~ .nav-scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(15, 23, 42, .45); }
  body.app .shell-main { margin-inline-start: 0; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 0 12px; }
  .content { padding: 18px 16px 48px; }
  .um-name, .chip { display: none; }
}

/* ------------------------------------------------------------------ page header, flash */
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.head h1 { margin: 0; }
.flash { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-inline-start: 4px solid var(--accent); border-radius: var(--radius); padding: 11px 14px; margin-bottom: 18px; box-shadow: var(--shadow); font-weight: 500; animation: flash-in .25s ease; }
@keyframes flash-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .flash { animation: none; } .sidebar { transition: none; } }

/* ------------------------------------------------------------------ buttons */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: var(--accent-ink); border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 8px 14px; font: 600 .88rem/1.2 var(--font); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .12s, box-shadow .12s, transform .05s;
}
button:hover, .btn:hover { background: var(--accent-hover); text-decoration: none; }
button:active, .btn:active { transform: translateY(1px); }
button.secondary, form.secondary button { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
button.secondary:hover, form.secondary button:hover { background: var(--surface-2); }
button.link { background: none; color: var(--accent); padding: 0; border: 0; font-weight: 500; }
.btn.big { padding: 12px 22px; font-size: 1rem; border-radius: 9px; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.wa { background: #16a34a; color: #fff; }
.btn.wa:hover { background: #15803d; }

/* ------------------------------------------------------------------ forms */
form { margin: 0; }
form.inline { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-block: 2px; margin-inline: 0 4px; }
form.inline .field { min-width: 0; margin: 0; }
input, select, textarea {
  font: inherit; font-size: .9rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); padding: 8px 10px; max-width: 100%; min-height: 38px; transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
input[type="checkbox"], input[type="radio"] { min-height: 0; width: 16px; height: 16px; accent-color: var(--accent); }
textarea { width: 100%; min-height: 84px; resize: vertical; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; flex: 1; min-width: 170px; }
.field > span { font-size: .8rem; color: var(--ink-2); font-weight: 600; }
.field input, .field select { width: 100%; }
.chk { display: inline-flex; gap: 7px; align-items: center; margin-block: 3px; margin-inline: 0 14px; font-size: .9rem; cursor: pointer; }
.cols { display: flex; flex-wrap: wrap; gap: 0 14px; align-items: flex-end; }
.cols2 { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 22px; align-items: start; }
@media (max-width: 900px) { .cols2 { grid-template-columns: 1fr; } }
main > form:not(.inline):not(.filters):not(.bulk):not(.outcomes),
.card > form:not(.inline), details > form:not(.inline) {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 18px 16px; box-shadow: var(--shadow); margin-bottom: 14px;
}
.card > form:not(.inline), details > form:not(.inline) { box-shadow: none; background: var(--surface-2); }
.usermenu form { background: none !important; border: 0 !important; padding: 0 !important; box-shadow: none !important; margin: 0 !important; }

/* toolbars */
.filters, .bulk {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin: 0 0 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; box-shadow: var(--shadow);
}
.filters .field { margin: 0; min-width: 150px; flex: 0 1 auto; }
.filters input[name="q"] { min-width: min(260px, 100%); flex: 1 1 220px; }
.filters .chk { margin-bottom: 9px; }
.bulk { background: var(--surface-2); box-shadow: none; align-items: center; }
.bulk > span { font-weight: 600; font-size: .85rem; color: var(--muted); margin-inline-end: 4px; }

/* ------------------------------------------------------------------ cards, tables */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin: 0 0 14px; box-shadow: var(--shadow); }
.card > h2:first-child { margin-top: 0; }
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; margin: 0 0 16px; }
table.grid { width: 100%; border-collapse: collapse; font-size: .89rem; }
.grid th, .grid td { text-align: start; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.grid thead th { background: var(--surface-2); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; white-space: nowrap; }
.grid tbody tr:last-child > * { border-bottom: 0; }
.grid tbody tr:hover > td { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.grid tbody th { font-size: .92rem; color: var(--ink); font-weight: 700; background: var(--surface-2); }
.grid.small td { font-size: .8rem; }
.grid.small code { font-size: .74rem; }
.grid tr.low td { background: var(--bad-soft); }
.grid td form.inline select, .grid td form.inline input { min-height: 32px; padding: 5px 8px; font-size: .84rem; }
.grid td form.inline button { padding: 6px 10px; font-size: .8rem; }
.card .table-wrap { box-shadow: none; }

/* badges */
.badge { display: inline-flex; align-items: center; font-size: .74rem; font-weight: 650; padding: 2px 9px; border-radius: 999px; white-space: nowrap; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.b-pending { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.b-confirmed { background: var(--info-soft); color: var(--info); border-color: transparent; }
.b-shipped { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.b-delivered { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.b-cancelled, .b-returned { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.b-duplicate { background: var(--surface-2); color: var(--muted); }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 4px 0 18px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 16px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 3px; background: var(--accent); opacity: .7; }
.kpi .v { font-size: 1.55rem; font-weight: 750; letter-spacing: -.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: .8rem; font-weight: 550; margin-top: 2px; }

/* alerts list */
.alerts { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; }
.alerts li { background: var(--surface); border: 1px solid var(--line); border-inline-start: 4px solid var(--info); border-radius: var(--radius-sm); padding: 10px 14px; box-shadow: var(--shadow); }
.alert.a-stock, .alert.a-lost, .alert.a-billing { border-inline-start-color: var(--bad); }
.alert.a-callback, .alert.a-unassigned, .alert.a-validation { border-inline-start-color: var(--warn); }

/* tabs */
.tabs { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; margin: 0 0 14px; }
.tabs a { padding: 6px 12px; border-radius: 6px; color: var(--ink-2); font-weight: 550; font-size: .87rem; }
.tabs a:hover { background: var(--surface-2); text-decoration: none; }
.tabs a.on { background: var(--accent); color: var(--accent-ink); }

/* details / disclosure */
details { margin: 8px 0; }
details > summary { cursor: pointer; font-weight: 600; color: var(--accent); padding: 6px 0; }
details[open] > summary { margin-bottom: 8px; }

/* ------------------------------------------------------------------ call screens */
.callcard { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px 22px; margin-bottom: 14px; box-shadow: var(--shadow); }
.callcard .phone { font-size: 1.9rem; font-weight: 750; margin: 0 0 6px; letter-spacing: .01em; font-variant-numeric: tabular-nums; }
.callcard .phone a { color: var(--ink); }
.callcard ul { padding-inline-start: 20px; }
.callcard .total { font-size: 1.2rem; font-weight: 750; }
.risk { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); margin: 10px 0; font-size: .9rem; }
.risk.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; font-weight: 600; }
form.outcomes { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; box-shadow: var(--shadow); margin-bottom: 14px; }
.outcomes .obtns { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; margin-top: 4px; }
.outcomes .obtns button { padding: 12px; font-size: .9rem; white-space: normal; text-align: center; min-height: 48px; color: #fff; }
.o-confirmed, .tc-ok, .tc-waiting { background: #16a34a; }
.o-confirmed:hover, .tc-ok:hover, .tc-waiting:hover { background: #15803d; }
.o-failed_attempt, .o-postponed, .o-scheduled, .tc-no_response, .tc-closed, .tc-busy, .tc-postponed, .tc-traveling, .tc-sms_sent { background: #d97706; }
.o-failed_attempt:hover, .o-postponed:hover, .o-scheduled:hover, .tc-no_response:hover, .tc-closed:hover, .tc-busy:hover,
.tc-postponed:hover, .tc-traveling:hover, .tc-sms_sent:hover { background: #b45309; }
.o-cancelled, .o-wrong_number, .o-invalid_order, .tc-wrong_number, .tc-fake_order, .tc-not_serious, .tc-bought_elsewhere, .tc-cancelled { background: #dc2626; }
.o-cancelled:hover, .o-wrong_number:hover, .o-invalid_order:hover, .tc-wrong_number:hover, .tc-fake_order:hover,
.tc-not_serious:hover, .tc-bought_elsewhere:hover, .tc-cancelled:hover { background: #b91c1c; }
.o-message_sent, .o-duplicate { background: #475569; }
.o-message_sent:hover, .o-duplicate:hover { background: #334155; }
.audit { font-size: .82rem; color: var(--muted); padding-inline-start: 18px; }

/* ------------------------------------------------------------------ plans, routing, labels */
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin: 12px 0 20px; }
.plan { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; }
.plan h3 { margin: 0; font-size: 1rem; }
.plan .price { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; }
.plan p { margin: 0; color: var(--ink-2); }
.plan .btn, .plan form { margin-top: auto; }
.plan form { background: none !important; border: 0 !important; box-shadow: none !important; padding: 8px 0 0 !important; }
.plan form button { width: 100%; }
.routing { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0 12px; }
.labels { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.label { border: 1.5px dashed #000; padding: 12px; background: #fff; color: #000; break-inside: avoid; font-size: 13px; border-radius: 6px; }
.label .lh { display: flex; justify-content: space-between; }
.label .trk { font: 700 20px var(--mono); margin: 6px 0; }
.label .cod { font-size: 18px; font-weight: 800; }
.noprint { margin-bottom: 14px; }
@media (max-width: 640px) { .labels { grid-template-columns: 1fr; } }
@media print {
  .sidebar, .topbar, .noprint, .flash, .nav-scrim { display: none !important; }
  body.app .shell-main { margin: 0; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; }
  .label { page-break-inside: avoid; }
}

/* ------------------------------------------------------------------ public site */
.pub-header { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.pub-inner { max-width: 1160px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; flex-wrap: wrap; }
.pub-header .brand, .auth-brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 800; font-size: 1.1rem; text-decoration: none; }
.pub-nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.pub-nav a:not(.btn) { color: var(--ink-2); font-weight: 550; }
body.public .content { max-width: 1160px; padding: 0 20px 70px; }
.pub-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; }
.pub-footer .pub-inner { min-height: 72px; }
@media (max-width: 560px) { .pub-nav a:not(.btn):not([href="/login"]) { display: none; } }
.hero { display: grid; grid-template-columns: 1.1fr .9fr; gap: 48px; align-items: center; padding: 72px 0 56px; }
.hero h1 { font-size: clamp(2rem, 4.2vw, 3.1rem); line-height: 1.1; letter-spacing: -.03em; margin-bottom: 18px; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero .lead { font-size: 1.12rem; color: var(--ink-2); max-width: 560px; margin-bottom: 26px; }
.hero .cta-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.hero .fine { font-size: .85rem; color: var(--muted); margin-top: 14px; }
.eyebrow { display: inline-block; font-size: .78rem; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 4px 10px; border-radius: 999px; margin-bottom: 16px; letter-spacing: .02em; }
.mock { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 18px; }
.mock-head { display: flex; gap: 6px; margin-bottom: 14px; }
.mock-head i { width: 10px; height: 10px; border-radius: 50%; background: var(--line-strong); }
.mock-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.mock-kpis div { background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 10px; }
.mock-kpis b { display: block; font-size: 1.2rem; }
.mock-kpis span { font-size: .72rem; color: var(--muted); }
.mock-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 4px; border-bottom: 1px solid var(--line); font-size: .85rem; }
.mock-row:last-child { border-bottom: 0; }
.section { padding: 56px 0 8px; }
.section > h2 { font-size: 1.7rem; text-align: center; margin: 0 0 8px; letter-spacing: -.02em; }
.section > .sub { text-align: center; color: var(--muted); max-width: 640px; margin: 0 auto 30px; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; counter-reset: step; }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; box-shadow: var(--shadow); }
.step::before { counter-increment: step; content: counter(step); display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 800; margin-bottom: 10px; }
.step h3 { margin: 0 0 4px; }
.step p { margin: 0; color: var(--muted); font-size: .9rem; }
.features { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.feat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; box-shadow: var(--shadow); }
.feat .i { width: 34px; height: 34px; padding: 7px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); margin-bottom: 10px; }
.feat h3 { margin: 0 0 6px; font-size: 1rem; }
.feat p { margin: 0; color: var(--muted); font-size: .9rem; }
.cta-band { margin-top: 56px; background: linear-gradient(135deg, #4f46e5, #7c3aed); color: #fff; border-radius: 18px; padding: 36px; display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; }
.cta-band h2 { margin: 0; font-size: 1.5rem; color: #fff; }
.cta-band p { margin: 6px 0 0; opacity: .85; }
.cta-band .btn { background: #fff; color: #312e81; }
.cta-band .btn:hover { background: #eef2ff; }
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; padding: 40px 0 24px; gap: 28px; } }

/* auth */
body.auth .content { max-width: none; padding: 0; }
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side { background: linear-gradient(160deg, #1e1b4b, #4f46e5 70%, #7c3aed); color: #e0e7ff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; }
.auth-side .auth-brand { color: #fff; }
.auth-side h2 { color: #fff; font-size: 1.9rem; line-height: 1.2; letter-spacing: -.02em; margin: 0 0 16px; }
.auth-side ul { padding: 0; list-style: none; display: grid; gap: 12px; margin: 0; }
.auth-side li { display: flex; gap: 10px; align-items: center; }
.auth-side li .i { color: #c7d2fe; }
.auth-main { display: grid; place-items: center; padding: 32px 20px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .auth-brand { margin-bottom: 28px; }
.auth-card h1 { font-size: 1.6rem; margin-bottom: 4px; }
.auth-card .sub { color: var(--muted); margin: 0 0 22px; }
.auth-card form { background: transparent !important; border: 0 !important; box-shadow: none !important; padding: 0 !important; }
.auth-card button[type="submit"] { width: 100%; padding: 11px; font-size: .95rem; margin-top: 6px; }
.auth-card .alt { text-align: center; margin-top: 18px; color: var(--muted); }
.auth-card .error { background: var(--bad-soft); padding: 10px 12px; border-radius: var(--radius-sm); font-weight: 500; }
@media (max-width: 860px) { .auth-wrap { grid-template-columns: 1fr; } .auth-side { display: none; } }
@media (min-width: 861px) { .auth-card .auth-brand { display: none; } }

.narrow { max-width: 420px; margin: 40px auto; }

/* breadcrumb, empty states, misc */
.crumb { color: var(--muted); font-weight: 500; }
.crumb-sep { color: var(--line-strong); margin: 0 8px; }
@media (max-width: 960px) { .crumb, .crumb-sep { display: none; } }
.empty { text-align: center; background: var(--surface); border: 1px dashed var(--line-strong); border-radius: 14px; padding: 48px 20px; margin: 10px 0 20px; }
.empty .i { width: 44px; height: 44px; padding: 10px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); }
.empty h2 { margin: 12px 0 4px; }
.empty p { color: var(--muted); margin: 0 auto 16px; max-width: 420px; }
.alert.a-ok { border-inline-start-color: var(--ok); }
.head p.muted { margin: 2px 0 0; }
.head .btn .i, .btn .i { width: 16px; height: 16px; }
body.auth .pub-header { display: none; }
bdi { unicode-bidi: isolate; }


/* ------------------------------------------------------------------ language switcher */
.lang-switch { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); margin: 0; }
.lang-switch button { background: transparent; color: var(--ink-2); border: 0; padding: 4px 9px; font-size: .78rem; font-weight: 600; border-radius: 6px; }
.lang-switch button:hover { background: var(--surface-2); }
.lang-switch button.on { background: var(--accent); color: var(--accent-ink); }
.lang-switch.block { display: flex; width: 100%; }
.lang-switch.block button { flex: 1; padding: 6px 4px; }
.um-section { padding: 6px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.um-label { display: block; font-size: .72rem; color: var(--muted); font-weight: 600; margin-bottom: 5px; }
.usermenu .lang-switch { background: var(--surface-2); }
.auth-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 28px; }
.auth-card .auth-top .auth-brand { margin: 0; }
@media (min-width: 861px) { .auth-card .auth-top { justify-content: flex-end; } }

/* ------------------------------------------------------------------ small widths (no inline styles: CSP) */
.w-xs { width: 5.5em; }
.w-sm { width: 8em; }

/* ------------------------------------------------------------------ Arabic / right-to-left */
html[lang="ar"] body {
  font-family: "Noto Sans Arabic", "SF Arabic", "Segoe UI", "Geeza Pro", Tahoma, system-ui, sans-serif;
  font-size: 15.5px; line-height: 1.7;
}
/* Letter-spacing breaks Arabic letter joining; uppercase has no meaning in Arabic. */
html[lang="ar"] * { letter-spacing: 0 !important; }
html[lang="ar"] .grid thead th, html[lang="ar"] .nav-label { text-transform: none; font-size: .78rem; }
html[lang="ar"] .hero h1 { line-height: 1.35; }
html[lang="ar"] .kpi .v, html[lang="ar"] .plan .price { font-family: var(--font); }
/* Values typed left-to-right (phones, amounts, dates, codes) stay LTR but line up with RTL labels. */
[dir="rtl"] input[dir="ltr"], [dir="rtl"] textarea[dir="ltr"] { text-align: right; }
[dir="rtl"] select[dir="ltr"] { direction: ltr; }
/* Direction-aware icons (logout arrow) mirror in RTL. */
[dir="rtl"] .flip { transform: scaleX(-1); }
[dir="rtl"] .chip, [dir="rtl"] .count { direction: rtl; }
[dir="rtl"] .label { direction: rtl; }
bdi[dir="ltr"] { unicode-bidi: isolate; direction: ltr; }

/* ------------------------------------------------------------------ list pages: tabs, toolbars, switches */
.pagetabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; border-bottom: 1px solid var(--line); }
.pagetabs a { padding: 10px 14px; color: var(--ink-2); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none; }
.pagetabs a:hover { color: var(--ink); }
.pagetabs a.on { color: var(--accent); border-bottom-color: var(--accent); }
.tcount { display: inline-block; min-width: 20px; padding: 0 6px; margin-inline-start: 4px; border-radius: 999px; background: var(--surface-2);
          border: 1px solid var(--line); font-size: .72rem; color: var(--muted); text-align: center; }
.on > .tcount, .seg.on .tcount { background: rgba(255,255,255,.2); border-color: transparent; color: inherit; }
.listbar { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; flex-wrap: wrap; }
.listbar .search { flex: 0 1 340px; }
.listbar .search input { width: 100%; padding-inline-start: 34px; background: var(--surface) no-repeat 10px 50% / 16px
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E"); }
[dir="rtl"] .listbar .search input { background-position: calc(100% - 10px) 50%; }
.fab { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: #fff; box-shadow: var(--shadow); }
.fab:hover { background: var(--accent-hover); text-decoration: none; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 10px; }
.toolbar .filters { margin: 0; }
.segs { display: inline-flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.segs.inline { display: inline-flex; }
.seg { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--surface);
       color: var(--ink-2); font-weight: 600; font-size: .84rem; cursor: pointer; text-decoration: none; list-style: none; }
.seg:hover { background: var(--surface-2); text-decoration: none; }
.seg.on, .range-custom.on > summary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
summary.seg::-webkit-details-marker, .range-custom > summary::-webkit-details-marker { display: none; }
.range-custom, .colset { position: relative; margin: 0; }
.range-custom > summary { list-style: none; display: inline-grid; place-items: center; width: 34px; height: 33px; border: 1px solid var(--line-strong);
                          border-radius: 7px; background: var(--surface); color: var(--ink-2); cursor: pointer; }
.range-custom > form, .colset .pop { position: absolute; z-index: 20; top: calc(100% + 6px); inset-inline-start: 0; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 12px; min-width: 260px; }
.colset .pop { display: flex; flex-direction: column; gap: 6px; }
.colset .pop form { background: none !important; border: 0 !important; box-shadow: none !important; padding: 0 !important; }
.hidden-form { display: none; }
.hidden-form:has(noscript) { display: contents; }
.sel-count { font-size: .85rem; color: var(--muted); margin-inline-end: 6px; }
.sel-count b { color: var(--ink); }
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 8px 0 20px; font-size: .85rem; }
.pager .muted { margin-inline-start: auto; display: inline-flex; gap: 6px; align-items: center; }

.switch { position: relative; width: 58px; height: 28px; padding: 0 8px; border-radius: 999px; background: var(--bad); color: #fff;
          font-size: .7rem; font-weight: 700; justify-content: flex-end; border: 0; }
.switch::before { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff;
                  transition: inset-inline-start .15s; }
.switch.on { background: var(--ok); justify-content: flex-start; }
.switch.on::before { inset-inline-start: 33px; }
.switch:hover { filter: brightness(.95); background: var(--bad); }
.switch.on:hover { background: var(--ok); }
@media (prefers-reduced-motion: reduce) { .switch::before { transition: none; } }

/* ------------------------------------------------------------------ dense tables, status rows, in-row editing */
.grid.dense th, .grid.dense td { padding: 7px 9px; }
.grid.dense { font-size: .85rem; }
.grid thead select.hsel { min-height: 30px; padding: 3px 6px; font-size: .74rem; font-weight: 650; text-transform: none; letter-spacing: 0;
                          background: var(--surface); color: var(--ink-2); max-width: 150px; }
.grid thead select.hsel:not([value=""]):has(option:checked:not([value=""])) { border-color: var(--accent); color: var(--accent); }
.cell-form { display: inline-flex; gap: 4px; margin: 0; }
select.pill { min-height: 30px; padding: 3px 8px; border-radius: 999px; font-size: .8rem; font-weight: 600; max-width: 170px; }
select.pill.st { background: var(--surface); }
tr.st-pending > td { background: color-mix(in srgb, var(--info) 6%, transparent); }
tr.st-failed > td { background: color-mix(in srgb, var(--warn) 13%, transparent); }
tr.st-duplicate > td, tr.st-frozen > td, tr.st-off > td { background: color-mix(in srgb, var(--muted) 12%, transparent); }
tr.st-off > td { opacity: .75; }
tr.st-cancelled > td, tr.st-returned > td { background: color-mix(in srgb, var(--bad) 10%, transparent); }
tr.st-confirmed > td { background: color-mix(in srgb, var(--accent) 7%, transparent); }
tr.st-shipped > td { background: color-mix(in srgb, var(--accent) 4%, transparent); }
tr.st-delivered > td { background: color-mix(in srgb, var(--ok) 9%, transparent); }
.grid tbody tr[class^="st-"]:hover > td { filter: brightness(.98); }
.chk-badge { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 999px; overflow: hidden; font-size: .78rem; }
.chk-badge b { padding: 1px 8px; }
.chk-badge .ok { background: var(--ok-soft); color: var(--ok); }
.chk-badge .ko { background: var(--surface); color: var(--muted); }
.chk-badge.risky .ko { background: var(--bad-soft); color: var(--bad); }
.note-dot { display: inline-grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; background: var(--ink-2); color: var(--surface);
            font-size: .68rem; font-weight: 800; cursor: help; vertical-align: middle; }
.wa-dot { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #16a34a; color: #fff; vertical-align: middle; }
.wa-dot .i { width: 13px; height: 13px; }
td.actions { white-space: nowrap; }
td.actions .icon-btn { width: 32px; height: 32px; }
.trk-cell { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; padding: 2px 4px 2px 10px; background: var(--surface); }
[dir="rtl"] .trk-cell { padding: 2px 10px 2px 4px; }
.trk-cell .dt { font-size: .68rem; font-weight: 800; padding: 1px 6px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
button.copy { background: transparent; color: var(--muted); border: 0; padding: 2px; min-height: 0; }
button.copy:hover { background: transparent; color: var(--accent); }
button.copy.copied, .seg.copy.copied { color: var(--ok); }
.copy .i { width: 15px; height: 15px; }

/* ------------------------------------------------------------------ statistics */
.statfilters .field { min-width: 170px; }
.income { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi.big .v { font-size: 1.8rem; }
.kpi.big p { margin: 6px 0 0; font-size: .8rem; }
.kpi.c-a::before { background: var(--accent); } .kpi.c-b::before { background: var(--ok); }
.kpi.c-c::before { background: var(--bad); } .kpi.c-n::before { background: var(--info); }
.chart { margin: 0 0 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.chart svg { width: 100%; height: auto; display: block; }
.chart .bar-a { fill: var(--accent); } .chart .bar-b { fill: var(--ok); } .chart .bar-c { fill: var(--bad); }
.chart .axis { fill: var(--muted); font-size: 10px; }
.chart .axis-line { stroke: var(--line-strong); }
.chart figcaption { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; font-size: .8rem; color: var(--muted); margin-top: 6px; }
.lg { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.lg.a { background: var(--accent); } .lg.b { background: var(--ok); } .lg.c { background: var(--bad); }
.top5s { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.top5 h3 { margin-top: 0; }
.top5 ol { margin: 0; padding-inline-start: 20px; display: grid; gap: 6px; }
.top5 li { display: flex; gap: 8px; align-items: baseline; }
.top5 li span:first-child { flex: 1; }
.top5 li .muted { font-size: .78rem; }

/* ------------------------------------------------------------------ settings, sheets */
.pw { display: flex; gap: 4px; align-items: center; }
.pw input { flex: 1; }
.codebox { position: relative; }
.codebox .copy { position: absolute; top: 8px; inset-inline-end: 8px; }
.codebox pre { max-height: 420px; overflow: auto; padding-top: 40px; }
.steps-list { padding-inline-start: 20px; display: grid; gap: 6px; }
.pricegrid input { width: 8em; }

/* fixes from browser review */
.grid.dense td { white-space: nowrap; }
.grid.dense td.wrap { white-space: normal; min-width: 120px; }
select.pill { min-width: 110px; max-width: 200px; }
.pw .reveal { background: transparent; color: var(--muted); border: 1px solid var(--line-strong); width: 38px; height: 38px; padding: 0; }
.pw .reveal:hover { background: var(--surface-2); color: var(--ink); }
.seg.copy .i { width: 14px; height: 14px; }

/* uncertain carrier upload */
.card.warn-card { border-inline-start: 4px solid var(--warn, #d97706); padding: 14px 16px; margin: 12px 0; }
.card.warn-card form { display: flex; gap: 8px; flex-wrap: wrap; }
.card.warn-card input[name="tracking"] { min-width: 260px; }
.pricegrid td.prefilled input { background: var(--warn-bg, #fff7e6); border-color: var(--warn, #d97706); }

/* notification centre */
.icon-btn.bell { position: relative; }
.icon-btn.bell .count { position: absolute; top: -4px; inset-inline-end: -4px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--danger, #dc2626); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.notif-list { list-style: none; margin: 0; padding: 0; background: var(--surface, #fff); border: 1px solid var(--line, #e5e7eb); border-radius: 12px; }
.notif-list li { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-bottom: 1px solid var(--line, #e5e7eb); }
.notif-list li:last-child { border-bottom: 0; }
.notif-list li div { display: flex; flex-direction: column; gap: 2px; }
.notif-list .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex: none; background: transparent; }
.notif-list li.unread .dot { background: var(--accent, #4f46e5); }
.notif-list li.unread a { font-weight: 600; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

/* multi-row order entry */
.table-scroll { overflow-x: auto; margin-bottom: 12px; }
.ordergrid td { padding: 4px 6px; vertical-align: top; }
.ordergrid input, .ordergrid select { min-width: 90px; padding: 6px 8px; font-size: 13px; }
.ordergrid input[name="full_name"], .ordergrid input[name="address"] { min-width: 150px; }
.ordergrid td:last-child { min-width: 140px; white-space: normal; }
img.thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line, #e5e7eb); vertical-align: middle; }
.thumb-row { display: flex; align-items: center; gap: 12px; }
.card.danger-zone { border: 1px solid var(--danger, #dc2626); margin-top: 24px; }
.card.danger-zone h2 { color: var(--danger, #dc2626); }
form.danger button[type="submit"] { background: var(--danger, #dc2626); }

/* onboarding checklist */
.card.onboarding { margin-bottom: 20px; }
.onboarding progress { -webkit-appearance: none; appearance: none; width: 100%; height: 8px; border: 0; border-radius: 4px;
  background: var(--surface-2, #eef0f4); overflow: hidden; }
.onboarding progress::-webkit-progress-bar { background: var(--surface-2, #eef0f4); border-radius: 4px; }
.onboarding progress::-webkit-progress-value { background: var(--accent, #4f46e5); border-radius: 4px; }
.onboarding progress::-moz-progress-bar { background: var(--accent, #4f46e5); border-radius: 4px; }
.onboarding ol { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 10px; }
.onboarding li { display: flex; gap: 12px; align-items: flex-start; }
.onboarding li div { display: flex; flex-direction: column; }
.onboarding .tick { width: 22px; height: 22px; flex: none; border-radius: 50%; border: 2px solid var(--line-strong, #cbd5e1);
  display: inline-flex; align-items: center; justify-content: center; }
.onboarding li.done .tick { background: var(--ok, #16a34a); border-color: var(--ok, #16a34a); color: #fff; }
.onboarding li.done .tick .i { width: 14px; height: 14px; }
.onboarding li.done b { text-decoration: line-through; color: var(--muted, #64748b); }
