:root {
  --bg: #080a0e;
  --panel: rgba(19, 22, 29, 0.88);
  --panel-strong: #171b23;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f7f7f2;
  --muted: #9198a5;
  --accent: #c8ff3d;
  --accent-ink: #101408;
  --danger: #ff6b6b;
  --warning: #f7c65d;
  --radius: 22px;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
  font-family:
    Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 84% -20%, rgba(200, 255, 61, 0.13), transparent 34%),
    radial-gradient(circle at -10% 35%, rgba(89, 111, 255, 0.08), transparent 30%),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.noise {
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.18;
  pointer-events: none;
  background-image: radial-gradient(
    circle at center,
    rgba(255, 255, 255, 0.12) 0.55px,
    transparent 0.7px
  );
  background-size: 5px 5px;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 28px;
}

.login-card {
  width: min(100%, 430px);
  padding: 44px;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: linear-gradient(145deg, rgba(28, 32, 41, 0.95), rgba(14, 16, 21, 0.96));
  box-shadow: var(--shadow);
}

.brand-mark {
  display: grid;
  width: 52px;
  height: 52px;
  margin-bottom: 32px;
  place-items: center;
  border-radius: 16px;
  color: var(--accent-ink);
  font-size: 22px;
  font-weight: 900;
  background: var(--accent);
  box-shadow: 0 0 42px rgba(200, 255, 61, 0.18);
}

.brand-mark.small {
  width: 38px;
  height: 38px;
  margin: 0;
  border-radius: 12px;
  font-size: 16px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

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

.login-card h1 {
  margin-bottom: 12px;
  font-size: clamp(36px, 8vw, 54px);
  line-height: 1;
  letter-spacing: -0.055em;
}

.login-copy,
.hero-copy,
.security-note {
  color: var(--muted);
  line-height: 1.7;
}

.login-card form {
  display: grid;
  gap: 12px;
  margin-top: 30px;
}

label {
  display: grid;
  gap: 8px;
  color: #c7cbd2;
  font-size: 13px;
  font-weight: 650;
}

input,
select {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  color: var(--text);
  background: rgba(255, 255, 255, 0.045);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

input:focus,
select:focus {
  border-color: rgba(200, 255, 61, 0.58);
  background: rgba(255, 255, 255, 0.065);
  box-shadow: 0 0 0 3px rgba(200, 255, 61, 0.1);
}

.primary-button,
.ghost-button,
.text-button,
.icon-button {
  border: 0;
  color: inherit;
}

.primary-button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 18px;
  border-radius: 13px;
  color: var(--accent-ink);
  font-weight: 850;
  background: var(--accent);
  transition:
    transform 160ms ease,
    filter 160ms ease;
}

.primary-button:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.primary-button:active {
  transform: translateY(0);
}

.full-width {
  width: 100%;
}

.security-note {
  margin: 24px 0 0;
  font-size: 12px;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  min-height: 74px;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(24px, calc((100vw - 1280px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(8, 10, 14, 0.82);
  backdrop-filter: blur(22px);
}

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

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 14px;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.system-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: 6px;
  color: var(--muted);
  font-size: 12px;
}

.system-state i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 14px var(--accent);
}

.ghost-button,
.text-button,
.icon-button {
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.035);
}

.ghost-button:hover,
.icon-button:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.07);
}

.text-button {
  padding: 0;
  border: 0;
  color: var(--accent);
  background: none;
}

.danger-text {
  color: #ff9c9c;
}

main {
  width: min(calc(100% - 48px), 1280px);
  margin: 0 auto;
  padding: 76px 0 100px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 40px;
  margin-bottom: 48px;
}

.hero h1 {
  max-width: 720px;
  margin-bottom: 20px;
  font-size: clamp(46px, 7vw, 88px);
  line-height: 0.96;
  letter-spacing: -0.065em;
}

.hero h1 span {
  color: var(--muted);
}

.hero-copy {
  max-width: 620px;
  margin-bottom: 0;
}

.hero-action {
  min-width: 190px;
}

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

.stat-card,
.panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.16);
  backdrop-filter: blur(14px);
}

.stat-card {
  min-height: 164px;
  padding: 22px;
  border-radius: 18px;
}

.stat-card.accent {
  color: var(--accent-ink);
  border-color: transparent;
  background: var(--accent);
}

.stat-card span,
.stat-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stat-card.accent span,
.stat-card.accent small {
  color: rgba(16, 20, 8, 0.65);
}

.stat-card strong {
  display: block;
  margin: 18px 0 10px;
  font-size: 42px;
  line-height: 1;
  letter-spacing: -0.055em;
}

.panel {
  border-radius: var(--radius);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.generate-panel,
.activity-panel {
  min-height: 460px;
  padding: 28px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
}

.panel-heading h2 {
  margin-bottom: 0;
  font-size: 24px;
  letter-spacing: -0.035em;
}

.privacy-pill {
  padding: 7px 10px;
  border: 1px solid rgba(200, 255, 61, 0.22);
  border-radius: 999px;
  color: var(--accent);
  font-size: 11px;
  background: rgba(200, 255, 61, 0.07);
}

.generate-form {
  display: grid;
  gap: 18px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.audit-list {
  display: grid;
  max-height: 355px;
  gap: 2px;
  overflow: auto;
}

.audit-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 13px 8px;
  border-bottom: 1px solid var(--line);
}

.audit-icon {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 10px;
  color: var(--accent);
  font-size: 13px;
  background: rgba(200, 255, 61, 0.08);
}

.audit-item strong,
.audit-item small {
  display: block;
}

.audit-item strong {
  margin-bottom: 4px;
  font-size: 13px;
}

.audit-item small,
.audit-time {
  color: var(--muted);
  font-size: 11px;
}

.cards-panel {
  padding: 28px 28px 12px;
}

.cards-heading {
  align-items: end;
}

.filters {
  display: flex;
  min-width: min(100%, 500px);
  gap: 10px;
}

.search-field {
  flex: 1;
}

.filters select {
  min-width: 126px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 16px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

td {
  font-size: 13px;
}

.key-cell strong,
.key-cell small,
.app-cell strong,
.app-cell small {
  display: block;
}

.key-cell strong {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

.key-cell small,
.app-cell small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  background: rgba(255, 255, 255, 0.06);
}

.status-badge::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.status-active {
  color: var(--accent);
  background: rgba(200, 255, 61, 0.08);
}

.status-disabled {
  color: var(--warning);
  background: rgba(247, 198, 93, 0.08);
}

.status-revoked,
.status-expired {
  color: #ff8b8b;
  background: rgba(255, 107, 107, 0.08);
}

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

.row-action {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #c8cdd5;
  font-size: 11px;
  background: transparent;
}

.row-action:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.table-footer {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

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

.generated-dialog {
  width: min(calc(100% - 32px), 720px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 24px;
  color: var(--text);
  background: #14171e;
  box-shadow: var(--shadow);
}

.generated-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  padding: 28px 28px 18px;
}

.dialog-header h2 {
  margin-bottom: 7px;
  font-size: 30px;
}

.dialog-header p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
}

.icon-button {
  width: 38px;
  height: 38px;
  padding: 0;
  font-size: 22px;
}

.one-time-warning {
  margin: 0 28px 16px;
  padding: 12px 14px;
  border: 1px solid rgba(247, 198, 93, 0.2);
  border-radius: 12px;
  color: #f9d98d;
  font-size: 12px;
  background: rgba(247, 198, 93, 0.06);
}

#generatedKeys {
  max-height: 340px;
  margin: 0 28px;
  padding: 18px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: #e7fcb1;
  font: 12px/1.8 "SFMono-Regular", Consolas, monospace;
  background: #0a0c10;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 20px 28px 28px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 30;
  max-width: min(360px, calc(100vw - 48px));
  padding: 13px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  opacity: 0;
  color: var(--text);
  background: #222731;
  box-shadow: var(--shadow);
  pointer-events: none;
  transform: translateY(12px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  border-color: rgba(255, 107, 107, 0.35);
}

.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: 980px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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

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

  .hero-action {
    width: fit-content;
  }
}

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

  .system-state,
  #refreshButton {
    display: none;
  }

  main {
    width: min(calc(100% - 28px), 1280px);
    padding-top: 48px;
  }

  .hero h1 {
    font-size: 48px;
  }

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

  .stat-card {
    min-height: 140px;
    padding: 18px;
  }

  .stat-card strong {
    font-size: 34px;
  }

  .generate-panel,
  .activity-panel,
  .cards-panel {
    padding: 20px;
  }

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

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

  .filters {
    min-width: 0;
    flex-direction: column;
  }

  .login-card {
    padding: 30px 24px;
  }
}
