:root {
  --canvas: #0a0d0f;
  --surface: #111619;
  --surface-2: #151c20;
  --surface-3: #1b242a;
  --ink: #eef1ea;
  --ink-2: #c3cbc4;
  --muted: #8e9a98;
  --faint: #667270;
  --hairline: #263139;
  --hairline-strong: #35444c;
  --accent: #d8f36a;
  --accent-2: #b9d94f;
  --accent-ink: #101507;
  --ok: #7fe0a8;
  --warn: #f2c66d;
  --danger: #ff7f6e;
  --info: #82c8ff;
  --radius: 2px;
  --sidebar: 248px;
  --font-sans: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --shadow-1: 0 10px 30px rgba(0, 0, 0, 0.22);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

html { color-scheme: dark; }

body {
  background:
    radial-gradient(1100px 520px at 84% -8%, rgba(216, 243, 106, 0.055), transparent 62%),
    linear-gradient(rgba(255, 255, 255, 0.017) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.017) 1px, transparent 1px),
    var(--canvas);
  background-size: auto, 48px 48px, 48px 48px, auto;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

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

button { cursor: pointer; }

svg { display: block; }

::selection { background: var(--accent); color: var(--accent-ink); }

* { caret-color: var(--accent); scrollbar-width: thin; scrollbar-color: var(--hairline-strong) transparent; }

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--hairline-strong); border: 3px solid var(--canvas); border-radius: 999px; }

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

.sr-only {
  position: absolute !important;
  left: 0; top: 0;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: fixed; top: 12px; left: 12px; z-index: 100;
  background: var(--accent); color: var(--accent-ink);
  padding: 8px 12px; border-radius: var(--radius);
  font-size: 12px; font-weight: 700;
  transform: translateY(-200%);
}
.skip-link:focus { transform: translateY(0); }

.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky; top: 0;
  height: 100vh;
  display: flex; flex-direction: column;
  padding: 24px 18px;
  border-right: 1px solid var(--hairline);
  background: var(--canvas);
  z-index: 20;
}

.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 8px;
  border-radius: var(--radius);
}

.brand-mark {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  color: var(--accent);
}
.brand-mark svg { width: 24px; height: 24px; fill: currentColor; }
.brand-mark-accent { fill: var(--accent); }

.brand-text {
  font-size: 11px; line-height: 1.22; font-weight: 700;
  letter-spacing: 0.16em; color: var(--ink);
}

.nav { margin-top: 38px; display: grid; gap: 3px; }

.nav-link {
  display: flex; align-items: center; gap: 11px;
  min-height: 38px; padding: 8px 10px;
  border: 1px solid transparent; border-radius: var(--radius);
  color: var(--muted); font-size: 13px;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}
.nav-link .icon { color: var(--faint); transition: color 160ms ease; }
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link:hover .icon { color: var(--ink-2); }
.nav-link.is-active { background: var(--surface); border-color: var(--hairline); color: var(--ink); }
.nav-link.is-active .icon { color: var(--accent); }

.sidebar-foot {
  margin-top: auto; padding: 18px 8px 4px;
  border-top: 1px solid var(--hairline);
  display: grid; gap: 8px;
}
.live { display: inline-flex; align-items: center; gap: 8px; font-size: 11px; color: var(--ink-2); letter-spacing: 0.04em; }
.live-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  animation: livePulse 2.8s ease-in-out infinite;
}
.build { font-family: var(--font-mono); font-size: 10px; color: var(--faint); letter-spacing: 0.01em; }

@keyframes livePulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(216, 243, 106, 0.08); }
  50% { box-shadow: 0 0 0 7px rgba(216, 243, 106, 0.015); }
}

.workspace { min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 15;
  min-height: 64px;
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 0 40px;
  border-bottom: 1px solid var(--hairline);
  background: var(--canvas);
}

.crumb {
  display: flex; align-items: center; gap: 10px;
  font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); white-space: nowrap; overflow: hidden;
}
.crumb-root { color: var(--ink-2); }
.crumb-sep { color: var(--faint); }

.topbar-actions { display: flex; align-items: center; gap: 12px; flex: none; }

.admin-chip {
  font-family: var(--font-mono); font-size: 10.5px;
  color: var(--ink-2);
  border: 1px solid var(--hairline);
  background: var(--surface);
  padding: 5px 9px; border-radius: var(--radius);
}

.page {
  width: 100%; max-width: 1480px;
  margin: 0 auto;
  padding: 40px 48px 80px;
}

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 28px;
  margin-bottom: 30px;
}
.page-head-copy { min-width: 0; }
.page-head-actions { display: flex; align-items: center; gap: 8px; flex: none; padding-top: 4px; }

h1 {
  margin: 0;
  font-size: 34px; line-height: 1.12;
  font-weight: 650; letter-spacing: -0.035em;
}
.lede {
  margin: 10px 0 0;
  max-width: 72ch;
  color: var(--muted);
  font-size: 14.5px; line-height: 1.55;
}

h2 { margin: 0; font-size: 16px; line-height: 1.3; font-weight: 600; letter-spacing: -0.012em; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px;
  border: 1px solid transparent; border-radius: var(--radius);
  font-size: 12.5px; font-weight: 650; line-height: 1;
  white-space: nowrap;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, opacity 160ms ease;
}
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-secondary { background: transparent; color: var(--ink); border-color: var(--hairline-strong); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--muted); }
.btn-ghost { background: transparent; color: var(--muted); border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(255, 127, 110, 0.34); }
.btn-danger:hover { background: rgba(255, 127, 110, 0.08); border-color: var(--danger); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 11.5px; }
.btn-block { width: 100%; height: 40px; }
.btn:disabled { opacity: 0.48; cursor: not-allowed; }

.text-link {
  color: var(--ink-2); font-size: 12px;
  text-decoration: underline; text-underline-offset: 3px;
  text-decoration-color: var(--hairline-strong);
  transition: color 160ms ease, text-decoration-color 160ms ease;
}
.text-link:hover { color: var(--accent); text-decoration-color: var(--accent); }

.flash {
  margin: 0 0 22px;
  padding: 12px 14px;
  border: 1px solid rgba(216, 243, 106, 0.28);
  background: rgba(216, 243, 106, 0.055);
  color: var(--ink);
  font-size: 12.5px;
  border-radius: var(--radius);
}
.flash.is-error { border-color: rgba(255, 127, 110, 0.36); background: rgba(255, 127, 110, 0.065); }

.status-rail {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--hairline);
  background: var(--surface);
  margin-bottom: 22px;
}
.status-cell {
  padding: 17px 20px;
  border-right: 1px solid var(--hairline);
  min-width: 0;
}
.status-cell:last-child { border-right: 0; }
.status-label { display: block; font-size: 9.5px; letter-spacing: 0.11em; text-transform: uppercase; color: var(--muted); }
.status-cell strong {
  display: block;
  margin: 7px 0 3px;
  font-family: var(--font-mono);
  font-size: 30px; line-height: 1; font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
}
.status-cell-live strong { color: var(--accent); }
.status-note { font-size: 10.5px; color: var(--faint); }

.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.55fr);
  gap: 20px;
  align-items: start;
}

.panel {
  border: 1px solid var(--hairline);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 21px 21px 17px;
  min-width: 0;
}
.panel-spaced { margin-top: 20px; }
.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 18px;
  margin-bottom: 14px;
}
.panel-note { margin: 5px 0 0; color: var(--muted); font-size: 11.5px; line-height: 1.45; max-width: 76ch; }
.panel-foot { border-top: 1px solid var(--hairline); margin-top: 14px; padding-top: 13px; }

.table-wrap { width: 100%; overflow-x: auto; }
.table-hint { display: none; margin: 0 0 8px; color: var(--faint); font-size: 10.5px; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  padding: 0 10px 9px;
  border-bottom: 1px solid var(--hairline);
  text-align: left;
  font-size: 9.5px; font-weight: 650;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.data-table td {
  padding: 11px 10px;
  border-bottom: 1px solid rgba(38, 49, 57, 0.62);
  color: var(--ink-2);
  font-size: 12.5px;
  vertical-align: middle;
}
.data-table tbody tr { transition: background 140ms ease; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table td.num { font-family: var(--font-mono); font-size: 10.5px; color: var(--faint); }
.data-table-wide { min-width: 760px; }
.actions-col { width: 1%; text-align: right; white-space: nowrap; }

.code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.01em;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  padding: 2px 5px;
  border-radius: var(--radius);
  white-space: nowrap;
}
.device-name { display: block; color: var(--ink); font-size: 12.5px; white-space: nowrap; }
.sub { display: block; margin-top: 2px; font-family: var(--font-mono); font-size: 10px; color: var(--faint); white-space: nowrap; }
.muted { color: var(--muted); }
.mono-small { font-family: var(--font-mono); font-size: 10.5px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 21px; padding: 1px 8px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--canvas);
  color: var(--muted);
  font-size: 10px; letter-spacing: 0.02em;
  white-space: nowrap;
}
.pill + .pill { margin-left: 4px; }
.pill-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.pill.is-active { color: var(--ok); border-color: rgba(127, 224, 168, 0.28); background: rgba(127, 224, 168, 0.055); }
.pill.is-unused { color: var(--ink-2); border-color: var(--hairline-strong); background: var(--surface-2); }
.pill.is-revoked { color: var(--danger); border-color: rgba(255, 127, 110, 0.3); background: rgba(255, 127, 110, 0.055); }
.pill.is-expired { color: var(--warn); border-color: rgba(242, 198, 109, 0.28); background: rgba(242, 198, 109, 0.055); }
.pill.is-stale { color: var(--warn); border-color: rgba(242, 198, 109, 0.3); background: transparent; }
.pill.is-none { color: var(--faint); }

.attention-list { list-style: none; margin: 0; padding: 0; }
.attention-list li {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 0;
  border-bottom: 1px solid var(--hairline);
  color: var(--muted);
  font-size: 12px; line-height: 1.45;
}
.attention-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.attention-list strong { color: var(--ink); font-weight: 600; }
.attention-list .text-link { margin-left: 4px; }
.attention-mark {
  width: 7px; height: 7px; flex: none; margin-top: 5px;
  border-radius: 50%; background: var(--faint);
}
.attention-mark.is-warn { background: var(--warn); }
.attention-mark.is-ok { background: var(--ok); }

.empty {
  border: 1px solid var(--hairline);
  background: var(--canvas);
  padding: 38px 22px;
  text-align: center;
}
.empty-title { margin: 0 0 5px; color: var(--ink); font-size: 14px; font-weight: 600; }
.empty p { margin: 0; color: var(--muted); font-size: 12.5px; }
.empty .btn { margin-top: 14px; }

.generated {
  border: 1px solid rgba(216, 243, 106, 0.33);
  background: #0e130d;
  padding: 20px;
  margin-bottom: 22px;
}
.generated-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.generated-head h2 { color: var(--accent); }
.generated-head p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.code-list {
  list-style: none; margin: 16px 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px; background: var(--hairline);
  border: 1px solid var(--hairline);
}
.code-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--canvas);
  padding: 9px 11px;
}
.code-list code { font-family: var(--font-mono); font-size: 12.5px; color: var(--accent); letter-spacing: 0.02em; }
.icon-btn {
  width: 28px; height: 28px; display: grid; place-items: center;
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--muted);
  border-radius: var(--radius);
  transition: color 150ms ease, border-color 150ms ease, background 150ms ease;
}
.icon-btn:hover { color: var(--accent); border-color: var(--hairline-strong); background: var(--surface-2); }
.icon-btn.is-copied { color: var(--accent); border-color: var(--accent); background: rgba(216, 243, 106, 0.06); }
.icon-btn .icon { width: 14px; height: 14px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px 18px;
  align-items: end;
}
.field { display: grid; gap: 6px; min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field-label { font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.field-hint { font-size: 10.5px; color: var(--faint); }
.input {
  width: 100%; height: 38px;
  border: 1px solid var(--hairline);
  background: var(--canvas);
  color: var(--ink);
  padding: 0 10px;
  border-radius: var(--radius);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.input:hover { border-color: var(--hairline-strong); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(216, 243, 106, 0.1); }
.input::placeholder { color: var(--faint); }
select.input { padding-right: 30px; }
.input-sm { height: 32px; font-size: 12px; }
.form-actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 2px; }
.hint { color: var(--faint); font-size: 10.5px; }

.filter-bar {
  display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap;
  padding: 12px;
  border: 1px solid var(--hairline);
  background: var(--canvas);
  margin-bottom: 12px;
}
.field-inline { display: flex; align-items: center; gap: 8px; }
.field-inline .field-label { white-space: nowrap; margin: 0; }
.field-grow { flex: 1 1 240px; }
.field-grow .input { flex: 1; }

.inline-form { display: inline-flex; }

/* Login */
.login-body { display: grid; place-items: stretch; }
.login-shell {
  width: 100%; max-width: 1600px; min-height: 100vh;
  margin: 0 auto;
  display: grid; grid-template-columns: 1.08fr 0.92fr;
}
.login-brand {
  display: flex; flex-direction: column;
  padding: 54px 64px 38px;
  border-right: 1px solid var(--hairline);
  background:
    radial-gradient(700px 420px at 18% 0%, rgba(216, 243, 106, 0.08), transparent 70%),
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    var(--canvas);
  background-size: auto, 56px 56px, 56px 56px, auto;
}
.login-brand-top { display: flex; align-items: center; gap: 14px; }
.brand-mark-lg { width: 44px; height: 44px; }
.brand-mark-lg svg { width: 30px; height: 30px; }
.login-wordmark { font-size: 11.5px; line-height: 1.22; font-weight: 700; letter-spacing: 0.18em; color: var(--ink); }
.login-statement { margin-top: 18vh; max-width: 580px; }
.login-statement h1 { font-size: 48px; line-height: 1.04; letter-spacing: -0.045em; }
.login-statement p { margin: 18px 0 0; max-width: 48ch; color: var(--muted); font-size: 14px; line-height: 1.6; }
.login-status {
  margin-top: auto; padding-top: 18px;
  border-top: 1px solid var(--hairline);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  color: var(--muted); font-size: 10.5px;
}
.login-status-meta { font-family: var(--font-mono); color: var(--faint); font-size: 10px; }
.login-panel { display: grid; place-items: center; padding: 48px; background: var(--surface); }
.login-panel-inner { width: min(380px, 100%); }
.login-heading { margin-bottom: 24px; }
.login-heading h2 { font-size: 28px; letter-spacing: -0.03em; }
.login-heading p { margin: 7px 0 0; color: var(--muted); font-size: 12.5px; }
.form-stack { display: grid; gap: 14px; }
.login-foot { margin: 24px 0 0; color: var(--faint); font-size: 10.5px; line-height: 1.6; }

@media (max-width: 1180px) {
  .page { padding: 32px 32px 64px; }
  .topbar { padding: 0 32px; }
  .split-grid { grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.7fr); }
  .login-brand { padding: 44px 44px 32px; }
  .login-statement h1 { font-size: 42px; }
}

@media (max-width: 980px) {
  .shell { display: block; }
  .sidebar {
    position: static; height: auto;
    display: flex; flex-direction: column; align-items: stretch;
    gap: 12px;
    padding: 14px 20px;
    border-right: 0; border-bottom: 1px solid var(--hairline);
  }
  .brand { padding: 0; }
  .brand-mark { width: 32px; height: 32px; }
  .brand-mark svg { width: 21px; height: 21px; }
  .nav { margin: 0; display: flex; flex-wrap: wrap; gap: 2px; overflow: visible; padding-bottom: 2px; width: 100%; }
  .nav-link { padding: 7px 9px; min-height: 34px; white-space: nowrap; }
  .nav-link span { font-size: 12px; }
  .sidebar-foot { display: none; }
  .topbar { position: static; padding: 0 24px; }
  .page { padding: 28px 24px 60px; }
  .split-grid { grid-template-columns: 1fr; }
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { min-height: 46vh; border-right: 0; border-bottom: 1px solid var(--hairline); padding: 34px 24px 26px; }
  .login-statement { margin-top: 8vh; }
  .login-statement h1 { font-size: 40px; }
  .login-panel { padding: 36px 24px; }
}

@media (max-width: 900px) {
  .hide-sm { display: none; }
  .data-table-wide { min-width: 620px; }
}

@media (max-width: 720px) {
  .status-rail { grid-template-columns: 1fr 1fr; }
  .status-cell { border-bottom: 1px solid var(--hairline); }
  .status-cell:nth-child(2) { border-right: 0; }
  .status-cell:nth-child(3), .status-cell:nth-child(4) { border-bottom: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .form-actions { align-items: flex-start; flex-direction: column; gap: 10px; }
  .page-head { flex-direction: column; gap: 16px; }
  .page-head-actions { padding-top: 0; width: 100%; }
  .page-head-actions .btn { width: 100%; }
  .topbar { min-height: 0; padding: 11px 18px; flex-wrap: wrap; gap: 8px; }
  .crumb-root { display: none; }
  .crumb-sep { display: none; }
  .admin-chip { display: none; }
  .page { padding: 22px 18px 56px; }
  h1 { font-size: 30px; }
  .hide-sm { display: none; }
  .table-hint { display: block; }
  .code-list { grid-template-columns: 1fr; }
  .filter-bar { align-items: stretch; }
  .field-inline { flex: 1 1 100%; }
  .login-brand { min-height: 42vh; }
  .login-statement h1 { font-size: 34px; }
  .login-statement p { font-size: 13px; }
}

@media (max-width: 460px) {
  .status-rail { grid-template-columns: 1fr; }
  .status-cell { border-right: 0; border-bottom: 1px solid var(--hairline); }
  .status-cell:nth-child(3) { border-bottom: 1px solid var(--hairline); }
  .status-cell:last-child { border-bottom: 0; }
  .login-statement h1 { font-size: 30px; }
  .generated { padding: 15px; }
  .generated-head { flex-direction: column; }
  .generated-head .btn { width: 100%; }
}

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

/* versions page */
.field-wide { grid-column: 1 / -1; }
textarea.input {
  min-height: 88px;
  resize: vertical;
  font: inherit;
  line-height: 1.55;
}
input[type="file"].input {
  height: auto;
  padding: 10px 12px;
  cursor: pointer;
}

.action-row { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
