:root {
  --bg: #0b0d12;
  --panel: #151820;
  --panel-2: #1b1f29;
  --line: #262b38;
  --text: #f4f6fb;
  --muted: #aab1c2;
  --accent: #ff0055;
  --accent-2: #ff4d85;
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 600px at 70% -10%, #24101a 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  font-size: 14px;
  min-height: 100vh;
}
a { color: var(--accent-2); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

/* login */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card {
  width: 380px; background: linear-gradient(180deg, #191d27, #12141b);
  border: 1px solid var(--line); border-radius: 16px; padding: 32px;
  box-shadow: 0 30px 80px rgba(0,0,0,.45);
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #7a1038);
  display: grid; place-items: center; font-weight: 800; letter-spacing: .5px;
}
.brand h1 { font-size: 18px; margin: 0; }
.login-sub { color: var(--muted); margin: 6px 0 26px; font-size: 13px; }
.field { margin-bottom: 16px; }
.field label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.field input, .field select, .field textarea {
  width: 100%; background: #0f1218; border: 1px solid var(--line); border-radius: 9px;
  padding: 11px 12px; outline: none; transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  border-radius: 9px; padding: 9px 14px; transition: .15s;
}
.btn:hover { border-color: #3a4152; transform: translateY(-1px); }
.btn.primary { background: linear-gradient(135deg, var(--accent), #c40042); border-color: transparent; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: #ffb4b4; border-color: #5a2020; background: #2a1414; }
.btn.small { padding: 6px 10px; font-size: 12px; border-radius: 7px; }
.btn.wide { width: 100%; padding: 12px; }
.error { color: #ff8f8f; font-size: 12px; min-height: 18px; margin-top: 8px; }

/* layout */
.topbar {
  height: 66px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px; border-bottom: 1px solid var(--line);
  background: rgba(11,13,18,.75); backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 20;
}
.topbar .left { display: flex; align-items: center; gap: 12px; }
.topbar .right { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 13px; }
.layout { display: grid; grid-template-columns: 190px 1fr; min-height: calc(100vh - 66px); }
.sidenav { border-right: 1px solid var(--line); padding: 18px 12px; background: rgba(15,17,23,.55); }
.sidenav button {
  width: 100%; text-align: left; background: transparent; border: 0; color: var(--muted);
  padding: 11px 14px; border-radius: 9px; margin-bottom: 4px; display: flex; gap: 10px; align-items: center;
}
.sidenav button.active { background: linear-gradient(90deg, rgba(255,0,85,.18), transparent); color: var(--text); }
.sidenav button:hover { color: var(--text); background: rgba(255,255,255,.04); }
.main { padding: 26px 30px 60px; max-width: 1500px; }
.page-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.page-title h2 { margin: 0; font-size: 21px; }
.page-title p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }

/* stats */
.stat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 18px; }
.stat {
  background: linear-gradient(180deg, var(--panel), #11141b); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px;
}
.stat .label { color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.stat .value { font-size: 26px; font-weight: 700; letter-spacing: .3px; }
.stat .hint { color: var(--muted); font-size: 11px; margin-top: 6px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
}
.panel h3 { margin: 0 0 16px; font-size: 15px; }
.bar-row { display: grid; grid-template-columns: 70px 1fr 50px; gap: 10px; align-items: center; margin-bottom: 11px; }
.bar-track { height: 9px; background: #0e1117; border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #ff7aa5); border-radius: 99px; }
.muted { color: var(--muted); }
.trend { display: flex; align-items: flex-end; gap: 8px; height: 150px; padding-top: 8px; }
.trend .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.trend .bar { width: 100%; background: linear-gradient(180deg, var(--accent), #6d0a2c); border-radius: 5px 5px 2px 2px; min-height: 3px; }
.trend .d { font-size: 10px; color: var(--muted); writing-mode: vertical-rl; }

/* toolbar/table */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar input, .toolbar select {
  background: #0f1218; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; outline: none;
}
.toolbar input { min-width: 220px; }
.toolbar .spacer { flex: 1; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; min-width: 900px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; background: #12151d; position: sticky; top: 0; }
tbody tr:hover { background: rgba(255,255,255,.025); }
tbody tr:last-child td { border-bottom: 0; }
.table-wrap input:not([type="checkbox"]) {
  background: #0f1218; border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 8px; color: var(--text); outline: none;
}
.table-wrap input:not([type="checkbox"]):focus { border-color: var(--accent); }
.table-wrap input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }
.badge { padding: 3px 9px; border-radius: 99px; font-size: 11px; border: 1px solid transparent; }
.badge.unused { color: #9fb2ff; background: rgba(90,120,255,.12); border-color: rgba(90,120,255,.25); }
.badge.active, .badge.ok { color: #86efac; background: rgba(34,197,94,.12); border-color: rgba(34,197,94,.25); }
.badge.expired, .badge.superseded { color: #fcd34d; background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.25); }
.badge.disabled, .badge.revoked, .badge.unbound { color: #fca5a5; background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.25); }
.mono { font-family: Consolas, "Cascadia Mono", monospace; }
.actions { display: flex; gap: 6px; }
.pager { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 12px; color: var(--muted); font-size: 13px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* modal */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.65); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal-card {
  width: 520px; max-width: 100%; background: #161a23; border: 1px solid var(--line);
  border-radius: 14px; padding: 24px; box-shadow: 0 40px 100px rgba(0,0,0,.6);
}
.modal-card.wide { width: 760px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.keys-output {
  width: 100%; height: 260px; background: #0b0e14; border: 1px solid var(--line); border-radius: 9px;
  padding: 12px; font-family: Consolas, monospace; font-size: 12px; resize: vertical;
}

/* toast */
.toast {
  position: fixed; right: 24px; bottom: 24px; background: #1d2230; border: 1px solid var(--line);
  border-left: 3px solid var(--accent); border-radius: 9px; padding: 12px 16px; z-index: 80;
  box-shadow: 0 20px 50px rgba(0,0,0,.5); max-width: 420px;
}
.toast.err { border-left-color: var(--bad); }

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .layout { grid-template-columns: 1fr; }
  .sidenav { display: flex; overflow: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidenav button { width: auto; white-space: nowrap; }
}
