:root {
  --black: #121110;
  --black-soft: #1c1a18;
  --gold: #c9a24d;
  --gold-bright: #e8cf8a;
  --cream: #faf7f1;
  --text: #241f19;
  --border: #e6ddc9;
  --muted: #8a7c63;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Helvetica, Arial, sans-serif;
  background: var(--cream);
  color: var(--text);
  padding-bottom: 3rem;
}

h1, h2 {
  font-family: Georgia, "Times New Roman", serif;
}

.app-header {
  background: var(--black);
  color: white;
  padding: 1.5rem 1.25rem 1.1rem;
  text-align: center;
}

.logo {
  display: block;
  width: 120px;
  height: 120px;
  margin: 0 auto 0.4rem;
}

.subtitle { margin: 0; opacity: 0.75; font-size: 0.85rem; }

.tabs {
  display: flex;
  background: var(--black-soft);
  padding: 0.4rem;
  gap: 0.4rem;
  position: sticky;
  top: 0;
  z-index: 40;
}

.tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.65);
  padding: 0.6rem 0.5rem;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--gold);
  color: #1a1408;
}

main {
  max-width: 480px;
  margin: 0 auto;
  padding: 1rem;
}

.view.hidden { display: none; }

.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.card h2 {
  margin: 0 0 0.6rem;
  font-size: 1.15rem;
  color: var(--black);
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

input[type="text"],
input[type="tel"] {
  width: 100%;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  margin-bottom: 0.6rem;
  background: #fffdfa;
}

.add-row { display: flex; flex-direction: column; }

.autocomplete-wrap {
  position: relative;
}

.suggestions {
  position: absolute;
  top: calc(100% - 0.4rem);
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 30;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
  list-style: none;
  margin: 0 0 0.6rem;
  padding: 0.2rem 0;
}

.suggestions li {
  padding: 0.6rem 0.9rem;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.suggestions li:last-child { border-bottom: none; }
.suggestions li:active { background: #fdf1e4; }
.suggestions .suggestion-name { display: block; font-weight: 600; }
.suggestions .suggestion-sub { display: block; font-size: 0.8rem; color: var(--muted); }

.btn-add, .btn-primary, .btn-secondary {
  border: none;
  border-radius: 12px;
  padding: 0.9rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}

.btn-add {
  background: var(--gold);
  color: #1a1408;
  margin-bottom: 0.2rem;
}

.btn-primary {
  background: var(--black);
  color: var(--gold-bright);
  margin-bottom: 0.6rem;
}

.btn-secondary {
  background: transparent;
  color: var(--black);
  border: 1px solid var(--black);
}

.btn-primary:disabled,
.btn-add:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.go-reparto-card {
  text-align: center;
}

.go-reparto-text {
  margin: 0 0 0.7rem;
  font-weight: 600;
  color: var(--black);
}

.stops-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
}

.stops-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.2rem;
  border-bottom: 1px solid var(--border);
}

.stops-list li:last-child { border-bottom: none; }

.stop-text { font-size: 0.95rem; }
.stop-name { font-weight: 600; }
.stop-addr { display: block; color: var(--muted); font-size: 0.85rem; }

.remove-btn {
  border: none;
  background: #f4e3e3;
  color: #b33;
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
  cursor: pointer;
  flex-shrink: 0;
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: -0.2rem 0 0.6rem;
}

.empty-msg {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  margin: 0.5rem 0 0;
}

.status {
  text-align: center;
  min-height: 1.2rem;
  font-size: 0.9rem;
  color: var(--black);
}

.hidden { display: none; }

.summary {
  font-size: 0.95rem;
  color: var(--muted);
  margin-top: 0;
}

.ordered-list {
  padding-left: 1.2rem;
  margin: 0.5rem 0 1rem;
}

.ordered-list li {
  margin-bottom: 0.6rem;
  font-size: 0.95rem;
}

.next-stop {
  background: #faf1dc;
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 0.7rem 0.9rem;
  margin-bottom: 0.8rem;
}

.next-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--black);
  margin-bottom: 0.15rem;
}

#nextStopText {
  margin: 0 0 0.7rem;
  font-size: 1rem;
  font-weight: 600;
}

.progress-list {
  list-style: none;
  padding-left: 0;
}

.progress-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  padding: 0.65rem 0.2rem;
  border-bottom: 1px solid var(--border);
}

.progress-actions {
  display: flex;
  gap: 0.5rem;
}

.progress-actions > * {
  flex: 1;
}

.progress-item:last-child { border-bottom: none; }

.progress-item.completed .stop-name,
.progress-item.completed .stop-addr {
  color: #b4a78f;
  text-decoration: line-through;
}

.progress-num {
  font-weight: 700;
  color: var(--gold);
  margin-right: 0.4rem;
}

.complete-btn {
  border: none;
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  background: var(--black);
  color: var(--gold-bright);
}

.complete-btn.done {
  background: #e5ded1;
  color: #6b5842;
}

.nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--black);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  color: var(--black);
  background: white;
}

.wa-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.3rem;
  height: 2.3rem;
  border: none;
  border-radius: 8px;
  background: #25d366;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}

.wa-icon-btn svg {
  width: 1.3rem;
  height: 1.3rem;
  fill: white;
}

#map {
  height: 260px;
  border-radius: 12px;
  margin: 0.5rem 0 1rem;
  border: 1px solid var(--border);
}

.btn-maps {
  display: block;
  text-align: center;
  text-decoration: none;
  margin-bottom: 0;
}

/* Pedidos */

.flavor-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.2rem;
  border-bottom: 1px solid var(--border);
}

.flavor-row:last-of-type { border-bottom: none; }

.flavor-name { font-size: 0.95rem; font-weight: 600; }

.stepper {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.step-btn {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  border: 1px solid var(--black);
  background: white;
  color: var(--black);
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.step-btn:active { background: var(--gold); }

.step-value {
  min-width: 1.6rem;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 700;
}

.pedido-total {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  margin-top: 0.2rem;
  color: var(--black);
}

.pedidos-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
}

.pedido-item {
  padding: 0.7rem 0.2rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.6rem;
}

.pedido-item:last-child { border-bottom: none; }

.pedido-cliente { font-weight: 700; }
.pedido-tel { display: block; color: var(--muted); font-size: 0.85rem; }
.pedido-items { display: block; font-size: 0.85rem; margin-top: 0.2rem; }

.pedido-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex-shrink: 0;
}

.edit-btn {
  border: 1px solid var(--black);
  background: white;
  color: var(--black);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.sales-report h2 {
  margin-top: 0;
}

.sales-report .pedidos-list li {
  display: flex;
  flex-direction: column;
  padding: 0.6rem 0.2rem;
  border-bottom: 1px solid var(--border);
}

.sales-report .pedidos-list li:last-child { border-bottom: none; }

.pedidos-totals {
  background: var(--black);
  color: var(--gold-bright);
  border-radius: 12px;
  padding: 0.8rem 0.9rem;
  margin-bottom: 0.8rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 100;
}

.modal-overlay.hidden {
  display: none;
}

.modal-box {
  background: white;
  border-radius: 16px;
  padding: 1.2rem;
  width: 100%;
  max-width: 340px;
}

.modal-text {
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
  margin: 0 0 1rem;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}

.historial-day {
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 0.8rem;
  overflow: hidden;
}

.historial-day-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: none;
  border: none;
  padding: 1rem;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
}

.historial-day-date {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  color: var(--black);
  font-size: 1rem;
}

.historial-day-meta {
  color: var(--muted);
  font-size: 0.8rem;
  flex: 1;
  text-align: right;
  margin-right: 0.2rem;
}

.historial-toggle-icon {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--gold);
  width: 1.4rem;
  text-align: center;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.historial-day-header.expanded .historial-toggle-icon {
  transform: rotate(45deg);
}

.historial-day-body {
  list-style: none;
  margin: 0;
  padding: 0 1rem 1rem;
}

.historial-day-body li {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.6rem 0;
  border-top: 1px solid var(--border);
}

.historial-search-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.2rem;
  border-bottom: 1px solid var(--border);
}

.historial-search-row:last-child { border-bottom: none; }
