:root {
  --bg: #faf6f0;
  --surface: #ffffff;
  --primary: #6b4423;
  --primary-soft: #a07856;
  --accent: #d4a574;
  --accent-soft: #e8d5b7;
  --text: #2d1f14;
  --muted: #8a7a6c;
  --border: #ece1d3;
  --success: #5d8a3a;
  --error: #c04444;
  --shadow-sm: 0 2px 8px rgba(107, 68, 35, 0.06);
  --shadow-md: 0 8px 24px rgba(107, 68, 35, 0.1);
  --shadow-lg: 0 16px 48px rgba(107, 68, 35, 0.15);
  --radius: 16px;
  --radius-sm: 12px;
  --radius-lg: 24px;
  --tabbar-h: 68px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg); color: var(--text);
  min-height: 100vh; font-size: 16px; line-height: 1.5;
}

.app {
  max-width: 480px; margin: 0 auto;
  padding: 0 0 calc(var(--tabbar-h) + 24px);
  min-height: 100vh; display: flex; flex-direction: column;
}

.app.no-tabs { padding-bottom: 24px; }

.app-padded { padding: 20px; }

/* ====== Top bar (бежевая шапка как у Safia) ====== */
.topbar {
  background: linear-gradient(135deg, var(--accent) 0%, var(--primary-soft) 100%);
  color: white; padding: 18px 20px;
  display: flex; align-items: center; justify-content: space-between;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow-sm); margin-bottom: 16px;
}
.topbar-loc { display: flex; flex-direction: column; }
.topbar-loc-label { font-size: 12px; opacity: 0.85; letter-spacing: 0.5px; }
.topbar-loc-value {
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 700; font-size: 17px; cursor: pointer;
}
.topbar-loc-value::after { content: '✏️'; font-size: 12px; opacity: 0.7; }
.topbar-actions { display: flex; gap: 14px; font-size: 22px; }
.topbar-btn { background: rgba(255,255,255,0.18); border: none; color: white; width: 38px; height: 38px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 18px; }

/* ====== Brand block ====== */
.brand { text-align: center; margin-bottom: 24px; padding: 24px 0 0; }
.brand-logo {
  width: 80px; height: 80px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--primary-soft) 100%);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 40px; margin-bottom: 12px; box-shadow: var(--shadow-md);
}
.brand-name { font-size: 28px; font-weight: 700; color: var(--primary); margin: 0; letter-spacing: 0.5px; }
.brand-tagline { color: var(--muted); font-size: 14px; margin-top: 4px; }

.title { font-size: 22px; font-weight: 700; margin: 0 0 8px; padding: 0 20px; }
.subtitle { color: var(--muted); font-size: 15px; margin: 0 0 18px; padding: 0 20px; }

/* ====== Cards ====== */
.card {
  background: var(--surface); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow-sm);
  border: 1px solid var(--border); margin-bottom: 16px;
}
.card-hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-soft) 100%);
  color: white; border-radius: var(--radius-lg); padding: 28px 24px;
  box-shadow: var(--shadow-md); margin-bottom: 20px; text-align: center;
}
.balance-label { font-size: 13px; text-transform: uppercase; letter-spacing: 1.2px; opacity: 0.85; margin: 0 0 8px; }
.balance-value { font-size: 48px; font-weight: 800; margin: 0; letter-spacing: -1px; }
.balance-unit { font-size: 18px; font-weight: 500; opacity: 0.9; margin-top: 4px; }

/* ====== Search ====== */
.search-wrap {
  display: flex; gap: 10px; padding: 0 20px; margin-bottom: 16px;
}
.search-input {
  flex: 1; background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 14px 18px; font-size: 16px;
  outline: none; box-shadow: var(--shadow-sm);
}
.search-input:focus { border-color: var(--accent); }

/* ====== Category list (как у Safia: круглая аватарка слева, название, шеврон) ====== */
.cat-list { padding: 0 20px; display: flex; flex-direction: column; gap: 4px; }
.cat-item {
  display: flex; align-items: center; padding: 12px 6px; gap: 14px;
  border-bottom: 1px solid var(--border); cursor: pointer;
  background: transparent;
  color: var(--text);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.cat-item:visited, .cat-item:hover, .cat-item:active { color: var(--text); text-decoration: none; }
.cat-item:last-child { border-bottom: none; }
.cat-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent-soft); flex-shrink: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center; font-size: 26px;
}
.cat-avatar img { width: 100%; height: 100%; object-fit: cover; }
.cat-name { flex: 1; font-size: 17px; font-weight: 500; }
.cat-arrow { color: var(--muted); font-size: 22px; }

/* ====== Product card ====== */
.prod-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px; padding: 0 20px;
}
.prod-card {
  background: var(--surface); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-sm); border: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.prod-img {
  width: 100%; aspect-ratio: 1 / 1; background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center; font-size: 40px;
  overflow: hidden;
}
.prod-img img { width: 100%; height: 100%; object-fit: cover; }
.prod-body { padding: 12px; display: flex; flex-direction: column; flex: 1; gap: 6px; }
.prod-name { font-size: 15px; font-weight: 600; line-height: 1.3; min-height: 38px; }
.prod-price { font-weight: 700; color: var(--primary); font-size: 16px; }
.prod-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.prod-add {
  background: var(--primary); color: white; border: none;
  padding: 10px 14px; border-radius: 10px; font-weight: 600;
  font-size: 14px; cursor: pointer;
}
.qty-ctl { display: inline-flex; align-items: center; background: var(--accent-soft); border-radius: 10px; overflow: hidden; }
.qty-ctl button {
  background: transparent; border: none; width: 32px; height: 32px;
  font-size: 18px; color: var(--primary); cursor: pointer;
}
.qty-ctl span { min-width: 22px; text-align: center; font-weight: 700; color: var(--primary); }

/* ====== Inputs ====== */
.input-group { margin-bottom: 16px; padding: 0 20px; }
.input-label { display: block; font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.input, .select, textarea.input {
  width: 100%; padding: 16px 18px; font-size: 17px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s; outline: none;
}
textarea.input { resize: vertical; min-height: 72px; }
.input:focus, .select:focus, textarea.input:focus {
  border-color: var(--primary-soft); box-shadow: 0 0 0 4px rgba(212, 165, 116, 0.15);
}

/* ====== Buttons ====== */
.btn {
  display: flex; align-items: center; justify-content: center;
  width: 100%; padding: 16px 20px; font-size: 16px; font-weight: 600;
  border: none; border-radius: var(--radius-sm); cursor: pointer;
  font-family: inherit; transition: transform 0.1s, box-shadow 0.2s;
  gap: 8px;
}
.btn-primary { background: var(--primary); color: white; box-shadow: var(--shadow-sm); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { background: var(--muted); cursor: not-allowed; }
.btn-secondary { background: var(--accent-soft); color: var(--primary); }
.btn-row { padding: 0 20px; }

/* ====== Choices (radio cards) ====== */
.choice-list { display: flex; flex-direction: column; gap: 10px; padding: 0 20px; }
.choice-item {
  display: flex; align-items: center; padding: 16px 18px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer; transition: all 0.15s;
}
.choice-item.selected { border-color: var(--primary); background: var(--accent-soft); }
.choice-item input { margin-right: 14px; accent-color: var(--primary); transform: scale(1.2); }
.choice-name { font-size: 16px; font-weight: 500; }

/* ====== City picker ====== */
.city-list { display: flex; flex-direction: column; gap: 10px; padding: 0 20px; }

/* ====== QR ====== */
.qr-card {
  background: var(--surface); border-radius: var(--radius); padding: 24px;
  text-align: center; box-shadow: var(--shadow-sm); border: 1px solid var(--border);
  margin: 0 20px 16px;
}
.qr-wrap {
  display: inline-block; padding: 16px; background: white;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.qr-phone { margin-top: 14px; font-size: 18px; font-weight: 600; letter-spacing: 0.5px; color: var(--primary); }
.qr-hint { margin-top: 6px; font-size: 13px; color: var(--muted); }

/* ====== User info ====== */
.user-info { display: flex; align-items: center; gap: 12px; margin: 0 20px 16px; }
.user-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--accent-soft); display: flex; align-items: center;
  justify-content: center; font-size: 22px; flex-shrink: 0;
}
.user-meta { display: flex; flex-direction: column; }
.user-name { font-weight: 600; font-size: 16px; }
.user-city { font-size: 13px; color: var(--muted); }

.section-title {
  font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.8px; color: var(--muted); margin: 24px 20px 12px;
}

/* ====== Order/transaction items ====== */
.tx-list, .order-list { display: flex; flex-direction: column; gap: 8px; padding: 0 20px; }
.tx-item, .order-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; background: var(--surface);
  border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.tx-meta, .order-meta { display: flex; flex-direction: column; gap: 2px; }
.tx-title, .order-title { font-weight: 600; font-size: 15px; }
.tx-date, .order-date { font-size: 12px; color: var(--muted); }
.tx-points { font-weight: 700; font-size: 16px; }
.tx-points.earn { color: var(--success); }
.tx-points.redeem { color: var(--error); }
.order-status {
  font-size: 12px; font-weight: 700; padding: 4px 10px;
  border-radius: 999px; background: var(--accent-soft); color: var(--primary);
}
.order-status.delivered { background: #e0eed3; color: var(--success); }
.order-status.cancelled { background: #fde7e7; color: var(--error); }

/* ====== Cart ====== */
.cart-item {
  display: flex; gap: 12px; padding: 12px;
  background: var(--surface); border-radius: var(--radius-sm);
  border: 1px solid var(--border); margin-bottom: 10px;
}
.cart-item-img {
  width: 64px; height: 64px; border-radius: 10px;
  background: var(--accent-soft); flex-shrink: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center; font-size: 28px;
}
.cart-item-img img { width: 100%; height: 100%; object-fit: cover; }
.cart-item-body { flex: 1; display: flex; flex-direction: column; justify-content: space-between; }
.cart-item-name { font-weight: 600; font-size: 15px; }
.cart-item-price { color: var(--primary); font-weight: 700; }
.cart-item-actions { display: flex; align-items: center; justify-content: space-between; }

/* ====== Empty ====== */
.empty { text-align: center; padding: 48px 16px; color: var(--muted); font-size: 14px; }
.empty-icon { font-size: 48px; margin-bottom: 12px; }

/* ====== Alerts ====== */
.alert { padding: 14px 16px; border-radius: var(--radius-sm); font-size: 14px; margin: 0 20px 16px; }
.alert-error { background: #fde7e7; color: var(--error); border: 1px solid #f4c2c2; }
.alert-success { background: #e8f3dd; color: var(--success); border: 1px solid #cce0b6; }

.spacer { flex: 1; }

/* ====== Loader ====== */
.loader { display: flex; align-items: center; justify-content: center; min-height: 60vh; color: var(--muted); }
.spinner {
  width: 36px; height: 36px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ====== Summary ====== */
.summary { padding: 0 20px 16px; display: flex; flex-direction: column; gap: 8px; }
.summary-row { display: flex; justify-content: space-between; font-size: 15px; }
.summary-row.total { font-size: 18px; font-weight: 700; padding-top: 8px; border-top: 1px solid var(--border); }
.summary-row.discount { color: var(--success); }

/* ====== Tab bar ====== */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--surface); border-top: 1px solid var(--border);
  display: flex; height: var(--tabbar-h);
  max-width: 480px; margin: 0 auto;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 50;
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 4px; cursor: pointer;
  color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 600;
  transition: color 0.15s; position: relative;
}
.tab.active { color: var(--primary); }
.tab-icon { font-size: 22px; line-height: 1; }
.tab-badge {
  position: absolute; top: 8px; right: calc(50% - 22px);
  background: var(--error); color: white; border-radius: 999px;
  font-size: 11px; padding: 1px 6px; min-width: 18px; text-align: center;
}

/* ====== Branch card ====== */
.branch-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 16px; margin: 0 20px 12px; border: 1px solid var(--border);
}
.branch-name { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.branch-city { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.branch-line { font-size: 14px; margin-top: 4px; color: var(--text); }

/* ====== Modal-ish bottom sheet for product ====== */
.sheet-overlay {
  position: fixed; inset: 0; background: rgba(45, 31, 20, 0.5);
  display: none; align-items: flex-end; z-index: 100;
}
.sheet-overlay.open { display: flex; }
.sheet {
  background: var(--surface); width: 100%; max-width: 480px; margin: 0 auto;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 20px 20px calc(24px + env(safe-area-inset-bottom));
  max-height: 85vh; overflow-y: auto; animation: slideUp 0.2s ease-out;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-img {
  width: 100%; aspect-ratio: 1.5 / 1; border-radius: var(--radius);
  overflow: hidden; background: var(--accent-soft); margin-bottom: 16px;
  display: flex; align-items: center; justify-content: center; font-size: 60px;
}
.sheet-img img { width: 100%; height: 100%; object-fit: cover; }

.gallery {
  width: 100%; aspect-ratio: 1.5 / 1; border-radius: var(--radius);
  overflow: hidden; background: var(--accent-soft); margin-bottom: 12px;
  position: relative;
}
.gallery-track {
  display: flex; height: 100%; overflow-x: auto; scroll-snap-type: x mandatory;
  scrollbar-width: none; -ms-overflow-style: none;
}
.gallery-track::-webkit-scrollbar { display: none; }
.gallery-slide {
  flex: 0 0 100%; height: 100%; scroll-snap-align: start;
}
.gallery-slide img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-dots {
  position: absolute; bottom: 8px; left: 0; right: 0;
  display: flex; justify-content: center; gap: 6px; pointer-events: none;
}
.gallery-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.5); transition: background 0.2s, width 0.2s;
}
.gallery-dot.active { background: white; width: 18px; border-radius: 3px; }
