:root {
  --bg: #0a0b12;
  --panel: #151826;
  --panel-soft: #1b2031;
  --text: #f4dbc3;
  --muted: #b89c88;
  --line: #2d344a;
  --orange: #ee9c62;
  --peach: #f6bc85;
  --red: #e46a63;
  --gold: #d6af59;
  --lavender: #b194d8;
  --cyan: #8bc9d8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "Arial Narrow", Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(238, 156, 98, 0.2), transparent 30%),
    linear-gradient(140deg, #080910, #121522 48%, #090a11);
  color: var(--text);
}

button {
  font: inherit;
}

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

.rail {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 18px;
  background: linear-gradient(180deg, rgba(246, 188, 133, 0.12), rgba(21, 24, 38, 0.92));
  border-right: 2px solid rgba(246, 188, 133, 0.18);
  min-width: 0;
}

.rail-top,
.rail-block,
.status-card,
.panel,
.detail-card,
.decision-row,
.audit-row,
.dependency-card {
  border-radius: 28px;
}

.rail-top {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--panel);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 22px;
  background: linear-gradient(180deg, var(--orange), var(--peach));
  color: #28140a;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.stack-label,
.panel-kicker,
.detail-kicker,
.rail-kicker,
.status-label,
.eyebrow,
.meta-label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--muted);
}

.stack-subtitle,
.rail-value {
  font-size: 0.95rem;
}

.rail-block {
  padding: 14px 16px;
  background: var(--panel);
}

.rail-actions {
  display: grid;
  gap: 12px;
}

.lcars-button {
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  padding: 0 18px;
  background: #2a3145;
  color: var(--text);
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
}

.lcars-button:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.lcars-button:disabled {
  cursor: not-allowed;
  filter: saturate(0.25);
  opacity: 0.48;
  transform: none;
}

.lcars-button.primary {
  background: linear-gradient(90deg, var(--orange), var(--peach));
  color: #25140b;
  font-weight: 700;
}

.lcars-button.warning {
  background: linear-gradient(90deg, #cb745a, var(--red));
}

.lcars-button.accent {
  background: linear-gradient(90deg, var(--lavender), #d3a8d2);
  color: #1d1525;
}

.bridge {
  padding: 28px;
  min-width: 0;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: end;
  margin-bottom: 24px;
}

.hero h1 {
  margin: 6px 0 10px;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 0.95;
  max-width: 10ch;
}

.hero p {
  margin: 0;
  max-width: 58ch;
  color: #dfc2ac;
}

.status-cluster {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 14px;
  min-width: 320px;
}

.status-card,
.panel,
.detail-card,
.decision-row,
.audit-row,
.dependency-card {
  background: linear-gradient(180deg, rgba(27, 32, 49, 0.95), rgba(18, 21, 34, 0.98));
  border: 1px solid rgba(246, 188, 133, 0.08);
}

.status-card {
  padding: 16px 18px;
}

.status-card strong {
  display: block;
  margin-top: 6px;
  font-size: 2rem;
}

.panel-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.95fr) minmax(0, 1.35fr);
  gap: 18px;
}

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

.panel-audit {
  grid-column: 1 / -1;
}

.panel-registry {
  grid-column: 1 / -1;
  border-color: rgba(177, 148, 216, 0.34);
}

.panel-change {
  grid-column: 1 / -1;
  border-color: rgba(177, 148, 216, 0.3);
}

.comparison-content {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.revision-navigation {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-width: 0;
}

.revision-link {
  display: flex;
  justify-content: center;
  gap: 10px;
  min-width: 0;
  color: var(--muted);
}

.revision-link span {
  max-width: 30%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.revision-link strong {
  color: var(--lavender);
}

.comparison-grid,
.change-impact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  min-width: 0;
}

.revision-card,
.change-surface,
.change-row,
.routine-row {
  border-radius: 22px;
  border: 1px solid rgba(246, 188, 133, 0.1);
  background: rgba(10, 11, 18, 0.3);
}

.revision-card,
.change-surface {
  padding: 16px;
  min-width: 0;
}

.revision-card h3 {
  margin: 8px 0;
}

.revision-card p {
  color: #d9c6ba;
}

.prior-revision {
  border-left: 5px solid var(--muted);
}

.current-revision {
  border-left: 5px solid var(--cyan);
}

.change-list,
.routine-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.change-row,
.routine-row {
  padding: 12px 14px;
}

.change-path,
.routine-name {
  color: var(--peach);
  font-weight: 700;
}

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

.change-before,
.change-after {
  padding: 9px 10px;
  border-radius: 14px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.change-before {
  background: rgba(228, 106, 99, 0.12);
  color: #ffb1ab;
}

.change-after {
  background: rgba(139, 201, 216, 0.12);
  color: var(--cyan);
}

.routine-row p {
  margin: 6px 0 0;
  color: #d9c6ba;
}

.routine-trigger {
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.8rem;
}

.panel-proof {
  grid-column: 1 / -1;
  border-color: rgba(139, 201, 216, 0.34);
  background:
    linear-gradient(135deg, rgba(139, 201, 216, 0.08), transparent 45%),
    linear-gradient(180deg, rgba(27, 32, 49, 0.95), rgba(18, 21, 34, 0.98));
}

.proof-chip {
  background: rgba(139, 201, 216, 0.16);
  color: var(--cyan);
}

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

.proof-disclosure {
  max-width: 82ch;
  margin: -4px 0 16px;
  color: #cad7dc;
}

.proof-replay-disclosure {
  margin: 0 0 14px;
  padding: 12px 16px;
  border-left: 5px solid var(--gold);
  border-radius: 16px;
  background: rgba(214, 175, 89, 0.1);
  color: #ead9b0;
}

.proof-replay {
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid rgba(139, 201, 216, 0.22);
  border-radius: 22px;
  background: rgba(10, 11, 18, 0.32);
}

.proof-replay-status {
  margin-bottom: 12px;
  color: var(--cyan);
  font-weight: 700;
}

.proof-replay-timeline {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.proof-replay-step {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(246, 188, 133, 0.1);
  border-radius: 18px;
  background: rgba(21, 24, 38, 0.7);
  opacity: 0.48;
  transition:
    opacity 180ms ease,
    border-color 180ms ease,
    transform 180ms ease,
    background 180ms ease;
}

.proof-replay-step > span {
  color: var(--muted);
  font-weight: 800;
}

.proof-replay-step strong {
  color: var(--text);
}

.proof-replay-step p {
  margin: 7px 0 0;
  color: #d9c6ba;
  font-size: 0.85rem;
}

.proof-replay-step.active {
  opacity: 1;
  transform: translateY(-2px);
  border-color: var(--peach);
  background: rgba(238, 156, 98, 0.1);
}

.proof-replay-step.complete {
  opacity: 1;
  border-color: rgba(139, 201, 216, 0.48);
  background: rgba(139, 201, 216, 0.08);
}

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

.proof-card,
.proof-document,
.proof-assets {
  padding: 14px 16px;
  border: 1px solid rgba(139, 201, 216, 0.16);
  border-radius: 22px;
  background: rgba(10, 11, 18, 0.28);
}

.proof-card strong,
.proof-document strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
}

.proof-document,
.proof-assets {
  margin-top: 12px;
}

.proof-document strong {
  color: var(--cyan);
}

.proof-assets .dependency-list {
  margin-top: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  min-width: 0;
}

.panel-header h2 {
  margin: 4px 0 0;
  font-size: 1.3rem;
}

.panel-chip {
  align-self: center;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(238, 156, 98, 0.16);
  color: var(--peach);
  font-size: 0.85rem;
}

.decision-list,
.audit-list,
.dependency-list,
.evidence-list {
  display: grid;
  gap: 12px;
}

.decision-row {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid transparent;
  text-align: left;
  color: inherit;
  cursor: pointer;
}

.decision-row.active {
  border-color: rgba(246, 188, 133, 0.6);
  box-shadow: inset 0 0 0 1px rgba(246, 188, 133, 0.25);
}

.decision-top,
.decision-bottom,
.audit-top,
.meta-grid,
.action-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.decision-title {
  font-weight: 700;
  min-width: 0;
  overflow-wrap: anywhere;
}

.decision-bottom,
.audit-meta {
  font-size: 0.82rem;
  color: var(--muted);
}

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

.detail-card {
  padding: 16px;
  min-height: 150px;
}

.detail-card p {
  margin: 10px 0 0;
}

.analytics-card {
  grid-column: 1 / -1;
  min-height: 0;
}

.analysis-sql {
  max-height: 220px;
  margin: 14px 0 0;
  padding: 14px;
  overflow: auto;
  border-radius: 18px;
  background: rgba(10, 11, 18, 0.5);
  color: var(--cyan);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.action-row {
  margin: 12px 0 16px;
  flex-wrap: wrap;
}

.meta-grid {
  flex-wrap: wrap;
}

.meta-grid strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.dependency-card {
  padding: 12px 14px;
}

.dependency-type {
  color: var(--gold);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.dependency-urn {
  margin-top: 6px;
  word-break: break-all;
  font-size: 0.9rem;
}

.evidence-list {
  margin: 12px 0 0;
  padding-left: 18px;
}

.evidence-list li {
  padding-left: 4px;
}

.audit-row {
  padding: 14px 16px;
}

.audit-event {
  font-weight: 700;
}

.audit-details {
  margin-top: 8px;
  color: #d9c6ba;
  font-size: 0.9rem;
}

.empty-state {
  padding: 24px;
  border-radius: 24px;
  background: rgba(139, 201, 216, 0.08);
  color: #cad7dc;
}

.error-text {
  color: #ffb1ab;
  min-height: 1.25rem;
}

.status-pill {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status-APPROVED,
.status-SYNCED {
  background: rgba(139, 201, 216, 0.16);
  color: var(--cyan);
}

.status-PENDING_APPROVAL,
.status-PENDING {
  background: rgba(246, 188, 133, 0.16);
  color: var(--peach);
}

.status-REVALIDATION_REQUIRED,
.status-RETRY_REQUIRED {
  background: rgba(228, 106, 99, 0.16);
  color: #ffb1ab;
}

.status-SUPERSEDED,
.status-NOT_CONFIGURED,
.status-DRAFT {
  background: rgba(177, 148, 216, 0.16);
  color: #d5c2f4;
}

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

  .rail {
    border-right: 0;
    border-bottom: 2px solid rgba(246, 188, 133, 0.18);
  }

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

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

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

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

  .revision-navigation {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .revision-link {
    order: -1;
  }

  .revision-navigation .lcars-button {
    width: 100%;
    min-width: 0;
  }

  .status-cluster {
    min-width: 0;
  }
}

@media (max-width: 720px) {
  .rail-top,
  .panel-header,
  .decision-top,
  .decision-bottom,
  .audit-top {
    min-width: 0;
  }

  .bridge {
    padding: 18px;
  }

  .hero {
    flex-direction: column;
    align-items: start;
  }

  .status-cluster {
    width: 100%;
    grid-template-columns: 1fr 1fr;
  }

  .proof-grid,
  .proof-replay-timeline,
  .proof-assets .dependency-list,
  .comparison-grid,
  .change-impact-grid,
  .change-values {
    grid-template-columns: 1fr;
  }
}
