:root {
  color-scheme: dark;
  --bg: #0b0b0d;
  --bg-elevated: #121215;
  --panel: #151519;
  --panel-raise: #1b1b20;
  --panel-inset: #0e0e11;
  --line: rgba(238, 232, 221, 0.095);
  --line-strong: rgba(238, 232, 221, 0.18);
  --line-hover: rgba(238, 232, 221, 0.28);
  --ivory: #f2f0ec;
  --ivory-soft: rgba(242, 240, 236, 0.68);
  --muted: rgba(242, 240, 236, 0.48);
  --faint: rgba(242, 240, 236, 0.34);
  --tally: #ff5a36;
  --tally-deep: #e64827;
  --tally-soft: rgba(255, 90, 54, 0.13);
  --tally-line: rgba(255, 90, 54, 0.34);
  --ok: #5fd39a;
  --ok-soft: rgba(95, 211, 154, 0.11);
  --ok-line: rgba(95, 211, 154, 0.3);
  --amber: #e3b26a;
  --amber-soft: rgba(227, 178, 106, 0.1);
  --amber-line: rgba(227, 178, 106, 0.28);
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --shadow-card: 0 22px 48px -28px rgba(0, 0, 0, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.045);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--ivory);
  background:
    radial-gradient(ellipse 68% 42% at 16% -6%, rgba(255, 90, 54, 0.095), transparent 62%),
    radial-gradient(ellipse 52% 36% at 86% 6%, rgba(238, 232, 221, 0.055), transparent 60%),
    linear-gradient(180deg, #0d0d10 0%, #0a0a0c 52%, #09090b 100%);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: var(--grain);
  opacity: 0.028;
  z-index: 0;
}

/* Clapperboard hairline bar crowning the viewport */
.slate-rail {
  height: 4px;
  width: 100%;
  background: repeating-linear-gradient(
    -52deg,
    rgba(238, 232, 221, 0.22) 0 14px,
    rgba(20, 20, 24, 0.9) 14px 28px
  );
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  position: relative;
  z-index: 2;
}

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 16px max(28px, calc((100vw - 1120px) / 2));
  display: flex;
  align-items: center;
  gap: 18px;
  background: rgba(11, 11, 13, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ivory);
  text-decoration: none;
  flex-shrink: 0;
}

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: block;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}

.wordmark {
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--ivory);
  text-decoration: none;
  font-size: 16px;
  line-height: 1;
}

.wordmark span {
  color: var(--tally);
  font-size: 12px;
  vertical-align: 1px;
  margin: 0 1px;
}

.top-divider {
  width: 1px;
  height: 16px;
  background: var(--line-strong);
  flex-shrink: 0;
}

.top-sub {
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.top-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.025);
  color: var(--ivory);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: border-color 0.16s, background 0.16s, color 0.16s;
}

.top-link:hover {
  border-color: var(--line-hover);
  background: var(--panel-raise);
  color: var(--ivory);
}

a {
  color: #ff8668;
  text-underline-offset: 4px;
  transition: color 0.15s;
}

a:hover {
  color: #ffab95;
}

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

main {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  padding: 52px 28px 64px;
}

/* Hero Slate Header */
.intro {
  max-width: 760px;
  margin-bottom: 38px;
}

.slate-tag {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 18px;
}

.tally-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--tally);
  box-shadow: 0 0 12px rgba(255, 90, 54, 0.85);
  flex-shrink: 0;
}

.eyebrow {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  margin: 0 0 10px;
}

.step-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--tally);
  background: var(--tally-soft);
  border: 1px solid var(--tally-line);
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 14px;
}

.step-badge.subtle {
  color: var(--ivory-soft);
  background: rgba(242, 240, 236, 0.05);
  border-color: var(--line-strong);
}

h1 {
  font-size: clamp(32px, 4.4vw, 52px);
  line-height: 1.18;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 16px;
  color: var(--ivory);
}

h1 span {
  color: var(--tally);
}

.lead {
  color: var(--ivory-soft);
  font-size: 15px;
  line-height: 1.75;
  margin: 0 0 22px;
  max-width: 580px;
}

.promise-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
}

.promise-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--ivory-soft);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  padding: 5px 12px;
  border-radius: 999px;
}

.promise-pill strong {
  color: var(--ivory);
  font-weight: 600;
}

p {
  color: var(--ivory-soft);
  font-size: 13.5px;
  margin: 10px 0;
}

h2 {
  font-size: 21px;
  line-height: 1.35;
  font-weight: 650;
  letter-spacing: -0.015em;
  margin: 0 0 12px;
  color: var(--ivory);
}

h3 {
  font-size: 15.5px;
  font-weight: 600;
  margin: 26px 0 12px;
  color: var(--ivory);
}

h4 {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ivory-soft);
}

/* Surfaces */
.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.022) 0%, rgba(255, 255, 255, 0) 48%), var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 28px 30px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-card);
  position: relative;
}

.card-accent {
  overflow: hidden;
}

.card-accent::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--tally) 0%, rgba(255, 90, 54, 0.25) 42%, transparent 100%);
}

/* Auth Split Stage */
.auth {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: 56px;
  padding: 36px 38px;
  align-items: start;
}

.auth-copy {
  padding-top: 4px;
}

.auth-copy h2 {
  font-size: 26px;
  margin-bottom: 12px;
}

.slate-notes {
  margin: 26px 0 0;
  padding: 18px 0 0;
  border-top: 1px solid var(--line);
  list-style: none;
  display: grid;
  gap: 11px;
}

.slate-notes li {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: baseline;
  font-size: 13px;
  color: var(--muted);
}

.slate-notes .idx {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--tally);
  letter-spacing: 0.06em;
}

.slate-notes strong {
  color: var(--ivory);
  font-weight: 600;
}

.auth-forms {
  background: var(--panel-inset);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 26px;
}

/* Account Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  margin-bottom: 22px;
}

.grid .card {
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
}

.grid .card .muted:last-child {
  margin-top: auto;
  padding-top: 12px;
}

/* Form Controls */
label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ivory-soft);
  margin-bottom: 16px;
  letter-spacing: 0.01em;
}

input,
textarea {
  display: block;
  width: 100%;
  border: 1px solid var(--line-strong);
  background: #0b0b0e;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  margin-top: 7px;
  color: var(--ivory);
  font: inherit;
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

input::placeholder,
textarea::placeholder {
  color: var(--faint);
}

input:hover,
textarea:hover {
  border-color: var(--line-hover);
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--tally);
  box-shadow: 0 0 0 3px rgba(255, 90, 54, 0.18);
  background: #0d0d11;
}

/* Buttons */
button {
  background: var(--ivory);
  color: #0c0c0e;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  min-height: 42px;
  padding: 10px 18px;
  cursor: pointer;
  letter-spacing: 0.01em;
  transition: background 0.16s, color 0.16s, border-color 0.16s, transform 0.12s;
}

button:hover:not(:disabled) {
  background: var(--tally);
  color: #ffffff;
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.45;
  cursor: default;
}

.secondary {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--line-strong);
  color: var(--ivory);
}

.secondary:hover:not(:disabled) {
  background: var(--panel-raise);
  border-color: var(--tally);
  color: var(--ivory);
}

.text-button {
  background: none;
  color: var(--ivory-soft);
  padding: 8px 4px;
  min-height: 36px;
  font-weight: 500;
}

.text-button:hover:not(:disabled) {
  background: none;
  color: var(--tally);
}

small {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  margin: -6px 0 16px;
}

/* Account Top Bar */
.account-bar,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.account-bar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px 26px;
  margin: 0 0 22px;
  box-shadow: var(--shadow-card);
}

.account-identity {
  display: flex;
  align-items: center;
  gap: 14px;
}

.account-badge {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--tally-soft);
  border: 1px solid var(--tally-line);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.account-bar .eyebrow {
  margin-bottom: 3px;
}

.account-bar h2 {
  margin: 0;
  font-size: 20px;
}

.muted {
  font-size: 12.5px;
  color: var(--muted);
}

.source-hint {
  font-size: 12.5px;
  color: var(--ivory-soft);
  background: rgba(255, 255, 255, 0.028);
  border: 1px solid var(--line);
  border-left: 2px solid var(--tally);
  border-radius: 0 8px 8px 0;
  padding: 10px 14px;
  margin: 8px 0 18px;
  line-height: 1.6;
}

.source-hint strong {
  color: var(--ivory);
  font-weight: 600;
}

/* License Pass Key-Value Grid */
#license-state {
  font-size: 22px;
  margin-bottom: 4px;
}

dl {
  margin: 18px 0;
  display: grid;
  grid-template-columns: 112px 1fr;
  font-size: 13px;
  gap: 10px 14px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  color: var(--ivory);
  font-variant-numeric: tabular-nums;
}

/* Inline Forms */
.inline-form {
  display: flex;
  align-items: end;
  gap: 12px;
  max-width: 560px;
}

.inline-form label {
  margin: 0;
  flex: 1;
}

.inline-form button {
  margin-bottom: 0;
  flex-shrink: 0;
}

/* List Rows */
.row {
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.row:last-child {
  border-bottom: 0;
  padding-bottom: 4px;
}

.row strong {
  font-size: 14px;
  color: var(--ivory);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.row small {
  margin: 4px 0 0;
  color: var(--muted);
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.row > div {
  min-width: 0;
}

.row button {
  flex-shrink: 0;
}

/* Status Banner */
#notice {
  border: 1px solid var(--ok-line);
  background: var(--ok-soft);
  color: #cdf5df;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 22px;
  font-size: 13.5px;
  overflow-wrap: anywhere;
}

#notice.error {
  background: var(--tally-soft);
  border-color: var(--tally-line);
  color: #ffc2b3;
}

#device-count {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--tally);
  font-weight: 600;
  background: var(--tally-soft);
  border: 1px solid var(--tally-line);
  padding: 2px 9px;
  border-radius: 999px;
  margin-left: 8px;
  vertical-align: 2px;
}

#pair-review {
  margin-top: 18px;
  padding: 20px;
  background: var(--panel-inset);
  border: 1px solid var(--tally-line);
  border-radius: var(--radius-md);
}

#pair-device {
  color: var(--ivory);
  margin-top: 0;
  margin-bottom: 14px;
}

/* Admin Console Surface */
#admin-panel {
  border-color: var(--amber-line);
  background:
    radial-gradient(ellipse 65% 24% at 12% 0%, rgba(227, 178, 106, 0.08), transparent 65%),
    var(--panel);
  overflow: hidden;
}

#admin-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--amber) 0%, rgba(227, 178, 106, 0.2) 55%, transparent 100%);
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.admin-header h2 {
  margin: 0;
}

.admin-chip {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--amber);
  background: var(--amber-soft);
  border: 1px solid var(--amber-line);
  padding: 4px 10px;
  border-radius: 999px;
  flex-shrink: 0;
}

.issuance-fields {
  min-inline-size: 0;
  margin: 0;
  border: 0;
  padding: 0;
}

.issuance-fields legend {
  padding: 0;
  font-size: 15.5px;
  font-weight: 650;
  color: var(--ivory);
}

.batch-fields {
  display: grid;
  grid-template-columns: minmax(96px, 0.45fr) minmax(0, 1fr) minmax(0, 1.5fr);
  gap: 14px;
  margin-top: 12px;
}

#new-card {
  background: var(--panel-inset);
  border: 1px solid var(--amber-line);
  padding: 22px;
  border-radius: var(--radius-md);
  margin-top: 22px;
}

#new-card h3,
#admin-user-detail h3 {
  margin-top: 0;
}

#card-output {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  letter-spacing: 0.04em;
  resize: vertical;
  margin-bottom: 16px;
  background: #08080a;
  color: #f6e7cb;
  border-color: var(--amber-line);
}

.actions,
nav[aria-label] {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
}

nav[aria-label]:not(:empty) {
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--muted);
}

.admin-section {
  border-top: 1px solid var(--line);
  margin-top: 28px;
  padding-top: 4px;
}

#admin-user-detail {
  background: var(--panel-inset);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-top: 18px;
}

#admin-user-detail h4 {
  margin: 18px 0 4px;
}

#admin-user-meta,
#card-output-info {
  overflow-wrap: anywhere;
}

.error-text {
  color: #ff9c85;
}

/* Bottom Activation Guide */
.help {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 32px;
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 36px;
}

.help h3 {
  margin-top: 0;
  font-size: 15px;
}

ol {
  padding-inline-start: 20px;
  font-size: 13.5px;
  color: var(--ivory-soft);
  margin: 10px 0;
}

ol li + li {
  margin-top: 8px;
}

ol li::marker {
  color: var(--tally);
  font-family: var(--mono);
  font-weight: 600;
}

.help p,
.help ol {
  font-size: 13px;
}

.guide-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0;
}

.guide-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ivory);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 500;
}

.guide-chip:hover {
  border-color: var(--tally);
  color: var(--ivory);
  background: var(--panel-raise);
}

/* Footer */
footer {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 28px 46px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--faint);
  font-size: 12px;
}

footer .wordmark {
  font-size: 13px;
  letter-spacing: 0.16em;
  color: var(--muted);
}

footer > span:last-child {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
}

/* 404 center frame */
.error-stage {
  max-width: 560px;
  margin: 72px auto;
  text-align: left;
}

[hidden] {
  display: none !important;
}

@media (max-width: 860px) {
  .auth {
    grid-template-columns: 1fr;
    gap: 28px;
    padding: 26px;
  }
  .grid,
  .help {
    grid-template-columns: 1fr;
    gap: 18px;
  }
}

@media (max-width: 640px) {
  .top {
    padding: 14px 18px;
    gap: 10px;
  }
  .top-divider,
  .top-sub {
    display: none;
  }
  .brand-logo {
    width: 28px;
    height: 28px;
  }
  .wordmark {
    font-size: 15px;
  }
  main {
    padding: 32px 18px 48px;
  }
  .card {
    padding: 22px 20px;
  }
  .auth {
    padding: 22px 18px;
  }
  .auth-forms {
    padding: 20px 16px;
  }
  .account-bar {
    padding: 16px 18px;
    flex-wrap: wrap;
  }
  .batch-fields {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .row {
    align-items: start;
    gap: 12px;
  }
  .row button {
    padding: 8px 12px;
  }
  .section-heading,
  .admin-header {
    align-items: start;
    flex-wrap: wrap;
  }
  .inline-form {
    flex-wrap: wrap;
  }
  .inline-form label {
    flex-basis: 100%;
  }
  footer {
    padding: 20px 18px 36px;
    flex-wrap: wrap;
    gap: 8px 16px;
  }
  footer > span:last-child {
    margin-left: 0;
    flex-basis: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
