:root {
  --bg: #F6F5EF;
  --card: #FFFFFF;
  --ink: #16201A;
  --muted: #5B6460;
  --line: #DEDCD2;
  --soft: #ECEDE6;
  --green: #1E6B45;
  --green-dark: #14492F;
  --green-tint: #E3F0E8;
  --orange-tint: #FDEBD3;
  --orange-ink: #7A3E0A;
  --danger: #A12B1D;
  --radius: 14px;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; line-height: 1.45; }
a { color: var(--green); }
a:hover { color: var(--green-dark); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 8px; }
h1 { font-size: 26px; }
h2 { font-size: 19px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.topbar { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--soft); position: relative; z-index: 5; }
.logo { font-weight: 800; font-size: 24px; color: var(--green); text-decoration: none; letter-spacing: -0.5px; }
.logo span { color: var(--ink); }
.topbar nav { margin-left: auto; display: flex; gap: 16px; align-items: center; font-weight: 600; font-size: 14px; }
.topbar nav a { text-decoration: none; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-dark); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13px; }

.chip { flex: none; height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: 600 13px/1 inherit; font-family: inherit; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 0; }
.chips::-webkit-scrollbar { display: none; }

.card { background: var(--card); border-radius: var(--radius); padding: 16px; border: 1px solid var(--soft); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--green-tint); color: var(--green-dark); }
.badge.warn { background: var(--orange-tint); color: var(--orange-ink); }
.badge.gray { background: var(--soft); color: var(--ink); }

label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; }
input, select, textarea { font: inherit; font-size: 15px; min-height: 44px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line); background: #fff; color: var(--ink); }
textarea { min-height: 80px; }
input[type=checkbox] { min-height: 0; width: 20px; height: 20px; accent-color: var(--green); }
.check { display: flex; gap: 10px; align-items: center; font-size: 14px; font-weight: 500; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }

.error { color: var(--danger); font-size: 14px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; z-index: 50; max-width: 90vw; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--soft); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--soft); font-size: 14px; vertical-align: top; }
.table-wrap { overflow-x: auto; }

/* --- Mapa --- */
.map-page { height: 100dvh; display: flex; flex-direction: column; }
.map-body { flex: 1; display: flex; min-height: 0; position: relative; }
.list-pane { width: 400px; flex: none; overflow-y: auto; padding: 14px 16px 24px; display: flex; flex-direction: column; gap: 10px; background: var(--bg); border-right: 1px solid var(--soft); }
#map { flex: 1; min-width: 0; }
.search { display: flex; gap: 8px; align-items: center; flex: 1 1 280px; max-width: 560px; }
.search input { flex: 1; min-width: 0; }
.point-item { display: block; text-decoration: none; color: var(--ink); background: var(--card); border: 2px solid transparent; border-radius: var(--radius); padding: 12px 14px; }
.point-item.active { border-color: var(--green); }
.point-item .price { font-weight: 800; color: var(--green); white-space: nowrap; }
.price-pin { padding: 6px 10px; border-radius: 999px; background: var(--green); color: #fff; font: 700 13px/1 Inter, system-ui, sans-serif; border: 2px solid #fff; box-shadow: 0 3px 10px rgba(22,32,26,.28); cursor: pointer; white-space: nowrap; }
.price-pin.closed { background: #6B736F; }
.price-pin.active { background: var(--ink); transform: scale(1.08); }
.view-toggle { display: none; }
.empty { text-align: center; padding: 30px 10px; }

@media (max-width: 760px) {
  .list-pane { position: absolute; inset: auto 0 0 0; width: auto; max-height: 48%; border-radius: 20px 20px 0 0; border: 0; box-shadow: 0 -6px 24px rgba(22,32,26,.15); z-index: 3; }
  .map-page.list-mode .list-pane { max-height: none; top: 0; border-radius: 0; }
  .view-toggle { display: inline-flex; }
}

/* --- Página de punto / pedido --- */
.page { max-width: 760px; margin: 0 auto; padding: 18px 16px 120px; display: flex; flex-direction: column; gap: 14px; }
.product { display: flex; flex-direction: column; gap: 10px; }
.offer { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--soft); }
.stepper { display: inline-flex; align-items: center; gap: 8px; }
.stepper button { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-size: 20px; cursor: pointer; }
.stepper output { min-width: 22px; text-align: center; font-weight: 700; }
.paybar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--soft); padding: 12px 16px; display: flex; gap: 14px; align-items: center; justify-content: center; z-index: 10; }
.paybar .inner { width: 100%; max-width: 760px; display: flex; gap: 14px; align-items: center; }
.total { font-size: 22px; font-weight: 800; }
.code-card { background: var(--ink); color: #fff; border-radius: 22px; padding: 24px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.code-card .code { font-size: 54px; font-weight: 800; letter-spacing: 12px; }
.code-card img { width: 180px; height: 180px; border-radius: 12px; background: #fff; }

/* --- Panel --- */
.layout { display: flex; flex-wrap: wrap; min-height: calc(100dvh - 60px); }
.side { flex: 1 1 200px; max-width: 240px; padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.side a { padding: 10px 12px; border-radius: 10px; text-decoration: none; color: var(--ink); font-weight: 600; }
.side a[aria-current="page"] { background: var(--green-tint); color: var(--green-dark); }
.main { flex: 999 1 560px; min-width: 0; padding: 18px 20px 60px; display: flex; flex-direction: column; gap: 16px; }
.kpis { display: flex; flex-wrap: wrap; gap: 12px; }
.kpi { flex: 1 1 180px; }
.kpi .v { font-size: 26px; font-weight: 800; }
.picker-map { height: 260px; border-radius: 12px; overflow: hidden; }
@media (max-width: 760px) {
  .side { max-width: none; flex-direction: row; overflow-x: auto; padding: 8px 12px; }
  .side a { white-space: nowrap; }
}
