/* Kurd Store VIP — Hostinger PHP edition
   Design tokens and primitives ported from src/styles.css.
   Dark-first, emerald primary, semantic surfaces, RTL-aware, no build step. */

/* ---------- Design tokens ---------- */
:root {
  color-scheme: dark;
  --bg:                 #0a0e13;
  --bg-elev:            #0d131a;
  --surface:            #10171f;
  --surface-2:          #141c25;
  --surface-3:          #182230;
  --border:             #1e2a37;
  --border-strong:      #2a3745;
  --ring:               rgba(16, 185, 129, .35);
  --input:              #141c25;
  --sidebar:            #0c1219;
  --sidebar-border:     #172029;

  --text:               #e6edf3;
  --text-muted:         #98a4b3;
  --text-dim:           #6a7683;

  --primary:            #10b981;
  --primary-hover:      #0ea371;
  --primary-active:     #0b8a5f;
  --primary-fg:         #04140e;
  --primary-soft:       rgba(16, 185, 129, .14);

  --accent:             #d4af37;
  --success:            #22c55e;
  --warning:            #f59e0b;
  --info:               #3b82f6;
  --destructive:        #ef4444;
  --purple:             #a855f7;

  --radius-xs:          6px;
  --radius-sm:          8px;
  --radius:             10px;
  --radius-md:          12px;
  --radius-lg:          16px;

  --shadow-xs:          0 1px 1px rgba(0,0,0,.15);
  --shadow-sm:          0 1px 2px rgba(0,0,0,.18);
  --shadow-md:          0 4px 12px rgba(0,0,0,.22);
  --shadow-pop:         0 12px 40px rgba(0,0,0,.35);

  --topbar-h:           64px;
  --topbar-h-mobile:    56px;
  --sidebar-w:          260px;
  --sidebar-w-rail:     72px;
  --content-max:        1760px;

  --font-sans:          'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-rtl:           'Noto Naskh Arabic', 'Noto Kufi Arabic', 'Inter', sans-serif;

  --ease:               cubic-bezier(.2,.6,.2,1);
}

[data-theme="light"] {
  color-scheme: light;
  --bg:                 #f7f8fa;
  --bg-elev:            #ffffff;
  --surface:            #ffffff;
  --surface-2:          #f2f4f7;
  --surface-3:          #e9edf2;
  --border:             #e4e8ee;
  --border-strong:      #d0d6de;
  --input:              #ffffff;
  --sidebar:            #ffffff;
  --sidebar-border:     #e4e8ee;
  --text:               #0d1622;
  --text-muted:         #4a5563;
  --text-dim:           #7b8695;
  --primary-fg:         #ffffff;
  --primary-soft:       rgba(16, 185, 129, .10);
  --shadow-sm:          0 1px 2px rgba(15,23,42,.06);
  --shadow-md:          0 4px 12px rgba(15,23,42,.08);
  --shadow-pop:         0 12px 40px rgba(15,23,42,.15);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
html[dir="rtl"] body { font-family: var(--font-rtl); }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; background: none; border: 0; color: inherit; padding: 0; }
input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }
:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--ring);
  border-radius: 6px;
}

/* ---------- Layout shell ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100dvh;
  min-height: 100vh;
}
.main { min-width: 0; display: flex; flex-direction: column; }
.page {
  padding: 20px clamp(16px, 3vw, 32px);
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
}
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 20px; flex-wrap: wrap;
}
.page-title { font-size: 22px; font-weight: 600; letter-spacing: -.01em; margin: 0; }
.page-sub { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--sidebar);
  border-inline-end: 1px solid var(--sidebar-border);
  position: sticky; top: 0; align-self: start;
  height: 100dvh; overflow-y: auto;
  display: flex; flex-direction: column;
  padding-bottom: 16px;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.brand {
  padding: 16px 18px;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex; align-items: center; gap: 10px;
  min-height: var(--topbar-h);
}
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #0891b2);
  display: grid; place-items: center;
  color: var(--primary-fg); font-weight: 700; font-size: 15px;
  box-shadow: 0 0 0 1px rgba(255,255,255,.04);
}
.brand-name { font-weight: 600; letter-spacing: -.01em; font-size: 14px; }
.brand-sub  { font-size: 11px; color: var(--text-dim); margin-top: 1px; }
.brand-online {
  margin-inline-start: auto;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--success) 25%, transparent);
}

.nav-group { padding: 12px 10px 2px; }
.nav-group-title {
  font-size: 10px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-dim); padding: 0 10px 6px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  color: var(--text-muted);
  font-size: 13.5px; min-height: 40px;
  transition: background .15s var(--ease), color .15s var(--ease);
  position: relative;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.is-active {
  background: var(--primary-soft);
  color: var(--text);
  font-weight: 500;
}
.nav-item.is-active::before {
  content: '';
  position: absolute;
  inset-inline-start: -10px;
  top: 8px; bottom: 8px; width: 3px;
  border-radius: 2px;
  background: var(--primary);
}
.nav-item svg { width: 18px; height: 18px; flex: 0 0 18px; opacity: .9; }
.nav-item.is-active svg { color: var(--primary); opacity: 1; }
.sidebar-footer {
  margin-top: auto; padding: 12px 18px 0;
  font-size: 11px; color: var(--text-dim);
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  background: color-mix(in oklab, var(--bg) 82%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 0 clamp(12px, 2vw, 24px);
}
.topbar-left { display: flex; align-items: center; gap: 8px; }
.topbar-menu { display: none; }
.topbar-search {
  justify-self: center;
  width: 100%; max-width: 640px;
}
.search-trigger {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 14px; min-height: 44px;
  color: var(--text-muted);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.search-trigger:hover { border-color: var(--border-strong); }
.search-trigger .search-placeholder {
  flex: 1; min-width: 0; text-align: start;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.search-trigger .kbd {
  margin-inline-start: auto;
  font-size: 11px; color: var(--text-dim);
  padding: 2px 6px; border: 1px solid var(--border);
  border-radius: 4px; background: var(--surface-2);
}
.topbar-actions { display: flex; align-items: center; gap: 6px; justify-self: end; }
.topbar-pop-wrap { position: relative; }

.icon-btn {
  width: 40px; height: 40px;
  display: inline-grid; place-items: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  position: relative;
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn.ghost { border-color: transparent; background: transparent; }

.mobile-search-trigger { display: none; }

.profile-trigger {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px; border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  min-height: 40px;
  transition: background .15s var(--ease), border-color .15s var(--ease);
}
.profile-trigger:hover { background: var(--surface-2); }
.profile-avatar {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  font-weight: 600; font-size: 12px;
}
.profile-name { font-size: 13px; font-weight: 500; max-width: 120px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Hard-guard popovers: even if CSS/JS fails, the [hidden] attribute
   and inline style="display:none" keep the panels closed. */
.popover[hidden] { display: none !important; }

.badge-dot {
  position: absolute; top: 4px; inset-inline-end: 4px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px;
  background: var(--destructive); color: #fff;
  font-size: 10px; font-weight: 600;
  display: grid; place-items: center;
  border: 2px solid var(--surface);
}

.mobile-greeting { display: none; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-xs);
}
.card-title { font-size: 13px; font-weight: 600; margin: 0 0 4px; }
.card-sub { font-size: 12px; color: var(--text-muted); margin: 0 0 12px; }

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

/* KPI */
.kpi { display: flex; flex-direction: column; gap: 6px; }
.kpi-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.kpi-value { font-size: 26px; font-weight: 600; letter-spacing: -.02em; }
.kpi-delta { font-size: 12px; color: var(--success); }
.kpi-delta.negative { color: var(--destructive); }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 500;
  background: var(--surface-2); color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge.success     { background: color-mix(in oklab, var(--success) 16%, transparent);     color: var(--success);     border-color: transparent; }
.badge.warning     { background: color-mix(in oklab, var(--warning) 16%, transparent);     color: var(--warning);     border-color: transparent; }
.badge.destructive { background: color-mix(in oklab, var(--destructive) 16%, transparent); color: var(--destructive); border-color: transparent; }
.badge.info        { background: color-mix(in oklab, var(--info) 16%, transparent);        color: var(--info);        border-color: transparent; }
.badge.purple      { background: color-mix(in oklab, var(--purple) 16%, transparent);      color: var(--purple);      border-color: transparent; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 10px;
  font-weight: 500; font-size: 13.5px;
  border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  min-height: 40px;
  transition: background .15s var(--ease), border-color .15s var(--ease), transform .05s var(--ease);
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--primary); border-color: var(--primary);
  color: var(--primary-fg);
  box-shadow: 0 4px 14px color-mix(in oklab, var(--primary) 30%, transparent);
}
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.primary:active { background: var(--primary-active); }
.btn.destructive { background: var(--destructive); border-color: var(--destructive); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 6px 10px; min-height: 32px; font-size: 12.5px; }
.btn:disabled { opacity: .55; pointer-events: none; }

/* Forms */
.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-row label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.input, select.input, textarea.input {
  width: 100%; padding: 10px 12px;
  border-radius: 10px;
  background: var(--input);
  border: 1px solid var(--border);
  color: var(--text);
  min-height: 40px;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.input:focus, textarea.input:focus, select.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}
.input-affix {
  position: relative; display: block;
}
.input-affix > svg {
  position: absolute; inset-inline-start: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim); width: 16px; height: 16px;
}
.input-affix > .input { padding-inline-start: 38px; }
.input-affix > .affix-btn {
  position: absolute; inset-inline-end: 8px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted); padding: 6px; border-radius: 6px;
}
.input-affix > .affix-btn:hover { color: var(--text); background: var(--surface-2); }

.hint { font-size: 11px; color: var(--text-dim); }
.error {
  color: var(--destructive); font-size: 12.5px;
  padding: 10px 12px; border-radius: 10px;
  background: color-mix(in oklab, var(--destructive) 12%, transparent);
  border: 1px solid color-mix(in oklab, var(--destructive) 35%, transparent);
}

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-md); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 10px 12px; text-align: start; }
table.data thead th {
  background: var(--surface-2); color: var(--text-muted);
  font-weight: 600; font-size: 11px; letter-spacing: .04em; text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
table.data tbody tr { border-bottom: 1px solid var(--border); }
table.data tbody tr:last-child { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface-2); }

/* Feed */
.feed-item {
  display: flex; gap: 12px; padding: 12px; border-radius: 10px;
  border: 1px solid transparent; color: inherit;
}
.feed-item:hover { background: var(--surface-2); }
.feed-item.unread {
  background: var(--primary-soft);
  border-color: color-mix(in oklab, var(--primary) 25%, transparent);
}
.feed-item .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--surface-2); display: grid; place-items: center;
  color: var(--text-muted);
}
.feed-item .body { flex: 1; min-width: 0; }
.feed-item .title { font-weight: 500; font-size: 13px; }
.feed-item .meta  { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

.empty { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty h3 { color: var(--text); margin: 6px 0; }

.backend-required {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 500;
  background: color-mix(in oklab, var(--warning) 16%, transparent);
  color: var(--warning);
}

/* ---------- Overlays: dropdown / popover / dialog / sheet ---------- */
.overlay-backdrop {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(6, 10, 15, .55);
  backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none;
  transition: opacity .18s var(--ease);
}
.overlay-backdrop.is-open { opacity: 1; pointer-events: auto; }

.popover {
  position: absolute; z-index: 95;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop);
  padding: 6px;
  display: none;
}
.popover.is-open { display: block; }
.popover .menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  color: var(--text); font-size: 13px;
  min-height: 36px; width: 100%; text-align: start;
}
.popover .menu-item:hover { background: var(--surface-2); }
.popover .menu-item.destructive { color: var(--destructive); }
.popover .menu-sep { height: 1px; background: var(--border); margin: 4px 2px; }
.popover .menu-label { padding: 6px 10px 4px; font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; }

.dialog {
  position: fixed; z-index: 100;
  inset-inline-start: 50%; top: 12vh;
  transform: translateX(-50%) scale(.98);
  width: min(92vw, 560px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  opacity: 0; pointer-events: none;
  transition: opacity .18s var(--ease), transform .18s var(--ease);
}
.dialog.is-open { opacity: 1; pointer-events: auto; transform: translateX(-50%) scale(1); }
.dialog-header, .dialog-body, .dialog-footer { padding: 14px 18px; }
.dialog-header { border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dialog-footer { border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.dialog h3 { margin: 0; font-size: 15px; font-weight: 600; }

/* Command palette */
.cmdk {
  position: fixed; z-index: 100;
  inset-inline-start: 50%; top: 12vh;
  transform: translateX(-50%);
  width: min(96vw, 640px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  display: none;
  overflow: hidden;
}
.cmdk.is-open { display: block; }
.cmdk-input {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.cmdk-input input {
  flex: 1; background: transparent; border: 0; outline: none;
  color: var(--text); font-size: 15px;
}
.cmdk-list { max-height: 60vh; overflow-y: auto; padding: 8px; }
.cmdk-group { padding: 4px 6px 8px; }
.cmdk-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-dim); padding: 6px 8px;
}
.cmdk-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  color: var(--text); font-size: 13.5px; min-height: 40px;
  cursor: pointer;
}
.cmdk-item[aria-selected="true"], .cmdk-item:hover {
  background: var(--surface-2);
}
.cmdk-item .meta { margin-inline-start: auto; font-size: 11px; color: var(--text-dim); }
.cmdk-empty { padding: 24px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* Sheet / drawer (mobile) */
.sheet {
  position: fixed; z-index: 100;
  inset-inline-start: 0; inset-inline-end: 0; bottom: 0;
  background: var(--surface);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  border-top: 1px solid var(--border);
  box-shadow: var(--shadow-pop);
  transform: translateY(100%);
  transition: transform .22s var(--ease);
  max-height: 85dvh;
  overflow-y: auto;
}
.sheet.is-open { transform: translateY(0); }
.sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: 8px auto 0; }
.sheet-body { padding: 12px 16px 24px; }

/* Tabs */
.tabs {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-2); border-radius: 10px;
  border: 1px solid var(--border);
}
.tabs .tab {
  padding: 6px 12px; border-radius: 8px;
  color: var(--text-muted); font-size: 12.5px; font-weight: 500;
  min-height: 32px; display: inline-flex; align-items: center; gap: 6px;
}
.tabs .tab.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }

/* Toast */
.toast-region {
  position: fixed; z-index: 110;
  inset-inline-end: 16px; bottom: 16px;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  min-width: 240px; max-width: 360px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; font-size: 13px;
  box-shadow: var(--shadow-md);
}
.toast.success { border-color: color-mix(in oklab, var(--success) 40%, transparent); }
.toast.error   { border-color: color-mix(in oklab, var(--destructive) 40%, transparent); }

/* Tooltip (CSS-only) */
[data-tooltip] { position: relative; }
[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after {
  content: attr(data-tooltip);
  position: absolute; bottom: calc(100% + 6px); inset-inline-start: 50%;
  transform: translateX(-50%);
  background: var(--surface-3); color: var(--text);
  border: 1px solid var(--border);
  padding: 4px 8px; border-radius: 6px;
  font-size: 11px; white-space: nowrap; pointer-events: none;
  box-shadow: var(--shadow-sm);
}

/* Skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2));
  background-size: 200% 100%;
  animation: skeleton 1.4s linear infinite;
  border-radius: 6px;
}
@keyframes skeleton { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* Offline banner */
.offline-banner {
  display: none;
  position: fixed; z-index: 120;
  top: 0; inset-inline-start: 0; inset-inline-end: 0;
  padding: 6px 12px;
  background: var(--warning); color: #1a1305;
  font-size: 12.5px; font-weight: 500; text-align: center;
}
body.is-offline .offline-banner { display: block; }

/* ---------- Login (Page 01) ---------- */
.login-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: clamp(16px, 4vw, 40px);
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(1200px 600px at 15% -10%, color-mix(in oklab, var(--primary) 22%, transparent) 0%, transparent 60%),
    radial-gradient(1000px 520px at 110% 110%, color-mix(in oklab, var(--info) 18%, transparent) 0%, transparent 55%),
    var(--bg);
}
[data-theme="light"] .login-shell {
  background:
    radial-gradient(1200px 600px at 15% -10%, color-mix(in oklab, var(--primary) 14%, transparent) 0%, transparent 60%),
    radial-gradient(1000px 520px at 110% 110%, color-mix(in oklab, var(--info) 12%, transparent) 0%, transparent 55%),
    var(--bg);
}
.login-shell::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 44px 44px;
  opacity: .18;
  -webkit-mask-image: radial-gradient(ellipse at center, #000 0%, transparent 70%);
          mask-image: radial-gradient(ellipse at center, #000 0%, transparent 70%);
  pointer-events: none;
}
.login-card {
  width: 100%;
  max-width: 440px;
  position: relative;
  z-index: 1;
}
.login-card .card {
  padding: clamp(22px, 3.5vw, 34px);
  border-radius: var(--radius-lg);
  background: color-mix(in oklab, var(--surface) 96%, transparent);
  border: 1px solid var(--border);
  backdrop-filter: blur(6px);
  box-shadow: var(--shadow-pop);
}
.login-head {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 22px;
}
.login-head .brand-mark { width: 44px; height: 44px; flex: 0 0 auto; }
.login-brand-text { min-width: 0; }
.login-brand-text strong { display: block; font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.login-brand-text .text-dim { font-size: 12px; }
.login-title {
  font-size: clamp(24px, 3vw, 30px);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 6px 0 4px;
  line-height: 1.15;
}
.login-sub {
  color: var(--text-muted);
  font-size: 13.5px;
  margin: 0 0 22px;
}
.login-card form .form-row { margin-bottom: 16px; }
.login-card .input { min-height: 46px; border-radius: var(--radius-md); font-size: 14px; }
.login-card .input-affix > .input { padding-inline-start: 42px; }
.login-card .input-affix > svg { inset-inline-start: 14px; }
.login-card .input-affix > .affix-btn {
  min-width: 40px; min-height: 40px;
  display: inline-grid; place-items: center;
}
.login-card .btn.primary {
  min-height: 48px; font-size: 14.5px; font-weight: 600;
  border-radius: var(--radius-md);
  display: inline-flex; align-items: center; justify-content: space-between;
  padding: 0 18px;
}
.login-card .btn.primary .arrow { transition: transform .2s var(--ease); }
.login-card .btn.primary:hover .arrow { transform: translateX(3px); }
[dir="rtl"] .login-card .btn.primary .arrow { transform: scaleX(-1); }
[dir="rtl"] .login-card .btn.primary:hover .arrow { transform: scaleX(-1) translateX(3px); }
.login-card .btn.primary[aria-busy="true"] .arrow { opacity: 0; }
.login-card .btn.primary .spinner {
  display: none; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.35); border-top-color: #fff;
  animation: ksv-spin .7s linear infinite;
}
.login-card .btn.primary[aria-busy="true"] .spinner { display: inline-block; }
@keyframes ksv-spin { to { transform: rotate(360deg); } }

.login-locale {
  position: absolute; top: 0; inset-inline-end: 0;
  display: inline-flex; gap: 2px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
}
.login-locale button {
  min-height: 30px; padding: 0 10px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .02em;
  color: var(--text-muted);
}
.login-locale button:hover { color: var(--text); }
.login-locale button.is-active {
  color: var(--primary-fg);
  background: var(--primary);
}
.login-footer {
  text-align: center;
  margin-top: 18px;
  font-size: 11px;
  color: var(--text-dim);
}
.login-offline {
  display: none;
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: color-mix(in oklab, var(--warning) 14%, transparent);
  border: 1px solid color-mix(in oklab, var(--warning) 35%, transparent);
  color: var(--text);
  font-size: 12.5px;
}
body.is-offline .login-offline { display: block; }
.login-error { margin-bottom: 14px; }

@media (max-width: 480px) {
  .login-shell { padding: 14px; }
  .login-card .card { padding: 22px 18px; }
  .login-title { font-size: 24px; }
  .login-locale { position: static; margin-inline-start: auto; }
  .login-head { flex-wrap: wrap; }
}


/* ---------- Mobile nav ---------- */
.mobile-nav { display: none; }

/* ---------- Utilities ---------- */
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.text-sm { font-size: 12px; }
.text-lg { font-size: 16px; }
.text-xl { font-size: 20px; font-weight: 600; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.w-full { width: 100%; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ---------- Split view ---------- */
.split { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 14px; }
@media (max-width: 1024px) { .split { grid-template-columns: 320px minmax(0, 1fr); } }
@media (max-width: 768px)  { .split { grid-template-columns: 1fr; } }
.list-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-bottom: 1px solid var(--border); cursor: pointer;
  min-height: 56px;
}
.list-item:hover { background: var(--surface-2); }
.list-item.is-active { background: var(--primary-soft); }
.avatar-lg { width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-weight: 600; color: var(--text-muted); }

/* ---------- Responsive breakpoints (tailwind parity) ---------- */
/* xl 1280 — content tightens */
@media (max-width: 1280px) {
  :root { --sidebar-w: 240px; }
}
/* lg 1024 — collapse to icon rail */
@media (max-width: 1024px) {
  :root { --sidebar-w: var(--sidebar-w-rail); }
  .app { grid-template-columns: var(--sidebar-w-rail) minmax(0, 1fr); }
  .sidebar .nav-group-title,
  .sidebar .brand-name,
  .sidebar .brand-sub,
  .sidebar .brand-online,
  .sidebar-footer,
  .nav-item span { display: none; }
  .nav-item { justify-content: center; padding: 8px; }
  .nav-item.is-active::before { display: none; }
  .brand { justify-content: center; padding: 12px 8px; }
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile-name { display: none; }
}
/* md 768 — mobile shell */
@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar {
    height: var(--topbar-h-mobile);
    padding: 0 12px;
  }
  .topbar-menu { display: inline-grid; }
  .topbar-search { display: none; }
  .mobile-search-trigger { display: inline-grid; }
  .mobile-nav {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; bottom: 0; inset-inline-start: 0; inset-inline-end: 0; z-index: 40;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 6px 4px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
  }
  .mobile-nav a {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 6px 4px; color: var(--text-muted); font-size: 10px;
    min-height: 48px; border-radius: 8px;
  }
  .mobile-nav a.is-active { color: var(--primary); }
  .mobile-nav a.plus {
    background: var(--primary); color: var(--primary-fg);
    font-weight: 600; border-radius: 14px;
    margin: -8px 6px 0; min-height: 52px;
    box-shadow: 0 8px 22px color-mix(in oklab, var(--primary) 40%, transparent);
  }
  .main { padding-bottom: 84px; }
  .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
  .page { padding: 14px; }
  .hide-mobile { display: none !important; }
  .cmdk { top: 0; inset-inline-start: 0; transform: none; width: 100vw; border-radius: 0; height: 100dvh; }
  .cmdk-list { max-height: calc(100dvh - 64px); }
  /* Tables → cards */
  table.data thead { display: none; }
  table.data, table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
  table.data tr {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 10px; margin-bottom: 10px;
  }
  table.data td { padding: 4px 0; border: 0; }
  table.data td::before {
    content: attr(data-label); display: block;
    font-size: 10px; text-transform: uppercase; color: var(--text-dim);
    letter-spacing: .04em; margin-bottom: 2px;
  }
}
/* sm 640 */
@media (max-width: 640px) {
  .page-title { font-size: 19px; }
}

/* ---------- Motion prefs ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* ---------- Stage B additions ---------- */
.section-title {
  font-size: 12px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-dim);
  margin: 8px 2px 10px;
}
.kpi-row .kpi { position: relative; overflow: hidden; }
.kpi-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.kpi-icon {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--primary-soft); color: var(--primary);
}
.kpi.tone-info      .kpi-icon { background: color-mix(in oklab, var(--info) 16%, transparent);        color: var(--info); }
.kpi.tone-success   .kpi-icon { background: color-mix(in oklab, var(--success) 16%, transparent);     color: var(--success); }
.kpi.tone-accent    .kpi-icon { background: color-mix(in oklab, var(--accent) 22%, transparent);      color: var(--accent); }
.kpi.tone-warning   .kpi-icon { background: color-mix(in oklab, var(--warning) 20%, transparent);     color: var(--warning); }
.kpi.tone-destructive .kpi-icon { background: color-mix(in oklab, var(--destructive) 18%, transparent); color: var(--destructive); }

/* Quick action cards */
.card.quick {
  display: flex; align-items: center; gap: 12px;
  text-decoration: none; color: inherit;
  transition: transform .18s var(--ease), border-color .18s var(--ease);
}
.card.quick:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.quick-icon {
  display: inline-grid; place-items: center;
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--primary-soft); color: var(--primary); flex: 0 0 auto;
}
.quick-icon.tone-info      { background: color-mix(in oklab, var(--info) 16%, transparent);      color: var(--info); }
.quick-icon.tone-success   { background: color-mix(in oklab, var(--success) 16%, transparent);   color: var(--success); }
.quick-icon.tone-warning   { background: color-mix(in oklab, var(--warning) 18%, transparent);   color: var(--warning); }
.quick-icon.tone-accent    { background: color-mix(in oklab, var(--accent) 22%, transparent);    color: var(--accent); }
.quick-icon.tone-primary   { background: var(--primary-soft); color: var(--primary); }
.quick-title { font-weight: 600; font-size: 14px; }

/* Filter chips */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); font-size: 12px; text-decoration: none;
}
.chip:hover { border-color: var(--border-strong); }

/* Tabs */
.tabs {
  display: flex; gap: 4px; padding: 4px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; margin-bottom: 14px; overflow-x: auto;
}
.tab {
  padding: 6px 12px; border-radius: 8px; text-decoration: none;
  color: var(--text-muted); font-size: 13px; font-weight: 500;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }
.tab-panel { min-height: 120px; }

/* Capacity bar */
.capacity .capacity-bar {
  position: relative; height: 6px; border-radius: 999px;
  background: var(--surface-3); overflow: hidden;
}
.capacity .capacity-bar > span {
  position: absolute; inset-inline-start: 0; top: 0; bottom: 0;
  background: var(--primary); border-radius: 999px;
}
.capacity.near .capacity-bar > span { background: var(--warning); }
.capacity.full .capacity-bar > span { background: var(--destructive); }
.capacity-meta { font-size: 11px; color: var(--text-dim); margin-top: 4px; }

/* Mask + backend-required chip */
.mask { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .1em; color: var(--text-muted); }
.backend-required {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  background: color-mix(in oklab, var(--warning) 14%, transparent);
  color: var(--warning); font-size: 11px; font-weight: 500;
  border: 1px solid color-mix(in oklab, var(--warning) 40%, transparent);
}

/* Small button size */
.btn.sm { padding: 4px 10px; font-size: 12px; min-height: 30px; }
.input.sm { min-height: 30px; padding: 4px 8px; font-size: 12px; }
.text-right { text-align: end; }
.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list li { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.plain-list li:last-child { border-bottom: 0; }

/* Mobile More button parity */
.mobile-nav .mnav-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 4px; color: var(--text-muted); font-size: 10px;
  min-height: 48px; border-radius: 8px;
  background: none; border: 0; cursor: pointer;
}
.mobile-nav .mnav-item.is-active { color: var(--primary); }
.mobile-nav .mnav-item.plus {
  background: var(--primary); color: var(--primary-fg);
  font-weight: 600; border-radius: 14px;
  margin: -8px 6px 0; min-height: 52px;
  box-shadow: 0 8px 22px color-mix(in oklab, var(--primary) 40%, transparent);
}

/* Badges tone extension */
.badge.destructive {
  background: color-mix(in oklab, var(--destructive) 14%, transparent);
  color: var(--destructive);
  border: 1px solid color-mix(in oklab, var(--destructive) 30%, transparent);
}

/* ---- Overlay scroll-lock (locks the page background when a dialog/palette is open) ---- */
body.has-overlay { overflow: hidden; touch-action: none; }
@supports (scrollbar-gutter: stable) {
  body.has-overlay { scrollbar-gutter: stable; }
}

/* Notification deep-link focus */
.notification-focus-target {
  position: relative;
  z-index: 3;
  outline: 3px solid var(--primary);
  outline-offset: 3px;
  box-shadow: 0 0 0 7px color-mix(in oklab, var(--primary) 22%, transparent),
              0 18px 55px color-mix(in oklab, var(--primary) 22%, transparent) !important;
  animation: notification-focus-pulse 1.05s ease-in-out 3;
}
.notification-focus-host { position: relative; }
.notification-focus-badge {
  position: absolute;
  z-index: 5;
  inset-block-start: 8px;
  inset-inline-end: 8px;
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border: 1px solid color-mix(in oklab, var(--primary) 48%, var(--border));
  border-radius: 999px;
  background: var(--primary);
  color: var(--primary-fg);
  box-shadow: 0 8px 24px color-mix(in oklab, var(--primary) 30%, transparent);
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}
.notification-focus-banner {
  position: fixed;
  z-index: 500;
  inset-block-start: 78px;
  inset-inline-start: 50%;
  max-width: min(92vw, 520px);
  padding: 10px 14px;
  border: 1px solid color-mix(in oklab, var(--primary) 42%, var(--border));
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 16px 48px rgba(0,0,0,.34);
  font-size: 12px;
  font-weight: 700;
  transform: translateX(-50%);
}
.notification-focus-banner.is-warning {
  border-color: color-mix(in oklab, var(--warning) 55%, var(--border));
  color: var(--warning);
}
@keyframes notification-focus-pulse {
  0%,100% { outline-color: var(--primary); }
  50% { outline-color: color-mix(in oklab, var(--primary) 30%, transparent); }
}
@media (max-width: 768px) {
  .notification-focus-banner { inset-block-start: 66px; }
}
@media (prefers-reduced-motion: reduce) {
  .notification-focus-target { animation: none; }
}

/* Shared Lovable-style action bar for Order, Stock, and Family cards */
.entity-card-actions {
  align-items: stretch;
  gap: 8px;
  padding: 11px 13px 13px;
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, color-mix(in oklab,var(--surface-2) 72%,transparent), var(--surface));
}
:is(.order-card,.stock-card,.family-card) {
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}
:is(.order-card,.stock-card,.family-card):hover {
  border-color: var(--border-strong);
  box-shadow: 0 12px 34px rgba(0,0,0,.13);
  transform: translateY(-1px);
}
.entity-card-actions .btn {
  min-width: 0;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .01em;
  transition: transform .16s ease, border-color .16s ease, background .16s ease, box-shadow .16s ease;
}
.entity-card-actions .btn:not(:disabled):hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
  background: var(--surface-3);
}
.entity-card-actions .entity-action-primary {
  flex: 1.45 1 0;
  border-color: color-mix(in oklab,var(--primary) 62%,var(--border));
  background: var(--primary);
  color: var(--primary-fg);
  box-shadow: 0 8px 22px color-mix(in oklab,var(--primary) 21%,transparent);
}
.entity-card-actions .entity-action-primary:not(:disabled):hover {
  border-color: var(--primary);
  background: color-mix(in oklab,var(--primary) 88%,white);
  box-shadow: 0 10px 28px color-mix(in oklab,var(--primary) 29%,transparent);
}
.entity-card-actions .entity-action-secondary {
  flex: 1 1 0;
  background: var(--surface-2);
  color: var(--text);
}
.entity-card-actions .entity-action-more {
  flex: .82 1 0;
  background: transparent;
  color: var(--text-muted);
}
.entity-card-actions .btn svg { flex: 0 0 auto; }
.entity-card-actions .btn:disabled { opacity: .48; }
@media(max-width:460px){
  .entity-card-actions{gap:6px;padding:9px}
  .entity-card-actions .btn{padding-inline:8px;font-size:9px}
  .entity-card-actions .entity-action-more{flex:.82 1 0}
}

/* Context actions expand inside the selected card instead of opening a detached sheet. */
.entity-inline-actions{position:static!important;inset:auto!important;width:auto!important;max-width:none!important;max-height:none!important;margin:0!important;border:0!important;border-top:1px solid var(--border)!important;border-radius:0!important;background:color-mix(in oklab,var(--surface-2) 72%,var(--surface))!important;box-shadow:none!important;overflow:visible!important}
.has-inline-actions{border-color:color-mix(in oklab,var(--primary) 42%,var(--border))!important;box-shadow:0 12px 30px rgba(0,0,0,.16)!important}
.entity-action-more[aria-expanded="true"]{border-color:color-mix(in oklab,var(--primary) 45%,var(--border));background:var(--primary-soft);color:var(--primary)}
.order-card>.entity-inline-actions,.stock-card>.entity-inline-actions,.family-card>.entity-inline-actions{grid-column:1/-1}
.order-card>.entity-inline-actions>header{min-height:50px;padding:9px 13px}
.order-card>.entity-inline-actions>header h2{font-size:12px}
.order-card>.entity-inline-actions .order-more-body,.stock-card>.entity-inline-actions,.family-card>.entity-inline-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;padding:10px}
.order-card>.entity-inline-actions .order-menu-label{grid-column:1/-1;padding:2px 3px 5px}
.order-card>.entity-inline-actions .order-more-body>a,.order-card>.entity-inline-actions .order-more-body>button,.stock-card>.entity-inline-actions>a,.stock-card>.entity-inline-actions>button,.family-card>.entity-inline-actions>a,.family-card>.entity-inline-actions>button{min-height:42px;justify-content:flex-start;padding:8px 11px;border:1px solid var(--border);border-radius:9px;background:var(--surface);font-size:10px}
.order-card>.entity-inline-actions .is-danger,.stock-card>.entity-inline-actions .danger,.family-card>.entity-inline-actions .danger{grid-column:1/-1;border-color:color-mix(in oklab,var(--destructive) 25%,var(--border));background:color-mix(in oklab,var(--destructive) 5%,var(--surface))}
@media(max-width:560px){.order-card>.entity-inline-actions .order-more-body,.stock-card>.entity-inline-actions,.family-card>.entity-inline-actions{grid-template-columns:1fr}}

/* Expanding one card must never stretch the sibling card in the same grid row. */
.orders-grid,.stock-grid,.family-grid{align-items:start}

/* Premium, consistent customer-message copy action. */
.premium-copy-action{border-color:color-mix(in oklab,var(--primary) 62%,var(--border))!important;background:linear-gradient(135deg,var(--primary),color-mix(in oklab,var(--primary) 76%,#0ea5e9))!important;color:var(--primary-fg)!important;box-shadow:0 8px 22px color-mix(in oklab,var(--primary) 20%,transparent);font-weight:750!important}
.premium-copy-action:not(:disabled):hover{transform:translateY(-1px);box-shadow:0 11px 28px color-mix(in oklab,var(--primary) 28%,transparent)}
.premium-copy-action:disabled{opacity:.5;box-shadow:none}
.family-member-actions{display:flex;align-items:center;justify-content:flex-end;gap:6px;flex-wrap:wrap}
.family-member-actions .premium-copy-action{min-height:36px;padding:6px 9px;font-size:8px}
@media(max-width:640px){.family-member{grid-template-columns:38px 1fr}.family-member-actions{grid-column:1/-1;justify-content:stretch}.family-member-actions .btn{flex:1}}
