:root {
  color-scheme: dark;
  --bg: #0d1117;
  --panel: #151b23;
  --panel-2: #1c2430;
  --text: #eef3f8;
  --muted: #9aa8b8;
  --line: #2a3442;
  --accent: #62a8ff;
  --normal: #29c174;
  --atencion: #f2c94c;
  --alerta: #f2994a;
  --critico: #eb5757;
  --shadow: 0 18px 60px rgba(0, 0, 0, .32);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(98, 168, 255, .14), transparent 32rem),
    linear-gradient(135deg, #0d1117 0%, #111820 48%, #171922 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 1.5rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--line);
  background: rgba(13, 17, 23, .86);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.eyebrow,
.section-label,
.muted,
.source {
  color: var(--muted);
}

.eyebrow,
.section-label {
  margin: 0 0 .3rem;
  font-size: .75rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.45rem, 3vw, 2.35rem);
}

h2 {
  margin-bottom: 1rem;
  font-size: 1.12rem;
}

.header-actions,
.panel-title-row {
  display: flex;
  align-items: center;
  gap: .8rem;
  flex-wrap: wrap;
}

.button {
  appearance: none;
  border: 1px solid rgba(98, 168, 255, .45);
  background: var(--accent);
  color: #06111f;
  border-radius: 8px;
  padding: .7rem .95rem;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
}

.button-ghost {
  background: transparent;
  color: var(--text);
}

.dashboard {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 1.25rem clamp(1rem, 4vw, 2.5rem) 3rem;
  display: grid;
  gap: 1rem;
}

.panel {
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(1rem, 2vw, 1.35rem);
  box-shadow: var(--shadow);
}

.executive {
  border-left: 4px solid var(--accent);
}

.executive p {
  margin-bottom: 0;
  color: #d8e2ee;
  font-size: 1.05rem;
  line-height: 1.65;
}

.areas-overview {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.15rem;
  align-items: center;
}

.areas-chart {
  min-height: 34rem;
  display: grid;
  grid-template-rows: 1fr auto;
  place-items: center;
  gap: .75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 1rem;
}

.donut-chart {
  width: min(100%, 34rem);
  height: auto;
  overflow: visible;
}

.chart-track {
  stroke: rgba(154, 168, 184, .16);
}

.chart-segment {
  filter: drop-shadow(0 0 8px color-mix(in srgb, currentColor 35%, transparent));
}

.chart-segment-bg {
  opacity: .98;
}

.chart-core {
  fill: #111820;
  stroke: var(--line);
  stroke-width: 1;
}

.donut-chart text {
  fill: var(--muted);
  font-size: .72rem;
  font-weight: 800;
}

.donut-chart .chart-area-label {
  fill: #d8e2ee;
  font-size: .86rem;
  paint-order: stroke;
  stroke: #0d1117;
  stroke-width: 5px;
  stroke-linejoin: round;
}

.donut-chart .chart-total {
  fill: var(--text);
  font-size: 3.15rem;
}

.donut-chart .chart-caption {
  fill: var(--muted);
  font-size: .95rem;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .45rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .35rem .55rem;
  color: var(--muted);
  font-size: .78rem;
}

.legend-item i {
  width: .55rem;
  height: .55rem;
  border-radius: 50%;
  background: var(--state);
  display: inline-block;
}

.areas-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(8rem, 1fr));
  gap: .75rem;
}

.area-pill {
  min-height: 7rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: .5rem;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 8px;
  padding: .85rem;
  background: var(--panel-2);
}

.area-pill strong {
  font-size: 1.05rem;
}

.area-pill small {
  color: var(--muted);
}

.normal { --state: var(--normal); }
.atencion { --state: var(--atencion); }
.alerta { --state: var(--alerta); }
.critico { --state: var(--critico); }

.area-pill,
.layer.recommended {
  border-left-color: var(--state);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-width: 5.8rem;
  justify-content: center;
  border: 1px solid color-mix(in srgb, var(--state) 74%, white);
  background: color-mix(in srgb, var(--state) 18%, transparent);
  color: color-mix(in srgb, var(--state) 78%, white);
  border-radius: 999px;
  padding: .35rem .65rem;
  font-weight: 800;
  font-size: .82rem;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

th,
td {
  padding: .9rem .8rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: .78rem;
  text-transform: uppercase;
}

td {
  line-height: 1.45;
}

.source {
  display: block;
  margin-top: .25rem;
  font-size: .78rem;
}

.filter,
input,
select {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f151d;
  color: var(--text);
  padding: .7rem .8rem;
}

.filter {
  margin-left: auto;
  width: min(20rem, 100%);
}

.global-alert {
  display: grid;
  grid-template-columns: 12rem 1fr;
  gap: 1.25rem;
  align-items: center;
}

.level-orb {
  width: 11rem;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  align-content: center;
  border: 2px solid var(--state);
  background: color-mix(in srgb, var(--state) 16%, var(--panel-2));
}

.level-orb span {
  color: var(--muted);
  font-size: .85rem;
}

.level-orb strong {
  font-size: 4.5rem;
  line-height: 1;
}

.global-copy h3 {
  margin: .75rem 0;
  font-size: 1.45rem;
}

ul {
  margin: 0;
  padding-left: 1.1rem;
}

li + li {
  margin-top: .35rem;
}

.layers {
  display: grid;
  gap: .75rem;
}

.layer {
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: .8rem 1rem;
}

.layer summary {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  font-weight: 800;
}

.layer summary::marker {
  color: var(--accent);
}

.layer p {
  color: #d6e0ea;
  margin: .8rem 0;
}

.notice {
  width: min(1440px, calc(100% - 2rem));
  margin: 1rem auto 0;
  border: 1px solid rgba(98, 168, 255, .35);
  border-radius: 8px;
  padding: .8rem 1rem;
  background: rgba(98, 168, 255, .12);
}

.admin-layout {
  max-width: 980px;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.login-panel {
  width: min(100%, 28rem);
}

.login-panel h1 {
  margin-bottom: 1.25rem;
}

.login-panel .notice {
  width: 100%;
  margin: 0 0 1rem;
}

.token-form,
.qual-form {
  display: grid;
  gap: .85rem;
}

.qual-row {
  border-left: 4px solid var(--state);
  padding: .95rem;
  border-radius: 8px;
  background: var(--panel-2);
  border-top: 1px solid var(--line);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.qual-controls {
  display: grid;
  grid-template-columns: 1.2fr 12rem 1.4fr;
  gap: .75rem;
  align-items: center;
}

.level-guide {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .6rem;
  margin-top: .85rem;
}

.guide-item {
  border: 1px solid color-mix(in srgb, var(--state) 45%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--state) 9%, #111820);
  padding: .72rem;
}

.guide-level {
  display: inline-flex;
  color: color-mix(in srgb, var(--state) 78%, white);
  font-weight: 850;
  font-size: .82rem;
  margin-bottom: .45rem;
}

.guide-item p {
  margin: 0;
  color: #d8e2ee;
  font-size: .84rem;
  line-height: 1.45;
}

@media (max-width: 1100px) {
  .areas-overview {
    grid-template-columns: 1fr;
  }

  .areas-grid {
    grid-template-columns: repeat(4, minmax(8rem, 1fr));
  }
}

@media (max-width: 760px) {
  .app-header,
  .global-alert,
  .qual-controls {
    grid-template-columns: 1fr;
  }

  .app-header {
    display: grid;
    position: static;
  }

  .areas-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .areas-chart {
    min-height: auto;
    padding: .75rem;
  }

  .donut-chart {
    width: min(100%, 27rem);
  }

  .donut-chart .chart-area-label {
    font-size: .74rem;
    stroke-width: 4px;
  }

  .global-alert {
    display: grid;
  }

  .level-orb {
    width: 8rem;
  }

  .level-orb strong {
    font-size: 3.2rem;
  }
}

@media (max-width: 900px) {
  .level-guide {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 460px) {
  .areas-grid {
    grid-template-columns: 1fr;
  }

  .level-guide {
    grid-template-columns: 1fr;
  }
}
