:root {
  --bg: #f4efe7;
  --bg-strong: #e8dfd0;
  --surface: rgba(255, 251, 244, 0.86);
  --surface-strong: #fffaf1;
  --surface-dark: #173233;
  --surface-dark-soft: #25484a;
  --text: #172525;
  --muted: #5d6864;
  --line: rgba(23, 50, 51, 0.12);
  --teal: #0f766e;
  --teal-soft: rgba(15, 118, 110, 0.12);
  --gold: #ca8a04;
  --gold-soft: rgba(202, 138, 4, 0.14);
  --rose: #c2410c;
  --rose-soft: rgba(194, 65, 12, 0.12);
  --shadow: 0 20px 50px rgba(23, 37, 37, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  --sans: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(202, 138, 4, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(15, 118, 110, 0.14), transparent 24%),
    linear-gradient(180deg, #f7f1e6 0%, #efe8dc 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.28) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.28) 1px, transparent 1px);
  background-size: 24px 24px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.35), transparent 85%);
}

.page-shell {
  width: min(1440px, calc(100vw - 32px));
  margin: 24px auto 56px;
  position: relative;
  z-index: 1;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
  gap: 24px;
  padding: 32px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 36px;
  background:
    linear-gradient(135deg, rgba(255, 250, 241, 0.95), rgba(244, 239, 231, 0.78)),
    linear-gradient(120deg, rgba(202, 138, 4, 0.08), rgba(15, 118, 110, 0.08));
  box-shadow: var(--shadow);
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  width: 280px;
  height: 280px;
  right: -80px;
  top: -120px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(15, 118, 110, 0.2), transparent 68%);
  filter: blur(10px);
}

.hero-copy,
.hero-status {
  position: relative;
  z-index: 1;
}

.eyebrow,
.panel-kicker,
.status-label {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--muted);
}

.hero h1,
.panel h2,
.panel h3,
.list-card h3 {
  margin: 0;
  line-height: 1.05;
}

.hero h1 {
  font-size: clamp(2.5rem, 6vw, 4.8rem);
  max-width: 12ch;
}

.hero-text {
  max-width: 60ch;
  margin: 16px 0 0;
  font-size: 1.05rem;
  color: var(--muted);
}

.hero-status {
  display: grid;
  gap: 16px;
}

.status-card,
.panel,
.chart-card,
.list-card,
.stack-card,
.inspector-card,
.session-card {
  border: 1px solid rgba(23, 50, 51, 0.09);
  background: var(--surface);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.status-card {
  display: grid;
  gap: 8px;
  padding: 18px 20px;
  border-radius: var(--radius-lg);
}

.status-card strong {
  font-size: 1.1rem;
}

.status-detail,
.hint {
  color: var(--muted);
  font-size: 0.92rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
}

.pill-muted {
  color: #6b7280;
  background: rgba(107, 114, 128, 0.12);
}

.pill-ok {
  color: var(--teal);
  background: var(--teal-soft);
}

.pill-warn {
  color: var(--gold);
  background: var(--gold-soft);
}

.pill-error {
  color: var(--rose);
  background: var(--rose-soft);
}

.section-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0 24px;
}

.section-nav a {
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--surface-dark);
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(23, 50, 51, 0.08);
  font-weight: 700;
}

.section-nav a:hover {
  background: white;
  transform: translateY(-1px);
}

.dashboard-grid {
  display: grid;
  gap: 20px;
}

.panel {
  padding: 24px;
  border-radius: var(--radius-xl);
  animation: fadeUp 280ms ease both;
}

.panel-head,
.list-card-head,
.chart-head,
.inspector-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.panel-head {
  margin-bottom: 20px;
}

.panel-actions,
.mini-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 11px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

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

.button-primary {
  background: var(--surface-dark);
  color: #f9f7f0;
  box-shadow: 0 10px 20px rgba(23, 50, 51, 0.16);
}

.button-secondary {
  background: linear-gradient(135deg, #d97706, #b45309);
  color: white;
  box-shadow: 0 10px 20px rgba(180, 83, 9, 0.18);
}

.button-ghost {
  background: rgba(255, 255, 255, 0.78);
  color: var(--surface-dark);
  border: 1px solid rgba(23, 50, 51, 0.09);
}

.button-subtle {
  background: transparent;
  color: var(--teal);
  border: 1px solid rgba(15, 118, 110, 0.16);
}

.button-danger {
  background: rgba(194, 65, 12, 0.12);
  color: var(--rose);
  border: 1px solid rgba(194, 65, 12, 0.18);
}

.auth-grid,
.chart-grid,
.stream-grid,
.workspace-grid,
.validation-grid,
.explorer-grid,
.intel-grid {
  display: grid;
  gap: 18px;
}

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

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

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

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

.stack-card,
.chart-card,
.list-card,
.session-card,
.inspector-card {
  padding: 18px;
  border-radius: var(--radius-lg);
}

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

.metric-card {
  padding: 18px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(248, 244, 235, 0.82));
  border: 1px solid rgba(23, 50, 51, 0.08);
  min-height: 132px;
}

.metric-card strong {
  display: block;
  margin-top: 12px;
  font-size: 1.9rem;
  line-height: 1;
}

.metric-card .meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 10px;
}

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

.filter-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
  margin-bottom: 16px;
}

.filter-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.filter-submit {
  justify-self: start;
}

.compact-form {
  margin-bottom: 18px;
}

label {
  display: grid;
  gap: 8px;
  min-width: 0;
}

label span {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid rgba(23, 50, 51, 0.12);
  background: rgba(255, 255, 255, 0.88);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  font: inherit;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: rgba(15, 118, 110, 0.48);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.1);
}

textarea {
  resize: vertical;
}

.facts-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
  margin: 0;
}

.facts-list div {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(23, 50, 51, 0.08);
}

.facts-list dt {
  margin: 0 0 6px;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.facts-list dd {
  margin: 0;
  font-weight: 700;
  word-break: break-word;
}

.chart-host,
.bars-host,
.list-host,
.table-host,
.validation-host {
  min-height: 120px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 120px;
  padding: 18px;
  border: 1px dashed rgba(23, 50, 51, 0.14);
  border-radius: var(--radius-md);
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.52);
}

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

.bar-row {
  display: grid;
  grid-template-columns: 44px 1fr 48px;
  align-items: center;
  gap: 12px;
}

.bar-track {
  height: 11px;
  border-radius: 999px;
  background: rgba(23, 50, 51, 0.08);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0f766e, #d97706);
}

.mini-list,
.entity-list {
  display: grid;
  gap: 10px;
}

.entity-row {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(23, 50, 51, 0.08);
}

.entity-row header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.entity-row strong {
  font-size: 0.98rem;
}

.entity-row p,
.entity-row small {
  margin: 0;
  color: var(--muted);
}

.inline-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.inline-badges span {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.1);
  color: var(--teal);
  font-size: 0.8rem;
  font-weight: 700;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
}

.data-table thead th {
  text-align: left;
  padding: 12px;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}

.data-table tbody td {
  padding: 12px;
  border-bottom: 1px solid rgba(23, 50, 51, 0.08);
  vertical-align: top;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.62);
}

.table-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--teal);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-align: left;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.score-chip,
.small-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

.score-chip {
  color: white;
  background: linear-gradient(135deg, #0f766e, #134e4a);
}

.score-chip.low {
  background: linear-gradient(135deg, #9a3412, #c2410c);
}

.small-chip {
  color: var(--surface-dark);
  background: rgba(23, 50, 51, 0.08);
}

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

.spark-card {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(23, 50, 51, 0.08);
}

.spark-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.spark-svg {
  width: 100%;
  height: 84px;
  display: block;
}

.validation-stack {
  display: grid;
  gap: 14px;
}

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

.validation-card {
  padding: 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(23, 50, 51, 0.08);
}

.validation-card dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  margin: 12px 0 0;
}

.validation-card dt {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.validation-card dd {
  margin: 0;
  font-weight: 700;
}

.inspector-summary {
  display: grid;
  gap: 10px;
  margin: 12px 0 14px;
}

.inspector-summary .summary-row {
  padding: 12px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(23, 50, 51, 0.08);
}

.code-block {
  margin: 0;
  min-height: 420px;
  max-height: 720px;
  overflow: auto;
  padding: 18px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, #112122, #152e2f);
  color: #effcf7;
  font-family: var(--mono);
  font-size: 0.87rem;
  line-height: 1.55;
}

.split-inputs {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 12px;
}

.path-grow {
  min-width: 0;
}

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

.positive {
  color: var(--teal);
}

.negative {
  color: var(--rose);
}

.nowrap {
  white-space: nowrap;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1220px) {
  .hero,
  .auth-grid,
  .chart-grid,
  .stream-grid,
  .workspace-grid,
  .validation-grid,
  .explorer-grid,
  .intel-grid,
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 860px) {
  .page-shell {
    width: min(100vw - 18px, 100%);
    margin: 12px auto 28px;
  }

  .hero,
  .auth-grid,
  .chart-grid,
  .stream-grid,
  .workspace-grid,
  .validation-grid,
  .explorer-grid,
  .intel-grid,
  .metric-grid,
  .filter-grid,
  .filter-grid.compact,
  .split-inputs,
  .validation-cards,
  .facts-list {
    grid-template-columns: 1fr;
  }

  .panel,
  .hero {
    padding: 18px;
    border-radius: 24px;
  }

  .panel-head,
  .list-card-head,
  .chart-head,
  .inspector-head {
    flex-direction: column;
  }
}
