:root {
  --primary: #021d33;
  --primary-mid: #0a2d4d;
  --accent: #0f6e9e;
  --accent-light: #e0f2fe;
  --accent-border: #38bdf8;
  --bg: #f0f4f8;
  --card: #ffffff;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-secondary: #475569;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --success: #16a34a;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 4px 16px rgba(2,29,51,.08), 0 1px 4px rgba(2,29,51,.05);
  --shadow-lg: 0 12px 40px rgba(2,29,51,.12), 0 4px 12px rgba(2,29,51,.07);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ── NAVBAR ─────────────────────────────── */
.navbar {
  background: var(--primary);
  padding: 0 40px;
  height: 62px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 0 rgba(255,255,255,.06);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.navbar img {
  height: 32px;
  object-fit: contain;
}

.navbar-divider {
  width: 1px;
  height: 20px;
  background: rgba(255,255,255,.2);
}

nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

nav a {
  color: rgba(255,255,255,.75);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 7px;
  transition: all .2s;
  letter-spacing: .01em;
}

nav a:hover {
  color: #fff;
  background: rgba(255,255,255,.1);
}

/* ── PAGE LAYOUT ─────────────────────────── */
.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 36px 24px 60px;
}

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  align-items: start;
}

/* ── SIDEBAR / PERFIL CARD ───────────────── */
.perfil-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: sticky;
  top: 86px;
}

.perfil-card-header {
  background: linear-gradient(160deg, var(--primary) 0%, var(--primary-mid) 100%);
  padding: 28px 24px 20px;
  text-align: center;
}

.avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255,255,255,.15);
  border: 2px solid rgba(255,255,255,.25);
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 600;
  color: #fff;
  font-family: 'DM Mono', monospace;
  letter-spacing: -1px;
}

.perfil-card-header h2 {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  letter-spacing: -.01em;
}

.perfil-card-header .email-badge {
  font-size: 12px;
  color: rgba(255,255,255,.65);
  font-weight: 400;
}

.perfil-card-body {
  padding: 16px 20px 20px;
}

.perfil-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.perfil-meta-row:last-child { border-bottom: none; }

.perfil-meta-icon {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.perfil-meta-icon svg {
  width: 15px;
  height: 15px;
  color: var(--muted);
}

.perfil-meta-value {
  color: var(--text-secondary);
  font-size: 13px;
  min-height: 16px;
}

.perfil-meta-value.italic { font-style: italic; color: #94a3b8; }

.perfil-actions {
  padding: 0 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn {
  width: 100%;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  letter-spacing: .01em;
}

.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: #0c5f89;
  border-color: #0c5f89;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(15,110,158,.3);
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-outline:hover {
  background: var(--bg);
  border-color: #94a3b8;
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: #fecaca;
}

.btn-danger:hover {
  background: var(--danger-bg);
  border-color: #fca5a5;
}

/* ── TABS ────────────────────────────────── */
.tabs-wrapper {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  display: inline-flex;
  padding: 5px;
  gap: 3px;
  margin-bottom: 20px;
}

.tabs-wrapper button {
  border: none;
  background: transparent;
  padding: 8px 20px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  border-radius: 9px;
  cursor: pointer;
  color: var(--muted);
  transition: all .2s;
  letter-spacing: .01em;
}

.tabs-wrapper button:hover:not(.active) {
  background: var(--bg);
  color: var(--text);
}

.tabs-wrapper button.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(2,29,51,.25);
}

/* ── TAB CONTENT ─────────────────────────── */
.tab-content { display: none; }
.tab-content.active {
  display: block;
  animation: fadeIn .25s ease;
}

/* El grid va en los contenedores internos que genera perfil.js */
#lista-compras,
#lista-favoritos,
#lista-turnos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.tab-empty {
  grid-column: 1/-1;
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.tab-empty svg {
  width: 36px;
  height: 36px;
  margin: 0 auto 12px;
  display: block;
  opacity: .3;
}

/* ── ITEM CARDS ──────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow .2s, transform .2s;
  padding: 14px 16px;
}

.card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

/* imagen generada por perfil.js — sin wrapper */
.card img {
  width: calc(100% + 32px);
  margin: -14px -16px 14px;
  height: 150px;
  object-fit: contain;
  display: block;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  box-sizing: border-box;
}

.card h3 {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}

.card p {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--text-secondary);
}

.card strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  font-family: 'DM Mono', monospace;
  margin-top: 6px;
}

/* botón "Quitar" de favoritos generado por perfil.js */
.card button {
  margin-top: 12px;
  width: 100%;
  padding: 8px;
  background: transparent;
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: 50px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
}

.card button:hover {
  background: var(--danger-bg);
  border-color: #fca5a5;
}

.estado {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 50px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.estado::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.estado.ok { background: #dcfce7; color: #15803d; }
.estado.fav { background: #fee2e2; color: #b91c1c; }
.estado.pending { background: #fef9c3; color: #a16207; }


/* ── MODALS ──────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 15, 30, .55);
  display: none;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(8px);
  z-index: 200;
  animation: fadeBg .2s;
  padding: 20px;
}

.modal.open { display: flex; }

.modal-box {
  background: var(--card);
  border-radius: 18px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  animation: scaleIn .25s cubic-bezier(.22,1,.36,1);
  overflow: hidden;
}

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -.01em;
}

.close-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: all .2s;
  font-size: 16px;
}

.close-btn:hover { background: var(--border); color: var(--text); }

.modal-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-group {
  margin-bottom: 12px;
}

.modal-body label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 5px;
}

.modal-body input {
  width: 100%;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}

.modal-body input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15,110,158,.12);
}

.modal-footer {
  padding: 14px 24px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal-footer .btn {
  width: auto;
  padding: 9px 20px;
}

.btn-cancel {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
}

.btn-cancel:hover { background: var(--bg); }

.btn-save {
  background: var(--accent);
  color: #fff;
  border: none;
}

.btn-save:hover { background: #0c5f89; }

.btn-save.loading {
  background: #94a3b8;
  cursor: not-allowed;
  position: relative;
  padding-right: 40px;
}

.btn-save.loading::after {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
}

/* ── DANGER MODAL ────────────────────────── */
.modal-danger .modal-header { border-bottom-color: #fee2e2; }
.modal-danger .modal-header h3 { color: var(--danger); }
.modal-danger .btn-confirm-danger {
  background: var(--danger);
  color: #fff;
  border: none;
}
.modal-danger .btn-confirm-danger:hover { background: #b91c1c; }

/* ── PASSWORD FIELDS ─────────────────────── */
.password-wrapper {
  position: relative;
}

.password-wrapper input {
  padding-right: 42px;
}

.toggle-pass {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .2s;
}

.toggle-pass:hover { color: var(--primary); }
.toggle-pass svg { width: 16px; height: 16px; display: block; }
.eye-open { display: none; }

/* ── FORM ERRORS ─────────────────────────── */
.error {
  color: var(--danger);
  font-size: 11.5px;
  min-height: 14px;
  display: block;
  margin-top: 3px;
  font-weight: 500;
}

/* ── TOAST ───────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--primary);
  color: white;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity .25s, transform .25s;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 320px;
}

.toast::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,.5);
  flex-shrink: 0;
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: #15803d; }
.toast.error { background: var(--danger); }

/* ── ANIMATIONS ──────────────────────────── */
@keyframes scaleIn {
  from { transform: scale(.96); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes fadeBg {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes spin {
  to { transform: translateY(-50%) rotate(360deg); }
}

/* ── RESPONSIVE ──────────────────────────── */
@media (max-width: 720px) {
  .navbar { padding: 0 20px; }
  .page { padding: 20px 16px 48px; }
  .layout { grid-template-columns: 1fr; }
  .perfil-card { position: static; }
}
/* =======================
   TOAST — BLUEMOTORS (insignia circular)
======================= */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  min-width: 320px;
  max-width: 400px;
  padding: 16px 44px 16px 60px;
  border-radius: 18px;

  background: linear-gradient(135deg, #0b2840, #021d33);
  border: 1px solid rgba(255,255,255,0.06);

  color: white;
  font-family: 'Segoe UI', Arial, sans-serif;

  opacity: 0;
  transform: translateY(30px) scale(0.95);
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);

  z-index: 99999;
  overflow: visible;

  box-shadow: 0 18px 50px rgba(0,0,0,0.5);
}

.toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* glow decorativo */
.toast::before {
  content: "";
  position: absolute;
  top: -30px; right: -30px;
  width: 110px; height: 110px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0.12;
}

/* =======================
   INSIGNIA (ícono que sobresale)
======================= */
.toast-icon {
  position: absolute;
  left: -16px;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: bold;
  color: white;
  box-shadow: 0 8px 22px rgba(0,0,0,0.4), 0 0 0 5px #0b1620;
  animation: toast-pop 0.5s cubic-bezier(0.34, 1.8, 0.64, 1);
}

@keyframes toast-pop {
  0%   { transform: translateY(-50%) scale(0.3) rotate(-45deg); opacity: 0; }
  60%  { transform: translateY(-50%) scale(1.15) rotate(10deg); }
  100% { transform: translateY(-50%) scale(1) rotate(0deg); opacity: 1; }
}

/* =======================
   CONTENIDO
======================= */
.toast-content {
  position: relative;
  z-index: 1;
}

.toast-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.3px;
  margin-bottom: 3px;
  display: block;
}

.toast-message {
  font-size: 12.5px;
  color: rgba(255,255,255,0.55);
  line-height: 1.4;
  display: block;
}

/* =======================
   ANILLO DE PROGRESO + CERRAR
======================= */
.toast-ring {
  position: absolute;
  right: 14px;
  top: 14px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: conic-gradient(var(--ring-color, #38bdf8) 0% 100%, rgba(255,255,255,0.1) 100% 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 4s linear;
}

.toast-ring::after {
  content: "✕";
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #0b2840;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  color: rgba(255,255,255,0.4);
}

.toast-ring:hover::after {
  color: white;
}

/* línea de velocidad decorativa */
.toast::after {
  content: "";
  position: absolute;
  bottom: 0; left: 60px; right: 20px;
  height: 1px;
  background: linear-gradient(90deg, var(--line-color, #38bdf8), transparent);
  opacity: 0.5;
}

/* =======================
   STACKING — varios toasts
======================= */
.toast:nth-last-of-type(2) {
  transform: scale(0.96) translateY(76px);
  opacity: 0.55;
  z-index: 99998;
}

.toast:nth-last-of-type(2).show {
  transform: scale(0.96) translateY(76px);
}

.toast:nth-last-of-type(n+3) {
  display: none;
}

/* =======================
   TIPOS
======================= */
.toast-success { --ring-color: #38bdf8; --line-color: #38bdf8; }
.toast-success::before { background: #38bdf8; }
.toast-success .toast-icon {
  background: linear-gradient(135deg, #38bdf8, #2563eb);
  box-shadow: 0 8px 22px rgba(56,189,248,0.45), 0 0 0 5px #0b1620;
}

.toast-error { --ring-color: #ef4444; --line-color: #ef4444; }
.toast-error::before { background: #ef4444; }
.toast-error .toast-icon {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  box-shadow: 0 8px 22px rgba(239,68,68,0.45), 0 0 0 5px #0b1620;
}

.toast-warning { --ring-color: #f59e0b; --line-color: #f59e0b; }
.toast-warning::before { background: #f59e0b; }
.toast-warning .toast-icon {
  background: linear-gradient(135deg, #f59e0b, #b45309);
  box-shadow: 0 8px 22px rgba(245,158,11,0.45), 0 0 0 5px #0b1620;
}

/* =======================
   ANIMACIÓN DE PROGRESO (consumo del anillo)
======================= */
.toast.show .toast-ring {
  animation: ring-drain 4s linear forwards;
}

@keyframes ring-drain {
  from { background: conic-gradient(var(--ring-color) 0% 100%, rgba(255,255,255,0.1) 100% 100%); }
  to   { background: conic-gradient(var(--ring-color) 0% 0%, rgba(255,255,255,0.1) 0% 100%); }
}

.toast-paused .toast-ring {
  animation-play-state: paused;
}

/* =======================
   RESPONSIVE
======================= */
@media (max-width: 480px) {
  .toast {
    bottom: 16px;
    right: 16px;
    left: 16px;
    min-width: 0;
    max-width: none;
  }
}
/* =======================
   MODAL ELIMINAR CUENTA
======================= */

/* header en rojo */
.modal-header-danger {
  background: linear-gradient(135deg, #7f1d1d, #021d33) !important;
}

/* caja con borde rojo sutil */
.modal-box-danger {
  border: 1px solid rgba(239,68,68,0.2);
}

/* =======================
   ALERTA DE ADVERTENCIA
======================= */
.alerta-danger {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: rgba(239,68,68,0.06);
  border: 1px solid rgba(239,68,68,0.18);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 18px;
}

.alerta-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: bold;
  color: white;
  box-shadow: 0 6px 16px rgba(239,68,68,0.35);
}

.alerta-texto strong {
  display: block;
  font-size: 14px;
  color: #991b1b;
  margin-bottom: 4px;
}

.alerta-texto p {
  font-size: 13px;
  color: #64748b;
  line-height: 1.5;
  margin: 0;
}

/* =======================
   BOTÓN ELIMINAR (confirmar)
======================= */
.btn-eliminar-confirm {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  border: none;
  padding: 10px 20px;
  border-radius: 10px;
  color: white;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.25s;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-eliminar-confirm:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(239,68,68,0.4);
}

.btn-eliminar-confirm.loading {
  background: #94a3b8;
  cursor: not-allowed;
  position: relative;
}

.btn-eliminar-confirm.loading::after {
  content: "";
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-left: 4px;
}