/* Pillan360 · Tiempo Real operacional */
.realtime-brief {
  transition: border-color .25s ease, background-color .25s ease;
}

.realtime-brief[data-level="normal"] {
  border-left-color: rgb(16 185 129);
  background: linear-gradient(110deg, rgb(6 78 59 / .15), transparent 55%);
}

.realtime-brief[data-level="attention"] {
  border-left-color: rgb(245 158 11);
  background: linear-gradient(110deg, rgb(120 53 15 / .17), transparent 55%);
}

.realtime-brief[data-level="significant"] {
  border-left-color: rgb(239 68 68);
  background: linear-gradient(110deg, rgb(127 29 29 / .18), transparent 55%);
}

.realtime-brief[data-level="unavailable"] {
  border-left-color: rgb(100 116 139);
  background: linear-gradient(110deg, rgb(30 41 59 / .22), transparent 55%);
}

.realtime-brief[data-level="normal"] .realtime-level-badge,
.realtime-brief[data-level="normal"] .realtime-brief-icon {
  border-color: rgb(16 185 129 / .35);
  background: rgb(16 185 129 / .15);
  color: rgb(110 231 183);
}

.realtime-brief[data-level="attention"] .realtime-level-badge,
.realtime-brief[data-level="attention"] .realtime-brief-icon {
  border-color: rgb(245 158 11 / .35);
  background: rgb(245 158 11 / .15);
  color: rgb(252 211 77);
}

.realtime-brief[data-level="significant"] .realtime-level-badge,
.realtime-brief[data-level="significant"] .realtime-brief-icon {
  border-color: rgb(239 68 68 / .35);
  background: rgb(239 68 68 / .15);
  color: rgb(252 165 165);
}

.realtime-brief[data-level="unavailable"] .realtime-level-badge,
.realtime-brief[data-level="unavailable"] .realtime-brief-icon {
  border-color: rgb(100 116 139 / .4);
  background: rgb(100 116 139 / .15);
  color: rgb(203 213 225);
}

#now-pressure {
  color: rgb(167 139 250);
}

.realtime-brief-icon {
  width: 2.4rem;
  height: 2.4rem;
  flex: 0 0 2.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: .7rem;
  border: 1px solid currentColor;
}

.realtime-level-badge {
  display: inline-flex;
  align-items: center;
  border-width: 1px;
  border-radius: 999px;
  padding: .17rem .5rem;
  font-size: .5rem;
  line-height: 1;
  font-weight: 900;
  letter-spacing: .08em;
}

.realtime-source-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem;
  flex: 0 0 auto;
}

.realtime-meta-pill {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  border: 1px solid rgb(100 116 139 / .45);
  background: rgb(15 23 42 / .45);
  color: rgb(148 163 184);
  border-radius: 999px;
  padding: .3rem .5rem;
  font-size: .55rem;
  line-height: 1;
  white-space: nowrap;
}

.realtime-meta-pill.is-current {
  border-color: rgb(16 185 129 / .45);
  color: rgb(110 231 183);
}

.realtime-meta-pill.is-delayed {
  border-color: rgb(245 158 11 / .5);
  color: rgb(252 211 77);
}

.realtime-meta-pill.is-stale {
  border-color: rgb(239 68 68 / .5);
  color: rgb(252 165 165);
}

.realtime-refresh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  min-height: 1.7rem;
  border: 1px solid rgb(59 130 246 / .42);
  border-radius: 999px;
  padding: .28rem .55rem;
  background: rgb(30 64 175 / .2);
  color: rgb(147 197 253);
  font-size: .55rem;
  font-weight: 700;
  transition: background-color .2s ease, color .2s ease, opacity .2s ease;
}

.realtime-refresh-btn:hover {
  background: rgb(37 99 235 / .35);
  color: white;
}

.realtime-refresh-btn:disabled {
  cursor: wait;
  opacity: .58;
}

.realtime-kpi {
  min-height: 7.25rem;
}

.realtime-kpi-note {
  display: block;
  min-height: 1rem;
  margin-top: .25rem;
  color: var(--text-secondary, rgb(148 163 184));
  font-size: .58rem;
  line-height: 1.35;
}

.realtime-accumulation-panel {
  overflow: hidden;
}

.realtime-location-name {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  font-size: clamp(1.35rem, 2.3vw, 1.875rem);
  line-height: 1.12;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.realtime-accumulation-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.5rem;
}

.realtime-accumulation {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 4.25rem;
  border: 1px solid rgb(14 165 233 / .18);
  border-radius: .65rem;
  background: rgb(8 47 73 / .15);
  text-align: center;
}

.realtime-accumulation span {
  color: var(--text-secondary, rgb(148 163 184));
  font-size: .55rem;
  text-transform: uppercase;
}

.realtime-accumulation strong {
  margin-top: .2rem;
  color: rgb(103 232 249);
  font-size: 1.05rem;
}

@media (max-width: 767px) {
  .realtime-source-row {
    padding-left: 3.15rem;
  }

  .realtime-kpi {
    min-height: 6.4rem;
  }

  .realtime-accumulation-grid {
    gap: 0.3rem;
  }

  .realtime-accumulation {
    min-height: 3.8rem;
    padding: 0.25rem;
  }

  .realtime-accumulation span {
    font-size: 0.48rem;
  }

  .realtime-accumulation strong {
    font-size: clamp(0.68rem, 2.5vw, 0.9rem);
    white-space: nowrap;
  }
}

@media (max-width: 420px) {
  .realtime-source-row {
    padding-left: 0;
  }

  .realtime-meta-pill {
    flex: 1 1 auto;
    justify-content: center;
  }

  .realtime-refresh-btn {
    flex: 1 1 100%;
  }
}

/* Avisos de servicios externos en Tiempo Real. Mantienen al usuario en la pestaña activa. */
.realtime-external-alert {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: .9rem;
  margin-top: .9rem;
  padding: 1rem 2.5rem 1rem 1rem;
  overflow: hidden;
  border: 1px solid rgba(250, 204, 21, .42);
  border-radius: .9rem;
  background:
    radial-gradient(circle at 12% 20%, rgba(250, 204, 21, .16), transparent 35%),
    linear-gradient(145deg, rgba(30, 41, 59, .96), rgba(2, 6, 23, .96));
  box-shadow: 0 16px 38px rgba(0, 0, 0, .28);
}

.realtime-external-alert[data-kind="water"] {
  border-color: rgba(34, 211, 238, .46);
  background:
    radial-gradient(circle at 12% 20%, rgba(14, 165, 233, .2), transparent 35%),
    linear-gradient(145deg, rgba(15, 23, 42, .96), rgba(2, 6, 23, .96));
}

.realtime-external-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  border: 1px solid rgba(250, 204, 21, .48);
  border-radius: 999px;
  color: rgb(253, 224, 71);
  background: rgba(161, 98, 7, .24);
}

.realtime-external-alert[data-kind="water"] .realtime-external-icon {
  border-color: rgba(34, 211, 238, .48);
  color: rgb(103, 232, 249);
  background: rgba(8, 145, 178, .22);
}

.realtime-external-content { min-width: 0; }
.realtime-external-content h3 {
  margin: 0 0 .3rem;
  color: rgb(248, 250, 252);
  font-size: .9rem;
  font-weight: 900;
}
.realtime-external-content p {
  margin: 0;
  color: rgb(203, 213, 225);
  font-size: .68rem;
  line-height: 1.5;
}
.realtime-external-content small {
  display: block;
  margin-top: .55rem;
  color: rgb(148, 163, 184);
  font-size: .56rem;
  line-height: 1.4;
}

.realtime-external-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .45rem;
  margin-top: .7rem;
}

.realtime-external-open,
.realtime-water-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 2rem;
  padding: .48rem .72rem;
  border: 1px solid rgba(250, 204, 21, .55);
  border-radius: .55rem;
  color: rgb(255, 251, 235);
  background: rgba(161, 98, 7, .68);
  font-size: .62rem;
  font-weight: 900;
  text-decoration: none;
  transition: transform .18s ease, background-color .18s ease;
}
.realtime-external-open:hover,
.realtime-water-links a:hover {
  transform: translateY(-1px);
  background: rgba(202, 138, 4, .82);
}
.realtime-external-alert[data-kind="water"] .realtime-external-open,
.realtime-external-alert[data-kind="water"] .realtime-water-links a {
  border-color: rgba(34, 211, 238, .52);
  color: rgb(236, 254, 255);
  background: rgba(8, 145, 178, .7);
}
.realtime-external-alert[data-kind="water"] .realtime-external-open:hover,
.realtime-external-alert[data-kind="water"] .realtime-water-links a:hover {
  background: rgba(6, 182, 212, .78);
}
.realtime-water-links {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}

.realtime-external-close {
  position: absolute;
  top: .55rem;
  right: .55rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.8rem;
  height: 1.8rem;
  border: 1px solid rgba(148, 163, 184, .35);
  border-radius: .5rem;
  color: rgb(203, 213, 225);
  background: rgba(15, 23, 42, .7);
}
.realtime-external-close:hover { color: white; background: rgba(51, 65, 85, .9); }

.light-mode .realtime-external-alert {
  background: linear-gradient(145deg, rgba(255, 251, 235, .98), rgba(254, 249, 195, .92));
  box-shadow: 0 12px 28px rgba(15, 23, 42, .12);
}
.light-mode .realtime-external-alert[data-kind="water"] {
  background: linear-gradient(145deg, rgba(240, 249, 255, .98), rgba(207, 250, 254, .92));
}
.light-mode .realtime-external-content h3 { color: rgb(15, 23, 42); }
.light-mode .realtime-external-content p { color: rgb(51, 65, 85); }
.light-mode .realtime-external-content small { color: rgb(71, 85, 105); }
.light-mode .realtime-external-close { color: rgb(51, 65, 85); background: rgba(255, 255, 255, .72); }

@media (max-width: 640px) {
  .realtime-external-alert {
    grid-template-columns: 1fr;
    padding: 1rem 2.4rem 1rem 1rem;
    text-align: left;
  }
  .realtime-external-icon { width: 3rem; height: 3rem; }
  .realtime-external-actions,
  .realtime-water-links { width: 100%; }
  .realtime-external-open,
  .realtime-water-links a { flex: 1 1 auto; }
}

