:root {
  --navy: #10263a;
  --navy2: #173b58;
  --blue: #2166d1;
  --cyan: #13a8b5;
  --bg: #f2f5f8;
  --text: #17212b;
  --muted: #6e7c89;
  --line: #e1e7ec;
  --white: #fff;
  --shadow: 0 12px 34px rgba(16, 38, 58, 0.08);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}
button,
input {
  font: inherit;
}
.shell {
  display: grid;
  grid-template-columns: 245px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: linear-gradient(180deg, var(--navy), #0c1b2a);
  color: white;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  background: linear-gradient(135deg, #2d86ed, #11abb8);
}
.brand span {
  display: block;
  font-size: 10px;
  color: #9eb0bf;
  margin-top: 3px;
}
.sidebar nav {
  margin-top: 44px;
  display: grid;
  gap: 8px;
}
.sidebar nav button {
  border: 0;
  background: transparent;
  color: #aebdca;
  text-align: left;
  padding: 12px 14px;
  border-radius: 9px;
  cursor: pointer;
}
.sidebar nav button:hover,
.sidebar nav .nav-active {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
}
.sidebar-foot {
  margin-top: auto;
  font-size: 11px;
  color: #8fa3b3;
  line-height: 1.7;
}
.sidebar-foot strong {
  color: #d8e3eb;
}
main {
  padding: 32px 38px;
  min-width: 0;
}
header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 24px;
}
.eyebrow {
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.13em;
  margin: 0 0 8px;
}
h1 {
  font-size: 28px;
  margin: 0 0 6px;
}
header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.panel {
  background: white;
  border: 1px solid rgba(225, 231, 236, 0.9);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.filters {
  padding: 16px;
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
}
.field {
  display: grid;
  gap: 7px;
}
.field.grow {
  flex: 1;
  min-width: 180px;
}
.field label {
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.field input,
.table-search {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  min-width: 145px;
  outline: none;
}
.field input:focus,
.table-search:focus {
  border-color: #8bb8ef;
  box-shadow: 0 0 0 3px rgba(33, 102, 209, 0.1);
}
.btn-primary,
.btn-secondary {
  height: 40px;
  border-radius: 8px;
  padding: 0 17px;
  font-weight: 700;
  cursor: pointer;
}
.btn-primary {
  border: 0;
  background: var(--blue);
  color: #fff;
}
.btn-secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--navy);
}
.kpis {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin: 18px 0;
}
.kpi {
  padding: 18px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.kpi span {
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--muted);
}
.kpi strong {
  display: block;
  font-size: 23px;
  margin-top: 10px;
}
.kpi small {
  display: block;
  color: #8a98a5;
  margin-top: 6px;
}
.insight {
  padding: 17px 20px;
  display: flex;
  gap: 14px;
  align-items: center;
  border-left: 4px solid var(--cyan);
  margin-bottom: 18px;
}
.insight-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #e5f7f8;
  color: #128b95;
  display: grid;
  place-items: center;
}
.insight span {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 4px;
}
.insight strong {
  font-size: 14px;
}
.grid.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}
.chart-card,
.ranking,
.table-card {
  padding: 20px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 18px;
}
.card-head span {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0.06em;
}
.card-head h2 {
  font-size: 17px;
  margin: 4px 0 0;
}
.legend {
  font-size: 10px;
  font-weight: 800;
  padding: 5px 8px;
  border-radius: 99px;
}
.legend.money {
  background: #eaf2fe;
  color: #2365c4;
}
.legend.units {
  background: #e5f7f8;
  color: #138991;
}
.chart-card canvas {
  max-height: 310px;
}
.table-wrap {
  overflow: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
th {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  text-align: left;
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
}
td {
  padding: 13px 10px;
  border-bottom: 1px solid #edf1f4;
}
.num {
  text-align: right;
}
.rank {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #edf3fb;
  color: #2a65ad;
  display: grid;
  place-items: center;
  font-weight: 800;
}
.ranking-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid #edf1f4;
}
.ranking-row:last-child {
  border: 0;
}
.ranking-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
  font-weight: 600;
}
.ranking-value {
  text-align: right;
  font-size: 12px;
  font-weight: 800;
}
.bar {
  grid-column: 2/4;
  height: 4px;
  border-radius: 9px;
  background: #edf1f4;
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
  border-radius: 9px;
}
.alert {
  padding: 13px 16px;
  margin-top: 15px;
  border-radius: 9px;
  background: #fff2f1;
  color: #a03a31;
  border: 1px solid #f2d2cf;
}
.hidden {
  display: none !important;
}
.loader {
  position: fixed;
  inset: 0;
  background: rgba(12, 27, 42, 0.46);
  backdrop-filter: blur(3px);
  display: grid;
  place-content: center;
  color: #fff;
  z-index: 99;
  text-align: center;
  gap: 12px;
}
.loader div {
  width: 42px;
  height: 42px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: auto;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
footer {
  text-align: center;
  color: #8a98a5;
  font-size: 11px;
  padding: 25px;
}
@media (max-width: 1100px) {
  .kpis {
    grid-template-columns: repeat(3, 1fr);
  }
  .shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: none;
  }
  main {
    padding: 24px;
  }
  .grid.two {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 680px) {
  main {
    padding: 15px;
  }
  .kpis {
    grid-template-columns: 1fr 1fr;
  }
  .filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .field.grow {
    min-width: 0;
  }
  .btn-primary {
    grid-column: 1/-1;
  }
  header {
    align-items: center;
  }
  header h1 {
    font-size: 22px;
  }
  .btn-secondary {
    padding: 0 10px;
  }
  .table-search {
    width: 140px;
    min-width: 0;
  }
}

.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.status-ok {
  background: #eaf8f1;
  color: #137a4b;
}
.status-off {
  background: #f2f4f7;
  color: #667085;
}
.inactive-row {
  background: #fafbfc;
  color: #7a8794;
}
.inactive-row strong {
  color: #536170;
}
.detail-card {
  margin-top: 18px;
}
.brand-pill {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  background: #edf3fb;
  color: #244f83;
  font-weight: 700;
  white-space: nowrap;
}
.detail-card td {
  vertical-align: middle;
}
.detail-card table {
  min-width: 900px;
}
.table-card {
  margin-bottom: 18px;
}

/* =========================================================
   AUDITORÍA DE FUENTES
   ========================================================= */

.source-card {
  margin-top: 18px;
}

.source-card table {
  min-width: 1120px;
}

.source-validation-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.source-validation-ok {
  background: #eaf8f1;
  color: #137a4b;
  border: 1px solid #c9ead9;
}

.source-validation-warning {
  background: #fff6e5;
  color: #9a6500;
  border: 1px solid #f4d89d;
}

.source-validation-error {
  background: #fff0ef;
  color: #b42318;
  border: 1px solid #f2c7c3;
}

.source-validation-neutral {
  background: #f2f4f7;
  color: #667085;
  border: 1px solid #e1e6eb;
}

.source-validation-summary {
  display: grid;
  grid-template-columns:
    minmax(260px, 1.5fr)
    minmax(260px, 1fr)
    minmax(230px, auto);
  gap: 14px;
  align-items: center;
  margin-bottom: 18px;
  padding: 14px 16px;
  border-radius: 10px;
  background: #f7f9fb;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.source-validation-summary strong {
  color: var(--navy);
  font-size: 12px;
}

.source-validation-summary span {
  display: block;
}

.source-card code {
  display: inline-block;
  padding: 5px 8px;
  border-radius: 6px;
  background: #f2f5f8;
  color: #34495e;
  border: 1px solid #e3e8ed;
  font-family: Consolas, Monaco, 'Courier New', monospace;
  font-size: 11px;
  white-space: nowrap;
}

.status-error {
  background: #fff0ef;
  color: #b42318;
}

.source-error-row {
  background: #fffafa;
}

.source-error-row td {
  border-bottom-color: #f2d6d3;
}

.source-error-row strong,
.source-error-row code {
  color: #a1332b;
}

#sourceRows td {
  vertical-align: middle;
}

#sourceRows td:last-child {
  min-width: 145px;
}

#sourceRows tr:hover {
  background: #f8fafc;
}

@media (max-width: 1100px) {
  .source-validation-summary {
    grid-template-columns: 1fr 1fr;
  }

  .source-validation-summary strong {
    grid-column: 1 / -1;
  }
}

@media (max-width: 680px) {
  .source-validation-summary {
    grid-template-columns: 1fr;
  }

  .source-validation-summary strong {
    grid-column: auto;
  }

  .source-card .card-head {
    align-items: flex-start;
    flex-direction: column;
  }
}
