*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #ffffff;
  --bg-secondary: #f5f4f0;
  --bg-tertiary: #efede8;
  --text: #1a1a1a;
  --text-secondary: #666660;
  --border: rgba(0,0,0,0.1);
  --border-mid: rgba(0,0,0,0.2);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --amber: #FAC775;
  --amber-bg: #FAEEDA;
  --amber-text: #633806;
  --amber-mid: #BA7517;
  --green-bg: #EAF3DE;
  --green-text: #27500A;
  --green-mid: #3B6D11;
  --purple-bg: #EEEDFE;
  --purple-text: #3C3489;
  --teal-bg: #E1F5EE;
  --teal-text: #085041;
  --blue-bg: #E6F1FB;
  --blue-text: #0C447C;
  --pink-bg: #FBEAF0;
  --pink-text: #72243E;
  --coral-bg: #FAECE7;
  --coral-text: #993C1D;
  --red-bg: #FCEBEB;
  --red-text: #791F1F;
  --gray-bg: #EEEEEC;
  --gray-text: #2C2C2A;
  --nav-height: 58px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1c1a;
    --bg-secondary: #242422;
    --bg-tertiary: #2c2c2a;
    --text: #f0ede8;
    --text-secondary: #999890;
    --border: rgba(255,255,255,0.08);
    --border-mid: rgba(255,255,255,0.18);
    --amber-bg: #412402;
    --amber-text: #FAC775;
    --green-bg: #173404;
    --green-text: #C0DD97;
    --green-mid: #7DBF3A;
    --purple-bg: #26215C;
    --purple-text: #CECBF6;
    --teal-bg: #04342C;
    --teal-text: #9FE1CB;
    --blue-bg: #042C53;
    --blue-text: #B5D4F4;
    --pink-bg: #4B1528;
    --pink-text: #F4C0D1;
    --coral-bg: #4A1B0C;
    --coral-text: #F5C4B3;
    --red-bg: #501313;
    --red-text: #F7C1C1;
    --gray-bg: #2C2C2A;
    --gray-text: #E4E4E0;
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-tertiary);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
}

/* ── NAV ── */
#nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  border-bottom: 0.5px solid var(--border);
  height: var(--nav-height);
}
.nav-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1rem;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}
.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--amber-bg);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--amber-text);
}
.logo-text { font-size: 15px; font-weight: 600; color: var(--text); }
.logo-sub  { font-size: 11px; color: var(--text-secondary); }
.nav-links {
  display: flex;
  gap: 2px;
  margin-left: auto;
  flex-wrap: wrap;
}
.nav-link {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 500;
  transition: background 0.1s;
}
.nav-link:hover { background: var(--bg-secondary); color: var(--text); }
.nav-link.active { background: var(--bg-secondary); color: var(--text); }
.btn-disconnect {
  margin-left: 8px;
  padding: 5px 12px;
  font-size: 12px;
  border: 0.5px solid var(--border-mid);
  background: none;
  cursor: pointer;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: inherit;
  flex-shrink: 0;
}
.btn-disconnect:hover { background: var(--red-bg); color: var(--red-text); border-color: transparent; }

/* ── SETUP SCREEN ── */
.setup-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.setup-card {
  background: var(--bg);
  border: 0.5px solid var(--border-mid);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 420px;
}
.setup-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 1rem; }
.setup-logo .logo-icon { width: 40px; height: 40px; font-size: 20px; }
.setup-title { font-size: 22px; font-weight: 700; }
.setup-sub { font-size: 13px; color: var(--text-secondary); margin-bottom: 1.5rem; line-height: 1.6; }
.setup-hint { font-size: 12px; color: var(--text-secondary); text-align: center; margin-top: 12px; }

/* ── CONTAINER ── */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* ── PAGE HEADER ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 10px;
}
.page-title { font-size: 20px; font-weight: 700; }
.page-sub { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

/* ── METRICS ── */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 1.5rem;
}
.metric {
  background: var(--bg);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
}
.metric-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 3px; }
.metric-value { font-size: 22px; font-weight: 700; }
.metric-value.good { color: var(--green-mid); }
.metric-value.warn { color: var(--amber-mid); }

/* ── TOOLBAR ── */
.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  align-items: center;
}

/* ── FORM ELEMENTS ── */
input[type=text],
input[type=number],
input[type=password],
select {
  width: 100%;
  padding: 8px 10px;
  border: 0.5px solid var(--border-mid);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
}
input:focus, select:focus {
  border-color: #888;
  box-shadow: 0 0 0 3px rgba(100,100,100,0.1);
}
.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  font-weight: 500;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ── BUTTONS ── */
.btn-primary {
  padding: 9px 18px;
  font-size: 14px;
  border: none;
  background: var(--amber-bg);
  cursor: pointer;
  border-radius: var(--radius-md);
  color: var(--amber-text);
  font-weight: 600;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary:hover { opacity: 0.85; }
.btn-secondary {
  padding: 7px 14px;
  font-size: 13px;
  border: 0.5px solid var(--border-mid);
  background: var(--bg);
  cursor: pointer;
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-secondary:hover { background: var(--bg-secondary); }
.btn-danger {
  padding: 7px 14px;
  font-size: 13px;
  border: none;
  background: var(--red-bg);
  cursor: pointer;
  border-radius: var(--radius-md);
  color: var(--red-text);
  font-family: inherit;
}
.btn-cancel {
  padding: 7px 14px;
  font-size: 13px;
  border: 0.5px solid var(--border-mid);
  background: none;
  cursor: pointer;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: inherit;
}
.btn-cancel:hover { background: var(--bg-secondary); }
.btn-save {
  padding: 7px 16px;
  font-size: 13px;
  border: none;
  background: var(--amber-bg);
  cursor: pointer;
  border-radius: var(--radius-md);
  color: var(--amber-text);
  font-weight: 600;
  font-family: inherit;
}
.btn-save:hover { opacity: 0.85; }
.btn-save:disabled { opacity: 0.5; cursor: default; }
.icon-btn {
  width: 28px; height: 28px;
  border: none; background: none;
  cursor: pointer; color: var(--text-secondary);
  display: inline-flex; align-items: center;
  justify-content: center; border-radius: 5px; font-size: 15px;
}
.icon-btn:hover { background: var(--bg-secondary); color: var(--text); }
.icon-btn.danger:hover { background: var(--coral-bg); color: var(--coral-text); }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; background: var(--bg); border: 0.5px solid var(--border); border-radius: var(--radius-lg); }
table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; min-width: 500px; }
thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 12px 12px 10px;
  border-bottom: 0.5px solid var(--border);
}
tbody tr { border-bottom: 0.5px solid var(--border); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-secondary); }
tbody td { padding: 10px 12px; vertical-align: middle; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-name { width: 32%; } .col-cat { width: 14%; } .col-price { width: 12%; }
.col-cost { width: 12%; color: var(--text-secondary); } .col-stock { width: 20%; } .col-act { width: 10%; text-align: right; }
.price-margin { font-size: 10px; color: var(--text-secondary); }

/* Tablet: drop Cost column, redistribute widths */
@media (max-width: 860px) {
  .col-cost  { display: none; }
  .col-name  { width: 36%; }
  .col-cat   { width: 16%; }
  .col-price { width: 14%; }
  .col-stock { width: 22%; }
  .col-act   { width: 12%; }
}

/* Mobile: card layout — CSS Grid for predictable placement */
@media (max-width: 640px) {
  .table-wrap { overflow: visible; background: transparent; border: none; border-radius: 0; }
  table { display: block; min-width: 0; width: 100%; }
  thead { display: none; }
  tbody { display: flex; flex-direction: column; gap: 10px; }
  tbody tr {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "name  name"
      "cat   price"
      "stock act";
    row-gap: 10px;
    column-gap: 12px;
    background: var(--bg);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  }
  tbody tr:last-child { border-bottom: 0.5px solid var(--border); }
  tbody tr:hover { background: var(--bg-secondary); }
  tbody td { display: block; padding: 0; border: none; overflow: visible; white-space: normal; text-overflow: clip; }

  /* Row 1: Name */
  .col-name {
    grid-area: name; align-self: center;
    font-weight: 700; font-size: 15px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }

  /* Row 2: Category badge (left) · Price (right) */
  .col-cat   { grid-area: cat;   align-self: center; }
  .col-price {
    grid-area: price; align-self: center;
    text-align: right; white-space: nowrap;
    font-size: 13px; font-weight: 600; color: var(--text);
  }
  .col-price .price-margin { font-size: 10px; font-weight: 400; color: var(--text-secondary); }
  .col-price .price-margin::before { content: " · "; }
  .col-cost  { display: none; }

  /* Row 3: Stock controls (left) + Edit/Del (right), divided by a rule */
  .col-stock {
    grid-area: stock; align-self: center;
    border-top: 0.5px solid var(--border); padding-top: 10px;
  }
  .col-act {
    grid-area: act; align-self: center;
    display: flex; gap: 6px; justify-content: flex-end;
    border-top: 0.5px solid var(--border); padding-top: 10px;
  }

  /* Stock controls — generous touch targets */
  .stock-cell { gap: 8px; }
  .adj-btn {
    width: 36px; height: 36px; font-size: 18px; font-weight: 700;
    border-radius: var(--radius-md);
    border: 0.5px solid var(--border-mid);
    background: var(--bg-secondary);
  }
  .adj-btn:hover { background: var(--bg-tertiary); color: var(--text); }
  .stock-num { font-size: 17px; font-weight: 700; min-width: 30px; text-align: center; }

  /* Action buttons */
  .col-act .icon-btn-text {
    height: 34px; padding: 0 14px;
    font-size: 12px; font-weight: 600; letter-spacing: 0.01em;
    border-radius: var(--radius-md);
    border: 0.5px solid var(--border-mid);
    background: var(--bg-secondary); color: var(--text);
  }
  .col-act .icon-btn.danger.icon-btn-text {
    background: var(--red-bg); color: var(--red-text); border-color: transparent;
  }
}

/* ── BADGES ── */
.cat-badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; }
.cat-sticker  { background: var(--purple-bg); color: var(--purple-text); }
.cat-keychain { background: var(--teal-bg);   color: var(--teal-text);   }
.low-badge { font-size: 10px; padding: 2px 6px; border-radius: 99px; font-weight: 600; }
.low-low { background: var(--amber-bg); color: var(--amber-text); }
.low-out { background: var(--coral-bg); color: var(--coral-text); }
.method-pill { font-size: 11px; padding: 2px 8px; border-radius: 99px; font-weight: 600; white-space: nowrap; }
.pill-cashapp { background: var(--teal-bg);   color: var(--teal-text);   }
.pill-venmo   { background: var(--blue-bg);   color: var(--blue-text);   }
.pill-paypal  { background: var(--purple-bg); color: var(--purple-text); }
.pill-zelle   { background: var(--pink-bg);   color: var(--pink-text);   }
.pill-square  { background: var(--gray-bg);   color: var(--gray-text);   }
.pill-cash    { background: var(--amber-bg);  color: var(--amber-text);  }

/* ── STOCK CONTROLS ── */
.stock-cell { display: flex; align-items: center; gap: 6px; }
.stock-num { min-width: 24px; font-weight: 700; }
.stock-low { color: var(--amber-mid); }
.stock-out { color: var(--coral-text); }
.adj-btn {
  width: 22px; height: 22px;
  border-radius: 4px;
  border: 0.5px solid var(--border-mid);
  background: var(--bg-secondary);
  cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); line-height: 1;
}
.adj-btn:hover { background: var(--bg); color: var(--text); }

/* ── MODAL ── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 1rem;
}
.modal {
  background: var(--bg);
  border-radius: var(--radius-lg);
  border: 0.5px solid var(--border-mid);
  padding: 1.5rem;
  width: 100%; max-width: 400px;
  max-height: 90vh; overflow-y: auto;
}
.modal-header {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 1.25rem;
}
.modal-header span { font-size: 17px; font-weight: 700; }
.modal-close {
  background: none; border: none;
  font-size: 22px; cursor: pointer;
  color: var(--text-secondary); line-height: 1;
}
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 1.25rem; }

/* ── SALE ROWS ── */
.sale-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.sale-row select { flex: 1; }
.sale-row input[type=number] { width: 70px; flex-shrink: 0; }

/* ── PAYMENT METHODS ── */
.pay-methods { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.pay-btn {
  border: 1.5px solid var(--border);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 8px 4px;
  cursor: pointer;
  text-align: center;
  font-size: 11px; font-weight: 600;
  color: var(--text-secondary);
  font-family: inherit;
}
.pay-btn:hover { border-color: var(--border-mid); }
.pay-btn.sel-cashapp { background: var(--teal-bg);   color: var(--teal-text);   border-color: #1D9E75; }
.pay-btn.sel-venmo   { background: var(--blue-bg);   color: var(--blue-text);   border-color: #378ADD; }
.pay-btn.sel-paypal  { background: var(--purple-bg); color: var(--purple-text); border-color: #7F77DD; }
.pay-btn.sel-zelle   { background: var(--pink-bg);   color: var(--pink-text);   border-color: #D4537E; }
.pay-btn.sel-square  { background: var(--gray-bg);   color: var(--gray-text);   border-color: #888780; }
.pay-btn.sel-cash    { background: var(--amber-bg);  color: var(--amber-text);  border-color: #BA7517; }

/* ── SALES LIST ── */
.sale-entry {
  display: flex; justify-content: space-between;
  align-items: center; padding: 12px 0;
  border-bottom: 0.5px solid var(--border);
}
.sale-entry:last-child { border-bottom: none; }
.sale-desc { font-size: 13px; font-weight: 500; }
.sale-time { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.sale-right { display: flex; align-items: center; gap: 10px; }
.sale-amount { font-weight: 700; font-size: 14px; min-width: 56px; text-align: right; }

/* ── BREAKDOWN ── */
.breakdown-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 1.5rem;
}
.breakdown-card {
  background: var(--bg);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
}
.breakdown-label { font-size: 11px; font-weight: 700; margin-bottom: 4px; }
.breakdown-amount { font-size: 22px; font-weight: 700; }
.breakdown-count { font-size: 11px; color: var(--text-secondary); margin-top: 3px; }
.bc-cashapp .breakdown-label { color: var(--teal-text); }
.bc-venmo   .breakdown-label { color: var(--blue-text); }
.bc-paypal  .breakdown-label { color: var(--purple-text); }
.bc-zelle   .breakdown-label { color: var(--pink-text); }
.bc-square  .breakdown-label { color: var(--gray-text); }
.bc-cash    .breakdown-label { color: var(--amber-text); }
.bar-track { height: 8px; background: var(--bg-secondary); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.bar-fill  { height: 100%; border-radius: 99px; }

/* ── ALERTS ── */
.alert-card {
  background: var(--bg);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  display: flex; align-items: center;
  gap: 12px; padding: 14px;
  margin-bottom: 8px;
}
.alert-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  display: flex; align-items: center;
  justify-content: center; font-size: 18px; flex-shrink: 0;
}
.alert-low { background: var(--amber-bg); }
.alert-out { background: var(--coral-bg); }
.alert-name { font-weight: 600; font-size: 14px; }
.alert-detail { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* ── MISC ── */
.card {
  background: var(--bg);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.section-title {
  font-size: 11px; font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}
.total-row {
  display: flex; justify-content: space-between;
  font-size: 16px; font-weight: 700;
  padding-top: 14px;
  border-top: 0.5px solid var(--border-mid);
  margin-top: 8px;
}
.divider { border: none; border-top: 0.5px solid var(--border); margin: 1rem 0; }
.msg { font-size: 13px; padding: 10px 12px; border-radius: var(--radius-md); margin-top: 8px; }
.msg.error   { background: var(--red-bg);   color: var(--red-text); }
.msg.success { background: var(--green-bg); color: var(--green-text); }
.msg.info    { background: var(--blue-bg);  color: var(--blue-text); }
.empty {
  text-align: center; padding: 3rem 1rem;
  color: var(--text-secondary); font-size: 14px;
  background: var(--bg); border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
}
.empty-icon { font-size: 40px; margin-bottom: 12px; }
.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid var(--border-mid);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -3px; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 860px) {
  .nav-email { display: none; }
  .nav-link { padding: 5px 8px; font-size: 12px; }
}
@media (max-width: 640px) {
  .nav-links { display: none; }
  .mobile-nav {
    display: flex;
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--bg);
    border-top: 0.5px solid var(--border);
    z-index: 50;
    padding: 6px 0 env(safe-area-inset-bottom);
  }
  .mobile-nav a {
    flex: 1;
    display: flex; flex-direction: column; align-items: center;
    text-align: center;
    font-size: 10px; font-weight: 600;
    text-decoration: none; color: var(--text-secondary);
    padding: 4px 2px; gap: 2px;
  }
  .mobile-nav a.active { color: var(--amber-text); }
  .mobile-nav-icon { font-size: 18px; line-height: 1; }
  body { padding-bottom: 80px; }
  .pay-methods { grid-template-columns: repeat(3, 1fr); }
  .field-row { grid-template-columns: 1fr; }
  .btn-disconnect { display: none; }

  /* Toolbar: search full-width, filters side-by-side */
  .toolbar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .toolbar #search-input { grid-column: 1 / -1; max-width: none; }
  .toolbar select { width: 100%; }

  /* Page header actions: stack buttons full-width */
  .page-header-actions { flex-direction: column; width: 100%; }
  .page-header-actions .btn-secondary,
  .page-header-actions .btn-primary { width: 100%; justify-content: center; }
}
@media (min-width: 641px) {
  .mobile-nav { display: none; }
}

/* ── SETTINGS ── */
.color-swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.color-swatch {
  width: 34px; height: 34px;
  border-radius: var(--radius-md);
  cursor: pointer;
  outline: 2px solid transparent;
  outline-offset: 2px;
  transition: outline-color 0.1s;
}
.color-swatch.selected { outline-width: 2.5px; }
.cat-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0;
  border-bottom: 0.5px solid var(--border);
}
.cat-row:last-child { border-bottom: none; }
.danger-zone {
  border-color: var(--red-text) !important;
}
.danger-title { color: var(--red-text); font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.danger-desc { font-size: 12px; color: var(--text-secondary); margin-bottom: 1rem; }

/* ── AUTH NAV ADDITIONS ── */
.nav-user { display: flex; align-items: center; gap: 10px; margin-left: 8px; flex-shrink: 0; }
.nav-email { font-size: 12px; color: var(--text-secondary); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) { .nav-email { display: none; } }

/* ── ENRICHED SALE MODAL ── */
.modal-sale-wide { max-width: 500px; }
.modal-subtitle { font-size: 12px; color: var(--text-secondary); font-weight: 400; margin-top: 1px; }

.sale-section-label {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin: 16px 0 8px;
}

/* Item rows */
.sale-item-row {
  background: var(--bg-secondary);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-bottom: 8px;
}
.sir-top { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.si-combo { position: relative; flex: 1; min-width: 0; }
.si-combo .si-search { width: 100%; }
.si-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  z-index: 200;
  background: var(--bg);
  border: 0.5px solid var(--border-mid);
  border-radius: var(--radius-md);
  box-shadow: 0 6px 20px rgba(0,0,0,0.22);
  max-height: 200px;
  overflow-y: auto;
}
.si-drop-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 0.5px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}
.si-drop-item:last-child { border-bottom: none; }
.si-drop-item:hover { background: var(--bg-secondary); }
.si-drop-item.selected { background: var(--amber-bg); }
.si-drop-name { flex: 1; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.si-drop-price { font-size: 13px; font-weight: 700; flex-shrink: 0; }
.si-drop-empty { padding: 10px 12px; font-size: 13px; color: var(--text-secondary); text-align: center; }
.sir-bottom { display: flex; align-items: center; justify-content: space-between; }
.sir-line-total { font-size: 14px; font-weight: 700; min-width: 60px; text-align: right; }

/* Qty controls */
.qty-ctrl {
  display: inline-flex; align-items: center;
  background: var(--bg);
  border: 0.5px solid var(--border-mid);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.qty-btn {
  width: 32px; height: 32px;
  border: none; background: none;
  cursor: pointer; font-size: 17px; line-height: 1;
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
  font-family: inherit;
}
.qty-btn:hover { background: var(--bg-tertiary); }
.qty-input {
  width: 42px; height: 32px;
  border: none;
  border-left: 0.5px solid var(--border);
  border-right: 0.5px solid var(--border);
  text-align: center;
  font-size: 14px; font-weight: 600;
  background: var(--bg); color: var(--text);
  font-family: inherit; padding: 0;
  -moz-appearance: textfield;
  appearance: textfield;
}
.qty-ctrl .qty-input { width: 42px; }
.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button { -webkit-appearance: none; }

/* Bundle chips */
.bundle-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.bundle-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px;
  background: var(--amber-bg); color: var(--amber-text);
  border: 1.5px solid transparent;
  border-radius: 99px;
  font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: border-color 0.1s, opacity 0.1s;
}
.bundle-chip:hover { border-color: var(--amber-mid); opacity: 0.9; }
.bundle-chip-price { opacity: 0.7; }

/* Discount */
.discount-type-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.disc-tabs {
  display: flex;
  background: var(--bg-secondary);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.disc-tab {
  padding: 6px 14px;
  font-size: 12px; font-weight: 600;
  border: none; background: none;
  cursor: pointer; color: var(--text-secondary);
  font-family: inherit; line-height: 1;
}
.disc-tab.active { background: var(--bg); color: var(--text); box-shadow: inset 0 0 0 0.5px var(--border-mid); }
.disc-input-wrap { display: flex; align-items: center; gap: 6px; }
.disc-input-wrap input { width: 80px; }
.disc-unit { font-size: 14px; font-weight: 600; color: var(--text-secondary); }

/* Sale totals */
.sale-totals {
  background: var(--bg-secondary);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 16px;
}
.sale-total-row {
  display: flex; justify-content: space-between;
  font-size: 13px; color: var(--text-secondary);
  padding: 3px 0;
}
.sale-total-discount { color: var(--green-mid); font-weight: 600; }
.sale-total-final {
  display: flex; justify-content: space-between;
  font-size: 17px; font-weight: 700; color: var(--text);
  padding-top: 8px; margin-top: 6px;
  border-top: 0.5px solid var(--border-mid);
}
.sale-total-final .final-amt { color: var(--green-mid); }

/* Bundle item rows (settings form) */
.bundle-item-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.bundle-item-row select { flex: 1; }
.bundle-item-row input[type=number] { width: 70px; flex-shrink: 0; }

/* Utility overrides used in sale modal */
.sale-section-first { margin-top: 0; }
.sale-disc-wrap { margin-bottom: 16px; }
#btn-add-sale-row { margin-bottom: 4px; }

/* ── PAGE LAYOUT ── */
.page-header-actions { display: flex; gap: 8px; }

/* ── TOOLBAR ── */
.toolbar select { width: auto; }
#search-input { max-width: 220px; }

/* ── CARD VARIANTS ── */
.card-flush { padding: 0; }
#sales-list { padding: 0 1.25rem; }

/* ── BUTTON VARIANTS ── */
.icon-btn-text { width: auto; padding: 0 8px; }
.btn-sm { font-size: 12px; padding: 4px 10px; flex-shrink: 0; }

/* ── SALE ROW INPUTS (edit modal) ── */
.sale-row .si-qty { width: 60px; }
.sale-row .si-price { width: 76px; }
#btn-add-edit-row { margin-bottom: 16px; }

/* ── EDIT SALE MODAL ── */
.edit-col-header { display: flex; gap: 8px; font-size: 11px; color: var(--text-secondary); margin-bottom: 4px; padding: 0 2px; }
.edit-col-header .col-item { flex: 1; }
.edit-col-header .col-qty { width: 60px; }
.edit-col-header .col-price { width: 76px; }
.edit-col-header .col-act { width: 28px; }
.edit-sale-total { text-align: right; font-size: 15px; font-weight: 700; color: var(--green-mid); margin: 10px 0 6px; }
.edit-sale-note { font-size: 11px; color: var(--text-secondary); margin: 0 0 12px; }

/* ── BADGE VARIANTS ── */
.pill-discount { background: var(--green-bg); color: var(--green-text); }

/* ── SHARED FORM COMPONENTS ── */
.form-title { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.form-footer { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.form-msg { font-size: 12px; color: var(--text-secondary); }

/* ── SETTINGS – CATEGORIES ── */
.cat-preview-badge { font-size: 13px; padding: 4px 14px; }
.danger-zone-body { display: flex; flex-direction: column; gap: 14px; }
.danger-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.danger-item-title { font-size: 13px; font-weight: 600; }
.danger-item-desc { font-size: 12px; color: var(--text-secondary); }
.divider-flush { margin: 0; }

/* ── SETTINGS – BUNDLE BUILDER ── */
.bundle-desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 16px; }
.bundle-add-item-btn { margin-top: 6px; font-size: 12px; padding: 5px 10px; }

/* ── ALERTS ── */
.alert-section-title { margin-bottom: 8px; }
.alert-section-list { margin-bottom: 1.5rem; }
.alert-content { flex: 1; }
.alert-cat-badge { margin-right: 6px; }
.alert-bar { margin-top: 6px; max-width: 200px; }

/* ── SHARED UTILITIES ── */
.flex-fill { flex: 1; min-width: 0; }
.flex-noshrink { flex-shrink: 0; }
.list-empty-msg { font-size: 13px; color: var(--text-secondary); padding: 4px 0 8px; }
.msg-spaced { margin-bottom: 12px; }
.cat-badge-lg { font-size: 13px; padding: 4px 14px; }
.pill-spaced { margin-left: 6px; }
.bundle-list-name { font-weight: 600; }
.bundle-item-list { font-size: 12px; color: var(--text-secondary); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sql-block { margin-top: 8px; font-size: 11px; background: var(--bg-tertiary); padding: 8px; border-radius: 6px; overflow-x: auto; white-space: pre-wrap; }

/* ── EOD / BREAKDOWN LAYOUT ── */
.card-hero { text-align: center; }
.hero-section-title { margin-bottom: 6px; }
#hero-revenue { font-size: 52px; font-weight: 800; color: var(--green-mid); line-height: 1.1; }

.two-col-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
@media (max-width: 640px) {
  .two-col-grid { grid-template-columns: 1fr; }
}

.metrics-compact { margin-bottom: 1rem; }
.card-no-mb { margin-bottom: 0; }

.method-bar-row { margin-bottom: 12px; }
.method-bar-label {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--text-secondary);
  margin-bottom: 4px;
}

.rank-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0;
  border-bottom: 0.5px solid var(--border);
  font-size: 13px;
}
.rank-row:last-child { border-bottom: none; }
.rank-num { color: var(--text-secondary); flex-shrink: 0; min-width: 24px; }
.rank-name { flex: 1; padding: 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-val { font-weight: 700; flex-shrink: 0; }

.card-list-header {
  padding: 1rem 1.25rem 0.75rem;
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 0.5px solid var(--border);
}
.section-title-inline { margin-bottom: 0; }
.card-list-count { font-size: 12px; color: var(--text-secondary); }
.card-list-body { padding: 0 1.25rem; }

.select-auto { width: auto; }
.bar-fill-amber { background: var(--amber-mid); }

/* ── SALE ITEM PICKER ── */
.picker-item-list {
  max-height: 200px;
  overflow-y: auto;
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
}
.picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 0.5px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
  -webkit-user-select: none;
  user-select: none;
}
.picker-item:last-child { border-bottom: none; }
.picker-item:hover { background: var(--bg-secondary); }
.picker-item.selected {
  background: var(--amber-bg);
  border-color: transparent;
}
.picker-item-name { flex: 1; font-size: 13px; font-weight: 500; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker-item-price { font-size: 13px; font-weight: 700; flex-shrink: 0; }
.picker-item-stock { font-size: 11px; color: var(--text-secondary); flex-shrink: 0; min-width: 46px; text-align: right; }
.picker-empty { padding: 14px 12px; text-align: center; font-size: 13px; color: var(--text-secondary); }

.sale-add-picker {
  background: var(--bg-secondary);
  border: 0.5px solid var(--border-mid);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.add-picker-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.add-picker-actions { display: flex; gap: 6px; margin-left: auto; }

/* ── CASH CHANGE CALCULATOR ── */
.cash-quick-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.cash-quick-btn {
  padding: 6px 14px;
  font-size: 13px; font-weight: 600;
  border: 0.5px solid var(--border-mid);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  cursor: pointer; font-family: inherit; color: var(--text);
  transition: background 0.1s;
}
.cash-quick-btn:hover { background: var(--bg-tertiary); }
.cash-input-row { display: flex; align-items: center; gap: 10px; }
.cash-input-row input { flex: 1; }
.cash-change-display { font-size: 15px; font-weight: 700; flex-shrink: 0; min-width: 110px; text-align: right; }
.cash-change-pos { color: var(--green-mid); }
.cash-change-neg { color: var(--amber-mid); }

/* ── TOASTS ── */
.toast-wrap {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 24px; z-index: 200;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: max-content; max-width: calc(100% - 32px);
  pointer-events: none;
}
.toast {
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 14px; font-weight: 600;
  background: var(--green-bg); color: var(--green-text);
  box-shadow: 0 4px 14px rgba(0,0,0,0.15);
  pointer-events: auto;
  animation: toast-in 0.2s ease-out;
}
.toast-error { background: var(--red-bg); color: var(--red-text); }
.toast-hide { opacity: 0; transition: opacity 0.3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ── MOBILE QUALITY OF LIFE ── */
html { -webkit-text-size-adjust: 100%; }
button, a, .picker-item, .si-drop-item { touch-action: manipulation; }
.modal { overscroll-behavior: contain; }

@media (max-width: 640px) {
  /* iOS zooms into any input under 16px */
  input[type=text], input[type=number], input[type=password], select, .qty-input { font-size: 16px; }

  /* Bigger tap targets */
  .adj-btn { width: 44px; height: 44px; }
  .qty-btn { width: 40px; height: 40px; }
  .qty-ctrl .qty-input { width: 48px; height: 40px; }

  /* The 860px column widths would otherwise shrink the card areas */
  .col-name, .col-cat, .col-price, .col-stock, .col-act { width: auto; }
  .pay-btn { padding: 12px 4px; font-size: 13px; }
  .cash-quick-btn { padding: 10px 16px; font-size: 15px; }
  .disc-tab { padding-top: 8px; padding-bottom: 8px; }
  .picker-item { padding: 12px; }
  .si-drop-item { padding-top: 12px; padding-bottom: 12px; }
  .modal-close { width: 44px; height: 44px; margin: -10px -12px -10px 0; }
  .modal-actions .btn-cancel, .modal-actions .btn-save { min-height: 44px; padding: 0 18px; font-size: 15px; }

  /* Modals become bottom sheets with the action buttons pinned */
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal {
    max-width: none;
    max-height: 92vh; max-height: 92dvh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: none;
    padding: 1.25rem 1rem 0;
  }
  .modal .modal-actions {
    position: sticky; bottom: 0;
    margin: 1rem -1rem 0;
    padding: 10px 1rem calc(10px + env(safe-area-inset-bottom));
    background: var(--bg);
    border-top: 0.5px solid var(--border);
  }
  .modal .modal-actions .btn-save { flex: 1; }

  /* Edit-sale rows: item on its own line, qty / price / remove below */
  .sale-row { display: grid; grid-template-columns: 1fr 1fr auto; }
  .sale-row select { grid-column: 1 / -1; }
  .sale-row input[type=number] { width: 100%; }

  /* Log Sale floats above the bottom nav */
  .page-header-actions #btn-log-sale {
    position: fixed; z-index: 60;
    right: 16px; bottom: calc(76px + env(safe-area-inset-bottom));
    width: auto; padding: 14px 22px; font-size: 16px;
    border-radius: 999px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.2);
  }
  body.has-fab { padding-bottom: 150px; }

  .toast-wrap { bottom: calc(80px + env(safe-area-inset-bottom)); }
  body.has-fab .toast-wrap { bottom: calc(140px + env(safe-area-inset-bottom)); }
}
