/* ═══════════════════════════════════════════════════════════
   RECORRIDAS — Stylesheet
   ═══════════════════════════════════════════════════════════ */

/* ── Design Tokens ── */
:root {
  --bg: #0C0C0E;
  --surface: #161619;
  --surface2: #1E1E22;
  --surface3: #26262B;
  --border: #2A2A30;
  --border2: #35353D;

  --text: #E8E6E3;
  --text2: #9B9A97;
  --text3: #6B6A68;

  --accent: #F97316;
  --accent2: #FB923C;

  --green: #22C55E;
  --green-bg: rgba(34, 197, 94, 0.10);
  --green-border: rgba(34, 197, 94, 0.20);

  --yellow: #EAB308;
  --yellow-bg: rgba(234, 179, 8, 0.08);
  --yellow-border: rgba(234, 179, 8, 0.18);

  --red: #EF4444;
  --red-bg: rgba(239, 68, 68, 0.08);

  --blue: #3B82F6;
  --blue-bg: rgba(59, 130, 246, 0.08);

  --new-bg: rgba(249, 115, 22, 0.06);
  --new-border: rgba(249, 115, 22, 0.20);

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.3);

  --font: 'DM Sans', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}


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

html {
  font-family: var(--font);
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

button {
  font-family: var(--font);
  cursor: pointer;
}

input, select, textarea {
  font-family: var(--font);
}


/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }


/* ── Utility ── */
.hidden { display: none !important; }
.green { color: var(--green); }
.red { color: var(--red); }


/* ═══════════════════════════════════════════
   LOGIN SCREEN
   ═══════════════════════════════════════════ */
.login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 40px 20px;
}

.login-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -1px;
}

.login-title span { color: var(--accent); }

.login-sub {
  color: var(--text2);
  margin-top: 6px;
  margin-bottom: 32px;
  font-size: 15px;
}

.login-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  max-width: 360px;
  width: 100%;
}

.login-btn {
  padding: 18px 16px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.login-btn:hover {
  border-color: var(--accent);
  background: var(--surface2);
}

.login-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  margin: 0 auto 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}

.login-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.login-hint {
  font-size: 11px;
  color: var(--text3);
  margin-top: 24px;
}

/* ── Login Form (real auth) ── */
.login-form {
  width: 100%;
  max-width: 340px;
}

.login-form .form-group { margin-bottom: 14px; }

.login-submit {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  margin-top: 6px;
}

.login-error {
  background: var(--red-bg);
  color: var(--red);
  font-size: 13px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* ── Loading Screen ── */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--text3);
  gap: 16px;
  font-size: 14px;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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


/* ═══════════════════════════════════════════
   NO RECORRIDA
   ═══════════════════════════════════════════ */
.no-recorrida {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  text-align: center;
  padding: 40px 20px;
}

.no-recorrida h2 {
  font-size: 22px;
  margin-top: 16px;
}

.no-recorrida p {
  color: var(--text2);
  margin: 8px 0 24px;
}


/* ═══════════════════════════════════════════
   APP LAYOUT
   ═══════════════════════════════════════════ */
.app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}


/* ── Header ── */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-menu-btn {
  border: none;
  padding: 6px;
}

.fecha-badge {
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  background: var(--surface2);
  padding: 4px 10px;
  border-radius: 20px;
  font-family: var(--mono);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface2);
}

.user-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

/* ── Menu Drawer (mobile) ── */
.menu-drawer {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px 16px;
  animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.menu-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.menu-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.menu-summary .summary-card {
  padding: 10px 12px;
}

.menu-summary .summary-value {
  font-size: 18px;
}

/* ── Responsive visibility ── */
@media (max-width: 639px) {
  .header-desktop-only { display: none; }
  .summary-desktop-only { display: none; }
}

@media (min-width: 640px) {
  .header-menu-btn { display: none; }
  .menu-drawer { display: none !important; }
  .header-desktop-only { display: flex; }
  .summary-desktop-only { display: flex; }
}


/* ── Closed Banner ── */
.closed-banner {
  background: var(--green-bg);
  border: 1px solid var(--green-border);
  border-radius: var(--radius);
  padding: 14px 20px;
  margin: 16px 20px 0;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--green);
}


/* ── Summary Bar ── */
.summary-bar {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  overflow-x: auto;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
}

.summary-bar::-webkit-scrollbar { display: none; }

.summary-card {
  flex: 1;
  min-width: 120px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.summary-card.accent {
  border-color: var(--accent);
  background: rgba(249, 115, 22, 0.05);
}

.summary-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text3);
  margin-bottom: 4px;
  font-weight: 600;
}

.summary-value {
  font-size: 20px;
  font-weight: 700;
  font-family: var(--mono);
  letter-spacing: -0.5px;
}


/* ── Controls Bar ── */
.controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px 12px;
  gap: 10px;
  flex-wrap: wrap;
}

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

.tabs {
  display: flex;
  gap: 3px;
  background: var(--surface);
  border-radius: 8px;
  padding: 3px;
}

.tab {
  font-size: 13px;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  background: transparent;
  color: var(--text2);
  transition: all 0.15s;
}

.tab:hover { color: var(--text); }
.tab.active { background: var(--accent); color: #fff; }

.tab .count {
  font-family: var(--mono);
  font-size: 11px;
  margin-left: 3px;
  opacity: 0.7;
}

.view-toggle {
  display: flex;
  gap: 2px;
  background: var(--surface);
  border-radius: 6px;
  padding: 2px;
}

.view-btn {
  padding: 6px 8px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  background: transparent;
  color: var(--text3);
  transition: all 0.15s;
  display: flex;
  align-items: center;
}

.view-btn.active {
  background: var(--surface3);
  color: var(--text);
}


/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  line-height: 1;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); }

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  border-color: var(--border2);
  background: var(--surface3);
}

.btn-danger {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.2);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.14); }

.btn-success {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid var(--green-border);
}
.btn-success:hover { background: rgba(34, 197, 94, 0.16); }

.btn-sm { padding: 5px 10px; font-size: 12px; }

.btn-icon {
  padding: 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}
.btn-icon:hover {
  background: var(--surface2);
  color: var(--text);
}


/* ── Warning Banner ── */
.warning-banner {
  background: var(--yellow-bg);
  border: 1px solid var(--yellow-border);
  border-radius: var(--radius);
  padding: 10px 16px;
  margin: 0 20px 12px;
  font-size: 13px;
  color: var(--yellow);
  display: flex;
  align-items: center;
  gap: 8px;
}


/* ── Gastos Section ── */
.gastos-section { padding: 0 20px 12px; }

.section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.gasto-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 5px;
  font-size: 14px;
}

.gasto-concepto-user {
  color: var(--text3);
  font-size: 12px;
}

.gasto-monto {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--red);
  white-space: nowrap;
}

.gasto-delete {
  padding: 2px 6px;
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}

.gasto-row:hover .gasto-delete { opacity: 1; }


/* ═══════════════════════════════════════════
   POINTS — Card View
   ═══════════════════════════════════════════ */
.points-container {
  padding: 0 20px 120px;
}

.points-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text3);
  font-size: 14px;
}

/* Card */
.point-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
  transition: all 0.2s;
  animation: cardIn 0.25s ease-out;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.point-card.nuevo {
  border-color: var(--new-border);
  background: var(--new-bg);
}

.point-card.realizado { opacity: 0.55; }

.point-card.en-proceso {
  border-color: var(--yellow-border);
  background: var(--yellow-bg);
}

/* Card header */
.point-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.point-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--mono);
  background: var(--surface3);
  color: var(--text2);
  flex-shrink: 0;
}

.point-card.realizado .point-num { background: var(--green-bg); color: var(--green); }
.point-card.en-proceso .point-num { background: var(--yellow-bg); color: var(--yellow); }
.point-card.nuevo .point-num { background: rgba(249, 115, 22, 0.15); color: var(--accent); }

.point-info {
  flex: 1;
  min-width: 0;
}

.point-cliente {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.point-meta {
  font-size: 12px;
  color: var(--text3);
  margin-top: 3px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.point-tipo {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--surface3);
  color: var(--text2);
  white-space: nowrap;
}

.point-importe {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--green);
  font-size: 14px;
  white-space: nowrap;
  margin-left: auto;
  padding-left: 8px;
}

.point-status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
  margin-left: 6px;
  flex-shrink: 0;
}

.status-pendiente { background: var(--surface3); color: var(--text3); }
.status-en-proceso { background: var(--yellow-bg); color: var(--yellow); border: 1px solid var(--yellow-border); }
.status-realizado { background: var(--green-bg); color: var(--green); }
.status-sin-atender { background: rgba(139,92,246,0.10); color: #A78BFA; border: 1px solid rgba(139,92,246,0.20); }

.point-card.sin-atender {
  border-color: rgba(139,92,246,0.25);
  background: rgba(139,92,246,0.05);
}
.point-card.sin-atender .point-num { background: rgba(139,92,246,0.15); color: #A78BFA; }

.proceso-user {
  font-size: 11px;
  color: var(--yellow);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.proceso-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.done-user {
  font-size: 11px;
  color: var(--green);
}

/* Card body (expanded) */
.point-body {
  padding: 0 16px 14px;
  border-top: 1px solid var(--border);
}

.point-detail-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 0;
  font-size: 13px;
  color: var(--text2);
}

.point-detail-row svg { color: var(--text3); flex-shrink: 0; }
.point-detail-text { flex: 1; min-width: 0; word-break: break-word; }

.point-notas {
  font-size: 13px;
  color: var(--text2);
  font-style: italic;
  padding: 8px 12px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  margin-top: 6px;
  word-break: break-word;
}

.point-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
}


/* ═══════════════════════════════════════════
   POINTS — Compact List View
   ═══════════════════════════════════════════ */
.compact-list {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.compact-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  transition: all 0.15s;
}

.compact-row:last-child { border-bottom: none; }
.compact-row.nuevo { background: var(--new-bg); }
.compact-row.realizado { opacity: 0.5; }
.compact-row.en-proceso { background: var(--yellow-bg); }
.compact-row.sin-atender { background: rgba(139,92,246,0.05); }

.compact-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--mono);
  background: var(--surface3);
  color: var(--text2);
  flex-shrink: 0;
}

.compact-cliente {
  font-size: 14px;
  font-weight: 500;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compact-proceso-user {
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.compact-tipo {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--surface3);
  color: var(--text2);
  white-space: nowrap;
}

.compact-importe {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--green);
  font-weight: 600;
  white-space: nowrap;
}

.compact-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.compact-actions .btn-icon { padding: 4px; }

/* Zona badges */
.zona-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--surface3);
  color: var(--text2);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.zona-badge.zona-peligro {
  background: rgba(239,68,68,0.12);
  color: var(--red);
  border: 1px solid rgba(239,68,68,0.2);
}

/* Compact expandable body */
.compact-body {
  width: 100%;
  padding: 10px 14px 12px 14px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text2);
  animation: cardIn 0.2s ease-out;
  overflow: hidden;
}

.compact-body .point-detail-row {
  padding: 5px 0;
  flex-wrap: wrap;
}

.compact-body .point-detail-row .btn {
  flex-shrink: 0;
}

.compact-body .point-actions {
  margin-top: 8px;
  flex-wrap: wrap;
}

.compact-body .factura-actions {
  flex-wrap: wrap;
}

/* Undo button */
.btn-undo {
  background: rgba(139,92,246,0.08);
  color: #A78BFA;
  border: 1px solid rgba(139,92,246,0.2);
}
.btn-undo:hover { background: rgba(139,92,246,0.14); }


/* ═══════════════════════════════════════════
   FAB
   ═══════════════════════════════════════════ */
.fab {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 24px rgba(249, 115, 22, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
  z-index: 50;
}

.fab:hover { transform: scale(1.08); }
.fab:active { transform: scale(0.96); }

.fab-map {
  bottom: 214px;
  right: 20px;
  background: var(--blue);
  box-shadow: 0 4px 24px rgba(59, 130, 246, 0.35);
  width: 48px;
  height: 48px;
}

.fab-chat {
  bottom: 156px;
  right: 20px;
  background: #8B5CF6;
  box-shadow: 0 4px 24px rgba(139, 92, 246, 0.35);
  width: 48px;
  height: 48px;
}

.chat-badge {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--mono);
  min-width: 18px; height: 18px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--bg);
}

@media (min-width: 640px) {
  .fab { bottom: 28px; right: 28px; }
  .fab-chat { bottom: 96px; right: 28px; }
  .fab-map { bottom: 154px; right: 28px; }
}

/* ═══════════════════════════════════════════
   CHAT PANEL
   ═══════════════════════════════════════════ */
.chat-panel {
  position: fixed;
  bottom: 90px; right: 20px;
  width: 320px;
  max-height: 480px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  z-index: 150;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.2s ease-out;
}

@media (max-width: 639px) {
  .chat-panel {
    bottom: 70px; right: 10px; left: 10px;
    width: auto;
    max-height: 65vh;
  }
}

.chat-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-panel-title {
  font-size: 15px;
  font-weight: 600;
  flex: 1;
}

/* User list */
.chat-user-list { display: flex; flex-direction: column; }

.chat-users {
  overflow-y: auto;
  max-height: 360px;
}

.chat-user-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.chat-user-item:hover { background: var(--surface2); }
.chat-user-item:last-child { border-bottom: none; }

.chat-user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}

.chat-user-info { flex: 1; min-width: 0; }
.chat-user-name { font-size: 14px; font-weight: 600; }
.chat-user-preview {
  font-size: 12px; color: var(--text3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.chat-user-unread {
  background: #8B5CF6;
  color: #fff;
  font-size: 10px; font-weight: 700;
  font-family: var(--mono);
  min-width: 20px; height: 20px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
}

/* Conversation */
.chat-conversation {
  display: flex;
  flex-direction: column;
  height: 420px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-msg {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.4;
  word-break: break-word;
  animation: fadeIn 0.15s;
}

.chat-msg.sent {
  align-self: flex-end;
  background: #8B5CF6;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-msg.received {
  align-self: flex-start;
  background: var(--surface3);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.chat-msg-sender {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: #A78BFA;
  margin-bottom: 2px;
}

.chat-msg-time {
  font-size: 10px;
  opacity: 0.6;
  margin-top: 2px;
  display: block;
}

.chat-msg-day {
  text-align: center;
  font-size: 11px;
  color: var(--text3);
  padding: 8px 0;
}

.chat-input-bar {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  padding: 8px 12px;
  font-size: 14px;
  font-family: var(--font);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  outline: none;
}
.chat-input:focus { border-color: #8B5CF6; }

.chat-send {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: #8B5CF6;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.chat-send:hover { background: #7C3AED; }


/* ═══════════════════════════════════════════
   BOTTOM NAV (mobile)
   ═══════════════════════════════════════════ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 6px 0 max(6px, env(safe-area-inset-bottom));
  z-index: 90;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text3);
  font-size: 10px;
  font-weight: 500;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.nav-item.active { color: var(--accent); }

@media (min-width: 640px) {
  .bottom-nav { display: none; }
  .points-container { padding-bottom: 40px; }
}


/* ═══════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.15s;
}

@keyframes fadeIn { from { opacity: 0; } }

.modal {
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.2s ease-out;
  padding: 24px;
}

@keyframes slideUp { from { transform: translateY(20px); } }

@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
  .modal { border-radius: var(--radius); }
}

.modal h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 12px;
}


/* ── Form ── */
.form-group { margin-bottom: 14px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 5px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent);
}

.form-textarea {
  min-height: 60px;
  resize: vertical;
}

.form-select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B6A68' stroke-width='2.5' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ── Factura Upload ── */
.factura-upload {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border: 2px dashed var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.factura-upload:hover {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(249,115,22,0.04);
}
.factura-upload.has-file {
  border-color: var(--green-border);
  background: var(--green-bg);
  color: var(--green);
  border-style: solid;
}

.factura-actual {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 8px;
}
.factura-actual a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.factura-actual a:hover { text-decoration: underline; }
.factura-actual .btn-icon { padding: 3px; }

/* ── Factura buttons in cards ── */
.factura-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.factura-actions .btn {
  font-size: 11px;
  padding: 4px 10px;
}


/* ── Cierre Modal ── */
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.summary-item {
  background: var(--surface2);
  padding: 12px;
  border-radius: var(--radius-sm);
}

.summary-item-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text3);
  font-weight: 600;
}

.summary-item-value {
  font-size: 20px;
  font-weight: 700;
  font-family: var(--mono);
  margin-top: 2px;
}

.cierre-resultado-box {
  background: var(--surface2);
  padding: 16px;
  border-radius: var(--radius-sm);
  text-align: center;
  margin-bottom: 20px;
}

.cierre-resultado-value {
  font-size: 32px;
  font-weight: 700;
  font-family: var(--mono);
  margin-top: 4px;
}


/* ═══════════════════════════════════════════
   MAP MODAL
   ═══════════════════════════════════════════ */
.modal-mapa {
  max-width: 700px;
  height: 85vh;
  display: flex;
  flex-direction: column;
}

.modal-mapa h2 { flex-shrink: 0; }

#map-container {
  flex: 1;
  min-height: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface2);
}

.map-legend {
  flex-shrink: 0;
  padding: 10px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 120px;
  overflow-y: auto;
}

.map-legend-item {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--surface2);
  color: var(--text2);
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: all 0.15s;
}

.map-legend-item:hover {
  border-color: var(--accent);
  color: var(--text);
}

.map-legend-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--mono);
}

/* Leaflet popup overrides */
.leaflet-popup-content-wrapper {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: var(--shadow) !important;
}
.leaflet-popup-content {
  margin: 10px 14px !important;
  font-family: var(--font) !important;
  font-size: 13px !important;
  line-height: 1.4 !important;
}
.leaflet-popup-content strong {
  font-size: 14px;
  display: block;
  margin-bottom: 2px;
}
.leaflet-popup-content .popup-tipo {
  font-size: 11px;
  color: var(--text3);
}
.leaflet-popup-content .popup-importe {
  color: var(--green);
  font-family: var(--mono);
  font-weight: 600;
}
.leaflet-popup-tip { background: var(--surface) !important; }

@media (min-width: 640px) {
  .modal-mapa { border-radius: var(--radius); height: 80vh; }
}

/* ═══════════════════════════════════════════
   HISTORIAL MODAL
   ═══════════════════════════════════════════ */
.modal-historial {
  max-width: 560px;
  max-height: 85vh;
}

.historial-list {
  max-height: 60vh;
  overflow-y: auto;
}

.historial-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  background: var(--surface2);
  transition: background 0.1s;
}

.historial-item:hover { background: var(--surface3); }

.historial-fecha {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

.historial-info {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--text2);
  line-height: 1.5;
}

.historial-resultado {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 16px;
  white-space: nowrap;
}

.historial-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.historial-empty {
  text-align: center;
  color: var(--text3);
  padding: 32px 20px;
  font-size: 14px;
}