/* Estadísticas UAC — estilos propios (sin frameworks) */

:root {
  color-scheme: light;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --border: #e3e8ef;
  --text: #13233a;
  --text-2: #4c5a6e;
  --text-3: #6b778a;
  --brand: #0b3d78;
  --brand-2: #1565c0;
  --accent: #f5b800;
  --series-1: #1565c0;
  --grid: #e8ecf2;
  --focus: #1565c0;
  --danger-bg: #fdecec;
  --danger-text: #8a1c1c;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 32, 56, .06), 0 2px 8px rgba(16, 32, 56, .05);
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #101317;
    --surface: #1a1d22;
    --surface-2: #20242a;
    --border: #2c3139;
    --text: #eef1f5;
    --text-2: #c2c9d3;
    --text-3: #98a2b0;
    --brand: #e8eef7;
    --brand-2: #4a90e2;
    --series-1: #4a90e2;
    --grid: #2a2f37;
    --focus: #4a90e2;
    --danger-bg: #3a1f1f;
    --danger-text: #ffb4b4;
    --shadow: none;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101317;
  --surface: #1a1d22;
  --surface-2: #20242a;
  --border: #2c3139;
  --text: #eef1f5;
  --text-2: #c2c9d3;
  --text-3: #98a2b0;
  --brand: #e8eef7;
  --brand-2: #4a90e2;
  --series-1: #4a90e2;
  --grid: #2a2f37;
  --focus: #4a90e2;
  --danger-bg: #3a1f1f;
  --danger-text: #ffb4b4;
  --shadow: none;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}

h1, h2, p { margin: 0; }

.wrap {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 16px;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- Encabezado ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border-top: 4px solid var(--accent);
}
.topbar__inner {
  display: flex;
  align-items: center;
  gap: 20px;
  padding-top: 14px;
  padding-bottom: 14px;
}
.brand img { display: block; height: 48px; width: auto; }
.topbar__title { border-left: 1px solid var(--border); padding-left: 20px; }
.eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-3);
}
.topbar h1 { font-size: 22px; line-height: 1.25; color: var(--brand); font-weight: 700; }

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .brand {
    background: #ffffff; border-radius: 8px; padding: 4px 8px;
  }
}
:root[data-theme="dark"] .brand { background: #ffffff; border-radius: 8px; padding: 4px 8px; }

/* ---------- Selector de período ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin: 24px 0 16px;
}
.segmented {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
}
.segmented button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-weight: 600;
  padding: 6px 18px;
  border-radius: 999px;
  cursor: pointer;
  min-height: 36px;
}
.segmented button[aria-selected="true"] {
  background: var(--brand-2);
  color: #ffffff;
}
.toolbar__note { color: var(--text-3); font-size: 13px; }

/* ---------- Alerta de error ---------- */
.alert {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--danger-bg);
  color: var(--danger-text);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.alert[hidden] { display: none; }
.alert span { display: block; font-size: 14px; }
.btn {
  appearance: none;
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
}

/* ---------- Indicadores ---------- */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  min-width: 0;
}
.kpi[hidden] { display: none; }
.kpi__label { font-size: 13px; color: var(--text-2); font-weight: 600; }
.kpi__value { font-size: 32px; font-weight: 700; line-height: 1.2; margin-top: 6px; color: var(--text); }
.kpi__value--text {
  font-size: 17px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.6em;
}
.kpi__meta { font-size: 13px; color: var(--text-3); margin-top: 4px; }
.meter {
  height: 6px;
  background: var(--grid);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}
.meter span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--series-1);
  border-radius: 999px;
  transition: width .4s ease;
}

/* ---------- Paneles ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.panel__head { padding: 16px 18px 0; }
.panel__head h2 { font-size: 17px; font-weight: 700; }
.panel__sub { font-size: 13px; color: var(--text-3); }
.panel__body {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 24px;
  padding: 12px 18px 18px;
  align-items: start;
}
.chart { position: relative; width: 100%; min-height: 160px; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); }
.table thead th {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-3);
  background: var(--surface-2);
}
.table tbody tr:hover { background: var(--surface-2); }
.table tfoot td { font-weight: 700; border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; }
.table .muted { color: var(--text-3); }
.table .empty { color: var(--text-3); text-align: center; padding: 24px 10px; }

/* ---------- Estado de carga ---------- */
.is-loading .kpi__value,
.is-loading .table tbody,
.is-loading .chart { opacity: .45; transition: opacity .2s; }

/* ---------- Pie de página ---------- */
.footer { color: var(--text-3); font-size: 13px; padding: 8px 0 32px; }
.footer__inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; }

/* ---------- Responsivo ---------- */
@media (max-width: 960px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel__body { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) {
  .topbar__inner { flex-direction: column; align-items: flex-start; gap: 10px; }
  .topbar__title { border-left: 0; padding-left: 0; }
  .topbar h1 { font-size: 19px; }
  .kpis { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .kpi__value:not(.kpi__value--text) { font-size: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  .meter span { transition: none; }
}
