:root {
  color-scheme: dark;
  --bg: #080611;
  --bg-2: #0d0a1d;
  --panel: rgba(18, 14, 36, 0.76);
  --panel-strong: rgba(28, 22, 54, 0.92);
  --line: rgba(197, 177, 255, 0.16);
  --line-strong: rgba(197, 177, 255, 0.28);
  --text: #f7f2ff;
  --muted: #aaa0c6;
  --soft: #d8cdfa;
  --purple: #8b5cf6;
  --purple-2: #c084fc;
  --cyan: #38d5ff;
  --green: #55f0aa;
  --danger: #ff6b8b;
  --warning: #ffd166;
  --radius-xl: 34px;
  --radius-lg: 24px;
  --radius-md: 16px;
  --shadow: 0 24px 80px rgba(2, 0, 12, 0.44);
  --font-display: "Space Grotesk", "Trebuchet MS", sans-serif;
  --font-mono: "IBM Plex Mono", "Lucida Console", monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background: radial-gradient(circle at top left, rgba(103, 58, 183, 0.24), transparent 28%),
    radial-gradient(circle at 80% 4%, rgba(56, 213, 255, 0.16), transparent 24%),
    linear-gradient(145deg, #080611 0%, #0e0921 44%, #080611 100%);
  color: var(--text);
  font-family: var(--font-display);
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.hidden {
  display: none !important;
}

.meridian-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  pointer-events: none;
}

.orb {
  position: absolute;
  width: 34vw;
  min-width: 280px;
  aspect-ratio: 1;
  border-radius: 999px;
  filter: blur(42px);
  opacity: 0.48;
  transform: translate3d(0, 0, 0);
}

.orb-a {
  top: -12%;
  left: -8%;
  background: #7c3aed;
}

.orb-b {
  top: 18%;
  right: -14%;
  background: #2563eb;
}

.orb-c {
  bottom: -18%;
  left: 32%;
  background: #c084fc;
  opacity: 0.22;
}

.grid-glow {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.75), transparent 78%);
}

.topbar {
  position: sticky;
  top: 14px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: min(1440px, calc(100% - 32px));
  margin: 14px auto 0;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(9, 7, 19, 0.74);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(22px) saturate(140%);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: max-content;
}

.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 16px;
  background: linear-gradient(135deg, #7c3aed, #38d5ff);
  box-shadow: 0 12px 34px rgba(124, 58, 237, 0.42);
}

.brand-mark span {
  width: 17px;
  height: 17px;
  border: 2px solid white;
  border-radius: 7px;
  transform: rotate(45deg);
}

.brand strong {
  display: block;
  font-size: 16px;
  letter-spacing: 0.01em;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2vw, 24px);
  color: var(--soft);
  font-size: 14px;
}

.nav-links a {
  opacity: 0.82;
  transition: opacity 160ms ease, color 160ms ease;
}

.nav-links a:hover {
  color: white;
  opacity: 1;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.primary-btn,
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border: 0;
  border-radius: 999px;
  padding: 0 18px;
  color: white;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, opacity 160ms ease;
  will-change: transform;
}

.primary-btn {
  background: linear-gradient(135deg, #7c3aed, #a855f7 52%, #38d5ff);
  box-shadow: 0 15px 35px rgba(124, 58, 237, 0.34);
  font-weight: 700;
}

.ghost-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.055);
  color: var(--soft);
}

.compact {
  min-height: 38px;
  padding: 0 14px;
  font-size: 13px;
}

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

.primary-btn:disabled,
.ghost-btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.console-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 34px auto 70px;
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.46fr) minmax(320px, 0.54fr);
  gap: 22px;
  align-items: stretch;
}

.hero-copy,
.hero-card,
.panel,
.metric-card,
.auth-panel {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.035));
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px) saturate(140%);
}

.hero-copy {
  position: relative;
  min-height: 420px;
  padding: clamp(34px, 5vw, 70px);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.hero-copy::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 72% 20%, rgba(168, 85, 247, 0.28), transparent 20%),
    linear-gradient(105deg, rgba(10, 8, 25, 0.2), rgba(124, 58, 237, 0.06));
  pointer-events: none;
}

.hero-copy > * {
  position: relative;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #d9c7ff;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.eyebrow::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 18px rgba(85, 240, 170, 0.82);
}

.hero-copy h1 {
  max-width: 900px;
  margin: 24px 0 18px;
  font-size: clamp(42px, 7vw, 96px);
  line-height: 0.92;
  letter-spacing: -0.075em;
}

.hero-copy p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: clamp(17px, 1.6vw, 21px);
  line-height: 1.58;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 34px;
}

.hero-card {
  border-radius: var(--radius-xl);
  padding: 24px;
}

.hero-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 20px rgba(85, 240, 170, 0.8);
}

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

.rail-stack div,
.proof-card {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.045);
}

.rail-stack span,
.proof-card span,
.metric-card span,
.form-title span,
.panel h3,
label {
  color: var(--muted);
}

.rail-stack strong {
  display: block;
  margin-top: 7px;
  font-size: 22px;
}

.proof-card {
  margin-top: 14px;
}

.proof-card code {
  display: inline-flex;
  margin: 10px 0;
  padding: 7px 10px;
  border: 1px solid rgba(56, 213, 255, 0.25);
  border-radius: 999px;
  color: #bdf2ff;
  background: rgba(56, 213, 255, 0.08);
  font-family: var(--font-mono);
}

.proof-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 20px;
  padding: 20px 24px;
  border-radius: var(--radius-lg);
}

.auth-panel p {
  margin: 6px 0 0;
  color: var(--muted);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  margin-top: 22px;
}

.metric-card {
  min-height: 142px;
  border-radius: var(--radius-lg);
  padding: 22px;
}

.metric-card strong {
  display: block;
  margin-top: 14px;
  font-size: clamp(30px, 4vw, 52px);
  line-height: 0.95;
  letter-spacing: -0.05em;
}

.metric-card small {
  display: block;
  margin-top: 12px;
  color: var(--muted);
}

.metric-card.wide {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.22), rgba(56, 213, 255, 0.08));
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  margin-top: 22px;
}

.panel {
  border-radius: var(--radius-xl);
  padding: clamp(18px, 2vw, 26px);
  min-width: 0;
}

.panel.tall {
  min-height: 780px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.panel h2 {
  margin: 7px 0 0;
  font-size: clamp(26px, 3vw, 42px);
  letter-spacing: -0.05em;
}

.panel h3 {
  margin: 0 0 12px;
  font-size: 13px;
  font-family: var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  max-width: 240px;
  border: 1px solid rgba(197, 177, 255, 0.2);
  border-radius: 999px;
  padding: 0 12px;
  color: var(--soft);
  background: rgba(255, 255, 255, 0.06);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.policy-form {
  margin-top: 22px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.04);
}

.form-title {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.form-title strong {
  font-size: 16px;
}

label {
  display: grid;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(197, 177, 255, 0.16);
  border-radius: 16px;
  background: rgba(7, 5, 17, 0.72);
  color: var(--text);
  outline: none;
  padding: 13px 14px;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

textarea {
  min-height: 230px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(168, 85, 247, 0.76);
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.15);
}

input::placeholder,
textarea::placeholder {
  color: rgba(216, 205, 250, 0.38);
}

.split-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 22px;
}

.list-block {
  margin-top: 22px;
}

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

.empty-list {
  color: var(--muted);
  font-size: 14px;
}

.item-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.045);
}

.item-card.active {
  border-color: rgba(56, 213, 255, 0.5);
  background: rgba(56, 213, 255, 0.07);
}

.item-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.item-main strong {
  display: block;
  line-height: 1.25;
}

.item-main span,
.meta-line {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.mini-btn {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--soft);
  padding: 0 10px;
  cursor: pointer;
  font-size: 12px;
}

.danger-btn {
  border-color: rgba(255, 107, 139, 0.28);
  color: #ffc5d2;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  background: rgba(85, 240, 170, 0.09);
  color: #a9ffd2;
  font-size: 11px;
  font-family: var(--font-mono);
}

.status-chip.pending,
.status-chip.limited,
.status-chip.requires_step_up,
.status-chip.requires_settlement {
  background: rgba(255, 209, 102, 0.1);
  color: #ffe5a2;
}

.status-chip.failed,
.status-chip.revoked,
.status-chip.blocked {
  background: rgba(255, 107, 139, 0.12);
  color: #ffc0cd;
}

.lab-grid {
  align-items: end;
}

.json-output {
  min-height: 260px;
  max-height: 520px;
  overflow: auto;
  margin: 16px 0 0;
  border: 1px solid rgba(56, 213, 255, 0.18);
  border-radius: 22px;
  background: rgba(5, 8, 18, 0.75);
  color: #c7f7ff;
  padding: 18px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.ledger-row {
  display: grid;
  grid-template-columns: 1.3fr 0.8fr 0.8fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.045);
}

.ledger-row strong,
.ledger-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.toast-root {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  display: grid;
  gap: 10px;
  width: min(380px, calc(100vw - 32px));
}

.toast {
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: rgba(15, 11, 31, 0.94);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
  padding: 14px 16px;
  color: var(--soft);
  backdrop-filter: blur(18px);
}

.toast strong {
  display: block;
  color: white;
  margin-bottom: 5px;
}

.toast.error {
  border-color: rgba(255, 107, 139, 0.42);
}

.toast.success {
  border-color: rgba(85, 240, 170, 0.38);
}

.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: rgba(5, 3, 11, 0.62);
  backdrop-filter: blur(16px);
}

.busy-overlay > div {
  display: grid;
  justify-items: center;
  gap: 10px;
  width: min(340px, calc(100vw - 36px));
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel-strong);
  padding: 28px;
  box-shadow: var(--shadow);
}

.busy-overlay small {
  color: var(--muted);
  text-align: center;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(255, 255, 255, 0.16);
  border-top-color: var(--cyan);
  border-radius: 999px;
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1180px) {
  .topbar {
    align-items: stretch;
    border-radius: 28px;
    flex-wrap: wrap;
  }

  .nav-links {
    order: 3;
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    padding: 4px 4px 2px;
  }

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

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

@media (max-width: 760px) {
  .topbar,
  .console-shell {
    width: min(100% - 20px, 1440px);
  }

  .topbar {
    top: 8px;
    margin-top: 8px;
  }

  .brand small {
    display: none;
  }

  .top-actions {
    width: 100%;
  }

  .top-actions .compact {
    flex: 1;
  }

  .hero-copy {
    min-height: auto;
    padding: 30px 22px;
  }

  .hero-copy h1 {
    font-size: clamp(38px, 13vw, 64px);
  }

  .hero-actions,
  .auth-panel,
  .panel-head,
  .form-title,
  .item-main {
    align-items: stretch;
    flex-direction: column;
  }

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

  .metric-card.wide {
    grid-column: 1 / -1;
  }

  .form-grid,
  .policy-form,
  .lab-grid,
  .split-list {
    grid-template-columns: 1fr;
  }

  .full {
    grid-column: auto;
  }

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

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

  .panel {
    border-radius: 24px;
  }

  .primary-btn,
  .ghost-btn {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }
}
