:root {
  color-scheme: dark;
  --bg: #080808;
  --panel: #111110;
  --panel-raised: #181714;
  --line: rgba(237, 226, 207, 0.1);
  --line-strong: rgba(237, 226, 207, 0.18);
  --ink: #f2eee7;
  --muted: #9a978f;
  --faint: #6f6d67;
  --gold: #d0aa68;
  --gold-bright: #ecd19a;
  --red: #d78173;
  --green: #9aba9f;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 82% 0, rgba(208, 170, 104, 0.1), transparent 32%),
    #080808;
}
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(430px, 100%);
  padding: 38px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(145deg, #171612, #0d0d0c);
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.45);
}
.brand-dot {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 1px solid rgba(208, 170, 104, 0.38);
  border-radius: 50%;
  color: var(--gold-bright);
  font: 30px "Songti SC", serif;
}
.eyebrow {
  margin: 18px 0 7px;
  color: #aa8b58;
  font: 8px "Avenir Next", sans-serif;
  letter-spacing: 0.2em;
}
h1, h2, p { margin-top: 0; }
h1 {
  margin-bottom: 9px;
  font: 500 34px "Songti SC", serif;
}
h2 {
  margin-bottom: 0;
  font: 500 22px "Songti SC", serif;
}
.copy, .section-head p {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}
form { display: grid; gap: 14px; }
label > span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 10px;
}
input {
  width: 100%;
  height: 42px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: 0;
  color: var(--ink);
  background: #111110;
}
input:focus { border-color: rgba(208, 170, 104, 0.42); }
.login-card button[type="submit"], #createForm button {
  height: 43px;
  border: 0;
  border-radius: 10px;
  color: #18130d;
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  font-weight: 700;
}
.error {
  min-height: 17px;
  margin: 0;
  color: #de9387;
  font-size: 10px;
}

.dashboard {
  width: min(1320px, calc(100% - 48px));
  margin: 0 auto;
  padding: 45px 0 80px;
}
.dashboard-head, .section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.head-actions { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 10px; }
.outline {
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 11px;
  margin-top: 28px;
}
.stats article {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}
.stats span, .stats strong { display: block; }
.stats span { color: var(--faint); font-size: 9px; }
.stats strong { margin-top: 8px; color: var(--gold-bright); font: 500 25px "Songti SC", serif; }

.toolbar, .license-section {
  margin-top: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
}
.toolbar {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 28px;
}
.create-form {
  grid-template-columns: 70px 190px 80px minmax(150px, 1fr) 110px;
  align-items: end;
}
.create-form .wide { min-width: 0; }
.section-head input { width: 250px; }
.table-wrap { overflow: auto; margin-top: 18px; }
table { width: 100%; border-collapse: collapse; font-size: 10px; }
th {
  padding: 10px;
  color: var(--faint);
  font-weight: 500;
  text-align: left;
}
td {
  padding: 13px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.055);
  color: #c8c3ba;
}
.key-prefix { color: var(--gold-bright); font-family: monospace; }
.status {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--faint);
  background: rgba(255, 255, 255, 0.04);
}
.status.active { color: var(--green); background: rgba(122, 163, 136, 0.09); }
.status.revoked { color: var(--red); background: rgba(210, 118, 102, 0.09); }
.row-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.row-actions button {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: #aaa69d;
  background: #151514;
  font-size: 8px;
}
.row-actions button:hover { border-color: rgba(208, 170, 104, 0.3); color: var(--gold-bright); }
.row-actions button.danger:hover { border-color: rgba(210, 118, 102, 0.35); color: var(--red); }
.empty { padding: 30px; color: var(--faint); text-align: center; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(10px);
}
.modal-card {
  position: relative;
  width: min(620px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  background: #151411;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.55);
}
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  background: transparent;
  font-size: 18px;
}
.modal-body { margin-top: 20px; color: #bbb7ad; font-size: 11px; line-height: 1.7; }
.key-list { display: grid; gap: 9px; }
.key-value {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0d0d0c;
}
.key-value code { color: var(--gold-bright); font-size: 12px; word-break: break-all; }
.key-value button, .modal-card form button {
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #181714;
}
.modal-card form { margin-top: 16px; }
.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  display: grid;
  gap: 8px;
}
.toast {
  padding: 12px 15px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: #d9d5cc;
  background: #171613;
  font-size: 10px;
}
.toast.error { border-color: rgba(210, 118, 102, 0.35); }

@media (max-width: 900px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .toolbar { grid-template-columns: 1fr; }
  .create-form { grid-template-columns: 1fr 1fr; }
  .create-form .wide { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  .dashboard { width: calc(100% - 24px); padding-top: 24px; }
  .dashboard-head, .section-head { align-items: flex-start; flex-direction: column; }
  .section-head input { width: 100%; }
  .create-form { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
}
