:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --line: #d9dee7;
  --text: #151922;
  --muted: #667085;
  --blue: #1f6feb;
  --blue-dark: #174ea6;
  --green: #16825d;
  --red: #d92d20;
  --shadow: 0 8px 26px rgba(17, 24, 39, .08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(10px);
}

h1, h2, p {
  margin: 0;
}

h1 {
  font-size: 20px;
  font-weight: 650;
}

h2 {
  margin-bottom: 14px;
  font-size: 16px;
  font-weight: 650;
}

p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  background: var(--blue);
  color: #fff;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

button:hover {
  background: var(--blue-dark);
}

button.secondary {
  background: #eef2f8;
  color: var(--text);
}

button.danger {
  background: var(--red);
}

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: clamp(16px, 3vw, 32px);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 18px;
}

.login-panel {
  max-width: 420px;
  margin: 64px auto;
}

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

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 12px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

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

.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.span-2 {
  grid-column: span 2;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--text);
  font: inherit;
  background: #fff;
}

.table-wrap {
  overflow: auto;
  max-height: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
  font-size: 13px;
}

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

th {
  position: sticky;
  top: 0;
  background: #f0f3f8;
  color: #374151;
  font-weight: 650;
}

.status {
  display: inline-flex;
  align-items: center;
  height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  background: #eef2f8;
  color: #334155;
}

.status.active {
  background: #e7f6ef;
  color: var(--green);
}

.status.revoked,
.status.disabled,
.status.expired {
  background: #fff1f0;
  color: var(--red);
}

.new-code {
  margin-top: 14px;
  border: 1px solid #b7d6ff;
  border-radius: 8px;
  background: #eef6ff;
  padding: 12px;
  word-break: break-all;
}

.new-code strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  border-radius: 8px;
  padding: 12px 14px;
  background: #111827;
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 14px;
}

.hidden {
  display: none !important;
}

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

  .span-2 {
    grid-column: auto;
  }
}
