:root {
  --bg-app: #080c14;
  --bg-surface: #0f172a;
  --bg-card: #151e33;
  --border-subtle: #1e293b;
  --border-active: #38bdf8;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-cyan: #38bdf8;
  --accent-blue: #0284c7;
  --accent-green: #10b981;

  --font-main: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", Consolas, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-main);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  overflow-x: hidden;
}

/* Cabecera Fija */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  padding: calc(0.6rem + env(safe-area-inset-top)) 1rem 0.6rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-badge {
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  color: #ffffff;
  font-weight: 800;
  font-size: 0.75rem;
  padding: 0.35rem 0.55rem;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.35);
}

.header-titles {
  display: flex;
  flex-direction: column;
}

.header-title {
  font-size: 1rem;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.15;
}

.header-domain {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--accent-cyan);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.ws-pill {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  border: 1px solid transparent;
}

.ws-pill.connected {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-color: rgba(52, 211, 153, 0.3);
}

.ws-pill.disconnected {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.3);
}

.pulse-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: currentColor;
  box-shadow: 0 0 6px currentColor;
  animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
  0%, 100% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.35); opacity: 1; }
}

/* Barra de Resumen Global */
.summary-bar {
  display: flex;
  gap: 0.5rem;
  padding: 0.6rem 0.8rem;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
}

.summary-chip {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.chip-label {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.4px;
}

.chip-value {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 700;
  color: #ffffff;
}

.chip-value.highlight {
  color: var(--accent-cyan);
}

/* Contenido Principal y Cuadrícula General de Silos */
.main-content {
  padding: 0.75rem 0.8rem;
}

.silos-grid-general {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

@media (min-width: 768px) {
  .silos-grid-general {
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    max-width: 1400px;
    margin: 1rem auto;
  }
}

/* Tarjeta del Silo */
.silo-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 0.75rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.silo-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #0284c7, #38bdf8);
}

.silo-card-header {
  display: flex;
  justify-content: center;
  align-items: center;
}

.silo-card-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: #ffffff;
}

/* Gráfico Silo SVG */
.silo-card-graphic {
  height: 135px;
  display: flex;
  justify-content: center;
  align-items: center;
}

@media (min-width: 768px) {
  .silo-card-graphic {
    height: 200px;
  }
}

.silo-card-graphic svg {
  height: 100%;
  width: auto;
  max-width: 100%;
}

/* Lecturas Claras de Nivel y Capacidad */
.silo-data-box {
  background: rgba(8, 12, 20, 0.65);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.data-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.data-row.highlight {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 0.25rem;
}

.data-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
}

.data-val {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 1.05rem;
  color: #ffffff;
}

.data-val-cap {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* Barra de progreso */
.progress-track {
  width: 100%;
  height: 5px;
  background: #1e293b;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 2px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #0284c7, #38bdf8);
  border-radius: 999px;
  transition: width 0.6s ease;
}

/* Estado de Carga */
.loading-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 4rem 1rem;
  color: var(--text-secondary);
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
