:root {
  color-scheme: dark;
  --bg: #0b0b0c;
  --sidebar: #0f0f11;
  --surface: #121214;
  --surface-hover: #19191c;
  --line: #26262b;
  --line-strong: #34343b;
  --text: #ececf0;
  --text-dim: #b6b6bd;
  --muted: #8a8a92;
  --danger: #e5534b;
  --ok: #3fb950;
  --link: #6ea8fe;
}

@font-face {
  font-family: "GravitAI Math";
  src: url("./fonts/noto-sans-math.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  unicode-range:
    U+2100-214F, U+2200-22FF, U+27C0-27EF, U+2980-29FF, U+2A00-2AFF,
    U+1D400-1D7FF, U+1EE00-1EEFF;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "GravitAI Math", system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code,
pre {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

/* ---------- 框架 ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  flex: 0 0 232px;
  width: 232px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 18px 12px 14px;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 8px 12px;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.brand img {
  width: 26px;
  height: 26px;
  border-radius: 7px;
}

.platform-tag {
  margin: 0 8px 14px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-item {
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  text-align: left;
}

.nav-item:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.nav-item.active {
  background: #1b1c1f;
  color: var(--text);
  font-weight: 600;
}

.side-bottom {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.side-link {
  display: block;
  padding: 9px 10px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 12.5px;
}

.side-link:hover {
  background: var(--surface-hover);
  color: var(--text);
  text-decoration: none;
}

.main {
  flex: 1 1 auto;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 56px;
  padding: 0 28px;
  background: rgba(11, 11, 12, 0.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.topbar h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.account-name {
  max-width: 180px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content {
  max-width: 1040px;
  margin: 0 auto;
  padding: 26px 28px 64px;
}

/* ---------- 内容 ---------- */

.page-intro {
  margin-bottom: 20px;
}

.page-intro-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.page-intro h2 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 650;
}

.page-intro p {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
}

.card {
  margin: 0 0 16px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.card h2 {
  margin: 0 0 4px;
  font-size: 15px;
}

.card .desc {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12.5px;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.card-head .desc {
  margin-bottom: 0;
}

.table-card {
  padding: 4px 10px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.stat-wide {
  grid-column: span 4;
}

.stat-label {
  color: var(--muted);
  font-size: 11.5px;
}

.stat-value {
  margin-top: 4px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.stat-value.mono {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 13px;
  font-weight: 500;
}

.btn-primary {
  display: inline-block;
  padding: 8px 14px;
  border: 0;
  border-radius: 7px;
  background: #f2f2f3;
  color: #0b0b0c;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary:hover {
  background: #fff;
  text-decoration: none;
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-ghost {
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
}

.btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.data-table th,
.data-table td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.data-table td.mono {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  color: var(--text-dim);
}

.tag {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  font-size: 11px;
}

.empty {
  margin: 0;
  padding: 22px 12px;
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
}

.message {
  margin: 0 0 12px;
  color: var(--ok);
  font-size: 12.5px;
}

.message.error {
  color: var(--danger);
}

.login-box {
  padding: 34px 20px;
  text-align: center;
}

.login-box p {
  margin: 0 0 14px;
  color: var(--muted);
}

.code {
  margin: 0;
  padding: 13px 15px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #0f0f11;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.7;
  white-space: pre;
}

.tabs {
  display: flex;
  gap: 3px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.tab {
  padding: 7px 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
}

.tab.active {
  border-bottom-color: #f2f2f3;
  color: var(--text);
}

.note-list {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--text-dim);
  font-size: 12.5px;
}

.note-list li {
  margin: 5px 0;
}

.footer {
  margin-top: 28px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
}


/* ---------- 计费方式切换 ---------- */

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.segment {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #0f0f11;
  color: var(--text-dim);
  text-align: left;
}

.segment strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.segment span {
  color: var(--muted);
  font-size: 11.5px;
}

.segment:hover {
  border-color: var(--line-strong);
  background: var(--surface-hover);
}

.segment.active {
  border-color: #f2f2f3;
  background: #1b1c20;
}

.segment:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.billing-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 11.5px;
}

/* ---------- 创建 Key 弹窗 ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
}

.modal-panel {
  position: relative;
  width: min(440px, 100%);
  padding: 22px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface);
}

.modal-panel h3 {
  margin: 0 0 6px;
  font-size: 17px;
}

.modal-desc {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 12.5px;
}

.modal-close {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
}

.modal-close:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.field {
  display: block;
  margin-bottom: 12px;
}

.field span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.field input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f0f11;
  color: var(--text);
  font-size: 14px;
}

.field input:focus {
  outline: none;
  border-color: var(--line-strong);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.key-reveal-row {
  display: flex;
  gap: 8px;
}

.key-reveal-row input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #0f0f11;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
}

.reveal-warn {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 11.5px;
}

/* ---------- 响应式 ---------- */

@media (max-width: 860px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: center;
    padding: 10px 12px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand {
    padding: 0 10px 0 0;
    white-space: nowrap;
  }

  .platform-tag,
  .side-bottom {
    display: none;
  }

  .side-nav {
    flex-direction: row;
    gap: 2px;
  }

  .nav-item {
    width: auto;
    white-space: nowrap;
  }

  .topbar {
    position: static;
    height: 48px;
    padding: 0 14px;
  }

  .content {
    padding: 16px 14px 48px;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat-wide {
    grid-column: span 2;
  }

  .page-intro-row,
  .card-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .data-table {
    display: block;
    overflow-x: auto;
  }
}

@media (max-width: 480px) {
  .account-name {
    display: none;
  }
}

@media (max-width: 860px) {
  .sidebar {
    scrollbar-width: none;
  }

  .sidebar::-webkit-scrollbar {
    display: none;
  }
}
