:root {
  --bg: #0f172a;
  --bg-card: #020617;
  --bg-card-soft: #020617;
  --border-subtle: #1e293b;
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.15);
  --accent-strong: #0ea5e9;
  --text-main: #e5e7eb;
  --text-muted: #9ca3af;
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.15);
  --ok: #22c55e;
  --ok-soft: rgba(34, 197, 94, 0.15);
  --warning: #eab308;
  --warning-soft: rgba(234, 179, 8, 0.15);
  --chip-bg: #020617;
  --chip-border: #1e293b;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, #1d283a, #020617);
  color: var(--text-main);
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Layout principal - AHORA A PANTALLA COMPLETA */
.main {
  width: 100%;
  max-width: none;           /* sin límite de ancho */
  margin: 16px 0 60px 0;     /* sin centrado horizontal */
  padding: 0 16px 32px;      /* algo de padding lateral */
}

/* Footer superior / inferior (reutilizado) */

.footer {
  width: 100%;
  padding: 10px 20px;
  background: radial-gradient(circle at top left, #020617, #020617);
  color: var(--text-muted);
  font-size: 0.8rem;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.3);
}

.footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.footer a:hover {
  text-decoration: underline;
}

.dot {
  font-size: 0.6rem;
}

/* Cards */

.card {
  background: radial-gradient(
      circle at top left,
      rgba(56, 189, 248, 0.08),
      transparent
    ),
    radial-gradient(circle at bottom right, rgba(15, 23, 42, 0.9), #020617);
  border-radius: 18px;
  padding: 20px;
  margin-bottom: 20px;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.7);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at top right,
    rgba(56, 189, 248, 0.12),
    transparent
  );
  opacity: 0.7;
  pointer-events: none;
}

.card > * {
  position: relative;
  z-index: 1;
}

.card h2 {
  margin: 0 0 16px;
  font-size: 1.2rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Header-status */

.header-status {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 12px 16px;
  flex-wrap: wrap;
}

/* Badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  border: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.85);
}

.badge-ok {
  border-color: rgba(34, 197, 94, 0.7);
  background: rgba(34, 197, 94, 0.1);
  color: #bbf7d0;
}

.badge-warn {
  border-color: rgba(234, 179, 8, 0.7);
  background: rgba(234, 179, 8, 0.12);
  color: #facc15;
}

.badge-danger {
  border-color: rgba(239, 68, 68, 0.7);
  background: rgba(239, 68, 68, 0.12);
  color: #fecaca;
}

.badge-gray {
  border-color: rgba(148, 163, 184, 0.7);
  background: rgba(15, 23, 42, 0.8);
  color: var(--text-muted);
}

/* Botones */

.btn {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: linear-gradient(135deg, #1e293b, #020617);
  color: var(--text-main);
  padding: 6px 14px;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s ease-out;
}

.btn:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.2);
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Grid */

.grid {
  display: grid;
  gap: 16px;
}

.grid-4 {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

/* Métricas */

.metric {
  padding: 14px 14px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.9), #020617);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
}

.metric-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.metric-value {
  font-size: 1.6rem;
  font-weight: 600;
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.metric-unit {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Alarmas */

.alarm-item {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.85), #020617);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
}

.alarm-label {
  font-size: 0.85rem;
  margin-bottom: 6px;
  color: var(--text-main);
}

/* Info filas */

.info-row {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}

.info-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.info-value {
  font-size: 0.9rem;
  font-weight: 500;
}

/* Log */

.log {
  background: rgba(2, 6, 23, 0.95);
  padding: 10px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.78rem;
  max-height: 260px;
  overflow-y: auto;
  color: #e5e7eb;
}

.log-entry {
  margin-bottom: 4px;
}

.log-entry-time {
  color: var(--accent);
  margin-right: 6px;
}

/* Chart wrapper - MÁS ALTO PARA APROVECHAR PANTALLA */
.chart-wrapper {
  width: 100%;
  height: 380px;   /* subido desde ~280px */
}

/* Responsive */

@media (max-width: 768px) {
  .main {
    padding: 0 10px 24px;
  }

  .card {
    padding: 16px;
  }

  .metric-value {
    font-size: 1.4rem;
  }

  .info-row {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .header-status {
    flex-direction: column;
    align-items: stretch;
  }

  .header-status .btn,
  .header-status .badge {
    width: 100%;
    justify-content: center;
  }
}
