:root {
  color-scheme: light;
  --ink: #15223b;
  --muted: #59677d;
  --line: #dce4ef;
  --surface: #fff;
  --canvas: #f1f5fa;
  --blue: #214cc1;
  --blue-hover: #1a3d9f;
  --nav: #101c33;
  --nav-muted: #bbc7de;
  --danger: #a41d32;
  font: 15px/1.5 "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(25px, 3.4vw, 32px); line-height: 1.25; }
h2 { font-size: 22px; line-height: 1.3; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .6; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid #597cff; outline-offset: 3px; }
input, select {
  width: 100%;
  min-height: 42px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
}
label { font-weight: 650; }
.muted { color: var(--muted); }
.message { color: var(--danger); }
.message:empty { display: none; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  white-space: nowrap;
  font-weight: 650;
  text-decoration: none;
}
.primary { background: var(--blue); color: white; }
.primary:hover { background: var(--blue-hover); }
.quiet { color: var(--ink); background: white; border-color: var(--line); }
.quiet:hover { background: #f0f4fd; }
.brand { display: flex; gap: 10px; align-items: center; font-size: 20px; font-weight: 750; white-space: nowrap; }
.brand-icon {
  display: inline-grid;
  width: 33px;
  height: 33px;
  place-items: center;
  border-radius: 9px;
  color: #fff;
  background: #4264e8;
}
.brand-icon::after {
  content: "";
  width: 0;
  height: 0;
  margin-left: 3px;
  border: 7px solid transparent;
  border-left: 11px solid currentColor;
  border-right: 0;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
  background: radial-gradient(ellipse at 14% 3%, #d3dffb, var(--canvas) 53%);
}
.login-panel {
  display: grid;
  gap: 14px;
  width: min(100%, 420px);
  padding: 36px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: white;
  box-shadow: 0 16px 45px #1422471a;
}
.login-panel .brand { margin-bottom: 12px; }
.login-form { display: grid; gap: 10px; margin-top: 10px; }
.login-form button { margin-top: 6px; }

.dashboard { display: grid; grid-template-columns: 222px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  gap: 32px;
  padding: 26px 18px;
  background: var(--nav);
  color: white;
}
.sidebar nav { display: grid; gap: 6px; }
.sidebar button {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--nav-muted);
  text-align: left;
  cursor: pointer;
}
.sidebar button:hover { background: #1e2e4d; color: white; }
.sidebar button[aria-current="page"] { background: #293d65; color: white; font-weight: 650; }
.sidebar .logout { margin-top: auto; }
.workspace { width: min(100%, 1500px); padding: 36px 38px; }
.page-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 24px; }
.page-heading p { margin-top: 8px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.records { overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 18px; }
.toolbar input { width: min(100%, 300px); }
.toolbar > div { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.panel-message { margin: 0 18px 10px; }
.success-message { color: #166344; }
.pager { display: flex; justify-content: flex-end; align-items: center; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--line); }
.pager button:disabled { cursor: default; }
.table-wrap { overflow: auto; }
table { width: 100%; border-spacing: 0; text-align: left; }
th, td { min-width: 90px; padding: 13px 14px; border-top: 1px solid var(--line); white-space: nowrap; }
th { background: #f4f7fc; color: var(--muted); font-size: 13px; font-weight: 650; }
td:first-child { font-weight: 650; }
#codes-panel td:nth-child(6) { max-width: 185px; overflow-wrap: anywhere; white-space: normal; }
.code-value { font: 600 13px/1.5 Consolas, "SFMono-Regular", monospace; color: #233e95; }
tr:last-child td { border-bottom: 0; }
.empty { padding: 34px 15px; border-top: 1px solid var(--line); color: var(--muted); text-align: center; }
.user-actions { display: flex; align-items: center; gap: 12px; }
.text-button { padding: 2px 0; border: 0; background: transparent; color: var(--blue); font-weight: 650; }
.text-button:hover { text-decoration: underline; }
.text-button.danger { color: var(--danger); }
.badge { display: inline-block; padding: 3px 8px; border-radius: 6px; background: #edf0f5; color: #46546a; font-size: 13px; white-space: nowrap; }
.badge.good { background: #e4f6eb; color: #166344; }
.badge.trial { background: #eaf0ff; color: #294fad; }
.badge.disabled { background: #fce9ed; color: var(--danger); }

dialog { width: min(calc(100% - 32px), 440px); padding: 25px; border: 1px solid var(--line); border-radius: 15px; color: var(--ink); }
dialog::backdrop { background: #0e1c37a6; }
dialog form, .dialog-content, .field { display: grid; gap: 8px; }
.duration-field { display: grid; grid-template-columns: minmax(0, 1fr) 92px; gap: 8px; }
dialog p.muted { margin: 1px 0 8px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.share-code { font-family: Consolas, "SFMono-Regular", monospace; color: #233e95; user-select: all; }

@media (max-width: 840px) {
  .dashboard { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; min-height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 15px 18px; }
  .sidebar nav { display: flex; order: 3; width: 100%; }
  .sidebar button, .sidebar .logout { width: auto; margin: 0; }
  .workspace { padding: 22px 16px; }
  .page-heading { align-items: start; }
}
@media (max-width: 480px) {
  .login-panel { padding: 24px; }
  .toolbar { padding: 10px; gap: 8px; }
  .toolbar > div { gap: 4px; }
  .toolbar .button { padding-inline: 9px; }
  .page-heading { flex-wrap: wrap; }
}
