:root {
  color-scheme: dark;
  --bg: #0c1018;
  --surface: #131a26;
  --surface-raised: #182132;
  --line: #2a364b;
  --text: #edf2ff;
  --muted: #93a0b8;
  --accent: #6b9cff;
  --accent-strong: #8db4ff;
  --good: #53d3a5;
  --warn: #f8bd62;
  --danger: #ff7d8e;
  --shadow: 0 20px 65px rgba(0, 0, 0, .28);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted, .hint { color: var(--muted); }
.eyebrow { margin: 0 0 7px; color: var(--accent-strong); font-size: 11px; font-weight: 750; letter-spacing: .14em; }

.connect-view { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 5%, #20345c 0, var(--bg) 42%); }
.connect-card { width: min(100%, 430px); padding: 42px; border: 1px solid var(--line); border-radius: 20px; background: rgba(19, 26, 38, .92); box-shadow: var(--shadow); }
.brand-mark { display: grid; width: 48px; height: 48px; margin-bottom: 24px; place-items: center; border-radius: 14px; color: #08101e; background: linear-gradient(135deg, var(--accent-strong), #71e3c4); font-size: 24px; font-weight: 850; }
.brand-mark.small { width: 30px; height: 30px; margin: 0; border-radius: 9px; font-size: 16px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(26px, 3vw, 34px); letter-spacing: -.035em; }
h2 { margin-bottom: 4px; font-size: 16px; letter-spacing: -.015em; }
.stack-form, .dialog-form { display: grid; gap: 13px; margin-top: 28px; }
label { display: grid; gap: 7px; color: #c6d0e4; font-size: 13px; font-weight: 650; }
input, select { width: 100%; min-height: 40px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; outline: none; color: var(--text); background: #0e1521; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(107, 156, 255, .16); }
.form-error { min-height: 18px; margin: 0; color: var(--danger); font-size: 13px; }
.hint { margin: 18px 0 0; font-size: 12px; line-height: 1.6; }

.button { min-height: 36px; padding: 8px 13px; border: 1px solid transparent; border-radius: 8px; color: var(--text); background: var(--surface-raised); font-size: 13px; font-weight: 700; transition: .15s ease; }
.button:hover { filter: brightness(1.12); transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .5; transform: none; }
.button.primary { color: #071122; background: linear-gradient(135deg, var(--accent-strong), #78d8ec); }
.button.quiet { border-color: var(--line); background: transparent; }

.topbar { position: sticky; z-index: 2; top: 0; display: flex; min-height: 62px; align-items: center; justify-content: space-between; padding: 0 28px; border-bottom: 1px solid var(--line); background: rgba(12, 16, 24, .88); backdrop-filter: blur(14px); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-size: 15px; font-weight: 750; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.last-updated { color: var(--muted); font-size: 12px; white-space: nowrap; }
.connection-state { color: var(--good); font-size: 13px; }
.connection-state::before { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: currentColor; content: ""; }
.workspace { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: calc(100vh - 62px); }
.sidebar { padding: 20px 14px; border-right: 1px solid var(--line); background: #101722; }
.nav-item { display: block; width: 100%; padding: 11px 13px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; text-align: left; font-size: 14px; font-weight: 700; }
.nav-item:hover, .nav-item.active { color: var(--text); background: #202b3f; }
.nav-item.active { box-shadow: inset 3px 0 var(--accent); }
.sidebar-note { margin: 25px 9px; color: #71809a; font-size: 12px; line-height: 1.65; }
.content { min-width: 0; width: min(1440px, 100%); padding: 35px clamp(20px, 4vw, 56px) 60px; }
.portal-content { margin: 0 auto; }
.notice { margin-bottom: 14px; padding: 12px 15px; border: 1px solid var(--line); border-radius: 9px; font-size: 13px; }
.notice.warning { border-color: #755c32; color: #ffd995; background: #302615; }
.notice.danger { border-color: #713b48; color: #ffb8c2; background: #321922; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 27px; }
.page-heading h1 { margin: 0; }
.page-heading .muted { margin: 9px 0 0; }

.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: #0f1622; }
.segmented button { padding: 7px 10px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 700; }
.segmented button.active { color: var(--text); background: #293854; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card { min-height: 135px; padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.stat-card span { display: block; color: var(--muted); font-size: 13px; }
.stat-card strong { display: block; margin: 14px 0 8px; font-size: clamp(23px, 2.5vw, 32px); letter-spacing: -.04em; }
.stat-card small { color: #7e8da7; font-size: 12px; }
.pool-inflight { display: grid; gap: 3px; margin: 4px 0; }
.pool-inflight > div { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.pool-inflight > div + div { padding-top: 3px; border-top: 1px solid var(--line); }
.pool-inflight dt { color: var(--muted); font-size: 13px; white-space: nowrap; }
.pool-inflight dd { margin: 0; color: var(--text); font-size: 20px; line-height: 1.1; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pool-inflight dd span { display: inline; color: var(--muted); font-size: 14px; font-weight: 400; }
@media (max-width: 560px) { .pool-inflight { gap: 2px; margin: 0; }.pool-inflight > div + div { padding-top: 2px; }.pool-inflight dd { font-size: 16px; }.pool-inflight dd span { font-size: 12px; } }
.stat-card .key-stat { overflow-wrap: anywhere; font-size: clamp(16px, 2vw, 22px); letter-spacing: 0; }
.compact .stat-card { min-height: 110px; }
.compact .stat-card strong { font-size: 25px; }

.panel { margin-bottom: 22px; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.panel-heading { display: flex; flex-wrap: wrap; min-height: 68px; align-items: center; justify-content: space-between; gap: 16px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.panel-heading h2, .panel-heading h3, .panel-heading p { margin: 0; }
.panel-heading .muted { margin-top: 4px; font-size: 12px; }
.compact-heading { min-height: 58px; border-top: 1px solid var(--line); }
.compact-heading h3 { font-size: 15px; }
.subscription-quota-body { padding: 18px 18px 0; }
.subscription-quota-body .stats-grid { margin-bottom: 18px; }
.subscription-quota-body .notice { margin-bottom: 18px; }
.chart-panel { min-height: 275px; }
.chart-panel .panel-heading > strong { font-size: 19px; }
.overview-chart-heading { flex-wrap: wrap; }
.overview-chart-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; }
.overview-chart-actions > strong { font-size: 19px; }
.line-chart { min-height: 195px; padding: 16px 18px 19px; }
.line-chart svg { display: block; width: 100%; height: 185px; overflow: visible; }
.line-chart .grid-line { stroke: #293448; stroke-width: 1; }
.line-chart .trend-area { pointer-events: none; }
.line-chart .trend-line { fill: none; stroke: #82adff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.line-chart .axis-label { fill: #7c8ba4; font-size: 11px; }
.chart-empty { display: grid; min-height: 175px; place-items: center; color: var(--muted); font-size: 13px; }
.two-column { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }

.toolbar { display: flex; align-items: center; gap: 11px; margin-bottom: 17px; }
.search { display: flex; flex: 1; align-items: center; max-width: 400px; gap: 8px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px; background: #0e1521; color: var(--muted); }
.search input { border: 0; box-shadow: none; background: transparent; }
.users-toolbar { flex-wrap: wrap; }
.bulk-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.bulk-actions select { width: auto; min-width: 145px; }
.filters { flex-wrap: wrap; align-items: end; }
.filters label { min-width: 145px; }
.filters select { min-width: 145px; }
.inline-filter { display: flex; align-items: center; gap: 8px; }
.inline-filter select { width: auto; min-width: 150px; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; font-size: 13px; }
th, td { padding: 13px 17px; border-bottom: 1px solid rgba(42, 54, 75, .7); text-align: left; }
th { color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
td { color: #dbe4f5; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(75, 95, 130, .11); }
.user-name { display: block; color: var(--text); font-weight: 700; }
.subtle { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.usage-bar { width: 95px; height: 6px; margin-right: 7px; overflow: hidden; border: 0; border-radius: 99px; vertical-align: middle; appearance: none; background: #263247; }
.usage-bar::-webkit-progress-bar { border-radius: inherit; background: #263247; }
.usage-bar::-webkit-progress-value { border-radius: inherit; background: var(--good); }
.usage-bar::-moz-progress-bar { border-radius: inherit; background: var(--good); }
.usage-bar.warn::-webkit-progress-value { background: var(--warn); }
.usage-bar.warn::-moz-progress-bar { background: var(--warn); }
.usage-bar.danger::-webkit-progress-value { background: var(--danger); }
.usage-bar.danger::-moz-progress-bar { background: var(--danger); }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; }
.status::before { width: 7px; height: 7px; border-radius: 50%; content: ""; background: currentColor; }
.status.enabled { color: var(--good); }.status.warning { color: var(--warn); }.status.disabled { color: var(--muted); }.status.error { color: var(--danger); }
.reasoning-badge { display: inline-flex; min-width: 35px; justify-content: center; padding: 3px 7px; border: 1px solid #465777; border-radius: 99px; color: #b9cced; background: #172238; font-size: 11px; font-weight: 750; }
.reasoning-badge.effort-low, .reasoning-badge.effort-minimal { border-color: #3d6f80; color: #86d0db; }.reasoning-badge.effort-medium { border-color: #6076a4; color: #b7c8ff; }.reasoning-badge.effort-high, .reasoning-badge.effort-xhigh { border-color: #8767b7; color: #d4bcff; }.reasoning-badge.effort-unknown, .reasoning-badge.effort-unspecified { color: var(--muted); }
.row-actions { display: flex; justify-content: flex-end; gap: 6px; }.row-actions .button { min-height: 30px; padding: 5px 8px; font-size: 12px; }
.pool-settings { display: grid; gap: 16px; padding: 20px; }
.pool-settings-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.pool-settings-heading > div { min-width: 0; flex: 1 1 320px; overflow-wrap: anywhere; }
.pool-settings-heading h2, .pool-settings-heading p { margin: 0; }
.pool-settings-heading p { margin-top: 8px; }
.pool-overview-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.pool-overview-item { min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-raised); }
.pool-overview-item-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pool-overview-item-heading strong { min-width: 0; overflow-wrap: anywhere; }
.pool-overview-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; color: var(--muted); font-size: 12px; }
.subscription-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; padding: 20px; border-bottom: 1px solid var(--line); }
.subscription-control { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; min-width: 0; }
.subscription-control h3, .subscription-control p { margin: 0; }
.subscription-control p, .control-status { font-size: 12px; line-height: 1.6; }
.subscription-control .row-actions { justify-content: flex-start; flex-wrap: wrap; margin-top: auto; }
@media (min-width: 1700px) { .subscription-controls { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 760px) { .pool-settings-heading { align-items: flex-start; flex-direction: column; }.pool-settings-heading > div { flex-basis: auto; }.pool-overview-list { grid-template-columns: 1fr; }.subscription-controls { grid-template-columns: 1fr; }.subscription-control + .subscription-control { padding-top: 16px; border-top: 1px solid var(--line); } }
.users-table { table-layout: fixed; white-space: normal; }
.users-table th, .users-table td { padding: 11px 9px; vertical-align: middle; }
.users-table th:nth-child(1) { width: 4%; }.users-table th:nth-child(2) { width: 16%; }.users-table th:nth-child(3) { width: 9%; }.users-table th:nth-child(4) { width: 15%; }.users-table th:nth-child(5) { width: 9%; }.users-table th:nth-child(6) { width: 11%; }.users-table th:nth-child(7) { width: 9%; }.users-table th:nth-child(8) { width: 16%; }.users-table th:nth-child(9) { width: 11%; }
.users-table .user-key { overflow-wrap: anywhere; }
.usage-primary, .usage-secondary { display: block; }
.usage-secondary { margin-top: 3px; }
.selection-column { text-align: center; }
.row-selector { width: 16px; min-height: 16px; padding: 0; accent-color: var(--accent-strong); vertical-align: middle; }
.user-action-select { width: 100%; min-width: 72px; min-height: 30px; padding: 5px 7px; font-size: 12px; }
.empty-row td { padding: 37px; color: var(--muted); text-align: center; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 13px; padding: 14px 18px; color: var(--muted); font-size: 12px; }

dialog { width: min(100% - 28px, 455px); padding: 0; border: 1px solid var(--line); border-radius: 14px; color: var(--text); background: var(--surface); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(3, 6, 12, .72); }
html:has(dialog:modal) { overflow: hidden; scrollbar-gutter: stable; }
#pool-dialog { width: min(640px, calc(100% - 28px)); max-height: 90dvh; overflow: hidden; }
#pool-form { display: flex; flex-direction: column; gap: 0; padding: 0; max-height: calc(90dvh - 2px); }
#pool-form > .dialog-heading, .pool-dialog-footer { flex-shrink: 0; padding: 18px 22px; }
#pool-form > .dialog-heading { border-bottom: 1px solid var(--line); }
.pool-dialog-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; padding: 18px 22px; }
.pool-dialog-body .hint, .pool-dialog-footer .hint { margin: 0; }
.pool-dialog-body h3 { margin: 22px 0 12px; font-size: 15px; }
#pool-project-list, #pool-account-list, #pool-member-list { display: grid; gap: 10px; }
#pool-member-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pool-project { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) auto; align-items: end; gap: 10px; }
.pool-project label { display: grid; gap: 5px; }
.pool-account { min-width: 0; overflow-wrap: anywhere; }
.pool-member { display: grid; gap: 5px; min-width: 0; min-height: 36px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; }
.pool-member .row-selector { flex: 0 0 16px; height: 16px; margin: 0; }
.pool-member span { min-width: 0; overflow-wrap: anywhere; }
.pool-dialog-footer { border-top: 1px solid var(--line); }
.pool-dialog-footer .form-error { min-height: 0; margin-top: 8px; overflow-wrap: anywhere; }
@media (max-width: 560px) { .pool-project, #pool-member-list { grid-template-columns: 1fr; } }
.dialog-form { margin: 0; padding: 24px; }.dialog-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; }.dialog-heading h2 { margin: 0; font-size: 20px; }.icon-button { width: 30px; height: 30px; padding: 0; border: 0; border-radius: 7px; color: var(--muted); background: transparent; font-size: 22px; line-height: 1; }.icon-button:hover { color: var(--text); background: #293448; }.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 9px; }.warning-text { margin: 4px 0; color: var(--warn); font-size: 13px; }.key-value { display: block; padding: 13px; overflow-wrap: anywhere; border: 1px solid #354766; border-radius: 8px; color: #bcd5ff; background: #0d1420; font-size: 12px; line-height: 1.55; }
.toast { position: fixed; z-index: 5; right: 22px; bottom: 22px; max-width: min(440px, calc(100% - 44px)); padding: 12px 15px; border: 1px solid #3d557b; border-radius: 9px; color: var(--text); background: #192841; box-shadow: var(--shadow); font-size: 13px; }.toast.error { border-color: #81404c; background: #381c26; }

@media (max-width: 1100px) { .workspace { grid-template-columns: minmax(0, 1fr); }.sidebar { display: flex; gap: 5px; padding: 10px 16px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }.nav-item { width: auto; white-space: nowrap; }.nav-item.active { box-shadow: inset 0 -3px var(--accent); }.sidebar-note { display: none; }.stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }.two-column { grid-template-columns: 1fr; } }
@media (max-width: 560px) { .topbar { padding: 0 15px; }.topbar-actions { gap: 6px; }.topbar-actions .connection-state, .topbar-actions .last-updated { display: none; }.topbar-actions .button { padding: 7px 9px; }.content { padding: 25px 15px 42px; }.page-heading { align-items: stretch; flex-direction: column; }.page-heading > .button { width: 100%; }.stats-grid { grid-template-columns: 1fr 1fr; gap: 9px; }.stat-card { min-height: 112px; padding: 14px; }.stat-card strong { font-size: 21px; }.segmented { width: 100%; }.segmented button { flex: 1; }.panel-heading { padding: 13px; } th, td { padding: 11px 13px; }.filters label { flex: 1 1 42%; }.filters .button { width: 100%; }.inline-filter { align-items: stretch; flex-direction: column; }.bulk-actions { width: 100%; margin-left: 0; }.bulk-actions select { flex: 1; min-width: 0; }.connect-card { padding: 29px 23px; } }
@media (max-width: 760px) { .users-table { min-width: 820px; } }

#model-weights-dialog { width: min(620px, calc(100% - 28px)); max-height: 90dvh; }
#model-weights-dialog .table-wrap { max-height: 40dvh; overflow-y: auto; }
#model-weights-dialog table { table-layout: fixed; }
#model-weights-dialog th:first-child { width: 55%; }
#model-weights-dialog th:last-child { width: 68px; }
#model-weights-dialog td { padding: 8px 4px; }
#model-weights-dialog input { min-width: 0; width: 100%; }

#model-weights-form .hint { margin: 0; }

.quota-pool-details { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 12px; margin-bottom: 18px; }
.quota-pool-detail { min-width: 0; padding: 14px 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.quota-pool-detail h3 { margin: 0 0 8px; font-size: 14px; }
.quota-pool-detail p, .quota-pool-detail small { margin: 5px 0; overflow-wrap: anywhere; }
.quota-pool-detail summary { cursor: pointer; font-size: 12px; }
.group-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.group-controls select { min-width: 130px; }
@media (max-width: 560px) { .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 15px; }.brand { flex-shrink: 0; white-space: nowrap; }.topbar-actions { flex-wrap: wrap; margin-left: auto; }.topbar-actions .button { white-space: nowrap; } }
