:root {
  --bg: #0f1419;
  --panel: #1a2332;
  --border: #2d3a4f;
  --text: #e8eef7;
  --muted: #8b9cb3;
  --accent: #3d7eff;
  --accent-dim: #2563d4;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  font-family: 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); min-height: 100vh; }

.topbar {
  display: flex; align-items: center; gap: 1.5rem;
  padding: 0.75rem 1.5rem; border-bottom: 1px solid var(--border);
  background: #121a24;
}
.brand { font-weight: 700; letter-spacing: 0.02em; }
.nav { display: flex; gap: 0.5rem; flex: 1; }
.nav-link {
  color: var(--muted); text-decoration: none; padding: 0.35rem 0.75rem; border-radius: 6px;
}
.nav-link:hover, .nav-link.active { color: var(--text); background: var(--panel); }
.topbar-actions { display: flex; align-items: center; gap: 0.75rem; }
.user-pill { font-size: 0.8rem; color: var(--muted); }

.main { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }
.page-header h1 { margin: 0 0 0.35rem; font-size: 1.5rem; }
.muted { color: var(--muted); font-size: 0.9rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 1rem 1.25rem;
}
.panel h2 { margin: 0 0 0.75rem; font-size: 1.1rem; }

.stack { display: flex; flex-direction: column; gap: 0.65rem; }
label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.85rem; color: var(--muted); }
input, select, textarea {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: 0.45rem 0.6rem; font-size: 0.95rem;
}
.checkbox { flex-direction: row; align-items: center; gap: 0.5rem; }

.btn {
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  border-radius: 6px; padding: 0.45rem 0.9rem; cursor: pointer; font-size: 0.9rem;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent-dim); color: #fff; }
.btn-primary:hover { background: var(--accent-dim); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.8rem; }

.login-card {
  max-width: 420px; margin: 3rem auto; padding: 1.5rem;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
}
.hint { margin-top: 1rem; font-size: 0.85rem; color: var(--muted); }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.card-link {
  display: block; padding: 1rem 1.25rem; background: var(--panel);
  border: 1px solid var(--border); border-radius: 10px; color: inherit; text-decoration: none;
}
.card-link:hover { border-color: var(--accent); }
.card-link h2 { margin: 0 0 0.35rem; font-size: 1.05rem; }
.card-link p { margin: 0; color: var(--muted); font-size: 0.85rem; }

.profile-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.6rem 0; border-bottom: 1px solid var(--border);
}
.profile-row button { margin-left: 0.35rem; }
.badge {
  font-size: 0.7rem; padding: 0.15rem 0.45rem; border-radius: 4px;
  background: #2a3548; color: var(--muted); text-transform: uppercase;
}
.badge-published { background: #14532d; color: #86efac; }
.badge-draft { background: #422006; color: #fcd34d; }

.dialog {
  border: 1px solid var(--border); border-radius: 10px; padding: 1.25rem;
  background: var(--panel); color: var(--text); max-width: 480px;
}
.dialog::backdrop { background: rgba(0,0,0,0.6); }
.dialog-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; }

.preview-wrap { display: flex; justify-content: center; padding: 1rem 0; }

/* FIPS-inspired ID-1 card preview (not to scale) */
.piv-card { width: 340px; perspective: 800px; }
.piv-card-front, .piv-card-back {
  width: 340px; height: 214px; border-radius: 10px; border: 1px solid #ccc;
  background: #fff; color: #111; position: relative; margin-bottom: 0.75rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.piv-card-front::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 8px;
  background: var(--accent);
}
.band-white .piv-card-front::after { background: #fff; border-top: 1px solid #ccc; }
.band-green .piv-card-front::after { background: #166534; }
.band-blue .piv-card-front::after { background: #1e40af; }

.piv-photo {
  position: absolute; left: 14px; top: 28px; width: 72px; height: 90px;
  background: linear-gradient(135deg, #cbd5e1, #94a3b8); border: 1px solid #64748b;
}
.piv-fields { position: absolute; left: 100px; top: 32px; right: 50px; font-size: 11px; }
.piv-name { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.piv-affiliation { font-weight: 600; }
.piv-org { color: #334155; margin-top: 2px; }
.piv-exp { margin-top: 8px; font-weight: 700; font-size: 12px; }
.piv-chip {
  position: absolute; right: 18px; top: 70px; width: 36px; height: 28px;
  background: linear-gradient(145deg, #d4af37, #b8860b); border-radius: 4px;
  border: 1px solid #92400e;
}
.piv-variant-tag {
  position: absolute; right: 12px; top: 10px; font-size: 9px; font-weight: 700;
  padding: 2px 6px; background: #1e293b; color: #fff; border-radius: 3px;
}
.piv-card-back { padding: 16px; font-size: 10px; font-family: monospace; }
.piv-serial { margin-top: 40px; font-weight: 700; }
.piv-iin { margin-top: 8px; color: #475569; }

.queue-row {
  padding: 0.65rem 0; border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}
.state { font-weight: 600; font-size: 0.75rem; text-transform: uppercase; }
.state-QUEUED { color: var(--warn); }
.state-COMPLETED { color: var(--ok); }
.state-FAILED { color: var(--danger); }
