:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e2e5ea;
  --ink: #1a1d24;
  --ink-secondary: #4b5262;
  --ink-muted: #8890a0;
  --accent: #4f6bff;
  --accent-soft: #eef1ff;
  --good: #1f9d55;
  --bad: #d94545;
  --warn: #c8850f;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  --font-display: var(--font);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--accent); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
}
.topbar .brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.topbar nav { display: flex; gap: 18px; align-items: center; }
.topbar nav a, .topbar nav button {
  color: var(--ink-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.topbar nav a.active, .topbar nav button.active { color: var(--accent); }

.shell { max-width: 1080px; margin: 0 auto; padding: 28px 24px 80px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
  margin-bottom: 18px;
}
.card h2 { margin: 0 0 4px; font-size: 15px; }
.card .sub { color: var(--ink-muted); font-size: 12.5px; margin: 0 0 16px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.stat-tile .label { color: var(--ink-muted); font-size: 12px; margin-bottom: 6px; }
.stat-tile .value { font-size: 24px; font-weight: 700; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--ink-muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .02em; padding: 8px 10px; border-bottom: 1px solid var(--border); }
td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent); color: #fff; border: none;
  padding: 9px 16px; border-radius: 8px; font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.btn:hover { opacity: .92; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: var(--surface-2); color: var(--ink); border: 1px solid var(--border); }
.btn.danger { background: #fdecec; color: var(--bad); border: 1px solid #f6c9c9; }
.btn.small { padding: 5px 10px; font-size: 12px; }

input, select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 13px;
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
}
label.field { display: block; margin-bottom: 12px; }
label.field .lbl { display: block; font-size: 12px; color: var(--ink-secondary); margin-bottom: 5px; font-weight: 600; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.badge.active { background: #e7f8ee; color: var(--good); }
.badge.unused { background: var(--accent-soft); color: var(--accent); }
.badge.revoked { background: #fdecec; color: var(--bad); }
.badge.expired { background: #fdf3e3; color: var(--warn); }
.badge.suspended { background: #fdecec; color: var(--bad); }

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.muted { color: var(--ink-muted); }
code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; font-size: 12px; font-family: ui-monospace, monospace; }

.hidden { display: none !important; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(20,22,30,.4); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal { background: var(--surface); border-radius: 14px; padding: 24px; width: 100%; max-width: 420px; max-height: 90vh; overflow-y: auto; }
.modal h3 { margin: 0 0 16px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 32px; width: 100%; max-width: 360px; }
.login-card h1 { font-size: 18px; margin: 0 0 4px; }
.login-card p.sub { color: var(--ink-muted); font-size: 13px; margin: 0 0 20px; }

.notice { font-size: 12.5px; padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; }
.notice.error { background: #fdecec; color: var(--bad); }
.notice.ok { background: #e7f8ee; color: var(--good); }

.copy-box { display: flex; gap: 8px; align-items: center; margin: 10px 0; }
.copy-box code { flex: 1; padding: 8px 10px; font-size: 12.5px; word-break: break-all; }

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 10px; }
  .shell { padding: 20px 16px 60px; }
}
