:root {
  --bg: #0c1220;
  --sidebar: #111827;
  --panel: #1a2332;
  --border: #2a3a52;
  --text: #edf2f7;
  --muted: #8fa3bf;
  --accent: #0ea5e9;
  --accent-2: #6366f1;
  --sandbox: #22c55e;
  --production: #f59e0b;
  --success: #22c55e;
  --danger: #ef4444;
  --warn-bg: #422006;
  --radius: 14px;
  --font: "Segoe UI", system-ui, sans-serif;
  --mono: "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); }

.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.eyebrow {
  margin: 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
}

.brand h1 { margin: 0.25rem 0; font-size: 1.35rem; line-height: 1.3; }
.tagline { margin: 0; color: var(--muted); font-size: 0.85rem; }

.nav { display: flex; flex-direction: column; gap: 0.35rem; flex: 1; }

.nav-item {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  text-align: left;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.92rem;
}

.nav-item:hover { background: #172033; border-color: var(--border); }
.nav-item.active { background: #1e3a5f; border-color: #2563eb; color: #93c5fd; }

.env-toggle span { display: block; font-size: 0.75rem; color: var(--muted); margin-bottom: 0.5rem; }
.toggle { display: flex; gap: 0.35rem; }
.env-btn {
  flex: 1;
  border: 1px solid var(--border);
  background: #0f172a;
  color: var(--muted);
  padding: 0.45rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8rem;
}
.env-btn.active[data-env="sandbox"], #envSandbox.active {
  border-color: var(--sandbox);
  color: var(--sandbox);
  background: #052e16;
}
.env-btn.active[data-env="production"], #envProduction.active {
  border-color: var(--production);
  color: var(--production);
  background: #422006;
}

.main { padding: 2rem 2.5rem; max-width: 1100px; }

.hero h2 { margin: 0 0 0.5rem; font-size: 2rem; }
.hero p { color: var(--muted); line-height: 1.6; max-width: 720px; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  cursor: pointer;
  transition: border-color 0.15s;
}
.card:hover { border-color: var(--accent); }
.card h3 { margin: 0 0 0.5rem; font-size: 1.05rem; }
.card p { margin: 0; color: var(--muted); font-size: 0.88rem; line-height: 1.5; }
.card .icon { font-size: 1.5rem; margin-bottom: 0.5rem; }

.alert {
  background: var(--warn-bg);
  border: 1px solid #b45309;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  line-height: 1.55;
  font-size: 0.92rem;
}
.alert strong { color: #fbbf24; }

.flow-header { margin-bottom: 1.5rem; }
.flow-header h2 { margin: 0 0 0.35rem; }
.flow-header p { margin: 0; color: var(--muted); }

.stepper {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}
.step-pill {
  border: 1px solid var(--border);
  background: #111827;
  color: var(--muted);
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  font-size: 0.78rem;
  cursor: pointer;
}
.step-pill.active { border-color: var(--accent); color: #7dd3fc; background: #0c4a6e; }
.step-pill.done { border-color: #166534; color: #86efac; }

.step-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.step-panel h3 { margin: 0 0 0.35rem; font-size: 1.25rem; }
.step-summary { color: var(--muted); margin: 0 0 1.25rem; }

.env-box {
  border-radius: 10px;
  padding: 1rem 1.15rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}
.env-box.sandbox { background: #052e16; border-color: #166534; }
.env-box.production { background: #422006; border-color: #b45309; }
.env-box .label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
  font-weight: 600;
}
.env-box.sandbox .label { color: var(--sandbox); }
.env-box.production .label { color: var(--production); }
.env-box p { margin: 0.35rem 0; line-height: 1.55; font-size: 0.9rem; }
.env-box .endpoint {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: #93c5fd;
  margin-top: 0.5rem;
  word-break: break-all;
}

.code-block {
  background: #0a0f1a;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.55;
  overflow-x: auto;
  white-space: pre-wrap;
  margin-top: 1rem;
}

.step-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 1.25rem;
  gap: 0.75rem;
}
.btn {
  border: none;
  border-radius: 10px;
  padding: 0.65rem 1.1rem;
  cursor: pointer;
  font-size: 0.9rem;
}
.btn-primary { background: var(--accent); color: #fff; font-weight: 600; }
.btn-secondary { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.compare-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  font-size: 0.9rem;
}
.compare-table th, .compare-table td {
  border: 1px solid var(--border);
  padding: 0.75rem 1rem;
  text-align: left;
  vertical-align: top;
}
.compare-table th { background: #111827; color: var(--muted); font-weight: 600; }
.compare-table .col-sandbox { background: #071a10; }
.compare-table .col-production { background: #1c1208; }

.journey-list { list-style: none; padding: 0; margin: 0; }
.journey-item {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  align-items: start;
}
.journey-num {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: #1e3a5f;
  color: #93c5fd;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem;
}
.journey-system {
  font-size: 0.78rem;
  color: var(--accent);
  background: #0c4a6e;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
}

.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.link-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.link-card a {
  color: #7dd3fc;
  word-break: break-all;
}
.link-card .role { color: var(--muted); font-size: 0.88rem; margin-top: 0.5rem; }

.prereq {
  margin: 1rem 0;
  padding-left: 1.2rem;
  color: var(--muted);
  line-height: 1.7;
}

ul.chars { color: var(--muted); line-height: 1.7; padding-left: 1.2rem; }

.card-highlight {
  border-color: var(--accent);
  background: linear-gradient(135deg, #0c1929 0%, #111827 100%);
}

.live-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1.25rem 0;
}

.live-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.live-grid--split {
  grid-template-columns: 1fr 1fr;
  align-items: start;
}

.live-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.live-panel h3 {
  margin: 0 0 1rem;
  font-size: 0.95rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.health-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.health-pill {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 0.6rem;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  background: #111827;
  font-size: 0.88rem;
}

.health-pill.ok { border-left: 3px solid var(--success); }
.health-pill.fail { border-left: 3px solid var(--danger); }

.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.health-pill.ok .health-dot { background: var(--success); }
.health-pill.fail .health-dot { background: var(--danger); }

.health-status { color: var(--muted); font-size: 0.82rem; }

.live-select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #111827;
  color: var(--text);
  font-size: 0.9rem;
}

.field-label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.citizen-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 1rem;
  margin: 1rem 0 0;
  font-size: 0.88rem;
}

.citizen-meta dt { color: var(--muted); }
.citizen-meta dd { margin: 0; }

.muted { color: var(--muted); font-size: 0.88rem; }

.live-steps {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.live-step {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 0.85rem 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.live-step.done {
  border-color: #065f46;
  background: #071a10;
}

.live-step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #1e3a5f;
  color: #93c5fd;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
}

.live-step.done .live-step-num {
  background: #065f46;
  color: #6ee7b7;
}

.live-step-body p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.btn-sm { padding: 0.45rem 0.85rem; font-size: 0.82rem; }

.response-log {
  max-height: 420px;
  overflow-y: auto;
  font-size: 0.78rem;
}

.log-entry {
  margin-bottom: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.log-entry summary {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  background: #111827;
  font-size: 0.85rem;
}

.log-entry.ok summary { border-left: 3px solid var(--success); }
.log-entry.fail summary { border-left: 3px solid var(--danger); }

.log-time { color: var(--muted); font-size: 0.78rem; margin-left: 0.5rem; }

.log-entry pre {
  margin: 0;
  padding: 0.75rem;
  overflow-x: auto;
  background: #0a0f1a;
  color: #93c5fd;
  white-space: pre-wrap;
  word-break: break-word;
}

.vc-iframe {
  width: 100%;
  height: 420px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.esignet-login-panel {
  grid-column: 1 / -1;
  border-color: #0ea5e9;
  background: linear-gradient(135deg, #0c1929 0%, #1a2332 100%);
}

.login-steps-guide {
  margin: 0 0 1rem;
  padding-left: 1.2rem;
  color: var(--muted);
  line-height: 1.8;
  font-size: 0.9rem;
}

.login-form {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.live-input {
  flex: 1;
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #111827;
  color: var(--text);
  font-size: 0.95rem;
  font-family: var(--mono);
}

.live-input[readonly] {
  opacity: 0.85;
  background: #0a0f1a;
}

.input-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.btn-esignet {
  width: 100%;
  padding: 0.85rem 1.2rem;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #0284c7 0%, #0ea5e9 100%);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-esignet:hover {
  filter: brightness(1.08);
}

.btn-esignet::before {
  content: '🔐';
}

.login-mode-note {
  margin: 0.75rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { height: auto; position: static; }
  .main { padding: 1.25rem; }
  .live-grid--split { grid-template-columns: 1fr; }
}
