*, *::before, *::after { box-sizing: border-box; }
html { min-height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--text-primary);
  background:
    radial-gradient(circle at top left, rgba(239, 159, 39, 0.14), transparent 28rem),
    radial-gradient(circle at top right, rgba(29, 158, 117, 0.11), transparent 24rem),
    var(--surface-app);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--header-height) 1fr;
  grid-template-areas: "sidebar topbar" "sidebar main";
  min-height: 100vh;
}
.shell__sidebar {
  grid-area: sidebar;
  background: rgba(255, 255, 255, 0.76);
  border-right: 0.5px solid var(--border-default);
  backdrop-filter: blur(18px);
  padding: var(--space-5);
  position: sticky;
  top: 0;
  height: 100vh;
}
.shell__topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 0 var(--space-6);
  background: rgba(255, 255, 255, 0.72);
  border-bottom: 0.5px solid var(--border-default);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.shell__main { grid-area: main; padding: var(--space-6); }
.page { max-width: var(--container-max); margin: 0 auto; }
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.page-header h1 { margin: 0; font-size: var(--fs-2xl); line-height: 1.1; }
.page-header p { margin: 4px 0 0; color: var(--text-secondary); }

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
}
.brand__mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--grad-pass);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: var(--elev-pass);
  font-weight: var(--fw-semibold);
}
.brand__title { font-weight: var(--fw-semibold); font-size: var(--fs-lg); }
.brand__subtitle { color: var(--text-tertiary); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.08em; }
.nav { display: grid; gap: var(--space-1); }
.nav a, .nav button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: 0;
  background: transparent;
  border-radius: var(--radius-md);
  padding: 10px 12px;
  cursor: pointer;
  color: var(--text-secondary);
}
.nav a:hover, .nav button:hover, .nav a.is-active { background: var(--surface-sunken); color: var(--text-primary); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
  white-space: nowrap;
}
.badge--neutral { background: var(--status-neutral-bg); color: var(--status-neutral-text); }
.badge--pending { background: var(--status-pending-bg); color: var(--status-pending-text); }
.badge--ok { background: var(--status-ok-bg); color: var(--status-ok-text); }
.badge--warn { background: var(--status-warn-bg); color: var(--status-warn-text); }
.badge--crit { background: var(--status-crit-bg); color: var(--status-crit-text); }
.badge--promo { background: var(--status-promo-bg); color: var(--status-promo-text); }
.badge--outline { background: transparent; border: 0.5px solid currentColor; }

.card {
  background: rgba(255, 255, 255, 0.92);
  border: 0.5px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  transition: border-color var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base);
}
.card--interactive:hover { border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--elev-2); }
.card--status { border-left: 4px solid var(--status-neutral-border); }
.card--status-neutral { border-left-color: var(--status-neutral-border); }
.card--status-pending { border-left-color: var(--status-pending-border); }
.card--status-ok { border-left-color: var(--status-ok-border); }
.card--status-warn { border-left-color: var(--status-warn-border); }
.card--status-crit { border-left-color: var(--status-crit-border); }
.card--status-promo { border-left-color: var(--brand-600); }

.grid { display: grid; gap: var(--space-4); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack > * + * { margin-top: var(--space-3); }
.row { display: flex; align-items: center; gap: var(--space-3); }
.row--between { justify-content: space-between; }
.row--end { justify-content: flex-end; }
.wrap { flex-wrap: wrap; }
.muted { color: var(--text-secondary); }
.mono { font-family: var(--font-mono); }
.eyebrow {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  font-weight: var(--fw-medium);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  border-radius: var(--radius-md);
  border: 0.5px solid var(--border-default);
  background: var(--surface-card);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
  white-space: nowrap;
}
.btn:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn:active { transform: scale(0.98); }
.btn--primary { background: var(--brand-600); color: var(--text-inverse); border-color: var(--brand-600); }
.btn--primary:hover { background: var(--brand-800); border-color: var(--brand-800); }
.btn--danger { background: var(--status-crit-bg); color: var(--status-crit-text); border-color: transparent; }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--sm { padding: 5px 10px; font-size: var(--fs-xs); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field__label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.field__hint { font-size: var(--fs-xs); color: var(--text-tertiary); }
.input, .select, .textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface-card);
  border: 0.5px solid var(--border-default);
  border-radius: var(--radius-md);
}
.textarea { min-height: 96px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand-400);
  box-shadow: 0 0 0 3px rgba(127, 119, 221, 0.18);
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--grad-stage);
  color: #412402;
  font-weight: var(--fw-medium);
  flex-shrink: 0;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar--sm { width: 32px; height: 32px; font-size: 11px; }
.avatar--md { width: 44px; height: 44px; font-size: 14px; }
.avatar--lg { width: 64px; height: 64px; font-size: 20px; }
.avatar--xl { width: 88px; height: 88px; font-size: 28px; border: 3px solid var(--brand-200); }
.avatar--ringed-ok { box-shadow: 0 0 0 2px var(--surface-card), 0 0 0 4px var(--status-ok-border); }
.avatar--ringed-warn { box-shadow: 0 0 0 2px var(--surface-card), 0 0 0 4px var(--status-pending-border); }
.avatar--ringed-crit { box-shadow: 0 0 0 2px var(--surface-card), 0 0 0 4px var(--status-crit-border); }

.pass { background: var(--grad-pass); border-radius: var(--radius-xl); padding: 1px; box-shadow: var(--elev-pass); max-width: 480px; }
.pass__inner {
  background: linear-gradient(160deg, #1a1640 0%, #2d2670 100%);
  border-radius: calc(var(--radius-xl) - 1px);
  padding: var(--space-6);
  color: var(--text-on-brand);
  position: relative;
  overflow: hidden;
}
.pass__inner::before {
  content: "";
  position: absolute;
  top: -20px;
  right: -20px;
  width: 140px;
  height: 140px;
  opacity: 0.07;
  background-image: radial-gradient(circle, #fff 1px, transparent 1px);
  background-size: 10px 10px;
}
.pass__lanyard {
  width: 38px;
  height: 48px;
  background: linear-gradient(180deg, var(--brand-600), var(--brand-800));
  border-radius: 4px 4px 8px 8px;
  margin: 0 auto -8px;
  position: relative;
}
.pass__lanyard::after {
  content: "";
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 14px;
  border: 2px solid var(--brand-50);
  border-radius: 50%;
}
.pass__role { font-size: 10px; letter-spacing: 0.14em; color: var(--brand-200); text-transform: uppercase; }
.pass__name { font-size: var(--fs-xl); font-weight: var(--fw-medium); color: #fff; line-height: 1.1; }
.pass__meta { font-size: var(--fs-sm); color: var(--brand-100); }
.stamp { border: 1.5px solid currentColor; border-radius: var(--radius-sm); padding: 6px 10px; text-align: center; display: inline-block; }
.stamp__title { font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.85; }
.stamp__sub { font-size: 10px; margin-top: 1px; }
.stamp--ok { color: #5dcaa5; transform: rotate(-1.5deg); }
.stamp--warn { color: #f0997b; transform: rotate(2deg); }
.qr {
  width: 56px;
  height: 56px;
  background:
    linear-gradient(90deg, #1a1640 50%, transparent 0) 0 0 / 16px 16px,
    linear-gradient(#1a1640 50%, transparent 0) 0 0 / 16px 16px,
    #eeedfe;
  border: 5px solid #eeedfe;
  border-radius: 6px;
}

.person-card {
  position: relative;
  overflow: hidden;
  min-height: 160px;
}
.person-card::after {
  content: "";
  position: absolute;
  right: -18px;
  bottom: -18px;
  width: 112px;
  height: 112px;
  opacity: 0.08;
  background: var(--grad-pass);
  border-radius: 24px;
  transform: rotate(8deg);
}
.person-card__code {
  margin-top: var(--space-4);
  color: var(--text-tertiary);
  font-size: 10px;
  word-break: break-all;
}
.person-detail {
  display: grid;
  grid-template-columns: minmax(320px, 520px) minmax(0, 1fr);
  gap: var(--space-6);
  align-items: start;
}
.credential-stage {
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  background:
    linear-gradient(135deg, rgba(38, 33, 92, 0.12), rgba(29, 158, 117, 0.08)),
    rgba(255, 255, 255, 0.42);
  border: 0.5px solid var(--border-default);
}
.pass-id {
  max-width: 72%;
  overflow-wrap: anywhere;
  color: var(--brand-100);
  font-size: 11px;
}

.timeline { display: flex; flex-direction: column; gap: 10px; }
.timeline__day { display: flex; gap: 12px; }
.timeline__date { width: 64px; flex-shrink: 0; text-align: center; padding-top: 14px; }
.timeline__date-dow { font-size: var(--fs-xs); color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.06em; }
.timeline__date-day { font-size: var(--fs-2xl); font-weight: var(--fw-medium); line-height: 1; }
.timeline__date-month { font-size: var(--fs-xs); color: var(--text-secondary); }
.timeline__card { flex: 1; }

.sensitive { filter: blur(5px); user-select: none; font-family: var(--font-mono); letter-spacing: 0.04em; transition: filter var(--dur-base); }
.sensitive--revealed { filter: blur(0); }
.sensitive-row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 0.5px solid var(--border-default); }
.sensitive-row:last-child { border-bottom: 0; }

.table-list { width: 100%; border-collapse: collapse; }
.table-list th, .table-list td { padding: 12px 8px; text-align: left; border-bottom: 0.5px solid var(--border-default); vertical-align: top; }
.table-list th { color: var(--text-tertiary); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.08em; }

.flash { margin-bottom: var(--space-4); padding: 12px 14px; border-radius: var(--radius-md); }
.flash--success { background: var(--status-ok-bg); color: var(--status-ok-text); }
.flash--error { background: var(--status-crit-bg); color: var(--status-crit-text); }
.empty-state { text-align: center; max-width: 560px; margin: var(--space-12) auto; }
.empty-state h1 { margin: 8px 0; font-size: var(--fs-2xl); }
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-6);
}
.login-card { width: min(100%, 420px); }

@media (max-width: 960px) {
  .grid--4, .grid--3, .grid--2 { grid-template-columns: 1fr; }
  .shell { grid-template-columns: 1fr; grid-template-areas: "topbar" "main"; }
  .shell__sidebar { display: none; }
  .shell__main { padding: var(--space-4); }
  .page-header { align-items: flex-start; flex-direction: column; }
  .timeline__day { gap: 8px; }
  .timeline__date { width: 48px; }
  .row.mobile-stack { flex-direction: column; align-items: stretch; }
  .person-detail { grid-template-columns: 1fr; }
  .credential-stage { padding: var(--space-4); }
}

@media print {
  body { background: #fff; font-size: 11pt; }
  .shell__sidebar, .shell__topbar, .btn, button { display: none !important; }
  .shell { display: block; }
  .shell__main { padding: 0; }
  .card { border: 0.5pt solid #000; box-shadow: none; page-break-inside: avoid; }
  .timeline__day { page-break-inside: avoid; }
  .pass { box-shadow: none; }
}
