:root {
  color-scheme: light;
  --hist-bg: #f4f6f3;
  --hist-surface: #ffffff;
  --hist-soft: #f8faf6;
  --hist-line: #d9e1d5;
  --hist-line-strong: #c5d0c1;
  --hist-text: #17211b;
  --hist-muted: #657064;
  --hist-teal: #0a7a75;
  --hist-green: #2f7d46;
  --hist-amber: #b7741f;
  --hist-red: #b9443b;
  --hist-blue: #356c9b;
  --hist-shadow: 0 16px 38px rgba(31, 45, 36, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--hist-bg);
  color: var(--hist-text);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  letter-spacing: 0;
}

h2 {
  font-size: 17px;
  letter-spacing: 0;
}

.hist-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 82px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--hist-line);
  background: var(--hist-surface);
}

.hist-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.hist-brand-logo {
  display: block;
  flex: 0 0 auto;
  width: 112px;
  max-width: 26vw;
  height: auto;
}

.hist-eyebrow {
  color: var(--hist-teal);
  font-size: 11px;
  font-weight: 780;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hist-status {
  max-width: 460px;
  color: var(--hist-muted);
  text-align: right;
}

.hist-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 18px 28px 32px;
}

.hist-alert-list {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.hist-alert {
  border: 1px solid #e5c982;
  border-left: 5px solid var(--hist-amber);
  border-radius: 6px;
  background: #fff8e7;
  color: #553c0c;
  padding: 10px 12px;
  font-weight: 650;
}

.hist-note {
  border: 1px solid var(--hist-line);
  border-left: 5px solid var(--hist-blue);
  border-radius: 6px;
  background: #f4f8fb;
  color: #24435c;
  padding: 10px 12px;
  font-weight: 620;
}

.hist-filters {
  display: grid;
  grid-template-columns: 0.8fr 1.1fr 0.7fr 1.25fr 1.45fr 0.85fr 1fr;
  gap: 10px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--hist-line);
  border-radius: 8px;
  background: var(--hist-surface);
  box-shadow: var(--hist-shadow);
}

.hist-scope {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 12px 0 14px;
}

.hist-scope div {
  border: 1px solid var(--hist-line);
  border-radius: 8px;
  background: var(--hist-surface);
  padding: 12px 14px;
}

.hist-scope strong {
  display: block;
  margin-top: 3px;
  font-size: 13px;
  font-weight: 680;
}

label {
  display: grid;
  gap: 6px;
  color: var(--hist-muted);
  font-size: 11px;
  font-weight: 760;
  text-transform: uppercase;
}

select,
button {
  min-height: 38px;
  border: 1px solid var(--hist-line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--hist-text);
  padding: 0 10px;
  font: inherit;
}

button {
  background: var(--hist-teal);
  color: #fff;
  font-weight: 760;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

select:disabled {
  background: #eef1ec;
  color: #8a9388;
}

.hist-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.hist-kpis article,
.hist-panel {
  border: 1px solid var(--hist-line);
  border-radius: 8px;
  background: var(--hist-surface);
  box-shadow: var(--hist-shadow);
}

.hist-kpis article {
  display: grid;
  gap: 4px;
  min-height: 86px;
  padding: 14px;
}

.hist-kpis span {
  color: var(--hist-muted);
  font-size: 12px;
  font-weight: 720;
}

.hist-kpis strong {
  font-size: 22px;
}

.hist-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(380px, 0.9fr);
  gap: 14px;
}

.hist-panel {
  min-width: 0;
  padding: 14px;
}

.hist-chart-panel {
  border-radius: 10px;
  box-shadow: 0 8px 26px rgba(18, 45, 30, 0.07);
}

.hist-chart-panel .hist-panel-head {
  min-height: 42px;
  margin-bottom: 10px;
}

.hist-chart-panel .hist-panel-head h2 {
  font-size: 15px;
  line-height: 1.2;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.hist-chart-subtitle {
  margin-top: 3px;
  color: var(--hist-muted);
  font-size: 11px;
  font-weight: 400;
}

.hist-chart {
  width: 100%;
  height: 300px;
  min-height: 260px;
}

.hist-chart .hist-empty {
  display: grid;
  min-height: 260px;
  place-items: center;
}

.hist-map-panel {
  grid-row: span 2;
}

.hist-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.hist-context {
  margin: -4px 0 12px;
  color: var(--hist-muted);
  font-size: 12px;
  font-weight: 650;
}

.hist-pill {
  border: 1px solid var(--hist-line);
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--hist-muted);
  font-size: 12px;
}

.hist-map-placeholder {
  margin-top: 12px;
  min-height: 260px;
  border: 1px solid var(--hist-line);
  border-radius: 8px;
  background: var(--hist-soft);
  padding: 14px;
}

.hist-map-info-cards {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.hist-map-info-cards article {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  min-height: 76px;
  border: 1px solid var(--hist-line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.hist-map-info-cards article > span {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #e5f2ec;
  position: relative;
}

.hist-map-info-cards article > span::after {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: var(--hist-green);
}

.hist-map-info-cards div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.hist-map-info-cards em {
  color: var(--hist-muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 760;
  line-height: 1.15;
}

.hist-map-info-cards strong {
  min-width: 0;
  color: var(--hist-text);
  font-size: 18px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.hist-map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--hist-muted);
  font-size: 12px;
  font-weight: 650;
}

.hist-map-toolbar button {
  min-height: 32px;
  padding: 0 9px;
  background: #ffffff;
  color: var(--hist-teal);
}

.hist-map-stage {
  position: relative;
}

.hist-layer-control {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 650;
  display: flex;
  flex-direction: column;
  gap: 7px;
  align-items: flex-start;
  justify-content: center;
  padding: 8px 10px;
  border: 1px solid rgba(23, 33, 27, 0.16);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 22px rgba(23, 33, 27, 0.12);
  max-width: min(190px, calc(100% - 24px));
}

.hist-layer-control label {
  display: inline-flex;
  grid-template-columns: none;
  gap: 5px;
  align-items: center;
  color: var(--hist-text);
  font-size: 11px;
  font-weight: 400;
  text-transform: none;
}

.hist-layer-control input {
  margin: 0;
  accent-color: var(--hist-teal);
}

.hist-layer-control strong {
  width: 100%;
}

.hist-leaflet-map {
  height: 430px;
  min-height: 360px;
  border: 1px solid var(--hist-line-strong);
  border-radius: 8px;
  background: #e8ece5;
  overflow: hidden;
}

.hist-map-legend {
  position: absolute;
  left: 12px;
  bottom: 14px;
  z-index: 640;
  display: grid;
  gap: 6px;
  width: 178px;
  max-height: calc(100% - 72px);
  overflow: auto;
  padding: 12px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.06);
  color: var(--hist-muted);
  font-size: 11px;
}

.hist-layer-control strong,
.hist-map-legend strong,
.hist-map-legend em {
  color: var(--hist-text);
  font-style: normal;
}

.hist-layer-control strong,
.hist-map-legend strong {
  font-size: 13px;
  text-align: center;
}

.hist-map-legend em {
  margin-top: -4px;
  color: var(--hist-muted);
  font-size: 11px;
  font-weight: 760;
}

.hist-map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.hist-map-legend i {
  display: inline-block;
  flex: 0 0 auto;
  width: 18px;
  height: 13px;
  border: 1px solid rgba(23, 33, 27, 0.16);
  border-radius: 2px;
}

.hist-seat-symbol,
.hist-seat-legend {
  position: relative;
  display: inline-block;
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  border: 1px solid rgba(0, 0, 0, 0.6);
  border-radius: 50%;
  background: #fff;
}

.hist-seat-symbol::after,
.hist-seat-legend::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.8);
  transform: translate(-50%, -50%);
}

.hist-seat-icon {
  background: transparent;
  border: 0;
  z-index: 700 !important;
}

.hist-municipio-label,
.hist-leaflet-map .sede-label {
  color: #17211b;
  font-size: 8px;
  font-weight: 760;
  line-height: 1.1;
  pointer-events: none;
  text-align: center;
  white-space: normal;
  text-shadow: 0 0 2px #fff, 0 0 4px #fff;
}

.hist-leaflet-map .sede-label {
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.hist-leaflet-map .sede-label::before {
  display: none;
}

.sede-label-text {
  display: inline-block;
  line-height: 1.1;
  white-space: nowrap;
}

.sede-label-text--wrapped {
  display: inline-grid;
  gap: 1px;
  min-width: max-content;
  text-align: center;
  white-space: normal;
}

.hist-label-anchor {
  background: transparent;
  border: 0;
}

.hist-map-legend .hist-empty {
  padding: 8px 10px;
  text-align: left;
}

.hist-leaflet-map .leaflet-popup-content {
  margin: 10px 12px;
  line-height: 1.45;
}

.hist-map-bars,
.hist-series {
  display: grid;
  gap: 8px;
}

.hist-bar {
  display: grid;
  grid-template-columns: minmax(120px, 0.9fr) minmax(120px, 2fr) auto;
  gap: 10px;
  align-items: center;
}

.hist-bar em,
.hist-selected-badge {
  display: inline-block;
  margin-left: 6px;
  border-radius: 999px;
  background: #e6f3f1;
  color: var(--hist-teal);
  padding: 2px 6px;
  font-size: 11px;
  font-style: normal;
  font-weight: 760;
}

.hist-selected-row {
  background: #edf8f6;
  box-shadow: inset 4px 0 0 var(--hist-teal);
}

.hist-bar.hist-selected-row {
  border-radius: 6px;
  padding: 6px 8px;
}

.hist-selected-row .hist-bar-fill {
  background: var(--hist-teal);
}

.hist-ranking-button {
  border: 0;
  background: transparent;
  color: var(--hist-text);
  min-height: 0;
  padding: 0;
  text-align: left;
  font: inherit;
  font-weight: 680;
  cursor: pointer;
}

.hist-ranking-button:hover,
.hist-ranking-button:focus-visible {
  color: var(--hist-teal);
  text-decoration: underline;
  outline: none;
}

.hist-bar-track {
  height: 14px;
  border-radius: 999px;
  background: #e4ebe1;
  overflow: hidden;
}

.hist-bar-fill {
  height: 100%;
  background: var(--hist-green);
}

.hist-table-wrap {
  overflow: auto;
  max-height: 430px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: var(--hist-muted);
  font-size: 11px;
  text-transform: uppercase;
}

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

.hist-side-panel div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--hist-line);
  padding-bottom: 7px;
}

.hist-limit-panel {
  margin-top: 14px;
}

.hist-empty {
  width: 100%;
  border: 1px dashed var(--hist-line-strong);
  border-radius: 6px;
  background: var(--hist-soft);
  color: var(--hist-muted);
  padding: 12px;
  text-align: center;
}

td.hist-empty {
  display: table-cell;
}

@media (max-width: 1100px) {
  .hist-filters,
  .hist-scope,
  .hist-kpis,
  .hist-grid {
    grid-template-columns: 1fr 1fr;
  }

  .hist-map-panel {
    grid-row: auto;
  }

  .hist-map-info-cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .hist-chart {
    height: 290px;
  }
}

@media (max-width: 720px) {
  .hist-topbar,
  .hist-shell {
    padding-left: 14px;
    padding-right: 14px;
  }

  .hist-topbar,
  .hist-filters,
  .hist-scope,
  .hist-kpis,
  .hist-grid {
    grid-template-columns: 1fr;
  }

  .hist-topbar {
    display: grid;
  }

  .hist-brand {
    align-items: flex-start;
  }

  .hist-brand-logo {
    width: 92px;
    max-width: 34vw;
  }

  .hist-status {
    text-align: left;
  }

  .hist-layer-control {
    position: static;
    justify-content: flex-start;
    margin: 0 0 8px;
    width: 100%;
    max-width: none;
  }

  .hist-map-legend {
    left: 8px;
    bottom: 10px;
    width: 150px;
    max-height: 52%;
    font-size: 10px;
  }

  .hist-map-info-cards {
    grid-template-columns: 1fr 1fr;
  }
}

/* Executive Intelligence Command Center visual system */
:root {
  --hist-bg: #f1f5f9;
  --hist-surface: #ffffff;
  --hist-soft: #f8fafc;
  --hist-line: #e2e8f0;
  --hist-line-strong: #cbd5e1;
  --hist-text: #0f172a;
  --hist-muted: #64748b;
  --hist-teal: #0f766e;
  --hist-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

body {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

.hist-topbar {
  min-height: 96px;
  padding: 18px 30px;
  border-color: #e2e8f0;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
}

.hist-shell {
  padding-top: 20px;
}

.hist-alert,
.hist-note {
  border-radius: 10px;
}

.hist-filters {
  gap: 12px;
  padding: 16px;
  border-color: rgba(148, 163, 184, 0.24);
  border-radius: 12px;
}

.hist-scope div {
  border-color: rgba(148, 163, 184, 0.20);
  border-radius: 12px;
  padding: 13px 15px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.05);
}

select,
button {
  min-height: 42px;
  border-radius: 9px;
  padding: 0 12px;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.hist-filters label,
.hist-filters select {
  min-width: 0;
  width: 100%;
}

select:focus,
button:focus-visible {
  border-color: var(--hist-teal);
  outline: none;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.hist-kpis article,
.hist-panel {
  border-color: rgba(148, 163, 184, 0.20);
  border-radius: 12px;
}

.hist-kpis article {
  min-height: 96px;
  padding: 16px;
}

.hist-kpis span {
  color: #64748b;
  font-size: 11px;
  letter-spacing: 0.02em;
}

.hist-kpis strong {
  color: #064e3b;
  font-size: 25px;
  letter-spacing: -0.025em;
}

.hist-panel {
  padding: 16px;
}

.hist-panel-head h2 {
  color: #0f172a;
}

.hist-map-info-cards article {
  border-color: rgba(148, 163, 184, 0.24);
  border-radius: 10px;
  box-shadow: 0 5px 14px rgba(15, 23, 42, 0.04);
}

.hist-leaflet-map {
  border-color: #cbd5e1;
  border-radius: 12px;
  background: #e2e8f0;
}

.hist-map-toolbar button {
  border-color: #cbd5e1;
  background: #ffffff;
}

.hist-pill {
  border-color: #dbe4ee;
  background: #f8fafc;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: #64748b;
  letter-spacing: 0.025em;
}

tbody tr:nth-child(even) {
  background: rgba(248, 250, 252, 0.72);
}

tbody tr:hover {
  background: #ecfdf5;
}
