:root {
  color-scheme: dark;
  --bg: #0b1117;
  --bg2: #111b23;
  --panel: rgba(20, 31, 40, .86);
  --panel2: rgba(15, 23, 31, .94);
  --line: rgba(150, 186, 205, .20);
  --text: #eef7fb;
  --soft: #9fb4c1;
  --muted: #6f8795;
  --cyan: #18d9d2;
  --blue: #48a7ff;
  --green: #39f46b;
  --yellow: #ffe04a;
  --orange: #ff9f2e;
  --red: #ff3d42;
  --shadow: 0 24px 70px rgba(0, 0, 0, .42);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Arial, sans-serif;
  background:
    linear-gradient(115deg, rgba(36, 97, 83, .22), transparent 42%),
    linear-gradient(245deg, rgba(110, 67, 33, .18), transparent 44%),
    repeating-linear-gradient(90deg, rgba(255,255,255,.026) 0 1px, transparent 1px 96px),
    linear-gradient(135deg, #071019 0%, #121b1f 48%, #0a0d10 100%);
  color: var(--text);
}

.shell {
  width: min(1780px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.topbar,
.hero-grid,
.main-grid {
  margin-bottom: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 2px;
  font-size: 38px;
  line-height: 1;
}

h2 {
  margin-bottom: 4px;
  font-size: 18px;
}

.subtitle {
  margin-bottom: 0;
  color: var(--soft);
}

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sync {
  color: var(--soft);
  font-size: 13px;
}

.primary-button {
  height: 38px;
  border: 1px solid rgba(24, 217, 210, .55);
  border-radius: 8px;
  padding: 0 18px;
  color: #031417;
  font-weight: 800;
  background: linear-gradient(135deg, #3fffe8, #69a9ff);
  box-shadow: 0 10px 26px rgba(24, 217, 210, .20);
  cursor: pointer;
}

.primary-button:disabled {
  opacity: .65;
  cursor: wait;
}

.depth {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(26, 39, 50, .92), rgba(9, 16, 23, .94));
  box-shadow: var(--shadow), inset 1px 1px 0 rgba(255, 255, 255, .07);
}

.depth::before {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 12px;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(255, 255, 255, .08), transparent 38%);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1.4fr) repeat(3, minmax(180px, .62fr));
  gap: 14px;
}

.level-card,
.metric-card,
.chart-panel,
.references,
.alerts,
.table-panel {
  padding: 18px;
}

.card-head,
.panel-title {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.card-head span,
.metric-card span {
  color: var(--soft);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.card-head strong {
  color: var(--muted);
  font-size: 13px;
}

.level-wrap {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}

.level-value {
  font-size: 58px;
  line-height: .9;
  font-weight: 900;
  color: var(--cyan);
  text-shadow: 0 0 30px rgba(24, 217, 210, .32);
}

.level-badge {
  max-width: 270px;
  border: 1px solid rgba(24, 217, 210, .26);
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--cyan);
  background: rgba(24, 217, 210, .08);
  font-size: 12px;
  font-weight: 800;
  text-align: right;
}

.level-badge.badge-moderada {
  border-color: rgba(255, 224, 74, .5);
  color: var(--yellow);
  background: rgba(255, 224, 74, .12);
}

.level-badge.badge-alta {
  border-color: rgba(255, 159, 46, .55);
  color: var(--orange);
  background: rgba(255, 159, 46, .14);
}

.level-badge.badge-muito-alta {
  border-color: rgba(255, 61, 66, .6);
  color: var(--red);
  background: rgba(255, 61, 66, .16);
}

.level-badge.badge-critico {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  border-color: rgba(255, 61, 66, .75);
  color: var(--red);
  background: rgba(255, 61, 66, .18);
  animation: badge-critico-pulse 1s ease-in-out infinite;
}

.siren-dot {
  display: inline-block;
  flex: none;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  animation: siren-flash .6s steps(2, start) infinite;
}

@keyframes siren-flash {
  0% { background: #ff3d42; box-shadow: 0 0 8px #ff3d42, 0 0 16px rgba(255, 61, 66, .8); }
  50% { background: #2b6bff; box-shadow: 0 0 8px #2b6bff, 0 0 16px rgba(43, 107, 255, .8); }
}

@keyframes badge-critico-pulse {
  0%, 100% { box-shadow: 0 0 0 rgba(255, 61, 66, 0); }
  50% { box-shadow: 0 0 20px rgba(255, 61, 66, .5); }
}

.gauge {
  position: relative;
  height: 16px;
  margin: 22px 0 12px;
  border-radius: 999px;
  background: #13202a;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, .55);
  overflow: hidden;
}

.gauge-fill {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #156cff, #20e7e0, #28f45e, #ffec3f, #ff9c28, #ff3030);
}

.gauge-marker {
  position: absolute;
  top: -4px;
  width: 4px;
  height: 24px;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 0 14px rgba(255, 255, 255, .8);
}

.situation {
  margin-bottom: 0;
  color: var(--soft);
  font-size: 13px;
}

.metric-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(22, 34, 45, .78), rgba(12, 19, 27, .9));
  box-shadow: 0 16px 44px rgba(0, 0, 0, .28);
}

.metric-card strong {
  display: block;
  margin: 18px 0 6px;
  font-size: 26px;
}

.metric-card small {
  color: var(--muted);
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(720px, 1fr) 360px;
  gap: 14px;
}

.chart-panel {
  min-height: 570px;
}

.panel-title {
  align-items: start;
  margin-bottom: 12px;
}

.panel-title p {
  color: var(--soft);
  font-size: 13px;
  margin-bottom: 0;
}

.legend-mini {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 8px 14px;
  min-width: 260px;
  color: var(--soft);
  font-size: 12px;
}

.dot,
.line {
  display: inline-block;
  margin-right: 6px;
  vertical-align: middle;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.history {
  background: var(--cyan);
}

.line {
  width: 18px;
  border-top: 3px dashed currentColor;
}

.dry {
  color: #ffffff;
}

.wet {
  color: var(--red);
}

.chart-wrap {
  position: relative;
}

.chart {
  height: 485px;
  border: 1px solid rgba(150, 186, 205, .18);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(184, 248, 224, .08), rgba(255, 255, 255, .02));
  overflow: hidden;
}

.chart svg {
  width: 100%;
  height: 100%;
  display: block;
}

.chart-hit {
  cursor: pointer;
}

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  transform: translate(-50%, -100%);
  background: rgba(8, 16, 22, .94);
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 7px;
  padding: 7px 11px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
  white-space: nowrap;
  z-index: 5;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .4);
}

.chart-tooltip strong {
  color: var(--cyan);
  font-size: 14px;
}

.chart-tooltip span {
  color: var(--soft);
}

.side-panel {
  display: grid;
  gap: 14px;
}

.reference-list,
.alert-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.ref-row,
.alert-row {
  display: grid;
  grid-template-columns: 12px 64px 1fr;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  color: var(--soft);
  font-size: 12px;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 12px currentColor;
}

.ref-row-current {
  position: relative;
  margin: 2px 0;
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 8px;
  background: rgba(255, 255, 255, .08);
  color: var(--text);
  font-weight: 800;
  animation: current-pulse 2.2s ease-in-out infinite;
}

.ref-row-current strong {
  color: var(--text);
}

.ref-row-current span {
  color: var(--text);
}

.current-dot {
  width: 12px;
  height: 12px;
  animation: current-dot-pulse 1.6s ease-in-out infinite;
}

@keyframes current-pulse {
  0%, 100% { box-shadow: 0 0 0 rgba(255, 255, 255, 0); }
  50% { box-shadow: 0 0 18px rgba(255, 255, 255, .22); }
}

@keyframes current-dot-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.35); }
}

.alert-row {
  grid-template-columns: 22px 64px 1fr;
  font-weight: 800;
}

.alert-icon {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  color: #06120b;
  background: var(--green);
}

.table-panel {
  margin-bottom: 18px;
}

.compact {
  align-items: center;
}

.compact a {
  color: var(--cyan);
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
}

.table-wrap {
  max-height: 310px;
  overflow: auto;
  border: 1px solid rgba(150, 186, 205, .16);
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(150, 186, 205, .10);
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--soft);
  background: #111c25;
  font-size: 11px;
  text-transform: uppercase;
}

td {
  color: #dce9ef;
}

.error {
  color: #ffb3b5;
}

.warning {
  color: #ffe08a;
}

.diagnostic {
  margin: 12px 0 0;
  max-height: 130px;
  overflow: auto;
  border: 1px solid rgba(255, 224, 138, .24);
  border-radius: 8px;
  padding: 10px;
  color: #ffe08a;
  background: rgba(35, 25, 8, .58);
  font-size: 12px;
  white-space: pre-wrap;
}

.current-point-ring {
  transform-box: fill-box;
  transform-origin: center;
  animation: current-point-ping 1.8s ease-out infinite;
}

.current-point-dot {
  transform-box: fill-box;
  transform-origin: center;
  animation: current-point-pulse 1.8s ease-in-out infinite;
}

.current-point-label {
  paint-order: stroke;
  stroke: rgba(7, 16, 25, .85);
  stroke-width: 3px;
  stroke-linejoin: round;
}

@keyframes current-point-ping {
  0% { transform: scale(1); opacity: .85; }
  100% { transform: scale(2.8); opacity: 0; }
}

@keyframes current-point-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); }
}

.version-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 6px;
  padding: 10px;
  color: var(--muted);
  font-size: 12px;
}

.version-footer a {
  color: var(--cyan);
  text-decoration: none;
  font-weight: 800;
}

@media (max-width: 1120px) {
  .hero-grid,
  .main-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .panel-title,
  .level-wrap {
    align-items: start;
    flex-direction: column;
  }

  .legend-mini {
    justify-content: start;
  }

  .main-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .shell {
    padding: 12px;
  }

  h1 {
    font-size: 28px;
  }

  .level-value {
    font-size: 42px;
  }

  .level-badge {
    max-width: 100%;
    text-align: left;
  }

  .chart-panel {
    min-height: auto;
  }

  .chart {
    height: 320px;
  }

  .legend-mini {
    font-size: 11px;
    gap: 6px 10px;
  }

  .metric-card strong {
    font-size: 22px;
  }

  .ref-row,
  .alert-row {
    grid-template-columns: 12px 54px 1fr;
    font-size: 11px;
  }
}
