:root {
    --primary: #0891b2;
    --primary-dark: #0e7490;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #06b6d4;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --font-size-base: 18px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f172a;
        --card: #1e293b;
        --text: #f1f5f9;
        --text-light: #94a3b8;
        --border: #334155;
    }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* 固定背景图片 - 使用本地图片（快速加载） */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg);
    background-image: url('assets/bg.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: -1;
}

/* iOS风格滚动条 */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.35);
}
::-webkit-scrollbar-thumb:active {
    background: rgba(0, 0, 0, 0.5);
}
::-webkit-scrollbar-corner {
    background: transparent;
}
/* 暗色模式下的滚动条 */
@media (prefers-color-scheme: dark) {
    ::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.2);
    }
    ::-webkit-scrollbar-thumb:hover {
        background: rgba(255, 255, 255, 0.35);
    }
    ::-webkit-scrollbar-thumb:active {
        background: rgba(255, 255, 255, 0.5);
    }
}
/* Firefox 滚动条 */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}
@media (prefers-color-scheme: dark) {
    * {
        scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
    }
}
html {
    font-size: var(--font-size-base);
}
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Ubuntu Mono', 'MiSans';
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
    font-size: 1rem;
    /* 字体渲染优化 */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-weight: 400;
}

/* 字体加载完成后应用 */
.fonts-loaded body {
    font-family: 'Ubuntu Mono', 'MiSans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* 确保所有元素继承字体 */
*, *::before, *::after {
    font-family: inherit;
}

/* 等宽字体用于代码/Token显示 */
code, pre, .mono, .token-display {
    font-family: 'Ubuntu Mono', 'Consolas', 'Monaco', monospace !important;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0.5rem;
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* 登录表单 */
.login-form {
    margin: auto;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-radius: 1rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    max-width: 400px;
    width: 100%;
    padding: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.5);
}
@media (prefers-color-scheme: dark) {
    .login-form {
        background: rgba(30, 41, 59, 0.65);
        border: 1px solid rgba(255, 255, 255, 0.2);
    }
}
.login-form h2 { 
    text-align: center; 
    margin-bottom: 1.5rem; 
    background: linear-gradient(135deg, var(--primary), var(--primary-dark)); 
    -webkit-background-clip: text; 
    -webkit-text-fill-color: transparent; 
    background-clip: text; 
    font-size: 1.5rem; 
    font-weight: 700; 
}

.form-group { margin-bottom: 1rem; }
label { 
    display: block; 
    margin-bottom: 0.5rem; 
    font-weight: 600; 
    color: var(--text); 
    font-size: 0.875rem; 
}
input, select, textarea {
    width: 100%;
    min-height: 40px;
    padding: 0.5rem 0.75rem 0.5rem 0.5rem !important; 
    border: 1.5px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    background: var(--card);
    color: var(--text);
    transition: all 0.2s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(8,145,178,0.1);
}
input::placeholder, textarea::placeholder { color: var(--text-light); opacity: 0.6; }

button {
    width: 100%;
    min-height: 44px;
    padding: 0.75rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(8,145,178,0.2);
}
button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(8,145,178,0.3); }
button:active:not(:disabled) { transform: translateY(0); }
button:disabled { opacity: 0.7; cursor: not-allowed; }
button.loading::after { 
    content: ''; 
    position: absolute; 
    width: 14px; 
    height: 14px; 
    margin-left: 8px; 
    border: 2px solid rgba(255,255,255,0.3); 
    border-top-color: white; 
    border-radius: 50%; 
    animation: spin 0.6s linear infinite; 
}

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

/* 主内容区 */
.main-content {
    margin: 0;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-radius: 1rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 1400px;
    height: calc(100vh - 1rem); /* Fallback */
    /* height: calc(100dvh - 1rem); */
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255, 255, 255, 0.5);
    overflow: hidden;
}
@media (prefers-color-scheme: dark) {
    .main-content {
        background: rgba(30, 41, 59, 0.65);
        border: 1px solid rgba(255, 255, 255, 0.2);
    }
}

.header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 0.75rem 1rem; 
    border-bottom: 1.5px solid var(--border); 
    flex-shrink: 0; 
}
.header-right { 
    display: flex; 
    align-items: center; 
    gap: 0.75rem; 
}
.server-info {
    font-size: 0.75rem;
    color: var(--text-light);
    background: var(--bg);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
}
.header button { 
    width: auto; 
    padding: 0.5rem 1rem; 
    font-size: 0.8rem; 
    min-height: 36px; 
}

.tabs { display: flex; gap: 0.25rem; }
.tab { 
    background: transparent; 
    color: var(--text-light); 
    border: none; 
    padding: 0.5rem 1rem; 
    border-radius: 0.375rem; 
    cursor: pointer; 
    font-weight: 600; 
    font-size: 0.875rem; 
    transition: all 0.2s; 
    min-height: 36px; 
    box-shadow: none; 
}
.tab:hover { background: var(--bg); color: var(--text); }
.tab.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 2px 6px rgba(8,145,178,0.25);
}

.content {
    padding: 1rem;
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#tokensPage {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

#settingsPage {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
}

/* 顶部栏 - 统计+操作 */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.6);
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    margin-bottom: 1rem;
    border: 1.5px solid var(--border);
    flex-shrink: 0;
}
@media (prefers-color-scheme: dark) {
    .top-bar {
        background: rgba(30, 41, 59, 0.6);
    }
}
.stats-inline { 
    display: flex; 
    gap: 1.5rem; 
}
.stat-item {
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
}
.stat-num {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}
.stat-item.success .stat-num { color: var(--success); }
.stat-item.danger .stat-num { color: var(--danger); }
.stat-text {
    font-size: 0.85rem;
    color: var(--text-light);
    line-height: 1;
}
.action-btns { 
    display: flex; 
    gap: 0.5rem; 
}

/* 按钮样式 */
.btn { 
    padding: 0.5rem 0.875rem; 
    border: none; 
    border-radius: 0.375rem; 
    cursor: pointer; 
    font-size: 0.8rem; 
    font-weight: 600; 
    transition: all 0.2s; 
    white-space: nowrap; 
    text-align: center; 
    display: inline-flex; 
    align-items: center; 
    justify-content: center; 
    gap: 0.25rem; 
    min-height: 36px; 
    box-shadow: none; 
}
.btn:hover { transform: translateY(-1px); }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.75rem; min-height: 32px; }
.btn-xs { padding: 0.25rem 0.5rem; font-size: 0.7rem; min-height: 28px; min-width: 28px; }
.btn-danger { background: var(--danger); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-secondary { background: #6b7280; color: white; }
.btn-info { background: var(--info); color: white; }

/* Token网格 */
.token-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.75rem;
    align-items: start;
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px 1rem 4px;
    overflow-x: auto;
    min-height: 0;
}
.token-card {
    background: rgba(255, 255, 255, 0.6);
    border: 1.5px solid var(--border);
    border-radius: 0.75rem;
    padding: 0.875rem;
    transition: all 0.2s;
    position: relative;
}
@media (prefers-color-scheme: dark) {
    .token-card {
        background: rgba(30, 41, 59, 0.6);
    }
}
.token-card:hover {
    border-color: var(--primary);
    box-shadow: 0 6px 16px rgba(0,0,0,0.12);
    background: rgba(255, 255, 255, 0.85);
    transform: scale(1.02);
    z-index: 1;
    position: relative;
}
@media (prefers-color-scheme: dark) {
    .token-card:hover {
        background: rgba(30, 41, 59, 0.85);
    }
}
.token-card.disabled { opacity: 0.6; }
.token-card.expired { border-color: var(--danger); }

.token-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 0.5rem; 
}
.token-id {
    font-size: 0.7rem;
    color: var(--text-light);
}

.token-info { 
    display: flex; 
    flex-direction: column; 
    gap: 0.375rem; 
    margin-bottom: 0.75rem; 
}
.info-row { 
    display: flex; 
    align-items: center; 
    gap: 0.375rem; 
    font-size: 0.8rem; 
}
.info-label { 
    flex-shrink: 0; 
    width: 20px; 
    text-align: center; 
}
.info-value {
    color: var(--text);
    font-size: 0.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.info-row.expired-text .info-value { color: var(--danger); }
.info-row.editable {
    cursor: pointer;
    padding: 0.25rem;
    margin: -0.25rem;
    border-radius: 0.25rem;
    transition: background 0.2s;
}
.info-row.editable:hover {
    background: rgba(8,145,178,0.08);
}
.info-edit-icon {
    font-size: 0.6rem;
    opacity: 0;
    transition: opacity 0.2s;
    margin-left: auto;
    flex-shrink: 0;
}
.info-row.editable:hover .info-edit-icon {
    opacity: 0.5;
}

/* Token完整显示样式 */
.token-display {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-family: 'Ubuntu Mono', 'MiSans', 'Consolas', monospace;
    font-size: 0.75rem;
    line-height: 1.4;
    word-break: break-all;
    color: var(--text-light);
    max-height: 80px;
    overflow-y: auto;
    user-select: all;
    cursor: text;
}
.inline-edit-input {
    flex: 1;
    min-height: 24px;
    padding: 0.125rem 0.375rem;
    font-size: 0.75rem;
    border: 1px solid var(--primary);
    border-radius: 0.25rem;
    background: var(--card);
}
.inline-edit-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(8,145,178,0.2);
}

/* Token卡片头部 */
.token-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.btn-icon {
    width: 24px;
    height: 24px;
    min-height: 24px;
    min-width: 24px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: none;
}
.btn-icon:hover {
    background: var(--primary);
    border-color: var(--primary);
    transform: none;
}

.token-actions { 
    display: flex; 
    gap: 0.375rem; 
    justify-content: flex-end; 
}

.status { 
    padding: 0.25rem 0.5rem; 
    border-radius: 9999px; 
    font-size: 0.7rem; 
    font-weight: 600; 
    display: inline-flex; 
    align-items: center; 
}
.status.enabled { background: rgba(16,185,129,0.15); color: var(--success); }
.status.disabled { background: rgba(239,68,68,0.15); color: var(--danger); }

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-light);
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}
.empty-state-icon { font-size: 3rem; margin-bottom: 0.75rem; opacity: 0.5; }
.empty-state-text { font-size: 1rem; font-weight: 500; margin-bottom: 0.375rem; }
.empty-state-hint { font-size: 0.8rem; }

/* 设置页面 */
.config-form { max-width: 100%; }
.config-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); 
    gap: 1rem; 
    margin-bottom: 1rem; 
    align-items: stretch;
}
.config-section {
    background: rgba(255, 255, 255, 0.6);
    padding: 1rem;
    border-radius: 0.75rem;
    border: 1.5px solid var(--border);
}
@media (prefers-color-scheme: dark) {
    .config-section {
        background: rgba(30, 41, 59, 0.6);
    }
}
.config-section h4 { 
    margin-bottom: 0.75rem; 
    color: var(--primary); 
    font-size: 0.95rem; 
    font-weight: 600; 
}
.form-row-inline { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 0.5rem; 
    margin-bottom: 0.5rem; 
}
.form-group.compact { margin-bottom: 0.5rem; }
.form-group.compact label { 
    font-size: 0.75rem; 
    margin-bottom: 0.25rem; 
    color: var(--text-light); 
}
.form-group.compact input,
.form-group.compact select {
    min-height: 36px;
    padding: 0.375rem 0.5rem;
    font-size: 0.8rem;
}
.form-group.compact textarea {
    min-height: 60px;
    max-height: 300px;
    padding: 0.375rem 0.5rem;
    font-size: 0.8rem;
    resize: vertical;
    height: auto;
    /* 自适应内容高度 - 纯CSS方案，零JS资源消耗 */
    field-sizing: content;
}
.form-group.highlight {
    background: rgba(8,145,178,0.08);
    padding: 0.5rem;
    border-radius: 0.5rem;
    margin-top: 0.5rem;
}
.form-group.highlight label { 
    color: var(--primary); 
    font-weight: 600; 
}
.config-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-start;
}
.config-actions .btn { width: auto; }

/* 字体大小控制 */
.font-size-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.font-size-control input[type="range"] {
    flex: 1;
    min-height: auto;
    height: 6px;
    padding: 0;
    cursor: pointer;
}
.font-size-control input[type="number"] {
    width: 60px;
    text-align: center;
    flex-shrink: 0;
}

/* 轮询策略状态显示 */
.rotation-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(8,145,178,0.08);
    border-radius: 0.5rem;
    margin-top: 0.5rem;
    font-size: 0.75rem;
}
.rotation-label {
    color: var(--text-light);
    font-weight: 500;
}
#currentRotationInfo {
    color: var(--primary);
    font-weight: 600;
}

/* Toast通知 */
.toast { 
    position: fixed; 
    top: 16px; 
    right: 16px; 
    background: var(--card); 
    border-radius: 0.75rem; 
    padding: 0.75rem 1rem; 
    box-shadow: 0 8px 24px rgba(0,0,0,0.15); 
    z-index: 9999; 
    display: flex; 
    align-items: center; 
    gap: 0.75rem; 
    min-width: 240px; 
    max-width: 360px; 
    animation: slideIn 0.3s ease; 
    border-left: 3px solid var(--primary); 
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast.info { border-left-color: var(--info); }
.toast-icon { font-size: 1.25rem; flex-shrink: 0; }
.toast-content { flex: 1; }
.toast-title { font-weight: 600; font-size: 0.875rem; color: var(--text); }
.toast-message { font-size: 0.8rem; color: var(--text-light); }

@keyframes slideIn { from { transform: translateX(400px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(400px); opacity: 0; } }

/* Modal弹窗 */
.modal { 
    position: fixed; 
    inset: 0; 
    background: rgba(0,0,0,0.5); 
    z-index: 9998; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    padding: 1rem; 
    animation: fadeIn 0.2s; 
}
.modal-content {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-radius: 1rem;
    padding: 1.25rem;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 16px 48px rgba(0,0,0,0.2);
    animation: scaleIn 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: var(--text);
}
@media (prefers-color-scheme: dark) {
    .modal-content {
        background: rgba(30, 41, 59, 0.8);
        border: 1px solid rgba(255, 255, 255, 0.15);
    }
}
.modal-content.modal-lg { max-width: 700px; }
.modal-content.modal-xl {
    max-width: 900px;
    display: flex;
    flex-direction: column;
    max-height: 80vh;
    overflow: hidden;
}
.modal-content.modal-xl .quota-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}
.modal-content.modal-xl .modal-actions {
    flex-shrink: 0;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    margin-top: 0.5rem;
    background: transparent;
}
.modal-title { font-size: 1rem; font-weight: 700; margin-bottom: 0.75rem; color: var(--text); }
.modal-message { color: var(--text-light); margin-bottom: 1rem; line-height: 1.5; font-size: 0.85rem; }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; }
.modal-actions button { flex: none; width: auto; }

.form-modal .modal-content { max-width: 480px; }
.form-modal input { margin-bottom: 0.75rem; }
.form-modal .form-row { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1rem; }
.form-modal .oauth-steps {
    background: rgba(59,130,246,0.1);
    padding: 0.875rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    border: 1.5px solid var(--info);
    color: var(--text);
}
.form-modal .oauth-steps p { margin-bottom: 0.5rem; font-size: 0.8rem; color: var(--text); }
.form-modal .oauth-steps p:last-child { margin-bottom: 0; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Loading遮罩 */
.loading-overlay { 
    position: fixed; 
    inset: 0; 
    background: rgba(0,0,0,0.6); 
    z-index: 9999; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    flex-direction: column; 
    gap: 1rem; 
}
.spinner { 
    width: 40px; 
    height: 40px; 
    border: 3px solid rgba(255,255,255,0.2); 
    border-top-color: white; 
    border-radius: 50%; 
    animation: spin 0.7s linear infinite; 
}
.loading-text { color: white; font-size: 0.875rem; font-weight: 500; }

/* 帮助提示 */
.help-tip { 
    display: inline-flex; 
    align-items: center; 
    justify-content: center; 
    width: 16px; 
    height: 16px; 
    border-radius: 50%; 
    background: var(--info); 
    color: white; 
    font-size: 0.65rem; 
    font-weight: 600; 
    cursor: help; 
    margin-left: 4px; 
    position: relative;
}
.help-tip::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 400;
    white-space: pre-line;
    min-width: 200px;
    max-width: 300px;
    text-align: left;
    line-height: 1.4;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.help-tip::after {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 1000;
}
.help-tip:hover::before,
.help-tip:hover::after {
    opacity: 1;
}
@media (prefers-color-scheme: dark) {
    .help-tip::before {
        background: rgba(30, 41, 59, 0.95);
        color: #f1f5f9;
        border: 1px solid rgba(255, 255, 255, 0.2);
    }
    .help-tip::after {
        border-top-color: rgba(30, 41, 59, 0.95);
    }
}

/* 开关样式 */
.switch-row {
    display: flex !important;
    flex-wrap: wrap;
    gap: 0.5rem;
    background: rgba(8,145,178,0.08);
    padding: 0.5rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(8,145,178,0.15);
    align-items: center;
}
.switch-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    background: var(--card);
    padding: 0.375rem 0.625rem;
    border-radius: 0.375rem;
    flex: 1 1 auto;
    min-width: 140px;
    border: 1px solid var(--border);
    transition: all 0.2s;
    min-height: 36px;
}
.switch-group:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(8,145,178,0.1);
}
.switch-group label:first-child {
    flex: 1;
    margin-bottom: 0;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
}
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
    padding: 0;
    min-height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 24px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}
input:checked + .slider {
    background-color: var(--primary);
}
input:checked + .slider:before {
    transform: translateX(20px);
}
.slider:hover {
    box-shadow: 0 0 0 3px rgba(8,145,178,0.1);
}

/* 额度弹窗头部 */
.quota-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.quota-update-time {
    font-size: 0.75rem;
    color: var(--text-light);
}

/* 额度弹窗 - 标签页样式 */
.quota-tabs {
    display: flex;
    gap: 0.625rem;
    margin-bottom: 1rem;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,0.2) transparent;
    padding: 0.375rem;
    margin: -0.375rem;
    margin-bottom: 0.625rem;
}
.quota-tabs::-webkit-scrollbar {
    height: 4px;
}
.quota-tabs::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.2);
    border-radius: 2px;
}
.quota-tab {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-light) !important;
    padding: 0.5rem 1rem;
    background: var(--bg) !important;
    border: 2px solid var(--border) !important;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    min-height: auto;
    box-shadow: none !important;
    width: auto;
    line-height: 1.2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.quota-tab:hover {
    color: var(--primary) !important;
    border-color: var(--primary) !important;
    background: rgba(8,145,178,0.05) !important;
    transform: none;
}
.quota-tab.active {
    color: white !important;
    background: var(--primary) !important;
    border-color: var(--primary) !important;
}
.quota-container {
    max-height: 55vh;
    overflow: auto;
    position: relative;
    padding: 0.25rem;
}
.quota-loading, .quota-error, .quota-empty {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-light);
    font-size: 0.875rem;
}
.quota-error { color: var(--danger); }
.quota-group-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    margin: 1rem 0 0.5rem 0;
    padding-bottom: 0.375rem;
    border-bottom: 1.5px solid var(--border);
}
.quota-group-title:first-child { margin-top: 0; }
.quota-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
    padding: 0.5rem;
}
.quota-item {
    background: rgba(255,255,255,0.6);
    padding: 0.625rem;
    border-radius: 0.5rem;
    border: 1.5px solid var(--border);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, background 0.15s ease;
    cursor: default;
    color: var(--text);
}
.quota-item:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 16px rgba(0,0,0,0.12);
    border-color: var(--primary);
    background: rgba(255,255,255,0.95);
    z-index: 1;
    position: relative;
}
@media (prefers-color-scheme: dark) {
    .quota-item {
        background: rgba(30, 41, 59, 0.6);
    }
    .quota-item:hover {
        background: rgba(30, 41, 59, 0.9);
    }
}
.quota-model-name {
    font-size: 0.75rem;
    color: var(--text);
    margin-bottom: 0.375rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.quota-bar-container {
    position: relative;
    height: 0.5rem;
    background: var(--border);
    border-radius: 0.25rem;
    overflow: hidden;
    margin-bottom: 0.375rem;
}
.quota-bar {
    height: 100%;
    border-radius: 0.25rem;
    transition: width 0.3s ease;
}
.quota-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.7rem;
}
.quota-percentage {
    font-weight: 600;
    color: var(--text);
}
.quota-reset {
    color: var(--text-light);
}

/* Token卡片内嵌额度 */
.token-quota-inline {
    background: rgba(8,145,178,0.05);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    margin-bottom: 0.75rem;
    overflow: hidden;
}
.quota-inline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.375rem 0.5rem;
    cursor: pointer;
    transition: background 0.2s;
}
.quota-inline-header:hover {
    background: rgba(8,145,178,0.1);
}
.quota-inline-summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
    font-size: 0.75rem;
}
.quota-summary-icon {
    flex-shrink: 0;
}
.quota-summary-model {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
    font-weight: 500;
}
.quota-summary-bar {
    flex: 0 0 60px;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}
.quota-summary-bar span {
    display: block;
    height: 100%;
    border-radius: 4px;
}
.quota-summary-pct {
    flex-shrink: 0;
    font-weight: 600;
    font-size: 0.7rem;
    color: var(--primary);
    min-width: 32px;
    text-align: right;
}
.quota-inline-toggle {
    font-size: 0.65rem;
    color: var(--text-light);
    flex-shrink: 0;
    margin-left: 0.5rem;
}
.quota-inline-detail {
    border-top: 1px solid var(--border);
    padding: 0.5rem;
    background: var(--bg);
}
.quota-detail-grid {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
}
.quota-detail-row {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0;
    font-size: 0.7rem;
    border-bottom: 1px solid var(--border);
}
.quota-detail-row:last-child {
    border-bottom: none;
}
.quota-detail-icon {
    flex-shrink: 0;
    font-size: 0.65rem;
}
.quota-detail-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
}
.quota-detail-bar {
    flex: 0 0 50px;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}
.quota-detail-bar span {
    display: block;
    height: 100%;
    border-radius: 3px;
}
.quota-detail-pct {
    flex-shrink: 0;
    font-weight: 600;
    font-size: 0.65rem;
    color: var(--primary);
    min-width: 28px;
    text-align: right;
}
.quota-refresh-btn {
    width: 100%;
    margin-top: 0.5rem;
}
.quota-loading-small {
    font-size: 0.7rem;
    color: var(--text-light);
    text-align: center;
    padding: 0.5rem;
}
.quota-empty-small, .quota-error-small {
    font-size: 0.7rem;
    color: var(--text-light);
    text-align: center;
    padding: 0.5rem;
}
.quota-error-small { color: var(--danger); }
.quota-summary-error {
    color: var(--danger);
    font-size: 0.7rem;
}

.hidden { display: none !important; }

/* 敏感信息模糊 */
.sensitive-info.blurred {
    filter: blur(4px);
    user-select: none;
    cursor: default;
}

/* 响应式 */
@media (max-width: 768px) {
    .container { padding: 0; height: 100vh; height: 100dvh; align-items: stretch; }
    .login-form { margin: auto 0.5rem; padding: 1.5rem; }
    .login-form h2 { font-size: 1.25rem; }
    .main-content { height: 100vh; height: 100dvh; border-radius: 0; margin: 0; }
    .header {
        padding: 0.5rem 0.75rem;
        flex-wrap: nowrap;
        gap: 0.5rem;
    }
    .header-right {
        flex-shrink: 0;
    }
    .header-right .server-info {
        display: none;
    }
    .header-right button {
        padding: 0.375rem 0.5rem;
        font-size: 0.7rem;
        min-height: 32px;
    }
    .tabs {
        flex: 1;
        min-width: 0;
    }
    .tab { flex: 1; font-size: 0.7rem; padding: 0.375rem 0.5rem; min-height: 32px; }
    .content { padding: 0.75rem; }
    
    .top-bar { flex-direction: column; gap: 0.5rem; align-items: stretch; padding: 0.5rem 0.75rem; }
    .stats-inline { justify-content: space-around; }
    .action-btns {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 0.375rem;
    }
    .action-btns .btn-sm {
        padding: 0.375rem 0.25rem;
        font-size: 0.7rem;
        min-height: 32px;
    }
    
    .token-grid { grid-template-columns: 1fr; }
    .config-grid { grid-template-columns: 1fr; }
    .form-row-inline { grid-template-columns: 1fr; }
    .switch-row { flex-direction: column !important; gap: 0.375rem; padding: 0.375rem; }
    .switch-group { width: 100%; min-height: 32px; padding: 0.3rem 0.5rem; }
    .toast { right: 8px; left: 8px; min-width: auto; max-width: none; }
    .modal { padding: 0.25rem; }
    .modal-content { padding: 0.75rem; }
    .modal-content.modal-xl {
        max-width: 100%;
        max-height: 90vh;
        margin: 0.25rem;
    }
    .quota-modal-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
    .quota-tabs {
        flex-wrap: nowrap;
        gap: 0.375rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.25rem;
    }
    .quota-tab {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
    }
    .quota-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        padding: 0.25rem;
    }
    .quota-item {
        padding: 0.5rem;
    }
    .quota-item:hover {
        transform: none;
    }
    .quota-group-title {
        font-size: 0.85rem;
        margin: 0.75rem 0 0.375rem 0;
    }
    
    /* 移动端内嵌额度优化 */
    .quota-summary-model {
        font-size: 0.7rem;
    }
    
    /* 移动端Token卡片操作按钮 */
    .token-actions {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 0.25rem;
    }
    .token-actions .btn-xs {
        padding: 0.375rem 0.25rem;
        font-size: 0.65rem;
        min-height: 28px;
    }
}

@media (max-width: 480px) {
    .stat-num { font-size: 1rem; }
    .stat-text { font-size: 0.75rem; }
    .btn-sm { padding: 0.25rem 0.375rem; font-size: 0.65rem; min-height: 30px; }
    .token-card { padding: 0.625rem; }
    .info-row { font-size: 0.7rem; }
    .info-label { width: 18px; }
    .info-value { font-size: 0.7rem; }
    
    /* 超小屏幕按钮2x2布局 */
    .action-btns {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .quota-summary-model {
        font-size: 0.65rem;
    }
    .quota-summary-pct {
        font-size: 0.65rem;
    }
    .quota-summary-bar {
        flex: 0 0 40px;
    }
    .quota-detail-name {
        font-size: 0.6rem;
    }
    .quota-detail-pct {
        font-size: 0.6rem;
    }
    
    /* Token卡片头部优化 */
    .token-header {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    .status {
        font-size: 0.65rem;
        padding: 0.2rem 0.4rem;
    }
    .token-id {
        font-size: 0.6rem;
    }
}
