:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-soft: #fafafa;
  --surface-tint: #f0faf5;
  --border: #dfdfdf;
  --border-strong: #c7c7c7;
  --ink: #171717;
  --muted: #707070;
  --muted-strong: #404040;
  --sidebar: #1c1c1c;
  --sidebar-deep: #171717;
  --sidebar-line: rgba(255, 255, 255, .12);
  --teal: #3ecf8e;
  --teal-dark: #24b47e;
  --teal-soft: #e5f9ef;
  --amber: #a15c00;
  --amber-soft: #fff6df;
  --red: #c73e3e;
  --red-soft: #fff0f0;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .04);
  --shadow-md: 0 12px 28px rgba(0, 0, 0, .10);
  font-family: "Inter", "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { min-width: 320px; margin: 0; background: var(--bg); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .58; }
[hidden] { display: none !important; }

/* 登录页：保留轻量结构，把品牌色和后台统一起来。 */
.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 18% 12%, rgba(19, 138, 115, .16), transparent 31%),
    radial-gradient(circle at 86% 84%, rgba(181, 107, 45, .13), transparent 30%),
    var(--bg);
}
.login-panel {
  position: relative;
  width: min(100%, 452px);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 42px;
  background: rgba(255, 253, 248, .92);
  box-shadow: var(--shadow-md);
}
.login-panel::before {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 5px;
  background: var(--teal);
  content: "";
}
.product-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 15px;
  color: #e9fff6;
  background: linear-gradient(145deg, #2f8d77, var(--sidebar));
  box-shadow: 0 8px 18px rgba(19, 76, 61, .18);
  font-family: Georgia, serif;
  font-size: 22px;
  font-weight: 800;
}
.product-mark.small { width: 36px; height: 36px; border-radius: 7px; font-size: 17px; }
.eyebrow {
  margin: 0 0 7px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}
h1, h2, h3, h4, p { margin-top: 0; }
.login-panel h1 { margin-bottom: 10px; font-family: Georgia, "Songti SC", serif; font-size: clamp(29px, 5vw, 38px); line-height: 1.15; letter-spacing: -.04em; }
.login-copy { max-width: 34em; margin-bottom: 30px; color: var(--muted); line-height: 1.75; }
.stack-form, .tool-panel { display: grid; gap: 16px; }
label { display: grid; gap: 8px; color: var(--muted-strong); font-size: 12px; font-weight: 800; letter-spacing: .01em; }
input, select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 9px 12px;
  color: var(--ink);
  background: #fffefa;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
input::placeholder { color: #9aa39c; }
input:hover, select:hover { border-color: #bcb2a1; }
input:focus, select:focus {
  border-color: var(--teal);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(19, 138, 115, .13);
}
.form-message { min-height: 20px; margin: -2px 0 0; color: var(--red); font-size: 12px; line-height: 1.5; }

/* 主布局：侧栏负责定位，内容区保持开阔，减少传统后台的拥挤感。 */
.app-shell { display: grid; min-height: 100vh; grid-template-columns: 256px minmax(0, 1fr); }
.sidebar {
  display: flex;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-direction: column;
  border-right: 1px solid var(--sidebar-line);
  padding: 23px 15px 17px;
  color: #c5d7cf;
  background:
    radial-gradient(circle at 18% 8%, rgba(83, 173, 143, .22), transparent 25%),
    linear-gradient(170deg, var(--sidebar) 0%, var(--sidebar-deep) 100%);
}
.side-brand { display: flex; align-items: center; gap: 11px; padding: 0 10px 29px; color: #f6fff9; }
.side-brand strong, .side-brand small { display: block; }
.side-brand strong { font-size: 15px; letter-spacing: .01em; }
.side-brand small { margin-top: 4px; color: #8fb4a6; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }
.nav-list { display: grid; gap: 6px; }
.nav-item {
  display: flex;
  min-height: 40px;
  align-items: center;
  gap: 11px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0 13px;
  color: #a8a8a8;
  background: transparent;
  text-align: left;
  font-size: 13px;
  font-weight: 700;
  transition: color .18s ease, background .18s ease, border-color .18s ease, transform .18s ease;
}
.nav-item::before {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid rgba(202, 229, 216, .2);
  border-radius: 7px;
  color: #8bb9a9;
  content: "•";
  font-size: 15px;
  line-height: 1;
}
.nav-item[data-view="overview"]::before { content: "⌂"; }
.nav-item[data-view="keys"]::before { content: "◇"; }
.nav-item[data-view="pricing"]::before { content: "≈"; }
.nav-item[data-view="pending"]::before { content: "◌"; }
.nav-item[data-view="usage-logs"]::before { content: "≋"; }
.nav-item[data-view="error-logs"]::before { content: "!"; }
.nav-item[data-view="settings"]::before { content: "⚙"; font-size: 13px; }
.nav-item:hover { color: #ffffff; background: rgba(255, 255, 255, .08); }
.nav-item.active {
  border-color: rgba(154, 221, 195, .2);
  color: #f7fff9;
  background: linear-gradient(90deg, rgba(71, 170, 139, .34), rgba(71, 170, 139, .12));
  box-shadow: inset 3px 0 0 #73d0ae;
}
.nav-item.active::before { border-color: rgba(62, 207, 142, .6); color: var(--teal); background: rgba(62, 207, 142, .12); }
.sidebar-bottom { display: flex; align-items: center; gap: 9px; margin-top: auto; padding: 15px 10px 2px; border-top: 1px solid var(--sidebar-line); color: #94b5a8; font-size: 11px; }
.status-dot { display: inline-block; width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: #5ed19f; box-shadow: 0 0 0 4px rgba(94, 209, 159, .13); }
.status-dot.offline { background: #e6a55a; box-shadow: 0 0 0 4px rgba(230, 165, 90, .14); }

.main-area { min-width: 0; }
.topbar {
  display: flex;
  position: sticky;
  z-index: 5;
  top: 0;
  min-height: 88px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid rgba(228, 221, 209, .92);
  padding: 16px clamp(22px, 4vw, 48px);
  background: rgba(255, 253, 248, .88);
  box-shadow: 0 8px 24px rgba(73, 74, 58, .04);
  backdrop-filter: blur(16px);
}
.topbar .eyebrow { margin-bottom: 4px; color: var(--muted); letter-spacing: .12em; }
.topbar h1 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: 25px; letter-spacing: -.035em; }
.account-menu { display: flex; align-items: center; gap: 11px; color: var(--muted-strong); font-size: 12px; font-weight: 700; }
.account-menu::before { display: block; width: 8px; height: 8px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 4px var(--teal-soft); content: ""; }
.content { width: min(100%, 1500px); margin: 0 auto; padding: 36px clamp(22px, 4vw, 48px) 60px; }
/* 模型价格表在放大后需要更宽的画布，避免右侧操作列在大屏被截断；其他页面仍沿用默认宽度。 */
.content:has(.view[data-panel="pricing"].active) { width: min(100%, 1800px); }
.view { display: grid; gap: 22px; min-width: 0; animation: view-in .3s ease both; }
.view > * { min-width: 0; max-width: 100%; }
@keyframes view-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }

.section-heading, .table-toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.section-heading h2 { margin-bottom: 7px; font-family: Georgia, "Songti SC", serif; font-size: clamp(24px, 3vw, 32px); letter-spacing: -.045em; }
.section-heading h3, .table-toolbar h3 { margin-bottom: 6px; font-family: Georgia, "Songti SC", serif; font-size: 20px; letter-spacing: -.025em; }
.section-heading h4, .table-toolbar h4 { margin-bottom: 5px; font-size: 14px; }
.section-heading p, .table-toolbar p { max-width: 70em; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.7; }

/* 概览页的上游状态条作为页面“主信号”，比单纯的提示框更容易扫读。 */
.connection-strip {
  display: flex;
  position: relative;
  overflow: hidden;
  align-items: flex-start;
  gap: 15px;
  border: 1px solid #bbdfd0;
  border-radius: 18px;
  padding: 19px 22px;
  color: #174e40;
  background: linear-gradient(110deg, #e6f6ee 0%, #f7fbf5 66%, #f4eadb 100%);
  box-shadow: var(--shadow-sm);
}
.connection-strip::after { position: absolute; right: -20px; bottom: -38px; width: 180px; height: 110px; border: 1px solid rgba(19, 138, 115, .16); border-radius: 50%; content: ""; transform: rotate(-12deg); }
.connection-strip .status-dot { margin-top: 5px; background: var(--teal); }
.connection-strip.offline { border-color: #ebc58e; color: #704613; background: linear-gradient(110deg, #fff0dc, #fffaf1); }
.connection-strip.offline .status-dot { background: var(--amber); }
.connection-strip strong { display: block; position: relative; z-index: 1; margin-bottom: 5px; color: #155b4a; font-size: 14px; }
.connection-strip.offline strong { color: #84500d; }
.connection-strip p { position: relative; z-index: 1; margin: 0; color: #4f7065; font-size: 12px; line-height: 1.6; }
.connection-strip.offline p { color: #765e3c; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metric {
  position: relative;
  min-height: 145px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.metric:hover { border-color: #cfc5b6; box-shadow: var(--shadow-md); transform: translateY(-3px); }
.metric::after { position: absolute; right: -22px; bottom: -35px; width: 100px; height: 100px; border: 1px solid rgba(19, 138, 115, .14); border-radius: 50%; content: ""; }
.metric:nth-child(2)::after { border-color: rgba(181, 107, 45, .18); }
.metric:nth-child(3)::after { border-color: rgba(19, 138, 115, .2); }
.metric:nth-child(4)::after { border-color: rgba(196, 83, 67, .15); }
.metric span, .metric small { display: block; position: relative; z-index: 1; color: var(--muted); font-size: 12px; }
.metric span::before { display: inline-block; width: 7px; height: 7px; margin: 0 8px 1px 0; border-radius: 50%; background: var(--teal); content: ""; }
.metric:nth-child(2) span::before { background: var(--amber); }
.metric:nth-child(3) span::before { background: #4ca8a1; }
.metric:nth-child(4) span::before { background: var(--red); }
.metric strong { display: block; position: relative; z-index: 1; margin: 21px 0 9px; color: var(--sidebar); font-family: inherit; font-size: clamp(30px, 4vw, 42px); line-height: .95; letter-spacing: -.05em; }
.metric small { font-size: 11px; }

.section-block, .tool-panel {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.section-block { padding: 24px; }
.tool-grid { display: grid; gap: 16px; }
.tool-grid.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tool-grid.single-column { grid-template-columns: minmax(0, 1fr); }
.tool-panel { padding: 23px; }
.panel-title h3 { margin-bottom: 6px; font-size: 16px; letter-spacing: -.01em; }
.panel-title p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.panel-title p + p { margin-top: 8px; }
.horizontal-form { grid-template-columns: 1.35fr repeat(3, minmax(0, .75fr)) auto; align-items: end; }
.horizontal-form .panel-title { align-self: start; }
.horizontal-form .button { min-width: 118px; }
.pricing-form { grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: end; }
.pricing-inline-form {
  display: grid;
  gap: 16px;
  border: 1px solid #cfe2d8;
  border-radius: 14px;
  padding: 18px;
  background: var(--surface-soft);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7);
}
.pricing-inline-fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: end; }
.pricing-inline-fields .pricing-margin-note { grid-column: 1 / -1; align-self: stretch; }
.pricing-editor-row:hover { background: transparent; }
.pricing-editor-row td { padding: 10px; background: var(--surface-soft); }
.billing-settings-form { grid-template-columns: minmax(190px, .65fr) minmax(190px, .65fr) 1fr; align-items: end; margin-bottom: 16px; }
.billing-settings-form .panel-title { grid-column: 1 / -1; }
.pricing-form .panel-title { grid-column: 1 / -1; }
.pricing-form-actions { display: flex; grid-column: 1 / -1; align-items: center; flex-wrap: wrap; gap: 9px; }
.pricing-form-actions .form-message { flex: 1 1 320px; min-height: 0; margin: 0; color: var(--muted); }
.inline-note { align-self: end; min-height: 42px; margin: 0; padding: 11px 13px; border: 1px dashed #c4d9ce; border-radius: 10px; color: var(--muted); background: var(--surface-tint); font-size: 12px; }
.inline-note strong { color: var(--teal-dark); font-family: Consolas, monospace; }
.toggle-field { display: flex; min-height: 42px; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--border-strong); border-radius: 10px; padding: 9px 12px; background: #fffefa; }
.toggle-field input { width: 18px; min-height: 18px; margin: 0; accent-color: var(--teal); }
.field-disabled { color: #9aa39c; }
.field-disabled input { color: #9aa39c; background: #f3f1eb; }

.table-toolbar { margin-top: 3px; }
.table-toolbar-actions, .action-cell { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.compact-filter { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 800; }
.compact-filter input, .compact-filter select { width: auto; min-width: 88px; min-height: 34px; border-radius: 9px; padding: 6px 9px; font-size: 12px; }
.key-search-filter input { min-width: 220px; }
.selection-count { min-width: 54px; color: var(--muted); font-size: 11px; font-weight: 800; white-space: nowrap; }
.key-unavailable { color: #915007; font-size: 11px; font-weight: 800; white-space: nowrap; }
.table-toolbar h3 { margin: 0 0 4px; font-size: 17px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
table { width: 100%; min-width: 700px; border-collapse: collapse; font-size: 12px; }
.table-wrap table:has(.check-cell) { min-width: 980px; }
/* 模型价格列较多，保留横向滚动并继续放大内容，优先保证价格和操作信息易读。 */
.pricing-table {
  min-width: 1512px;
  table-layout: fixed;
  font-size: 14px;
}
.pricing-table th,
.pricing-table td { padding: 12px 12px; }
.pricing-table th:nth-child(1), .pricing-table td:nth-child(1) { width: 180px; }
.pricing-table th:nth-child(2), .pricing-table td:nth-child(2) { width: 86px; }
.pricing-table th:nth-child(3), .pricing-table td:nth-child(3),
.pricing-table th:nth-child(4), .pricing-table td:nth-child(4),
.pricing-table th:nth-child(5), .pricing-table td:nth-child(5),
.pricing-table th:nth-child(6), .pricing-table td:nth-child(6) { width: 89px; }
.pricing-table th:nth-child(7), .pricing-table td:nth-child(7) { width: 192px; min-width: 0; }
.pricing-table th:nth-child(8), .pricing-table td:nth-child(8) { width: 106px; min-width: 0; }
.pricing-table th:nth-child(9), .pricing-table td:nth-child(9) { width: 168px; min-width: 0; }
.pricing-table th:nth-child(10), .pricing-table td:nth-child(10) { width: 89px; }
.pricing-table th:nth-child(11), .pricing-table td:nth-child(11) { width: 108px; }
.pricing-table th:nth-child(12), .pricing-table td:nth-child(12) { width: 84px; }
.pricing-table th:nth-child(13), .pricing-table td:nth-child(13) { width: 144px; }
.pricing-table td:nth-child(1), .pricing-table td:nth-child(7), .pricing-table td:nth-child(11) { overflow-wrap: anywhere; }
.pricing-table td:nth-child(9) { vertical-align: top; }
.pricing-table td strong { font-size: 14px; }
.pricing-table td small { margin-top: 4px; font-size: 12px; line-height: 1.4; }
.pricing-table .badge { min-height: 26px; padding: 2px 8px; font-size: 13px; }
.pricing-table .table-actions { gap: 6px; }
.pricing-table .button-small { min-height: 36px; padding: 0 11px; font-size: 13px; }
.pricing-table .profit-total { min-width: 0; gap: 4px; border-radius: 9px; padding: 8px 10px; }
.pricing-table .profit-total strong { font-size: 14px; }
.pricing-table .profit-total small { font-size: 12px; }

th { border-bottom: 1px solid var(--border); padding: 12px 14px; color: #738078; background: #faf8f3; text-align: left; font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
td { border-bottom: 1px solid #eee9df; padding: 14px; color: var(--muted-strong); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .15s ease; }
tbody tr:hover { background: #fbf8f0; }
td strong { display: block; color: var(--ink); font-size: 12px; }
td small { display: block; margin-top: 4px; color: #909a92; font-size: 10px; line-height: 1.45; }
td code, code { border-radius: 7px; padding: 3px 6px; color: #236253; background: #edf5f0; font-family: Consolas, "SFMono-Regular", monospace; font-size: 11px; }
.check-cell { width: 38px; }
.check-cell input { width: 16px; min-height: 16px; margin: 0; accent-color: var(--teal); }
.empty { padding: 30px 16px !important; color: #8f9891; text-align: center; }

.button {
  min-height: 39px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0 15px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .01em;
  transition: background .18s ease, border-color .18s ease, color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.button:hover { transform: translateY(-1px); }
.button-primary { color: #f4fff9; background: var(--teal); box-shadow: 0 7px 14px rgba(19, 138, 115, .16); }
.button-primary:hover { background: var(--teal-dark); box-shadow: 0 9px 18px rgba(19, 138, 115, .21); }
.button-secondary { border-color: var(--border-strong); color: var(--muted-strong); background: #fffefa; }
.button-secondary:hover { border-color: #b8ad9b; color: var(--ink); background: #faf5eb; }
.button-quiet { min-height: 34px; border-color: transparent; color: var(--muted-strong); background: transparent; }
.button-quiet:hover { color: var(--ink); background: #f2ece2; }
.button-danger { border-color: #efc1b8; color: #ad4135; background: #fff9f7; }
.button-danger:hover { border-color: #df9e93; background: var(--red-soft); }
.button-small { min-height: 30px; border-radius: 8px; padding: 0 10px; font-size: 11px; }
.table-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.icon-button { display: grid; width: 35px; height: 35px; place-items: center; border: 1px solid var(--border-strong); border-radius: 10px; color: var(--muted-strong); background: #fffefa; font-size: 18px; line-height: 1; }
.icon-button:hover { color: var(--teal-dark); border-color: #a8c9bb; background: var(--teal-soft); }
.badge { display: inline-flex; align-items: center; min-height: 23px; border-radius: 999px; padding: 2px 9px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.badge.success { color: #0b765e; background: var(--teal-soft); }
.badge.warning { color: #915007; background: var(--amber-soft); }
.badge.muted { color: #738078; background: #eef0ec; }

/* 毛利按计费项拆成小行，先看结果，再看收入和成本，避免公式挤成一团。 */
.profit-stack { display: grid; gap: 6px; min-width: 232px; }
.profit-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  align-items: center;
  column-gap: 8px;
  border: 1px solid #e8e3d9;
  border-left-width: 3px;
  border-radius: 9px;
  padding: 6px 8px;
  background: #fbfaf6;
}
.profit-row.positive { border-left-color: #2d9b78; background: #f4fbf7; }
.profit-row.negative { border-left-color: var(--red); background: #fff8f6; }
.profit-row.neutral { border-left-color: #a8b0aa; }
.profit-label { color: var(--muted-strong); font-size: 10px; font-weight: 800; }
.profit-main { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 8px; }
.profit-row strong { min-width: 0; overflow-wrap: anywhere; color: var(--ink); font-size: 11px; font-weight: 800; }
.profit-row.positive strong { color: #127458; }
.profit-row.negative strong { color: #b04438; }
.profit-margin { flex: 0 0 auto; border-radius: 999px; padding: 3px 6px; color: var(--muted); background: #eef0ec; font-size: 9px; font-weight: 800; white-space: nowrap; }
.profit-row.positive .profit-margin { color: #127458; background: #dff3e8; }
.profit-row.negative .profit-margin { color: #a63d32; background: #ffe7e2; }
.profit-total {
  display: grid;
  min-width: 132px;
  gap: 4px;
  border: 1px solid #e8e3d9;
  border-left-width: 3px;
  border-radius: 9px;
  padding: 8px 10px;
  background: #fbfaf6;
}
.profit-total.positive { border-left-color: #2d9b78; background: #f4fbf7; }
.profit-total.negative { border-left-color: var(--red); background: #fff8f6; }
.profit-total.neutral { border-left-color: #a8b0aa; }
.profit-total strong { color: var(--ink); font-size: 12px; font-weight: 800; }
.profit-total.positive strong { color: #127458; }
.profit-total.negative strong { color: #b04438; }
.profit-total small { margin-top: 0; color: var(--muted); font-size: 10px; }

.created-key-panel {
  display: grid;
  grid-template-columns: minmax(180px, .7fr) minmax(0, 1.8fr) auto;
  align-items: center;
  gap: 16px;
  border: 1px solid #b9ddcc;
  border-radius: 16px;
  padding: 18px 21px;
  color: #164c39;
  background: linear-gradient(110deg, #edf9f3, #f9fcf4);
  box-shadow: var(--shadow-sm);
}
.created-key-panel strong { display: block; font-size: 14px; }
.created-key-panel p { margin: 5px 0 0; color: #497061; font-size: 11px; line-height: 1.5; }
.created-key-panel code { min-width: 0; max-width: 100%; overflow-wrap: anywhere; padding: 11px 12px; color: #0d5b40; background: rgba(255, 255, 255, .86); font-size: 12px; line-height: 1.55; white-space: pre-wrap; word-break: break-all; }
.created-key-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* 日志、模型设置和统计区域使用同一套筛选与详情语言。 */
.log-filter-form { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin: 0 0 14px; }
.log-filter-form label { flex: 1 1 150px; }
.log-filter-form .compact-filter { flex: 1 1 150px; }
.log-filter-form .compact-filter input, .log-filter-form .compact-filter select { width: 100%; }
.log-filter-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; color: var(--muted); font-size: 11px; }
.detail-grid, .usage-dialog-panel dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; margin: 0; }
.detail-item { min-width: 0; border: 1px solid var(--border); border-radius: 10px; padding: 11px 13px; background: var(--surface-soft); }
.detail-item dt { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.detail-item dd { margin: 5px 0 0; overflow-wrap: anywhere; color: var(--ink); font-size: 12px; line-height: 1.5; }
.settings-form { display: flex; flex-wrap: wrap; align-items: end; gap: 13px; }
.settings-form .panel-title { flex: 1 1 100%; }
.settings-form > label { flex: 1 1 300px; }
.settings-form .pricing-form-actions { flex: 1 1 100%; }
.log-summary { color: var(--muted); font-size: 11px; }
.pending-table { min-width: 1080px; }
.pending-table .pending-reason { max-width: 360px; color: var(--muted-strong); overflow-wrap: anywhere; }
.pending-table small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.pending-review-fields { display: grid; gap: 13px; }
.pending-review-fields > label { display: grid; gap: 6px; }
.pending-review-fields textarea { width: 100%; resize: vertical; }
.pending-token-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 13px; border: 1px dashed var(--border-strong); border-radius: 12px; background: var(--surface-tint); }
.pending-token-fields label { display: grid; gap: 6px; }
.pending-token-fields .inline-note { grid-column: 1 / -1; min-height: 0; }
.pending-review-actions { align-items: center; gap: 8px; }
.pending-review-actions .form-message { flex: 1 1 auto; }.daily-stats-block { background: linear-gradient(180deg, #fffdf8, #fbf8f1); }
.daily-stats-block .section-heading { align-items: flex-start; }
.model-capabilities-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.model-capability-card { display: grid; gap: 8px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-soft); }
.model-capability-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.model-capability-heading strong { color: var(--ink); overflow-wrap: anywhere; }
.model-capability-heading code { color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }
.model-capability-context { color: var(--muted); font-size: 11px; }
.capability-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.capability-badge { display: inline-flex; padding: 4px 8px; border-radius: 999px; background: rgba(120, 130, 145, .12); color: var(--muted); font-size: 10px; }
.capability-badge.is-positive { color: #168257; background: rgba(26, 139, 91, .12); }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; max-width: min(420px, calc(100vw - 48px)); border: 1px solid #a6d9c6; border-radius: 12px; padding: 13px 15px; color: #0a674f; background: #effaf5; box-shadow: var(--shadow-md); font-size: 12px; opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s ease; }
.toast.error { border-color: #eab8b4; color: #9f2720; background: #fff1f0; }
.toast.show { opacity: 1; transform: translateY(0); }
.usage-dialog { width: min(1120px, calc(100vw - 32px)); max-height: min(780px, calc(100vh - 32px)); border: 0; padding: 0; color: var(--ink); background: transparent; }
.usage-dialog::backdrop { background: rgba(16, 37, 34, .52); backdrop-filter: blur(4px); }
.usage-dialog-panel { display: grid; gap: 17px; max-height: min(780px, calc(100vh - 32px)); overflow: hidden; border: 1px solid var(--border); border-radius: 18px; padding: 23px; background: var(--surface); box-shadow: 0 24px 70px rgba(16, 37, 34, .25); }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.dialog-heading h2 { margin: 0 0 6px; font-family: Georgia, "Songti SC", serif; font-size: 22px; letter-spacing: -.03em; }
.dialog-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.usage-dialog .table-wrap { max-height: min(510px, calc(100vh - 230px)); }
.dialog-actions { display: flex; justify-content: flex-end; }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 226px minmax(0, 1fr); }
  .content, .topbar { padding-right: 28px; padding-left: 28px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .horizontal-form { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .horizontal-form .panel-title { grid-column: 1 / -1; }
  .pricing-form { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pricing-inline-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .billing-settings-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .billing-settings-form .panel-title, .billing-settings-form .pricing-form-actions { grid-column: 1 / -1; }
  .created-key-panel { grid-template-columns: 1fr auto; }
  .created-key-panel code { grid-column: 1 / -1; grid-row: 2; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: static; height: auto; min-height: 0; padding: 14px 12px 12px; }
  .side-brand { padding: 0 6px 15px; }
  .nav-list { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
  .nav-item { min-height: 41px; justify-content: center; gap: 4px; padding: 4px 3px; text-align: center; font-size: 11px; }
  .nav-item::before { width: 17px; height: 17px; border: 0; font-size: 13px; }
  .sidebar-bottom { display: none; }
  .topbar { min-height: 72px; padding: 13px 17px; }
  .topbar h1 { font-size: 21px; }
  .account-menu { gap: 7px; font-size: 11px; }
  .content { padding: 22px 17px 38px; }
  .section-heading, .table-toolbar { align-items: flex-start; flex-direction: column; gap: 11px; }
  .section-heading h2 { font-size: 27px; }
  .section-heading > .button, .table-toolbar-actions { width: 100%; }
  .section-heading > .button { align-self: stretch; }
  .metric-grid { gap: 10px; }
  .pricing-table { min-width: 1512px; }
  .pricing-table th:nth-child(7), .pricing-table td:nth-child(7) { width: 192px; min-width: 0; }
  .pricing-table th:nth-child(8), .pricing-table td:nth-child(8) { width: 106px; min-width: 0; }
  .pricing-table th:nth-child(9), .pricing-table td:nth-child(9) { width: 168px; min-width: 0; }
  .metric { min-height: 120px; padding: 15px; border-radius: 14px; }
  .metric strong { margin-top: 15px; font-size: 29px; }
  .section-block, .tool-panel { padding: 17px; border-radius: 15px; }
  .tool-grid.two-columns { grid-template-columns: 1fr; }
  .horizontal-form, .pricing-form, .billing-settings-form { grid-template-columns: 1fr; }
  .pricing-inline-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .horizontal-form .panel-title, .pricing-form .panel-title, .billing-settings-form .panel-title, .billing-settings-form .pricing-form-actions { grid-column: auto; }
  .horizontal-form .button, .pricing-form-actions .button { width: 100%; }
  .pricing-form-actions { display: grid; }
  .pricing-form-actions .form-message { min-height: 20px; }
  .table-toolbar-actions { display: flex; align-items: stretch; flex-wrap: wrap; }
  .table-toolbar-actions .button-secondary { flex: 1 1 120px; }
  .compact-filter { flex: 1 1 140px; }
  .compact-filter input, .compact-filter select { width: 100%; }
  .key-search-filter { flex-basis: 100%; }
  .created-key-panel { grid-template-columns: 1fr; }
  .created-key-panel code { grid-column: auto; grid-row: auto; }
  .created-key-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .created-key-actions .button { width: 100%; }
  .login-panel { padding: 34px 24px; border-radius: 19px; }
  .usage-dialog { width: calc(100vw - 20px); max-height: calc(100vh - 20px); }
  .usage-dialog-panel { max-height: calc(100vh - 20px); padding: 17px; border-radius: 15px; }
  .pagination, .detail-grid, .usage-dialog-panel dl { grid-template-columns: 1fr; flex-direction: column; align-items: stretch; }
  .log-filter-form, .settings-form { display: grid; grid-template-columns: 1fr; }
  .log-filter-actions .button { flex: 1; }
}

@media (max-width: 460px) {
  .nav-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { align-items: flex-start; flex-direction: column; gap: 8px; }
  .account-menu { align-self: stretch; justify-content: space-between; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric { min-height: 112px; }
  .metric span { font-size: 11px; }
  .metric small { font-size: 10px; }
  .metric strong { font-size: 26px; }
}

/* Buddy 后台视觉系统：白色画布、近黑导航、克制的绿色动作色。 */
:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-soft: #fafafa;
  --surface-tint: #f0faf5;
  --border: #dfdfdf;
  --border-strong: #c7c7c7;
  --ink: #171717;
  --muted: #707070;
  --muted-strong: #404040;
  --sidebar: #1c1c1c;
  --sidebar-deep: #171717;
  --sidebar-line: rgba(255, 255, 255, .12);
  --teal: #3ecf8e;
  --teal-dark: #24b47e;
  --teal-soft: #e5f9ef;
  --amber: #a15c00;
  --amber-soft: #fff6df;
  --red: #c73e3e;
  --red-soft: #fff0f0;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .04);
  --shadow-md: 0 16px 40px rgba(0, 0, 0, .12);
}

html, body { background: var(--bg); color: var(--ink); }
body { line-height: 1.5; }

/* 登录是后台的第一道入口，保留足够留白但不使用装饰性渐变。 */
.login-shell { padding: 24px; background: var(--bg); }
.login-panel { border-radius: 8px; padding: 40px; background: var(--surface); box-shadow: 0 16px 40px rgba(0, 0, 0, .08); }
.login-panel::before { height: 3px; background: var(--teal); }
.product-mark { width: 44px; height: 44px; border: 0; border-radius: 8px; color: var(--ink); background: var(--teal); box-shadow: none; font-family: inherit; font-size: 21px; font-weight: 700; }
.product-mark.small { width: 36px; height: 36px; border-radius: 7px; font-size: 17px; }
.login-panel h1 { font-family: inherit; font-weight: 600; letter-spacing: -.03em; }

input, select, textarea { min-height: 38px; border-color: var(--border-strong); border-radius: 6px; color: var(--ink); background: var(--surface); }
input:hover, select:hover, textarea:hover { border-color: #9f9f9f; }
input:focus, select:focus, textarea:focus { border-color: var(--teal-dark); box-shadow: 0 0 0 3px rgba(62, 207, 142, .18); }

.app-shell { grid-template-columns: 240px minmax(0, 1fr); }
.sidebar { border-right: 1px solid #2d2d2d; padding: 20px 12px 16px; color: #b4b4b4; background: var(--sidebar); }
.side-brand { gap: 10px; padding: 0 10px 24px; color: #fff; }
.side-brand strong { font-size: 15px; font-weight: 600; }
.side-brand small { color: #8a8a8a; }
.nav-list { gap: 2px; }
.nav-section-label { margin: 14px 10px 6px; color: #707070; font-size: 10px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; }
.nav-section-label:first-child { margin-top: 0; }
.nav-section-label:not(:first-child) { padding-top: 7px; border-top: 1px solid rgba(255, 255, 255, .08); }
.nav-item { min-height: 38px; gap: 10px; border-radius: 6px; padding: 0 11px; color: #a8a8a8; font-size: 13px; font-weight: 500; }
.nav-item::before { width: 20px; height: 20px; border-color: rgba(255, 255, 255, .16); border-radius: 5px; color: #8f8f8f; }
.nav-item:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.nav-item.active { border-color: rgba(62, 207, 142, .35); color: #fff; background: rgba(62, 207, 142, .16); box-shadow: inset 2px 0 0 var(--teal); }
.nav-item.active::before { border-color: rgba(62, 207, 142, .6); color: var(--teal); background: rgba(62, 207, 142, .12); }
.sidebar-bottom { padding: 14px 10px 2px; color: #8a8a8a; }
.status-dot { width: 7px; height: 7px; background: var(--teal); box-shadow: 0 0 0 3px rgba(62, 207, 142, .16); }
.status-dot.offline { background: #e4a11b; box-shadow: 0 0 0 3px rgba(228, 161, 27, .16); }

.topbar { min-height: 72px; border-bottom: 1px solid var(--border); padding: 16px clamp(22px, 4vw, 48px); background: rgba(255, 255, 255, .96); box-shadow: none; backdrop-filter: none; }
.topbar .eyebrow { color: var(--muted); }
.topbar h1 { font-family: inherit; font-size: 24px; font-weight: 600; letter-spacing: -.025em; }
.account-menu { color: var(--muted-strong); font-weight: 500; }
.account-menu::before { width: 7px; height: 7px; background: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }
.content { width: min(100%, 1440px); padding: 32px clamp(22px, 4vw, 48px) 56px; }
.content:has(.view[data-panel="pricing"].active) { width: min(100%, 1800px); }
.view { gap: 20px; }

.section-heading h2, .section-heading h3, .table-toolbar h3, .dialog-heading h2 { font-family: inherit; font-weight: 600; letter-spacing: -.02em; }
.section-heading h2 { margin-bottom: 6px; font-size: clamp(24px, 3vw, 30px); }
.section-heading h3, .table-toolbar h3 { margin-bottom: 5px; font-size: 18px; }
.section-heading p, .table-toolbar p { line-height: 1.6; }

.connection-strip { gap: 13px; border: 1px solid #b9e7d0; border-radius: 8px; padding: 16px 18px; color: #155b4a; background: var(--surface-tint); box-shadow: none; }
.connection-strip::after { display: none; }
.connection-strip .status-dot { margin-top: 5px; background: var(--teal-dark); }
.connection-strip.offline { border-color: #ead28b; color: #704613; background: #fffaf0; }
.connection-strip strong { color: #155b4a; }
.connection-strip.offline strong { color: #84500d; }

.metric-grid { gap: 12px; }
.metric { min-height: 132px; border-radius: 8px; padding: 18px; background: var(--surface); box-shadow: none; transition: border-color .18s ease, background .18s ease; }
.metric:hover { border-color: var(--border-strong); background: #fff; box-shadow: none; transform: none; }
.metric::after { display: none; }
.metric span, .metric small { color: var(--muted); }
.metric span::before { width: 6px; height: 6px; margin-right: 7px; background: var(--teal); }
.metric:nth-child(2) span::before { background: #8c8c8c; }
.metric:nth-child(3) span::before { background: var(--teal-dark); }
.metric:nth-child(4) span::before { background: #d08b00; }
.metric strong { margin: 18px 0 8px; color: var(--ink); font-size: clamp(28px, 4vw, 38px); font-weight: 600; letter-spacing: -.045em; }
.metric:nth-child(3) strong { color: var(--teal-dark); }
.metric:nth-child(4) strong { color: #8a5b00; }

.section-block, .tool-panel { border-radius: 8px; background: var(--surface); box-shadow: none; }
.section-block { padding: 22px; }
.tool-grid { gap: 14px; }
.tool-panel { padding: 22px; }
.panel-title h3 { font-weight: 600; }
.pricing-inline-form { gap: 14px; border-color: #cfe2d8; border-radius: 8px; padding: 16px; background: var(--surface-soft); box-shadow: none; }
.pricing-inline-fields { gap: 10px; }
.pricing-editor-row td { padding: 8px; background: var(--surface-soft); }
.inline-note { border-color: #b9dfcc; border-radius: 6px; background: var(--surface-tint); }
.toggle-field { min-height: 38px; border-radius: 6px; background: var(--surface); }
.toggle-field input, .check-cell input { accent-color: var(--teal-dark); }
.field-disabled input { background: #f3f3f3; }
.daily-stats-block { background: var(--surface); }

.table-toolbar { align-items: flex-end; margin-top: 2px; }
.table-toolbar-actions, .action-cell { gap: 6px; }
.compact-filter { font-weight: 500; }
.compact-filter input, .compact-filter select { min-height: 34px; border-radius: 6px; }
.table-wrap { border-color: var(--border); border-radius: 8px; background: var(--surface); box-shadow: none; }
th { border-bottom-color: var(--border); padding: 11px 14px; color: #707070; background: #fafafa; font-size: 10px; font-weight: 600; letter-spacing: .06em; }
td { border-bottom-color: #ededed; padding: 13px 14px; color: var(--muted-strong); }
tbody tr:hover { background: #fcfcfc; }
td strong { color: var(--ink); font-weight: 600; }
td code, code { border-radius: 5px; color: #236253; background: var(--surface-tint); }
.empty { padding: 34px 16px !important; color: #8b8b8b; }

.button { min-height: 36px; border-radius: 6px; padding: 0 14px; font-size: 12px; font-weight: 600; box-shadow: none; }
.button:hover { transform: none; }
.button-primary { color: var(--ink); background: var(--teal); box-shadow: none; }
.button-primary:hover { color: var(--ink); background: var(--teal-dark); box-shadow: none; }
.button-secondary { border-color: var(--border-strong); color: var(--muted-strong); background: var(--surface); }
.button-secondary:hover { border-color: #9f9f9f; color: var(--ink); background: #f7f7f7; }
.button-quiet { min-height: 32px; color: var(--muted-strong); }
.button-quiet:hover { color: var(--ink); background: #f2f2f2; }
.button-danger { border-color: #e8b5b5; color: #b72f2f; background: #fffafa; }
.button-danger:hover { border-color: #d98b8b; background: var(--red-soft); }
.button-small { min-height: 30px; border-radius: 5px; font-weight: 600; }
.icon-button { width: 34px; height: 34px; border-color: var(--border-strong); border-radius: 6px; background: var(--surface); }
.icon-button:hover { color: var(--teal-dark); border-color: #9fd5bb; background: var(--teal-soft); }
.badge { min-height: 22px; padding: 2px 8px; font-weight: 600; }
.badge.success { color: #127458; background: var(--teal-soft); }
.badge.warning { color: #8a5b00; background: var(--amber-soft); }
.badge.muted { color: #707070; background: #f0f0f0; }

.created-key-panel { border-color: #a9ddc2; border-radius: 8px; padding: 16px 18px; color: #164c39; background: var(--surface-tint); box-shadow: none; }
.created-key-panel code { background: var(--surface); }
.log-filter-form { gap: 10px; }
.pagination { margin-top: 10px; }
.detail-item { border-radius: 6px; background: var(--surface-soft); }
.pending-token-fields { border-radius: 6px; background: var(--surface-tint); }

.profit-row, .profit-total { border-radius: 6px; }
.profit-row.positive, .profit-total.positive { background: #f2fbf6; }
.profit-row.negative, .profit-total.negative { background: #fff8f8; }

.toast { right: 24px; bottom: 24px; border-radius: 6px; padding: 12px 14px; color: #0a674f; background: var(--surface-tint); box-shadow: 0 10px 24px rgba(0, 0, 0, .10); }
.toast.error { color: #9f2720; background: var(--red-soft); }
.usage-dialog { width: min(1120px, calc(100vw - 32px)); }
.usage-dialog::backdrop { background: rgba(23, 23, 23, .42); backdrop-filter: none; }
.usage-dialog-panel { gap: 16px; border-color: var(--border); border-radius: 8px; padding: 22px; background: var(--surface); box-shadow: 0 20px 52px rgba(0, 0, 0, .18); }
.dialog-heading h2 { font-size: 22px; }

button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--teal-dark); outline-offset: 2px; }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 224px minmax(0, 1fr); }
}

@media (max-width: 760px) {
  .sidebar { padding: 14px 12px 12px; }
  .side-brand { padding: 0 6px 14px; }
  .nav-section-label { display: none; }
  .nav-list { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
  .nav-item { min-height: 42px; justify-content: center; gap: 4px; padding: 4px 3px; text-align: center; font-size: 11px; }
  .nav-item::before { width: 17px; height: 17px; border: 0; font-size: 13px; }
  .topbar { min-height: 68px; padding: 13px 17px; }
  .content { padding: 22px 17px 38px; }
  .section-block, .tool-panel { padding: 17px; }
  .metric { min-height: 116px; padding: 15px; }
  .metric strong { margin-top: 14px; font-size: 28px; }
  .usage-dialog-panel { border-radius: 8px; }
}

@media (max-width: 460px) {
  .nav-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric { min-height: 108px; }
  .metric strong { font-size: 25px; }
}