:root {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #182736;
  background: #f5f7f8;
  font-synthesis: none;
  --surface: #fff;
  --line: #e1e8eb;
  --muted: #586874;
  --accent: #076657;
  --accent-soft: #e3f1ed;
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
h1, h2, p, dl, dd { margin: 0; }
h1 { font-size: clamp(24px, 3vw, 32px); letter-spacing: -.035em; line-height: 1.3; }
h2 { font-size: 17px; }
button, input, select { font: inherit; }
button, input, select { border: 1px solid var(--line); border-radius: 7px; min-height: 40px; }
button { padding: 0 14px; background: var(--surface); color: inherit; cursor: pointer; white-space: nowrap; }
button:hover:not(:disabled) { background: #eff4f5; }
button:disabled { cursor: default; opacity: .55; }
button.primary { background: var(--accent); color: white; border-color: var(--accent); }
button.primary:hover:not(:disabled) { background: #064e42; }
input, select { padding: 8px 11px; background: white; color: inherit; width: 100%; }
:focus-visible { outline: 2px solid #0b7f71; outline-offset: 3px; }
label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.brand { display: flex; gap: 10px; align-items: center; font-weight: 700; }
.brand small { font-size: 12px; color: var(--muted); font-weight: 500; display: block; }
.mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; background: var(--accent); color: white; }
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-form { width: min(100%, 380px); padding: 30px; display: grid; gap: 18px; }
.login-form h1 { font-size: 24px; margin-top: 7px; }
.workspace { display: grid; min-height: 100dvh; grid-template-columns: 212px minmax(0, 1fr); }
.sidebar { background: white; border-right: 1px solid var(--line); padding: 25px 17px; display: flex; flex-direction: column; gap: 32px; }
.sidebar .brand { padding-inline: 8px; }
nav, .account { display: grid; gap: 6px; }
nav a { padding: 11px 12px; border-radius: 7px; color: var(--muted); text-decoration: none; font-size: 14px; }
nav a:hover { background: #f1f5f5; }
nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.account { margin-top: auto; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.account button { text-align: left; }
.content { padding: 32px clamp(16px, 4vw, 50px); width: 100%; max-width: 1470px; margin-inline: auto; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
#edit-user { color: var(--muted); font-size: 14px; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.metrics .panel { padding: 17px 20px; }
dt, .legend, .pagination { font-size: 13px; color: var(--muted); }
dd { font-size: clamp(22px, 3vw, 31px); font-weight: 660; margin-top: 7px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.trend { padding: 20px; }
.trend-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.legend { display: flex; gap: 14px; list-style: none; padding: 0; margin: 0; }
.legend li::before { content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 5px; border-radius: 2px; background: var(--accent); }
.legend li + li::before { background: #4864ac; }
.trend-bars { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.day { display: grid; grid-template-rows: 136px auto; gap: 8px; text-align: center; font-size: 12px; color: var(--muted); }
.bar-group { display: flex; gap: 4px; align-items: end; justify-content: center; border-bottom: 1px solid var(--line); }
.bar { display: grid; align-items: end; justify-items: center; width: min(34%, 28px); height: 100%; }
.bar-fill { display: block; position: relative; width: 100%; height: var(--height); min-height: 2px; background: var(--accent); border-radius: 4px 4px 0 0; }
.bar:nth-child(2) .bar-fill { background: #4864ac; }
.bar-fill span { position: absolute; bottom: calc(100% + 3px); left: 50%; transform: translateX(-50%); color: #334554; font-size: 11px; font-variant-numeric: tabular-nums; }
.search { display: flex; gap: 8px; padding: 16px; }
.search input { max-width: 290px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 14px; }
th, td { padding: 11px 13px; border-top: 1px solid var(--line); white-space: nowrap; }
th { font-weight: 600; font-size: 12px; color: var(--muted); background: #f8fafb; }
td:nth-child(n+3):nth-child(-n+6) { font-variant-numeric: tabular-nums; }
td small { display: block; margin-top: 3px; color: var(--muted); }
td button { min-height: 32px; color: var(--accent); }
td.empty { text-align: center; color: var(--muted); padding: 27px; }
.pagination { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); }
.pagination button + button, .dialog-actions button + button { margin-left: 6px; }
dialog { width: min(calc(100% - 36px), 410px); border: 1px solid var(--line); border-radius: 12px; padding: 24px; color: inherit; }
dialog::backdrop { background: rgb(16 33 41 / 44%); }
dialog form { display: grid; gap: 14px; }
.dialog-actions { text-align: right; }
.error { color: #982b2b; font-size: 14px; overflow-wrap: anywhere; }
.notice { padding: 10px 14px; background: #faeeee; border-radius: 7px; margin-bottom: 14px; }
@media (max-width: 760px) {
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar { padding: 10px 12px; gap: 8px; border-right: 0; border-bottom: 1px solid var(--line); flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar .brand { padding-inline: 0; }
  .sidebar .mark { width: 30px; height: 30px; }
  nav { display: flex; flex-wrap: wrap; }
  nav a { padding: 8px; }
  .account { margin: 0 0 0 auto; }
  .account span { display: none; }
  .account button { font-size: 12px; min-height: 33px; padding: 0 8px; }
  .content { padding-block: 20px; }
  .metrics .panel { padding: 12px; }
  .trend { padding: 13px; }
}
@media (max-width: 385px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

td button + button { margin-left: 6px; }
.chat-dialog, .image-dialog { width: min(calc(100% - 28px), 760px); max-height: 86dvh; }
.chat-header { display: flex; justify-content: space-between; align-items: start; gap: 12px; margin-bottom: 14px; }
.chat-header h2 { overflow-wrap: anywhere; }
.dialog-user { color: var(--muted); font-size: 13px; margin-top: 5px; overflow-wrap: anywhere; }
.chat-status { color: var(--muted); font-size: 14px; padding: 10px 0; }
.conversation-list, .chat-messages { list-style: none; margin: 0; padding: 0; }
.conversation-list { display: grid; gap: 7px; }
.conversation-button { width: 100%; display: grid; gap: 5px; text-align: left; padding: 10px 13px; white-space: normal; overflow-wrap: anywhere; }
.conversation-button small, .chat-turn time { font-size: 12px; color: var(--muted); }
.chat-tools { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.chat-turn { display: grid; gap: 8px; padding: 12px 0; border-top: 1px solid var(--line); }
.chat-prompt, .chat-answer { padding: 10px 12px; border-radius: 7px; background: #f1f5f6; }
.chat-prompt { background: var(--accent-soft); }
.chat-turn strong { font-size: 13px; }
.chat-turn p { margin-top: 5px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.6; }
.chat-images { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chat-thumbnail { width: 80px; height: 64px; padding: 0; overflow: hidden; font-size: 12px; }
.chat-thumbnail img { display: block; width: 100%; height: 100%; object-fit: cover; }
#image-preview img { display: block; max-width: 100%; max-height: 68dvh; margin: 0 auto; object-fit: contain; }
#image-preview img[hidden] { display: none; }
.analysis-back { margin-bottom: 12px; }
.detail-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); gap: 10px; }
.detail-fields > div { padding: 10px 12px; background: #f1f5f6; border-radius: 7px; }
.detail-fields dd { font-size: 14px; margin-top: 4px; font-weight: 500; }
#user-data-body h3 { margin: 18px 0 9px; font-size: 15px; }
.report-text { font-size: 14px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
#analysis-pagination { margin-top: 10px; }
.analysis-images button { display: grid; align-content: start; gap: 4px; width: 112px; padding: 6px; white-space: normal; overflow-wrap: anywhere; }
.analysis-images img { width: 100%; height: 70px; object-fit: cover; border-radius: 4px; }
.analysis-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 16px 0; }
.playground-page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.playground-panel { padding: 18px 20px; min-width: 0; }
#playground-workbench { display: grid; gap: 14px; margin-bottom: 14px; }
.playground-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.playground-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.playground-heading button { min-height: 34px; }
.playground-note { color: var(--muted); font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; }
.playground-source-info { display: grid; gap: 4px; margin-block: 10px; overflow-wrap: anywhere; }
#playground-config-status { margin: 0 0 14px; }
#playground-fields { display: grid; gap: 12px; min-inline-size: 0; padding: 0; margin: 14px 0 0; border: 0; }
#playground-fields textarea { width: 100%; min-height: 68px; border: 1px solid var(--line); border-radius: 7px; padding: 8px 11px; font: inherit; color: inherit; resize: vertical; }
#playground-api-address { margin-top: -8px; }
.playground-actions { display: flex; justify-content: flex-end; }
#playground-result, #playground-result-error, #playground-run-error { margin-top: 10px; }
.playground-status { padding: 4px 8px; border-radius: 5px; background: #f1f5f6; color: var(--muted); font-size: 12px; white-space: nowrap; }
.playground-status[data-status="running"] { background: #e9effb; color: #355187; }
.playground-status[data-status="completed"] { background: var(--accent-soft); color: var(--accent); }
.playground-status[data-status="failed"] { background: #faeeee; color: #982b2b; }
.playground-run { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.playground-run > span:first-child { display: grid; gap: 4px; }
.playground-run[aria-current="true"] { border-color: var(--accent); background: var(--accent-soft); }
#playground-pagination { padding: 12px 0 0; margin-top: 12px; }
#playground-api-dialog { width: min(calc(100% - 28px), 530px); max-height: 86dvh; }
.playground-api-fields { display: grid; gap: 12px; min-inline-size: 0; padding: 0; margin: 0; border: 0; }
.playground-api-fields h3 { font-size: 15px; margin: 2px 0 0; }
#playground-saved-apis { max-height: 210px; overflow: auto; padding: 4px; margin: -4px; }
.playground-clear-key { display: flex; align-items: center; gap: 8px; }
.playground-clear-key input { width: auto; min-height: 0; }
@media (max-width: 960px) { .playground-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 460px) {
  .playground-panel { padding: 14px; }
  #playground .page-header { gap: 8px; flex-wrap: wrap; }
  #playground .page-header button { padding-inline: 8px; }
}

.membership-form {display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));align-items:end;gap:12px;padding:16px 0;}
.membership-form label {display:grid;gap:5px;}
.membership-form [hidden] {display:none;}
.membership-form output {grid-column:1/-1;}
.usage-filters {padding:16px;}
.usage-table {background:var(--surface);border:1px solid var(--line);border-radius:12px;}
#usage-results h2 {margin:22px 0 8px;}
.rate-link { color: var(--accent); font-size: 14px; }
#model-rates > h2 { margin: 24px 0 10px; }
#model-rates-status { color: var(--accent); }
#model-rates-list, #model-rate-bands { display: grid; gap: 12px; }
.rate-card { display: grid; gap: 12px; padding: 16px; min-width: 0; }
.rate-card h3 { margin: 0; font-size: 16px; overflow-wrap: anywhere; }
.rate-card header, .rate-band header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.rate-card header, .rate-actions { flex-wrap: wrap; }
.rate-actions { display: flex; gap: 8px; }
#model-rate-dialog { width: min(calc(100% - 28px), 740px); max-height: 90dvh; }
#model-rate-fields { border: 0; padding: 0; margin: 0; min-inline-size: 0; }
#model-rate-fields h3 { font-size: 16px; margin: 22px 0 10px; }
#model-rate-fields h3 small { color: var(--muted); font-size: 13px; font-weight: 400; }
.rate-inputs { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); gap: 12px; }
.rate-band { display: grid; gap: 10px; padding: 12px; background: #f5f7f8; border-radius: 8px; }
.rate-band header button { min-height: 30px; }
#model-rate-add-band { margin-top: 10px; }
#plans-body {padding:16px;}

#switches-fields { display: grid; gap: 1rem; border: 0; padding: 0 0 1.25rem; }
#switches-fields label { display: grid; gap: .35rem; max-width: 32rem; }
#switches-fields label[hidden] { display: none; }
#switches-fields .switch-option { display: flex; align-items: center; gap: .65rem; }
#switches-fields input[type=checkbox] { width: 1.15rem; height: 1.15rem; }
