:root {
  color-scheme: dark;
  --bg: #0b1020;
  --panel: #111827;
  --panel-2: #1e293b;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #22c55e;
  --danger: #f87171;
  --border: rgba(148, 163, 184, 0.18);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px calc(10px + env(safe-area-inset-top));
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  margin: 0;
  font-size: 18px;
}

.topbar p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.toolbar {
  display: grid;
  gap: 10px;
  padding: 12px 16px;
}

input, select, button {
  font: inherit;
}

input, select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--panel);
  color: var(--text);
}

.cart-btn {
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: var(--panel-2);
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  min-width: 22px;
  justify-content: center;
  margin-left: 4px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #082f49;
  font-size: 12px;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 0 16px 96px;
}

@media (min-width: 720px) {
  .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

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

.product-card img,
.product-card .placeholder {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: #020617;
}

.product-card .placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}

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

.product-name {
  margin: 0;
  font-size: 13px;
  line-height: 1.35;
  min-height: 2.7em;
}

.product-meta {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}

.product-price {
  font-size: 14px;
  font-weight: 700;
  color: #fde68a;
}

.product-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

button {
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
}

button.primary {
  background: linear-gradient(135deg, #0ea5e9, #22c55e);
  color: #04111f;
  font-weight: 700;
}

button.ghost {
  background: transparent;
  color: var(--muted);
}

button.secondary {
  flex: 1;
  background: var(--panel-2);
  color: var(--text);
  font-weight: 600;
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
}

.sheet.hidden { display: none; }

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.65);
}

.sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  border-radius: 18px 18px 0 0;
  background: var(--panel);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.sheet-header h2 {
  margin: 0;
  font-size: 16px;
}

.cart-items, .order-result {
  overflow: auto;
  padding: 12px 16px;
}

.cart-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.cart-row strong { font-size: 14px; }
.cart-row small { color: var(--muted); }

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

.qty-controls button {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  background: var(--panel-2);
}

.sheet-footer {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
}

.order-result h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.order-result ul {
  margin: 0 0 12px;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
}

.order-result .ok { color: var(--accent-2); }
.order-result .fail { color: var(--danger); }

.preview-save-status.ok { color: var(--accent-2); }
.preview-save-status.fail { color: var(--danger); }
.preview-save-status a { color: #7dd3fc; }

.route-preview {
  padding: 0 16px 16px;
}

.route-preview.hidden { display: none; }

.route-preview-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.route-preview-head h3 {
  margin: 0;
  font-size: 14px;
}

#routeCanvas {
  width: 100%;
  height: min(48vh, 420px);
  min-height: 300px;
  display: block;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #020617;
}

.status {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.status.show { opacity: 1; }

.empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  padding: 40px 16px;
}
