:root {
  --bg: #ffffff;
  --surface: #f6f7f9;
  --border: #e3e6ea;
  --text: #1c2529;
  --muted: #6b7680;
  --accent: #e30613;
  --accent-soft: #fdecee;
  --ok: #1f8a4c;
  --ok-soft: #e7f6ed;
  --warn: #b26a00;
  --warn-soft: #fff4e0;
  --shadow: 0 1px 2px rgba(20, 30, 40, 0.06), 0 8px 24px rgba(20, 30, 40, 0.06);
  --radius: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--surface);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--accent);
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 16px;
}

.topbar-spacer {
  flex: 1;
}

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

.address-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--muted);
  max-width: 320px;
}

.address-chip strong {
  color: var(--text);
  font-weight: 600;
}

.btn {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.btn:hover {
  background: var(--surface);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: #c80511;
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
}

.btn-icon {
  padding: 8px;
  border-radius: 999px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.segmented button {
  border: 0;
  background: var(--bg);
  padding: 8px 12px;
  font-weight: 600;
  font-size: 14px;
  color: var(--muted);
}

.segmented button + button {
  border-left: 1px solid var(--border);
}

.segmented button.active {
  background: var(--text);
  color: #fff;
}

.main {
  flex: 1;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
}

.main.single {
  grid-template-columns: minmax(0, 1fr);
}

.content {
  min-width: 0;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.pad {
  padding: 20px;
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 12px;
}

.section-head h2 {
  font-size: 18px;
  margin: 0;
  letter-spacing: -0.01em;
}

.count-pill {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 9px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}

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

.product-media {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--surface);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.product-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  mix-blend-mode: multiply;
}

.product-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.product-name {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.7em;
}

.product-amount {
  font-size: 12px;
  color: var(--muted);
}

.price-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.price {
  font-weight: 800;
  font-size: 17px;
}

.price-was {
  color: var(--muted);
  text-decoration: line-through;
  font-size: 13px;
}

.price-unit {
  color: var(--muted);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  padding: 3px 9px;
  border: 1px solid transparent;
}

.badge-ok {
  color: var(--ok);
  background: var(--ok-soft);
  border-color: #cdeed9;
}

.badge-warn {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: #f3e0bd;
}

.badge-sale {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: #f7cdd2;
}

.badge-muted {
  color: var(--muted);
  background: var(--surface);
  border-color: var(--border);
}

.product-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.qty {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.qty button {
  border: 0;
  background: var(--bg);
  width: 34px;
  height: 34px;
  font-size: 18px;
  line-height: 1;
  color: var(--text);
}

.qty button:hover:not(:disabled) {
  background: var(--surface);
}

.qty button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.qty .qty-value {
  min-width: 34px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.add-btn {
  flex: 1;
  justify-content: center;
}

.heart {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 999px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  font-size: 16px;
}

.heart.active {
  color: var(--accent);
  border-color: #f7cdd2;
  background: var(--accent-soft);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

table.products {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

table.products th,
table.products td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table.products th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--surface);
  position: sticky;
  top: 0;
}

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

.cell-product {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 240px;
}

.cell-thumb {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: var(--surface);
  object-fit: contain;
  flex: none;
}

.cell-name {
  font-weight: 600;
}

.cell-sub {
  font-size: 12px;
  color: var(--muted);
}

.num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.extras {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 2px dashed var(--border);
}

.extras-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
  font-weight: 600;
}

.side {
  position: sticky;
  top: 84px;
}

.cart-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 60vh;
  overflow: auto;
  margin: 0 -8px;
}

.cart-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
}

.cart-row:hover {
  background: var(--surface);
}

.cart-thumb {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: contain;
  background: var(--surface);
  flex: none;
}

.cart-main {
  min-width: 0;
  flex: 1;
}

.cart-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cart-sub {
  font-size: 12px;
  color: var(--muted);
}

.cart-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-top: 12px;
  margin-top: 12px;
  border-top: 1px solid var(--border);
  font-weight: 700;
}

.muted {
  color: var(--muted);
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
}

.login-wrap {
  max-width: 420px;
  margin: 48px auto;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field label {
  font-size: 13px;
  font-weight: 600;
}

.field input,
.field select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--bg);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  margin-bottom: 16px;
}

.banner {
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  margin-bottom: 14px;
  border: 1px solid;
}

.banner-error {
  color: #8a1119;
  background: var(--accent-soft);
  border-color: #f7cdd2;
}

.banner-info {
  color: #0f4f7a;
  background: #eaf4fb;
  border-color: #cfe6f5;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(18, 24, 30, 0.45);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 50;
}

.modal {
  width: min(560px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
}

.modal-head h2 {
  margin: 0;
  font-size: 17px;
}

.modal-body {
  padding: 20px;
}

.hint {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 12px;
}

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
}

.toast {
  background: var(--text);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  box-shadow: var(--shadow);
}

.toast.error {
  background: var(--accent);
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner.dark {
  border-color: rgba(0, 0, 0, 0.2);
  border-top-color: var(--text);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-block {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  padding: 40px;
  justify-content: center;
}

@media (max-width: 900px) {
  .main {
    grid-template-columns: minmax(0, 1fr);
  }
  .side {
    position: static;
  }
}
