:root {
  --bg-0: #060b17;
  --bg-1: #091225;
  --bg-2: #0d1730;
  --panel: #0f1c36;
  --panel-2: #131f3a;
  --card: #101d38;
  --line: rgba(156, 182, 255, 0.22);
  --line-soft: rgba(156, 182, 255, 0.12);
  --text: #ecf2ff;
  --muted: #9eadd6;
  --accent: #5d9bff;
  --accent-2: #78e6d8;
  --good: #2fd6a1;
  --warn: #ffb454;
  --bad: #ff6b6b;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0 auto;
  max-width: 1680px;
  padding: 24px;
  background:
    radial-gradient(circle at 0% 0%, rgba(99, 148, 255, 0.2), transparent 34%),
    radial-gradient(circle at 100% 0%, rgba(35, 222, 193, 0.16), transparent 34%),
    radial-gradient(circle at 50% 120%, rgba(127, 72, 255, 0.12), transparent 44%),
    linear-gradient(145deg, var(--bg-0), var(--bg-1) 48%, var(--bg-2));
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
  overflow-x: hidden;
}

.page-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0;
  color: #88b6ff;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 11px;
}

h1 {
  margin: 6px 0 6px;
  font-size: 42px;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0;
  max-width: 900px;
  color: var(--muted);
}

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

.top-nav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(13, 22, 44, 0.8);
  backdrop-filter: blur(8px);
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  color: #b5c5ee;
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.nav-link:hover {
  color: #eaf1ff;
  background: rgba(106, 146, 255, 0.14);
}

.nav-link.active {
  color: #f5f8ff;
  background: linear-gradient(145deg, rgba(93, 155, 255, 0.9), rgba(79, 128, 255, 0.92));
  box-shadow: 0 8px 24px rgba(54, 104, 255, 0.4);
}

.primary-btn {
  border: 1px solid rgba(129, 167, 255, 0.45);
  background: linear-gradient(180deg, #67a5ff, #4f81ff);
  color: #fff;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(53, 111, 255, 0.34);
  transition: transform 120ms ease;
}

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

.filters {
  display: grid;
  grid-template-columns: repeat(7, minmax(130px, 1fr));
  gap: 12px;
  margin: 14px 0 20px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

input,
select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(12, 21, 42, 0.92);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

input:focus,
select:focus {
  border-color: rgba(111, 164, 255, 0.8);
  box-shadow: 0 0 0 3px rgba(99, 151, 255, 0.18);
}

.checkbox-label {
  justify-content: flex-end;
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 11px;
  color: var(--text);
  background: rgba(12, 21, 42, 0.92);
  font-weight: 600;
}

.checkbox-row input {
  width: 15px;
  height: 15px;
  margin: 0;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.kpi-grid-8 {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.kpi-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(160deg, rgba(15, 28, 54, 0.96), rgba(17, 31, 59, 0.95));
  padding: 12px;
  box-shadow: var(--shadow);
}

.kpi-good {
  border-color: rgba(47, 214, 161, 0.4);
  background: linear-gradient(160deg, rgba(11, 44, 42, 0.62), rgba(11, 35, 40, 0.65));
}

.kpi-warn {
  border-color: rgba(255, 180, 84, 0.48);
  background: linear-gradient(160deg, rgba(62, 42, 16, 0.66), rgba(53, 35, 13, 0.65));
}

.kpi-label {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.kpi-value {
  margin: 7px 0 5px;
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.kpi-sub {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
}

.insights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.insight-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(160deg, rgba(15, 28, 54, 0.96), rgba(17, 31, 59, 0.95));
  padding: 12px;
  box-shadow: var(--shadow);
}

.insight-good {
  border-color: rgba(47, 214, 161, 0.38);
}

.insight-warn {
  border-color: rgba(255, 180, 84, 0.42);
}

.insight-title {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 800;
}

.insight-value {
  margin: 6px 0 6px;
  font-size: 20px;
  line-height: 1.25;
}

.insight-text {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.card-grid {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}

.two-up {
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  align-items: stretch;
}

.three-up {
  grid-template-columns: repeat(3, minmax(220px, 1fr));
}

.card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(155deg, rgba(15, 28, 54, 0.96), rgba(16, 31, 58, 0.95));
  padding: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
  contain: layout paint;
}

h2 {
  margin: 0 0 10px;
  font-size: 16px;
  letter-spacing: 0.01em;
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chart-wrap {
  position: relative;
  height: clamp(250px, 35vh, 330px);
  min-height: 250px;
}

.chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  max-height: 460px;
  background: rgba(10, 20, 40, 0.45);
}

.action-table-wrap {
  height: 286px;
  max-height: 286px;
}

.targets-table-wrap {
  height: 460px;
  max-height: 460px;
}

.feature-catalog-wrap {
  height: 460px;
  max-height: 460px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th,
td {
  text-align: left;
  padding: 9px 8px;
  border-bottom: 1px solid rgba(160, 186, 255, 0.11);
  vertical-align: top;
  word-break: break-word;
  max-width: 300px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(15, 29, 56, 0.98);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

tbody tr:nth-child(2n) {
  background: rgba(9, 18, 36, 0.35);
}

.event-title {
  font-weight: 700;
  color: var(--text);
}

.event-detail {
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
}

.mono {
  font-family: "JetBrains Mono", Menlo, Consolas, monospace;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid rgba(142, 170, 240, 0.42);
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #b8c9f0;
  background: rgba(90, 121, 188, 0.16);
}

.pill-muted {
  border-color: rgba(142, 170, 240, 0.24);
  color: #95a6ce;
  background: rgba(120, 140, 187, 0.11);
}

.pill-signal-high {
  border-color: rgba(47, 214, 161, 0.5);
  color: #7cf1cb;
  background: rgba(47, 214, 161, 0.16);
}

.pill-signal-medium {
  border-color: rgba(93, 155, 255, 0.5);
  color: #9dc4ff;
  background: rgba(93, 155, 255, 0.16);
}

.pill-signal-low {
  border-color: rgba(255, 180, 84, 0.5);
  color: #ffd39b;
  background: rgba(255, 180, 84, 0.15);
}

.heatmap-wrap {
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(165deg, rgba(9, 17, 34, 0.96), rgba(7, 14, 29, 0.98));
  height: 286px;
}

.heatmap-lab-wrap {
  height: 460px;
}

#heatmapCanvas {
  width: 100%;
  height: 280px;
  display: block;
}

.heatmap-lab-wrap #heatmapCanvas {
  height: 460px;
}

.bucket-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}

.bucket-card {
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  padding: 10px;
  background: rgba(9, 18, 36, 0.48);
}

.bucket-label {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.bucket-value {
  margin: 5px 0 2px;
  font-size: 20px;
  font-weight: 700;
}

.bucket-meta {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
}

.merge-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.feature-filter-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.status {
  color: var(--muted);
  font-size: 12px;
  margin: 14px 2px 4px;
}

.bad {
  color: var(--bad);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: rgba(130, 162, 231, 0.35);
  border-radius: 999px;
}

::-webkit-scrollbar-track {
  background: rgba(9, 18, 36, 0.4);
}

@media (max-width: 1480px) {
  .filters {
    grid-template-columns: repeat(3, minmax(180px, 1fr));
  }

  .three-up {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }

  .feature-filter-row {
    grid-template-columns: repeat(2, minmax(170px, 1fr));
  }
}

@media (max-width: 960px) {
  body {
    padding: 14px;
  }

  h1 {
    font-size: 32px;
  }

  .filters,
  .two-up,
  .three-up {
    grid-template-columns: 1fr;
  }

  .feature-filter-row {
    grid-template-columns: 1fr;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .header-actions {
    justify-content: flex-start;
  }

  .top-nav {
    width: 100%;
    justify-content: space-between;
  }

  .nav-link {
    flex: 1;
  }

  #heatmapCanvas,
  .heatmap-lab-wrap #heatmapCanvas {
    height: 320px;
  }

  .heatmap-wrap,
  .heatmap-lab-wrap,
  .targets-table-wrap,
  .feature-catalog-wrap,
  .action-table-wrap {
    height: 320px;
    max-height: 320px;
  }
}
