:root {
  color-scheme: light;
  --bg: #f5f4ef;
  --surface: #ffffff;
  --surface-muted: #f0f6f4;
  --text: #202421;
  --muted: #65706a;
  --line: #d9ded8;
  --primary: #0d766e;
  --primary-strong: #075e58;
  --accent: #b7791f;
  --danger: #b42318;
  --danger-bg: #fff0ed;
  --success-bg: #e8f7ee;
  --warning-bg: #fff5d6;
  --shadow: 0 18px 45px rgba(37, 44, 40, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(245, 244, 239, 0.78), rgba(245, 244, 239, 1)),
    url("data:image/svg+xml,%3Csvg width='140' height='140' viewBox='0 0 140 140' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23d2ddd8' stroke-width='1' opacity='.42'%3E%3Cpath d='M0 70h140M70 0v140'/%3E%3Ccircle cx='70' cy='70' r='28'/%3E%3C/g%3E%3C/svg%3E");
  color: var(--text);
}

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

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.user-shell {
  width: min(760px, calc(100% - 32px));
}

.brand-strip,
.toolbar,
.section-head,
.action-row,
.filter-row,
.inline-field,
.step-row {
  display: flex;
  align-items: center;
}

.brand-strip {
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 6vw, 4rem);
  line-height: 1;
}

h2 {
  margin-bottom: 18px;
  font-size: 1.1rem;
}

h3 {
  margin-bottom: 0;
  font-size: 0.95rem;
}

.ghost-link,
.primary-button,
.quiet-button,
.tab-button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 16px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.ghost-link,
.quiet-button {
  background: rgba(255, 255, 255, 0.68);
  border-color: var(--line);
  color: var(--text);
}

.primary-button {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 750;
}

.primary-button:hover {
  background: var(--primary-strong);
}

.quiet-button:hover,
.ghost-link:hover {
  border-color: var(--primary);
}

.quiet-button.danger {
  color: var(--danger);
}

.panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(217, 222, 216, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.compact-panel {
  max-width: 560px;
}

.submit-panel {
  padding: clamp(20px, 5vw, 34px);
}

.form-grid {
  display: grid;
  gap: 12px;
}

label {
  color: var(--muted);
  font-weight: 750;
}

input,
textarea,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

textarea {
  min-height: 180px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13, 118, 110, 0.14);
}

.inline-field {
  gap: 10px;
}

.inline-field input {
  flex: 1 1 auto;
}

.action-row {
  justify-content: flex-end;
  gap: 10px;
}

.message {
  min-height: 28px;
  margin-top: 18px;
  color: var(--muted);
  font-weight: 700;
}

.message.success {
  color: #14713f;
}

.message.error {
  color: var(--danger);
}

.queue-panel {
  display: grid;
  gap: 8px;
  margin-top: 22px;
  border: 1px solid rgba(13, 118, 110, 0.28);
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 18px;
}

.queue-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.queue-panel strong {
  color: var(--primary);
  font-size: 2rem;
  line-height: 1;
}

.queue-panel p {
  margin: 0;
  color: var(--text);
  font-weight: 750;
}

.queue-panel .quiet-button {
  width: fit-content;
  margin-top: 4px;
}

.hidden {
  display: none !important;
}

.step-row {
  gap: 8px;
  margin-bottom: 28px;
}

.step {
  flex: 1 1 0;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  padding: 10px;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 800;
}

.step.active {
  border-color: var(--primary);
  background: var(--surface-muted);
  color: var(--primary);
}

.step.done {
  border-color: rgba(20, 113, 63, 0.35);
  background: var(--success-bg);
  color: #14713f;
}

.toolbar {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.tab-group {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.tab-button {
  background: transparent;
  color: var(--muted);
}

.tab-button.active {
  background: var(--primary);
  color: #fff;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat-tile {
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  padding: 16px;
}

.stat-tile strong {
  display: block;
  margin-top: 8px;
  font-size: 1.8rem;
  line-height: 1;
}

.stat-tile span {
  color: var(--muted);
  font-weight: 750;
}

.split-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.82fr) minmax(420px, 1.5fr);
  gap: 18px;
  align-items: start;
}

.field-row {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.generated-box {
  margin-top: 20px;
}

.generated-box textarea {
  margin-top: 12px;
  min-height: 150px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.section-head {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.section-head h2,
.section-head h3 {
  margin: 0;
}

.filter-row {
  gap: 10px;
  margin-bottom: 14px;
}

.filter-row select {
  max-width: 132px;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  background: #fff;
}

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

th {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

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

.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.9rem;
}

.status-pill {
  display: inline-flex;
  min-width: 72px;
  justify-content: center;
  border-radius: 999px;
  padding: 5px 10px;
  background: var(--surface-muted);
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 850;
}

.status-pill.used {
  background: var(--success-bg);
  color: #14713f;
}

.status-pill.revoked {
  background: var(--danger-bg);
  color: var(--danger);
}

.status-pill.expired {
  background: var(--warning-bg);
  color: var(--accent);
}

.process-pill {
  display: inline-flex;
  min-width: 72px;
  justify-content: center;
  border-radius: 999px;
  padding: 5px 10px;
  background: var(--warning-bg);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 850;
}

.process-pill.activated {
  background: var(--success-bg);
  color: #14713f;
}

.session-content {
  max-width: 520px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: min(360px, calc(100vw - 48px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 14px 16px;
  color: var(--text);
  font-weight: 750;
}

.empty-row {
  color: var(--muted);
  text-align: center;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
  color: var(--muted);
  font-weight: 750;
}

.pager .quiet-button {
  min-height: 36px;
}

@media (max-width: 900px) {
  .stats-grid,
  .split-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  .brand-strip,
  .toolbar,
  .inline-field,
  .action-row,
  .filter-row {
    align-items: stretch;
    flex-direction: column;
  }

  .brand-strip {
    gap: 14px;
  }

  .ghost-link,
  .primary-button,
  .quiet-button,
  .queue-panel .quiet-button {
    width: 100%;
  }

  .pager {
    align-items: stretch;
    flex-direction: column;
  }

  .panel {
    padding: 16px;
  }

  .step-row {
    align-items: stretch;
  }

  .step {
    font-size: 0.78rem;
    padding: 9px 6px;
  }

  .field-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .filter-row select {
    max-width: none;
  }
}
