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

:root {
  --bg: #0c0c0c;
  --surface: #161616;
  --surface2: #1f1f1f;
  --border: #2a2a2a;
  --accent: #ffffff;
  --accent-dim: rgba(255,255,255,0.06);
  --green: #3ecf6e;
  --green-dark: #2fb85c;
  --text: #f0f0f0;
  --text-muted: #888;
  --radius: 12px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(12,12,12,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
}

.brand {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--accent);
}

/* Main */
main {
  flex: 1;
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* Product */
.product {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.product-image-wrap {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: var(--surface);
  aspect-ratio: 4/3;
}

.product-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.product-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background: #fff;
  color: #000;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.15em;
  padding: 4px 8px;
  border-radius: 4px;
}

.product-info {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.product-name {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.product-price {
  font-size: 22px;
  font-weight: 600;
  color: var(--green);
}

/* Field label */
.field-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: -8px;
}

/* Size grid */
.size-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.size-btn {
  flex: 1;
  min-width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.size-btn:hover {
  border-color: #555;
  background: var(--surface2);
}

.size-btn.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #000;
}

/* Quantity */
.qty-wrap {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: fit-content;
}

.qty-btn {
  width: 44px;
  height: 44px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  border-radius: 10px;
}

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

.qty-value {
  width: 44px;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  user-select: none;
}

/* Sections */
.delivery-section,
.checkout-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Input */
.input-group { position: relative; }

.input-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.text-input {
  width: 100%;
  height: 50px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
  padding: 0 14px;
  outline: none;
  transition: border-color 0.15s;
  font-family: var(--font);
}

.text-input:focus { border-color: #555; }
.text-input::placeholder { color: var(--text-muted); }

textarea.text-input {
  height: auto;
  resize: vertical;
  padding-top: 12px;
  line-height: 1.5;
}

/* City dropdown */
.city-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 50;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

.city-dropdown.hidden { display: none; }

.city-option {
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.city-option:last-child { border-bottom: none; }
.city-option:hover { background: var(--accent-dim); }

.city-option-name { font-size: 14px; font-weight: 500; }
.city-option-region { font-size: 12px; color: var(--text-muted); }

/* Tariff cards */
.tariff-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tariff-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.tariff-card:hover { border-color: #555; background: var(--surface2); }

.tariff-card.active {
  border-color: var(--green);
  background: rgba(62,207,110,0.06);
}

.tariff-card-info { display: flex; flex-direction: column; gap: 3px; }
.tariff-card-name { font-size: 14px; font-weight: 600; }
.tariff-card-desc { font-size: 12px; color: var(--text-muted); }
.tariff-card-days { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.tariff-card-price {
  font-size: 16px;
  font-weight: 700;
  color: var(--green);
  white-space: nowrap;
}

/* PVZ list */
.pvz-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  max-height: 260px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.pvz-loading {
  padding: 16px 14px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

.pvz-item {
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.pvz-item:last-child { border-bottom: none; }
.pvz-item:hover { background: var(--accent-dim); }

.pvz-item.active {
  background: rgba(62, 207, 110, 0.08);
  border-left: 3px solid var(--green);
}

.pvz-item-address {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
}

.pvz-item-meta {
  font-size: 11px;
  color: var(--text-muted);
}

/* Buttons */
.btn-calc {
  width: 100%;
  height: 52px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn-calc:hover:not(:disabled) {
  background: var(--surface2);
  border-color: #444;
}

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

.btn-pay {
  width: 100%;
  height: 56px;
  border-radius: var(--radius);
  border: none;
  background: var(--green);
  color: #000;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
}

.btn-pay:hover:not(:disabled) {
  background: var(--green-dark);
  transform: translateY(-1px);
}

.btn-pay:active { transform: translateY(0); }
.btn-pay:disabled { opacity: 0.5; cursor: not-allowed; }

.pay-note {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* Delivery result */
.delivery-result {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.delivery-result.hidden { display: none; }

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.result-label { font-size: 13px; color: var(--text-muted); }
.result-value { font-size: 14px; font-weight: 500; }

.result-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.total-row .result-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.total-row .result-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--green);
}

/* Hidden */
.hidden { display: none !important; }

/* Loading spinner inline */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

.btn-pay .spinner {
  border: 2px solid rgba(0,0,0,0.2);
  border-top-color: #000;
}

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

/* Error toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #c0392b;
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  z-index: 999;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  animation: toastIn 0.25s ease;
  max-width: calc(100vw - 32px);
  text-align: center;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Footer */
footer {
  border-top: 1px solid var(--border);
  padding: 20px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}
