:root {
  --bg: #f4f7fb;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-border: rgba(15, 23, 42, 0.08);
  --text: #0f172a;
  --muted: #526077;
  --accent: #0f766e;
  --accent-dark: #134e4a;
  --accent-soft: #ccfbf1;
  --warning: #b45309;
  --warning-soft: #fef3c7;
  --danger: #b42318;
  --danger-soft: #fee4e2;
  --success: #166534;
  --success-soft: #dcfce7;
  --shadow: 0 24px 60px rgba(15, 23, 42, 0.08);
  --radius-lg: 28px;
  --radius-md: 22px;
  --radius-sm: 16px;
  --transition-base: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(13, 148, 136, 0.12), transparent 30%),
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.12), transparent 25%),
    linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
  min-height: 100vh;
}

button,
input,
textarea,
code,
pre {
  font: inherit;
}

/* ── Page shell ── */

.page-shell {
  max-width: 1260px;
  margin: 0 auto;
  padding: 40px 20px 60px;
}

/* ── Fade-in keyframes for page load ── */

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

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(15, 118, 110, 0.25); }
  50%      { box-shadow: 0 0 0 8px rgba(15, 118, 110, 0); }
}

@keyframes checkPop {
  0%   { transform: scale(0); opacity: 0; }
  60%  { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ── Hero ── */

.hero {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 24px;
  align-items: stretch;
  margin-bottom: 28px;
  animation: fadeSlideUp 0.5s ease-out both;
}

.hero-copy,
.hero-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.hero-copy {
  padding: 34px;
}

.hero-card {
  padding: 28px;
  background: linear-gradient(160deg, #0f172a 0%, #134e4a 100%);
  color: #f8fafc;
}

.eyebrow,
.section-label,
.hero-label {
  margin: 0 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
  font-weight: 700;
}

.eyebrow,
.section-label {
  color: var(--accent);
}

.hero-label {
  color: #99f6e4;
}

.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(2.2rem, 5vw, 4rem);
  line-height: 0.96;
}

.lede,
.section-text,
.hero-list,
.empty-state,
.timeline-details,
.meta-row span,
.copy-heading span,
.fact-label,
.user-grid span {
  color: var(--muted);
}

.hero-list {
  margin: 18px 0 0;
  padding-left: 18px;
  color: #dbeafe;
  line-height: 1.8;
}

/* ── Dashboard ── */

.dashboard {
  display: grid;
  gap: 24px;
}

.dashboard > * {
  animation: fadeSlideUp 0.5s ease-out both;
}

.dashboard > *:nth-child(1) { animation-delay: 0.08s; }
.dashboard > *:nth-child(2) { animation-delay: 0.16s; }
.dashboard > *:nth-child(3) { animation-delay: 0.24s; }
.dashboard > *:nth-child(4) { animation-delay: 0.32s; }

.grid.two-up {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

/* ── Panels ── */

.panel {
  padding: 26px;
  transition: box-shadow var(--transition-base);
}

.panel:hover {
  box-shadow: 0 28px 70px rgba(15, 23, 42, 0.11);
}

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

.panel-heading.compact {
  margin-bottom: 18px;
}

.panel h2,
.panel h3 {
  margin: 0;
}

/* ── Buttons ── */

.primary-button,
.ghost-button {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: transform var(--transition-base), opacity var(--transition-base), background var(--transition-base), box-shadow var(--transition-base);
}

.primary-button {
  background: linear-gradient(135deg, var(--accent) 0%, #0f766e 100%);
  color: #fff;
  padding: 14px 22px;
  font-weight: 700;
  font-size: 1rem;
}

.primary-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(15, 118, 110, 0.3);
}

.primary-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.primary-button:active {
  transform: translateY(0);
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.7;
  transform: none;
  box-shadow: none;
}

.primary-button.generating {
  animation: pulseGlow 1.2s ease-in-out infinite;
}

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 2px solid rgba(15, 118, 110, 0.2);
  border-radius: 999px;
  background: rgba(204, 251, 241, 0.3);
  color: var(--accent-dark);
  padding: 12px 20px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform var(--transition-base), background var(--transition-base), border-color var(--transition-base);
}

.secondary-button:hover {
  background: rgba(204, 251, 241, 0.6);
  border-color: rgba(15, 118, 110, 0.35);
  transform: translateY(-1px);
}

.secondary-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.secondary-button.hidden {
  display: none;
}

.ghost-button {
  background: transparent;
  color: var(--accent-dark);
  font-size: 0.92rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 8px;
  position: relative;
}

.ghost-button:hover {
  background: rgba(204, 251, 241, 0.4);
  transform: translateY(-1px);
}

.ghost-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}

.panel-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.ghost-button .copy-check {
  display: inline-block;
  animation: checkPop 0.35s ease-out both;
  color: var(--success);
}

/* ── Quick facts ── */

.quick-facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.fact {
  background: rgba(240, 249, 255, 0.8);
  border: 1px solid rgba(15, 118, 110, 0.12);
  border-radius: 20px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fact strong {
  word-break: break-word;
}

/* ── QR panel ── */

.qr-panel,
.payload-panel {
  min-height: 100%;
}

.qr-wrap {
  min-height: 330px;
  border-radius: 24px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.9), rgba(236, 253, 245, 0.9));
  border: 1px dashed rgba(15, 118, 110, 0.2);
  display: grid;
  place-items: center;
  padding: 24px;
  transition: border-color var(--transition-base), background var(--transition-base);
}

.qr-wrap:has(.qr-image) {
  border-style: solid;
  border-color: rgba(15, 118, 110, 0.15);
  background: linear-gradient(145deg, #ffffff, #f0fdfa);
}

.qr-image {
  width: min(100%, 300px);
  height: auto;
  border-radius: var(--radius-sm);
  box-shadow: 0 24px 50px rgba(15, 23, 42, 0.12);
  animation: fadeSlideUp 0.4s ease-out both;
}

.session-meta {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  padding-bottom: 10px;
}

.meta-row strong {
  text-align: right;
}

/* ── Copy blocks ── */

.copy-block {
  background: rgba(248, 250, 252, 0.9);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 14px;
  transition: border-color var(--transition-base);
}

.copy-block:hover {
  border-color: rgba(15, 118, 110, 0.18);
}

.copy-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
  align-items: center;
}

code,
pre {
  display: block;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92rem;
  background: transparent;
  margin: 0;
}

/* ── Postman panel highlight ── */

.postman-panel {
  border: 2px solid rgba(15, 118, 110, 0.15);
  background: linear-gradient(180deg, rgba(204, 251, 241, 0.15) 0%, var(--panel) 100%);
  position: relative;
}

.postman-panel::before {
  content: "DEMO ACTION";
  position: absolute;
  top: -1px;
  right: 24px;
  background: linear-gradient(135deg, var(--accent) 0%, #0f766e 100%);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  padding: 5px 14px;
  border-radius: 0 0 10px 10px;
}

/* ── Result card ── */

.result-card,
.user-profile {
  border-radius: 24px;
  padding: 18px 20px;
  border: 1px solid transparent;
  transition: background var(--transition-base), border-color var(--transition-base), box-shadow var(--transition-base);
}

.result-card h3,
.user-profile h3 {
  margin-bottom: 8px;
}

.result-idle {
  background: rgba(226, 232, 240, 0.35);
  border-color: rgba(148, 163, 184, 0.25);
}

.result-success {
  background: var(--success-soft);
  border-color: rgba(22, 101, 52, 0.18);
  animation: fadeIn 0.4s ease-out;
}

.result-warning {
  background: var(--warning-soft);
  border-color: rgba(180, 83, 9, 0.18);
  animation: fadeIn 0.4s ease-out;
}

.result-error {
  background: var(--danger-soft);
  border-color: rgba(180, 35, 24, 0.18);
  animation: fadeIn 0.4s ease-out;
}

.result-success code {
  margin-top: 12px;
}

.result-pending {
  background: rgba(204, 251, 241, 0.25);
  border-color: rgba(15, 118, 110, 0.12);
}

.user-profile {
  margin-top: 14px;
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(15, 23, 42, 0.08);
  animation: fadeSlideUp 0.35s ease-out both;
}

.user-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.user-grid div {
  background: rgba(248, 250, 252, 0.8);
  border-radius: 18px;
  padding: 14px;
}

.hidden {
  display: none;
}

/* ── Status pill ── */

.status-pill {
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(226, 232, 240, 0.8);
  color: var(--accent-dark);
  text-transform: capitalize;
  font-weight: 700;
  font-size: 0.88rem;
  transition: background var(--transition-base), color var(--transition-base);
  white-space: nowrap;
}

.status-pill[data-state="pending"] {
  background: rgba(204, 251, 241, 0.5);
  color: var(--accent);
}

.status-pill[data-state="verifying"] {
  background: rgba(219, 234, 254, 0.75);
  color: #1d4ed8;
}

.status-pill[data-state="authenticated"] {
  background: var(--success-soft);
  color: var(--success);
}

.status-pill[data-state="expired"] {
  background: var(--warning-soft);
  color: var(--warning);
}

.status-pill[data-state="rejected"] {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ── Gate grid ── */

.gate-section {
  margin-bottom: 24px;
}

.gate-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

.gate-section-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.gate-section-icon.core {
  background: linear-gradient(135deg, var(--accent) 0%, #0f766e 100%);
  color: #fff;
}

.gate-section-icon.cross {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff;
}

.gate-section-title {
  font-size: 0.88rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.gate-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.gate-card {
  padding: 16px;
  border-radius: var(--radius-md);
  background: rgba(248, 250, 252, 0.86);
  border: 1px solid rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color var(--transition-base), transform var(--transition-base), box-shadow var(--transition-base);
}

.gate-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}

.gate-card[data-gate-state="passed"] {
  border-color: rgba(22, 101, 52, 0.2);
  background: rgba(220, 252, 231, 0.35);
}

.gate-card[data-gate-state="failed"] {
  border-color: rgba(180, 35, 24, 0.2);
  background: rgba(254, 228, 226, 0.35);
}

.gate-name {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.3;
}

.gate-value {
  text-transform: capitalize;
  font-size: 0.95rem;
}

.gate-value[data-state="passed"],
.timeline-status[data-state="passed"] {
  color: var(--success);
}

.gate-value[data-state="failed"],
.timeline-status[data-state="failed"] {
  color: var(--danger);
}

.gate-value[data-state="pending"],
.timeline-status[data-state="pending"] {
  color: var(--warning);
}

/* ── Timeline ── */

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

.timeline-item {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 14px;
  align-items: start;
  animation: fadeSlideUp 0.3s ease-out both;
}

.timeline-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-top: 8px;
  transition: background var(--transition-base);
}

.timeline-dot[data-state="passed"] {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(22, 101, 52, 0.15);
}

.timeline-dot[data-state="failed"] {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.15);
}

.timeline-dot[data-state="pending"] {
  background: var(--warning);
  box-shadow: 0 0 0 3px rgba(180, 83, 9, 0.15);
}

.timeline-body {
  border-radius: 20px;
  padding: 14px 18px;
  background: rgba(248, 250, 252, 0.86);
  border: 1px solid rgba(15, 23, 42, 0.08);
  transition: border-color var(--transition-base);
}

.timeline-item:first-child .timeline-body {
  border-color: rgba(15, 118, 110, 0.15);
}

.timeline-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.timeline-at {
  font-size: 0.84rem;
  color: var(--muted);
}

/* ── Summary bar ── */

.gate-summary {
  display: flex;
  gap: 16px;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  background: rgba(248, 250, 252, 0.9);
  border: 1px solid rgba(15, 23, 42, 0.06);
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.gate-summary-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 0.92rem;
}

.gate-summary-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.gate-summary-dot.passed { background: var(--success); }
.gate-summary-dot.failed { background: var(--danger); }
.gate-summary-dot.pending { background: var(--warning); }

.gate-summary-count {
  color: var(--muted);
  font-weight: 600;
}

/* ── Toasts ── */

.toast-root {
  position: fixed;
  right: 22px;
  bottom: 22px;
  display: grid;
  gap: 10px;
  z-index: 1000;
  pointer-events: none;
}

.toast {
  min-width: 230px;
  max-width: 320px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.16);
  font-size: 0.9rem;
  color: var(--text);
  pointer-events: auto;
  animation: fadeSlideUp 0.2s ease-out both;
}

.toast.success {
  border-color: rgba(22, 101, 52, 0.25);
  background: rgba(220, 252, 231, 0.95);
}

.toast.error {
  border-color: rgba(180, 35, 24, 0.25);
  background: rgba(254, 228, 226, 0.95);
}

/* ── Responsive ── */

@media (max-width: 1024px) {
  .hero,
  .grid.two-up {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 720px) {
  .page-shell {
    padding: 18px 14px 40px;
  }

  .hero-copy,
  .hero-card,
  .panel {
    border-radius: var(--radius-md);
    padding: 20px;
  }

  .quick-facts,
  .user-grid {
    grid-template-columns: 1fr;
  }

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

  .panel-heading,
  .copy-heading,
  .timeline-head,
  .meta-row {
    flex-direction: column;
    align-items: start;
  }

  .gate-summary {
    flex-direction: column;
    gap: 10px;
  }

  .ghost-button {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

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