@keyframes pulseActive {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
    background: rgba(255, 255, 255, 0.08);
  }

  50% {
    box-shadow: 0 0 8px 2px rgba(16, 185, 129, 0.8);
    background: rgba(16, 185, 129, 0.3);
    border-color: #10b981;
    color: #fff;
  }

  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    background: rgba(255, 255, 255, 0.08);
  }
}

@keyframes pulseBrain {
  0% {
    transform: scale(1);
    opacity: 1;
  }

  50% {
    transform: scale(1.3);
    opacity: 0.7;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100%);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  margin: 0;
  padding: 0;
  font-family: Inter, system-ui, sans-serif;
}

body,
html {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: #0f0c29;
  display: flex;
  flex-direction: column;
}

/* Pantallas */
.screen {
  display: none;
  height: 100%;
  width: 100%;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

/* Login */
#login-screen {
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at center, #1a1543 0%, #0f0c29 100%);
}

.login-card {
  background: rgba(15, 23, 42, 0.9);
  padding: 40px;
  border-radius: 12px;
  border: 1px solid #334155;
  text-align: center;
  width: 350px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
}

.brand {
  color: #60a5fa;
  font-weight: 900;
  font-size: 2rem;
  margin-bottom: 5px;
}

.subtitle {
  color: #94a3b8;
  margin-bottom: 25px;
  font-size: 0.9rem;
  letter-spacing: 1px;
  text-transform: uppercase;
}

input {
  width: 100%;
  padding: 12px;
  margin-bottom: 15px;
  background: #1e293b;
  border: 1px solid #475569;
  color: white;
  border-radius: 6px;
  outline: none;
}

input:focus {
  border-color: #3b82f6;
}

#btn-login {
  width: 100%;
  padding: 12px;
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 6px;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
}

#btn-login:hover {
  background: #1d4ed8;
}

.error-msg {
  color: #ef4444;
  margin-top: 15px;
  font-size: 0.85rem;
  min-height: 20px;
}

/* Top Bar */
.top-bar {
  background: rgba(15, 12, 41, 0.95);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: white;
  z-index: 100;
  flex-shrink: 0;
}

.top-bar-brand {
  font-weight: 900;
  font-size: 1.1rem;
  color: #60a5fa;
  display: flex;
  align-items: center;
  white-space: nowrap;
}

.status-badge {
  margin-left: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #60a5fa;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
  transition: all 0.2s;
}

.top-bar-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.btn-nav {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #e2e8f0;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.btn-danger {
  background: transparent;
  border: 1px solid #ef4444;
  color: #ef4444;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: bold;
  cursor: pointer;
}

.btn-danger:hover {
  background: #ef4444;
  color: white;
}

.btn-running {
  animation: pulseActive 2s infinite !important;
  pointer-events: none !important;
  opacity: 0.8;
  color: #10b981 !important;
  border-color: #10b981 !important;
}

/* Modales */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 15px;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: #ffffff;
  padding: 15px;
  border-radius: 12px;
  width: 100%;
  max-width: 650px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
  position: relative;
  overflow: hidden;
}

.modal-close {
  position: absolute;
  top: 5px;
  right: 15px;
  cursor: pointer;
  font-size: 2rem;
  color: #888;
  background: none;
  border: none;
  font-weight: bold;
  z-index: 10;
}

.modal-title {
  margin: 0 0 10px 0;
  color: #302b63;
  font-size: 1.1rem;
  border-bottom: 2px solid #eee;
  padding-bottom: 8px;
  flex-shrink: 0;
  font-weight: 900;
}

.modal-body {
  font-size: 0.9rem;
  color: #374151;
  line-height: 1.5;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Toasts */
#toast-container {
  position: fixed;
  bottom: 15px;
  right: 15px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 90%;
  max-width: 350px;
  pointer-events: none;
}

.toast-msg {
  background: rgba(15, 23, 42, 0.95);
  border-left: 4px solid #3b82f6;
  color: #fff;
  padding: 14px 35px 14px 16px;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
  animation: slideInRight 0.4s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
  pointer-events: auto;
  position: relative;
  width: 100%;
}

.toast-close {
  position: absolute;
  top: 12px;
  right: 12px;
  color: #94a3b8;
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  font-weight: bold;
  padding: 0 5px;
}

.toast-close:hover {
  color: #fff;
}

/* Grillas */
.list-container {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  height: 100%;
  gap: 0;
  padding-right: 2px;
}

.list-item {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1.5fr 2.5fr;
  gap: 2px;
  align-items: center;
  border-bottom: 1px solid #f1f5f9;
  padding: 3px 4px;
  font-size: 0.65rem;
  background: transparent;
  margin: 0;
}

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

.li-col-1,
.li-col-2,
.li-col-3,
.li-col-4 {
  white-space: nowrap;
  overflow: hidden;
  display: flex;
  align-items: center;
}

.li-col-2 {
  justify-content: flex-start;
}

.li-col-3,
.li-col-4 {
  justify-content: flex-end;
  font-family: monospace;
  font-weight: bold;
}

/* Radar */
.radar-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1vh;
  width: 100%;
  padding: 1vh;
  overflow-y: auto;
}

.radar-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 1vh;
  padding: 1vh;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  position: relative;
  transition: all 0.2s;
}

.radar-card.current {
  background: rgba(59, 130, 246, 0.08);
  border: 2px solid #3b82f6;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.3);
  transform: scale(1.02);
  z-index: 5;
}

.radar-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 900;
  font-size: 2vh;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 0.5vh;
  margin-bottom: 0.5vh;
}

.radar-card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.2vh;
  width: 100%;
}

.radar-card-row span:first-child {
  color: #64748b;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 1.4vh;
}

.radar-card-row span:last-child {
  font-family: monospace;
  font-weight: 800;
  font-size: 1.6vh;
}

/* Cards principales */
.container {
  flex: 1;
  width: 100%;
  padding: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.row {
  display: flex;
  flex-direction: row;
  width: 100%;
  flex: 1;
  min-height: 0;
  margin-bottom: 10px;
  align-items: stretch;
}

.row:last-child {
  margin-bottom: 0;
}

.card {
  background: #ffffff;
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
  flex: 1;
  margin-right: 10px;
  min-height: 0;
  overflow: hidden;
}

.card:last-child {
  margin-right: 0;
}

.card h2 {
  color: #667eea;
  font-size: 0.85rem;
  text-transform: uppercase;
  margin: 0 0 6px 0;
  border-bottom: 2px solid #f0f0f0;
  padding-bottom: 4px;
  font-weight: 800;
  flex-shrink: 0;
}

.chart-container {
  flex: 1;
  min-height: 0;
  background: #fdfdfd;
  border-radius: 8px;
  border: 1px solid #eee;
  position: relative;
  margin-right: 40px;
}

.y-axis-label {
  position: absolute;
  right: -40px;
  width: 35px;
  text-align: left;
  font-size: 0.65rem;
  font-weight: 800;
  color: #555;
  font-family: monospace;
}

.metric {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid #f5f5f5;
  font-size: 0.8rem;
  align-items: center;
}

.metric span:last-child {
  font-family: monospace;
  font-weight: 800;
  color: #111827;
  text-align: right;
}

.pos {
  color: #10b981 !important;
}

.neg {
  color: #ef4444 !important;
}

.brain-icon {
  animation: pulseBrain 1s infinite;
  display: inline-block;
}

/* Mobile */
@media (max-width: 1200px) {
  .radar-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

@media (max-width: 767px) {

  body,
  html {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    height: auto !important;
  }

  .hide-on-mobile {
    display: none !important;
  }

  .container {
    overflow-y: visible !important;
    padding: 8px !important;
    display: flex !important;
    flex-direction: column !important;
    height: auto !important;
    min-height: 100vh !important;
  }

  .row {
    flex-direction: column !important;
    margin-bottom: 0 !important;
    display: flex !important;
    flex: none !important;
    height: auto !important;
  }

  .card {
    width: 100% !important;
    margin-right: 0 !important;
    margin-bottom: 12px !important;
    display: flex !important;
    flex-direction: column !important;
    height: auto !important;
    max-height: none !important;
    min-height: min-content !important;
    overflow: visible !important;
    padding: 12px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    flex: none !important;
  }

  .top-bar {
    flex-direction: column !important;
    align-items: stretch !important;
    padding: 12px 10px !important;
  }

  .top-bar-controls {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    gap: 4px !important;
    width: 100% !important;
  }

  .chart-container {
    height: 180px !important;
    display: block !important;
    margin-bottom: 10px !important;
  }

  .radar-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 0.5vh !important;
    padding: 0.5vh !important;
    height: auto !important;
    overflow: hidden !important;
  }
}