:root {
  color: #18201e;
  background: #f4f7f6;
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  font-synthesis: none;
  --accent: #17806f;
  --accent-dark: #0f6659;
  --border: #d7e0dd;
  --muted: #60706c;
  --surface: #fbfdfc;
  --surface-strong: #ffffff;
  --danger: #aa382f;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  background: #f4f7f6;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: .5;
}

[hidden] {
  display: none !important;
}

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

.login-view {
  display: grid;
  min-height: calc(100dvh - 100px);
  place-items: center;
}

.login-panel {
  width: min(420px, 100%);
  padding: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-strong);
  box-shadow: 0 24px 60px rgba(31, 62, 54, .09);
}

.brand {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .08em;
}

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

h1 {
  margin-bottom: 8px;
  font-size: clamp(28px, 4vw, 38px);
  line-height: 1.15;
}

h2 {
  margin-bottom: 7px;
  font-size: 19px;
}

.muted {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.stack {
  display: grid;
  gap: 10px;
  margin-top: 26px;
}

label {
  font-size: 14px;
  font-weight: 650;
}

input,
select {
  min-height: 42px;
  border: 1px solid #bbc9c5;
  border-radius: 8px;
  outline: none;
  background: var(--surface-strong);
  color: #18201e;
}

input {
  padding: 9px 12px;
}

select {
  padding: 8px 34px 8px 11px;
}

input:focus,
select:focus,
button:focus-visible {
  border-color: var(--accent);
  outline: 3px solid rgba(23, 128, 111, .18);
  outline-offset: 1px;
}

.button {
  min-height: 40px;
  padding: 8px 15px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 650;
  white-space: nowrap;
}

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

.button.primary {
  background: var(--accent);
  color: #f7fffc;
}

.button.primary:hover:not(:disabled) {
  background: var(--accent-dark);
}

.button.secondary {
  border-color: #9eb5af;
  background: var(--surface-strong);
  color: #24423b;
}

.button.quiet {
  border-color: transparent;
  background: #e8efed;
  color: #334a44;
}

.button.danger {
  border-color: #e2b8b4;
  background: #fff7f6;
  color: var(--danger);
}

.form-error {
  margin: 0;
  color: var(--danger);
  font-size: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.topbar h1 {
  margin-bottom: 0;
}

.topbar-actions,
.generated-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.notice {
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid #a9cfc6;
  border-radius: 8px;
  background: #edf8f5;
  color: #184f44;
}

.notice.error {
  border-color: #e2b8b4;
  background: #fff4f2;
  color: #842b24;
}

.summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 20px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.summary article {
  padding: 18px 22px;
}

.summary article + article {
  border-left: 1px solid var(--border);
}

.summary span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.summary strong {
  font-size: 28px;
  font-variant-numeric: tabular-nums;
}

.workspace {
  display: grid;
  gap: 20px;
}

.create-panel,
.list-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.create-panel {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 22px;
}

.generate-form {
  display: flex;
  align-items: end;
  gap: 10px;
}

.generate-form > div {
  display: grid;
  gap: 6px;
}

.generate-form input {
  width: 100px;
}

.list-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 22px;
}

.filters {
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr) auto;
  gap: 9px;
}

.table-wrap {
  overflow-x: auto;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid #e7ecea;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f5f8f7;
  color: #4d5f5a;
  font-size: 12px;
  font-weight: 700;
}

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

.mono {
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.status {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}

.status.issued {
  background: #eef3f1;
  color: #425750;
}

.status.activated {
  background: #e4f5ef;
  color: #126552;
}

.status.revoked {
  background: #fae9e7;
  color: #943129;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.row-actions .button {
  min-height: 32px;
  padding: 5px 9px;
  font-size: 12px;
}

.empty-state {
  padding: 48px 20px;
  color: var(--muted);
  text-align: center;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 14px 18px;
  color: var(--muted);
  font-size: 13px;
}

dialog {
  width: min(760px, calc(100% - 28px));
  max-height: min(720px, calc(100dvh - 32px));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-strong);
  color: #18201e;
  box-shadow: 0 28px 80px rgba(25, 52, 45, .22);
}

dialog::backdrop {
  background: rgba(18, 30, 27, .55);
}

.dialog-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px;
  border-bottom: 1px solid var(--border);
}

.generated-actions {
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
}

.generated-list {
  max-height: 480px;
  overflow: auto;
  padding: 0 22px 22px;
}

.generated-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid #e7ecea;
}

.generated-card code {
  color: #143d35;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

  .topbar,
  .create-panel,
  .list-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions .button,
  .generate-form .button {
    flex: 1;
  }

  .summary {
    grid-template-columns: 1fr;
  }

  .summary article + article {
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .generate-form,
  .filters {
    width: 100%;
  }

  .generate-form {
    align-items: stretch;
  }

  .generate-form > div {
    flex: 1;
  }

  .generate-form input {
    width: 100%;
  }

  .filters {
    grid-template-columns: 1fr;
  }

  .pagination {
    justify-content: center;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .button {
    transition: background-color .15s ease, border-color .15s ease, transform .08s ease;
  }
}
