/* ==========================================================================
   Square Ibis — core styles (Axiom Eye design system)
   1 tokens · 2 base · 3 living background · 4 shell · 5 sidebar · 6 topbar · 7 page
   8 buttons · 9 forms · 10 chips & status · 11 cards & KPIs · 12 tables · 13 drawer & modal
   14 menus & palette · 15 toasts · 16 feedback (empty, skeleton, timeline) · 17 motion · 18 responsive
   Layout uses logical properties (inline-start/end) so Arabic (RTL) mirrors automatically.
   ========================================================================== */

/* ---------- 1. tokens ---------- */

@property --angle { syntax: '<angle>'; inherits: false; initial-value: 0deg; }

:root {
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-ar: "IBM Plex Sans Arabic", "Inter", ui-sans-serif, system-ui, sans-serif;
  --serif: "Instrument Serif", ui-serif, Georgia, "Times New Roman", serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --r-sm: 9px;
  --r: 14px;
  --r-lg: 22px;
  --side-w: 264px;
  --page-w: 1320px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  /* brand colours: a company palette overrides these (public/js/brand.js) */
  --a0-rgb: 124, 92, 255;
  --a1-rgb: 139, 108, 255;
  --a2-rgb: 34, 211, 238;
  --a3-rgb: 240, 171, 252;
  --accent-1: #8b6cff;
  --accent-2: #22d3ee;
  --accent-3: #f0abfc;
  --accent: #8b6cff;
  --grad: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  --grad-3: linear-gradient(120deg, #a48bff 0%, #7c8cff 45%, #22d3ee 100%);
  --dur-1: 120ms;
  --dur-2: 200ms;
  --dur-3: 320ms;
  --dur-4: 520ms;
  --dur-5: 800ms;
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --fs-xs: 11px;
  --fs-sm: 12.5px;
  --fs-md: 14.5px;
  --fs-lg: 16.5px;
  --fs-xl: 22px;
  --fs-2xl: 30px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #06070c;
  --bg-2: #0c0e16;
  --panel: rgba(12, 14, 22, .66);
  --panel-solid: #0d0f18;
  --surface: rgba(255, 255, 255, .03);
  --surface-2: rgba(255, 255, 255, .052);
  --surface-3: rgba(255, 255, 255, .085);
  --border: rgba(255, 255, 255, .07);
  --border-strong: rgba(255, 255, 255, .125);
  --highlight: rgba(255, 255, 255, .06);
  --text: #eef0f8;
  --text-2: #a6abc0;
  --text-3: #6d728a;
  --aurora-1: rgba(var(--a0-rgb), .38);
  --aurora-2: rgba(var(--a2-rgb), .24);
  --aurora-3: rgba(var(--a3-rgb), .16);
  --spot: rgba(var(--a1-rgb), .12);
  --shadow: 0 24px 48px -24px rgba(0, 0, 0, .8), 0 2px 6px -2px rgba(0, 0, 0, .4);
  --shadow-sm: 0 4px 14px -6px rgba(0, 0, 0, .6);
  --green: #34d399;
  --rose: #fb7185;
  --amber: #fbbf24;
  --blue: #60a5fa;
  --indigo: #818cf8;
  --cyan: #22d3ee;
  --violet: #a78bfa;
  --orange: #fb923c;
  --gray: #8b90a6;
  --chip-l: 78%;
  --chip-bg-a: .12;
  --chip-bd-a: .26;
  --row-hover: rgba(255, 255, 255, .028);
  --row-sel: rgba(var(--a1-rgb), .1);
  /* chart series (validated for CVD separation against the dark surface) */
  --series-1: #8b6cff;
  --series-2: #0b9cc0;
  --series-3: #f0468f;
  --grid: rgba(255, 255, 255, .07);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f5fb;
  --bg-2: #ffffff;
  --panel: rgba(255, 255, 255, .72);
  --panel-solid: #ffffff;
  --surface: rgba(20, 24, 50, .024);
  --surface-2: rgba(20, 24, 50, .048);
  --surface-3: rgba(20, 24, 50, .078);
  --border: rgba(20, 24, 50, .08);
  --border-strong: rgba(20, 24, 50, .14);
  --highlight: rgba(255, 255, 255, .9);
  --text: #10121c;
  --text-2: #4e546a;
  --text-3: #898fa5;
  --aurora-1: rgba(var(--a0-rgb), .18);
  --aurora-2: rgba(var(--a2-rgb), .16);
  --aurora-3: rgba(var(--a3-rgb), .14);
  --spot: rgba(var(--a0-rgb), .07);
  --shadow: 0 24px 48px -26px rgba(30, 35, 80, .28), 0 2px 6px -3px rgba(30, 35, 80, .12);
  --shadow-sm: 0 4px 14px -8px rgba(30, 35, 80, .25);
  --green: #059669;
  --rose: #e11d48;
  --amber: #d97706;
  --blue: #2563eb;
  --indigo: #4f46e5;
  --cyan: #0891b2;
  --violet: #7c3aed;
  --orange: #ea580c;
  --gray: #6b7085;
  --chip-l: 36%;
  --chip-bg-a: .10;
  --chip-bd-a: .24;
  --row-hover: rgba(20, 24, 50, .025);
  --row-sel: rgba(var(--a0-rgb), .08);
  /* chart series (validated for CVD separation against the light surface) */
  --series-1: #6d4aff;
  --series-2: #0891b2;
  --series-3: #db2777;
  --grid: rgba(20, 24, 50, .08);
}

/* ---------- 2. base ---------- */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
  text-rendering: optimizeLegibility;
}
:root[lang="ar"] body { font-family: var(--font-ar); }
/* monospace faces have no Arabic glyphs and break letter joining: Arabic text never uses them */
:root[lang="ar"] .delta, :root[lang="ar"] .live, :root[lang="ar"] .kbd, :root[lang="ar"] kbd, :root[lang="ar"] .tag, :root[lang="ar"] .nav-badge { font-family: var(--font-ar); letter-spacing: 0; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
code, kbd, .mono { font-family: var(--mono); font-size: .9em; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
h1, h2, h3, h4, p { margin: 0; }
em { font-style: normal; }
img { max-width: 100%; }

svg[viewBox="0 0 24 24"] {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
:root[dir="rtl"] svg.flip-rtl { transform: scaleX(-1); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
::selection { background: rgba(var(--a1-rgb), .35); }

* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 99px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* serif italic accent + gradient ink (brand word, hero headlines) */
.ink, .brand-name em, .page-title em, .auth-title em {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0;
  background: var(--grad-3);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  padding-inline-end: .06em;
}
:root[lang="ar"] .ink, :root[lang="ar"] .brand-name em, :root[lang="ar"] .page-title em, :root[lang="ar"] .auth-title em { font-family: var(--font-ar); font-style: normal; font-weight: 700; }

.muted { color: var(--text-3); }
.dim { color: var(--text-2); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.row { display: flex; align-items: center; gap: var(--s-2); }
.row-wrap { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s-2); }
.stack { display: flex; flex-direction: column; gap: var(--s-3); }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }
.right { margin-inline-start: auto; }
.tone-green { color: var(--green); } .tone-rose { color: var(--rose); } .tone-amber { color: var(--amber); }
.tone-blue { color: var(--blue); } .tone-violet { color: var(--violet); } .tone-cyan { color: var(--cyan); }

/* ---------- 3. living background ---------- */

.aurora { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.aurora span { position: absolute; width: 62vmax; height: 62vmax; border-radius: 50%; will-change: transform; }
.aurora span:nth-child(1) { top: -30vmax; left: -18vmax; background: radial-gradient(circle, var(--aurora-1), transparent 62%); animation: drift1 26s ease-in-out infinite alternate; }
.aurora span:nth-child(2) { top: -22vmax; right: -26vmax; background: radial-gradient(circle, var(--aurora-2), transparent 62%); animation: drift2 32s ease-in-out infinite alternate; }
.aurora span:nth-child(3) { bottom: -38vmax; left: 22vw; background: radial-gradient(circle, var(--aurora-3), transparent 60%); animation: drift3 38s ease-in-out infinite alternate; }
.app-dim .aurora { opacity: .55; }

.grain {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .055;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}
:root[data-theme="light"] .grain { opacity: .035; mix-blend-mode: multiply; }

/* pointer spotlight (fx.js sets --mx/--my on the hovered .spot element) */
.spot { position: relative; isolation: isolate; }
.spot::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(520px circle at var(--mx, -999px) var(--my, -999px), var(--spot), transparent 42%);
  opacity: 0;
  transition: opacity .4s var(--ease);
}
.spot:hover::before { opacity: 1; }

/* ---------- 4. shell ---------- */

#root { position: relative; z-index: 1; min-height: 100%; }
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 100vh; min-height: 100dvh; }
.view { flex: 1; min-height: 0; view-transition-name: main-view; }
body.is-booting #root { opacity: 0; }

/* ---------- 5. sidebar ---------- */

.side {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  padding: 16px 12px 12px;
  background: var(--panel);
  border-inline-end: 1px solid var(--border);
  backdrop-filter: blur(26px) saturate(150%);
  -webkit-backdrop-filter: blur(26px) saturate(150%);
  box-shadow: inset -1px 0 0 var(--highlight);
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 2px 6px 6px; color: inherit; }
.brand:hover { text-decoration: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; flex: 1; min-width: 0; }
.brand-name { font-weight: 700; font-size: 16.5px; letter-spacing: -.015em; white-space: nowrap; }
.brand-name em { font-size: 1.12em; }
.brand-sub { margin-top: 4px; font-size: 11.5px; color: var(--text-3); letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.logo {
  position: relative;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: linear-gradient(145deg, var(--surface-3), var(--surface));
  border: 1px solid var(--border-strong);
  box-shadow: 0 0 28px -6px rgba(var(--a1-rgb), .6), inset 0 1px 0 var(--highlight);
  flex: none;
  overflow: hidden;
}
.logo svg { width: 28px; height: 28px; overflow: visible; }
.logo .ibis { animation: ibisNod 7s ease-in-out infinite; transform-origin: 19px 35px; transform-box: view-box; }
.logo .ibis-parcel { animation: parcelSway 3.6s ease-in-out infinite; transform-origin: 42.1px 20.6px; transform-box: view-box; }
.logo .ibis-eye { fill: var(--bg); }
.logo .ibis-cut { stroke: var(--bg); }
.logo-img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }
.logo.lg { width: 76px; height: 76px; border-radius: 24px; }
.logo.lg svg { width: 54px; height: 54px; }

.nav { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -6px; padding: 2px 6px 8px; display: flex; flex-direction: column; gap: 1px; }
.nav-group { padding: 14px 10px 5px; font-size: 10.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); }
.nav-group:first-child { padding-top: 4px; }
:root[lang="ar"] .nav-group { letter-spacing: 0; font-size: 11.5px; }
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  height: 38px;
  padding: 0 10px 0 12px;
  border-radius: 11px;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  transition: background .2s, color .2s, transform .2s var(--ease);
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item:active { transform: scale(.985); }
.nav-item svg { width: 17px; height: 17px; opacity: .85; }
.nav-item.is-active { background: linear-gradient(90deg, rgba(var(--a1-rgb), .16), var(--surface-2) 70%); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }
:root[dir="rtl"] .nav-item.is-active { background: linear-gradient(-90deg, rgba(var(--a1-rgb), .16), var(--surface-2) 70%); }
.nav-item.is-active svg { opacity: 1; color: var(--accent); }
.nav-item.is-active::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 3px;
  background: var(--grad);
  box-shadow: 0 0 12px rgba(var(--a1-rgb), .9);
}
.nav-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; display: grid; place-items: center; font-family: var(--mono); font-size: 10.5px; font-weight: 600; background: var(--surface-3); color: var(--text-2); }
.nav-badge.hot { background: var(--grad); color: #fff; box-shadow: 0 4px 12px -4px rgba(var(--a0-rgb), .9); }

.me {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  text-align: start;
  transition: background .2s, border-color .2s, transform .2s var(--ease);
}
.me:hover { background: var(--surface-2); border-color: var(--border-strong); transform: translateY(-1px); }
.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 11px;
  background: var(--grad);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  box-shadow: 0 6px 16px -6px rgba(var(--a0-rgb), .8), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.avatar.lg { width: 46px; height: 46px; font-size: 18px; border-radius: 15px; }
.avatar.sm { width: 26px; height: 26px; font-size: 11px; border-radius: 9px; }
.avatar[data-h] { background: linear-gradient(135deg, hsl(var(--h) 80% 62%), hsl(calc(var(--h) + 40) 85% 55%)); }
.me-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.me-name { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-role { font-size: 11.5px; color: var(--text-3); }
.me .chev { width: 15px; height: 15px; color: var(--text-3); }

.backdrop { display: none; }

/* ---------- 6. topbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 62px;
  padding: 0 18px 0 24px;
  padding-inline: 24px 18px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  flex: none;
  z-index: 15;
}
.crumbs { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-3); }
.crumbs b { color: var(--text); font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs svg { width: 14px; height: 14px; }

.search-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 36px;
  min-width: 260px;
  padding: 0 8px 0 12px;
  padding-inline: 12px 8px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-3);
  font-size: 13px;
  transition: border-color .2s, background .2s, color .2s;
}
.search-btn:hover { border-color: var(--border-strong); background: var(--surface-2); color: var(--text-2); }
.search-btn span { flex: 1; text-align: start; }
.search-btn svg { width: 16px; height: 16px; }
kbd, .kbd { display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border-radius: 6px; border: 1px solid var(--border-strong); background: var(--surface-2); font-family: var(--mono); font-size: 10.5px; color: var(--text-3); }

.live {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 11px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 11px;
  white-space: nowrap;
}
.pulse { position: relative; width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex: none; }
.pulse::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 1.5px solid var(--green); opacity: 0; animation: ping 2.4s var(--ease) infinite; }
.live.is-off .pulse { background: var(--amber); }
.live.is-off .pulse::after { border-color: var(--amber); }

.icon-btn {
  position: relative;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: var(--text-2);
  transition: background .18s, color .18s, transform .18s;
  flex: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(.92); }
.icon-btn:disabled { opacity: .28; pointer-events: none; }
.icon-btn.danger:hover { color: var(--rose); }
.icon-btn.sm { width: 30px; height: 30px; border-radius: 9px; }
.icon-btn.sm svg { width: 16px; height: 16px; }
.icon-btn .dot-badge { position: absolute; top: 6px; inset-inline-end: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--rose); box-shadow: 0 0 0 2px var(--bg); }
#themeBtn svg { transition: transform .5s var(--spring); }
#themeBtn:hover svg { transform: rotate(35deg); }
.only-mobile { display: none !important; }

/* ---------- 7. page ---------- */

.page { width: 100%; max-width: var(--page-w); margin: 0 auto; padding: 26px 28px 80px; display: flex; flex-direction: column; gap: 18px; }
.page.narrow { max-width: 920px; }
.page.wide { max-width: none; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; animation: fadeUp .5s var(--ease-out) both; }
.page-head > div:first-child { flex: 1; min-width: 240px; }
.page-title { font-size: 27px; font-weight: 700; letter-spacing: -.03em; line-height: 1.15; }
.page-title em { font-size: 1.1em; }
.page-sub { margin-top: 5px; color: var(--text-2); font-size: 14px; max-width: 720px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.section-title { display: flex; align-items: center; gap: 10px; font-size: 12px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--text-3); margin: 6px 2px -4px; }
:root[lang="ar"] .section-title { letter-spacing: 0; font-size: 13px; }

.grid { display: grid; gap: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }

/* ---------- 8. buttons ---------- */

.btn {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 15px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  transition: background .2s, border-color .2s, transform .2s var(--ease), box-shadow .25s, filter .2s, opacity .2s;
}
.btn:hover { background: var(--surface-3); transform: translateY(-1px); text-decoration: none; }
.btn:active { transform: translateY(0) scale(.97); }
.btn:disabled, .btn.is-disabled { opacity: .45; pointer-events: none; }
.btn svg { width: 16px; height: 16px; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: 10px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-lg { height: 48px; padding: 0 20px; font-size: 15px; font-weight: 600; border-radius: 14px; }
.btn-xl { height: 58px; padding: 0 24px; font-size: 16.5px; font-weight: 600; border-radius: 17px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 10px 26px -10px rgba(var(--a0-rgb), .95), inset 0 1px 0 rgba(255, 255, 255, .25); }
.btn-primary:hover { background: var(--grad); filter: brightness(1.08); box-shadow: 0 14px 30px -10px rgba(var(--a0-rgb), 1), inset 0 1px 0 rgba(255, 255, 255, .25); }
.btn-primary::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, .38) 50%, transparent 70%); transform: translateX(-120%); transition: transform .8s var(--ease); pointer-events: none; }
.btn-primary:hover::after { transform: translateX(120%); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { color: var(--rose); border-color: color-mix(in srgb, var(--rose) 35%, transparent); background: color-mix(in srgb, var(--rose) 8%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, var(--rose) 14%, transparent); }
.btn-success { color: #fff; border-color: transparent; background: linear-gradient(135deg, #10b981, #22c55e); box-shadow: 0 10px 24px -10px rgba(16, 185, 129, .9), inset 0 1px 0 rgba(255, 255, 255, .25); }
.btn-success:hover { background: linear-gradient(135deg, #10b981, #22c55e); filter: brightness(1.06); }
.btn-warn { color: #fff; border-color: transparent; background: linear-gradient(135deg, #f59e0b, #f97316); box-shadow: 0 10px 24px -10px rgba(245, 158, 11, .8), inset 0 1px 0 rgba(255, 255, 255, .25); }
.btn-warn:hover { background: linear-gradient(135deg, #f59e0b, #f97316); filter: brightness(1.06); }
.btn.is-confirm { background: var(--rose); color: #fff; border-color: transparent; }
.btn.is-loading { pointer-events: none; }
.btn.is-loading > svg:first-child { display: none; }
.btn.is-loading::before { content: ""; width: 15px; height: 15px; border-radius: 50%; border: 2px solid currentColor; border-top-color: transparent; animation: spin .7s linear infinite; flex: none; }
.link-btn { color: var(--accent-2); font-weight: 500; }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
.ripple { position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: currentColor; opacity: .22; pointer-events: none; animation: ripple .65s var(--ease-out) forwards; }

/* ---------- 9. forms ---------- */

.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field-label { font-size: 12.5px; font-weight: 500; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.field-label .req { color: var(--rose); }
.field-hint { font-size: 12px; color: var(--text-3); }
.field-error { font-size: 12px; color: var(--rose); }
.field.has-error .input, .field.has-error input, .field.has-error select, .field.has-error textarea { border-color: color-mix(in srgb, var(--rose) 60%, transparent) !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--rose) 12%, transparent); }

.input, .field input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]), .field select, .field textarea, .select {
  width: 100%;
  height: 40px;
  padding: 0 13px;
  border-radius: 11px;
  border: 1px solid var(--border-strong);
  background: color-mix(in srgb, var(--bg-2) 72%, transparent);
  outline: none;
  font-size: 14px;
  transition: border-color .25s, box-shadow .25s, background .25s;
}
.field textarea, textarea.input { height: auto; min-height: 84px; padding: 10px 13px; resize: vertical; line-height: 1.5; }
.input:hover, .field input:hover, .field select:hover, .field textarea:hover, .select:hover { border-color: color-mix(in srgb, var(--accent) 30%, var(--border-strong)); }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus, .select:focus {
  border-color: color-mix(in srgb, var(--accent) 65%, transparent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 15%, transparent);
  background: var(--bg-2);
}
.input.sm, .select.sm { height: 34px; font-size: 13px; border-radius: 10px; padding: 0 11px; }
.input[readonly] { color: var(--text-2); background: var(--surface); }
select, .select { appearance: none; -webkit-appearance: none; cursor: pointer; padding-inline-end: 34px !important;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b90a6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-size: 16px; background-position: right 11px center; }
:root[dir="rtl"] select, :root[dir="rtl"] .select { background-position: left 11px center; }
select option { background: var(--panel-solid); color: var(--text); }
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button, input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="date"] { color-scheme: inherit; }

.input-icon { position: relative; }
.input-icon > svg { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-3); pointer-events: none; }
.input-icon > .input { padding-inline-start: 36px; }
.input-affix { position: relative; }
.input-affix > .affix { position: absolute; inset-inline-end: 12px; top: 50%; transform: translateY(-50%); font-family: var(--mono); font-size: 12px; color: var(--text-3); pointer-events: none; }
.input-affix > .input, .input-affix > input { padding-inline-end: 52px !important; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.form-section { display: flex; flex-direction: column; gap: 14px; }
.form-section + .form-section { padding-top: 18px; border-top: 1px dashed var(--border-strong); }
.form-section-title { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.form-section-title svg { width: 16px; height: 16px; color: var(--accent); }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.form-actions.start { justify-content: flex-start; }

/* switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-size: 13.5px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { position: relative; width: 38px; height: 22px; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--border-strong); transition: background .25s, border-color .25s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; inset-inline-start: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .35); transition: transform .3s var(--spring); }
.switch input:checked + .track { background: var(--grad); border-color: transparent; }
.switch input:checked + .track::after { transform: translateX(16px); }
:root[dir="rtl"] .switch input:checked + .track::after { transform: translateX(-16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* checkbox */
.check { position: relative; display: inline-grid; place-items: center; width: 18px; height: 18px; flex: none; }
.check input { appearance: none; -webkit-appearance: none; margin: 0; width: 18px; height: 18px; border-radius: 6px; border: 1.5px solid var(--border-strong); background: var(--surface); cursor: pointer; transition: background .2s, border-color .2s; }
.check input:checked, .check input:indeterminate { background: var(--grad); border-color: transparent; }
.check svg { position: absolute; width: 12px; height: 12px; color: #fff; pointer-events: none; opacity: 0; stroke-width: 3; }
.check input:checked ~ svg.i-on, .check input:indeterminate ~ svg.i-mid { opacity: 1; }

/* segmented control with a sliding pill */
.segmented { position: relative; display: inline-flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.segmented > button { position: relative; z-index: 1; height: 30px; padding: 0 12px; border-radius: 9px; font-size: 13px; font-weight: 500; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; transition: color .2s; }
.segmented > button svg { width: 15px; height: 15px; }
.segmented > button:hover { color: var(--text); }
.segmented > button[aria-checked="true"] { color: var(--text); }
.segmented::before { content: ""; position: absolute; top: 3px; bottom: 3px; left: var(--ix, 3px); width: var(--iw, 0); border-radius: 9px; background: var(--surface-3); box-shadow: inset 0 1px 0 var(--highlight), 0 2px 8px -2px rgba(0, 0, 0, .3); transition: left .35s var(--ease-out), width .35s var(--ease-out); }
.segmented.lg > button { height: 38px; padding: 0 16px; font-size: 14px; }
.segmented.block { display: flex; }
.segmented.block > button { flex: 1; justify-content: center; }

/* tabs (underline) */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs > button, .tabs > a { position: relative; display: inline-flex; align-items: center; gap: 7px; height: 40px; padding: 0 12px; font-size: 13.5px; font-weight: 500; color: var(--text-2); white-space: nowrap; text-decoration: none; }
.tabs > button:hover, .tabs > a:hover { color: var(--text); text-decoration: none; }
.tabs > [aria-selected="true"] { color: var(--text); }
.tabs > [aria-selected="true"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--grad); box-shadow: 0 0 10px rgba(var(--a1-rgb), .8); }
.tabs .count { font-family: var(--mono); font-size: 10.5px; padding: 1px 6px; border-radius: 99px; background: var(--surface-2); color: var(--text-3); }

/* ---------- 10. chips & status ---------- */

.chip {
  --h: 262;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  height: 24px;
  padding: 0 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  color: hsl(var(--h) 85% var(--chip-l));
  background: hsl(var(--h) 85% 60% / var(--chip-bg-a));
  border: 1px solid hsl(var(--h) 85% 62% / var(--chip-bd-a));
}
.chip svg { width: 13px; height: 13px; }
.chip.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; flex: none; }
.chip.lg { height: 30px; padding: 0 13px; font-size: 13px; }
.chip.sm { height: 20px; padding: 0 8px; font-size: 11px; }
.chip.plain { --h: 230; color: var(--text-2); background: var(--surface-2); border-color: var(--border); }
button.chip { cursor: pointer; transition: transform .2s var(--ease), background .2s; }
button.chip:hover { transform: translateY(-1px); }
button.chip[aria-pressed="false"] { color: var(--text-3); background: transparent; border-color: var(--border); }
button.chip[aria-pressed="false"]::before { box-shadow: none; opacity: .5; }

/* hue classes */
.h-violet { --h: 262; } .h-blue { --h: 217; } .h-cyan { --h: 190; } .h-teal { --h: 168; } .h-green { --h: 152; }
.h-lime { --h: 95; } .h-amber { --h: 40; } .h-orange { --h: 24; } .h-rose { --h: 350; } .h-pink { --h: 325; }
.h-indigo { --h: 235; } .h-gray { --h: 230; }
.h-gray.chip, .chip.h-gray { color: var(--text-2); background: var(--surface-2); border-color: var(--border-strong); }

/* parcel status pill: dot + label, hue set by class */
.status-pill { display: inline-flex; align-items: center; gap: 7px; height: 26px; padding: 0 11px 0 9px; padding-inline: 9px 11px; border-radius: 99px; font-size: 12.5px; font-weight: 500; white-space: nowrap;
  color: hsl(var(--h) 85% var(--chip-l)); background: hsl(var(--h) 85% 60% / var(--chip-bg-a)); border: 1px solid hsl(var(--h) 85% 62% / var(--chip-bd-a)); }
.status-pill i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; flex: none; }
.status-pill.is-live i { animation: dotPulse 1.6s ease-in-out infinite; }
.status-pill.sm { height: 22px; font-size: 11.5px; padding-inline: 8px 9px; }
.status-pill.h-gray { color: var(--text-2); background: var(--surface-2); border-color: var(--border-strong); }

.tag { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 6px; font-size: 11px; font-weight: 600; letter-spacing: .02em; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.tag svg { width: 12px; height: 12px; }
.tag.warn { color: var(--amber); background: color-mix(in srgb, var(--amber) 10%, transparent); border-color: color-mix(in srgb, var(--amber) 25%, transparent); }
.tag.bad { color: var(--rose); background: color-mix(in srgb, var(--rose) 10%, transparent); border-color: color-mix(in srgb, var(--rose) 25%, transparent); }
.tag.good { color: var(--green); background: color-mix(in srgb, var(--green) 10%, transparent); border-color: color-mix(in srgb, var(--green) 25%, transparent); }
.tag.info { color: var(--cyan); background: color-mix(in srgb, var(--cyan) 10%, transparent); border-color: color-mix(in srgb, var(--cyan) 25%, transparent); }
.tag.accent { color: var(--violet); background: color-mix(in srgb, var(--violet) 10%, transparent); border-color: color-mix(in srgb, var(--violet) 25%, transparent); }

.risk { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; }
.risk i { width: 8px; height: 8px; border-radius: 50%; }
.risk.good i { background: var(--green); box-shadow: 0 0 8px var(--green); }
.risk.mid i { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.risk.bad i { background: var(--rose); box-shadow: 0 0 8px var(--rose); }
.risk.new i { background: var(--gray); }

/* ---------- 11. cards & KPIs ---------- */

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm), inset 0 1px 0 var(--highlight);
  animation: fadeUp .55s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 45ms);
  transition: border-color .3s;
  min-width: 0;
}
.card:hover { border-color: var(--border-strong); }
.card.flat { box-shadow: none; animation: none; }
.card.tight { padding: 14px; gap: 12px; }
.card.pad-0 { padding: 0; gap: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.card.pad-0 > .card-head { padding: 16px 18px 12px; }
.card-head > div.grow { min-width: 0; }
.card-title { font-size: 14.5px; font-weight: 600; letter-spacing: -.005em; display: flex; align-items: center; gap: 8px; }
.card-sub { margin-top: 2px; font-size: 12.5px; color: var(--text-3); }
.card-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; background: var(--surface-3); color: var(--text); flex: none; box-shadow: inset 0 1px 0 var(--highlight); }
.card-icon svg { width: 18px; height: 18px; }
.card-icon.grad { background: var(--grad); color: #fff; box-shadow: 0 8px 22px -8px rgba(var(--a0-rgb), .85), inset 0 1px 0 rgba(255, 255, 255, .25); }
.card-icon.tint { color: hsl(var(--h) 85% var(--chip-l)); background: hsl(var(--h) 85% 60% / var(--chip-bg-a)); border: 1px solid hsl(var(--h) 85% 62% / var(--chip-bd-a)); }
.card-foot { display: flex; align-items: center; gap: 8px; padding-top: 14px; border-top: 1px dashed var(--border-strong); }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.kpi {
  --h: 262;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 15px 16px 14px;
  border-radius: 18px;
  background: linear-gradient(160deg, hsl(var(--h) 85% 60% / .07), var(--surface) 55%);
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 0 var(--highlight);
  overflow: hidden;
  animation: fieldIn .55s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 50ms);
  transition: transform .3s var(--ease-out), border-color .3s;
  text-align: start;
  color: inherit;
}
a.kpi:hover, button.kpi:hover { transform: translateY(-2px); border-color: var(--border-strong); text-decoration: none; }
.kpi-label { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 500; color: var(--text-2); }
.kpi-label svg { width: 15px; height: 15px; color: hsl(var(--h) 85% var(--chip-l)); }
.kpi-value { font-family: var(--mono); font-size: 26px; font-weight: 500; letter-spacing: -.03em; line-height: 1.15; color: var(--text); font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: 13px; color: var(--text-3); margin-inline-start: 4px; letter-spacing: 0; }
.kpi-foot { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-3); min-height: 16px; }
.delta { font-family: var(--mono); font-size: 11px; font-weight: 600; }
.delta.up { color: var(--green); } .delta.down { color: var(--rose); }
.kpi .spark { position: absolute; inset-inline-end: 10px; bottom: 10px; width: 84px; height: 30px; opacity: .9; }
.kpi .spark path.line { fill: none; stroke: hsl(var(--h) 85% 62%); stroke-width: 1.6; }
.kpi .spark path.area { fill: hsl(var(--h) 85% 60% / .14); stroke: none; }

.meter { display: flex; flex-direction: column; gap: 7px; }
.meter-top { display: flex; align-items: baseline; gap: 8px; font-size: 12.5px; color: var(--text-2); }
.meter-top b { font-family: var(--mono); font-weight: 500; color: var(--text); }
.meter-track { position: relative; height: 7px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.meter-fill { position: relative; height: 100%; border-radius: inherit; background: var(--grad); box-shadow: 0 0 14px rgba(var(--a1-rgb), .55); transform-origin: left; animation: growX 1s var(--ease-out) both; overflow: hidden; }
:root[dir="rtl"] .meter-fill { transform-origin: right; }
.meter-fill::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent); transform: translateX(-100%); animation: sheen 2.8s var(--ease) 1s infinite; }
.meter.good .meter-fill { background: linear-gradient(90deg, #10b981, #34d399); box-shadow: 0 0 12px rgba(52, 211, 153, .45); }
.meter.mid .meter-fill { background: linear-gradient(90deg, #f59e0b, #fbbf24); box-shadow: 0 0 12px rgba(251, 191, 36, .4); }
.meter.bad .meter-fill { background: linear-gradient(90deg, #e11d48, #fb7185); box-shadow: 0 0 12px rgba(251, 113, 133, .45); }

.stat-row { display: flex; flex-wrap: wrap; gap: 8px; }
.stat { display: inline-flex; align-items: baseline; gap: 7px; padding: 8px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; color: var(--text-2); }
.stat b { font-family: var(--mono); font-size: 16px; font-weight: 500; color: var(--text); }

.kv-list { display: flex; flex-direction: column; }
.kv { display: grid; grid-template-columns: minmax(110px, 38%) minmax(0, 1fr); gap: 12px; align-items: baseline; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
.kv:last-child { border-bottom: 0; }
.kv > span:first-child { color: var(--text-3); font-size: 12.5px; }
.kv > span:last-child { min-width: 0; overflow-wrap: anywhere; }

/* ---------- 12. tables ---------- */

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar .search { flex: 1 1 260px; max-width: 420px; }
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.table-card { border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm), inset 0 1px 0 var(--highlight); overflow: hidden; animation: fadeUp .55s var(--ease-out) .05s both; }
.table-scroll { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.tbl th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 40px;
  padding: 0 12px;
  text-align: start;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-3);
  background: color-mix(in srgb, var(--panel-solid) 92%, transparent);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}
:root[lang="ar"] .tbl th { letter-spacing: 0; font-size: 12px; }
.tbl th.sortable { cursor: pointer; }
.tbl th.sortable:hover { color: var(--text); }
.tbl th .sort { display: inline-block; width: 10px; margin-inline-start: 4px; opacity: .8; }
.tbl td { height: 54px; padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background .15s; }
.tbl tbody tr:hover { background: var(--row-hover); }
.tbl tbody tr.is-selected { background: var(--row-sel); }
.tbl tbody tr.is-click { cursor: pointer; }
.tbl tbody tr.is-flash { animation: rowFlash 1.6s var(--ease-out); }
.tbl .c-check { width: 44px; padding-inline-end: 0; }
.tbl .c-num { text-align: end; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .c-actions { width: 1%; white-space: nowrap; text-align: end; }
.tbl .c-min { width: 1%; white-space: nowrap; }
.tbl .cell-main { font-weight: 500; color: var(--text); white-space: nowrap; }
.tbl .cell-sub { font-size: 12px; color: var(--text-3); white-space: nowrap; margin-top: 1px; }
.tbl .tracking { font-family: var(--mono); font-size: 12.5px; font-weight: 500; letter-spacing: .02em; }
.tbl.compact td { height: 42px; padding-top: 5px; padding-bottom: 5px; }
.tbl tfoot td { font-weight: 600; background: var(--surface-2); }
.tbl input.input { height: 32px; font-size: 13px; }

.table-foot { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-3); flex-wrap: wrap; }
.pager { display: inline-flex; align-items: center; gap: 4px; margin-inline-start: auto; }
.pager .num { min-width: 70px; text-align: center; color: var(--text-2); }

.bulkbar {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 16px;
  padding-inline: 16px 8px;
  border-radius: 18px;
  background: color-mix(in srgb, var(--panel-solid) 90%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow), 0 0 60px -20px rgba(var(--a0-rgb), .6);
  animation: toastIn .45s var(--spring) both;
  max-width: calc(100vw - 24px);
  overflow-x: auto;
}
.bulkbar .count { font-weight: 600; white-space: nowrap; margin-inline-end: 6px; }

/* ---------- 13. drawer & modal ---------- */

.overlay { position: fixed; inset: 0; z-index: 70; background: rgba(4, 5, 10, .5); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: fadeIn .25s var(--ease) both; }
:root[data-theme="light"] .overlay { background: rgba(20, 24, 50, .28); }
.overlay.is-out { animation: fadeOut .22s var(--ease) forwards; }

.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  inset-inline-end: 0;
  z-index: 71;
  width: min(620px, 100vw);
  display: flex;
  flex-direction: column;
  background: color-mix(in srgb, var(--panel-solid) 94%, transparent);
  backdrop-filter: blur(28px) saturate(150%);
  -webkit-backdrop-filter: blur(28px) saturate(150%);
  border-inline-start: 1px solid var(--border-strong);
  box-shadow: -30px 0 80px -30px rgba(0, 0, 0, .7);
  animation: drawerIn .45s var(--ease-out) both;
}
:root[dir="rtl"] .drawer { animation-name: drawerInRtl; }
.drawer.is-out { animation: drawerOut .3s var(--ease) forwards; }
:root[dir="rtl"] .drawer.is-out { animation-name: drawerOutRtl; }
.drawer.wide { width: min(860px, 100vw); }
.drawer-head { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 12px 16px 12px 22px; padding-inline: 22px 16px; border-bottom: 1px solid var(--border); flex: none; }
.drawer-title { flex: 1; min-width: 0; }
.drawer-title h2 { font-size: 17px; font-weight: 600; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.drawer-title p { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.drawer-body { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 22px 28px; display: flex; flex-direction: column; gap: 18px; }
.drawer-foot { display: flex; align-items: center; gap: 8px; padding: 12px 16px 12px 22px; padding-inline: 22px 16px; border-top: 1px solid var(--border); flex: none; flex-wrap: wrap; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }

.modal-wrap { position: fixed; inset: 0; z-index: 72; display: flex; padding: 24px 16px; overflow-y: auto; }
.modal {
  margin: auto;
  width: min(520px, 100%);
  display: flex;
  flex-direction: column;
  border-radius: 24px;
  background: color-mix(in srgb, var(--panel-solid) 96%, transparent);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow), inset 0 1px 0 var(--highlight), 0 0 90px -30px rgba(var(--a0-rgb), .5);
  animation: modalIn .45s var(--spring) both;
}
.modal.wide { width: min(780px, 100%); }
.modal.is-out { animation: modalOut .2s var(--ease) forwards; }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 18px 6px 22px; padding-inline: 22px 18px; }
.modal-head h2 { flex: 1; font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.modal-head p { font-size: 13px; color: var(--text-2); margin-top: 3px; }
.modal-body { padding: 14px 22px 6px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 16px 22px 20px; flex-wrap: wrap; }

/* ---------- 14. menus & palette ---------- */

.menu {
  position: fixed;
  z-index: 80;
  min-width: 210px;
  max-width: min(320px, calc(100vw - 16px));
  padding: 6px;
  border-radius: 15px;
  background: color-mix(in srgb, var(--panel-solid) 94%, transparent);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  animation: menuIn .22s var(--ease-out) both;
}
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 10px; border-radius: 10px; font-size: 13.5px; color: var(--text-2); text-align: start; text-decoration: none; }
.menu-item:hover, .menu-item.is-active { background: var(--surface-2); color: var(--text); text-decoration: none; }
.menu-item svg { width: 16px; height: 16px; }
.menu-item.danger { color: var(--rose); }
.menu-item .check-mark { margin-inline-start: auto; color: var(--accent); }
.menu-sep { height: 1px; margin: 5px 4px; background: var(--border); }
.menu-label { padding: 8px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }

.palette-wrap { position: fixed; inset: 0; z-index: 90; display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; }
.palette {
  width: min(640px, 100%);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  border-radius: 22px;
  background: color-mix(in srgb, var(--panel-solid) 95%, transparent);
  backdrop-filter: blur(30px) saturate(160%);
  -webkit-backdrop-filter: blur(30px) saturate(160%);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow), 0 0 100px -30px rgba(var(--a0-rgb), .6);
  animation: modalIn .35s var(--spring) both;
  overflow: hidden;
}
.palette-input { display: flex; align-items: center; gap: 12px; padding: 0 18px; height: 58px; border-bottom: 1px solid var(--border); }
.palette-input svg { width: 19px; height: 19px; color: var(--text-3); }
.palette-input input { flex: 1; height: 100%; border: 0; outline: none; background: none; font-size: 16px; }
.palette-list { flex: 1; overflow-y: auto; padding: 8px; }
.pal-group { padding: 10px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.pal-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 10px; border-radius: 12px; text-align: start; color: var(--text-2); }
.pal-item.is-active { background: var(--surface-3); color: var(--text); }
.pal-item .pal-icon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 10px; background: var(--surface-2); flex: none; }
.pal-item .pal-icon svg { width: 16px; height: 16px; }
.pal-item .pal-text { flex: 1; min-width: 0; }
.pal-item .pal-title { font-size: 14px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pal-item .pal-sub { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pal-empty { padding: 30px 10px; text-align: center; color: var(--text-3); font-size: 13.5px; }
.pal-foot { display: flex; gap: 14px; padding: 9px 16px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--text-3); }

/* ---------- 15. toasts ---------- */

.toasts { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 16px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel-solid) 90%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  font-size: 13.5px;
  font-weight: 500;
  pointer-events: auto;
  animation: toastIn .5s var(--spring) both;
}
.toast::after { content: ""; position: absolute; left: 0; bottom: 0; height: 2px; width: 100%; background: var(--grad); transform-origin: left; animation: toastTimer var(--toast-ms, 2800ms) linear forwards; }
.toast svg { width: 16px; height: 16px; flex: none; }
.toast.ok svg { color: var(--green); }
.toast.err svg { color: var(--rose); }
.toast.err::after { background: var(--rose); }
.toast.info svg { color: var(--accent); }
.toast.is-out { animation: toastOut .3s var(--ease) forwards; }
.toast .toast-act { margin-inline-start: 6px; color: var(--accent-2); font-weight: 600; }

/* ---------- 16. feedback ---------- */

.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 46px 20px; text-align: center; color: var(--text-3); }
.empty-state .es-icon { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 18px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); margin-bottom: 4px; box-shadow: inset 0 1px 0 var(--highlight); }
.empty-state .es-icon svg { width: 24px; height: 24px; }
.empty-state h3 { font-size: 15.5px; font-weight: 600; color: var(--text); }
.empty-state p { font-size: 13.5px; max-width: 420px; }

.skel { display: block; height: 12px; border-radius: 99px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.skel.block { height: 90px; border-radius: 16px; }
.skel-rows { display: flex; flex-direction: column; gap: 14px; padding: 18px; }

.loading-line { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 200; background: var(--grad); transform-origin: left; animation: loadLine 1.2s var(--ease) infinite; box-shadow: 0 0 12px rgba(var(--a1-rgb), .9); }

.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: spin .7s linear infinite; flex: none; }

.callout { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; font-size: 13.5px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); }
.callout svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.callout.info { background: color-mix(in srgb, var(--cyan) 7%, transparent); border-color: color-mix(in srgb, var(--cyan) 22%, transparent); }
.callout.info svg { color: var(--cyan); }
.callout.warn { background: color-mix(in srgb, var(--amber) 8%, transparent); border-color: color-mix(in srgb, var(--amber) 25%, transparent); }
.callout.warn svg { color: var(--amber); }
.callout.bad { background: color-mix(in srgb, var(--rose) 8%, transparent); border-color: color-mix(in srgb, var(--rose) 25%, transparent); }
.callout.bad svg { color: var(--rose); }
.callout.good { background: color-mix(in srgb, var(--green) 8%, transparent); border-color: color-mix(in srgb, var(--green) 25%, transparent); }
.callout.good svg { color: var(--green); }
.callout b { color: var(--text); }

.timeline { position: relative; display: flex; flex-direction: column; gap: 2px; padding-inline-start: 4px; }
.tl-item { position: relative; display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 12px; padding-bottom: 16px; animation: fieldIn .45s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 40ms); }
.tl-item::before { content: ""; position: absolute; inset-inline-start: 10px; top: 22px; bottom: 0; width: 2px; background: var(--border-strong); border-radius: 2px; }
.tl-item:last-child::before { display: none; }
.tl-dot { --h: 230; position: relative; z-index: 1; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: hsl(var(--h) 85% 60% / .16); border: 1.5px solid hsl(var(--h) 85% 62% / .55); }
.tl-dot::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: hsl(var(--h) 85% 62%); box-shadow: 0 0 10px hsl(var(--h) 85% 62% / .8); }
.tl-item:first-child .tl-dot { box-shadow: 0 0 0 4px hsl(var(--h) 85% 60% / .12); }
.tl-title { font-size: 13.5px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tl-meta { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.tl-note { margin-top: 5px; font-size: 13px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 7px 10px; overflow-wrap: anywhere; }

.progress-steps { display: flex; align-items: center; gap: 0; }
.ps-step { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 7px; position: relative; font-size: 11.5px; color: var(--text-3); text-align: center; }
.ps-step::before { content: ""; position: absolute; top: 11px; inset-inline-start: calc(-50% + 14px); inset-inline-end: calc(50% + 14px); height: 2px; background: var(--border-strong); border-radius: 2px; }
.ps-step:first-child::before { display: none; }
.ps-step i { position: relative; z-index: 1; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: 1.5px solid var(--border-strong); }
.ps-step i svg { width: 13px; height: 13px; stroke-width: 2.6; opacity: 0; }
.ps-step.is-done { color: var(--text-2); }
.ps-step.is-done i { background: var(--grad); border-color: transparent; color: #fff; }
.ps-step.is-done i svg { opacity: 1; }
.ps-step.is-done::before, .ps-step.is-current::before { background: var(--grad); }
.ps-step.is-current { color: var(--text); font-weight: 600; }
.ps-step.is-current i { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(var(--a1-rgb), .2); background: var(--bg-2); }
.ps-step.is-current i::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--grad); animation: dotPulse 1.6s ease-in-out infinite; }
.ps-step.is-bad i { background: var(--rose); border-color: transparent; color: #fff; }
.ps-step.is-bad i svg { opacity: 1; }

/* ---------- 17. motion ---------- */

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes fadeDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@keyframes fieldIn { from { opacity: 0; transform: translateY(8px) scale(.98); filter: blur(3px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes chipIn { from { opacity: 0; transform: scale(.8); } to { opacity: 1; transform: none; } }
@keyframes drawerIn { from { transform: translateX(104%); } to { transform: none; } }
@keyframes drawerOut { to { transform: translateX(104%); } }
@keyframes drawerInRtl { from { transform: translateX(-104%); } to { transform: none; } }
@keyframes drawerOutRtl { to { transform: translateX(-104%); } }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes modalOut { to { opacity: 0; transform: translateY(8px) scale(.97); } }
@keyframes menuIn { from { opacity: 0; transform: translateY(-6px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.94); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px) scale(.96); } }
@keyframes toastTimer { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes sheen { 0% { transform: translateX(-100%); } 60%, 100% { transform: translateX(100%); } }
@keyframes growX { from { transform: scaleX(0); } to { transform: none; } }
@keyframes ping { 0% { transform: scale(.6); opacity: .8; } 80%, 100% { transform: scale(1.8); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes spinAngle { to { --angle: 360deg; } }
@keyframes ripple { to { transform: scale(26); opacity: 0; } }
@keyframes dotPulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .55; transform: scale(.75); } }
@keyframes shake { 10%, 90% { transform: translateX(-1px); } 20%, 80% { transform: translateX(3px); } 30%, 50%, 70% { transform: translateX(-6px); } 40%, 60% { transform: translateX(6px); } }
@keyframes rowFlash { 0% { background: color-mix(in srgb, var(--accent) 22%, transparent); } 100% { background: transparent; } }
@keyframes loadLine { 0% { transform: scaleX(0); transform-origin: left; } 50% { transform: scaleX(1); transform-origin: left; } 50.1% { transform-origin: right; } 100% { transform: scaleX(0); transform-origin: right; } }
@keyframes ibisNod { 0%, 74%, 100% { transform: rotate(0); } 82% { transform: rotate(2deg); } 91% { transform: rotate(-.8deg); } }
@keyframes parcelSway { 0%, 100% { transform: rotate(-5deg); } 50% { transform: rotate(5deg); } }
@keyframes drift1 { from { transform: translate(0, 0) scale(1); } to { transform: translate(14vw, 10vh) scale(1.18); } }
@keyframes drift2 { from { transform: translate(0, 0) scale(1.1); } to { transform: translate(-12vw, 14vh) scale(.92); } }
@keyframes drift3 { from { transform: translate(0, 0) scale(.95); } to { transform: translate(-16vw, -10vh) scale(1.15); } }
@keyframes popIn { 0% { transform: scale(.6); opacity: 0; } 60% { transform: scale(1.08); opacity: 1; } 100% { transform: none; } }

/* view transitions between pages */
::view-transition-old(main-view) { animation: vtOut .18s var(--ease) both; }
::view-transition-new(main-view) { animation: vtIn .36s var(--ease-out) both; }
@keyframes vtOut { to { opacity: 0; transform: translateY(-6px); filter: blur(4px); } }
@keyframes vtIn { from { opacity: 0; transform: translateY(10px); filter: blur(4px); } }
html.theme-vt .view { view-transition-name: none; }
html.theme-vt::view-transition-old(root), html.theme-vt::view-transition-new(root) { animation: none; mix-blend-mode: normal; }

body.is-intro .side { animation: introSide .8s var(--ease-out) both; }
body.is-intro .topbar { animation: fadeDown .7s var(--ease-out) .06s both; }
@keyframes introSide { from { opacity: 0; transform: translateX(-24px); } to { opacity: 1; transform: none; } }
:root[dir="rtl"] body.is-intro .side { animation-name: introSideRtl; }
@keyframes introSideRtl { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }

/* ---------- 18. responsive ---------- */

@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search-btn { min-width: 0; width: 36px; padding: 0; justify-content: center; border-color: transparent; background: none; }
  .search-btn span, .search-btn kbd { display: none; }
}

@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .only-mobile { display: grid !important; }
  .side {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    height: auto;
    z-index: 60;
    width: min(86vw, 300px);
    padding-top: calc(16px + env(safe-area-inset-top));
    background: color-mix(in srgb, var(--panel-solid) 96%, transparent);
    transform: translateX(-104%);
    transition: transform .45s var(--ease-out);
    box-shadow: var(--shadow);
  }
  :root[dir="rtl"] .side { transform: translateX(104%); }
  .shell.side-open .side { transform: none; }
  .backdrop { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, .45); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); opacity: 0; pointer-events: none; transition: opacity .35s; }
  .shell.side-open .backdrop { opacity: 1; pointer-events: auto; }
  body.is-intro .side { animation: none; }
  .topbar { padding-inline: 10px; padding-top: env(safe-area-inset-top); height: calc(58px + env(safe-area-inset-top)); gap: 4px; }
  .page { padding: 18px 16px 90px; gap: 14px; }
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .live .live-text { display: none; }
}

@media (max-width: 640px) {
  body { font-size: 14px; }
  .page-title { font-size: 23px; }
  .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .form-grid, .form-grid.three { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .kpi { padding: 12px 13px; border-radius: 15px; }
  .kpi-value { font-size: 21px; }
  .kpi .spark { display: none; }
  .card { padding: 16px; border-radius: 19px; }
  .drawer { width: 100vw; border-inline-start: 0; }
  .drawer-body { padding: 16px 16px 24px; }
  .modal-wrap { padding: 0; align-items: flex-end; }
  .modal { width: 100%; margin: auto 0 0; border-radius: 24px 24px 0 0; padding-bottom: env(safe-area-inset-bottom); animation-name: sheetIn; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .palette-wrap { padding-top: calc(10px + env(safe-area-inset-top)); }
  .pal-foot { display: none; }
  .tbl td { height: 50px; }
  .table-foot .hide-sm { display: none; }
}
@keyframes sheetIn { from { transform: translateY(100%); } to { transform: none; } }

@media (hover: none) {
  .spot::before { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0ms !important;
    transition-duration: .001ms !important;
  }
  .aurora span { animation: none; }
}
