/* ─────────────────────────────────────────────────────────────────
   Shadow Swipe Admin — Design System
   Tokens, base styles, utilities, and component primitives.
   ───────────────────────────────────────────────────────────────── */

:root {
  /* ── Palette ── */
  --bg:             #06070b;
  --bg-1:           #0b0d14;
  --bg-2:           #11141d;
  --bg-3:           #161a25;
  --bg-overlay:     rgba(6, 7, 11, 0.72);

  --text:           #e7e9ee;
  --text-dim:       #b3b7c2;
  --text-mute:      #7a8091;
  --text-faint:     #515668;

  --primary:        #00ff7f;
  --primary-glow:   rgba(0, 255, 127, 0.45);
  --primary-dim:    rgba(0, 255, 127, 0.12);
  --primary-border: rgba(0, 255, 127, 0.32);

  --cyan:           #00e5ff;
  --cyan-glow:      rgba(0, 229, 255, 0.45);
  --cyan-dim:       rgba(0, 229, 255, 0.12);

  --violet:         #8b5cf6;
  --violet-dim:     rgba(139, 92, 246, 0.14);

  --gold:           #ffd84d;
  --gold-dim:       rgba(255, 216, 77, 0.14);

  --danger:         #ff5a6b;
  --danger-dim:     rgba(255, 90, 107, 0.14);

  --warn:           #ffb46a;
  --warn-dim:       rgba(255, 180, 106, 0.14);

  --success:        var(--primary);
  --success-dim:    var(--primary-dim);

  --info:           var(--cyan);
  --info-dim:       var(--cyan-dim);

  --border:         rgba(255, 255, 255, 0.06);
  --border-strong:  rgba(255, 255, 255, 0.12);

  /* ── Typography ── */
  --font-body:      'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:      'JetBrains Mono', 'SF Mono', Consolas, monospace;
  --font-heading:   'Inter', -apple-system, sans-serif;

  /* ── Spacing (4px step) ── */
  --sp-1: 4px;   --sp-2: 8px;   --sp-3: 12px;  --sp-4: 16px;
  --sp-5: 20px;  --sp-6: 24px;  --sp-8: 32px;  --sp-10: 40px;
  --sp-12: 48px; --sp-16: 64px; --sp-20: 80px;

  /* ── Radius ── */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px; --r-pill: 9999px;

  /* ── Shadows ── */
  --sh-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --sh-2: 0 6px 18px rgba(0, 0, 0, 0.35);
  --sh-3: 0 14px 36px rgba(0, 0, 0, 0.45);
  --sh-glow: 0 0 0 1px var(--primary-border), 0 10px 30px -8px var(--primary-glow);

  /* ── Easing / Duration ── */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 140ms;
  --dur: 220ms;
  --dur-slow: 420ms;

  /* ── Layout ── */
  --sidebar-w: 260px;
  --sidebar-collapsed-w: 72px;
  --topbar-h: 64px;
}

/* ─── Base ─────────────────────────────────────────────── */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; max-width: 100%; }
html, body { overflow-x: clip; }
/* Fallback for older browsers that don't support `clip` */
@supports not (overflow: clip) {
  html, body { overflow-x: hidden; }
}

body {
  background:
    radial-gradient(1200px 600px at 0% -10%, rgba(0, 255, 127, 0.05), transparent 60%),
    radial-gradient(900px 500px at 100% -5%, rgba(139, 92, 246, 0.04), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-1) 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; transition: color var(--dur-fast) var(--ease); }
a:hover { color: var(--cyan); }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1.2;
  margin: 0;
}

code, pre, kbd { font-family: var(--font-mono); }

/* ─── Scrollbar ────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ─── Selection ────────────────────────────────────────── */
::selection { background: var(--primary); color: var(--bg); }

/* ─── Admin shell layout ──────────────────────────────── */
.admin-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  min-height: 100dvh;
  transition: grid-template-columns var(--dur) var(--ease);
}
.admin-shell.is-collapsed { grid-template-columns: var(--sidebar-collapsed-w) 1fr; }

.admin-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
}

.admin-topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: var(--sp-4);
  height: var(--topbar-h);
  padding: 0 var(--sp-6);
  background: rgba(11, 13, 20, 0.78);
  backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}
.admin-topbar::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  opacity: 0.35;
}
.topbar-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  background: transparent; border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-dim);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.topbar-toggle:hover { color: var(--primary); border-color: var(--primary-border); }

.topbar-search {
  flex: 1;
  max-width: 420px;
  position: relative;
}
.topbar-search input {
  width: 100%;
  padding: 9px 14px 9px 38px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  transition: all var(--dur-fast) var(--ease);
}
.topbar-search input::placeholder { color: var(--text-faint); }
.topbar-search input:focus {
  outline: none;
  border-color: var(--primary-border);
  box-shadow: 0 0 0 3px var(--primary-dim);
}
.topbar-search .s-icon {
  position: absolute; top: 50%; left: 12px;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: 0.85rem;
  pointer-events: none;
}

.topbar-user {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: var(--sp-3);
  padding: 6px 10px 6px 6px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--bg-2);
}
.topbar-user__avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  color: var(--bg);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.8rem;
}
.topbar-user__name {
  font-size: 0.82rem;
  color: var(--text);
  font-weight: 500;
}
.topbar-user__role {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

/* ── Sign-out button — lives outside the user pill so it's always visible ── */
.topbar-logout-form {
  margin: 0;
  flex-shrink: 0;
}
.topbar-logout {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-dim);
  background: rgba(255, 90, 107, 0.08);
  border: 1px solid rgba(255, 90, 107, 0.22);
  border-radius: var(--r-md);
  cursor: pointer;
  transition:
    color var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease);
}
.topbar-logout:hover {
  color: var(--danger);
  background: rgba(255, 90, 107, 0.14);
  border-color: rgba(255, 90, 107, 0.4);
  transform: translateY(-1px);
}
.topbar-logout:active { transform: translateY(0); }
.topbar-logout i {
  font-size: 0.9rem;
  color: var(--danger);
}

.admin-content {
  flex: 1;
  padding: var(--sp-8) var(--sp-6);
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  min-width: 0;
}
.admin-content img, .admin-content svg { max-width: 100%; }
@media (max-width: 767.98px) {
  /* Add an extra bottom pad + the iOS safe-area so the last row of content
     (typically a submit button) clears the dynamic Safari chrome. */
  .admin-content {
    padding: var(--sp-5) var(--sp-4) calc(var(--sp-10) + env(safe-area-inset-bottom, 0px));
  }
}
@media (max-width: 575.98px) {
  .admin-content {
    padding: var(--sp-4) var(--sp-3) calc(var(--sp-10) + env(safe-area-inset-bottom, 0px));
  }
}

/* ─── Page Header ──────────────────────────────────────── */
.x-page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-6);
  padding-bottom: var(--sp-5);
  margin-bottom: var(--sp-6);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.x-page-header__copy { min-width: 0; }
.x-page-header__eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  color: var(--text-mute);
  text-transform: uppercase;
  margin-bottom: var(--sp-2);
}
.x-page-header__eyebrow::before {
  content: '';
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 6px var(--primary-glow);
}
.x-page-header__title {
  font-size: clamp(1.4rem, 2.3vw, 1.85rem);
  font-weight: 600;
  letter-spacing: -0.022em;
  display: flex; align-items: center; gap: var(--sp-3);
  color: var(--text);
}
.x-page-header__title i {
  color: var(--primary);
  font-size: 0.82em;
}
.x-page-header__subtitle {
  margin: 6px 0 0;
  color: var(--text-mute);
  font-size: 0.9rem;
  max-width: 72ch;
  line-height: 1.5;
}
.x-page-header__actions {
  display: flex; align-items: center; gap: var(--sp-2);
  flex-wrap: wrap;
}

/* ─── Button ───────────────────────────────────────────── */
.x-btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  line-height: 1.2;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition:
    background-color var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease);
  text-decoration: none;
  white-space: nowrap;
  vertical-align: middle;
}
.x-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.x-btn:disabled, .x-btn[aria-disabled="true"] {
  opacity: 0.55; cursor: not-allowed;
}
.x-btn i { font-size: 0.85em; }

/* Sizes */
.x-btn--sm { padding: 6px 12px; font-size: 0.78rem; }
.x-btn--lg { padding: 12px 22px; font-size: 0.95rem; }
.x-btn--icon { padding: 8px; width: 34px; height: 34px; }

/* Variants */
.x-btn--primary {
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  color: var(--bg);
  box-shadow: 0 6px 18px -6px var(--primary-glow), inset 0 1px 0 rgba(255,255,255,0.25);
}
.x-btn--primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px -8px var(--primary-glow), inset 0 1px 0 rgba(255,255,255,0.3);
  color: var(--bg);
}
.x-btn--ghost {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-dim);
  border-color: var(--border);
}
.x-btn--ghost:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.06);
}
.x-btn--outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary-border);
}
.x-btn--outline:hover:not(:disabled) {
  background: var(--primary-dim);
  color: var(--primary);
}
.x-btn--danger {
  background: var(--danger-dim);
  color: var(--danger);
  border-color: var(--danger);
}
.x-btn--danger:hover:not(:disabled) {
  background: var(--danger);
  color: var(--bg);
}
.x-btn--subtle {
  background: var(--bg-2);
  color: var(--text-dim);
  border-color: var(--border);
}
.x-btn--subtle:hover:not(:disabled) {
  background: var(--bg-3);
  color: var(--text);
}

/* ─── Card ─────────────────────────────────────────────── */
.x-card {
  position: relative;
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow:
    0 16px 40px -24px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
  overflow: hidden;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.x-card--hover:hover {
  border-color: var(--border-strong);
  box-shadow:
    0 22px 52px -24px rgba(0, 0, 0, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transform: translateY(-2px);
}
.x-card--accent::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--primary) 50%, transparent);
  opacity: 0.6;
}
.x-card__head {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
}
.x-card__title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}
.x-card__title i {
  color: var(--primary); margin-right: 6px;
}
.x-card__actions { margin-left: auto; display: inline-flex; gap: var(--sp-2); }
.x-card__body { padding: var(--sp-5); }
.x-card__foot {
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border);
  background: rgba(6, 7, 11, 0.35);
}

/* ─── Stat Tile ────────────────────────────────────────── */
.x-stat {
  position: relative;
  padding: var(--sp-5);
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition:
    transform var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
}
.x-stat:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow:
    0 18px 40px -18px rgba(0, 0, 0, 0.6),
    0 6px 14px -8px color-mix(in oklab, var(--x-stat-accent, var(--primary)) 40%, transparent);
}
.x-stat::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--x-stat-accent, var(--primary)) 50%, transparent);
  opacity: 0.6;
}
.x-stat__head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.x-stat__icon {
  width: 42px; height: 42px;
  border-radius: var(--r-md);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--x-stat-accent, var(--primary));
  background: var(--x-stat-bg, var(--primary-dim));
  border: 1px solid var(--x-stat-border, var(--primary-border));
  font-size: 1.05rem;
}
.x-stat__trend {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: var(--r-pill);
  background: var(--bg-3);
  color: var(--text-mute);
}
.x-stat__trend--up { color: var(--primary); background: var(--primary-dim); }
.x-stat__trend--down { color: var(--danger); background: var(--danger-dim); }
.x-stat__value {
  font-family: var(--font-heading);
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.x-stat__label {
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--text-mute);
  font-weight: 500;
  letter-spacing: 0;
  font-family: var(--font-body);
}

/* Accent variants: set CSS vars on the element */
.x-stat--primary { --x-stat-accent: var(--primary); --x-stat-bg: var(--primary-dim); --x-stat-border: var(--primary-border); }
.x-stat--cyan    { --x-stat-accent: var(--cyan);    --x-stat-bg: var(--cyan-dim);    --x-stat-border: var(--cyan-dim); }
.x-stat--violet  { --x-stat-accent: var(--violet);  --x-stat-bg: var(--violet-dim);  --x-stat-border: var(--violet-dim); }
.x-stat--gold    { --x-stat-accent: var(--gold);    --x-stat-bg: var(--gold-dim);    --x-stat-border: var(--gold-dim); }
.x-stat--danger  { --x-stat-accent: var(--danger);  --x-stat-bg: var(--danger-dim);  --x-stat-border: var(--danger-dim); }
.x-stat--warn    { --x-stat-accent: var(--warn);    --x-stat-bg: var(--warn-dim);    --x-stat-border: var(--warn-dim); }

/* ─── Badge ────────────────────────────────────────────── */
.x-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  white-space: nowrap;
  line-height: 1.5;
}
.x-badge__dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
  flex-shrink: 0;
}
.x-badge--primary { color: var(--primary); background: var(--primary-dim); border-color: var(--primary-border); }
.x-badge--cyan    { color: var(--cyan);    background: var(--cyan-dim);    border-color: var(--cyan-dim); }
.x-badge--gold    { color: var(--gold);    background: var(--gold-dim);    border-color: var(--gold-dim); }
.x-badge--danger  { color: var(--danger);  background: var(--danger-dim);  border-color: var(--danger-dim); }
.x-badge--warn    { color: var(--warn);    background: var(--warn-dim);    border-color: var(--warn-dim); }
.x-badge--muted   { color: var(--text-mute); background: var(--bg-3); border-color: var(--border); }

/* ─── Alert ────────────────────────────────────────────── */
.x-alert {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  margin-bottom: var(--sp-4);
  font-size: 0.88rem;
  line-height: 1.5;
}
.x-alert__icon { font-size: 1rem; margin-top: 1px; flex-shrink: 0; }
.x-alert__body { flex: 1; min-width: 0; }
.x-alert__close {
  background: transparent; border: 0;
  color: inherit; opacity: 0.6; cursor: pointer;
  padding: 0 4px; font-size: 1rem;
  transition: opacity var(--dur-fast);
}
.x-alert__close:hover { opacity: 1; }

.x-alert--success { color: var(--primary); background: var(--primary-dim); border-color: var(--primary-border); }
.x-alert--danger  { color: var(--danger);  background: var(--danger-dim);  border-color: var(--danger); }
.x-alert--warn    { color: var(--warn);    background: var(--warn-dim);    border-color: var(--warn); }
.x-alert--info    { color: var(--cyan);    background: var(--cyan-dim);    border-color: var(--cyan); }

/* ─── Form Field ───────────────────────────────────────── */
.x-field { margin-bottom: var(--sp-4); }
.x-field__label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--text-dim);
  margin-bottom: 8px;
  font-family: var(--font-body);
}
.x-field__label .req { color: var(--danger); margin-left: 2px; }

.x-input, .x-select, .x-textarea {
  display: block;
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.9rem;
  line-height: 1.4;
  transition: all var(--dur-fast) var(--ease);
}
.x-textarea { min-height: 90px; resize: vertical; }
.x-input::placeholder, .x-textarea::placeholder { color: var(--text-faint); }

.x-input:focus, .x-select:focus, .x-textarea:focus {
  outline: none;
  border-color: var(--primary-border);
  box-shadow: 0 0 0 3px var(--primary-dim);
  background: var(--bg-2);
}

.x-input.is-invalid, .x-select.is-invalid, .x-textarea.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-dim);
}
.x-field__error {
  display: flex; align-items: center; gap: 5px;
  margin-top: 6px;
  color: var(--danger);
  font-size: 0.78rem;
}
.x-field__hint {
  margin-top: 6px;
  color: var(--text-mute);
  font-size: 0.78rem;
}

/* ─── Data Table ───────────────────────────────────────── */
.x-table-wrap {
  position: relative;
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--primary-border) transparent;
}
.x-table-wrap::-webkit-scrollbar { height: 10px; }
.x-table-wrap::-webkit-scrollbar-track { background: var(--bg-3); }
.x-table-wrap::-webkit-scrollbar-thumb {
  background: var(--primary-border);
  border-radius: 10px;
}
.x-table-wrap::-webkit-scrollbar-thumb:hover { background: var(--primary); }
/* Scroll affordance (persistent fade + chevron) shown on mobile so users
   know the table pans. iOS Safari/Chrome use overlay scrollbars that hide,
   so we render our own visual hint. */
.x-table-scroll { position: relative; }
@media (max-width: 767.98px) {
  .x-table-wrap { overflow-x: scroll; }
  .x-table-scroll::before,
  .x-table-scroll::after {
    content: '';
    position: absolute;
    top: 0; bottom: 0;
    width: 36px;
    pointer-events: none;
    z-index: 2;
  }
  .x-table-scroll::before {
    left: 0;
    background: linear-gradient(90deg, var(--bg-1), transparent);
    border-top-left-radius: var(--r-lg);
    border-bottom-left-radius: var(--r-lg);
    opacity: 0;
    transition: opacity var(--dur) var(--ease);
  }
  .x-table-scroll::after {
    right: 0;
    background: linear-gradient(270deg, var(--bg-1), transparent);
    border-top-right-radius: var(--r-lg);
    border-bottom-right-radius: var(--r-lg);
  }
  .x-table-scroll.is-scrolled::before { opacity: 1; }
  .x-table-scroll.is-end::after       { opacity: 0; }

  .x-table-scroll__hint {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    background: var(--primary);
    color: var(--bg);
    border-radius: 50%;
    font-size: 0.72rem;
    box-shadow: 0 0 0 4px rgba(0,255,127,0.18), 0 4px 12px rgba(0,0,0,0.5);
    pointer-events: none;
    z-index: 3;
    animation: x-swipe-hint 1.4s var(--ease) infinite;
  }
  .x-table-scroll.is-end .x-table-scroll__hint { display: none; }
}
@keyframes x-swipe-hint {
  0%, 100% { transform: translate(0, -50%); }
  50%      { transform: translate(-6px, -50%); }
}
.x-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.x-table thead th {
  background: var(--bg-3);
  padding: 11px var(--sp-4);
  text-align: left;
  font-family: var(--font-body);
  font-size: 0.76rem;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--text-mute);
  border-bottom: 1px solid var(--border);
}
.x-table tbody td {
  padding: 13px var(--sp-4);
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  vertical-align: middle;
}
.x-table tbody tr:last-child td { border-bottom: 0; }
.x-table tbody tr:hover td { background: rgba(255, 255, 255, 0.02); color: var(--text); }
.x-table td.is-strong { color: var(--text); font-weight: 500; }
.x-table td.is-mono { font-family: var(--font-mono); font-size: 0.82rem; }
.x-table td.is-num { text-align: right; font-variant-numeric: tabular-nums; }

.x-table-empty {
  padding: var(--sp-10);
  text-align: center;
  color: var(--text-mute);
}
.x-table-empty i { font-size: 2rem; color: var(--text-faint); display: block; margin-bottom: var(--sp-3); }

/* ─── Toggle switch + shared form bits ─────────────────── */
.x-switch { position: relative; display: inline-block; cursor: pointer; flex-shrink: 0; }
.x-switch input { position: absolute; opacity: 0; pointer-events: none; }
.x-switch__track {
  display: inline-block;
  width: 44px; height: 24px;
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  position: relative;
  transition:
    background-color var(--dur) var(--ease),
    border-color var(--dur) var(--ease);
}
.x-switch__thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: var(--text);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  transition: transform var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.x-switch input:checked + .x-switch__track {
  background: color-mix(in oklab, var(--primary) 22%, transparent);
  border-color: color-mix(in oklab, var(--primary) 55%, transparent);
}
.x-switch input:checked + .x-switch__track .x-switch__thumb {
  transform: translateX(20px);
  background: var(--primary);
  box-shadow: 0 0 8px color-mix(in oklab, var(--primary) 55%, transparent);
}
.x-switch input:focus-visible + .x-switch__track {
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--primary) 25%, transparent);
}

.gw-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  flex-wrap: wrap;
}
.gw-toggle { display: flex; align-items: center; gap: var(--sp-3); flex: 1; min-width: 0; }
.gw-toggle__copy { display: flex; flex-direction: column; min-width: 0; }
.gw-toggle__title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.012em;
}
.gw-toggle__sub { font-size: 0.82rem; color: var(--text-mute); margin-top: 2px; }

.x-checkbox {
  appearance: none;
  flex-shrink: 0;
  width: 16px; height: 16px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--bg-2);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  position: relative;
  vertical-align: middle;
}
.x-checkbox:hover { border-color: var(--primary-border); }
.x-checkbox:checked { background: var(--primary); border-color: var(--primary); }
.x-checkbox:checked::after {
  content: '';
  position: absolute;
  left: 4px; top: 1px;
  width: 5px; height: 9px;
  border: solid var(--bg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* ─── Pagination ───────────────────────────────────────── */
.x-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border);
  background: rgba(6, 7, 11, 0.35);
}
.x-pager__range {
  color: var(--text-mute);
  font-size: 0.82rem;
  line-height: 1.4;
}
.x-pager__range strong {
  color: var(--text);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.x-pager__list {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  padding: 0;
  margin: 0;
}
.x-pager__btn {
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-mute);
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: none;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition:
    background-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease);
}
.x-pager__btn:hover:not(.is-active):not(.is-disabled) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}
.x-pager__btn.is-active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-strong);
  cursor: default;
}
.x-pager__btn.is-disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.x-pager__btn i { font-size: 0.72rem; }
.x-pager__ellipsis {
  color: var(--text-faint);
  font-size: 0.82rem;
  padding: 0 6px;
  user-select: none;
}

@media (max-width: 575.98px) {
  .x-pager { justify-content: center; padding: var(--sp-3) var(--sp-4); }
  .x-pager__range { order: 2; width: 100%; text-align: center; }
}

/* ─── Sidebar ──────────────────────────────────────────── */
.x-sidebar {
  position: sticky; top: 0;
  height: 100vh;
  background: linear-gradient(180deg, rgba(11, 13, 20, 0.95), rgba(6, 7, 11, 0.98));
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.x-sidebar__brand {
  display: flex; align-items: center; gap: var(--sp-3);
  height: var(--topbar-h);
  padding: 0 var(--sp-5);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.x-sidebar__brand-mark {
  width: 32px; height: 32px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  color: var(--bg);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.9rem;
  flex-shrink: 0;
  box-shadow: 0 0 12px var(--primary-glow);
}
.x-sidebar__brand-copy { min-width: 0; }
.x-sidebar__brand-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.x-sidebar__brand-sub {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  color: var(--primary);
  text-transform: uppercase;
}

.x-sidebar__nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-4) var(--sp-3);
  display: flex; flex-direction: column; gap: var(--sp-5);
}

.x-nav-section__title {
  padding: 0 var(--sp-3) 6px;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: var(--text-faint);
  text-transform: uppercase;
}
.x-nav-section__items {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 2px;
}

.x-nav-link {
  position: relative;
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 9px var(--sp-3);
  border-radius: var(--r-md);
  color: var(--text-dim);
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--dur-fast) var(--ease);
  border: 1px solid transparent;
}
.x-nav-link:hover {
  background: var(--bg-2);
  color: var(--text);
}
.x-nav-link__icon {
  width: 18px;
  display: inline-flex; justify-content: center;
  color: var(--text-mute);
  transition: color var(--dur-fast);
  flex-shrink: 0;
}
.x-nav-link:hover .x-nav-link__icon { color: var(--primary); }

.x-nav-link.is-active {
  color: var(--primary);
  background: var(--primary-dim);
  border-color: var(--primary-border);
}
.x-nav-link.is-active .x-nav-link__icon { color: var(--primary); }
.x-nav-link.is-active::before {
  content: '';
  position: absolute; left: -4px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 2px;
  background: var(--primary);
  box-shadow: 0 0 8px var(--primary-glow);
}

.x-sidebar__footer {
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--text-mute);
  letter-spacing: 0.1em;
  display: flex; align-items: center; gap: 6px;
}
.x-sidebar__footer .led {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--primary); box-shadow: 0 0 6px var(--primary-glow);
}

/* Collapsed state */
.is-collapsed .x-sidebar__brand-copy,
.is-collapsed .x-nav-link__text,
.is-collapsed .x-nav-section__title,
.is-collapsed .x-sidebar__footer span:not(.led) {
  display: none;
}
.is-collapsed .x-sidebar__brand { justify-content: center; padding: 0; }
.is-collapsed .x-nav-link { justify-content: center; padding: 10px; }
.is-collapsed .x-nav-link__icon { width: auto; }

/* Mobile — slide-over sidebar */
@media (max-width: 991.98px) {
  .admin-shell { grid-template-columns: 1fr; }
  .x-sidebar {
    position: fixed; inset: 0 auto 0 0;
    width: var(--sidebar-w);
    z-index: 60;
    transform: translateX(-100%);
    transition: transform var(--dur) var(--ease);
    box-shadow: var(--sh-3);
  }
  .is-sidebar-open .x-sidebar { transform: translateX(0); }
  .is-sidebar-open::after {
    content: '';
    position: fixed; inset: 0;
    background: var(--bg-overlay);
    z-index: 55;
    backdrop-filter: blur(4px);
  }
}

/* Mobile — compact topbar so it never pushes horizontal scroll */
@media (max-width: 767.98px) {
  .admin-topbar { padding: 0 var(--sp-4); gap: var(--sp-3); }
  .topbar-search { max-width: none; }
  .topbar-user { padding: 4px 6px; gap: var(--sp-2); }
  /* Hide the name/role text; keep the avatar as an identity cue. */
  .topbar-user__info { display: none; }

  /* Shrink the logout button to icon-only but keep it visible. */
  .topbar-logout {
    padding: 0 10px;
    gap: 0;
    height: 34px;
  }
  .topbar-logout span { display: none; }
}
@media (max-width: 575.98px) {
  .admin-topbar { padding: 0 var(--sp-3); gap: var(--sp-2); }
  .topbar-search { display: none; }
}

/* ─── Utilities ────────────────────────────────────────── */
.text-dim     { color: var(--text-dim) !important; }
.text-mute    { color: var(--text-mute) !important; }
.text-primary-g { color: var(--primary) !important; }
.text-cyan-g  { color: var(--cyan) !important; }
.text-gold-g  { color: var(--gold) !important; }
.text-danger-g{ color: var(--danger) !important; }

.mono         { font-family: var(--font-mono); }

.grid-cols-1  { display: grid; gap: var(--sp-4); grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2  { display: grid; gap: var(--sp-4); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3  { display: grid; gap: var(--sp-4); grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4  { display: grid; gap: var(--sp-4); grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1199.98px) { .grid-cols-4 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 991.98px)  { .grid-cols-3, .grid-cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 575.98px)  { .grid-cols-2, .grid-cols-3, .grid-cols-4 { grid-template-columns: 1fr; } }

.stack-sm > * + * { margin-top: var(--sp-3); }
.stack-md > * + * { margin-top: var(--sp-5); }
.stack-lg > * + * { margin-top: var(--sp-8); }

.fade-in { animation: fadeIn 0.45s var(--ease) both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

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

/* ─── Tone swatches & chips (used by service categories + products) ── */
.tone-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.tone-swatch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 0.82rem;
  color: var(--text-dim);
}
.tone-swatch:hover {
  color: var(--text);
  border-color: var(--primary-border);
  background: rgba(0, 255, 127, 0.03);
}
.tone-swatch input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.tone-swatch__dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
  transition: transform 0.15s ease;
}
.tone-swatch:has(input:checked) {
  color: var(--text);
  border-color: rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.04);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.06);
}
.tone-swatch:has(input:checked) .tone-swatch__dot {
  transform: scale(1.15);
  border-color: rgba(255,255,255,0.35);
}
.tone-swatch__label {
  font-weight: 500;
  letter-spacing: -0.01em;
}

.tone-chip {
  font-family: var(--font-mono);
  font-size: 0.56rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--chip);
  background: color-mix(in srgb, var(--chip) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--chip) 30%, transparent);
  line-height: 1.3;
  white-space: nowrap;
}

/* ── Form action row (create/edit submits) ── */
.x-form-actions {
  display: flex;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-top: var(--sp-4);
}
.x-form-actions > * { flex-shrink: 0; }
@media (max-width: 575.98px) {
  /* Full-width buttons on very small screens — the submit can't get clipped. */
  .x-form-actions { flex-direction: column; }
  .x-form-actions > * { width: 100%; }
  .x-form-actions > * > * { justify-content: center; }
}

/* ── Product hero image uploader (admin) ── */
.product-image-row {
  display: flex;
  gap: var(--sp-4);
  align-items: center;
  flex-wrap: wrap;
}
.product-image-preview {
  width: 140px;
  height: 140px;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--bg-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.product-image-preview.is-empty {
  border-style: dashed;
  color: var(--muted);
  font-size: 1.5rem;
}
.product-image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.product-image-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-width: 220px;
}
.product-image-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.product-image-pick {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  background: color-mix(in srgb, var(--primary) 8%, transparent);
  border: 1px dashed color-mix(in srgb, var(--primary) 40%, transparent);
  border-radius: var(--r-md);
  color: var(--text);
  cursor: pointer;
  width: fit-content;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.product-image-pick:hover {
  background: color-mix(in srgb, var(--primary) 16%, transparent);
  border-color: var(--primary);
}
.product-image-pick i { color: var(--primary); }
.product-image-remove {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  color: var(--muted);
  cursor: pointer;
}
.product-image-remove input {
  accent-color: #ef4444;
  width: 15px;
  height: 15px;
}
.product-image-remove i { color: #ef4444; margin-right: 4px; }

/* Universal file-input confirmation chip — injected by the global file
   auto-wire in layouts/app.blade.php. Appears beneath/after any file
   input on change, showing filename + size (or "N files selected"). */
.x-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 6px 10px;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.78rem;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
  border-radius: var(--r-sm);
  width: fit-content;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.x-file-chip::before {
  content: '\f00c'; /* fa-check */
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  flex-shrink: 0;
}
