:root {
  --bg: #ffffff;
  --bg-2: #f8fbff;
  --panel: #ffffff;
  --panel-strong: #ffffff;
  --line: #dbe5f0;
  --line-soft: #edf2f7;
  --text: #0f172a;
  --muted: #475569;
  --blue: #4da3ff;
  --cyan: #6bc1ff;
  --green: #8fe388;
  --gold: #f7d44c;
  --purple: #b8a7ff;
  --red: #ff5c5c;
  --emcali-yellow: #f7d44c;
  --emcali-red: #ef2b2d;
  --emcali-gold: #ffd94a;
  --shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
  --radius: 24px;
  --radius-sm: 16px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: #ffffff;
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  color: var(--text);
  background: #ffffff;
  height: 100%;
  overflow: hidden;
}

.sidebar {
  height: 100vh;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: #ffffff;
  position: relative;
  align-self: stretch;
  scrollbar-width: thin;
  scrollbar-color: #b9c9da #ffffff;
}

.app-shell {
  height: 100vh;
  min-height: 0;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  background: #ffffff;
  overflow: hidden;
}


.sidebar::-webkit-scrollbar {
  width: 8px;
}

.sidebar::-webkit-scrollbar-track {
  background: #ffffff;
}

.sidebar::-webkit-scrollbar-thumb {
  background: #c7d6e6;
  border-radius: 999px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: #9fb7d0;
}

.main-content {
  height: 100vh;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px;
  background: #ffffff;
  min-width: 0;
  scrollbar-width: thin;
  scrollbar-color: #c7d6e6 #ffffff;
}

.tab-panel {
  display: none;
  background: transparent;
  min-height: 0;
}

.tab-panel.active {
  display: block;
  min-height: 0;
}
.main-content::-webkit-scrollbar {
  width: 10px;
}

.main-content::-webkit-scrollbar-track {
  background: #ffffff;
}

.main-content::-webkit-scrollbar-thumb {
  background: #c7d6e6;
  border-radius: 999px;
}

.main-content::-webkit-scrollbar-thumb:hover {
  background: #9fb7d0;
}

button,
select,
input {
  font: inherit;
}


.glass,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}



.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.brand-row h1,
.hero h2,
.section-head h2,
.card-head h3,
.station-header h3,
.compare-header h3,
.panel h2 {
  margin: 0;
  color: #0b1f35;
}

.brand-row p,
.section-head p,
.card-head p,
.hero-copy,
.file-meta,
.status-box,
.station-header p,
.compare-header p,
.logic-list,
.meta-list {
  color: var(--muted);
}

.panel {
  padding: 18px;
  margin-bottom: 16px;
}

.hero {
  position: relative;
  overflow: hidden;
  padding: 22px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  background: linear-gradient(180deg, #ffffff, #f9fcff);
  border: 1px solid #dbe5f0;
}

.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: var(--radius);
  background: linear-gradient(90deg, rgba(77,163,255,0.04) 0%, rgba(247,212,76,0.04) 55%, rgba(239,43,45,0.03) 100%);
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: 12px;
  color: #1d4ed8;
  font-weight: 700;
}

.hero-copy {
  max-width: 880px;
  line-height: 1.55;
  margin: 8px 0 0;
}

.hero-side {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  min-width: 340px;
}

.hero-box {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
  background: #ffffff;
}

.hero-box span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.hero-box strong {
  font-size: 18px;
  color: #0f172a;
}

.hero-brand-card {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 16px 18px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: #ffffff;
}

.hero-brand-card img {
  width: 72px;
  height: 72px;
  object-fit: contain;
}

.hero-brand-card strong {
  display: block;
  font-size: 18px;
  margin: 4px 0;
  color: #0f172a;
}

.hero-brand-card small,
.hero-brand-kicker {
  color: var(--muted);
  display: block;
}

.hero-brand-kicker {
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 11px;
  color: #b45309;
  font-weight: 700;
}

.hero-status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.section-head,
.card-head,
.with-right {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.with-right {
  align-items: center;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border-radius: 999px;
  background: #f8fbff;
  border: 1px solid var(--line);
  color: #334155;
  font-size: 12px;
  font-weight: 600;
}

.chip-ok {
  color: #166534;
}

.dropzone {
  margin-top: 12px;
  min-height: 150px;
  border-radius: 20px;
  border: 1px dashed #cbd5e1;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
  text-align: center;
  padding: 18px;
  cursor: pointer;
  transition: .2s ease;
}

.dropzone.dragover,
.dropzone:hover {
  transform: translateY(-1px);
  border-color: var(--blue);
  background: #f7fbff;
}

.dropzone-icon {
  font-size: 30px;
}

.file-meta {
  font-size: 13px;
}

.status-box {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #ffffff;
  font-size: 13px;
  line-height: 1.45;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.field label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.field select,
.table-toolbar input {
  width: 100%;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
  border-radius: 14px;
  padding: 12px 14px;
  outline: none;
}

.field select:focus,
.table-toolbar input:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(77, 163, 255, 0.12);
}

.table-toolbar input::placeholder {
  color: #94a3b8;
}

option {
  color: #0f172a;
  background: #ffffff;
}

.stack {
  display: grid;
  gap: 10px;
}

.stack.two {
  grid-template-columns: 1fr 1fr;
}

.mt-10 {
  margin-top: 10px;
}

.mt-12 {
  margin-top: 12px;
}

.mt-14 {
  margin-top: 14px;
}

.mt-18 {
  margin-top: 18px;
}

.gap-sm {
  gap: 10px;
}

.btn {
  border: none;
  border-radius: 14px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 700;
  color: white;
  transition: .2s ease;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(135deg, var(--blue), #255dff);
  box-shadow: 0 8px 18px rgba(37, 93, 255, 0.20);
}

.btn-soft {
  background: #ffffff;
  border: 1px solid var(--line);
  box-shadow: none;
  color: #0f172a;
}

.action-buttons {
  display: grid;
  gap: 10px;
}

.action-buttons .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.meta-list,
.logic-list {
  padding-left: 18px;
  margin: 10px 0 0;
  display: grid;
  gap: 8px;
  line-height: 1.45;
}

.meta-list strong {
  color: var(--text);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi-grid-extended {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.kpi-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 148px;
  padding: 16px 16px 14px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.kpi-card::before {
  content: '';
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 4px;
  background: var(--blue);
}

.kpi-blue::before {
  background: linear-gradient(90deg, #4da3ff, #78d1ff);
}

.kpi-cyan::before {
  background: linear-gradient(90deg, #55d2ff, #75e4ff);
}

.kpi-green::before {
  background: linear-gradient(90deg, #8fe388, #b7f05f);
}

.kpi-gold::before {
  background: linear-gradient(90deg, #f7d44c, #ffe07f);
}

.kpi-purple::before {
  background: linear-gradient(90deg, #b8a7ff, #dfc6ff);
}

.kpi-red::before {
  background: linear-gradient(90deg, #ef2b2d, #ff6a6a);
}

.kpi-card span,
.compare-card span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  min-height: 20px;
  font-weight: 600;
}

.kpi-card strong,
.compare-card strong {
  display: block;
  margin: 10px 0 6px;
  font-size: clamp(18px, 1.45vw, 28px);
  line-height: 1.05;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-variant-numeric: tabular-nums;
  color: #0f172a;
}

.kpi-card small,
.compare-card small {
  color: var(--muted);
  display: block;
  line-height: 1.35;
}

.tabs-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.tab-btn {
  border: 1px solid var(--line);
  background: #ffffff;
  color: #334155;
  border-radius: 999px;
  padding: 11px 16px;
  cursor: pointer;
  font-weight: 700;
}

.tab-btn.active {
  color: #0b2a4a;
  background: #eef6ff;
  border-color: #bfdbfe;
}

.tab-panel {
  display: none;
  background: transparent;
}

.tab-panel.active {
  display: block;
}

.charts-grid {
  display: grid;
  gap: 16px;
}

.charts-grid.two-col {
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
}

.span-2 {
  grid-column: 1 / -1;
}

.chart-card {
  padding: 18px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.chart-wrap {
  position: relative;
  min-height: 320px;
  margin-top: 12px;
  background: #ffffff;
}

.chart-wrap.large {
  min-height: 380px;
}

.chart-wrap canvas {
  background: #ffffff;
  border-radius: 12px;
}

.heatmap-wrap {
  margin-top: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  max-width: 100%;
  background: #ffffff;
  min-height: 260px;
}

.heatmap-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1100px;
  background: #ffffff;
}

.heatmap-table th,
.heatmap-table td {
  padding: 10px 8px;
  text-align: center;
  border-bottom: 1px solid var(--line-soft);
  border-right: 1px solid var(--line-soft);
  white-space: nowrap;
  font-size: 12px;
  color: #0f172a;
}

.heatmap-table th {
  background: #f8fbff;
  color: #0f172a;
  font-weight: 700;
}

.heatmap-table th:first-child,
.heatmap-table td:first-child {
  position: sticky;
  left: 0;
  background: #f8fbff;
  text-align: left;
  z-index: 1;
  font-weight: 700;
}

.heatmap-empty {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.insights-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 12px;
}

.insights-panel {
  background: #ffffff;
}

.insight-card {
  border-radius: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  background: #ffffff;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.04);
}

.insight-card h4 {
  margin: 0 0 8px;
  font-size: 15px;
  color: #0f2742;
}

.insight-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 14px;
}

.station-header,
.compare-header {
  padding: 18px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.station-mini-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 12px;
}

.station-mini-grid-wide {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.mini-stat {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #ffffff;
  padding: 14px;
}

.mini-stat span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 600;
}

.mini-stat strong {
  display: block;
  margin-top: 8px;
  font-size: 20px;
  color: #0f172a;
}

.compare-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-content: flex-start;
}

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

.compare-grid-extended {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.compare-card {
  padding: 18px;
  border-radius: var(--radius-sm);
  background: #ffffff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.delta-up {
  color: #15803d !important;
}

.delta-down {
  color: #dc2626 !important;
}

.delta-flat {
  color: #b45309 !important;
}


.table-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 360px;
}

.data-panel {
  padding: 18px;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 220px);
  min-height: 0;
  overflow: hidden;
}

.table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #ffffff;
  max-width: 100%;
}


#dataTable {
  width: 100%;
  border-collapse: collapse;
  min-width: 1380px;
  background: #ffffff;
}

#dataTable th,
#dataTable td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
  text-align: left;
  color: #0f172a;
}

#dataTable thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fbff;
  color: #0f2742;
  font-size: 13px;
  font-weight: 700;
}

#dataTable tbody tr {
  background: #ffffff;
}

#dataTable tbody tr:hover {
  background: #f8fbff;
}

.alert-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.alert-strip-extended {
  grid-template-columns: repeat(5, minmax(0,1fr));
}

.alert-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px 18px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: #ffffff;
  box-shadow: var(--shadow);
}

.alert-card span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  display: block;
  font-weight: 700;
}

.alert-card strong {
  display: block;
  margin: 4px 0 8px;
  font-size: 18px;
  color: #0f172a;
}

.alert-card small {
  color: var(--muted);
  line-height: 1.45;
  display: block;
}

.alert-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  margin-top: 6px;
  box-shadow: 0 0 0 6px rgba(15, 23, 42, 0.04);
}

.alert-info .alert-dot {
  background: #4da3ff;
}

.alert-warning .alert-dot {
  background: #f7d44c;
}

.alert-success .alert-dot {
  background: #8fe388;
}

.alert-danger .alert-dot {
  background: #ef2b2d;
}

.alert-card.alert-info {
  border-color: rgba(77,163,255,0.22);
  background: #f7fbff;
}

.alert-card.alert-warning {
  border-color: rgba(247,212,76,0.28);
  background: #fffdf5;
}

.alert-card.alert-success {
  border-color: rgba(143,227,136,0.30);
  background: #f6fff8;
}

.alert-card.alert-danger {
  border-color: rgba(239,43,45,0.22);
  background: #fff7f7;
}

.brand-row-textonly {
  display: block;
  margin-bottom: 22px;
}

.brand-row-textonly h1 {
  font-size: 24px;
}

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

.heatmap-panel .heatmap-wrap {
  max-height: none;
}

.brand-row-textonly {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  margin-bottom: 24px;
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  border: 1px solid var(--line);
}

.sidebar-logo {
  width: 150px;
}

/* Opcional: mejorar jerarquía visual */
.brand-text h1 {
  font-size: 20px;
  margin: 0;
}

.brand-text small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-weight: 600;
}

.brand-text p {
  font-size: 13px;
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.4;
}

@media (min-width: 1100px) {
  .action-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

@media (max-width: 1400px) {
  .app-shell {
    grid-template-columns: 320px 1fr;
  }

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

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

  .alert-strip-extended {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    height: auto;
    max-height: none;
    overflow: visible;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  
  .main-content {
    height: auto;
    overflow: visible;
  }
  .hero {
    flex-direction: column;
  }

  .hero-side {
    min-width: auto;
  }

  .charts-grid.two-col,
  .kpi-grid,
  .kpi-grid-extended,
  .compare-grid,
  .compare-grid-extended,
  .insights-grid,
  .alert-strip,
  .alert-strip-extended,
  .station-mini-grid,
  .station-mini-grid-wide {
    grid-template-columns: 1fr;
  }

  .section-head,
  .card-head,
  .with-right,
  .station-header,
  .compare-header {
    flex-direction: column;
    align-items: stretch;
  }

  .table-toolbar {
    min-width: auto;
    flex-direction: column;
    align-items: stretch;
  }

  .stack.two {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .main-content,
  .sidebar {
    padding: 16px;
  }

  .panel,
  .chart-card,
  .compare-card,
  .alert-card,
  .station-header,
  .compare-header,
  .kpi-card {
    border-radius: 18px;
  }

  .hero {
    padding: 18px;
  }

  .btn,
  .tab-btn,
  .field select,
  .table-toolbar input {
    width: 100%;
  }
}

#stationEnergyTable {
  width: 100%;
  border-collapse: collapse;
  min-width: 1100px;
  background: #ffffff;
}

#stationEnergyTable th,
#stationEnergyTable td {
  padding: 12px 14px;
  border-bottom: 1px solid #edf2f7;
  text-align: left;
  white-space: nowrap;
  color: #0f172a;
  font-size: 13px;
}

#stationEnergyTable thead th {
  background: #f8fbff;
  color: #0f2742;
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 1;
}

#stationEnergyTable tbody tr {
  background: #ffffff;
}

#stationEnergyTable tbody tr:hover {
  background: #f8fbff;
}

#stationEnergyTable td:nth-child(2),
#stationEnergyTable td:nth-child(5),
#stationEnergyTable td:nth-child(6) {
  font-weight: 600;
}

#stationEnergyTable th:nth-child(n+2),
#stationEnergyTable td:nth-child(n+2) {
  text-align: right;
}

.station-legend-box {
  margin-top: 14px;
  margin-bottom: 18px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.04);
}

.station-legend-head h3 {
  margin: 0 0 6px;
  font-size: 16px;
  color: #0f2742;
}

.station-legend-head p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.station-legend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.station-legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #e5edf6;
  border-radius: 14px;
  background: #f8fbff;
}

.station-legend-code {
  min-width: 52px;
  text-align: center;
  padding: 6px 8px;
  border-radius: 10px;
  background: #eaf3ff;
  color: #0b2a4a;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.station-legend-name {
  color: #0f172a;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
}