:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-muted: #eef2f5;
  --text: #18202a;
  --text-soft: #5f6a77;
  --brand: #0f4f8f;
  --brand-strong: #0b4279;
  --ok: #1f9d55;
  --warn: #cb7c0a;
  --danger: #c13e3e;
  --border: #d7dfe7;
  --shadow: 0 6px 18px rgba(24, 32, 42, 0.08);
}

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

body {
  margin: 0;
  font-family: "Segoe UI", "SF Pro Text", "Roboto", sans-serif;
  background: linear-gradient(180deg, #f8fafc 0%, var(--bg) 30%);
  color: var(--text);
}

.app-shell {
  max-width: 820px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 14px 12px calc(94px + env(safe-area-inset-bottom));
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  background: rgba(243, 245, 247, 0.95);
  backdrop-filter: blur(6px);
  padding: 8px 0 12px;
}

.app-header h1 {
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.1;
}

.app-header p {
  margin: 4px 0 0;
  color: var(--text-soft);
  font-size: 0.9rem;
}

.cart-shortcut {
  border: 0;
  border-radius: 14px;
  background: var(--brand);
  color: #fff;
  min-height: 46px;
  padding: 8px 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow);
}

.counter {
  min-width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #fff;
  color: var(--brand-strong);
  font-size: 0.85rem;
  display: inline-grid;
  place-items: center;
  padding: 0 6px;
}

.search-panel {
  margin: 4px 0 12px;
}

.search-panel input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 14px;
  padding: 0 14px;
  font-size: 1rem;
}

.categories-section {
  padding-top: 12px;
}

.category-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.category-chip {
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text);
  border-radius: 999px;
  min-height: 36px;
  padding: 7px 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  font-weight: 600;
}

.category-chip .category-count {
  min-width: 20px;
  border-radius: 999px;
  padding: 0 6px;
  background: #dce6f2;
  color: var(--brand-strong);
  font-size: 0.78rem;
  line-height: 1.5;
  text-align: center;
}

.category-chip.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.category-chip.active .category-count {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.section {
  margin-top: 12px;
  background: var(--surface);
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.section h2 {
  margin: 0;
  font-size: 1.05rem;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.muted {
  color: var(--text-soft);
  font-size: 0.9rem;
}

.product-list {
  display: grid;
  gap: 10px;
}

.product-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 10px;
}

.product-card img {
  width: 92px;
  height: 92px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--surface-muted);
}

.product-name {
  font-size: 0.94rem;
  margin: 0 0 6px;
}

.product-meta {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.82rem;
}

.product-price-row {
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.price {
  font-weight: 700;
  font-size: 1rem;
}

.stock {
  font-size: 0.8rem;
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--surface-muted);
}

.stock.in-stock {
  color: var(--ok);
}

.stock.low-stock {
  color: var(--warn);
}

.stock.out-of-stock {
  color: var(--danger);
}

.product-card button {
  margin-top: 10px;
  width: 100%;
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-weight: 600;
}

.product-card button:disabled {
  background: #b5c2ce;
}

.cart-list {
  display: grid;
  gap: 10px;
}

.cart-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  display: grid;
  grid-template-columns: 62px 1fr auto;
  gap: 8px 10px;
  align-items: center;
}

.cart-thumb {
  width: 62px;
  height: 62px;
  border-radius: 10px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  overflow: hidden;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.cart-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cart-thumb.is-placeholder {
  background: #eef2f5;
}

.cart-thumb-placeholder {
  font-size: 0.64rem;
  line-height: 1.15;
  color: var(--text-soft);
  text-align: center;
  padding: 4px;
}

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

.cart-title {
  margin: 0;
  font-size: 0.92rem;
}

.cart-line {
  margin: 4px 0 0;
  font-size: 0.83rem;
  color: var(--text-soft);
}

.qty-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.cart-actions {
  justify-self: end;
  display: grid;
  gap: 6px;
  justify-items: end;
}

.qty-controls button {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 1.1rem;
}

.remove-btn {
  border: 0;
  background: none;
  color: var(--danger);
  font-size: 0.88rem;
  padding: 0;
  justify-self: end;
}

.empty-state {
  margin: 0;
  color: var(--text-soft);
}

.checkout-section form {
  display: grid;
  gap: 12px;
}

.field-grid {
  display: grid;
  gap: 10px;
}

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

.city-field {
  position: relative;
}

.field span {
  font-size: 0.88rem;
  color: var(--text-soft);
}

.field input,
.field select,
.field textarea {
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  font-size: 0.95rem;
  font: inherit;
}

.field textarea {
  resize: vertical;
  min-height: 88px;
}

.city-search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 30;
  padding: 4px;
}

.city-search-option {
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 8px;
  background: transparent;
  padding: 8px 10px;
  font: inherit;
  color: var(--text);
}

.city-search-option:hover {
  background: var(--surface-muted);
}

.delivery-point-results {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  max-height: 240px;
  overflow-y: auto;
  padding: 6px;
}

.delivery-point-option {
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 8px;
  background: transparent;
  padding: 8px 10px;
  font: inherit;
  color: var(--text);
}

.delivery-point-option:hover {
  background: var(--surface-muted);
}

.primary-btn {
  min-height: 48px;
  border-radius: 12px;
  border: 0;
  background: var(--brand);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
}

.primary-btn:disabled {
  background: #b5c2ce;
}

.form-message {
  margin: 0;
  font-size: 0.92rem;
  color: var(--text-soft);
}

.form-message.error {
  color: var(--danger);
}

.form-message.success {
  color: var(--ok);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 640px) {
  .app-shell {
    padding: 18px 20px 24px;
  }

  .product-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 420px) {
  .cart-item {
    grid-template-columns: 56px 1fr;
    align-items: start;
  }

  .cart-thumb {
    width: 56px;
    height: 56px;
  }

  .cart-actions {
    grid-column: 2;
    justify-self: stretch;
    justify-items: start;
  }
}
