:root {
  color-scheme: light;
  font-family: "Instrument Sans", "Microsoft YaHei UI", system-ui, sans-serif;
  color: #28252d;
  background: #f7f5f1;
  --paper: #fffdfa;
  --line: #e8e3e4;
  --muted: #6b6572;
  --lavender: #eee8fa;
  --accent: #51367d;
  --rose: #f7e8ec;
  --danger: #912f48;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.75rem, 4vw, 2.6rem); letter-spacing: -.04em; }
h2 { font-size: 1.35rem; }
button, input, select, textarea { font: inherit; }
button, input, select, textarea {
  padding: .65rem .85rem;
  border: 1px solid var(--line);
  border-radius: 11px;
  min-height: 42px;
  background: var(--paper);
  color: inherit;
}
button { cursor: pointer; font-weight: 600; }
button:hover:enabled { background: var(--rose); }
button:disabled { cursor: default; opacity: .5; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.primary {
  color: white;
  background: #48346e;
  border-color: #48346e;
}
.primary:hover:enabled { color: white; background: #793c63; border-color: #793c63; }
label { display: grid; gap: .45rem; color: var(--muted); font-size: .86rem; font-weight: 600; }
input, select, textarea { min-width: 0; color: #28252d; font-weight: 400; }
textarea { width: 100%; resize: vertical; }
.brand { display: flex; gap: .75rem; align-items: center; font-size: 1.22rem; white-space: nowrap; }
.brand img { width: 36px; height: 36px; }
.sign-in {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: radial-gradient(ellipse at 25% 20%, #ede5f5, transparent 55%), #f7f5f1;
}
.login-card {
  display: grid;
  gap: 1.15rem;
  width: min(100%, 410px);
  padding: clamp(1.25rem, 6vw, 2.5rem);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: 0 20px 65px #43304a12;
}
.login-card h1 { font-size: 1.65rem; }
[role="alert"] { color: var(--danger); }
[role="alert"]:empty { display: none; }
.workspace { display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: 100dvh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  padding: 1.55rem 1rem;
  background: var(--paper);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 2rem;
}
.sidebar .brand { padding-inline: .4rem; }
nav { display: grid; gap: .3rem; }
nav button { border-color: transparent; text-align: left; color: var(--muted); }
nav button[aria-current="page"] { background: var(--lavender); color: var(--accent); }
.session { margin-top: auto; display: grid; gap: .65rem; color: var(--muted); overflow-wrap: anywhere; }
.content { width: 100%; max-width: 1720px; margin-inline: auto; padding: clamp(1rem, 3vw, 3.25rem); }
.page-header { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; align-items: end; margin-bottom: 1.5rem; }
.page-header p { margin-top: .4rem; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.metric, .panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 22px;
}
.metric { display: grid; gap: .9rem; padding: 1.45rem; }
.metric span { color: var(--muted); }
.metric strong { font-size: 2.25rem; line-height: 1; font-variant-numeric: tabular-nums; }
.metric:first-child, .metric:nth-child(2) { background: var(--lavender); }
.status { margin-bottom: 1rem; color: var(--accent); overflow-wrap: anywhere; }
.filters, .pagination { display: flex; flex-wrap: wrap; align-items: end; gap: .7rem; padding: 1rem; }
.filters label:first-child { flex: 1 1 230px; }
.pagination { justify-content: space-between; align-items: center; color: var(--muted); }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: .85rem; }
th, td { border-block-end: 1px solid var(--line); padding: .75rem .85rem; white-space: nowrap; }
thead { background: #f5f1f7; }
tbody tr:hover { background: #fcf7f8; }
td.long { white-space: pre-wrap; overflow-wrap: anywhere; min-width: 11rem; max-width: 25rem; }
td button { min-height: 34px; padding: .35rem .65rem; }
.key { font-family: ui-monospace, Consolas, monospace; }
.badge { display: inline-block; padding: .3rem .58rem; border-radius: 999px; background: var(--lavender); color: var(--accent); }
.badge.disabled, .badge.expired { background: var(--rose); color: var(--danger); }
.badge.archived { background: #eeebee; color: #584e5b; }
dialog {
  width: min(530px, calc(100% - 2rem));
  max-height: calc(100dvh - 2rem);
  background: var(--paper);
  color: inherit;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 1.35rem;
  box-shadow: 0 20px 70px #21192e30;
}
dialog::backdrop { background: #25202a70; }
dialog header { display: flex; gap: 1rem; justify-content: space-between; align-items: center; }
dialog header button { min-height: 36px; min-width: 36px; padding: 0; font-size: 1.2rem; }
#dialog-content { display: grid; gap: .9rem; margin-block: 1rem; overflow-wrap: anywhere; }
#dialog-content p { color: var(--muted); line-height: 1.6; }
#dialog-error { margin-bottom: .75rem; }
#dialog-actions { justify-content: flex-end; }
@media (max-width: 750px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace { display: block; }
  .sidebar { position: static; height: auto; gap: .8rem; padding: .8rem 1rem; border-right: 0; border-bottom: 1px solid var(--line); }
  nav { display: flex; flex-wrap: wrap; gap: .25rem; }
  nav button { padding: .45rem .6rem; min-height: 36px; }
  .session { display: flex; justify-content: space-between; align-items: center; }
}
