/* ============================================================
   base-tokens.css — house design tokens + the handful of base components
   (buttons, surface, table, tag, modal, banners) every page and the DataTable
   skin build on. Extracted from the reference project's admin.css (RoboPager: web-font import removed, see below).
   Rules: use the SEMANTIC tokens (--primary, --text-main, --border, --card-bg…);
   the short aliases (--ink, --line, --ember…) exist for legacy components.
   Dark mode = html.dark (token overrides only). RTL = [dir="rtl"] + logical props.
   Tablet-first (1180×820). Load this FIRST, before any page/feature CSS.
   ============================================================ */
/* Brand fonts are vendored (CSP font-src 'self'): Inter (body) and Space Grotesk (headings), Latin subset, variable weight.
   Arabic falls back to the system Arabic stacks below. Licences: /resources/vendor/fonts/*-LICENSE.txt (SIL OFL). */
@font-face{ font-family:'Inter'; font-style:normal; font-weight:100 900; font-display:swap; src:url('/resources/vendor/fonts/inter-latin-var-260c81a4759baf163c025001c4f27872.woff2') format('woff2'); }
@font-face{ font-family:'Space Grotesk'; font-style:normal; font-weight:300 700; font-display:swap; src:url('/resources/vendor/fonts/space-grotesk-latin-var-87c506d88b9f587f0e2292bc271f5083.woff2') format('woff2'); }

:root{
  /* Notch palette (from the RoboPager design): Bone canvas, Ink text and sidebar, Ping accent. Ink text sits ON Ping (white fails contrast). */
  --primary:#FF4B1F;
  --on-primary:#151515;
  --primary-text:#B93412;
  --primary-hover:#E8420F;
  --primary-active:#CC380A;
  --primary-rgb:255, 75, 31;
  --primary-soft:#FFE6DE;
  --accent-pink:#B7A8FF;
  --accent-pink-soft:#ECE6FF;
  --accent-yellow:#FFB020;
  --accent-yellow-soft:#FFF0CF;
  --bg-soft:#ECE8DE;
  --bg-blue-soft:#E4DFFF;
  --page-gradient-start:#F4F1EA;
  --page-gradient-mid:#F4F1EA;
  --page-gradient-end:#F4F1EA;
  --page-gradient:none;
  --text-main:#151515;
  --text-muted:#5F5B54;
  --text-subtle:#6A665F;
  --border:#D8D3C8;
  --border-soft:#ECE8DE;
  --card-bg:#FFFFFF;
  --sidebar-bg:#151515;
  --header-bg:rgba(244,241,234,.92);
  --input-bg:#FFFFFF;
  --secondary-action-bg:#ECE8DE;
  --secondary-action-hover:#E1DCCF;
  --focus-ring:rgba(var(--primary-rgb),.40);
  --signal:#FF4B1F; --ink-nav:#151515; --ink-nav-2:#2B2B2B;
  --disabled-bg:#ECE8DE;
  --disabled-text:#8A857C;
  --danger:#C8455B;
  --danger-soft:#F8DEE2;
  --success:#1F8A6D;
  --success-soft:#D9F3E8;
  --warning:#7A4E00;
  --warning-soft:#FFF0CF;
  /* Stage colours shared with the mobile app and the orders board. */
  --stage-received:#CFC9BC; --stage-preparing:#FFB020; --stage-wrapping:#B7A8FF; --stage-ready:#FF4B1F; --stage-online:#2BC48A;

  /* Backwards-compatible aliases consumed by existing portal components. */
  --ink:var(--text-main); --ink-2:var(--text-muted); --ink-3:var(--text-subtle); --ink-4:#8A857C;
  --line:var(--border); --line-2:var(--border-soft); --line-3:#F3F0E8;
  --paper:#F4F1EA; --paper-2:var(--bg-soft); --paper-3:#E1DCCF; --card:var(--card-bg);
  --ember:var(--primary); --ember-deep:var(--primary-text); --ember-soft:var(--primary-soft);
  --gold:#FFB020; --gold-deep:#7A4E00; --gold-soft:var(--accent-yellow-soft);
  --plum:#202020; --plum-2:#2B2B2B;
  --teal:#1F8A6D; --teal-soft:#D9F3E8; --teal-ink:#17705A; --sky-ink:#4B38B5;
  --sky:#5B47C9; --sky-soft:#E9E4FF;
  --rose:var(--danger); --rose-soft:var(--danger-soft);
  --violet:#7A66E0; --violet-soft:#E9E4FF;
  /* density-driven (changed by .density-compact/.density-spacious) */
  --pad-y:16px; --pad-x:18px;
  --row-h:48px;
  --gap:14px;
  /* radius / elevation */
  --r-sm:10px; --r-md:14px; --r-lg:20px; --r-xl:28px;
  --shadow-1:0 1px 2px rgba(21,21,21,.06), 0 1px 1px rgba(21,21,21,.03);
  --shadow-2:0 4px 14px rgba(21,21,21,.08), 0 12px 34px rgba(21,21,21,.06);
  --shadow-3:0 10px 30px rgba(21,21,21,.14), 0 30px 70px rgba(21,21,21,.12);
  --font-disp:'Space Grotesk', ui-rounded, 'Segoe UI', system-ui, -apple-system, 'Geeza Pro', Tahoma, 'Noto Sans Arabic', sans-serif;
  --font-text:'Inter', system-ui, -apple-system, 'Segoe UI', 'Geeza Pro', Tahoma, 'Noto Sans Arabic', Roboto, sans-serif;
}

/* density vars — actually consumed by .adm-body/.surface/.kpi-card/.tbl below */
.density-compact { --pad-y:10px; --pad-x:12px; --row-h:36px; --gap:10px; --surf-pad:13px; --row-pad-y:9px; --kpi-val:24px; --body-pad:14px; }
.density-cozy    { --pad-y:14px; --pad-x:18px; --row-h:48px; --gap:14px; --surf-pad:20px; --row-pad-y:12px; --kpi-val:32px; --body-pad:32px; }
.density-spacious{ --pad-y:20px; --pad-x:24px; --row-h:60px; --gap:20px; --surf-pad:24px; --row-pad-y:16px; --kpi-val:36px; --body-pad:28px; }


/* ===== dark mode (token overrides) ===== */
html.dark,
.dark-admin{
  --paper:#151515; --paper-2:#202020; --paper-3:#2B2B2B; --card:#202020;
  --text-main:#F4F1EA; --text-muted:#A8A39A; --text-subtle:#A8A39A;
  --ink:var(--text-main); --ink-2:var(--text-muted); --ink-3:var(--text-subtle); --ink-4:#8A857C;
  --primary-text:#FF7A57;
  --line:#2B2B2B; --line-2:#242424; --line-3:#202020;
  --ember-soft:rgba(var(--primary-rgb),.18); --gold-soft:rgba(255,176,32,.16); --accent-yellow-soft:rgba(255,176,32,.16);
  --teal-soft:rgba(43,196,138,.16); --sky-soft:rgba(183,168,255,.16);
  --rose-soft:rgba(200,69,91,.16); --violet-soft:rgba(183,168,255,.16);
  /* Tag text on the translucent dark tints (kept at 4.5:1 or better). */
  --gold-deep:#FFC75A; --sky:#B7A8FF; --rose:#F08A9B; --teal-ink:#2BC48A; --sky-ink:#B7A8FF; --violet:#B7A8FF;
}

/* ===== base ===== */
*,*::before,*::after{ box-sizing:border-box; }
body{ margin:0; font-family:var(--font-text); color:var(--ink); background:var(--paper); -webkit-font-smoothing:antialiased; }

.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px; min-height:38px;
  padding:8px 14px; border-radius:10px; font-family:var(--font-text); font-weight:700; font-size:13.5px; line-height:1.2;
  border:1px solid var(--border); background:var(--card-bg); color:var(--text-main); cursor:pointer; text-decoration:none;
  white-space:nowrap; flex:none; box-shadow:var(--shadow-1);
  transition:background .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease, transform .16s cubic-bezier(.22,1,.36,1);
}
.btn:hover{ background:var(--secondary-action-hover); border-color:var(--ink-4);}
.btn:active{ background:var(--secondary-action-hover); transform:translateY(1px); box-shadow:none;}
.btn:focus-visible{ outline:3px solid var(--focus-ring); outline-offset:2px;}
.btn.primary{ background:var(--primary); color:var(--on-primary); border-color:var(--primary); box-shadow:0 1px 2px rgba(var(--primary-rgb),.4), 0 6px 14px -4px rgba(var(--primary-rgb),.45);}
.btn.primary:hover{ background:var(--primary-hover); border-color:var(--primary-hover);}
.btn.primary:active{ background:var(--primary-active); border-color:var(--primary-active);}
.btn:disabled, .btn[disabled], .bigbtn:disabled, .bigbtn[disabled]{ background:var(--disabled-bg); border-color:var(--border); color:var(--disabled-text); box-shadow:none; cursor:not-allowed; opacity:.72;}
.btn.dark{ background:var(--ink); color:var(--paper); border-color:var(--ink);}
.btn.gold{ background:var(--gold); color:#151515; border-color:var(--gold);}
/* Used by RCUI.confirm for destructive actions. */
.btn.danger{ background:var(--danger); color:#fff; border-color:var(--danger); box-shadow:0 6px 14px rgba(200,69,91,.22);}
.btn.danger:hover{ background:#B13A4E; border-color:#B13A4E;}
.btn.lg{ padding:12px 20px; min-height:48px; font-size:15px; border-radius:12px;}
/* .sm was already used by Home's QR row and the readiness steps but had no rule,
   so those buttons rendered at full size. Defined once here rather than per page. */
.btn.sm{ padding:5px 11px; min-height:32px; font-size:12.5px; border-radius:8px; gap:6px;}
.btn.sm svg{ width:14px; height:14px;}
.btn svg{ width:14px; height:14px; flex:none;}
.btn.lg svg{ width:16px; height:16px;}

.surface{ background:var(--card-bg); border:1px solid var(--line); border-radius:var(--r-lg); padding:var(--surf-pad, 18px); display:flex; flex-direction:column; gap:calc(var(--gap, 14px) - 2px);  box-shadow:var(--shadow-1);}
.surface .head{ display:flex; align-items:center; justify-content:space-between;}
.surface .head h3{ font-family:var(--font-disp); font-weight:700; font-size:17px; letter-spacing:-.012em;}
.surface .head .sub{ font-size:12.5px; color:var(--ink-3); font-weight:600; margin-top:2px;}
.surface .head .right{ display:flex; gap:8px; align-items:center;}

.tbl{ width:100%; border-collapse:collapse; font-size:13.5px;}
.tbl thead th{
  text-align:left; padding:calc(var(--row-pad-y, 12px) - 2px) 12px; font-size:11px; font-weight:800; color:var(--ink-3);
  letter-spacing:.08em; text-transform:uppercase; border-bottom:1px solid var(--line-2);
  background:var(--paper);
  white-space:nowrap;
}
.tbl thead th:first-child{ border-top-left-radius:12px;}
.tbl thead th:last-child{ border-top-right-radius:12px;}
.tbl tbody td{ padding:var(--row-pad-y, 12px) 12px; border-bottom:1px solid var(--line-2); vertical-align:middle;}
.tbl tbody tr:hover td{ background:var(--primary-soft);}
.tbl tbody tr:last-child td{ border-bottom:none;}

.tag{
  display:inline-flex; align-items:center; gap:6px; padding:3px 9px;
  border-radius:999px; font-size:11px; font-weight:800;
  letter-spacing:.04em;
}
.tag .d{ width:6px; height:6px; border-radius:50%; background:currentColor;}
.tag.gold{ background:var(--gold-soft); color:var(--gold-deep);}
.tag.teal{ background:var(--teal-soft); color:var(--teal-ink);}
.tag.sky{ background:var(--sky-soft); color:var(--sky-ink);}
.tag.ember{ background:var(--ember-soft); color:var(--ember-deep);}
.tag.rose{ background:var(--rose-soft); color:var(--rose);}
.tag.violet{ background:var(--violet-soft); color:var(--sky-ink);}
.tag.line{ background:var(--card-bg); border:1px solid var(--line); color:var(--ink-2);}
.tag.dark{ background:var(--ink); color:#fff;}

.errbanner{
  background:var(--rose-soft); border:1.5px solid #F0BFC8; border-radius:14px;
  padding:12px 14px; display:flex; gap:10px; align-items:flex-start; font-size:13.5px; color:#7A2535;
}
.errbanner b{ font-weight:800; display:block;}
.errbanner .ic{ width:22px; height:22px; border-radius:7px; background:var(--rose); color:#fff; display:flex; align-items:center; justify-content:center; flex:none;}
.errbanner .ic svg{ width:14px; height:14px;}

.scrim{
  position:absolute; inset:0; background:rgba(34,34,34,.46); backdrop-filter:blur(2px);
  display:flex; align-items:center; justify-content:center; z-index:40;
}
.modal{
  width:480px; max-width:92%; background:var(--card-bg); border:1px solid var(--line); border-radius:20px;
  box-shadow:var(--shadow-3); overflow:hidden;
}
.modal .mhead{ padding:20px 22px 0; display:flex; gap:14px; align-items:flex-start;}
.modal .mhead .mic{
  width:48px; height:48px; border-radius:14px; flex:none;
  background:var(--rose-soft); color:var(--rose); display:flex; align-items:center; justify-content:center;
}
.modal .mhead .mic svg{ width:22px; height:22px;}
.modal .mhead h3{ font-family:var(--font-disp); font-weight:700; font-size:20px; letter-spacing:-.018em;}
.modal .mhead .sub{ font-size:13.5px; color:var(--ink-2); margin-top:4px; line-height:1.5;}
.modal .mbody{ padding:14px 22px 4px; display:flex; flex-direction:column; gap:12px;}
.modal .mfoot{ padding:16px 22px 18px; display:flex; gap:10px; justify-content:flex-end;}

/* callouts */
.callout{
  display:flex; gap:10px; align-items:flex-start;
  background:var(--rose-soft); border:1px solid #F0BFC8; border-radius:12px;
  padding:11px 13px; color:#7A2535; font-size:12.5px; font-weight:600; line-height:1.45;
}
.callout.warn{ background:var(--gold-soft); border-color:#F0DCAE; color:#6A4910;}
.callout.info{ background:var(--sky-soft); border-color:#CFE0F2; color:#1F4A86;}
.callout .ic{ width:22px; height:22px; border-radius:7px; flex:none; display:flex; align-items:center; justify-content:center;}

/* page states (RCUI.setState) — minimal; style richer per project */
.rc-empty, .rc-state{ padding:28px 16px; text-align:center; color:var(--ink-3); font-size:13.5px;}
.rc-skeleton{ background:linear-gradient(90deg, var(--paper-2) 0%, var(--paper-3) 50%, var(--paper-2) 100%); background-size:200% 100%; animation:rc-shimmer 1.4s ease-in-out infinite; border-radius:10px;}
@keyframes rc-shimmer{ 0%{ background-position:200% 0;} 100%{ background-position:-200% 0;} }

/* LTR islands inside RTL pages (phones, codes, ids) */
.rc-ltr{ direction:ltr; unicode-bidi:isolate; }

@media (prefers-reduced-motion: reduce){
  .rc-skeleton{ animation:none; }
  .btn{ transition:none; }
}

/* ===== page shell (base-layout.html) =====
   .adm-body is a viewport-height flex column. A page with several stacked sections must pin
   its children: .adm-body:has(.my-page) > * { flex-shrink: 0 } */
.app-main{ min-height:100vh; display:flex; flex-direction:column; }
.adm-body{ flex:1; min-height:0; display:flex; flex-direction:column; gap:var(--gap, 14px); padding:var(--body-pad, 22px); }
html.dark body{ background:var(--paper); color:var(--ink); }
