:root {
  --bg: #f5f6f8;
  --sidebar-bg: #f7f7f9;
  --white: #ffffff;
  --border: #e6e7eb;
  --text-primary: #1f2430;
  --text-secondary: #6b7280;
  --text-muted: #9aa1ac;
  --accent: #2f6feb;
  --accent-soft: #eaf1fe;
  --success: #22c55e;
  --idle: #cbd2db;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
button { font-family: inherit; }

/* App shell */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  height: 100vh;
  position: sticky;
  top: 0;
}

.sidebar-brand { display: flex; align-items: center; gap: 4px; padding: 4px 8px 16px; }

.brand-logo { height: 30px; width: auto; display: block; }

.brand-name { font-weight: 700; font-size: 15px; }

.sidebar-search { padding: 0 8px 12px; }

.sidebar-search input {
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--white);
  font-size: 13px;
  color: var(--text-secondary);
  font-family: inherit;
}

.sidebar-search input:disabled { cursor: not-allowed; opacity: .7; }

.sidebar-nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }

.nav-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  padding: 12px 12px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background .12s ease, color .12s ease;
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: rgba(17, 20, 28, 0.05); color: var(--text-primary); }
.nav-item.active { background: var(--white); color: var(--text-primary); box-shadow: var(--shadow-card); }

.sidebar-profile-card {
  margin-top: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--white);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  position: relative;
}

.sidebar-profile-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent-soft) 0%, transparent 60%);
  pointer-events: none;
}

.sidebar-profile-main {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  position: relative;
}

.sidebar-profile-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent) 0%, #0f1f4d 100%);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(47, 111, 235, 0.35);
}

.sidebar-user-info { min-width: 0; position: relative; }

.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-email {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-logout-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  position: relative;
}

.sidebar-logout-row svg { width: 15px; height: 15px; flex-shrink: 0; }
.sidebar-logout-row:hover { background: rgba(17, 20, 28, 0.03); color: var(--text-primary); }

/* Main area */
.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 60px;
  flex-shrink: 0;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
}

.topbar-breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 14px; min-width: 0; }
.topbar-tenant { font-weight: 600; }
.topbar-sep { color: var(--text-muted); }
.topbar-page { color: var(--text-secondary); }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.notif-bell-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}

.notif-bell-btn:hover { background: var(--bg); color: var(--text-primary); }
.notif-bell-btn svg { width: 18px; height: 18px; }

.ask-cody-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px 5px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, var(--accent-soft) 0%, var(--white) 65%);
  cursor: pointer;
  position: relative;
  font-family: inherit;
  transition: border-color .12s ease;
}

.ask-cody-btn:hover { border-color: var(--accent); }

.ask-cody-face { width: 28px; height: 28px; object-fit: contain; flex-shrink: 0; display: block; }

.ask-cody-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  min-width: 62px;
  text-align: left;
  display: inline-block;
}

.ask-cody-text::after {
  content: '';
  display: inline-block;
  width: 2px;
  height: 12px;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: middle;
  animation: ask-cody-caret-blink 0.8s steps(1) infinite;
}

@keyframes ask-cody-caret-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.ask-cody-soon {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--text-primary);
  color: var(--white);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 999px;
  line-height: 1.4;
  pointer-events: none;
}

.global-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-primary);
  color: var(--white);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 8px 20px rgba(16, 24, 40, 0.25);
  z-index: 200;
}

.main-content-wrapper { position: relative; flex: 1; display: flex; flex-direction: column; min-height: 0; }

.main-content-wrapper::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent-soft) 0%, transparent 500px);
  pointer-events: none;
}

.main-content { flex: 1; overflow-y: auto; padding: 32px; position: relative; }

.page-loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.88);
  z-index: 50;
  opacity: 1;
  transition: opacity .3s ease;
}

.page-loader.hidden { display: none; }
.page-loader.page-loader-complete { opacity: 0; }

.page-loader-icon { position: relative; width: 56px; height: 63px; }

.page-loader-ghost,
.page-loader-fill {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.page-loader-ghost { opacity: 0.9; }

.page-loader-fill { clip-path: inset(100% 0 0 0); }

.page-loader-wave {
  position: absolute;
  left: -4px;
  right: -4px;
  top: 100%;
  height: 3px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 8px 2px var(--accent), 0 0 2px 1px var(--white);
  opacity: 0;
}

.page-loader-active .page-loader-fill {
  animation: cody-loader-fill-clip 1.6s ease-in-out infinite;
}

.page-loader-active .page-loader-wave {
  animation: cody-loader-wave 1.6s ease-in-out infinite;
}

.page-loader-complete .page-loader-fill {
  clip-path: inset(0 0 0 0) !important;
  animation: none !important;
}

.page-loader-complete .page-loader-wave {
  top: 0% !important;
  opacity: 0 !important;
  animation: none !important;
}

@keyframes cody-loader-fill-clip {
  0% { clip-path: inset(100% 0 0 0); }
  62% { clip-path: inset(0% 0 0 0); }
  80% { clip-path: inset(0% 0 0 0); }
  81%, 100% { clip-path: inset(100% 0 0 0); }
}

@keyframes cody-loader-wave {
  0%, 8% { top: 100%; opacity: 0; }
  15% { opacity: 1; }
  62% { top: 0%; opacity: 1; }
  80% { top: 0%; opacity: 0; }
  81%, 100% { top: 100%; opacity: 0; }
}

.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 700; margin: 0 0 4px; }
.page-header p { font-size: 14px; color: var(--text-secondary); margin: 0; }

/* Cards */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 24px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 56px 24px;
  gap: 6px;
}

.empty-state-icon { color: var(--text-muted); margin-bottom: 8px; }
.empty-state-icon svg { width: 40px; height: 40px; }
.empty-state-message { font-weight: 600; font-size: 15px; margin: 0; }
.empty-state-hint { font-size: 13px; color: var(--text-muted); margin: 0; max-width: 360px; }

/* Stat tiles (reserved for future use once real data exists) */
.stat-tile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.stat-tile-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-tile-icon svg { width: 18px; height: 18px; }
.stat-tile-label { font-size: 12px; color: var(--text-secondary); }
.stat-tile-value { font-size: 16px; font-weight: 700; }

/* Status dot */
.status-dot { width: 8px; height: 8px; border-radius: 999px; display: inline-block; }
.status-dot.active { background: var(--success); }
.status-dot.idle { background: var(--idle); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn:active { transform: scale(0.98); }
.btn-primary { background: #16181d; color: var(--white); }
.btn-primary:hover { background: #000; }
.btn-secondary { background: var(--white); border-color: var(--border); color: var(--text-primary); }
.btn-secondary:hover { background: #f3f4f6; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }

/* Auth pages */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #eef4ff 0%, #f5f6f8 100%);
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 32px;
}

.auth-brand { display: flex; align-items: center; justify-content: center; gap: 4px; margin-bottom: 20px; }
.auth-brand .brand-logo { height: 34px; }
.auth-title { font-size: 20px; font-weight: 700; text-align: center; margin: 0 0 4px; }
.auth-subtitle { font-size: 14px; color: var(--text-secondary); text-align: center; margin: 0 0 24px; }

.form-field { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.form-field label { font-size: 13px; font-weight: 600; }

.form-field input {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 14px;
  font-family: inherit;
  transition: border-color .12s ease, box-shadow .12s ease;
}

.form-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-error {
  color: #b91c1c;
  font-size: 13px;
  margin-bottom: 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

.auth-footer-link { text-align: center; font-size: 13px; color: var(--text-secondary); margin-top: 20px; }
.auth-footer-link a { color: var(--accent); font-weight: 600; text-decoration: none; }
.auth-footer-link a:hover { text-decoration: underline; }

.hidden { display: none !important; }

/* Orders page */
.order-list {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.order-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .12s ease;
}

.order-row:last-child { border-bottom: none; }
.order-row:hover, .order-row:focus { background: #f9fafb; outline: none; }

.order-row-number { font-size: 14px; font-weight: 700; width: 90px; flex-shrink: 0; }

.order-row-customer {
  font-size: 14px;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.order-row-date { font-size: 13px; color: var(--text-muted); width: 100px; flex-shrink: 0; }
.order-row-status { width: 130px; flex-shrink: 0; }
.order-row-total { font-size: 14px; font-weight: 600; width: 110px; flex-shrink: 0; text-align: right; }
.order-row-source { width: 40px; flex-shrink: 0; text-align: right; }

.status-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.status-badge-positive { background: #ecfdf5; color: #15803d; border-color: #bbf7d0; }
.status-badge-muted { background: var(--bg); color: var(--text-muted); }
.status-badge-neutral { background: #f0f1f3; color: var(--text-secondary); }

/* Order detail drawer */
.order-detail-section { margin-bottom: 20px; }
.order-detail-section:last-child { margin-bottom: 0; }

.order-detail-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  margin: 0 0 8px;
}

.order-detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  padding: 4px 0;
}

.order-detail-row-label { color: var(--text-secondary); }
.order-detail-row-value { font-weight: 600; text-align: right; }

.order-item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.order-item-row:last-child { border-bottom: none; }

.order-item-info { flex: 1; min-width: 0; }
.order-item-title { font-size: 13px; font-weight: 600; }
.order-item-meta { font-size: 12px; color: var(--text-muted); }
.order-item-total { font-size: 13px; font-weight: 600; flex-shrink: 0; }

.order-address-text { font-size: 13px; line-height: 1.5; color: var(--text-primary); }

/* Shopify connection page */
.shopify-connect-card { max-width: 560px; }

.shopify-connect-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.shopify-connect-domain { font-size: 13px; color: var(--text-secondary); }
.shopify-connect-success { color: #15803d; font-size: 13px; margin: 0 0 16px; }

.copy-field { display: flex; gap: 8px; }
.copy-field input {
  flex: 1;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 13px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text-secondary);
}

.shopify-connect-steps {
  margin: 20px 0;
  padding-left: 20px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.8;
}

/* Apps page */
.apps-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

@media (max-width: 1100px) {
  .apps-grid { grid-template-columns: repeat(2, 1fr); }
}

.app-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.app-card-cover {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #05070d;
}

.app-card-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }

.app-card-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.app-card-name { font-size: 15px; font-weight: 700; margin: 0; }

.app-card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 4px;
  line-height: 1.4;
  flex: 1;
}

/* Products page */
.page-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.page-header-row .page-header { flex: 1; min-width: 0; }

.analytics-bar {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  margin-bottom: 20px;
  overflow: hidden;
}

.analytics-bar-scroll {
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
}

.analytics-bar-scroll::-webkit-scrollbar { display: none; }

.analytics-stat {
  flex: 1 0 170px;
  padding: 18px 24px;
  border-right: 1px solid var(--border);
}

.analytics-stat:last-child { border-right: none; }

.analytics-stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  white-space: nowrap;
}

.analytics-stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.products-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.products-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  flex: 1 1 260px;
  max-width: 360px;
}

.products-search svg { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }

.products-search input {
  border: none;
  outline: none;
  font-size: 14px;
  font-family: inherit;
  width: 100%;
  background: transparent;
}

.products-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.multiselect-count { font-size: 13px; color: var(--text-secondary); white-space: nowrap; }

.btn-danger { background: #dc2626; color: var(--white); }
.btn-danger:hover { background: #b91c1c; }

.product-list {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.product-checkbox {
  display: none;
  position: relative;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  cursor: pointer;
}

.product-list.multiselect-mode .product-checkbox { display: inline-flex; }

.product-checkbox input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.checkbox-visual {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  background: var(--white);
  display: flex;
  flex-shrink: 0;
  transition: background .12s ease, border-color .12s ease;
}

.product-checkbox input:checked + .checkbox-visual {
  background: var(--accent);
  border-color: var(--accent);
}

.product-checkbox input:checked + .checkbox-visual::after {
  content: '';
  width: 5px;
  height: 9px;
  margin: 2px auto auto auto;
  border: solid var(--white);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}

.product-checkbox input:focus-visible + .checkbox-visual { box-shadow: 0 0 0 3px var(--accent-soft); }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 14px;
}

.pager-btn, .pager-page {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.pager-btn:hover:not(:disabled), .pager-page:hover:not(.active) { background: var(--bg); }

.pager-page.active { background: var(--text-primary); color: var(--white); }

.pager-btn:disabled { color: var(--text-muted); cursor: not-allowed; opacity: .5; }

.pager-ellipsis { color: var(--text-muted); padding: 0 4px; font-size: 13px; }

.product-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .12s ease;
}

.product-row:last-child { border-bottom: none; }
.product-row:hover, .product-row:focus { background: #f9fafb; outline: none; }

.product-thumb {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.product-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.product-thumb-placeholder { color: var(--text-muted); display: flex; }
.product-thumb-placeholder svg { width: 18px; height: 18px; }

.product-row-id { font-size: 12px; color: var(--text-muted); width: 48px; flex-shrink: 0; }

.product-row-name {
  font-size: 14px;
  font-weight: 500;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-row-price { font-size: 14px; font-weight: 600; width: 100px; flex-shrink: 0; text-align: right; }
.product-row-source { width: 90px; flex-shrink: 0; text-align: right; }

.badge-source {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 10px;
  border-radius: 999px;
  display: inline-block;
}

.source-icon {
  width: 20px;
  height: 23px;
  display: inline-block;
  vertical-align: middle;
}

/* Modal (import) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 20, 28, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

.modal {
  width: 100%;
  max-width: 480px;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 40px rgba(16, 24, 40, 0.2);
  padding: 24px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.modal-header h2 { font-size: 17px; font-weight: 700; margin: 0; }

.modal-close {
  border: none;
  background: none;
  font-size: 20px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

.modal-close:hover { color: var(--text-primary); }
.modal-hint { font-size: 13px; color: var(--text-secondary); margin: 0 0 16px; }

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 32px 16px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: border-color .12s ease, background .12s ease;
}

.dropzone svg { width: 28px; height: 28px; color: var(--text-muted); margin-bottom: 4px; }
.dropzone-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.dropzone-hint { font-size: 12px; color: var(--text-muted); }

.dropzone.dropzone-active { border-color: var(--accent); background: var(--accent-soft); }

.import-success { color: #15803d; font-size: 13px; margin: 12px 0 0; }

/* Import conflict resolution */
.modal-wide { max-width: 640px; }

.conflict-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.conflict-row:last-child { border-bottom: none; }

.conflict-existing { display: flex; align-items: center; gap: 10px; min-width: 0; }
.conflict-existing-label { font-size: 12px; color: var(--text-muted); }

.conflict-existing-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.conflict-choice {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  flex-shrink: 0;
}

.conflict-choice label { display: flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; }

.conflict-rename-input {
  margin-left: 22px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 13px;
  font-family: inherit;
}

.conflict-rename-input:disabled { background: var(--bg); color: var(--text-muted); }

.conflict-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* Product detail drawer */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 20, 28, 0.35);
  z-index: 100;
  display: flex;
  justify-content: flex-end;
}

.drawer {
  width: 100%;
  max-width: 420px;
  height: 100%;
  background: var(--white);
  box-shadow: -8px 0 24px rgba(16, 24, 40, 0.12);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--white);
}

.drawer-header h2 { font-size: 16px; font-weight: 700; margin: 0; }
.drawer-body { padding: 20px 24px; }

.drawer-gallery {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 16px;
}

.drawer-gallery img {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.drawer-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  font-size: 13px;
  color: var(--text-muted);
}

.unit-price-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.unit-price-row input { min-width: 0; flex: 1; }
.unit-price-sep { color: var(--text-muted); flex-shrink: 0; }

.drawer-saved { color: #15803d; font-size: 13px; text-align: center; margin: 10px 0 0; }

.drawer-danger-zone {
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.btn-delete-product {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: none;
  color: #b91c1c;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-family: inherit;
}

.btn-delete-product:hover { background: #fef2f2; }
.btn-delete-product svg { width: 16px; height: 16px; }

/* Mobile bottom bar + drag-up sheet (hidden on desktop) */
.mobile-bottom-bar { display: none; }
.mobile-sheet-backdrop { display: none; }

@media (max-width: 720px) {
  .sidebar { display: none; }
  .main-content { padding: 20px; padding-bottom: 88px; }
  .product-row-source { display: none; }
  .order-row-source, .order-row-date { display: none; }
  .drawer { max-width: 100%; }

  .analytics-stat { flex-basis: 150px; padding: 14px 18px; }
  .analytics-stat-value { font-size: 18px; }

  .conflict-row { flex-direction: column; align-items: flex-start; }
  .conflict-choice { width: 100%; }
  .conflict-existing-name { max-width: 100%; }

  .products-search { max-width: none; flex-basis: 100%; }
  .products-toolbar-actions { flex-basis: 100%; justify-content: flex-end; }

  .apps-grid { grid-template-columns: 1fr; }

  body.sheet-open .main-content { overflow: hidden; }

  .mobile-bottom-bar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 64px;
    padding-bottom: env(safe-area-inset-bottom, 0);
    background: var(--white);
    border-top: 1px solid var(--border);
    justify-content: space-around;
    align-items: stretch;
    z-index: 90;
  }

  .mobile-bar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
    font-family: inherit;
    cursor: pointer;
    padding: 0;
  }

  .mobile-bar-item svg { width: 22px; height: 22px; }
  .mobile-bar-item.active { color: var(--accent); }

  .mobile-sheet-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(17, 20, 28, 0.4);
    z-index: 120;
  }

  .mobile-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100vh;
    background: var(--white);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -8px 24px rgba(16, 24, 40, 0.18);
    transform: translateY(100%);
    display: flex;
    flex-direction: column;
    touch-action: none;
  }

  .mobile-sheet-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 0 8px;
    border: none;
    background: none;
    flex-shrink: 0;
    touch-action: none;
  }

  .mobile-sheet-handle span {
    width: 36px;
    height: 4px;
    border-radius: 999px;
    background: var(--border);
  }

  .mobile-sheet-nav {
    overflow-y: auto;
    padding: 4px 16px calc(24px + env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .sheet-nav-item { padding: 14px 12px; font-size: 15px; }
  .sheet-nav-item svg { width: 20px; height: 20px; }
}
