* { box-sizing: border-box; }
:root {
  color-scheme: light dark;
  --bg: #f2f2f7;
  --card: rgba(255,255,255,.94);
  --text: #111114;
  --muted: #6e6e73;
  --line: rgba(60,60,67,.18);
  --accent: #1f947e;
  --accent-pressed: #187562;
  --danger: #ff3b30;
  --input: #ffffff;
  --shadow: 0 12px 32px rgba(0,0,0,.08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000;
    --card: #1c1c1e;
    --text: #f5f5f7;
    --muted: #98989d;
    --line: rgba(84,84,88,.65);
    --accent: #37c5a9;
    --accent-pressed: #2ea58e;
    --input: #2c2c2e;
    --shadow: none;
  }
}
html, body { margin: 0; padding: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.shell {
  width: min(100%, 680px);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px calc(32px + env(safe-area-inset-bottom));
}
.card, .add-card, .list-card, .tabs {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.auth-card { margin-top: 9vh; padding: 28px 22px; text-align: center; }
.app-icon { width: 84px; height: 84px; border-radius: 21px; display: block; margin: 0 auto 18px; }
h1 { margin: 0; font-size: 29px; line-height: 1.08; letter-spacing: -.025em; }
h2 { margin: 0; font-size: 21px; }
.muted, .hint, .status { color: var(--muted); }
.muted { margin: 10px 0 22px; }
.stack { display: grid; gap: 14px; text-align: left; }
.stack label span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 7px 4px; }
input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--input);
  color: var(--text);
  padding: 0 14px;
  font-size: 17px;
  outline: none;
}
input:focus { border-color: var(--accent); }
.primary, .add-button {
  border: 0;
  border-radius: 13px;
  min-height: 48px;
  font-weight: 700;
  cursor: pointer;
}
.primary, .add-button { background: var(--accent); color: white; }
.primary:active, .add-button:active { background: var(--accent-pressed); }
.primary:disabled, .add-button:disabled { opacity: .55; cursor: default; }
.error { min-height: 18px; margin: 0; color: var(--danger); font-size: 14px; text-align: center; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 8px 2px 16px;
}
.eyebrow { margin: 0 0 4px; color: var(--muted); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.text-button { border: 0; background: transparent; color: var(--muted); padding: 8px; cursor: pointer; }

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 5px;
  margin-bottom: 14px;
  border-radius: 15px;
}
.tab {
  min-height: 42px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
  cursor: pointer;
}
.tab.active { background: var(--accent); color: white; }
.tab-count {
  display: inline-flex;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  margin-left: 5px;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(127,127,127,.14);
  font-size: 13px;
}
.tab.active .tab-count { background: rgba(255,255,255,.19); }

.add-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
  padding: 10px;
  border-radius: 17px;
}
.add-card > input { border: 0; background: var(--input); min-width: 0; }


.add-button { min-width: 104px; padding: 0 16px; }
.status { min-height: 21px; margin: 9px 4px 5px; font-size: 14px; }
.list-card { overflow: hidden; border-radius: 17px; }
.product-list { display: block; }
.product-row {
  min-height: 58px;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  text-align: left;
  cursor: pointer;
}
.product-row:last-child { border-bottom: 0; }
.product-row:active { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.product-name { font-size: 18px; min-width: 0; overflow-wrap: anywhere; }
.quantity-badge {
  flex: 0 0 auto;
  min-width: 44px;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  color: var(--accent);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.empty-state { padding: 42px 20px; text-align: center; }
.empty-state p { margin: 8px 0 0; color: var(--muted); }
.empty-icon {
  width: 52px; height: 52px; margin: 0 auto 14px;
  border-radius: 50%; display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent); font-size: 27px; font-weight: 800;
}
.hint { margin: 12px 6px 0; font-size: 13px; text-align: center; }

.snackbar {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translate(-50%, 130%);
  width: min(calc(100% - 32px), 540px);
  min-height: 54px;
  padding: 10px 12px 10px 16px;
  border-radius: 16px;
  background: #2c2c2e;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: 0 12px 28px rgba(0,0,0,.25);
  transition: transform .22s ease;
  z-index: 20;
}
.snackbar.visible { transform: translate(-50%, 0); }
.snackbar button {
  border: 0; background: transparent; color: #64d8bf; font-weight: 800;
  min-height: 40px; padding: 0 8px; cursor: pointer;
}

@media (max-width: 520px) {
  .add-card { grid-template-columns: minmax(0, 1fr) auto; }
  .add-button { min-width: 110px; }
}
@media (max-width: 360px) {
  .shell { padding-left: 10px; padding-right: 10px; }
  .quantity-stepper { grid-template-columns: 38px 44px 38px; }
  .add-button { min-width: 104px; }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0,0,0,.38);
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal-card {
  width: min(100%, 420px);
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 22px 50px rgba(0,0,0,.22);
  padding: 22px;
}
.modal-card h2 {
  text-align: center;
  font-size: 22px;
}
.modal-product-name {
  margin: 8px 0 18px;
  text-align: center;
  color: var(--muted);
  font-size: 17px;
}
.modal-stepper {
  display: grid;
  grid-template-columns: 52px 1fr 52px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--input);
}
.modal-stepper button {
  min-height: 52px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 26px;
  font-weight: 800;
  cursor: pointer;
}
.modal-stepper input {
  min-height: 52px;
  border: 0;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  border-radius: 0;
  text-align: center;
  font-weight: 800;
  appearance: textfield;
  -moz-appearance: textfield;
}
.modal-stepper input::-webkit-outer-spin-button,
.modal-stepper input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 10px;
  margin-top: 18px;
}
.secondary-button,
.primary-button {
  min-height: 48px;
  border-radius: 13px;
  font-weight: 750;
  cursor: pointer;
}
.secondary-button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
}
.primary-button {
  border: 0;
  background: var(--accent);
  color: white;
}
