/*
 * Istimarh — store dashboard.
 *
 * Hand-written, no build step. The palette and shapes are the mobile app's
 * (CatalogStyle): ink for primary actions, the red accent for prices, badges
 * and active states, hairline borders on white. RTL first — only logical
 * properties, so the same rules lay out Arabic and English.
 */

@font-face {
  font-family: "SaudiRiyal";
  src: url("/fonts/saudi-riyal.woff2") format("woff2");
  unicode-range: U+E900;
  font-display: block;
}

:root {
  --ink: #1D1D1B;
  --ink-2: #3A3A37;
  --muted: #6B6B6B;
  --muted-2: #9A9A96;
  --accent: #ED6879;
  --accent-ink: #B8364A;       /* accent dark enough for text on white */
  --accent-wash: #FDEEF0;
  --hairline: rgba(158, 158, 158, .22);
  --hairline-strong: rgba(158, 158, 158, .38);
  --surface: #FFFFFF;
  --wash: #F9FAFC;
  --page: #F4F5F7;
  --warn: #B26B00;
  --warn-wash: #FFF4E0;
  --ok: #2E7D32;
  --ok-wash: #E9F5EA;
  --danger: #C62828;
  --danger-wash: #FDECEC;
  --info: #1F5E8C;
  --info-wash: #E8F1F8;

  --radius-card: 15px;
  --radius-btn: 12px;
  --radius-input: 10px;
  --radius-chip: 20px;
  --btn-h: 44px;
  --btn-h-lg: 48px;
  --btn-h-sm: 34px;

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

  --sidebar-w: 256px;
  --shadow-pop: 0 12px 32px rgba(29, 29, 27, .12);
  --font: "SaudiRiyal", "El Messiri", "Segoe UI", Tahoma, system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.store {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--page);
  font-variant-numeric: tabular-nums;
}
[dir="rtl"] body.store { line-height: 1.6; }
img { max-width: 100%; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; inset-inline-start: var(--s3); inset-block-start: -60px; z-index: 100;
  background: var(--ink); color: #fff; padding: var(--s2) var(--s4); border-radius: var(--radius-btn);
  text-decoration: none;
}
.skip-link:focus { inset-block-start: var(--s3); }
:focus-visible { outline: 3px solid rgba(237, 104, 121, .55); outline-offset: 2px; border-radius: 6px; }

.icon { flex: none; vertical-align: middle; }
[dir="rtl"] .icon-dir { transform: scaleX(-1); }
.muted { color: var(--muted); }
.strong { font-weight: 700; }
.nowrap { white-space: nowrap; }

/* ---------------------------------------------------------------- money --- */
.money { display: inline-flex; align-items: baseline; gap: 3px; white-space: nowrap; }
.money bdi { font-variant-numeric: tabular-nums; }
.riyal { font-family: "SaudiRiyal"; font-size: .82em; color: var(--muted); }

/* ---------------------------------------------------------------- shell --- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; inset-block-start: 0; height: 100vh; overflow-y: auto;
  background: var(--surface); border-inline-end: 1px solid var(--hairline);
  padding: var(--s4) var(--s3); display: flex; flex-direction: column; gap: var(--s4);
}
.brand { display: flex; align-items: center; gap: var(--s3); text-decoration: none; padding: var(--s1) var(--s2); }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px; background: var(--ink); color: #fff;
  display: grid; place-items: center;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-sub { font-size: 12px; color: var(--muted); }

.nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: var(--s3); min-height: 44px; padding: 0 var(--s3);
  border-radius: var(--radius-btn); text-decoration: none; color: var(--ink-2); font-weight: 500;
}
.nav-link:hover { background: var(--wash); }
.nav-link.is-active { background: var(--ink); color: #fff; }
.nav-link.is-active .icon { color: #fff; }
.nav-badge {
  margin-inline-start: auto; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px;
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center;
}

.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; inset-block-start: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s5); background: rgba(244, 245, 247, .92);
  backdrop-filter: blur(8px); border-block-end: 1px solid var(--hairline);
}
.menu-toggle { display: none; }
.topbar-search {
  flex: 1; max-width: 420px; display: flex; align-items: center; gap: var(--s2);
  background: var(--surface); border: 1px solid var(--hairline-strong); border-radius: var(--radius-btn);
  padding: 0 var(--s3); height: 42px; color: var(--muted);
}
.topbar-search input { border: 0; outline: 0; background: transparent; font: inherit; color: var(--ink); width: 100%; }
.topbar-search:focus-within { border-color: var(--ink); }
.topbar-search-spacer { flex: 1; }
.topbar-actions { margin-inline-start: auto; display: flex; align-items: center; gap: var(--s2); }
.icon-btn {
  display: inline-flex; align-items: center; gap: var(--s2); min-height: 42px; min-width: 42px; padding: 0 var(--s3);
  border-radius: var(--radius-btn); border: 1px solid transparent; background: transparent; color: var(--ink-2);
  font: inherit; cursor: pointer; text-decoration: none; position: relative;
}
.icon-btn:hover { background: var(--surface); border-color: var(--hairline); }
.count-badge {
  position: absolute; inset-block-start: 4px; inset-inline-end: 4px; min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--accent-wash); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 700;
}
.account-menu { position: relative; }
.account-menu summary { list-style: none; }
.account-menu summary::-webkit-details-marker { display: none; }
.account-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-panel {
  position: absolute; inset-inline-end: 0; inset-block-start: calc(100% + 6px); min-width: 220px; z-index: 30;
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius-card); box-shadow: var(--shadow-pop);
  padding: var(--s2); display: flex; flex-direction: column;
}
.menu-panel a, .menu-panel button {
  display: flex; align-items: center; gap: var(--s2); padding: 10px var(--s3); border-radius: 10px; border: 0; background: none;
  font: inherit; color: var(--ink); text-align: start; text-decoration: none; cursor: pointer; width: 100%;
}
.menu-panel a:hover, .menu-panel button:hover { background: var(--wash); }
.menu-panel form { border-block-start: 1px solid var(--hairline); margin-block-start: var(--s1); padding-block-start: var(--s1); }

.content { padding: var(--s5); display: flex; flex-direction: column; gap: var(--s5); max-width: 1320px; width: 100%; }
.content:focus { outline: none; }

/* --------------------------------------------------------------- banners --- */
.banners { padding: var(--s4) var(--s5) 0; display: flex; flex-direction: column; gap: var(--s2); max-width: 1320px; }
.banner, .alert {
  display: flex; align-items: flex-start; gap: var(--s3); padding: var(--s3) var(--s4);
  border-radius: var(--radius-card); border: 1px solid transparent;
}
.banner p, .alert p { flex: 1; }
.banner .btn { flex: none; }
.banner-info, .alert-info { background: var(--info-wash); border-color: rgba(31, 94, 140, .15); color: var(--info); }
.banner-warn, .alert-warn { background: var(--warn-wash); border-color: rgba(178, 107, 0, .18); color: #7A4A00; }
.banner-danger, .alert-danger { background: var(--danger-wash); border-color: rgba(198, 40, 40, .18); color: #8E1C1C; }
.alert-ok { background: var(--ok-wash); border-color: rgba(46, 125, 50, .18); color: #1E5A22; }
.alert-title { font-weight: 700; }
.alert-list { margin: var(--s1) 0 0; padding-inline-start: 18px; }

/* ----------------------------------------------------------- page header --- */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; }
.page-title { font-size: 26px; line-height: 1.25; font-weight: 700; text-wrap: balance; }
.page-sub { color: var(--muted); margin-block-start: var(--s1); }
.page-actions { display: flex; gap: var(--s2); flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-size: 14px; margin-block-end: var(--s2); }
.back-link .icon { transform: scaleX(-1); }
[dir="rtl"] .back-link .icon { transform: none; }

/* ----------------------------------------------------------------- grids --- */
.grid { display: grid; gap: var(--s4); }
.grid-kpi { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.stack { display: flex; flex-direction: column; gap: var(--s4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--s2); }
.row { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.row-between { justify-content: space-between; }
.row-gap-sm { gap: var(--s2); }

/* ------------------------------------------------------------------ card --- */
.card { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius-card); min-width: 0; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: var(--s4) var(--s4) 0;
}
.card-title { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: var(--s2); }
.card-title .icon { color: var(--muted); }
.card-actions { display: flex; align-items: center; gap: var(--s2); }
.card-body { padding: var(--s4); }
.card-flush .card-body { padding: 0; }

/* ------------------------------------------------------------------ stat --- */
.stat {
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius-card);
  padding: var(--s4); display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: inherit; min-width: 0;
}
.stat-link:hover { border-color: var(--hairline-strong); box-shadow: 0 2px 10px rgba(29, 29, 27, .05); }
.stat-label { color: var(--muted); font-size: 13.5px; display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 26px; font-weight: 700; line-height: 1.2; }
.stat-hint { color: var(--muted); font-size: 12.5px; }
.stat-accent { border-color: rgba(237, 104, 121, .45); background: linear-gradient(0deg, var(--surface), var(--surface)), var(--accent-wash); }
.stat-accent .stat-value { color: var(--accent-ink); }
.stat-danger .stat-value { color: var(--danger); }
.stat-warn .stat-value { color: var(--warn); }

/* --------------------------------------------------------------- buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  height: var(--btn-h); padding: 0 var(--s4); border-radius: var(--radius-btn);
  font: inherit; font-weight: 700; font-size: 14.5px; text-decoration: none; cursor: pointer;
  border: 1px solid transparent; transition: transform .11s ease-out, background-color .15s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-lg { height: var(--btn-h-lg); font-size: 15.5px; }
.btn-sm { height: var(--btn-h-sm); padding: 0 var(--s3); font-size: 13.5px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-filled { background: var(--ink); color: #fff; }
.btn-filled:hover { background: #33332F; }
.btn-outlined { background: var(--surface); color: var(--ink); border-color: var(--hairline-strong); }
.btn-outlined:hover { border-color: var(--ink); }
.btn-accent { background: var(--surface); color: var(--accent-ink); border-color: rgba(237, 104, 121, .6); }
.btn-accent:hover { background: var(--accent-wash); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--wash); }
.btn-danger { background: var(--danger); color: #fff; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; }

.link { color: var(--accent-ink); font-weight: 600; text-decoration: none; }
.link:hover { text-decoration: underline; }
.link-sm { font-size: 13.5px; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent-ink); font-weight: 600; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- badges --- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 10px; border-radius: var(--radius-chip);
  font-size: 12.5px; font-weight: 600; white-space: nowrap; vertical-align: middle;
}
.badge-muted { background: #F0F0EE; color: var(--ink-2); }
.badge-accent { background: var(--accent-wash); color: var(--accent-ink); }
.badge-ok { background: var(--ok-wash); color: var(--ok); }
.badge-warn { background: var(--warn-wash); color: var(--warn); }
.badge-danger { background: var(--danger-wash); color: var(--danger); }
.badge-info { background: var(--info-wash); color: var(--info); }
.badge-ink { background: var(--ink); color: #fff; }

/* ---------------------------------------------------------------- fields --- */
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-weight: 600; font-size: 14px; }
.req { color: var(--accent-ink); margin-inline-start: 2px; }
.control { position: relative; display: flex; }
.input {
  width: 100%; min-height: 46px; padding: 10px var(--s3); border-radius: var(--radius-input);
  border: 1px solid var(--hairline-strong); background: var(--wash); font: inherit; color: var(--ink);
}
textarea.input { resize: vertical; min-height: 96px; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-inline-end: 34px; }
[dir="rtl"] select.input { background-position: 18px 50%, 13px 50%; }
.input:focus { outline: none; border-color: var(--ink); background: var(--surface); box-shadow: 0 0 0 3px rgba(29, 29, 27, .08); }
.has-suffix .input { padding-inline-end: 46px; }
.control-suffix {
  position: absolute; inset-inline-end: 4px; inset-block: 4px; min-width: 38px; border: 0; background: transparent;
  color: var(--muted); display: grid; place-items: center; cursor: pointer; border-radius: 8px;
}
span.control-suffix { cursor: default; }
.hint { color: var(--muted); font-size: 12.5px; }
.error { color: var(--danger); font-size: 13px; font-weight: 600; }
.is-invalid .input { border-color: var(--danger); background: #FFFBFB; }
.input-code { letter-spacing: .4em; font-size: 22px; text-align: center; }
.check { display: inline-flex; align-items: center; gap: var(--s2); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); }

/* ----------------------------------------------------------------- empty --- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: var(--s5) var(--s3); color: var(--muted); }
.empty .icon { color: var(--muted-2); }
.empty-title { color: var(--ink); font-weight: 600; font-size: 14.5px; }
.empty-hint { font-size: 12.5px; max-width: 40ch; }

/* ------------------------------------------------------------ order rows --- */
.order-row { display: flex; gap: var(--s3); justify-content: space-between; padding: var(--s3) 0; border-block-end: 1px solid var(--hairline); }
.order-row:first-child { padding-block-start: 0; }
.order-row:last-child { border-block-end: 0; padding-block-end: 0; }
.order-row-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.order-row-title { font-weight: 700; display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.order-row-title a { text-decoration: none; }
.order-row-title a:hover { text-decoration: underline; }
.order-row-meta { color: var(--muted); font-size: 13px; }
.order-row-side { display: flex; flex-direction: column; align-items: flex-end; gap: var(--s2); flex: none; }
.line-list { list-style: none; margin: 4px 0 0; padding: 0; font-size: 13.5px; display: flex; flex-direction: column; gap: 2px; }
.qty { display: inline-block; min-width: 30px; padding: 0 6px; margin-inline-end: 4px; border-radius: 6px; background: var(--wash); border: 1px solid var(--hairline); font-weight: 700; text-align: center; }

/* ------------------------------------------------------------- sparkline --- */
.trend-head { display: flex; align-items: baseline; gap: var(--s3); flex-wrap: wrap; margin-block-end: var(--s3); }
.trend-total { font-size: 26px; font-weight: 700; }
.sparkline { margin: 0; }
.sparkline svg { width: 100%; height: 140px; display: block; }
[dir="rtl"] .sparkline svg { transform: scaleX(-1); }
.spark-grid { stroke: var(--hairline); stroke-width: 1; }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 2.5; vector-effect: non-scaling-stroke; }
.spark-area { fill: rgba(237, 104, 121, .12); stroke: none; }
.spark-dot { fill: var(--accent); stroke: #fff; stroke-width: 2; }
.spark-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-block-start: 6px; }

.countdown { font-weight: 600; color: var(--ink-2); font-size: 13.5px; white-space: nowrap; }
.countdown.is-overdue { color: var(--danger); }

/* ----------------------------------------------------------------- toast --- */
.toast-region { position: fixed; inset-block-end: var(--s5); inset-inline-start: var(--s5); z-index: 60; display: flex; flex-direction: column; gap: var(--s2); }
.toast {
  background: var(--ink); color: #fff; padding: var(--s3) var(--s4); border-radius: var(--radius-btn); box-shadow: var(--shadow-pop);
  display: flex; align-items: center; gap: var(--s3); max-width: 360px; animation: toast-in .2s ease-out;
}
.toast a { color: #fff; font-weight: 700; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- dialog --- */
dialog.confirm {
  border: 0; border-radius: var(--radius-card); padding: var(--s5); max-width: 420px; width: calc(100% - 32px);
  box-shadow: var(--shadow-pop); color: var(--ink);
}
dialog.confirm::backdrop { background: rgba(29, 29, 27, .45); }
dialog.confirm h2 { font-size: 18px; margin-block-end: var(--s2); }
dialog.confirm p { color: var(--muted); }
dialog.confirm .dialog-actions { display: flex; justify-content: flex-end; gap: var(--s2); margin-block-start: var(--s5); }

/* ------------------------------------------------------------------ auth --- */
.store-guest { background: radial-gradient(1200px 500px at 50% -10%, #FBE5E8 0%, rgba(251, 229, 232, 0) 60%), var(--page); }
.auth-shell { min-height: 100vh; display: flex; flex-direction: column; }
.auth-top { display: flex; align-items: center; justify-content: space-between; padding: var(--s4) var(--s5); }
.auth-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: var(--s5) var(--s4) var(--s7); gap: var(--s4); }
.auth-main:focus { outline: none; }
.auth-card {
  width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 20px; padding: var(--s6); display: flex; flex-direction: column; gap: var(--s4);
  box-shadow: 0 1px 2px rgba(29, 29, 27, .04);
}
.auth-card-wide { max-width: 760px; }
.auth-title { font-size: 26px; font-weight: 700; }
.auth-sub { color: var(--muted); margin-block-start: calc(var(--s2) * -1); }
.auth-below { color: var(--muted); font-size: 14px; }
.resend-row { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; font-size: 14px; justify-content: center; }

/* ------------------------------------------------------------------ tabs --- */
.tabs { display: flex; gap: var(--s1); border-block-end: 1px solid var(--hairline); overflow-x: auto; scrollbar-width: none; }
.tab {
  display: inline-flex; align-items: center; gap: var(--s2); padding: var(--s3) var(--s4); min-height: 44px;
  text-decoration: none; color: var(--muted); font-weight: 600; white-space: nowrap;
  border-block-end: 2px solid transparent; margin-block-end: -1px;
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--ink); border-color: var(--ink); }
.tab-count {
  min-width: 24px; height: 22px; padding: 0 7px; border-radius: 11px; background: #ECECEA; color: var(--ink-2);
  font-size: 12px; display: grid; place-items: center;
}
.tab.is-active .tab-count { background: var(--ink); color: #fff; }

/* ------------------------------------------------------------ filter bar --- */
.filter-bar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s3);
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius-card); padding: var(--s3) var(--s4);
}
.filter-bar .field { min-width: 150px; gap: 4px; }
.filter-bar .field-grow { flex: 1 1 220px; }
.filter-bar .label { font-size: 12.5px; color: var(--muted); }
.filter-bar .input { min-height: 42px; padding-block: 8px; }
.filter-bar .check { min-height: 42px; }
.filter-actions { display: flex; gap: var(--s2); margin-inline-start: auto; }

/* ----------------------------------------------------------------- table --- */
.table-wrap { overflow-x: auto; }
/* Scroll sideways on a phone rather than squeeze part names to a word a line. */
.table-wrap .table { min-width: 640px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: start; font-weight: 600; color: var(--muted); font-size: 12.5px; white-space: nowrap;
  padding: 10px var(--s4); border-block-end: 1px solid var(--hairline); background: var(--wash);
}
.table td { padding: var(--s3) var(--s4); border-block-end: 1px solid var(--hairline); vertical-align: top; }
.table tbody tr:last-child td { border-block-end: 0; }
.table tbody tr:hover td { background: #FCFCFD; }
.table .num { text-align: end; white-space: nowrap; }
.table a { text-decoration: none; }
.table a:hover { text-decoration: underline; }
.cell-sub { color: var(--muted); font-size: 12.5px; margin-block-start: 2px; font-weight: 400; }
.cell-actions { text-align: end; white-space: nowrap; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .92em; }
.card-flush .card-head { padding-block-end: var(--s3); }
.pagination {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: var(--s3) var(--s4); border-block-start: 1px solid var(--hairline);
}

/* ---------------------------------------------------------- order detail --- */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: var(--s4); align-items: start; }
.badge-lg { height: 32px; padding: 0 14px; font-size: 14px; }

.stepper { list-style: none; margin: 0; padding: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
.step { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; color: var(--muted); font-size: 13.5px; }
.step::before {
  content: ""; position: absolute; inset-block-start: 15px; height: 2px; background: var(--hairline-strong);
  inset-inline-start: calc(-50% + 20px); inset-inline-end: calc(50% + 20px);
}
.step:first-child::before { display: none; }
.step.is-done::before, .step.is-current::before { background: var(--ink); }
.step-dot {
  position: relative; z-index: 1; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); border: 2px solid var(--hairline-strong); font-weight: 700;
}
.step.is-done, .step.is-current { color: var(--ink); font-weight: 600; }
.step.is-done .step-dot { background: var(--ink); border-color: var(--ink); color: #fff; }
.step.is-current .step-dot { border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 0 0 4px var(--accent-wash); }

.kv { margin: 0 0 var(--s3); display: flex; flex-direction: column; gap: var(--s2); }
.kv div { display: flex; justify-content: space-between; gap: var(--s3); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; text-align: end; }

.totals { margin: 0; display: flex; flex-direction: column; }
.totals div { display: flex; justify-content: space-between; gap: var(--s3); padding: 8px 0; }
.totals dd { margin: 0; font-weight: 600; }
.totals .sub { padding-block: 2px; font-size: 13px; }
.totals .sub dt, .totals .sub dd { color: var(--muted); font-weight: 400; }
.totals .sub dt { padding-inline-start: var(--s3); }
.totals .total { border-block-start: 1px solid var(--hairline); margin-block-start: 6px; padding-block-start: var(--s3); font-size: 17px; }
.totals .total dt, .totals .total dd { font-weight: 700; color: var(--ink); }

.next-step { border-color: rgba(29, 29, 27, .3); }
.next-step .card-body { display: flex; flex-direction: column; gap: var(--s3); }
.deadline { display: flex; align-items: center; gap: var(--s2); font-weight: 600; flex-wrap: wrap; }
.otp { display: flex; flex-direction: column; gap: 4px; padding: var(--s3); border-radius: var(--radius-btn); background: var(--wash); border: 1px dashed var(--hairline-strong); }
.otp-label { color: var(--muted); font-size: 13px; }
.otp-code { font-size: 30px; font-weight: 700; letter-spacing: .25em; }

/* ------------------------------------------------------------ print page --- */
.print-page { background: #fff; }
.print-bar { display: flex; justify-content: space-between; gap: var(--s2); padding: var(--s4); max-width: 820px; margin: 0 auto; }
.slip { max-width: 820px; margin: 0 auto; padding: var(--s4) var(--s4) var(--s7); display: flex; flex-direction: column; gap: var(--s5); }
.slip-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s4); border-block-end: 2px solid var(--ink); padding-block-end: var(--s4); }
.slip-head h1 { font-size: 24px; }
.slip-num { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: 13px; color: var(--muted); }
.slip-num strong { font-size: 22px; color: var(--ink); }
.slip-meta { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s4); }
.slip-meta dt { color: var(--muted); font-size: 12.5px; }
.slip-meta dd { margin: 2px 0 0; font-weight: 600; }
.slip-table th, .slip-table td,
.slip-table tbody tr:last-child td { border: 1px solid #CFCFCF; }
.check-box { display: inline-block; width: 18px; height: 18px; border: 1.5px solid var(--ink); border-radius: 4px; }
.slip-sign { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s6); margin-block-start: var(--s6); }
.slip-sign div { border-block-start: 1px solid var(--ink); padding-block-start: var(--s2); color: var(--muted); font-size: 13px; }

/* ----------------------------------------------------------------- parts --- */
.input-sm { min-height: 36px; padding: 6px 10px; font-size: 14px; }
.mini-control { position: relative; display: flex; align-items: center; width: 132px; }
.mini-control .input { padding-inline-end: 30px; }
.mini-control .riyal { position: absolute; inset-inline-end: 10px; pointer-events: none; }
.stock-cell { display: flex; align-items: center; gap: 6px; }
.stock-control { width: 84px; }
.cell-input { white-space: nowrap; }
.cell-check { width: 44px; }
.bulk-check { width: 18px; height: 18px; accent-color: var(--ink); cursor: pointer; }
.inline-form { display: inline; }
.row-status { display: inline-block; min-width: 16px; font-size: 12.5px; vertical-align: middle; margin-inline: 4px; }
.row-status.is-saving { color: var(--muted); }
.row-status.is-saved { color: var(--ok); }
.row-status.is-error { color: var(--danger); white-space: normal; }
tr.is-saving td { opacity: .7; }
tr.is-error td { background: #FFFBFB; }
.js [data-inline-save] { display: none; }
.parts-table td:nth-child(2) { min-width: 170px; }

/* A left-to-right input (prices, part numbers, passwords) starts its text on
   the left in both languages, so its suffix stays on the right, where the
   text doesn't reach — not on the Arabic inline end, where it would overlap. */
.control-ltr .control-suffix { inset-inline-start: auto; inset-inline-end: auto; right: 4px; }
.mini-control .riyal { inset-inline-start: auto; inset-inline-end: auto; right: 10px; }
.control-ltr .input, .mini-control .input { padding-left: 12px; padding-right: 34px; }
[dir="rtl"] select.input { background-position: 13px 50%, 18px 50%; }

.bulk-bar {
  display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; color: var(--muted);
  padding: var(--s3) var(--s4); border-block-end: 1px solid var(--hairline);
}
.bulk-bar.is-active { background: var(--accent-wash); color: var(--ink); }
.bulk-bar .spacer { flex: 1; }

.switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; flex: none; }
.switch input[type="checkbox"] { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch-track { position: relative; width: 40px; height: 24px; border-radius: 12px; background: #D5D5D2; transition: background .15s; }
.switch-track::after {
  content: ""; position: absolute; inset-block-start: 3px; inset-inline-start: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: inset-inline-start .15s;
}
.switch input:checked + .switch-track { background: var(--ok); }
.switch input:checked + .switch-track::after { inset-inline-start: 19px; }
.switch input:focus-visible + .switch-track { outline: 3px solid rgba(237, 104, 121, .55); outline-offset: 2px; }
.visibility-cell { display: flex; align-items: center; gap: var(--s2); }

fieldset.field { border: 0; margin: 0; padding: 0; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip { position: relative; }
.chip input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.chip span {
  display: inline-flex; align-items: center; min-height: 42px; padding: 0 var(--s4); cursor: pointer;
  border-radius: var(--radius-chip); border: 1px solid var(--hairline-strong); background: var(--surface); font-weight: 600;
}
.chip input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip input:focus-visible + span { outline: 3px solid rgba(237, 104, 121, .55); outline-offset: 2px; }

.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--s4); align-items: start; }
.grid-tight { gap: var(--s3); }
.stack-top { margin-block-start: var(--s3); }
.readonly-part { display: flex; flex-direction: column; gap: 2px; padding: var(--s3) var(--s4); border-radius: var(--radius-btn); background: var(--wash); border: 1px solid var(--hairline); }
.explain { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius-card); padding: var(--s3) var(--s4); }
.explain summary { cursor: pointer; font-weight: 600; color: var(--ink-2); }
.explain ul { margin: var(--s2) 0 0; padding-inline-start: 20px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }

/* --------------------------------------------------------------- imports --- */
.dropzone {
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--s2); padding: var(--s5);
  border: 2px dashed var(--hairline-strong); border-radius: var(--radius-card); background: var(--wash);
}
.dropzone.is-invalid { border-color: var(--danger); }
.dropzone input[type="file"] { font: inherit; max-width: 100%; }
.column-list { list-style: none; margin: var(--s3) 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.column-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s2); }
.column-list code { font-family: inherit; font-weight: 700; background: var(--wash); border: 1px solid var(--hairline); border-radius: 6px; padding: 1px 8px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--s3); }
.card-note { padding: 0 var(--s4) var(--s3); }

/* ----------------------------------------------------------------- money --- */
.amount { display: inline-flex; align-items: baseline; gap: 2px; font-weight: 700; white-space: nowrap; }
.amount-in { color: var(--ok); }
.amount-out { color: var(--ink); }
.list-rows { list-style: none; margin: 0; padding: 0; }
.list-rows li { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s2) 0; border-block-end: 1px solid var(--hairline); }
.list-rows li:last-child { border-block-end: 0; }

/* ----------------------------------------------------- settings and plans --- */
.logo-row { display: flex; align-items: center; gap: var(--s4); }
.logo-preview { width: 72px; height: 72px; border-radius: 16px; object-fit: cover; border: 1px solid var(--hairline); background: var(--wash); flex: none; }
.coords { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); margin-block: var(--s2); }
.danger-card { border-color: rgba(198, 40, 40, .3); }
.blockers { margin: var(--s2) 0 0; padding-inline-start: 20px; color: var(--danger); display: flex; flex-direction: column; gap: 4px; }
.section-title { font-size: 18px; font-weight: 700; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--s4); align-items: stretch; }
.plan {
  display: flex; flex-direction: column; gap: var(--s2); padding: var(--s5);
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius-card);
}
.plan.is-current { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.plan .badge { align-self: flex-start; }
.plan-name { font-size: 18px; font-weight: 700; }
.plan-price { font-size: 30px; font-weight: 700; line-height: 1.2; }
.plan-desc { color: var(--muted); }
.plan-features { list-style: none; margin: var(--s2) 0 var(--s3); padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; flex: 1; }
.plan-features li { display: flex; align-items: center; gap: var(--s2); }
.plan-features .icon { color: var(--ok); }
.simulator { max-width: 560px; margin-inline: auto; width: 100%; }
.note-line { display: flex; align-items: flex-start; gap: var(--s2); }
.note-line .icon { margin-block-start: 3px; }
.text-ok { color: var(--ok); }

/* --------------------------------------------------------- notifications --- */
.notification-list { list-style: none; margin: 0; padding: 0; }
.notification { display: flex; align-items: flex-start; gap: var(--s3); padding: var(--s3) var(--s4); border-block-end: 1px solid var(--hairline); }
.notification:last-child { border-block-end: 0; }
.notification.is-unread { background: #FFFBFC; }
.notification-icon { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--wash); color: var(--ink-2); flex: none; }
.notification.is-unread .notification-icon { background: var(--accent-wash); color: var(--accent-ink); }
.notification-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: inherit; }
.notification-main:hover .notification-title { text-decoration: underline; }
.notification-title { font-weight: 700; }
.notification-body { color: var(--ink-2); font-size: 14px; }
.unread-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-inline-start: 6px; vertical-align: middle; }

/* -------------------------------------------------------- signup and help --- */
.steps-indicator { list-style: none; margin: 0; padding: 0; display: flex; gap: var(--s2); }
.steps-indicator li { flex: 1; padding: var(--s2) var(--s3); border-radius: var(--radius-btn); background: var(--wash); color: var(--muted); font-weight: 600; text-align: center; }
.steps-indicator li.is-active { background: var(--ink); color: #fff; }
html:not(.js) .steps-indicator, html:not(.js) [data-step-next], html:not(.js) [data-step-back] { display: none; }
fieldset.register-step { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: var(--s4); }
.register-step > legend { font-size: 18px; font-weight: 700; margin-block-end: var(--s2); }
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) 0; border-block-end: 1px solid var(--hairline); }
.checklist li:last-child { border-block-end: 0; }
.check-dot { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--hairline-strong); font-weight: 700; flex: none; }
.checklist li.is-done .check-dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.checklist .grow { flex: 1; min-width: 0; }
.page-text { white-space: pre-line; line-height: 1.9; }


@media (max-width: 1100px) {
  .detail-grid, .form-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .stepper { grid-auto-flow: row; grid-auto-columns: auto; gap: var(--s3); }
  .step { flex-direction: row; text-align: start; }
  .step::before { display: none; }
  .filter-bar .field { min-width: 0; flex: 1 1 100%; }
  .filter-actions { margin-inline-start: 0; width: 100%; }
  .slip-meta { grid-template-columns: minmax(0, 1fr); }
}
@media print {
  @page { margin: 14mm; }
  .print-page .slip { padding: 0; }
}

/* ------------------------------------------------------------ responsive --- */
@media (max-width: 1180px) {
  .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0; width: min(290px, 86vw); z-index: 50;
    transform: translateX(-105%); box-shadow: var(--shadow-pop);
    /* visibility keeps the closed menu's links out of the tab order */
    visibility: hidden; transition: transform .2s ease-out, visibility 0s linear .2s;
  }
  [dir="rtl"] .sidebar { transform: translateX(105%); }
  body.menu-open .sidebar { transform: none; visibility: visible; transition: transform .2s ease-out, visibility 0s; }
  .scrim { position: fixed; inset: 0; background: rgba(29, 29, 27, .4); z-index: 40; }
  .menu-toggle { display: inline-flex; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .content, .topbar { padding-inline: var(--s4); }
  .banners { padding-inline: var(--s4); }
  .account-name { display: none; }
}
@media (max-width: 560px) {
  .grid-kpi { grid-template-columns: minmax(0, 1fr); }
  .topbar-search { display: none; }
  .locale-switch span { display: none; }
  .auth-card { padding: var(--s5); }
  .order-row { flex-direction: column; }
  .order-row-side { align-items: flex-start; }
  .page-title { font-size: 22px; }
}

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

@media print {
  .sidebar, .topbar, .banners, .toast-region, .page-actions, .no-print { display: none !important; }
  .shell { display: block; }
  body.store { background: #fff; }
  .card { border-color: #ccc; break-inside: avoid; }
}

/* ------------------------------------------------------- new order alert --- */
.order-alert { border: 0; border-radius: var(--radius-card); padding: 0; max-width: min(92vw, 460px); box-shadow: 0 24px 60px rgb(0 0 0 / 25%); }
.order-alert::backdrop { background: rgb(29 29 27 / 55%); }
.order-alert-inner { padding: var(--s6) var(--s5) var(--s5); display: flex; flex-direction: column; gap: var(--s2); text-align: center; }
.order-alert-eyebrow { color: var(--accent); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; font-size: 13px; margin: 0; }
.order-alert h2 { font-size: 22px; font-weight: 800; margin: 0; }
.order-alert-order { font-weight: 700; margin: var(--s2) 0 0; }
.order-alert-facts { color: var(--muted); margin: 0; }
.order-alert-clock { font-size: 34px; font-weight: 800; margin: var(--s3) 0 0; font-variant-numeric: tabular-nums; }
.order-alert.is-late .order-alert-clock { color: var(--accent); font-size: 20px; }
.order-alert-note { color: var(--muted); font-size: 14px; margin: 0; }
.order-alert-actions { display: flex; flex-direction: column; gap: var(--s2); margin-block-start: var(--s4); }
.order-alert-actions .btn { width: 100%; }
@media (prefers-reduced-motion: no-preference) {
  .order-alert[open] { animation: order-alert-in .2s ease-out; }
  @keyframes order-alert-in { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
}
.vin { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .04em; font-weight: 600; }
.order-alert-car { color: var(--ink-2); font-weight: 600; margin: 0; }

/* -------------------------------------------------------- open / closed --- */
.open-switch { margin: 0; }
.open-toggle { gap: 8px; font-weight: 700; }
.open-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); flex: none; }
.open-toggle.is-closed .open-dot { background: var(--muted); }
.open-toggle.is-closed { color: var(--muted); }
