:root {
  --bg: #fafaf7;
  --panel: #ffffff;
  --ink: #171717;
  --muted: #65625c;
  --faint: #918d84;
  --line: rgba(23, 23, 23, .11);
  --line-strong: rgba(23, 23, 23, .2);
  --accent: #315f54;
  --accent-2: #8f433b;
  --warm: #ece2cc;
  --shadow: 0 24px 80px rgba(23, 23, 23, .14);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

/* Component rules below use display:flex/grid. Keep the HTML hidden attribute
   authoritative so unauthenticated sections cannot be exposed by them. */
[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
}

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

button,
input,
select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(250, 250, 247, .88);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 680;
}

.brand img {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

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

.nav a,
.pill-button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
  border-radius: 7px;
  color: var(--muted);
  border: 1px solid transparent;
}

.nav a:hover {
  color: var(--ink);
  background: rgba(23, 23, 23, .05);
}

.pill-button {
  color: #fff;
  background: var(--ink);
  border-color: var(--ink);
  font-weight: 620;
}

.pill-button.secondary {
  color: var(--ink);
  background: transparent;
  border-color: var(--line-strong);
}

.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 680;
  cursor: pointer;
}

.text-button:hover {
  color: var(--ink);
}

.hero {
  min-height: calc(100vh - 64px);
  display: grid;
  align-items: end;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(250,250,247,.22), rgba(250,250,247,.9) 74%, var(--bg)),
    url("./assets/icon.svg") center 18% / min(58vw, 620px) no-repeat,
    var(--warm);
}

.hero-inner {
  width: min(1120px, calc(100vw - 48px));
  margin: 0 auto;
  padding: 96px 0 56px;
  display: grid;
  gap: 28px;
}

.hero-copy {
  max-width: 720px;
  display: grid;
  gap: 18px;
}

.eyebrow {
  color: var(--accent);
  font-size: 13px;
  font-weight: 760;
}

h1 {
  margin: 0;
  font-size: clamp(48px, 9vw, 112px);
  line-height: .92;
  font-weight: 760;
}

.hero-copy p {
  margin: 0;
  max-width: 620px;
  color: var(--muted);
  font-size: clamp(17px, 2vw, 22px);
  line-height: 1.55;
}

.hero-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.app-preview {
  min-height: 270px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-rows: 42px 1fr;
}

.preview-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  color: var(--faint);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #e46f61;
}

.dot:nth-child(2) {
  background: #e4b152;
}

.dot:nth-child(3) {
  background: #5ab66a;
}

.preview-body {
  display: grid;
  grid-template-columns: 240px 1fr 1fr;
  min-height: 260px;
}

.preview-sidebar {
  border-right: 1px solid var(--line);
  padding: 16px;
  display: grid;
  align-content: start;
  gap: 10px;
  background: #f5f1e8;
}

.preview-row {
  height: 28px;
  border-radius: 6px;
  background: rgba(23, 23, 23, .06);
}

.preview-row.active {
  background: rgba(49, 95, 84, .18);
}

.preview-editor,
.preview-render {
  padding: 22px;
  display: grid;
  align-content: start;
  gap: 12px;
}

.preview-editor {
  border-right: 1px solid var(--line);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #4b4945;
}

.line {
  height: 11px;
  border-radius: 999px;
  background: rgba(23, 23, 23, .1);
}

.line.short {
  width: 62%;
}

.preview-render h3 {
  margin: 0;
  font-size: 26px;
}

.preview-render p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.section {
  width: min(1120px, calc(100vw - 48px));
  margin: 0 auto;
  padding: 72px 0;
}

.section-header {
  display: grid;
  gap: 10px;
  max-width: 680px;
  margin-bottom: 28px;
}

.section-header h2 {
  margin: 0;
  font-size: 34px;
}

.section-header p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.feature-grid,
.pricing-grid,
.admin-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.feature,
.price,
.metric,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 18px;
}

.feature h3,
.price h3,
.panel h3 {
  margin: 0 0 8px;
  font-size: 17px;
}

.feature p,
.price p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.price {
  display: grid;
  gap: 14px;
}

.amount {
  font-size: 34px;
  font-weight: 760;
}

.amount span {
  color: var(--faint);
  font-size: 14px;
  font-weight: 560;
}

.steps {
  display: grid;
  gap: 10px;
  counter-reset: step;
}

.step {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 12px;
  align-items: start;
}

.step::before {
  counter-increment: step;
  content: counter(step);
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-weight: 720;
  font-size: 13px;
}

.step strong {
  display: block;
  margin-bottom: 3px;
}

.step span {
  color: var(--muted);
  line-height: 1.5;
}

.footer {
  border-top: 1px solid var(--line);
  padding: 28px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.admin-shell {
  min-height: calc(100vh - 64px);
  width: min(1280px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.admin-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.admin-title h1 {
  font-size: 34px;
  line-height: 1.1;
}

.admin-title p {
  margin: 8px 0 0;
  color: var(--muted);
}

.upload-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  margin-bottom: 16px;
}

.code-generator {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
}

.code-generator p {
  margin: 0;
}

.generator-form {
  display: grid;
  grid-template-columns: 110px minmax(160px, 1fr) 110px 110px auto;
  gap: 10px;
  align-items: end;
}

.generator-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
}

.generator-form input {
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 10px;
}

.generated-codes {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f5f1e8;
  overflow: hidden;
}

.generated-header {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
}

.generated-codes pre {
  margin: 0;
  max-height: 220px;
  overflow: auto;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.file-input {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.metric {
  display: grid;
  gap: 6px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  font-size: 30px;
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
}

.search {
  flex: 1;
  min-width: 220px;
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 12px;
}

.select {
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 10px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
  line-height: 1.55;
}

th {
  color: var(--muted);
  font-weight: 680;
  background: #f5f1e8;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.expand-col {
  width: 34px;
}

.expand-cell {
  width: 34px;
  color: var(--muted);
  vertical-align: middle;
}

.summary-row {
  cursor: pointer;
}

.summary-row td {
  vertical-align: middle;
}

.summary-row:hover {
  background: rgba(49, 95, 84, .05);
}

.summary-row.open {
  background: rgba(49, 95, 84, .07);
}

.summary-row.open td {
  border-bottom-color: transparent;
}

.caret {
  display: inline-block;
  transition: transform .15s ease;
  font-size: 11px;
}

.summary-row.open .caret {
  transform: rotate(90deg);
}

.note-dot {
  color: var(--accent);
  font-weight: 800;
}

.detail-row > td {
  padding: 0 14px 16px;
  background: rgba(49, 95, 84, .04);
}

.detail-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 4px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px 24px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detail-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  font-weight: 680;
}

.detail-value {
  font-size: 13px;
}

.detail-section h4 {
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
}

.note-input {
  width: 100%;
  max-width: 520px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  font: inherit;
  font-size: 13px;
  resize: vertical;
}

.date-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.date-field input {
  width: auto;
}

.text-button.danger {
  color: var(--accent-2);
}

.text-button.danger:hover {
  color: #7a1f1a;
}

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 12px 0 4px;
}

.pager-info {
  font-size: 13px;
  color: var(--muted);
}

.pager .pill-button[disabled] {
  opacity: .4;
  cursor: not-allowed;
}

.lock-notice p {
  margin: 0;
}

.reconcile-result {
  flex-basis: 100%;
  margin: 4px 0 0;
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  max-width: min(420px, calc(100vw - 40px));
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(23, 23, 23, .25);
}

.toast.error {
  background: #b42318;
  border-color: #b42318;
}

.device-binding {
  padding: 6px 0;
}

.device-binding + .device-binding {
  border-top: 1px solid var(--line);
}

.device-binding-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.device-binding.revoked code {
  color: var(--muted);
  text-decoration: line-through;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.copy-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  white-space: nowrap;
}

.copy-field code {
  overflow: hidden;
  text-overflow: ellipsis;
}

.copy-button {
  flex: none;
  padding: 1px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 680;
  line-height: 1.6;
  cursor: pointer;
}

.copy-button:hover {
  color: var(--ink);
  border-color: var(--ink);
}

.copy-button.copied {
  color: var(--accent);
  border-color: var(--accent);
}

.action-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  white-space: nowrap;
}

.action-stack .text-button {
  min-height: 24px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(49, 95, 84, .12);
  color: var(--accent);
  font-weight: 680;
  font-size: 12px;
}

.status-pill.unused {
  color: var(--faint);
  background: rgba(23, 23, 23, .06);
}

.status-pill.full {
  color: var(--accent-2);
  background: rgba(143, 67, 59, .12);
}

.status-pill.disabled {
  color: #7a4a00;
  background: rgba(228, 177, 82, .2);
}

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

@media (max-width: 820px) {
  .topbar {
    padding: 0 16px;
  }

  .nav a:not(.pill-button) {
    display: none;
  }

  .hero-inner,
  .section {
    width: min(100vw - 32px, 1120px);
  }

  .preview-body,
  .feature-grid,
  .pricing-grid,
  .admin-grid,
  .generator-form {
    grid-template-columns: 1fr;
  }

  .preview-sidebar {
    display: none;
  }
}
