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

body { 
  font-family: system-ui, sans-serif; 
  background: #f5f5f5; 
  height: 100dvh;
  display: flex; 
  flex-direction: column;
  overflow: hidden;
}

#header { 
  background: #000000; 
  padding: 20px 20px;
  display: flex; 
  align-items: center; 
  justify-content: space-between;
  flex-shrink: 0;
  min-height: 80px;
}

#header h1 { 
  font-size: 28px; 
  line-height: 1;
  display: flex;
  align-items: baseline;
  gap: 2px;
}

#header h1 .agentias {
  font-family: 'Roboto', sans-serif;
  font-weight: 700;
  color: #e8dcc8;
  font-size: 28px;
  letter-spacing: 2px;
  position: relative;
  overflow: hidden;
}

#header h1 .agentias .ia {
  color: white;
}

#header h1 .agentias::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(
    120deg,
    transparent 0%,
    rgba(255,255,255,0.4) 50%,
    transparent 100%
  );
  animation: reflejo 7s ease-in-out infinite;
}

@keyframes reflejo {
  0% { left: -100%; }
  50% { left: 150%; }
  100% { left: 150%; }
}

#vendedor-nombre { 
  font-size: 12px; 
  color: #888;
  font-family: 'Roboto', sans-serif;
  letter-spacing: 1px;
  text-transform: uppercase;
}

#chat { 
  flex: 1; 
  overflow-y: auto; 
  padding: 16px;
  display: flex; 
  flex-direction: column; 
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}

.mensaje { 
  max-width: 85%;
  padding: 10px 14px; 
  border-radius: 16px; 
  font-size: 14px; 
  line-height: 1.5;
}

.mensaje.usuario { 
  background: #1a1a2e; 
  color: white; 
  align-self: flex-end; 
  border-radius: 16px 16px 4px 16px; 
}

.mensaje.agente { 
  background: white; 
  color: #333; 
  align-self: flex-start; 
  border-radius: 16px 16px 16px 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  max-width: 90%;
}

.mensaje.agente table { 
  width: 100%; 
  border-collapse: collapse; 
  margin: 8px 0;
  font-size: 12px;
}

.mensaje.agente th, 
.mensaje.agente td { 
  padding: 6px 8px; 
  border: 1px solid #eee; 
  text-align: left;
}

.mensaje.agente th { background: #f9f9f9; font-weight: 600; }

#input-area { 
  padding: 10px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: white; 
  border-top: 1px solid #eee; 
  display: flex; 
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

#input { 
  flex: 1; 
  padding: 10px 14px; 
  border: 1px solid #ddd; 
  border-radius: 20px; 
  font-size: 15px;
  outline: none;
  background: #f9f9f9;
}

#input:focus { border-color: #1a1a2e; background: white; }

#enviar { 
  width: 40px;
  height: 40px;
  background: #1a1a2e; 
  color: white; 
  border: none; 
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#enviar:disabled { background: #ccc; cursor: not-allowed; }

.cargando { 
  color: #aaa; 
  font-size: 13px; 
  align-self: flex-start; 
  padding: 8px 4px;
}

/* Desktop */
@media (min-width: 600px) {
  body { max-width: 480px; margin: 0 auto; box-shadow: 0 0 40px rgba(0,0,0,0.1); }
}

.widget-ranking {
  background: var(--color-background-primary);
  border-radius: 16px 16px 16px 4px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  width: 95%;
  align-self: flex-start;
  border-left: none;
}

.widget-titulo {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #1D9E75;
  margin-bottom: 20px;
  font-weight: 600;
}

.widget-subtitulo {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--color-text-secondary);
  margin: 24px 0 12px;
  font-weight: 500;
}

.ranking-fila {
  padding: 10px 12px;
  border: 0.5px solid transparent;
  border-radius: 8px;
  margin-bottom: 6px;
}

.ranking-fila.yo {
  background: var(--color-background-secondary);
  border-color: var(--color-border-secondary);
  cursor: pointer;
}

.ranking-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.ranking-pos {
  font-size: 13px;
  min-width: 20px;
  text-align: center;
  color: var(--color-text-secondary);
}

.ranking-pos.p1 { font-size: 16px; color: var(--color-text-primary); }

.ranking-nombre {
  flex: 1;
  font-size: 14px;
  color: var(--color-text-primary);
}

.ranking-nombre.yo { font-weight: 500; }

.ranking-tag {
  font-size: 11px;
  color: var(--color-text-secondary);
  margin-left: 6px;
}

.ranking-importe {
  font-size: 14px;
  color: var(--color-text-primary);
  min-width: 60px;
  text-align: right;
}

.ranking-importe.yo { font-weight: 500; }

.ranking-chevron {
  font-size: 16px;
  color: var(--color-text-secondary);
}

.ranking-ver {
  font-size: 11px;
  color: var(--color-text-secondary);
  margin: 8px 0 0;
  text-align: right;
}

.ranking-barra-wrap {
  height: 3px;
  background: var(--color-background-secondary);
  border-radius: 2px;
  overflow: hidden;
}

.ranking-fila.yo .ranking-barra-wrap {
  background: var(--color-background-primary);
}

.ranking-barra {
  height: 100%;
  border-radius: 2px;
  width: 0%;
  transition: width 0.9s cubic-bezier(0.4, 0, 0.2, 1);
}

.ranking-meta {
  margin-top: 16px;
  background: var(--color-background-secondary);
  border-radius: 8px;
  padding: 12px 14px;
}

.ranking-meta-label {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin: 0 0 2px;
}

.ranking-meta-valor {
  font-size: 18px;
  font-weight: 500;
  color: var(--color-text-primary);
  margin: 0;
}

.ranking-consejo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--color-background-primary);
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 8px;
}

.ranking-consejo-texto { flex: 1; }

.ranking-consejo-titulo {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-primary);
  margin: 0 0 2px;
}

.ranking-consejo-desc {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin: 0;
}

.cargando-msg {
  padding: 12px 16px;
}

@keyframes parpadeo {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 1; }
}

.puntos {
  animation: parpadeo 1.2s ease-in-out infinite;
  color: #aaa;
  font-size: 18px;
  letter-spacing: 2px;
}

#acciones-rapidas {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  background: white;
  border-top: 0.5px solid #eee;
  overflow-x: auto;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

#acciones-rapidas::-webkit-scrollbar { display: none; }

.accion-rapida {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 16px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  flex: 1;
}

.accion-rapida i { font-size: 18px; color: white; }
.accion-rapida span { font-size: 11px; color: rgba(255,255,255,0.9); }

.accion-rapida.reservas { background: linear-gradient(135deg, #378ADD, #2563b0); }
.accion-rapida.ranking { background: linear-gradient(135deg, #1D9E75, #147a58); }
.accion-rapida.comisiones { background: linear-gradient(135deg, #F5A623, #c47c00); }
.accion-rapida.desafios { background: linear-gradient(135deg, #6366F1, #4338ca); }

.res-card {
  background: #fffdf9;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  border-left: 3px solid #378ADD;
  overflow: hidden;
}

.ranking-fila {
  background: #fffdf9;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  border-left: 3px solid #e0e0e0;
}

.ranking-fila.p1 {
  border-left: 3px solid #1D9E75;
}

.ranking-fila.yo {
  border-left: 3px solid transparent;
  border-image: linear-gradient(to bottom, #FFE066, #C8860A, #FFE066) 1;
}

.ranking-barra.yo {
  background: linear-gradient(90deg, #C8860A, #FFE066, #C8860A);
  background-size: 200% 100%;
  animation: reflejo-barra 3s ease-in-out infinite;
}

@keyframes reflejo-barra {
  0% { background-position: 100% 0; }
  50% { background-position: 0% 0; }
  100% { background-position: 100% 0; }
}

body::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url('img/tile-fondo.png');
  background-size: 250px 250px;
  background-repeat: repeat;
  opacity: 0.4;
  pointer-events: none;
  z-index: 0;
}

body {
  position: relative;
}

#header, #chat, #acciones-rapidas, #input-area {
  position: relative;
  z-index: 1;
}

.widget-ranking, .res-card, .ranking-fila {
  position: relative;
  z-index: 1;
  background-color: #fffdf9;
}

#login-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100dvh;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

#login-box {
  width: 85%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

#login-box input,
#login-btn {
  width: 100%;
}

#login-logo {
  margin-bottom: 8px;
}

#login-box .agentias {
  font-family: 'Roboto', sans-serif;
  font-weight: 700;
  color: #e8dcc8;
  font-size: 28px;
  letter-spacing: 2px;
  margin-bottom: 8px;
}

#login-box .agentias .ia {
  color: white;
}

#login-box h1 {
  text-align: center;
  margin-bottom: 12px;
}

#login-box input {
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid #333;
  background: #1a1a1a;
  color: white;
  font-size: 15px;
  outline: none;
}

#login-box input:focus {
  border-color: #F93822;
}

#login-box input::placeholder {
  color: #777;
}

#login-btn {
  padding: 14px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #F93822, #c42200);
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
  transition: background 0.3s, opacity 0.3s;
}

#login-btn:disabled {
  background: #444;
  cursor: not-allowed;
  opacity: 0.6;
}

#login-error {
  color: #ff6b6b;
  font-size: 13px;
  text-align: center;
  min-height: 18px;
  margin: 0;
}

@media (min-width: 600px) {
  #login-screen {
    max-width: 480px;
    left: 50%;
    transform: translateX(-50%);
  }
}

.accion-rapida:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
#login-particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  display: none;
}

#login-isotipo {
  position: fixed;
  inset: 0;
  background: #111;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}