:root {
  --onyx-deep: #080808;
  --onyx-surface: #121212;
  --emerald-glow: #50c878;
  --emerald-dim: #1e5631;
  --acid-growth: #a2ff00;
  --risk-amber: #d97706;
  --risk-red: #b91c1c;
  --ops-cyan: #2f8f83;
  --compliance-blue: #4f6bff;
  --text-dim: #74b48a;
  --line-soft: rgba(80, 200, 120, 0.12);
  --border-glow: 0 0 10px rgba(80, 200, 120, 0.15);
  --font-main: "JetBrains Mono", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  background-color: var(--onyx-deep);
  color: var(--emerald-glow);
  font-family: var(--font-main);
  margin: 0;
  padding: 15px;
}

button,
input,
select {
  font: inherit;
}

.dashboard-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  grid-template-rows: auto 1fr 300px;
  gap: 15px;
  height: calc(100vh - 30px);
}

.header {
  grid-column: 1 / -1;
}

.command-sidebar {
  grid-row: 2 / 3;
  background: var(--onyx-surface);
  border: 1px solid var(--emerald-dim);
  padding: 20px;
  box-shadow: var(--border-glow);
  overflow: auto;
}

.intelligence-canvas {
  grid-row: 2 / 3;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 15px;
  min-width: 0;
}

.raw-records-foundation {
  grid-column: 1 / -1;
  background: var(--onyx-surface);
  border: 1px solid var(--emerald-dim);
  overflow: hidden;
  padding: 14px;
  box-shadow: var(--border-glow);
}

.panel {
  background: var(--onyx-surface);
  border: 1px solid var(--emerald-dim);
  box-shadow: var(--border-glow);
}

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

.header h1,
.header h2,
.command-sidebar h2,
.explorer-context h2,
.explorer-primary h2,
.raw-records-foundation h2,
p {
  margin: 0;
}

.header h1 {
  margin-top: 8px;
  font-size: 1.15rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.header p,
.status-line,
.nlq-output,
[data-record-caption],
[data-page-status] {
  color: var(--text-dim);
}

.header-copy {
  display: grid;
  gap: 8px;
}

.header-kicker,
.section-label,
.zone-head,
.record-meta {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
}

.header-command {
  display: block;
  padding: 10px 12px;
  border: 1px solid var(--emerald-dim);
  background: #0c0c0c;
  color: var(--emerald-glow);
}

.header-actions,
.header-buttons,
.sidebar-actions,
.mode-toggle,
.foundation-tools,
.panel-toolbar,
.foundation-head,
.zone-head,
.sort-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.header-actions {
  flex-direction: column;
  align-items: flex-end;
}

.sidebar-section,
.context-zone {
  display: grid;
  gap: 10px;
}

.command-sidebar {
  display: grid;
  gap: 16px;
  align-content: start;
}

.input-block {
  display: grid;
  gap: 7px;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.input-block input,
.input-block select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--emerald-dim);
  background: #0b0b0b;
  color: var(--emerald-glow);
}

.command-entry {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.filter-stack {
  display: grid;
  gap: 9px;
}

.action-button {
  border: 1px solid var(--emerald-dim);
  background: #0d0d0d;
  color: var(--emerald-glow);
  padding: 8px 10px;
  cursor: pointer;
}

.action-button:hover,
.sort-row button:hover {
  background: rgba(80, 200, 120, 0.08);
}

.action-button-solid,
.action-button.is-active {
  background: var(--emerald-glow);
  color: #08110b;
  border-color: var(--emerald-glow);
  font-weight: 700;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 30px;
}

.tag {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 4px 8px;
  border: 1px solid var(--emerald-dim);
  background: rgba(80, 200, 120, 0.05);
  font-size: 0.74rem;
}

.tag button {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  cursor: pointer;
}

.explorer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(320px, 0.85fr);
  gap: 15px;
  min-height: 0;
}

.explorer-primary,
.explorer-context {
  padding: 14px;
  min-height: 0;
}

.panel-toolbar,
.foundation-head {
  justify-content: space-between;
}

.explorer-stage {
  margin-top: 12px;
  height: calc(100% - 60px);
  min-height: 360px;
}

.explorer-svg,
.cluster-svg {
  width: 100%;
  height: 100%;
  background:
    linear-gradient(rgba(80, 200, 120, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(80, 200, 120, 0.05) 1px, transparent 1px);
  background-size: 24px 24px;
}

.is-hidden {
  display: none;
}

.context-zone {
  padding: 10px;
  border: 1px solid var(--emerald-dim);
  background: #0d0d0d;
}

.zone-head {
  justify-content: space-between;
  color: var(--text-dim);
}

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

.kpi-card {
  padding: 10px;
  border: 1px solid var(--line-soft);
  background: #0a0a0a;
}

.kpi-value {
  margin-top: 8px;
  font-size: 1.1rem;
  font-weight: 700;
}

.kpi-note {
  margin-top: 6px;
  color: var(--text-dim);
  font-size: 0.72rem;
}

.heatmap,
.keyword-bars {
  margin-top: 10px;
}

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

.heat-label,
.keyword-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--text-dim);
}

.heat-cell {
  min-height: 54px;
  border: 1px solid rgba(80, 200, 120, 0.18);
  background: rgba(80, 200, 120, 0.08);
  color: var(--emerald-glow);
  cursor: pointer;
}

.keyword-bars {
  display: grid;
  gap: 6px;
}

.keyword-row {
  display: grid;
  grid-template-columns: 86px 1fr auto;
  gap: 8px;
  align-items: center;
}

.keyword-track {
  position: relative;
  height: 10px;
  background: rgba(80, 200, 120, 0.08);
  cursor: pointer;
}

.keyword-fill {
  position: absolute;
  inset: 0 auto 0 0;
}

.foundation-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) 320px;
  gap: 14px;
  height: calc(100% - 72px);
  margin-top: 10px;
  min-height: 0;
}

.table-pane {
  min-width: 0;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

th {
  text-align: left;
  padding: 10px;
  border-bottom: 2px solid var(--emerald-dim);
  text-transform: uppercase;
  color: var(--emerald-dim);
  position: sticky;
  top: 0;
  background: #0d0d0d;
}

td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(80, 200, 120, 0.1);
}

tr:hover {
  background: rgba(80, 200, 120, 0.05);
  cursor: pointer;
}

tr.is-selected {
  background: rgba(80, 200, 120, 0.08);
}

.revenue-cell {
  color: var(--acid-growth);
  font-weight: bold;
}

.sort-row {
  margin-top: 10px;
  flex-wrap: wrap;
}

.sort-row button {
  border: 1px solid var(--emerald-dim);
  background: #0d0d0d;
  color: var(--emerald-glow);
  padding: 6px 9px;
  cursor: pointer;
}

.context-inspector {
  position: relative;
  background: rgba(18, 18, 18, 0.95);
  border: 1px solid var(--emerald-glow);
  padding: 12px;
  font-size: 0.75rem;
  backdrop-filter: blur(4px);
  pointer-events: none;
  overflow: auto;
}

.tooltip {
  position: fixed;
  background: rgba(18, 18, 18, 0.95);
  border: 1px solid var(--emerald-glow);
  padding: 12px;
  font-size: 0.75rem;
  backdrop-filter: blur(4px);
  pointer-events: none;
  color: var(--emerald-glow);
  z-index: 20;
}

.node {
  stroke: var(--emerald-glow);
  stroke-width: 1.5px;
  transition: all 0.2s ease;
}

.node.risk {
  fill: var(--risk-red);
  stroke: var(--risk-amber);
}

.node.growth {
  fill: var(--acid-growth);
}

.node.operations {
  fill: var(--emerald-dim);
}

.node.experience {
  fill: var(--risk-amber);
}

.node.compliance {
  fill: var(--compliance-blue);
}

@media (max-width: 1200px) {
  .dashboard-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr auto;
    height: auto;
  }

  .command-sidebar,
  .intelligence-canvas {
    grid-row: auto;
  }

  .explorer-grid,
  .foundation-grid {
    grid-template-columns: 1fr;
  }

  .raw-records-foundation {
    min-height: 420px;
  }
}
