:root {
  color-scheme: light;
  --primary: #33287b;
  --azure: #6cbae9;
  --ink: #163262;
  --muted: #657289;
  --accent: #33287b;
  --bg: #f0f2f5;
  --surface: #fff;
  --line: #dfe5ee;
  --table-head: #f7f9fc;
  --table-line: #edf0f5;
  --badge-bg: #ebedf9;
  --error-bg: #fff0ed;
  --error-line: #f0d3cd;
  --error-ink: #a03e2d;
  --shadow: #16326204;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e0e8f5;
  --muted: #a2b1c9;
  --accent: #6cbae9;
  --bg: #101722;
  --surface: #1a2433;
  --line: #33425a;
  --table-head: #202d40;
  --table-line: #2e3c51;
  --badge-bg: #273b54;
  --error-bg: #3b2529;
  --error-line: #79434b;
  --error-ink: #ffb5a8;
  --shadow: #00000026;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, "Source Han Sans SC", "Noto Sans CJK SC", "PingFang SC", sans-serif;
}
a { color: var(--accent); text-underline-offset: .18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--azure); outline-offset: 3px; }
svg { flex-shrink: 0; }
button, input, select { font: inherit; }
button, .button, input, select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}
input, select { display: block; min-width: 0; width: 100%; padding: 7px 10px; }
input::placeholder { color: var(--muted); opacity: 1; }
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 13px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.primary, .tabs a[aria-current="page"] { background: var(--primary); color: #fff; }
.primary { border-color: var(--primary); font-weight: 600; }
button:hover:not(.primary), .button:hover:not(.primary) { background: var(--table-head); }
.primary:hover { box-shadow: inset 0 0 0 2px var(--azure); }
label { display: grid; gap: 5px; font-weight: 600; }
label input, label select { font-weight: 400; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(26px, 3.5vw, 34px); line-height: 1.2; margin-bottom: 18px; }
h2 { font-size: 18px; line-height: 1.35; margin-bottom: 14px; }
code { font-family: ui-monospace, monospace; overflow-wrap: anywhere; }
.skip-link {
  position: fixed;
  z-index: 3;
  top: 6px;
  left: 6px;
  padding: 6px 9px;
  background: var(--surface);
  transform: translateY(-160%);
}
.skip-link:focus { transform: none; }
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-header-inner, .page { max-width: 1200px; margin: auto; padding-inline: clamp(16px, 4vw, 44px); }
.site-header-inner {
  min-height: 73px;
  padding-block: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
}
.brand, .header-actions, .appearance, .account { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand { color: var(--ink); font-weight: 700; text-decoration: none; }
.brand-logo { display: block; width: 112px; height: auto; flex-shrink: 0; }
:root[data-theme="dark"] .brand-logo { filter: brightness(0) invert(1); }
.header-actions { flex-wrap: wrap; }
.appearance { gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 12px; }
.appearance button {
  width: 40px;
  height: 40px;
  padding: 0;
  border-color: transparent;
  color: var(--muted);
}
.appearance button[aria-pressed="true"] { color: var(--accent); background: var(--badge-bg); }
.account-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.page { padding-block: 28px 48px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 26px; width: fit-content; }
.tabs a { border-radius: 8px; padding: 8px 13px; text-decoration: none; font-weight: 600; }
.tabs a:not([aria-current="page"]):hover { background: var(--badge-bg); }
.card {
  min-width: 0;
  margin-bottom: 14px;
  padding: clamp(15px, 3vw, 23px);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 2px 6px var(--shadow);
}
.auth-card { max-width: 660px; margin: clamp(12px, 5vh, 60px) auto 0; }
.auth-card > p { margin-bottom: 14px; }
.auth-card > p:empty { margin: 0; }
.signed-in-as { overflow-wrap: anywhere; }
.fields { display: grid; align-items: end; gap: 12px; }
.create-fields { grid-template-columns: minmax(130px, 1fr) minmax(155px, 1fr) auto; }
.usage-fields { grid-template-columns: repeat(4, minmax(130px, 1fr)) auto auto; }
.usage-fields > a { line-height: 40px; }
.table-scroll { overflow: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 10px 12px; vertical-align: top; overflow-wrap: anywhere; }
th { background: var(--table-head); font-size: 13px; font-weight: 650; color: var(--muted); }
tbody tr:not(:last-child) { border-bottom: 1px solid var(--table-line); }
.keys-table { min-width: 680px; }
.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 8px;
  background: var(--badge-bg);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}
.badge.inactive { background: var(--table-head); color: var(--muted); }
.row-actions { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 4px 12px; }
.text-button {
  display: inline;
  cursor: pointer;
  border: 0;
  padding: 0;
  min-height: 0;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: .18em;
}
button.text-button:hover { background: transparent; text-decoration-thickness: 2px; }
.danger { color: var(--error-ink); }
.alias-editor form { display: grid; gap: 8px; padding-block: 10px; }
.alias-editor input { min-width: 150px; }
.secret-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 12px; }
.secret-input { flex: 1 0 min(300px, 100%); font: 14px ui-monospace, monospace; }
.muted, .empty { color: var(--muted); }
.error {
  margin-bottom: 14px;
  padding: 9px 12px;
  border: 1px solid var(--error-line);
  border-radius: 8px;
  background: var(--error-bg);
  color: var(--error-ink);
}
.usage-breakdown { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.usage-total h2 { margin-bottom: 0; }
.metric { font-size: 36px; line-height: 1.2; font-variant-numeric: tabular-nums; }
@media (max-width: 880px) {
  .usage-fields { grid-template-columns: repeat(2, minmax(130px, 1fr)); }
}
@media (max-width: 570px) {
  .create-fields, .usage-breakdown { grid-template-columns: 1fr; }
  .usage-breakdown { gap: 0; }
  .usage-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .account-name { max-width: 110px; }
}
