:root {
  --bg: #edf3f0;
  --panel: #ffffff;
  --panel-alt: #f1f6f3;
  --ink: #15221c;
  --muted: #617068;
  --line: #d9e5df;
  --brand: #006b43;
  --brand-2: #008650;
  --brand-dark: #0d3328;
  --red: #9f2f2f;
  --gold: #c39a16;
  --green: #008650;
  --cyan: #2f7d73;
  --shadow: 0 16px 40px rgba(19, 53, 41, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.is-hidden {
  display: none !important;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(6, 41, 31, 0.96), rgba(0, 134, 80, 0.88)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.09) 0 1px, transparent 1px 72px),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.06) 0 1px, transparent 1px 72px);
}

.login-panel {
  width: min(100%, 470px);
  padding: 30px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.login-logo-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 94px;
  margin-bottom: 18px;
  padding: 14px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.login-logo-frame img {
  display: block;
  max-width: 100%;
  max-height: 78px;
  object-fit: contain;
}

.brand-mark {
  display: grid;
  width: 52px;
  height: 52px;
  margin-bottom: 18px;
  place-items: center;
  color: #ffffff;
  background: #b83737;
  border: 2px solid rgba(255, 255, 255, 0.65);
  border-radius: 8px;
  font-weight: 800;
}

.brand-mark.small {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  margin: 0;
  font-size: 0.8rem;
}

.login-panel h1 {
  margin: 0 0 8px;
  font-size: 2rem;
  line-height: 1.1;
}

.login-copy {
  margin: 0 0 24px;
  color: var(--muted);
}

.login-credentials {
  display: grid;
  gap: 5px;
  margin: 0 0 20px;
  padding: 12px;
  color: var(--muted);
  background: #f6faf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.86rem;
}

.login-credentials strong {
  color: var(--brand);
}

.login-form,
.filters {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: inherit;
  font-size: 0.85rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(27, 107, 143, 0.22);
  outline-offset: 2px;
}

.error-message {
  min-height: 20px;
  margin: 0;
  color: #9f2f2f;
  font-size: 0.86rem;
}

.primary-button,
.secondary-button,
.ghost-button,
.tool-button {
  min-height: 40px;
  padding: 9px 14px;
  border-radius: 6px;
  font-weight: 800;
}

.primary-button {
  color: #ffffff;
  background: var(--brand);
  border: 1px solid var(--brand);
}

.secondary-button {
  color: #ffffff;
  background: var(--brand-dark);
  border: 1px solid var(--brand-dark);
}

.gold-action {
  background: var(--gold);
  border-color: var(--gold);
}

.green-action {
  background: var(--brand);
  border-color: var(--brand);
}

.ghost-button {
  color: var(--brand);
  background: transparent;
  border: 1px solid var(--line);
}

.app-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 292px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 22px;
  color: #ffffff;
  background: linear-gradient(180deg, #08261e, #0f362a 52%, #0a201a);
}

.sidebar-head {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.sidebar-logo {
  width: 52px;
  height: 52px;
  object-fit: contain;
}

.sidebar-head span {
  display: block;
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.82rem;
}

.filter-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.filter-title h2 {
  margin: 0;
  font-size: 1rem;
}

.sidebar .ghost-button {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.22);
}

.admin-tools {
  display: grid;
  gap: 10px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.admin-tools h2 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.tool-button {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  text-align: left;
}

.tool-button:hover {
  background: rgba(255, 255, 255, 0.14);
}

.dashboard {
  min-width: 0;
  padding: 22px;
  background:
    linear-gradient(180deg, rgba(0, 134, 80, 0.08), transparent 280px),
    var(--bg);
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
  padding: 18px 20px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(31, 45, 61, 0.04);
}

.topbar h1 {
  max-width: 850px;
  margin: 0;
  font-size: 1.65rem;
  line-height: 1.18;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.role-badge {
  min-height: 40px;
  padding: 10px 13px;
  color: #ffffff;
  background: var(--brand-2);
  border-radius: 6px;
  font-size: 0.86rem;
  font-weight: 850;
}

.role-badge[data-role="admin"] {
  background: var(--brand-dark);
}

.role-badge[data-role="ejecutivo"] {
  background: var(--green);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi-card,
.chart-panel,
.table-panel,
.briefing-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(31, 45, 61, 0.05);
}

.kpi-card {
  min-height: 116px;
  padding: 15px;
  border-top: 4px solid var(--brand-2);
}

.kpi-card span,
.kpi-card small,
.panel-head span {
  color: var(--muted);
}

.kpi-card span {
  display: block;
  font-size: 0.82rem;
  font-weight: 850;
  text-transform: uppercase;
}

.kpi-card strong {
  display: block;
  min-height: 39px;
  margin: 8px 0 3px;
  font-size: 1.65rem;
  line-height: 1;
}

.kpi-card small {
  font-size: 0.86rem;
}

.kpi-card.accent-red {
  border-top-color: var(--red);
}

.kpi-card.accent-risk {
  border-top-color: var(--gold);
  background: linear-gradient(180deg, #fffdf6, #ffffff 68%);
}

.kpi-card.accent-blue {
  border-top-color: var(--cyan);
}

.kpi-card.accent-gold {
  border-top-color: var(--gold);
}

.kpi-card.accent-green {
  border-top-color: var(--green);
}

.briefing-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.briefing-panel {
  min-width: 0;
  padding: 18px;
}

.brief-list {
  display: grid;
  gap: 10px;
}

.brief-item {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  background: var(--panel-alt);
  border-left: 4px solid var(--brand);
  border-radius: 6px;
}

.brief-item strong {
  color: var(--ink);
  font-size: 0.9rem;
}

.brief-item span,
.brief-empty {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.chart-panel,
.table-panel {
  min-width: 0;
  padding: 18px;
}

.chart-panel.wide {
  grid-column: span 2;
}

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

.panel-head h2 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.2;
}

.line-chart {
  height: 260px;
}

.line-chart svg {
  display: block;
  width: 100%;
  height: 100%;
}

.axis-label {
  fill: var(--muted);
  font-size: 12px;
}

.bar-chart {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(92px, 0.9fr) minmax(130px, 2fr) 42px;
  gap: 10px;
  align-items: center;
  min-height: 28px;
  font-size: 0.86rem;
}

.bar-label {
  overflow: hidden;
  color: var(--brand-dark);
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  background: var(--panel-alt);
  border-radius: 999px;
}

.bar-fill {
  height: 100%;
  min-width: 2px;
  background: linear-gradient(90deg, var(--brand-2), var(--gold));
  border-radius: inherit;
}

.bar-value {
  color: var(--muted);
  font-weight: 850;
  text-align: right;
}

.donut-layout {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 20px;
  align-items: center;
  min-height: 170px;
}

.donut {
  width: 148px;
  height: 148px;
  background: conic-gradient(var(--brand-2) 0deg, var(--brand-2) 360deg);
  border: 12px solid #ffffff;
  border-radius: 50%;
  box-shadow: inset 0 0 0 22px #ffffff, 0 0 0 1px var(--line);
}

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

.legend-item {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  font-size: 0.86rem;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.rank-list {
  display: grid;
  gap: 10px;
}

.rank-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.rank-row:last-child {
  border-bottom: 0;
}

.rank-name {
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.rank-count {
  min-width: 40px;
  padding: 6px 9px;
  color: #ffffff;
  background: var(--brand);
  border-radius: 6px;
  font-size: 0.86rem;
  font-weight: 850;
  text-align: center;
}

.table-panel {
  margin-top: 16px;
}

.access-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 16px;
  padding: 18px 20px;
  color: #ffffff;
  background: var(--brand-dark);
  border: 1px solid var(--brand-dark);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(31, 45, 61, 0.08);
}

.heat-matrix {
  display: grid;
  gap: 6px;
  overflow: auto;
}

.matrix-corner,
.matrix-head,
.matrix-day,
.matrix-cell {
  min-height: 34px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 850;
}

.matrix-head,
.matrix-day {
  color: var(--muted);
  background: #f8fbf9;
  border: 1px solid var(--line);
}

.matrix-cell {
  color: #ffffff;
  background: rgba(0, 134, 80, var(--intensity));
  border: 1px solid rgba(0, 134, 80, 0.12);
}

.matrix-cell:empty {
  background: #f3f7f5;
}

.gauge-card {
  display: grid;
  gap: 14px;
  justify-items: center;
  min-height: 238px;
  padding-top: 8px;
}

.gauge {
  display: grid;
  width: 154px;
  height: 154px;
  place-items: center;
  color: var(--brand-dark);
  background:
    radial-gradient(circle at center, #ffffff 0 56%, transparent 57%),
    conic-gradient(var(--brand) 0 var(--value), #e4eee9 var(--value) 360deg);
  border-radius: 50%;
  font-size: 1.75rem;
  font-weight: 900;
}

.gauge-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
  text-align: center;
}

.access-panel h2 {
  margin: 0 0 6px;
  font-size: 1.05rem;
}

.access-panel p {
  max-width: 760px;
  margin: 0;
  color: rgba(255, 255, 255, 0.76);
  font-size: 0.94rem;
}

.access-panel span {
  flex: 0 0 auto;
  padding: 8px 10px;
  color: #ffffff;
  background: var(--green);
  border-radius: 6px;
  font-size: 0.84rem;
  font-weight: 850;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 0.84rem;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #ffffff;
  background: var(--brand-dark);
  font-size: 0.78rem;
  text-transform: uppercase;
}

td {
  color: #26323f;
}

tbody tr:hover {
  background: #f7fafc;
}

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

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

  .sidebar {
    position: static;
    height: auto;
  }

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

  .filter-title {
    grid-column: 1 / -1;
  }

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

@media (max-width: 720px) {
  .dashboard {
    padding: 16px;
  }

  .topbar,
  .panel-head,
  .access-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar h1 {
    font-size: 1.35rem;
  }

  .filters,
  .kpi-grid,
  .briefing-grid,
  .analysis-grid {
    grid-template-columns: 1fr;
  }

  .chart-panel.wide {
    grid-column: auto;
  }

  .donut-layout {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .bar-row {
    grid-template-columns: minmax(82px, 1fr) minmax(120px, 1.5fr) 36px;
  }
}

@media print {
  .sidebar,
  .topbar-actions,
  .table-panel {
    display: none !important;
  }

  .app-shell {
    display: block;
  }

  .dashboard {
    padding: 0;
    background: #ffffff;
  }
}
