/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  --bg: #eff4f8;
  --surface: #ffffff;
  --surface-2: #f6f9fc;
  --border: #dde7f0;
  --text: #111827;
  --text-2: #4b5563;
  --muted: #9ca3af;
  --primary: #1a9cff;
  --primary-hover: #007fe0;
  --accent: #ffa43c;
  --danger: #ef4444;
  --radius-xs: 6px;
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --sidebar-width: 260px;
  --transition: 260ms cubic-bezier(0.2, 0.75, 0.2, 1);
  --bg-grad-a: #f6fbff;
  --bg-grad-b: #eaf4ff;
  --bg-grad-c: #eefaf5;
  --shadow-sm: 0 6px 20px rgba(20, 56, 88, 0.08);
  --shadow-md: 0 14px 36px rgba(20, 56, 88, 0.12);
  --shadow-lg: 0 20px 54px rgba(20, 56, 88, 0.15);
  --font-sans: "DM Sans", sans-serif;
  --font-display: "Space Grotesk", sans-serif;
}

body.dark {
  --bg: #0a1220;
  --surface: #131f31;
  --surface-2: #1a2a42;
  --border: rgba(255, 255, 255, 0.09);
  --text: #e9f1ff;
  --text-2: #9fb3d2;
  --muted: #6b7f9f;
  --primary: #4eb2ff;
  --primary-hover: #3c9be3;
  --accent: #ffb85c;
  --bg-grad-a: #0d1a2f;
  --bg-grad-b: #0b1a29;
  --bg-grad-c: #11243a;
  --shadow-sm: 0 8px 24px rgba(2, 8, 18, 0.36);
  --shadow-md: 0 16px 42px rgba(2, 8, 18, 0.42);
  --shadow-lg: 0 24px 60px rgba(2, 8, 18, 0.5);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  background-image: radial-gradient(1200px 760px at 10% -8%, var(--bg-grad-a) 0%, transparent 60%), radial-gradient(900px 700px at 100% 0%, var(--bg-grad-b) 0%, transparent 60%), linear-gradient(180deg, var(--bg-grad-c) 0%, var(--bg) 56%, var(--bg) 100%);
  -webkit-font-smoothing: antialiased;
  position: relative;
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  z-index: 0;
  pointer-events: none;
  border-radius: 50%;
  filter: blur(2px);
  animation: floatBlob 14s ease-in-out infinite;
}

body::before {
  width: 340px;
  height: 340px;
  right: -120px;
  top: 64px;
  background: radial-gradient(circle, color-mix(in srgb, var(--primary) 30%, transparent) 0%, transparent 72%);
}

body::after {
  width: 280px;
  height: 280px;
  left: -100px;
  bottom: 40px;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 24%, transparent) 0%, transparent 74%);
  animation-delay: -4s;
}

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

h1 { font-size: 2rem; }
h2 { font-size: 1.625rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1rem; }

p { margin: 0; color: var(--text-2); line-height: 1.65; }

button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: 0; background: none; }

/* ============================================================
   APP SHELL
   ============================================================ */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  padding: 24px 16px;
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
  backdrop-filter: blur(14px);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.brand-logo {
  width: 38px;
  height: 38px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}

.brand-block h1 {
  font-size: 1.05rem;
  font-weight: 700;
}

.brand-block .eyebrow {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--primary);
  display: block;
  margin-bottom: 1px;
}

.nav-stack { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color var(--transition), background var(--transition), transform var(--transition), box-shadow var(--transition);
}

.nav-item:hover { color: var(--text); background: var(--surface-2); transform: translateX(4px); }

.nav-item.active {
  background: linear-gradient(135deg, var(--primary) 0%, color-mix(in srgb, var(--primary) 64%, #ffffff) 100%);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 10px 18px color-mix(in srgb, var(--primary) 35%, transparent);
}

.nav-item i { width: 18px; text-align: center; font-size: 0.9rem; }

.sidebar-card {
  border-radius: var(--radius-md);
  padding: 16px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  margin-top: auto;
  box-shadow: var(--shadow-sm);
}

.sidebar-card h2 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.sidebar-card p { font-size: 0.8rem; color: var(--muted); margin: 2px 0; }

.sidebar-chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

.sidebar-chip {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 0.78rem;
  font-weight: 500;
}

/* ============================================================
   MAIN & TOPBAR
   ============================================================ */
.app-main {
  padding: 24px 32px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  position: sticky;
  top: 8px;
  z-index: 40;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm);
}

.topbar > div:first-child {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.topbar > div:first-child h2 {
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

.topbar > div:first-child .eyebrow {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--primary);
  padding: 3px 8px;
  border: 1px solid rgba(52, 211, 153, 0.25);
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

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

.sync-pill,
.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: default;
}

.sync-pill[data-tone="good"] { color: var(--primary); border-color: rgba(52, 211, 153, 0.3); }
.sync-pill[data-tone="warn"] { color: var(--danger); border-color: rgba(239, 68, 68, 0.3); }
.sync-pill[data-tone="live"] { color: var(--accent); border-color: rgba(249, 115, 22, 0.3); }

.topbar-auth-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(130deg, var(--primary) 0%, color-mix(in srgb, var(--primary) 70%, #ffffff) 100%);
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 600;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}

.topbar-auth-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.topbar-auth-btn:active { transform: translateY(0); }

.topbar-auth-btn.logout-mode { background: var(--danger); }

/* ============================================================
   VIEWS
   ============================================================ */
.view { display: none; animation: viewIn 420ms cubic-bezier(0.2, 0.75, 0.2, 1); }
.view.active { display: block; }

@keyframes viewIn {
  from { opacity: 0; transform: translateY(14px) scale(0.995); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   BUTTONS
   ============================================================ */
.primary-button,
.secondary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  border: 1px solid transparent;
  transition: background var(--transition), border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.primary-button { background: linear-gradient(135deg, var(--primary) 0%, color-mix(in srgb, var(--primary) 65%, #ffffff) 100%); color: #fff; box-shadow: 0 10px 20px color-mix(in srgb, var(--primary) 32%, transparent); }
.primary-button:hover { background: var(--primary-hover); transform: translateY(-2px); }
.primary-button:active { transform: translateY(0); }

.secondary-button { background: linear-gradient(135deg, var(--accent) 0%, color-mix(in srgb, var(--accent) 65%, #ffffff) 100%); color: #fff; box-shadow: 0 10px 20px color-mix(in srgb, var(--accent) 30%, transparent); }
.secondary-button:hover { opacity: 0.9; transform: translateY(-1px); }
.secondary-button:active { transform: translateY(0); }

.ghost-button {
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  color: var(--text-2);
  border-color: var(--border);
}
.ghost-button:hover { background: var(--surface-2); color: var(--text); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.ghost-button:active { transform: translateY(0); }

.small-button { min-height: 36px; padding: 0 12px; font-size: 0.82rem; border-radius: var(--radius-xs); }
.button-full { width: 100%; }

/* ============================================================
   DASHBOARD
   ============================================================ */
.dashboard-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 28px;
  margin-bottom: 24px;
  border: 1px solid color-mix(in srgb, var(--border) 75%, #ffffff);
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, color-mix(in srgb, var(--surface) 86%, #ffffff) 0%, color-mix(in srgb, var(--surface-2) 80%, #ffffff) 100%);
  box-shadow: var(--shadow-md);
}

.dashboard-hero-copy h3 {
  font-size: clamp(1.5rem, 2.5vw, 2rem);
  margin-bottom: 6px;
}

.welcome-greeting {
  font-size: 0.88rem;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 8px;
}

.dashboard-hero-copy p:last-child { font-size: 0.9rem; color: var(--muted); }

.dashboard-hero-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }

/* ============================================================
   STATS GRID
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.stats-card {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
  box-shadow: var(--shadow-sm);
}

.stats-card:hover { border-color: var(--primary); transform: translateY(-4px); box-shadow: var(--shadow-md); }

.stats-card span {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.stats-card strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}

/* ============================================================
   PANELS
   ============================================================ */
.panel-grid { display: grid; gap: 16px; }
.two-column { grid-template-columns: repeat(2, 1fr); }
.three-column { grid-template-columns: 1fr 1fr 1.2fr; }


.panel {
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.panel-head h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0;
}

.panel-head .eyebrow {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--primary);
  font-weight: 600;
  display: block;
  margin-bottom: 2px;
}

.panel-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dashboard-panels { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.dashboard-stats { margin-bottom: 18px; }

/* Recent product rows on dashboard */
.recent-product-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.recent-product-row:last-child { border-bottom: none; }

.recent-product-thumb {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--surface-2);
  flex-shrink: 0;
}

.recent-product-info {
  flex: 1;
  min-width: 0;
}
.recent-product-info strong { display: block; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-product-info span { font-size: 0.78rem; color: var(--muted); }


/* ============================================================
   DASHBOARD QUICK ACTIONS
   ============================================================ */
.quick-overview-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }

.quick-overview-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), transform var(--transition), box-shadow var(--transition);
}

.quick-overview-card:hover { border-color: var(--primary); background: var(--surface); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.quick-overview-card i { font-size: 1.1rem; color: var(--primary); flex-shrink: 0; }
.quick-overview-card h4 { margin: 0; font-size: 0.9rem; }
.quick-overview-card p { font-size: 0.82rem; color: var(--muted); margin: 2px 0 0; }

/* ============================================================
   RECENT PRODUCTS
   ============================================================ */
#recentProductsList { display: flex; flex-direction: column; gap: 10px; }

/* ============================================================
   PRODUCT GRID & CARDS
   ============================================================ */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.product-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
  box-shadow: var(--shadow-sm);
  animation: cardRise 460ms cubic-bezier(0.2, 0.75, 0.2, 1);
}

.product-card:hover { border-color: var(--primary); transform: translateY(-5px); box-shadow: var(--shadow-md); }

.product-grid .product-card:nth-child(2) { animation-delay: 40ms; }
.product-grid .product-card:nth-child(3) { animation-delay: 80ms; }
.product-grid .product-card:nth-child(4) { animation-delay: 120ms; }
.product-grid .product-card:nth-child(5) { animation-delay: 160ms; }
.product-grid .product-card:nth-child(6) { animation-delay: 200ms; }

.product-card-media { padding: 10px 10px 0; }

.product-card img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: var(--radius-md);
  display: block;
  background: var(--surface-2);
}

.product-badge {
  position: absolute;
  left: 20px;
  bottom: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.product-card-media { position: relative; }

.product-card-body { padding: 12px 14px 14px; display: grid; gap: 10px; }

.product-edit-form { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.product-edit-form .field { margin-bottom: 0; }
.product-edit-form .field input { padding: 8px 10px; font-size: 0.9rem; }
.product-edit-actions { display: flex; gap: 8px; margin-top: 4px; padding-top: 12px; border-top: 1px dashed var(--border); }
.product-card-top { display: grid; gap: 6px; }

.product-card h4 { font-size: 0.92rem; margin: 0; }

.product-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--muted);
}

.product-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.product-actions button { flex: 1 1 calc(50% - 4px); min-width: 0; }

/* ============================================================
   CATALOG TOOLBAR
   ============================================================ */
.catalog-toolbar { display: flex; align-items: center; gap: 10px; }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  min-height: 42px;
  max-width: 280px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
}

.search-box input {
  border: 0;
  background: transparent;
  outline: none;
  color: inherit;
  width: 100%;
  font-size: 0.88rem;
}

.sort-select {
  padding: 0 12px;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.88rem;
}

.catalog-panel { margin-top: 16px; }

/* ============================================================
   FORMS
   ============================================================ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.field { display: grid; gap: 6px; }

.field span {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-2);
}

.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  font-size: 0.9rem;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent);
}

.field input::placeholder,
.field textarea::placeholder { color: var(--muted); }

.field textarea { min-height: 100px; resize: vertical; }
.field-full { grid-column: 1 / -1; }

.form-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Toggle */
.toggle-field {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface-2) 86%, #ffffff);
  cursor: pointer;
  user-select: none;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.toggle-field:hover { border-color: var(--primary); transform: translateY(-1px); box-shadow: var(--shadow-sm); }

.toggle-field input { position: absolute; opacity: 0; pointer-events: none; }

.toggle-track {
  width: 40px;
  height: 23px;
  border-radius: 999px;
  background: var(--border);
  position: relative;
  flex-shrink: 0;
  transition: background var(--transition);
}

.toggle-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--transition);
}

.toggle-field input:checked + .toggle-track { background: var(--primary); }
.toggle-field input:checked + .toggle-track::after { transform: translateX(17px); }

/* ============================================================
   IMAGE DROPZONE
   ============================================================ */
.image-dropzone {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 120px;
  padding: 14px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  transition: border-color var(--transition), background var(--transition);
  cursor: default;
}

.image-dropzone.is-dragover {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, var(--surface-2));
}

.image-preview-thumb {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-md);
  object-fit: cover;
  background: var(--surface);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.dropzone-labels {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.dropzone-labels p {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0;
}

.dropzone-btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Legacy - keep for any existing references */
.image-dropzone-copy { display: grid; gap: 4px; color: var(--muted); }
.image-dropzone-copy i { font-size: 1.1rem; color: var(--accent); }
.image-dropzone-copy strong { color: var(--text); font-size: 0.9rem; }
.image-dropzone-copy p { font-size: 0.82rem; }

.image-dropzone-preview {
  width: 88px;
  height: 88px;
  border-radius: var(--radius-md);
  object-fit: cover;
  background: var(--surface);
  border: 1px solid var(--border);
}

/* ============================================================
   LIST TABLE
   ============================================================ */
.list-table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.list-table { width: 100%; border-collapse: collapse; }

.list-table th,
.list-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.list-table th {
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.list-table tr:last-child td { border-bottom: 0; }

.text-right { text-align: right; }
.text-center { text-align: center; }

.price-item-cell { display: flex; align-items: center; gap: 10px; }

.price-item-thumb {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--surface-2);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.price-item-copy { display: grid; gap: 2px; }
.price-item-copy strong { font-size: 0.9rem; }
.price-item-copy span { color: var(--muted); font-size: 0.8rem; }

/* ============================================================
   RECEIPT / PREVIEW
   ============================================================ */
.receipt-preview { padding: 20px; border-radius: var(--radius-md); }

.template-switcher { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }

.template-chip {
  padding: 5px 14px;
  min-height: 34px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.83rem;
  border: 1px solid var(--border);
  transition: background var(--transition), color var(--transition);
}

.template-chip.active { background: var(--primary); color: #fff; border-color: transparent; }

.receipt-header { padding-bottom: 16px; border-bottom: 1px dashed var(--border); }
.receipt-header h3 { margin: 0; }

.receipt-lines { display: grid; gap: 10px; margin: 16px 0; }

.receipt-line {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}

.receipt-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 10px;
  background: var(--surface);
}

.receipt-meta { font-size: 0.82rem; color: var(--muted); }
.receipt-line strong { font-size: 0.9rem; }

.receipt-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
  font-size: 0.9rem;
}

/* ── Receipt template base (resets dark-mode inheritance) ── */
.receipt-preview {
  padding: 20px;
  border-radius: var(--radius-md);
  /* fallback to classic look */
  background: #f8f5ee;
  color: #1a221c;
}

.receipt-preview .receipt-header { padding-bottom: 16px; border-bottom: 1px dashed #c8c0b0; }
.receipt-preview .receipt-header h3 { color: #1a221c; font-family: var(--font-display); margin: 0; }
.receipt-preview .receipt-header .eyebrow { color: #0f9270; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; display: block; margin-bottom: 4px; }
.receipt-preview .receipt-meta { color: #6d6a63; font-size: 0.82rem; }
.receipt-preview .receipt-lines { display: grid; gap: 8px; margin: 14px 0; }
.receipt-preview .receipt-line { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; padding: 10px 12px; border: 1px solid #e4ddd0; border-radius: 10px; background: #ffffff; align-items: center; }
.receipt-preview .receipt-line strong { color: #1a221c; font-size: 0.88rem; display: block; }
.receipt-preview .receipt-line .receipt-meta { color: #6d6a63; font-size: 0.78rem; margin-top: 1px; }
.receipt-preview .receipt-line > strong:last-child { color: #0f9270; font-size: 0.9rem; white-space: nowrap; }
.receipt-preview .receipt-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 8px; background: #ede7db; }
.receipt-preview .receipt-footer { display: flex; justify-content: space-between; padding-top: 14px; border-top: 1px dashed #c8c0b0; font-size: 0.82rem; color: #6d6a63; }
.receipt-preview .empty-state { background: #fff; border: 1px dashed #c8c0b0; border-radius: 10px; padding: 20px; text-align: center; }
.receipt-preview .empty-state h4 { color: #1a221c; margin: 0 0 4px; }
.receipt-preview .empty-state p { color: #6d6a63; margin: 0; font-size: 0.84rem; }

/* ── CLASSIC (warm off-white) ─── */
.receipt-preview.template-classic { background: #f8f5ee; color: #1a221c; }
.receipt-preview.template-classic .receipt-header { border-color: #c8c0b0; }
.receipt-preview.template-classic .receipt-header h3 { color: #1a221c; }
.receipt-preview.template-classic .receipt-line { background: #ffffff; border-color: #e4ddd0; }
.receipt-preview.template-classic .receipt-line strong { color: #1a221c; }
.receipt-preview.template-classic .receipt-line > strong:last-child { color: #c75b22; }
.receipt-preview.template-classic .receipt-footer { color: #6d6a63; border-color: #c8c0b0; }

/* ── MARKET (deep forest green) ─── */
.receipt-preview.template-market { background: #102119; color: #f0ebe0; }
.receipt-preview.template-market .receipt-header { border-color: rgba(240,235,224,0.18); }
.receipt-preview.template-market .receipt-header h3 { color: #f0ebe0; }
.receipt-preview.template-market .receipt-header .eyebrow { color: #4ede9e; }
.receipt-preview.template-market .receipt-meta { color: #99b09e; }
.receipt-preview.template-market .receipt-line { background: rgba(255,255,255,0.07); border-color: rgba(255,255,255,0.1); }
.receipt-preview.template-market .receipt-line strong { color: #f0ebe0; }
.receipt-preview.template-market .receipt-line > strong:last-child { color: #4ede9e; }
.receipt-preview.template-market .receipt-footer { color: #99b09e; border-color: rgba(240,235,224,0.18); }
.receipt-preview.template-market .empty-state { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.12); }
.receipt-preview.template-market .empty-state h4 { color: #f0ebe0; }
.receipt-preview.template-market .empty-state p { color: #99b09e; }

/* ── MINIMAL (clean white) ─── */
.receipt-preview.template-minimal { background: #ffffff; color: #1a1a1a; }
.receipt-preview.template-minimal .receipt-header { border-color: #e0ddd8; }
.receipt-preview.template-minimal .receipt-header h3 { color: #111111; }
.receipt-preview.template-minimal .receipt-header .eyebrow { color: #555; }
.receipt-preview.template-minimal .receipt-meta { color: #888; }
.receipt-preview.template-minimal .receipt-line { background: #f7f6f4; border-color: #e0ddd8; }
.receipt-preview.template-minimal .receipt-line strong { color: #111111; }
.receipt-preview.template-minimal .receipt-line > strong:last-child { color: #111111; font-weight: 700; }
.receipt-preview.template-minimal .receipt-footer { color: #999; border-color: #e0ddd8; }
.receipt-preview.template-minimal .empty-state { background: #f7f6f4; border-color: #e0ddd8; }
.receipt-preview.template-minimal .empty-state h4 { color: #1a1a1a; }
.receipt-preview.template-minimal .empty-state p { color: #888; }

/* ── FESTIVAL (warm saffron-orange) ─── */
.receipt-preview.template-festival { background: linear-gradient(145deg, #fff4df, #ffe8c4); color: #5e2408; }
.receipt-preview.template-festival .receipt-header { border-color: rgba(141,60,21,0.2); }
.receipt-preview.template-festival .receipt-header h3 { color: #5e2408; }
.receipt-preview.template-festival .receipt-header .eyebrow { color: #c75b22; }
.receipt-preview.template-festival .receipt-meta { color: #8d5b3e; }
.receipt-preview.template-festival .receipt-line { background: rgba(255,255,255,0.72); border-color: rgba(141,60,21,0.12); }
.receipt-preview.template-festival .receipt-line strong { color: #5e2408; }
.receipt-preview.template-festival .receipt-line > strong:last-child { color: #b94100; font-weight: 700; }
.receipt-preview.template-festival .receipt-footer { color: #8d5b3e; border-color: rgba(141,60,21,0.2); }
.receipt-preview.template-festival .empty-state { background: rgba(255,255,255,0.7); border-color: rgba(141,60,21,0.2); }
.receipt-preview.template-festival .empty-state h4 { color: #5e2408; }
.receipt-preview.template-festival .empty-state p { color: #8d5b3e; }

/* ── NIGHT (deep navy blue) ─── */
.receipt-preview.template-night { background: #0d1b2e; color: #c8d8f0; }
.receipt-preview.template-night .receipt-header { border-color: rgba(200,216,240,0.14); }
.receipt-preview.template-night .receipt-header h3 { color: #e8f0ff; }
.receipt-preview.template-night .receipt-header .eyebrow { color: #7eb8f0; }
.receipt-preview.template-night .receipt-meta { color: #7a99be; }
.receipt-preview.template-night .receipt-line { background: rgba(255,255,255,0.06); border-color: rgba(200,216,240,0.1); }
.receipt-preview.template-night .receipt-line strong { color: #e8f0ff; }
.receipt-preview.template-night .receipt-line > strong:last-child { color: #7eb8f0; font-weight: 700; }
.receipt-preview.template-night .receipt-footer { color: #7a99be; border-color: rgba(200,216,240,0.14); }
.receipt-preview.template-night .empty-state { background: rgba(255,255,255,0.05); border-color: rgba(200,216,240,0.14); }
.receipt-preview.template-night .empty-state h4 { color: #e8f0ff; }
.receipt-preview.template-night .empty-state p { color: #7a99be; }

/* ── SAFFRON (vibrant Indian yellow-orange) ─── */
.receipt-preview.template-saffron { background: #1a0d00; color: #fde8b2; }
.receipt-preview.template-saffron .receipt-header { border-color: rgba(253,200,50,0.2); }
.receipt-preview.template-saffron .receipt-header h3 { color: #fff3cc; }
.receipt-preview.template-saffron .receipt-header .eyebrow { color: #ffc000; }
.receipt-preview.template-saffron .receipt-meta { color: #c8994d; }
.receipt-preview.template-saffron .receipt-line { background: rgba(255,200,50,0.07); border-color: rgba(253,200,50,0.15); }
.receipt-preview.template-saffron .receipt-line strong { color: #fff3cc; }
.receipt-preview.template-saffron .receipt-line > strong:last-child { color: #ffc000; font-weight: 700; }
.receipt-preview.template-saffron .receipt-footer { color: #c8994d; border-color: rgba(253,200,50,0.2); }
.receipt-preview.template-saffron .empty-state { background: rgba(255,200,50,0.06); border-color: rgba(253,200,50,0.2); }
.receipt-preview.template-saffron .empty-state h4 { color: #fff3cc; }
.receipt-preview.template-saffron .empty-state p { color: #c8994d; }

/* ── PAPER (soft cream, print-ready) ─── */
.receipt-preview.template-paper { background: #faf7f2; color: #2e2a24; border: 1px solid #ddd8ce; }
.receipt-preview.template-paper .receipt-header { border-color: #b8b0a0; border-bottom-style: solid; }
.receipt-preview.template-paper .receipt-header h3 { color: #2e2a24; font-family: Georgia, serif; }
.receipt-preview.template-paper .receipt-header .eyebrow { color: #7a7060; }
.receipt-preview.template-paper .receipt-meta { color: #7a7060; }
.receipt-preview.template-paper .receipt-line { background: transparent; border-color: transparent; border-bottom: 1px solid #ddd8ce; border-radius: 0; }
.receipt-preview.template-paper .receipt-line strong { color: #2e2a24; }
.receipt-preview.template-paper .receipt-line > strong:last-child { color: #2e2a24; font-weight: 700; }
.receipt-preview.template-paper .receipt-footer { color: #7a7060; border-top: 1px solid #b8b0a0; }
.receipt-preview.template-paper .empty-state { background: transparent; border-color: #ddd8ce; }
.receipt-preview.template-paper .empty-state h4 { color: #2e2a24; }
.receipt-preview.template-paper .empty-state p { color: #7a7060; }


/* ============================================================
   PRICE LIST SUMMARY
   ============================================================ */
.list-summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  font-size: 0.9rem;
  color: var(--text-2);
}

/* ============================================================
   BILLING
   ============================================================ */
.billing-layout { margin-top: 14px; }
.billing-actions button { flex: 1 1 180px; min-width: 0; }
.billing-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.list-table-wrapper { margin-bottom: 20px; overflow: auto; }

.customer-history { display: grid; gap: 12px; }

.history-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  padding: 14px;
  display: grid;
  gap: 8px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.history-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--primary); }

.history-card h4,
.history-card p { margin: 0; }

.history-card-top,
.history-meta { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.history-meta { color: var(--muted); font-size: 0.82rem; }

/* ============================================================
   SETTINGS
   ============================================================ */
.settings-tools { display: grid; gap: 14px; margin-top: 16px; }

.settings-tool-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.settings-tool-card h4 { margin: 0 0 10px; font-size: 0.9rem; }
.settings-tool-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.settings-tool-actions button { flex: 1 1 180px; min-width: 0; }

.settings-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 16px;
}

.about-card {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  box-shadow: var(--shadow-sm);
}

.about-card h4 { margin: 0 0 8px; font-size: 0.88rem; }
.about-card p { font-size: 0.85rem; }

.stack-actions { display: flex; flex-direction: column; gap: 10px; }
.stack-actions button { width: 100%; text-align: left; justify-content: flex-start; }

/* ============================================================
   MOBILE NAV
   ============================================================ */
.mobile-nav {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 16px;
  display: none;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  border-radius: 24px;
  z-index: 50;
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-lg);
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 6px;
  border-radius: 16px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 500;
  transition: color var(--transition), background var(--transition);
}

.mobile-nav-item:hover { color: var(--text); background: var(--surface-2); }
.mobile-nav-item.active { background: var(--primary); color: #fff; }
.mobile-nav-item i { font-size: 1.1rem; }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  right: 16px;
  bottom: 80px;
  min-width: 200px;
  max-width: min(88vw, 340px);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 0.88rem;
  font-weight: 500;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity var(--transition), transform var(--transition);
  z-index: 80;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-lg);
}

.toast.show { opacity: 1; transform: translateY(0); }

/* ============================================================
   MISC UTILITIES
   ============================================================ */
.eyebrow {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--primary);
  margin: 0 0 4px;
}

.text-muted { color: var(--muted); font-size: 0.88rem; }
.text-center { text-align: center; }

.empty-state {
  padding: 28px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  color: var(--muted);
}

.insight-item {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  box-shadow: var(--shadow-sm);
}

.insight-item p,
.product-card p,
.receipt-meta { color: var(--muted); }

@keyframes cardRise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes floatBlob {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-20px) scale(1.05); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}



/* ============================================================
   RESPONSIVE BREAKPOINTS
   ============================================================ */
@media (max-width: 1080px) {
  .two-column,
  .three-column,
  .settings-meta-grid,
  .dashboard-panels { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .app-main { padding: 16px 14px 96px; }
  .topbar { margin-bottom: 16px; padding: 10px 14px; top: 6px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .panel-grid { grid-template-columns: 1fr; }
  .mobile-nav { display: grid; }
}

@media (max-width: 640px) {
  .app-main { padding: 12px 12px 90px; }
  .topbar {
    padding: 8px 12px;
    gap: 8px;
    flex-wrap: wrap;
  }

  .topbar > div:first-child { flex: 1 1 auto; min-width: 0; }

  .topbar-meta { flex-shrink: 0; }

  .sync-pill,
  .user-pill { display: none; }

  .topbar-auth-btn { padding: 5px 14px; font-size: 0.78rem; }

  .stats-grid { grid-template-columns: 1fr; }
  .dashboard-hero { flex-direction: column; align-items: flex-start; padding: 18px 20px; gap: 14px; }
  .dashboard-hero-actions { width: 100%; }
  .panel { padding: 18px; }
  .panel-head { flex-wrap: wrap; }
  .form-grid { grid-template-columns: 1fr; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .two-column, .three-column { grid-template-columns: 1fr; }
}

@media (max-width: 400px) {
  .topbar { padding: 12px; }
  .panel { padding: 14px; }
  .product-grid { grid-template-columns: repeat(2, 1fr); }
}
