/* ========================================================================
   Shell: sidebar + topbar + main content
   ======================================================================== */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  background: var(--bg);
  transition: grid-template-columns var(--dur) var(--ease-out);
}
.app[data-sidebar="collapsed"] {
  grid-template-columns: var(--sidebar-w-collapsed) 1fr;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sb {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 20;
}

.sb-head {
  height: var(--header-h);
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.sb-mark {
  width: 28px; height: 28px;
  border-radius: var(--r-8);
  background: linear-gradient(135deg, var(--p-400), var(--p-600));
  color: white;
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px;
  letter-spacing: -0.04em;
  flex-shrink: 0;
  box-shadow: 0 1px 2px oklch(0.5 0.2 275 / 0.3), inset 0 1px 0 oklch(1 0 0 / 0.15);
}
.sb-brand {
  font-weight: 600;
  font-size: var(--t-14);
  letter-spacing: -0.012em;
  white-space: nowrap;
  overflow: hidden;
}
.sb-brand-tld {
  color: var(--text-subtle);
  font-weight: 500;
}
.sb-badge-role {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: var(--r-4);
  background: var(--primary-soft);
  color: var(--primary-text);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  flex-shrink: 0;
}
[data-role="vendor"] .sb-badge-role {
  background: color-mix(in oklab, var(--role-accent) 12%, transparent);
  color: var(--role-accent);
}

/* Quick create button */
.sb-create {
  margin: 10px 10px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--text);
  color: var(--bg);
  border-radius: var(--r-6);
  font-weight: 500;
  font-size: var(--t-13);
  box-shadow: var(--shadow-sm), inset 0 1px 0 oklch(1 0 0 / 0.08);
  width: calc(100% - 20px);
  justify-content: flex-start;
}
.sb-create:hover { background: var(--n-800); }
[data-theme="dark"] .sb-create { background: var(--n-50); color: var(--n-950); }
[data-theme="dark"] .sb-create:hover { background: #fff; }
.sb-create svg { width: 14px; height: 14px; }
.sb-create kbd { margin-left: auto; background: color-mix(in oklab, currentColor 10%, transparent); border: 0; color: inherit; opacity: 0.7; }

.sb-nav {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 12px;
}
.sb-section {
  padding: 14px 10px 4px;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 600;
}
.sb-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: var(--r-6);
  color: var(--text-muted);
  font-size: var(--t-13);
  font-weight: 450;
  width: 100%;
  text-align: left;
  position: relative;
  white-space: nowrap;
  min-width: 0;
}
.sb-item > span:not([class]), .sb-item > span:first-of-type {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.sb-item:hover { background: var(--surface-hover); color: var(--text); }
.sb-item svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--text-subtle); }
.sb-item:hover svg { color: var(--text-2); }
.sb-item.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-xs), inset 0 0 0 1px var(--border);
  font-weight: 500;
}
.sb-item.active svg { color: var(--primary); }
[data-role="vendor"] .sb-item.active svg { color: var(--role-accent); }

.sb-item-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: var(--r-full);
  background: var(--bg-sunken);
  color: var(--text-muted);
}
.sb-item.active .sb-item-count {
  background: var(--primary-soft);
  color: var(--primary-text);
}
.sb-item-dot {
  margin-left: auto;
  width: 6px; height: 6px;
  border-radius: var(--r-full);
  background: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.sb-sub {
  margin-left: 26px;
  padding-left: 10px;
  border-left: 1px solid var(--border-subtle);
  margin-top: 2px;
  padding-top: 2px;
  padding-bottom: 4px;
}
.sb-sub .sb-item { padding: 5px 8px; font-size: 12.5px; }

/* Sidebar footer — store switcher + user */
.sb-foot {
  border-top: 1px solid var(--border-subtle);
  padding: 8px;
  flex-shrink: 0;
}
.sb-store {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-6);
  width: 100%;
  text-align: left;
}
.sb-store:hover { background: var(--surface-hover); }
.sb-store-logo {
  width: 24px; height: 24px;
  border-radius: var(--r-4);
  background: linear-gradient(135deg, oklch(0.55 0.13 45), oklch(0.42 0.15 30));
  display: grid; place-items: center;
  color: white;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.sb-store-text { flex: 1; min-width: 0; }
.sb-store-name {
  font-size: var(--t-13);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-store-meta {
  font-size: 11px;
  color: var(--text-subtle);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-store svg { width: 14px; height: 14px; color: var(--text-faint); flex-shrink: 0; }

/* ── Topbar ──────────────────────────────────────────────── */
.tb {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--header-h);
  padding: 0 16px;
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.tb-toggle {
  width: 28px; height: 28px;
  border-radius: var(--r-4);
  display: grid; place-items: center;
  color: var(--text-muted);
}
.tb-toggle:hover { background: var(--surface-hover); color: var(--text); }
.tb-toggle svg { width: 16px; height: 16px; }
.tb-sep {
  width: 1px;
  height: 16px;
  background: var(--border);
}
.tb-crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--t-13);
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 0;
}
.tb-crumbs svg {
  width: 12px; height: 12px;
  color: var(--text-faint);
}
.tb-crumbs .cur { color: var(--text); font-weight: 500; }

.tb-spacer { flex: 1; }

/* Search — centered, large, Stripe-like */
.tb-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: 34px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-6);
  color: var(--text-subtle);
  font-size: var(--t-13);
  width: 440px;
  max-width: 48vw;
  cursor: text;
}
.tb-search:hover { border-color: var(--border-strong); background: var(--surface); }
.tb-search svg { width: 14px; height: 14px; }
.tb-search-kbd { margin-left: auto; display: flex; gap: 2px; }

/* Right actions */
.tb-right {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}
.tb-icon {
  width: 32px; height: 32px;
  border-radius: var(--r-6);
  display: grid; place-items: center;
  color: var(--text-muted);
  position: relative;
}
.tb-icon:hover { background: var(--surface-hover); color: var(--text); }
.tb-icon svg { width: 16px; height: 16px; }
.tb-icon .notif-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  border-radius: var(--r-full);
  background: var(--danger-500);
  border: 2px solid var(--bg);
}
.tb-user {
  margin-left: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 4px;
  border-radius: var(--r-full);
}
.tb-user:hover { background: var(--surface-hover); }
.tb-user-av {
  width: 24px; height: 24px;
  border-radius: var(--r-full);
  background: linear-gradient(135deg, var(--p-400), var(--p-700));
  color: white;
  display: grid; place-items: center;
  font-size: 11px;
  font-weight: 600;
}
.tb-user-name { font-size: var(--t-13); font-weight: 500; }

/* ── Role banner (thin) ──────────────────────────────────── */
.role-strip {
  height: 3px;
  background: var(--role-banner-grad);
  flex-shrink: 0;
}

/* ── Main area ───────────────────────────────────────────── */
.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.content {
  padding: 24px 32px 64px;
  max-width: var(--page-max);
  width: 100%;
  margin: 0 auto;
}
[data-role="vendor"] .content { padding: 28px 32px 72px; }
[data-density="compact"] .content { padding: 18px 24px 48px; }

/* Page header */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.page-head-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.page-title {
  font-family: var(--font-display);
  font-size: var(--t-24);
  font-weight: 600;
  letter-spacing: -0.022em;
  margin: 0;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}
[data-role="vendor"] .page-title { font-size: 26px; }
.page-sub {
  font-size: var(--t-13);
  color: var(--text-muted);
  margin: 0;
}
.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Section title within a page */
.sec-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.sec-title {
  font-size: var(--t-15);
  font-weight: 600;
  letter-spacing: -0.008em;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sec-sub {
  font-size: var(--t-12);
  color: var(--text-subtle);
  margin: 2px 0 0;
}

/* Responsive: collapse to mobile */
@media (max-width: 1024px) {
  :root { --sidebar-w: 220px; }
  .tb-search { width: 280px; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr !important; }
  .sb {
    position: fixed;
    left: 0; top: 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform var(--dur) var(--ease-out);
    box-shadow: var(--shadow-xl);
  }
  .sb.is-open { transform: translateX(0); }
  .content { padding: 18px 16px 48px; }
  .tb-search { display: none; }
  .tb-search-compact {
    width: 32px; height: 32px;
    border-radius: var(--r-6);
    display: grid; place-items: center;
    color: var(--text-muted);
  }
  .tb-search-compact:hover { background: var(--surface-hover); color: var(--text); }
  .tb-crumbs .crumb-mid { display: none; }
}
@media (min-width: 821px) { .tb-search-compact { display: none; } }
