/* Three Amigos Bon Appetit — shared styles (mobile/tablet-first)
   Palette matches the distro_order_app.jsx reference mockup:
   stone-900 dark UI chrome, amber accent, emerald for cart/success actions. */

:root {
  --stone-900: #1c1917;
  --stone-800: #292524;
  --stone-700: #44403c;
  --stone-500: #78716c;
  --stone-400: #a8a29e;
  --stone-200: #e7e5e4;
  --stone-100: #f5f5f4;
  --stone-50: #fafaf9;

  --amber-50: #fffbeb;
  --amber-100: #fef3c7;
  --amber-300: #fcd34d;
  --amber-400: #fbbf24;
  --amber-500: #f59e0b;
  --amber-700: #b45309;
  --amber-900: #78350f;

  --emerald-50: #ecfdf5;
  --emerald-100: #d1fae5;
  --emerald-600: #059669;
  --emerald-700: #047857;

  --red-50: #fef2f2;
  --red-100: #fee2e2;
  --red-600: #dc2626;
  --red-900: #7f1d1d;

  --pink-50: #fdf2f8;
  --pink-100: #fce7f3;
  --pink-600: #db2777;
  --pink-900: #831843;

  --teal-50: #f0fdfa;
  --teal-100: #ccfbf1;
  --teal-600: #0d9488;
  --teal-900: #134e4a;

  --brown-50: #faf3ea;
  --brown-100: #f0e0cb;
  --brown-600: #92582a;
  --brown-900: #4a2d13;

  --violet-50: #f5f3ff;
  --violet-100: #ede9fe;
  --violet-600: #7c3aed;
  --violet-900: #4c1d95;

  --color-primary: var(--stone-900);
  --color-accent: var(--amber-500);
  --color-cart: var(--emerald-600);
  --color-bg: var(--stone-50);
  --color-surface: #ffffff;
  --color-border: var(--stone-200);
  --color-text: var(--stone-900);
  --color-text-muted: var(--stone-500);
  --color-danger: var(--red-600);

  --status-pending-bg: var(--amber-100);
  --status-pending-text: var(--amber-900);
  --status-fulfilled-bg: var(--teal-100);
  --status-fulfilled-text: var(--teal-900);
  --status-invoiced-bg: #e6eefb;
  --status-invoiced-text: #2a4d8f;
  --status-unpaid-bg: var(--red-100);
  --status-unpaid-text: var(--red-900);
  --status-paid-bg: var(--emerald-100);
  --status-paid-text: var(--emerald-700);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --nav-height: 64px;
  --header-height: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--color-bg);
  position: relative;
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 12px);
}

/* ---- Header (light, back-office pages) ---- */
.header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.header h1 {
  font-size: 18px;
  font-weight: 800;
  margin: 0;
}

.header .header-sub {
  font-size: 12px;
  color: var(--color-text-muted);
  font-weight: 600;
}

.user-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  font-size: 12px;
  color: var(--color-text-muted);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.user-strip strong {
  color: var(--color-text);
}

.user-strip-signout {
  border: none;
  background: none;
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

.icon-btn {
  border: none;
  background: var(--stone-100);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  color: var(--stone-900);
}
.icon-btn:active {
  transform: scale(0.96);
}

/* ---- Dark app bar (catalog/order flow, mockup style) ---- */
.dark-appbar {
  background: var(--stone-900);
  color: #fff;
  padding: 10px 16px 14px;
}
.dark-appbar .dark-appbar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.dark-appbar .eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--stone-400);
  font-weight: 800;
  margin: 0;
}
.dark-appbar .title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
.dark-appbar .title-row .title {
  font-weight: 800;
  font-size: 16px;
  line-height: 1;
}
.dark-appbar .icon {
  color: var(--amber-400);
}

.dark-icon-btn {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--stone-800);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
  font-size: 18px;
}
.dark-icon-btn:active {
  background: var(--stone-700);
}
.dark-icon-btn .cart-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--amber-500);
  color: var(--stone-900);
  font-size: 11px;
  font-weight: 800;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-box {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--stone-800);
  border-radius: 12px;
  padding: 10px 12px;
}
.search-box input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: #fff;
  font-size: 14px;
}
.search-box input::placeholder {
  color: var(--stone-400);
}
.search-box .icon {
  color: var(--stone-400);
}

/* ---- Main content ---- */
.content {
  padding: 16px;
}

/* ---- Bottom nav ---- */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  max-width: 720px;
  margin: 0 auto;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
}

.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  color: var(--color-text-muted);
  font-weight: 700;
}

.bottom-nav a .nav-icon {
  font-size: 20px;
  line-height: 1;
}

.bottom-nav a.active {
  color: var(--stone-900);
}
.bottom-nav a.active .nav-icon {
  color: var(--amber-500);
}

/* ---- Dashboard summary cards ---- */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px;
}

.stat-card .stat-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--stone-900);
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--color-text-muted);
  font-weight: 600;
  margin-top: 2px;
}

.section-title {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  margin: 20px 0 10px;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.quick-action {
  background: var(--stone-900);
  color: #fff;
  border-radius: var(--radius-md);
  padding: 14px;
  font-weight: 800;
  font-size: 13px;
  text-align: center;
  border: none;
  cursor: pointer;
}
.quick-action.accent {
  background: var(--color-cart);
}
.quick-action:active {
  filter: brightness(1.15);
}

/* ---- Lists / cards ---- */
.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
}
.card:active {
  filter: brightness(0.98);
}

.card-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.card-title {
  font-weight: 800;
  font-size: 15px;
}

.card-subtitle {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.card-meta {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 8px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.card-amount {
  font-weight: 800;
  font-size: 15px;
  white-space: nowrap;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-text-muted);
}
.empty-state .empty-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

/* ---- Status badges ---- */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
  text-transform: capitalize;
  white-space: nowrap;
}
.badge.pending { background: var(--status-pending-bg); color: var(--status-pending-text); }
.badge.fulfilled { background: var(--status-fulfilled-bg); color: var(--status-fulfilled-text); }
.badge.invoiced { background: var(--status-invoiced-bg); color: var(--status-invoiced-text); }
.badge.unpaid { background: var(--status-unpaid-bg); color: var(--status-unpaid-text); }
.badge.paid { background: var(--status-paid-bg); color: var(--status-paid-text); }

/* ---- Filter chips (light, back-office lists) ---- */
.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 14px;
}
.chip-row::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text-muted);
  cursor: pointer;
}
.chip.active {
  background: var(--stone-900);
  border-color: var(--stone-900);
  color: #fff;
}

/* ---- Category chips (dark catalog strip, mockup style) ---- */
.category-strip {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}
.category-strip::-webkit-scrollbar { display: none; }

.category-chip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}
.category-chip .cat-icon { font-size: 14px; }

.category-chip.ring-amber { background: var(--amber-100); color: var(--amber-900); border-color: var(--amber-300); }
.category-chip.ring-amber.active { background: var(--amber-500); color: #fff; border-color: var(--amber-500); }
.category-chip.ring-red { background: var(--red-100); color: var(--red-900); border-color: #fecaca; }
.category-chip.ring-red.active { background: var(--red-600); color: #fff; border-color: var(--red-600); }
.category-chip.ring-pink { background: var(--pink-100); color: var(--pink-900); border-color: #fbcfe8; }
.category-chip.ring-pink.active { background: var(--pink-600); color: #fff; border-color: var(--pink-600); }
.category-chip.ring-teal { background: var(--teal-100); color: var(--teal-900); border-color: #99f6e4; }
.category-chip.ring-teal.active { background: var(--teal-600); color: #fff; border-color: var(--teal-600); }
.category-chip.ring-brown { background: var(--brown-100); color: var(--brown-900); border-color: #e2c9a0; }
.category-chip.ring-brown.active { background: var(--brown-600); color: #fff; border-color: var(--brown-600); }
.category-chip.ring-violet { background: var(--violet-100); color: var(--violet-900); border-color: #ddd6fe; }
.category-chip.ring-violet.active { background: var(--violet-600); color: #fff; border-color: var(--violet-600); }

/* ---- Product grid (catalog) ---- */
.product-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 12px 16px 90px;
}
@media (min-width: 600px) {
  .product-grid { grid-template-columns: repeat(3, 1fr); }
}

.product-tile {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.product-tile .tile-art {
  position: relative;
  height: 78px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--color-border);
  font-weight: 800;
  font-size: 17px;
  letter-spacing: 0.02em;
}
.tile-art.ring-amber { background: var(--amber-50); color: var(--amber-700); }
.tile-art.ring-red { background: var(--red-50); color: var(--red-600); }
.tile-art.ring-pink { background: var(--pink-50); color: var(--pink-600); }
.tile-art.ring-teal { background: var(--teal-50); color: var(--teal-600); }
.tile-art.ring-brown { background: var(--brown-50); color: var(--brown-600); }
.tile-art.ring-violet { background: var(--violet-50); color: var(--violet-600); }

.tile-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  transform: rotate(-6deg);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
}
.tile-badge.ring-amber { background: var(--amber-500); }
.tile-badge.ring-red { background: var(--red-600); }
.tile-badge.ring-pink { background: var(--pink-600); }
.tile-badge.ring-teal { background: var(--teal-600); }
.tile-badge.ring-brown { background: var(--brown-600); }
.tile-badge.ring-violet { background: var(--violet-600); }

.product-tile .tile-body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tile-name {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
}
.tile-size {
  font-size: 11px;
  color: var(--color-text-muted);
  font-weight: 600;
}
.tile-footer {
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tile-price {
  font-size: 14px;
  font-weight: 800;
}

.add-btn {
  background: var(--stone-900);
  color: #fff;
  border: none;
  font-size: 11px;
  font-weight: 800;
  padding: 7px 11px;
  border-radius: 8px;
  cursor: pointer;
}
.add-btn:active { background: var(--stone-700); }

.stepper {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--stone-100);
  border-radius: 8px;
}
.stepper button {
  width: 26px;
  height: 26px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  border-radius: 8px;
  color: var(--stone-900);
}
.stepper button:active { background: var(--stone-200); }
.stepper .qty {
  width: 18px;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
}

/* ---- Sticky cart bar (mockup style) ---- */
.cart-bar {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 12px);
  z-index: 25;
  max-width: 688px;
  margin: 0 auto;
  background: var(--color-cart);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 13px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(5, 150, 105, 0.3);
  font-size: 14px;
  font-weight: 700;
}
.cart-bar .cart-bar-cta {
  font-weight: 800;
}

/* ---- Floating action button ---- */
.fab {
  position: fixed;
  right: 20px;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
  z-index: 25;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--stone-900);
  color: #fff;
  border: none;
  font-size: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(28, 25, 23, 0.35);
  cursor: pointer;
}
.fab:active {
  transform: scale(0.95);
}

/* ---- Bottom sheet / modal ---- */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 15, 10, 0.45);
  z-index: 40;
  display: none;
}
.sheet-overlay.open {
  display: block;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  max-width: 720px;
  margin: 0 auto;
  max-height: 88vh;
  background: var(--color-surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  transform: translateY(100%);
  transition: transform 0.22s ease;
  display: flex;
  flex-direction: column;
}
.sheet.open {
  transform: translateY(0);
}

.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--color-border);
  border-radius: 999px;
  margin: 10px auto 4px;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 12px;
  border-bottom: 1px solid var(--color-border);
}

.sheet-header h2 {
  font-size: 17px;
  margin: 0;
  font-weight: 800;
}

.sheet-body {
  padding: 16px;
  overflow-y: auto;
}

.sheet-footer {
  padding: 12px 16px calc(16px + var(--safe-bottom));
  border-top: 1px solid var(--color-border);
}

/* ---- Forms ---- */
.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 12px;
  font-weight: 800;
  color: var(--color-text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 12px 12px;
  font-size: 15px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text);
  font-family: inherit;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid var(--stone-900);
  outline-offset: -1px;
}

.field-row {
  display: flex;
  gap: 10px;
}
.field-row .field {
  flex: 1;
}

.btn {
  display: block;
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--stone-900);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  text-align: center;
}
.btn:active {
  filter: brightness(1.15);
}
.btn.secondary {
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.btn.accent {
  background: var(--color-cart);
}
.btn.small {
  width: auto;
  padding: 8px 14px;
  font-size: 13px;
}
.btn.danger {
  background: var(--color-danger);
}

/* ---- Line items builder ---- */
.line-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.line-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px;
}

.line-item .li-name {
  flex: 1;
  font-size: 13px;
  font-weight: 700;
}
.line-item .li-sub {
  font-size: 11px;
  color: var(--color-text-muted);
}

.line-item .li-remove {
  border: none;
  background: none;
  color: var(--color-danger);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
}

.line-item .li-barcode {
  margin-top: 8px;
  max-width: 100%;
}
.line-item .li-barcode svg {
  max-width: 100%;
  height: auto;
  display: block;
}
.line-item .li-upc {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  font-weight: 700;
  color: var(--color-text-muted);
  letter-spacing: 0.03em;
  margin-top: 3px;
}

/* ---- UPC block (used in Add-to-Order modal) ---- */
.upc-block {
  margin-top: 16px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.upc-block .upc-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  font-weight: 700;
  margin-bottom: 8px;
}
.upc-block .upc-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-align: center;
}

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 2px;
  font-weight: 700;
}
.total-row .total-label {
  color: var(--color-text-muted);
  font-weight: 600;
}
.total-row.grand {
  font-size: 18px;
  border-top: 1px solid var(--color-border);
  margin-top: 4px;
  padding-top: 12px;
}

/* ---- Detail view ---- */
.detail-header {
  margin-bottom: 16px;
}
.detail-header .detail-title {
  font-size: 20px;
  font-weight: 800;
}
.detail-header .detail-subtitle {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.info-item .info-label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--color-text-muted);
  font-weight: 700;
  margin-bottom: 3px;
}
.info-item .info-value {
  font-size: 14px;
  font-weight: 600;
}

hr.divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 16px 0;
}

/* ---- Order confirmation ---- */
.confirm-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-top: 48px;
  gap: 10px;
  padding: 0 24px;
}
.confirm-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--emerald-100);
  color: var(--emerald-700);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
}
.confirm-title {
  font-weight: 800;
  font-size: 18px;
}
.confirm-sub {
  font-size: 13px;
  color: var(--color-text-muted);
}

/* ---- Tablet / larger screens ---- */
@media (min-width: 600px) {
  .app {
    box-shadow: 0 0 0 1px var(--color-border);
  }
  .stat-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
