/* ============================================================
   AI 聚合网关 · 控制台样式
   移动端优先 · 零横向溢出 · 扁平 · 无渐变
   ============================================================ */

/* ---------- 设计令牌 ---------- */
:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --surface-2: #fafbfc;
    --border: #e5e7eb;
    --border-strong: #d1d5db;
    --text: #16181d;
    --text-soft: #5b6472;
    --text-faint: #8b94a3;

    --primary: #2563eb;
    --primary-deep: #1d4ed8;
    --primary-soft: #eef3ff;

    --amber: #b45309;
    --amber-soft: #fdf3e3;
    --celadon: #15803d;
    --celadon-soft: #e9f6ee;
    --rust: #b91c1c;
    --rust-soft: #fdecec;
    --clay: #4b5563;
    --clay-soft: #f1f2f4;
    --plum: #7c3aed;
    --plum-soft: #f3eefe;

    --r-xs: 6px;
    --r-sm: 8px;
    --r-md: 11px;
    --r-lg: 15px;
    --r-xl: 20px;

    --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-sm: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
    --shadow-md: 0 8px 24px rgba(16, 24, 40, .10);
    --shadow-lg: 0 20px 48px rgba(16, 24, 40, .18);

    --sidebar-w: 232px;
    --header-h: 58px;

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
        "Liberation Mono", monospace;
}

[data-theme="dark"] {
    --bg: #0f1216;
    --surface: #171b21;
    --surface-2: #1c2128;
    --border: #272d36;
    --border-strong: #39414d;
    --text: #e8ebef;
    --text-soft: #a2abba;
    --text-faint: #737d8c;

    --primary: #4f83f1;
    --primary-deep: #3b6fe0;
    --primary-soft: #1b2740;

    --amber: #e0a54a;
    --amber-soft: #2c2415;
    --celadon: #4fbf83;
    --celadon-soft: #14271d;
    --rust: #e8776b;
    --rust-soft: #2c1a19;
    --clay: #97a1af;
    --clay-soft: #21262d;
    --plum: #a78bfa;
    --plum-soft: #221c33;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .5);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, .55);
    --shadow-lg: 0 20px 48px rgba(0, 0, 0, .65);
}

/* ---------- 基础重置 ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
    min-width: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

html,
body {
    margin: 0;
    padding: 0;
    max-width: 100%;
    overflow-x: hidden;
}

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6, p, figure {
    margin: 0;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button,
input,
select,
textarea {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

img,
svg,
video,
canvas {
    max-width: 100%;
    height: auto;
}

.mono {
    font-family: var(--mono);
    font-feature-settings: "tnum" 1;
}

.text-soft { color: var(--text-soft); }
.text-faint { color: var(--text-faint); }
.text-sm { font-size: 12.5px; }

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.mb-0 { margin-bottom: 0 !important; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }

.flex { display: flex; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.flex-col { flex-direction: column; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.flex-1 { flex: 1 1 auto; min-width: 0; }
.ml-auto { margin-left: auto; }
.w-full { width: 100%; }
.nowrap { white-space: nowrap; }

/* 通用横向换行容器：所有按钮组/标签组都应带这个，避免挤压溢出 */
.wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* ---------- 应用骨架 ---------- */
.shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: block;
}

/* 未登录（登录 / 注册页）：隐藏侧栏，内容区占满 */
.shell--guest .sidebar { display: none; }
.shell--guest .main { margin-left: 0; }
.shell--guest .scrim { display: none; }

/* ---------- 侧栏 ---------- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 60;
    overflow-y: auto;
    overflow-x: hidden;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 16px 14px;
    border-bottom: 1px solid var(--border);
}

.brand__mark {
    width: 34px;
    height: 34px;
    flex: none;
    border-radius: var(--r-sm);
    background: var(--primary-soft);
    color: var(--primary);
    display: grid;
    place-items: center;
}

.brand__text {
    min-width: 0;
}

.brand__name {
    font-size: 14.5px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand__sub {
    font-size: 11.5px;
    color: var(--text-faint);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav {
    padding: 10px 10px 16px;
    flex: 1 1 auto;
}

.nav__group {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-faint);
    padding: 14px 10px 6px;
}

.nav__item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    margin-bottom: 2px;
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--text-soft);
    font-size: 13.5px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background .12s ease, color .12s ease;
}

.nav__item:hover {
    background: var(--surface-2);
    color: var(--text);
}

.nav__item.is-active {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 600;
}

.nav__item .ic { flex: none; }

.nav__label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar__foot {
    padding: 12px 14px 16px;
    border-top: 1px solid var(--border);
    font-size: 11.5px;
    color: var(--text-faint);
}

/* ---------- 主区 ---------- */
.main {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-width: 100%;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    height: var(--header-h);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar__title {
    font-size: 15.5px;
    font-weight: 650;
    line-height: 1.25;
}

.topbar__desc {
    font-size: 12.5px;
    color: var(--text-faint);
    line-height: 1.25;
}

.topbar__head {
    min-width: 0;
    flex: 1 1 auto;
}

.topbar__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: none;
}

.topbar__user {
    max-width: 150px;
    min-width: 0;
}

.topbar__user-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar__group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: none;
}

.menu-toggle {
    display: none;
    width: 38px;
    height: 38px;
    flex: none;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    place-items: center;
}

.content {
    flex: 1 1 auto;
    padding: 18px 20px 40px;
    width: 100%;
    max-width: 1320px;
    margin: 0 auto;
    min-width: 0;
}

/* 页面头（每页内容区顶部的标题 + 操作，统一装进浅色框架） */
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 13px 15px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xs);
    min-width: 0;
}

.page-head__main {
    min-width: 0;
    flex: 1 1 220px;
}

.page-head__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* 卡片内部的页面头（如趋势图指标切换）不再重复叠加外框 */
.card .page-head {
    margin-bottom: 0;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    align-items: flex-start;
}

.scrim {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 18, 22, .45);
    z-index: 55;
}

/* ---------- 图标 ---------- */
.ic {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    flex: none;
}

.ic svg { display: block; }

.ic--text {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-faint);
}

/* ---------- 卡片 ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xs);
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

.card + .card { margin-top: 16px; }

.card__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 15px 16px;
    border-bottom: 1px solid var(--border);
}

.card__titles { min-width: 0; flex: 1 1 200px; }

.card__title {
    font-size: 14.5px;
    font-weight: 650;
    line-height: 1.3;
}

.card__sub {
    font-size: 12.5px;
    color: var(--text-faint);
    margin-top: 2px;
}

/* 卡片头操作区：始终换行，绝不横向溢出 */
.card__actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
}

.card__body {
    padding: 16px;
    min-width: 0;
}

.card__body--flush {
    padding: 0;
    min-width: 0;
}

/* ---------- 网格 ---------- */
.grid {
    display: grid;
    gap: 14px;
    min-width: 0;
}

.grid--stats {
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
}

.grid--2 {
    grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
}

.grid--cards {
    grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
}

.grid--list {
    grid-template-columns: 1fr;
}

/* ---------- 统计块 ---------- */
.stat {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 13px 14px 13px 16px;
    min-width: 0;
    overflow: hidden;
}

.stat::after {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--clay);
}

.stat--primary::after { background: var(--primary); }
.stat--amber::after { background: var(--amber); }
.stat--celadon::after { background: var(--celadon); }
.stat--rust::after { background: var(--rust); }
.stat--plum::after { background: var(--plum); }

.stat__top {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-faint);
}

.stat__label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 500;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stat__value {
    font-size: 21px;
    font-weight: 700;
    line-height: 1.2;
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat__foot {
    font-size: 11.5px;
    color: var(--text-faint);
    margin-top: 2px;
}

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-weight: 550;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
    transition: background .12s ease, border-color .12s ease, opacity .12s ease;
    max-width: 100%;
}

.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(.5px); }

.btn:disabled {
    opacity: .55;
    cursor: not-allowed;
}

.btn--primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn--primary:hover { background: var(--primary-deep); border-color: var(--primary-deep); }

.btn--amber { background: var(--amber-soft); border-color: transparent; color: var(--amber); }
.btn--celadon { background: var(--celadon-soft); border-color: transparent; color: var(--celadon); }
.btn--danger { background: var(--rust-soft); border-color: transparent; color: var(--rust); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--text-soft); }
.btn--ghost:hover { background: var(--surface-2); }

.btn--sm {
    padding: 6px 10px;
    font-size: 12.5px;
    border-radius: var(--r-xs);
}

.btn--block { width: 100%; }

.btn--icon {
    padding: 8px;
    width: 36px;
    height: 36px;
}

.btn--icon.btn--sm { width: 30px; height: 30px; padding: 6px; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }

.field__label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-soft);
    margin-bottom: 6px;
}

.field__hint {
    font-size: 12px;
    color: var(--text-faint);
    margin-top: 5px;
    line-height: 1.5;
}

.field__row {
    display: flex;
    gap: 8px;
    align-items: stretch;
    flex-wrap: wrap;
}

.field__row > .input,
.field__row > .select,
.field__row > .textarea {
    flex: 1 1 200px;
    width: auto;
    min-width: 0;
}

/* 图形验证码图片：固定尺寸，点击可刷新 */
.captcha-img {
    flex: 0 0 auto;
    width: 118px;
    height: 100%;
    min-height: 38px;
    object-fit: contain;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    user-select: none;
}

.input,
.select,
.textarea {
    width: 100%;
    max-width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    background: var(--surface);
    font-size: 13.5px;
    line-height: 1.4;
    outline: none;
    transition: border-color .12s ease, box-shadow .12s ease;
}

.input:focus,
.select:focus,
.textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.input:read-only,
.input[readonly] {
    background: var(--surface-2);
    color: var(--text-soft);
}

.textarea {
    resize: vertical;
    min-height: 82px;
}

.select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b94a3' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 11px center;
    padding-right: 32px;
}

/* ---------- 开关 ---------- */
.switch {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    cursor: pointer;
    font-size: 13.5px;
    user-select: none;
    max-width: 100%;
}

.switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.switch__track {
    position: relative;
    width: 38px;
    height: 22px;
    flex: none;
    border-radius: 999px;
    background: var(--border-strong);
    transition: background .15s ease;
}

.switch__track::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: var(--shadow-xs);
    transition: transform .15s ease;
}

.switch input:checked + .switch__track { background: var(--primary); }
.switch input:checked + .switch__track::after { transform: translateX(16px); }
.switch input:disabled + .switch__track { opacity: .5; }
.switch > span:last-child { min-width: 0; }

/* ---------- 徽标 ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
    background: var(--clay-soft);
    color: var(--clay);
}

.badge--success { background: var(--celadon-soft); color: var(--celadon); }
.badge--warning { background: var(--amber-soft); color: var(--amber); }
.badge--danger { background: var(--rust-soft); color: var(--rust); }
.badge--primary { background: var(--primary-soft); color: var(--primary); }
.badge--plum { background: var(--plum-soft); color: var(--plum); }
.badge--amber { background: var(--amber-soft); color: var(--amber); }
.badge--celadon { background: var(--celadon-soft); color: var(--celadon); }
.badge--rust { background: var(--rust-soft); color: var(--rust); }
.badge--clay { background: var(--clay-soft); color: var(--clay); }
.badge--muted { background: var(--clay-soft); color: var(--text-faint); }

.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex: none;
}

/* ---------- 分段控件 ---------- */
.segbar {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 3px;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface-2);
    max-width: 100%;
}

.segbar__item {
    padding: 6px 12px;
    border: 0;
    border-radius: var(--r-xs);
    background: transparent;
    color: var(--text-soft);
    font-size: 12.5px;
    font-weight: 550;
    cursor: pointer;
    white-space: nowrap;
    transition: background .12s ease, color .12s ease;
}

.segbar__item:hover { color: var(--text); }

.segbar__item.is-active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: var(--shadow-xs);
}

/* 卡片右上角 分段控件 + 按钮 的紧凑排布 */
.trend-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
}

.trend-actions .segbar { width: auto; }

/* ---------- 表格 ---------- */
.table__wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.table th {
    text-align: left;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .02em;
    text-transform: uppercase;
    color: var(--text-faint);
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    background: var(--surface-2);
}

.table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- 空 / 加载 ---------- */
.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 44px 20px;
    gap: 6px;
}

.empty__icon {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--text-faint);
    margin-bottom: 4px;
}

.empty__title { font-size: 14px; font-weight: 600; }
.empty__desc { font-size: 12.5px; color: var(--text-faint); max-width: 380px; }

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 44px 20px;
    color: var(--text-faint);
    font-size: 13px;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-strong);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    flex: none;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 供应商 / 账号 卡片 ---------- */
.provider,
.account {
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 3px solid var(--tone, var(--clay));
    border-radius: var(--r-md);
    padding: 14px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.provider.is-off,
.account.is-off { opacity: .58; }

.provider__head,
.account__head {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-width: 0;
}

.avatar {
    width: 36px;
    height: 36px;
    flex: none;
    border-radius: var(--r-sm);
    display: grid;
    place-items: center;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    background: var(--tone, var(--clay));
}

.avatar--lg { width: 44px; height: 44px; font-size: 15px; }

.avatar__img {
    width: 100%;
    height: 100%;
    border-radius: inherit;
    object-fit: cover;
    display: block;
}

.provider__title,
.account__title {
    min-width: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.provider__name,
.account__name {
    font-size: 14px;
    font-weight: 650;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.provider__key,
.account__sub {
    font-size: 12px;
    color: var(--text-faint);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.provider__meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(62px, 1fr));
    gap: 8px;
}

.kv-item {
    min-width: 0;
    padding: 7px 8px;
    border-radius: var(--r-xs);
    background: var(--surface-2);
    text-align: center;
}

.kv-item b {
    display: block;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kv-item span {
    display: block;
    margin-top: 1px;
    font-size: 11px;
    color: var(--text-faint);
    white-space: nowrap;
}

.account__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin: 0;
}

.account__meta > div {
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 5px;
    font-size: 12px;
}

.account__meta dt { flex: none; color: var(--text-faint); }

.account__meta dd {
    margin: 0;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.provider__actions,
.account__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 2px;
}

/* ---------- 供应商分组（按供应商列账号） ---------- */
.provider-groups {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.provider-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface-2);
    min-width: 0;
}

/* 分组内：供应商卡收成一条横向紧凑表头，避免整块过高 */
.provider-group > .provider {
    background: var(--surface);
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 14px;
    padding: 10px 12px;
}

.provider-group > .provider .provider__head {
    flex: 1 1 200px;
    align-items: center;
}

.provider-group > .provider .provider__meta {
    flex: 0 1 auto;
    grid-template-columns: repeat(4, minmax(52px, 1fr));
}

.provider-group > .provider .provider__actions {
    flex: 0 0 auto;
    margin-top: 0;
    justify-content: flex-end;
}

/* 分组内账号卡更紧凑、列更窄 */
.provider-group__body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-left: 10px;
    border-left: 2px solid var(--border-strong);
    min-width: 0;
}

.provider-group__body .grid--cards {
    grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr));
    gap: 10px;
}

.provider-group__body .account {
    padding: 10px 12px;
    gap: 8px;
}

.provider-group__bar {
    display: flex;
    align-items: center;
    gap: 8px;
}

.provider-group__label {
    font-size: 12px;
    font-weight: 650;
    letter-spacing: .02em;
    color: var(--text-faint);
}

.provider-group__empty {
    padding: 14px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--r-sm);
    font-size: 12.5px;
    color: var(--text-faint);
    text-align: center;
}

/* ---------- 模型行 ---------- */
.modelrow {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface-2);
    min-width: 0;
    max-width: 100%;
}

.modelrow__main {
    min-width: 0;
    flex: 1 1 260px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.modelrow__title {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 0;
}

.modelrow__id {
    font-family: var(--mono);
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text);
    overflow-wrap: anywhere;
    word-break: break-word;
}

.modelrow__call {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 0;
}

.modelrow__call-label {
    flex: none;
    font-size: 11px;
    color: var(--text-faint);
    line-height: 1.4;
}

.modelrow__call-val {
    font-family: var(--mono);
    font-size: 11.5px;
    color: var(--text-soft);
    line-height: 1.4;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.modelrow__alias {
    font-size: 11.5px;
    color: var(--text-faint);
    line-height: 1.4;
}

.modelrow__meta {
    font-size: 11.5px;
    color: var(--text-soft);
    line-height: 1.5;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.modelrow__side {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    flex: 0 1 auto;
    margin-left: auto;
    min-width: 0;
    max-width: 100%;
}

.modelrow__tags {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 7px;
    min-width: 0;
}

.modelrow__ops {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 7px;
    flex: none;
}

/* ---------- 模型目录分组头 ---------- */
.card__head--custom {
    align-items: center;
    padding: 12px 14px;
}

.grouphead {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    width: 100%;
}

.grouphead__toggle {
    flex: none;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-xs);
    background: var(--surface);
    color: var(--text-soft);
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.grouphead__toggle:hover { background: var(--surface-2); color: var(--text); }

.grouphead__main { flex: 1 1 auto; min-width: 0; }

.grouphead__title {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.grouphead__name {
    font-size: 14px;
    font-weight: 650;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.grouphead__sub {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
    font-size: 11.5px;
    color: var(--text-faint);
    line-height: 1.4;
}

.grouphead__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
    flex: none;
}

/* ---------- 供应商胶囊 ---------- */
.chipgrid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    padding: 7px 13px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 12.5px;
    font-weight: 550;
    line-height: 1.2;
    cursor: pointer;
    transition: background .14s ease, border-color .14s ease;
}

.chip:hover { background: var(--surface); border-color: var(--border-strong); }

.chip.is-on {
    background: var(--surface);
    border-color: var(--border-strong);
}

.chip__dot {
    flex: none;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-faint);
}

.chip__dot.is-on { background: var(--celadon); }

.chip__name { min-width: 0; }

.chip__meta {
    flex: none;
    padding-left: 8px;
    border-left: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-faint);
}

/* ---------- 图表 ---------- */
.chart {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.chart svg { display: block; width: 100%; height: auto; }

.trend {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 140px;
    padding-top: 8px;
    min-width: 0;
}

.trend__col {
    flex: 1 1 0;
    min-width: 2px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    gap: 5px;
    height: 100%;
    position: relative;
}

.trend__bar {
    width: 100%;
    max-width: 42px;
    border-radius: 3px 3px 0 0;
    background: var(--primary);
    min-height: 2px;
    transition: opacity .12s ease;
}

.trend__bar:hover { opacity: .8; }

.trend__label {
    font-size: 10.5px;
    color: var(--text-faint);
    white-space: nowrap;
    overflow: hidden;
    max-width: 100%;
    text-overflow: ellipsis;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
}

.legend__item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--text-soft);
    min-width: 0;
}

.legend__swatch {
    width: 9px;
    height: 9px;
    border-radius: 2px;
    flex: none;
}

.legend__val {
    font-weight: 650;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

/* 折线 / 面积图 */
.linechart {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.linechart svg { display: block; width: 100%; height: auto; }

.linechart__grid { stroke: var(--border); stroke-width: 1; }

.linechart__axis {
    fill: var(--text-faint);
    font-size: 10.5px;
    font-family: var(--font);
}

.linechart__area { fill: var(--primary-soft); stroke: none; }

.linechart__line {
    fill: none;
    stroke: var(--primary);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.linechart__dot { fill: var(--surface); stroke: var(--primary); stroke-width: 1.6; }

/* 迷你走势线 */
.spark { display: block; overflow: visible; }

/* 环形图 */
.donut {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
    min-width: 0;
}

.donut__wrap { position: relative; flex: none; }

.donut__svg { display: block; }

.donut__track { fill: none; stroke: var(--clay-soft); }

.donut__seg { fill: none; }

.donut__center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
}

.donut__num {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.donut__cap { font-size: 11px; color: var(--text-faint); }

.donut .legend { flex: 1 1 180px; min-width: 0; flex-direction: column; gap: 8px; }

/* ---------- 进度条 ---------- */
.bar {
    height: 6px;
    border-radius: 999px;
    background: var(--clay-soft);
    overflow: hidden;
    min-width: 0;
}

.bar__fill {
    height: 100%;
    border-radius: 999px;
    background: var(--primary);
    transition: width .3s ease;
}

/* ---------- 提示条 ---------- */
.note {
    padding: 10px 12px;
    border-radius: var(--r-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--text-soft);
    word-break: break-word;
}

.note--info { background: var(--primary-soft); border-color: transparent; color: var(--primary-deep); }
.note--warn { background: var(--amber-soft); border-color: transparent; color: var(--amber); }
.note--danger { background: var(--rust-soft); border-color: transparent; color: var(--rust); }
.note--sm { padding: 8px 10px; font-size: 11.5px; line-height: 1.5; }

.codeblock {
    margin: 0;
    padding: 13px 14px;
    border-radius: var(--r-sm);
    background: #0f1420;
    color: #d7dce6;
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.65;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: pre;
    max-width: 100%;
}

/* ---------- 客户端接入 ---------- */
.pickbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.pickbar__url {
    font-size: 11.5px;
    color: var(--text-faint);
    min-width: 0;
}

.codebox {
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    overflow: hidden;
    max-width: 100%;
}

.codebox__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 7px 12px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-size: 11.5px;
}

.codebox__label { font-weight: 600; color: var(--text-soft); }
.codebox__meta { color: var(--text-faint); }
.codebox .codeblock { border-radius: 0; }

/* ---------- 定时任务状态条 ---------- */
.schedfoot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.schedfoot__info {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
}

.schedfoot__label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-faint);
}

.schedfoot__time {
    font-family: var(--mono);
    font-size: 12.5px;
    color: var(--text);
}

.schedfoot__time--none { color: var(--text-faint); }

.schedfoot__buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex: none;
}

.schedfoot__log {
    flex: 1 1 100%;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    min-width: 0;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--r-xs);
    background: var(--surface-2);
    font-size: 11.5px;
    color: var(--text-soft);
}

.schedfoot__log-text {
    flex: 1 1 auto;
    min-width: 0;
    line-height: 1.55;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.schedfoot__log-tag {
    flex: none;
    padding: 1px 6px;
    border-radius: var(--r-xs);
    background: var(--clay-soft);
    color: var(--text-soft);
    font-size: 10.5px;
    font-weight: 600;
}

[data-theme="dark"] .codeblock { background: #0b0e14; }

/* ---------- 弹窗 ---------- */
.modal-mask {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 18, 22, .5);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.modal {
    width: 100%;
    max-width: 520px;
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    min-width: 0;
}

.modal--wide { max-width: 680px; }

.modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 18px;
    border-bottom: 1px solid var(--border);
    flex: none;
}

.modal__title {
    font-size: 15px;
    font-weight: 650;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.modal__close {
    width: 32px;
    height: 32px;
    flex: none;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--text-faint);
    cursor: pointer;
}

.modal__close:hover { background: var(--surface-2); color: var(--text); }

.modal__body {
    padding: 18px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1 1 auto;
    min-width: 0;
}

.modal__foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 18px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    flex: none;
    flex-wrap: wrap;
}

.modal__foot .btn { flex: 0 0 auto; }

/* ---------- 吐司 ---------- */
.toasts {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(420px, calc(100vw - 32px));
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 11px 14px;
    border-radius: var(--r-md);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    font-size: 13px;
    pointer-events: auto;
    animation: toast-in .18s ease;
}

.toast__body { flex: 1 1 auto; min-width: 0; word-break: break-word; }
.toast__close { flex: none; border: 0; background: transparent; color: var(--text-faint); cursor: pointer; line-height: 1; }

.toast--success { border-left: 3px solid var(--celadon); }
.toast--success .toast__icon { color: var(--celadon); }
.toast--error { border-left: 3px solid var(--rust); }
.toast--error .toast__icon { color: var(--rust); }
.toast--warning { border-left: 3px solid var(--amber); }
.toast--warning .toast__icon { color: var(--amber); }
.toast--info { border-left: 3px solid var(--primary); }
.toast--info .toast__icon { color: var(--primary); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---------- 登录页 ---------- */
.login-wrap {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 18px;
    background: var(--bg);
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-sm);
    padding: 30px 26px;
}

.login-card__mark {
    width: 46px;
    height: 46px;
    border-radius: var(--r-md);
    background: var(--primary-soft);
    color: var(--primary);
    display: grid;
    place-items: center;
    margin-bottom: 16px;
}

.login-card__title {
    font-size: 19px;
    font-weight: 700;
    line-height: 1.25;
}

.login-card__desc {
    font-size: 13px;
    color: var(--text-faint);
    margin-top: 4px;
    margin-bottom: 22px;
}

/* ---------- 杂项 ---------- */
.kv {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    min-width: 0;
}

.kv:last-child { border-bottom: 0; }
.kv__k { color: var(--text-faint); flex: none; }
.kv__v { min-width: 0; text-align: right; word-break: break-all; }

.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
    padding: 14px;
}

.pager__info {
    font-size: 12.5px;
    color: var(--text-faint);
    width: 100%;
    text-align: center;
    margin-bottom: 4px;
}

/* ============================================================
   响应式 —— 移动端优先修正
   ============================================================ */

/* 平板 / 小桌面：侧栏收起为抽屉 */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform .22s ease;
        width: 250px;
        box-shadow: var(--shadow-lg);
    }

    .sidebar.is-open { transform: translateX(0); }

    .main { margin-left: 0; }

    .menu-toggle { display: grid; }

    .scrim.is-open { display: block; }

    .content { padding: 16px 14px 40px; }

    /* 表格改为横向滚动，不再压缩文字 */
    .table { min-width: 560px; }
}

@media (max-width: 640px) {
    :root { --header-h: 54px; }

    body { font-size: 13.5px; }

    .content { padding: 14px 12px 36px; }

    .topbar { padding: 0 12px; }
    .topbar__title { font-size: 14.5px; }
    .topbar__desc { font-size: 12px; }

    /* 顶栏：窄屏隐藏用户徽标，两个图标按钮成组靠右，避免拥挤 */
    .topbar__user { display: none; }
    .topbar__group { gap: 6px; }

    .grid { gap: 10px; }
    .grid--stats { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 8px; }
    .grid--2 { grid-template-columns: 1fr; }
    .grid--cards { grid-template-columns: 1fr; }

    .card__head { padding: 13px 13px; }
    .card__body { padding: 13px; }

    /* 关键修复：卡片头操作区在窄屏占满整行，按钮可换行且不被裁切 */
    .card__actions {
        width: 100%;
        justify-content: flex-start;
    }

    /* 页面头：窄屏收紧内边距，操作按钮占满整行、允许换行 */
    .page-head { padding: 12px 13px; }
    .page-head__actions { width: 100%; }

    .stat { padding: 11px 12px 11px 14px; }
    .stat__value { font-size: 19px; }

    .segbar { width: 100%; }
    .segbar__item {
        flex: 1 1 0;
        min-width: 0;
        padding: 7px 6px;
        font-size: 12px;
        text-align: center;
        white-space: normal;
        line-height: 1.3;
    }

    /* 弹窗改为底部抽屉，彻底避免横向溢出 */
    .modal-mask {
        align-items: flex-end;
        padding: 0;
    }

    .modal,
    .modal--wide {
        max-width: 100%;
        width: 100%;
        max-height: 92vh;
        max-height: 92dvh;
        border-radius: var(--r-lg) var(--r-lg) 0 0;
    }

    .modal__head { padding: 14px 15px; }
    .modal__body { padding: 15px; }
    .modal__foot { padding: 12px 15px calc(12px + env(safe-area-inset-bottom)); }
    .modal__foot .btn { flex: 1 1 auto; }

    /* 表单行：窄屏保持单行紧凑，放不下自动换行；避免纵向堆叠时 flex-basis 把输入框撑高 */
    .field__row { gap: 6px; }
    .field__row > .input,
    .field__row > .select,
    .field__row > .textarea { flex: 1 1 140px; }

    /* 模型/日志行：窄屏换行，操作区独占一行，杜绝横向溢出 */
    .modelrow { flex-wrap: wrap; }
    .modelrow__side {
        width: 100%;
        margin-left: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .modelrow__tags { justify-content: flex-start; }

    /* 操作按钮：四个等宽铺满一行，整齐不拥挤 */
    .modelrow__ops {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 6px;
    }

    .modelrow__ops .btn { width: 100%; }

    /* 分组头：窄屏操作按钮换行到独立一行 */
    .grouphead { flex-wrap: wrap; }
    .grouphead__actions {
        width: 100%;
        justify-content: flex-start;
    }

    .login-card { padding: 26px 20px; }
    .codeblock { font-size: 11.5px; }

    .toasts { top: 10px; width: calc(100vw - 20px); }
}

@media (max-width: 380px) {
    .grid--stats { grid-template-columns: 1fr 1fr; }
    .btn { padding: 8px 11px; font-size: 12.5px; }
    .page-head__actions .btn { flex: 1 1 auto; }
}

/* ---------- 数据大屏 ---------- */
/* 大屏表格里的「占比」条：表格单元格不能像卡片那样给最小宽度，否则窄屏会撑破布局。
   这里只保证一条可见的进度条底槽，宽度交给表格自动分配。 */
.table td .bar {
    min-width: 56px;
    max-width: 160px;
}

/* 大屏指标卡：数值更长（Token / 费用），字号略收，避免撑爆一行 */
.grid--stats .stat__value {
    font-variant-numeric: tabular-nums;
}

/* 大屏里带表头的卡片：表格贴卡片内边距边缘，避免右侧留白过多。
   用 .page-screen 限定作用域，避免影响其他页面已有的非 flush 卡片。 */
.page-screen .card .table__wrap {
    margin: 0 -14px;
}

.page-screen .card .table__wrap .table th:first-child,
.page-screen .card .table__wrap .table td:first-child {
    padding-left: 14px;
}

.page-screen .card .table__wrap .table th:last-child,
.page-screen .card .table__wrap .table td:last-child {
    padding-right: 14px;
}

/* 大屏的折线图容器：给一层内边距，折线不贴卡片边缘 */
.page-screen .card .linechart {
    padding: 4px 2px 0;
}

/* 触控设备：保证点击热区 */
@media (hover: none) {
    .btn { min-height: 38px; }
    .btn.btn--icon { min-height: 0; }
    .nav__item { min-height: 42px; }
}