.insights-terminal-viewport {
  padding: 12px;
  height: 100%;
  overflow: hidden;
}

.insights-dashboard {
  height: 100%;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 14px;
  position: relative;
  color: var(--phosphor);
  font-family: "Share Tech Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: clamp(0.8em, 1vw, 0.95em);
}

.insights-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.insights-title {
  font-size: clamp(1.125em, 1.4vw, 1.5em);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.insights-subtitle {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  color: rgba(170, 255, 220, 0.95);
}

.insights-status {
  min-height: 18px;
  color: rgba(255, 210, 120, 0.9);
}

.insights-status.is-error {
  color: rgba(255, 120, 120, 0.95);
}

.insights-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(min-content, max-content);
  gap: 14px;
  min-height: 0;
}

.insights-charts {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  min-height: 0;
}

.panel {
  border: 1px solid rgba(120, 255, 180, 0.35);
  border-radius: 12px;
  padding: 12px;
  background: rgba(9, 22, 14, 0.85);
  box-shadow: 0 0 14px rgba(88, 255, 160, 0.12);
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: auto;
  overflow: visible;
}

@media (max-width: 640px) {
  .insights-dashboard {
    gap: 10px;
    font-size: 0.9em;
  }
  .panel {
    box-shadow: none;
    background: rgba(9, 22, 14, 0.75);
  }
  .panel-chart .panel__body {
    height: 200px;
  }
  .panel__chart--pie {
    height: 120px;
  }
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.panel__actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.expand {
  border: 1px solid rgba(120, 255, 180, 0.45);
  background: rgba(10, 24, 16, 0.7);
  color: rgba(170, 255, 220, 0.95);
  font-size: 0.75em;
  letter-spacing: 0.06em;
  padding: 4px 8px;
  border-radius: 8px;
  cursor: pointer;
  text-transform: uppercase;
}

.expand:hover,
.expand:focus-visible {
  border-color: rgba(170, 255, 220, 0.9);
  color: #d5ffe8;
  background: rgba(20, 50, 30, 0.9);
  outline: none;
}

.expand:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.panel__title {
  margin: 0;
  font-size: 1.05em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.panel__body {
  min-height: 0;
  height: auto;
  overflow: visible;
}

.panel__split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px;
  gap: 10px;
  align-items: center;
}

.panel__chart--pie {
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.panel-chart .panel__body {
  position: relative;
  flex: 1;
  height: 240px;
  overflow: hidden;
}

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

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

.kpi {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.kpi-label {
  color: rgba(140, 255, 200, 0.75);
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
}

.kpi-value,
.kpi-text {
  color: var(--phosphor);
  flex: 0 0 auto;
  text-align: right;
}

.split-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
}

.split-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  color: rgba(170, 255, 210, 0.9);
}

.split-list li span:first-child {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
}

.split-list li span:last-child {
  flex: 0 0 auto;
  text-align: right;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(150, 255, 210, 0.7);
  font-size: 0.95em;
  text-align: center;
  padding: 8px;
}

.panel-chart canvas,
.panel__chart--pie canvas {
  width: 100% !important;
  height: 100% !important;
}

.info {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid rgba(120, 255, 180, 0.6);
  background: rgba(10, 24, 16, 0.9);
  color: rgba(160, 255, 210, 0.9);
  font-size: 0.85em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, border 0.2s ease, color 0.2s ease;
}

.info:hover,
.info:focus {
  outline: none;
  border-color: rgba(170, 255, 220, 0.9);
  color: rgba(210, 255, 230, 1);
  background: rgba(20, 50, 30, 0.95);
}

.insights-tooltip {
  position: absolute;
  max-width: 280px;
  background: rgba(10, 26, 16, 0.98);
  border: 1px solid rgba(120, 255, 180, 0.6);
  color: rgba(200, 255, 230, 0.95);
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 0.9em;
  line-height: 1.3;
  box-shadow: 0 0 16px rgba(120, 255, 180, 0.2);
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 5;
}

.insights-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.insights-tooltip.is-top {
  transform: translateY(-6px);
}

.insights-tooltip::before {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  background: inherit;
  border-left: 1px solid rgba(120, 255, 180, 0.6);
  border-top: 1px solid rgba(120, 255, 180, 0.6);
  top: -6px;
  left: var(--arrow-left, 18px);
  transform: translateX(-50%) rotate(45deg);
}

.insights-tooltip.is-top::before {
  top: auto;
  bottom: -6px;
  transform: translateX(-50%) rotate(225deg);
}

.insights-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  color: rgba(140, 255, 200, 0.85);
  font-size: 0.95em;
}

.insights-footer .cta {
  color: var(--link);
  text-decoration: none;
}

.insights-footer .cta:hover,
.insights-footer .cta:focus {
  text-decoration: underline;
}

.interpret-panel {
  border: 1px solid rgba(120, 255, 180, 0.35);
  border-radius: 12px;
  padding: 12px;
  background: rgba(9, 22, 14, 0.75);
  box-shadow: 0 0 14px rgba(88, 255, 160, 0.12);
}

.interpret-toggle {
  background: transparent;
  border: 1px solid rgba(120, 255, 180, 0.45);
  border-radius: 10px;
  color: var(--phosphor-bright);
  padding: 8px 12px;
  font-family: "Share Tech Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.95em;
  text-shadow: 0 0 6px rgba(88, 255, 160, 0.25);
  cursor: pointer;
}

.interpret-toggle:focus-visible {
  outline: 2px solid #56ff92;
  outline-offset: 2px;
}

.interpret-content {
  margin-top: 12px;
  color: rgba(150, 255, 210, 0.9);
}

.interpret-content h3 {
  margin: 12px 0 6px 0;
  color: var(--phosphor-bright);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.95em;
}

.interpret-content ul,
.interpret-content dl {
  margin: 6px 0 10px 18px;
}

.interpret-content dt {
  color: var(--phosphor-bright);
  margin-top: 8px;
}

.interpret-content dd {
  margin: 4px 0 0 0;
  color: rgba(140, 255, 200, 0.85);
}

body.modal-open {
  overflow: hidden;
}

.chart-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.78);
  z-index: 1500;
  padding: 16px;
}

.chart-modal.is-open {
  display: flex;
}

.chart-modal__backdrop {
  position: absolute;
  inset: 0;
}

.chart-modal__dialog {
  position: relative;
  width: min(900px, 96vw);
  max-height: 90vh;
  background: rgba(9, 22, 14, 0.95);
  border: 1px solid rgba(120, 255, 180, 0.45);
  border-radius: 14px;
  box-shadow: 0 0 24px rgba(88, 255, 160, 0.2);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-family: "Share Tech Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

.chart-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chart-modal__title {
  color: var(--phosphor-bright);
  letter-spacing: 0.06em;
  font-size: 1em;
  text-transform: uppercase;
}

.chart-modal__close {
  border: 1px solid rgba(120, 255, 180, 0.45);
  background: rgba(10, 24, 16, 0.8);
  color: rgba(170, 255, 220, 0.95);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 0.75em;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.chart-modal__close:focus-visible,
.chart-modal__close:hover {
  outline: none;
  border-color: rgba(170, 255, 220, 0.9);
  color: #d5ffe8;
}

.chart-modal__body {
  flex: 1;
  min-height: 220px;
  max-height: 70vh;
}

.chart-modal__body canvas {
  width: 100% !important;
  height: 100% !important;
}

.insights-dashboard.is-loading .kpi-value,
.insights-dashboard.is-loading .split-list li,
.insights-dashboard.is-loading .chart-empty {
  color: transparent;
  background: linear-gradient(90deg, rgba(60, 120, 90, 0.25), rgba(120, 255, 180, 0.18), rgba(60, 120, 90, 0.25));
  background-size: 200% 100%;
  animation: insights-shimmer 1.2s ease-in-out infinite;
  border-radius: 6px;
}

.insights-dashboard.is-loading .split-list li {
  min-height: 18px;
}

@keyframes insights-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@media (max-width: 1100px) {
  .insights-grid,
  .insights-charts {
    grid-template-columns: 1fr;
  }

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

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

@media (max-height: 760px) {
  .insights-terminal-viewport {
    height: auto;
    overflow: auto;
  }

  .insights-dashboard {
    height: auto;
  }
}

@media (max-height: 860px) {
  .panel-chart .panel__body {
    height: 200px;
  }

  .insights-dashboard {
    gap: 10px;
  }
}