/* ============================================================
   方案二：白净极简商务风 (Linear / Stripe Dashboard Style)
   - 纯白背景 + 极细边框
   - 深色文字 + 单品牌色
   - 药丸形按钮 + 内敛动效
   ============================================================ */

/* Google Fonts 已移除（国内无法访问），使用系统字体 */

/* ========== CSS 变量 ========== */
:root {
    --bg: #ffffff;
    --bg-secondary: #fafafa;
    --bg-tertiary: #f5f5f5;
    --border: #eaeaea;
    --border-hover: #ccc;

    --text-primary: #000;
    --text-secondary: #666;
    --text-tertiary: #999;

    --accent: #000;
    --accent-hover: #333;
    --brand: #6366f1;
    --brand-light: #eef2ff;

    --success: #10b981;
    --success-bg: #ecfdf5;
    --error: #ef4444;
    --error-bg: #fef2f2;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;

    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-pill: 999px;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.06);

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
             "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

/* ========== 全局样式 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    letter-spacing: -0.011em;
}

::selection {
    background: var(--brand-light);
    color: var(--brand);
}

/* ========== 导航栏 ========== */
.navbar {
    background: var(--bg);
    color: var(--text-primary);
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border);
}

.nav-row-top {
    /* Keep the shared navigation row as a real flex item.  Some browsers
       calculate sticky flex children inconsistently when this is contents. */
    display: flex;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0;
}

.nav-brand {
    font-size: 16px;
    font-weight: 700;
    white-space: nowrap;
    min-width: 160px;
    color: var(--text-primary);
    letter-spacing: -0.03em;
}

.nav-tabs {
    display: flex;
    gap: 2px;
}

.nav-tab {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 8px 14px;
    border-radius: var(--radius-pill);
    font-size: 14px;
    font-weight: 500;
    transition: color 0.2s, background 0.2s;
}

.nav-tab:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.nav-tab.active {
    color: var(--text-primary);
    background: var(--bg-tertiary);
    font-weight: 600;
}

.nav-date,
.nav-right {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    min-width: 180px;
    justify-content: flex-end;
}

.nav-date label {
    color: var(--text-tertiary);
    font-size: 13px;
}

.nav-date input[type="date"],
.nav-date select {
    padding: 6px 10px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text-primary);
    font-size: 13px;
    font-family: var(--font);
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
}

.nav-date input[type="date"]:focus,
.nav-date select:focus {
    border-color: var(--text-primary);
}

.nav-date select option {
    background: var(--bg);
    color: var(--text-primary);
}

/* 用户信息 & 退出 */
.nav-user-info {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-left: 12px;
    white-space: nowrap;
}

.nav-logout {
    color: var(--text-tertiary);
    text-decoration: none;
    margin-left: 8px;
    font-size: 12px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    transition: all 0.2s;
}

.nav-logout:hover {
    color: var(--text-primary);
    border-color: var(--text-primary);
}

/* 红点 */
.nav-badge {
    width: 8px;
    height: 8px;
    background: var(--error);
    border-radius: 50%;
    position: absolute;
}

/* ========== 容器 ========== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
}

/* ========== 汇总卡片 ========== */
.card-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

.summary-card {
    background: var(--bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--border);
    transition: border-color 0.2s;
}

.summary-card:hover {
    border-color: var(--border-hover);
}

.card-label {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-bottom: 8px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.card-value {
    font-size: 36px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
    letter-spacing: -0.04em;
    line-height: 1.1;
}

.card-value.up {
    color: var(--success);
}

.card-value.down {
    color: var(--error);
}

.card-trend {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

.card-sub {
    font-size: 12px;
    color: var(--text-tertiary);
}

/* ========== 图表区域 ========== */
.chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 32px;
}

.chart-box {
    background: var(--bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--border);
}

.chart-box.full-width {
    margin-bottom: 32px;
}

.chart-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.chart-toolbar {
    margin-bottom: 12px;
}

.btn-sm {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--bg);
    cursor: pointer;
    font-size: 13px;
    font-family: var(--font);
    color: var(--text-secondary);
    transition: all 0.2s;
    font-weight: 500;
}

.btn-sm:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
}

.btn-sm.active {
    background: var(--text-primary);
    border-color: var(--text-primary);
    color: var(--bg);
}

.chart {
    width: 100%;
    height: 350px;
}

/* ========== 表格 ========== */
.table-box {
    background: var(--bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--border);
    margin-bottom: 24px;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}

.search-input {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    font-size: 14px;
    font-family: var(--font);
    outline: none;
    width: 240px;
    transition: border-color 0.2s;
    background: var(--bg);
}

.search-input:focus {
    border-color: var(--text-primary);
}

.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

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

th {
    background: transparent;
    padding: 10px 16px;
    text-align: left;
    font-weight: 500;
    color: var(--text-tertiary);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

th:hover {
    color: var(--text-primary);
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--bg-tertiary);
    white-space: nowrap;
    color: var(--text-primary);
}

tr:hover td {
    background: var(--bg-secondary);
}

tr:last-child td {
    border-bottom: none;
}

.num-col {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.author-name {
    font-weight: 500;
    color: var(--text-primary);
}

/* ========== 聊天页面 ========== */
.chat-page {
    --chat-nav-height: 56px;
    display: flow-root;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    background: #ffffff;
}

.chat-page .navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.chat-container {
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    height: calc(100vh - var(--chat-nav-height));
    height: calc(100dvh - var(--chat-nav-height));
    margin-top: var(--chat-nav-height);
    overflow: hidden;
}

/* 快捷问题 */
.quick-questions {
    flex-shrink: 0;
    max-height: 40%;
    overflow-y: auto;
    padding: 20px 40px;
    background: white;
    border-bottom: none;
}

.quick-title {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-bottom: 12px;
    font-weight: 500;
}

.quick-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.quick-btn {
    padding: 8px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: white;
    cursor: pointer;
    font-size: 13px;
    font-family: var(--font);
    color: var(--text-secondary);
    transition: all 0.2s;
    white-space: nowrap;
    font-weight: 500;
}

.quick-btn:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
    background: var(--bg-secondary);
}

/* 聊天消息区 */
.chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 24px 40px;
    display: flex;
    flex-direction: column;
    gap: 28px;
    background: #ffffff;
}

.message {
    display: flex;
    gap: 16px;
    max-width: 100%;
    animation: fadeIn 0.3s ease;
}

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

/* 用户消息 */
.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
    max-width: 75%;
}

.user-message .message-content {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-radius: 20px 20px 4px 20px;
    padding: 12px 20px;
    box-shadow: none;
}

/* 头像 */
.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    margin-top: 2px;
}

.user-message .message-avatar {
    background: var(--brand);
}

/* AI 回复 */
.bot-message {
    max-width: 100%;
}

.bot-message .message-content {
    background: transparent;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    max-width: 100%;
    overflow: visible;
}

.message-content {
    background: white;
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    max-width: 100%;
    overflow: hidden;
}

/* AI 回复文字排版 */
.message-text {
    font-size: 15px;
    line-height: 1.8;
    color: var(--text-primary);
    word-wrap: break-word;
}

.message-text p {
    margin-bottom: 12px;
}

.message-text p:last-child {
    margin-bottom: 0;
}

.message-text h1,
.message-text h2,
.message-text h3 {
    color: var(--text-primary);
    margin-top: 20px;
    margin-bottom: 10px;
    line-height: 1.4;
    letter-spacing: -0.02em;
}

.message-text h1 { font-size: 22px; font-weight: 700; }
.message-text h2 { font-size: 18px; font-weight: 700; }
.message-text h3 { font-size: 16px; font-weight: 600; }

.message-text strong {
    font-weight: 600;
    color: var(--text-primary);
}

.message-text em {
    font-style: italic;
    color: var(--text-secondary);
}

.message-text ul,
.message-text ol {
    padding-left: 24px;
    margin: 10px 0;
}

.message-text li {
    margin-bottom: 6px;
    line-height: 1.7;
    padding-left: 4px;
}

.message-text li::marker {
    color: var(--text-tertiary);
}

.message-text code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--error);
}

.message-text pre {
    background: #1e1e1e;
    color: #d4d4d4;
    border-radius: var(--radius);
    padding: 16px 20px;
    overflow-x: auto;
    margin: 12px 0;
    font-size: 13px;
    line-height: 1.6;
}

.message-text pre code {
    background: none;
    color: inherit;
    padding: 0;
    font-size: inherit;
}

.message-text hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 16px 0;
}

/* 聊天中的表格 */
.data-table-wrapper {
    overflow-x: auto;
    margin: 12px 0;
    -webkit-overflow-scrolling: touch;
}

.chat-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    margin: 12px 0;
}

.chat-table th {
    background: var(--bg-secondary);
    padding: 10px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
    border-bottom: 1px solid var(--border);
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.chat-table td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--bg-tertiary);
    font-size: 14px;
    color: var(--text-primary);
}

.chat-table tr:hover td {
    background: var(--bg-secondary);
}

/* SQL 详情折叠 */
.sql-details {
    margin-top: 16px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--text-tertiary);
}

.sql-details summary {
    cursor: pointer;
    color: var(--text-tertiary);
    font-weight: 500;
}

.sql-details code {
    display: block;
    margin-top: 8px;
    padding: 12px;
    background: #1e1e1e;
    color: #d4d4d4;
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 12px;
    word-break: break-all;
    white-space: pre-wrap;
}

/* 加载动画 */
.loading-dots {
    display: flex;
    gap: 6px;
    padding: 8px 0;
}

.loading-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-tertiary);
    animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* 输入区域 */
.chat-input-area {
    flex-shrink: 0;
    padding: 16px 40px 24px;
    background: #ffffff;
    border-top: none;
}

.chat-input-box {
    display: flex;
    align-items: flex-end;
    gap: 0;
    max-width: 100%;
    background: var(--bg-secondary);
    border-radius: var(--radius-pill);
    padding: 6px 6px 6px 20px;
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.chat-input-box:focus-within {
    background: #ffffff;
    border-color: var(--text-primary);
}

.chat-input-box textarea {
    flex: 1;
    padding: 10px 0;
    border: none;
    border-radius: 0;
    font-size: 15px;
    font-family: var(--font);
    outline: none;
    resize: none;
    max-height: 120px;
    line-height: 1.5;
    background: transparent;
    color: var(--text-primary);
}

.chat-input-box textarea::placeholder {
    color: var(--text-tertiary);
}

.send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--text-primary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.2s;
}

.send-btn:hover {
    opacity: 0.8;
}

.send-btn:disabled {
    background: var(--border);
    cursor: not-allowed;
}

/* ========== 上传页面 ========== */
.upload-section {
    background: var(--bg);
    border-radius: var(--radius-lg);
    padding: 32px;
    border: 1px solid var(--border);
    margin-bottom: 24px;
}

.upload-desc {
    font-size: 14px;
    color: var(--text-tertiary);
    margin-bottom: 24px;
    line-height: 1.6;
}

.upload-form {
    max-width: 600px;
}

.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.form-group {
    flex: 1;
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.required {
    color: var(--error);
}

.form-group input[type="date"],
.form-group input[type="datetime-local"] {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: var(--font);
    outline: none;
    transition: border-color 0.2s;
    background: var(--bg);
}

.form-group input[type="date"]:focus,
.form-group input[type="datetime-local"]:focus {
    border-color: var(--text-primary);
}

/* 文件拖拽区域 */
.file-drop-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.file-drop-area:hover {
    border-color: var(--text-primary);
}

.file-drop-area.drag-over {
    border-color: var(--text-primary);
    background: var(--bg-secondary);
}

.file-drop-icon {
    font-size: 40px;
}

.file-drop-text {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.file-drop-hint {
    font-size: 12px;
    color: var(--text-tertiary);
}

.selected-file {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: 8px;
    font-size: 14px;
    color: var(--text-primary);
}

.btn-remove {
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.btn-remove:hover {
    color: var(--error);
}

/* 主按钮 - 黑色药丸 */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 32px;
    background: var(--text-primary);
    color: var(--bg);
    border: none;
    border-radius: var(--radius-pill);
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: opacity 0.2s;
    min-width: 160px;
}

.btn-primary:hover {
    opacity: 0.8;
}

.btn-primary:disabled {
    background: var(--border);
    cursor: not-allowed;
    opacity: 1;
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 6px;
}

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

/* 上传结果 */
.upload-result {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    animation: fadeIn 0.3s ease;
}

.upload-result.success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid #a7f3d0;
}

.upload-result.error {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid #fecaca;
}

/* 类型标签 */
.tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.tag-manual {
    background: var(--brand-light);
    color: var(--brand);
}

.tag-auto {
    background: var(--success-bg);
    color: var(--success);
}

.file-name-cell {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.remark-cell {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-secondary);
    font-size: 13px;
}

/* ========== 账号管理页面 ========== */
.authors-section {
    background: var(--bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--border);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}

.author-count {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-left: 4px;
}

.section-desc {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-left: 4px;
}

.section-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.add-form {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    animation: fadeIn 0.2s ease;
    border: 1px solid var(--border);
}

.add-form-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.add-form-hint {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 8px;
}

.form-input {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: var(--font);
    outline: none;
    min-width: 160px;
    transition: border-color 0.2s;
    background: var(--bg);
}

.form-input:focus {
    border-color: var(--text-primary);
}

.form-input-sm {
    min-width: 120px;
}

.btn-sm-pad {
    padding: 8px 20px !important;
    font-size: 13px !important;
}

.action-result {
    margin-bottom: 12px;
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    animation: fadeIn 0.3s ease;
}

.action-result.success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid #a7f3d0;
}

.action-result.error {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid #fecaca;
}

.filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.tag-filters {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.tag-chip {
    padding: 4px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--bg);
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    transition: all 0.2s;
    white-space: nowrap;
    font-weight: 500;
}

.tag-chip:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
}

.tag-chip.active {
    background: var(--text-primary);
    border-color: var(--text-primary);
    color: var(--bg);
    font-weight: 500;
}

.tag-group {
    background: var(--brand-light);
    color: var(--brand);
    border: 1px solid #c7d2fe;
    cursor: pointer;
}

.tag-group:hover {
    background: #ddd6fe;
}

.tag-empty {
    font-size: 12px;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 2px 8px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-pill);
    transition: all 0.2s;
}

.tag-empty:hover {
    color: var(--text-primary);
    border-color: var(--text-primary);
}

.douyin-id-cell {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-secondary);
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-danger-sm {
    padding: 4px 12px;
    border: 1px solid #fecaca;
    border-radius: var(--radius-pill);
    background: var(--error-bg);
    color: var(--error);
    cursor: pointer;
    font-size: 12px;
    font-family: var(--font);
    transition: all 0.2s;
}

.btn-danger-sm:hover {
    background: var(--error);
    color: white;
    border-color: var(--error);
}

.btn-add-sm {
    padding: 4px 12px;
    border: 1px solid #a7f3d0;
    border-radius: var(--radius-pill);
    background: var(--success-bg);
    color: var(--success);
    cursor: pointer;
    font-size: 12px;
    font-family: var(--font);
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-add-sm:hover {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

/* ========== 昵称合并展示 ========== */
.merge-content {
    padding: 0 4px;
}

.merge-groups {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 12px;
    padding: 8px 0;
}

.merge-group-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    font-size: 13px;
    line-height: 1.8;
}

.merge-group-card .merge-label {
    color: var(--text-tertiary);
    font-size: 12px;
}

.merge-canonical strong {
    color: var(--brand);
    font-size: 14px;
}

.merge-alias-list {
    color: var(--warning);
    font-weight: 500;
}

.merge-product-id {
    color: var(--text-tertiary);
    font-family: var(--font-mono);
    font-size: 12px;
}

.alias-names {
    color: var(--warning);
    font-size: 12px;
    word-break: break-all;
}

/* ========== 响应式 ========== */
@media (max-width: 1100px) {
    /* Keep every module on the same two-row mobile navigation layout. */
    :root .navbar {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        column-gap: 8px;
        row-gap: 4px;
        height: auto;
        padding: 10px 16px 6px;
    }

    :root .navbar .nav-row-top {
        display: contents;
    }

    :root .navbar .nav-brand {
        grid-column: 1;
        grid-row: 1;
        font-size: 15px;
        min-width: 0;
        margin: 0;
    }

    :root .navbar .nav-tabs {
        grid-column: 1 / -1;
        grid-row: 2;
        width: 100%;
        min-width: 0;
        max-width: 100%;
        flex-wrap: nowrap;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
        gap: 2px;
    }

    :root .navbar .nav-tab {
        flex: 0 0 auto;
        white-space: nowrap;
        padding: 6px 10px;
        font-size: 13px;
    }

    :root .navbar > .nav-date,
    :root .navbar > .nav-right,
    :root .navbar > .nav-user-info {
        grid-column: 2;
        grid-row: 1;
        position: static;
        width: auto;
        height: auto;
        min-width: 0;
        margin: 0;
        padding: 0;
        border: 0;
        background: transparent;
        justify-self: end;
        justify-content: flex-end;
    }

    :root .navbar .nav-user-info {
        display: flex;
        align-items: center;
        gap: 6px;
        margin: 0;
    }

    :root .navbar .nav-username {
        display: none;
    }

    :root .navbar .nav-logout {
        flex-shrink: 0;
        margin: 0;
    }
}

@media (max-width: 768px) {
    .nav-date,
    .nav-right {
        width: 100%;
        display: flex !important;
        align-items: center;
        gap: 8px;
        padding: 8px 16px;
        background: var(--bg-secondary);
        border-top: 1px solid var(--border);
        font-size: 13px;
        min-width: 0;
        justify-content: flex-start;
    }

    .nav-date label {
        color: var(--text-tertiary);
        font-size: 12px;
        flex-shrink: 0;
    }

    .nav-date input[type="date"] {
        flex: 0 1 auto;
        max-width: 150px;
    }

    .nav-username {
        display: none;
    }

    .nav-user-info {
        margin-left: auto;
    }

    .container {
        padding: 16px;
    }

    .card-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .summary-card {
        padding: 16px;
    }

    .card-value {
        font-size: 24px;
    }

    .card-label {
        font-size: 11px;
    }

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

    .chart {
        height: 280px;
    }

    #rankingChart {
        height: 420px;
    }

    .chart-box {
        padding: 16px;
    }

    .table-box {
        padding: 16px;
    }

    .search-input {
        width: 100%;
    }

    th, td {
        padding: 8px 12px;
        font-size: 12px;
    }

    .upload-section {
        padding: 20px;
    }

    .upload-form {
        max-width: 100%;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .file-drop-area {
        padding: 24px 16px;
    }

    .file-drop-icon {
        font-size: 30px;
    }

    .file-name-cell {
        max-width: 120px;
    }

    .authors-section {
        padding: 16px;
    }

    .add-form-row {
        flex-direction: column;
    }

    .form-input {
        min-width: 100%;
    }

    .section-actions {
        width: 100%;
    }

    .section-actions .btn-sm {
        flex: 1;
    }

    .chat-messages {
        padding: 16px;
        gap: 20px;
    }

    .message {
        max-width: 100%;
    }

    .user-message {
        max-width: 85%;
    }

    .message-text {
        font-size: 14px;
        line-height: 1.7;
    }

    .quick-questions {
        padding: 12px 16px;
    }

    .quick-list {
        gap: 6px;
    }

    .quick-btn {
        font-size: 13px;
        padding: 6px 14px;
    }

    .chat-input-area {
        padding: 12px 16px 20px;
    }

    .chat-input-box {
        padding: 4px 4px 4px 16px;
    }

    .chat-input-box textarea {
        font-size: 14px;
    }
}

@media (max-width: 375px) {
    .card-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .card-value {
        font-size: 20px;
    }

    .chart {
        height: 240px;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .card-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 12px;
    }

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