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

:root {
  --p:       #0f6e56;
  --p-dk:    #085041;
  --p-lt:    #e8f5f1;
  --accent:  #f0a500;
  --danger:  #e53e3e;
  --success: #38a169;
  --gray-50: #fafafa;
  --gray-100:#f4f4f5;
  --gray-200:#e4e4e7;
  --gray-400:#a1a1aa;
  --gray-600:#52525b;
  --gray-900:#18181b;
  --white:   #ffffff;
  --radius:  12px;
  --radius-lg: 18px;
  --shadow:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  min-height: 100vh;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Navbar ── */
.navbar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 0 1rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar-brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--p);
  display: flex;
  align-items: center;
  gap: .5rem;
}
.navbar-brand span { color: var(--gray-900); }
.navbar-user {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: .875rem;
  color: var(--gray-600);
}
.avatar {
  width: 32px; height: 32px;
  background: var(--p-lt);
  color: var(--p);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .8rem;
}

/* ── Auth ── */
.auth-body {
  background: var(--gray-50);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}
.login-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-md);
}
.login-logo {
  width: 52px; height: 52px;
  background: var(--p);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  margin: 0 auto 1.25rem;
}
.login-title {
  text-align: center;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: .25rem;
}
.login-subtitle {
  text-align: center;
  font-size: .875rem;
  color: var(--gray-400);
  margin-bottom: 1.75rem;
}

/* ── Forms ── */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: .375rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: .75rem 1rem;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 1rem;
  background: var(--white);
  color: var(--gray-900);
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--p);
  box-shadow: 0 0 0 3px rgba(15,110,86,.1);
}
.form-group textarea { resize: vertical; min-height: 80px; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .75rem 1.5rem;
  border-radius: var(--radius);
  font-size: .95rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary  { background: var(--p); color: var(--white); }
.btn-primary:hover  { background: var(--p-dk); }
.btn-outline  { background: transparent; color: var(--p); border: 1.5px solid var(--p); }
.btn-outline:hover  { background: var(--p-lt); }
.btn-danger   { background: var(--danger); color: var(--white); }
.btn-danger:hover   { background: #c53030; }
.btn-ghost    { background: transparent; color: var(--gray-600); }
.btn-ghost:hover    { background: var(--gray-100); }
.btn-block    { width: 100%; }
.btn-lg       { padding: 1rem; font-size: 1.05rem; border-radius: var(--radius-lg); }
.btn-sm       { padding: .45rem .9rem; font-size: .825rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Alerts ── */
.alert {
  padding: .875rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .875rem;
  display: flex;
  align-items: flex-start;
  gap: .5rem;
}
.alert-error   { background: #fff5f5; color: #c53030; border: 1px solid #fed7d7; }
.alert-success { background: #f0fff4; color: #276749; border: 1px solid #c6f6d5; }
.alert-info    { background: var(--p-lt); color: var(--p-dk); border: 1px solid #b2dfdb; }

/* ── Layout ── */
.main-content {
  padding: 1rem;
  max-width: 680px;
  margin: 0 auto;
}

/* ── Cards ── */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: .875rem;
  border: 1px solid var(--gray-200);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.card-title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--gray-900);
}
.card-muted { font-size: .8rem; color: var(--gray-400); }

/* ── Visita card ── */
.visita-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: .75rem;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  text-decoration: none;
  color: inherit;
}
.visita-card:hover { border-color: var(--p); box-shadow: var(--shadow-md); }
.visita-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}
.visita-body { flex: 1; min-width: 0; }
.visita-cliente { font-weight: 600; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.visita-tipo    { font-size: .8rem; color: var(--gray-400); margin-top: .125rem; }
.visita-meta    { font-size: .75rem; color: var(--gray-400); text-align: right; flex-shrink: 0; }

/* ── Status badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .25rem .625rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-pendiente   { background: #fef3c7; color: #92400e; }
.badge-en_curso    { background: #dbeafe; color: #1e40af; }
.badge-completada  { background: #dcfce7; color: #166534; }
.badge-cancelada   { background: var(--gray-100); color: var(--gray-600); }

/* ── Tipo icons ── */
.tipo-gestion_comercial  { background: #ede9fe; }
.tipo-cobranza           { background: #fef3c7; }
.tipo-entrega_mercaderia { background: #dbeafe; }
.tipo-reunion_rutina     { background: #dcfce7; }
.tipo-entrada_salida     { background: var(--gray-100); }

/* ── Check-in card ── */
.checkin-card {
  background: var(--p);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  color: var(--white);
  margin-bottom: 1rem;
  text-align: center;
}
.checkin-card h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: .25rem; }
.checkin-card p  { font-size: .875rem; opacity: .85; margin-bottom: 1.25rem; }

/* ── Geo status ── */
.geo-status {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .625rem 1rem;
  border-radius: var(--radius);
  font-size: .825rem;
  font-weight: 500;
  margin-bottom: 1rem;
}
.geo-ok      { background: #f0fff4; color: #276749; border: 1px solid #c6f6d5; }
.geo-waiting { background: #fefce8; color: #854d0e; border: 1px solid #fef08a; }
.geo-error   { background: #fff5f5; color: #c53030; border: 1px solid #fed7d7; }

/* ── Photo preview ── */
.photo-area {
  border: 2px dashed var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  margin-bottom: 1rem;
}
.photo-area:hover { border-color: var(--p); background: var(--p-lt); }
.photo-area img   { width: 100%; border-radius: var(--radius); margin-top: .5rem; }
.photo-placeholder { color: var(--gray-400); font-size: .875rem; }
.photo-placeholder .icon { font-size: 2rem; margin-bottom: .5rem; }

/* ── Dashboard stats ── */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
  margin-bottom: 1rem;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 1rem;
  text-align: center;
}
.stat-num  { font-size: 1.75rem; font-weight: 700; color: var(--gray-900); }
.stat-label{ font-size: .75rem; color: var(--gray-400); margin-top: .125rem; }

/* ── Section title ── */
.section-title {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-400);
  margin-bottom: .75rem;
  margin-top: 1.25rem;
}

/* ── Divider ── */
.divider { height: 1px; background: var(--gray-200); margin: 1rem 0; }

/* ── Footer ── */
.footer {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--gray-400);
  font-size: .75rem;
}

/* ── Responsive ── */
@media (min-width: 640px) {
  .main-content { padding: 1.5rem; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ── Tipo icon texto ── */
.visita-icon {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--gray-600);
}
.tipo-gestion_comercial  { background: #ede9fe; color: #5b21b6; }
.tipo-cobranza           { background: #fef3c7; color: #92400e; }
.tipo-entrega_mercaderia { background: #dbeafe; color: #1e40af; }
.tipo-reunion_rutina     { background: #dcfce7; color: #166534; }
.tipo-entrada_salida     { background: var(--gray-100); color: var(--gray-600); }

/* ── Admin nav responsive ── */
.admin-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.admin-nav-links {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}
.admin-nav-mobile { display: none; }

@media (max-width: 600px) {
  .admin-nav { flex-direction: column; align-items: flex-start; gap: .75rem; }
  .admin-nav-links { display: none; }
  .admin-nav-mobile { display: block; width: 100%; }
  .admin-nav-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 8px;
  }
  .admin-nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: var(--radius);
    border: 0.5px solid var(--gray-200);
    background: var(--gray-50);
    text-decoration: none;
    color: var(--gray-900);
    font-size: .8rem;
  }
  .admin-nav-item i { font-size: 16px; color: var(--gray-600); }
}

.badge-vencida  { background: #fef2f2; color: #991b1b; }

/* ── Toasts ── */
#toast-container {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  width: calc(100% - 2rem);
  max-width: 420px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  border: 0.5px solid transparent;
  font-size: .875rem;
  pointer-events: all;
  animation: toastIn .2s ease;
}
.toast-error   { background:#fef2f2; border-color:#fecaca; }
.toast-success { background:#f0fdf4; border-color:#bbf7d0; }
.toast-info    { background:var(--p-lt); border-color:#b2dfdb; }
.toast-icon  { font-size:18px; flex-shrink:0; margin-top:1px; }
.toast-error   .toast-icon { color:#dc2626; }
.toast-success .toast-icon { color:#16a34a; }
.toast-info    .toast-icon { color:var(--p); }
.toast-body  { flex:1; }
.toast-title { font-weight:600; margin-bottom:2px; }
.toast-error   .toast-title { color:#991b1b; }
.toast-success .toast-title { color:#166534; }
.toast-info    .toast-title { color:var(--p-dk); }
.toast-msg   { font-size:.8rem; }
.toast-error   .toast-msg { color:#b91c1c; }
.toast-success .toast-msg { color:#15803d; }
.toast-info    .toast-msg { color:var(--p); }
.toast-close { background:none; border:none; cursor:pointer; font-size:1.1rem; opacity:.6; flex-shrink:0; }
@keyframes toastIn { from { opacity:0; transform:translateY(-8px); } to { opacity:1; transform:translateY(0); } }

/* ── Modal confirm ── */
#modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 9998;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
#modal-overlay.active { display: flex; }
#modal-box {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  width: 100%;
  max-width: 400px;
  animation: modalIn .2s ease;
}
@keyframes modalIn { from { opacity:0; transform:translateY(20px); } to { opacity:1; transform:translateY(0); } }
.modal-icon {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: #fef2f2;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 1rem;
}
.modal-icon i { font-size: 22px; color: #dc2626; }
.modal-title { font-size: 1rem; font-weight: 700; margin-bottom: .375rem; }
.modal-msg   { font-size: .875rem; color: var(--gray-600); margin-bottom: 1.25rem; }
.modal-btns  { display: flex; gap: .625rem; }
.modal-btns .btn { flex: 1; }

.badge-vencida { background: #fef2f2; color: #991b1b; }

/* ── Autocomplete ── */
.autocomplete-lista {
  position: absolute;
  z-index: 9999;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-height: 200px;
  overflow-y: auto;
  width: 100%;
  left: 0;
  top: 100%;
}
.autocomplete-item {
  padding: .625rem .875rem;
  font-size: .875rem;
  cursor: pointer;
  border-bottom: 0.5px solid var(--gray-100);
  color: var(--gray-900);
}
.autocomplete-item:hover { background: var(--p-lt); }
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-wrap { position: relative; flex: 1; }

/* ── Buscador select ── */
.buscador-wrap { position: relative; }
.buscador-wrap .ti-search {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%);
  font-size: 16px; color: var(--gray-400); pointer-events: none;
}
.buscador-lista {
  border: 0.5px solid var(--gray-200);
  border-radius: var(--radius);
  margin-top: 4px;
  background: var(--white);
  max-height: 220px;
  overflow-y: auto;
}
.buscador-item {
  padding: .625rem .875rem;
  cursor: pointer;
  border-bottom: 0.5px solid var(--gray-100);
}
.buscador-item:last-child { border-bottom: none; }
.buscador-item:hover { background: var(--p-lt); }
.buscador-item.activo { background: var(--p-lt); }
.buscador-item .b-nombre { font-size: .875rem; color: var(--gray-900); }
.buscador-item .b-sub { font-size: .75rem; color: var(--gray-400); margin-top: 1px; }
.buscador-seleccionado {
  display: none; margin-top: 8px; padding: 8px 12px;
  background: #f0fdf4; border-radius: var(--radius);
  align-items: center; gap: 8px; border: 0.5px solid #bbf7d0;
}
.buscador-sin-resultados {
  display: none; padding: .75rem;
  text-align: center; font-size: .875rem; color: var(--gray-400);
}

/* ── Botones de acción (dashboard vendedor) ── */
.accion-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 1.25rem;
}
.accion-btn {
  text-decoration: none;
  border-radius: 8px;
  padding: .875rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.accion-btn-primary {
  background: #0f6e56;
}
.accion-btn-primary i,
.accion-btn-primary span {
  color: #ffffff;
}
.accion-btn-secondary {
  background: #ffffff;
  border: 1.5px solid #e5e7eb;
}
.accion-btn-secondary i,
.accion-btn-secondary span {
  color: #111827;
}
.accion-btn span {
  font-size: .8rem;
  font-weight: 600;
  text-align: center;
}
.accion-btn i {
  font-size: 22px;
}
.accion-full {
  grid-column: 1 / -1;
}
