/* ===== 全局重置与变量 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary: #6366f1;
    --primary-light: #eef2ff;
    --primary-dark: #4f46e5;
    --primary-glow: rgba(99,102,241,0.15);
    --accent-blue: #5470c6;
    --accent-red: #ee6666;
    --accent-green: #22c55e;
    --accent-orange: #f59e0b;
    --bg: #f5f5f7;
    --bg-secondary: #eeeef0;
    --surface: #ffffff;
    --surface-hover: #fafafa;
    --border: #e5e5e5;
    --border-light: #f0f0f0;
    --text: #1a1a1a;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --text-muted: #d1d5db;
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.05);
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 深色主题 */
body.dark {
    --bg: #0f0f11;
    --bg-secondary: #18181b;
    --surface: #1e1e22;
    --surface-hover: #27272a;
    --border: #2e2e33;
    --border-light: #232328;
    --text: #f0f0f0;
    --text-secondary: #a1a1aa;
    --text-light: #71717a;
    --text-muted: #52525b;
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.4);
    --primary-light: #1e1b4b;
    --primary-glow: rgba(99,102,241,0.2);
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    transition: background 0.3s, color 0.3s;
}

/* ===== 顶部导航栏 ===== */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 52px;
    padding: 0 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
    z-index: 100;
    gap: 12px;
    transition: var(--transition);
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.logo-icon { font-size: 1.4rem; color: var(--primary); }

.top-bar-left h1 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
    white-space: nowrap;
}

.top-bar-center {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    justify-content: center;
    overflow-x: auto;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.toolbar-label {
    font-size: 0.72rem;
    color: var(--text-light);
    white-space: nowrap;
    font-weight: 500;
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    flex-shrink: 0;
}

.btn-group {
    display: flex;
    gap: 3px;
    background: var(--bg);
    border-radius: var(--radius-md);
    padding: 3px;
}

.tb-btn, .style-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    white-space: nowrap;
}

.style-btn { padding: 5px 8px; }

.tb-btn:hover, .style-btn:hover {
    color: var(--primary);
    background: var(--primary-light);
}

.tb-btn.active, .style-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 6px rgba(99,102,241,0.3);
}

.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
}

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

.action-btn.active {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.info-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: var(--bg);
    border-radius: var(--radius-xl);
    font-size: 0.72rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.info-badge i { color: var(--primary); font-size: 0.85rem; }

/* ===== 主布局 ===== */
.main-layout {
    display: flex;
    height: calc(100vh - 52px - 32px);
    overflow: hidden;
}

/* ===== 左侧字段面板 ===== */
.field-panel {
    width: 230px;
    min-width: 230px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: var(--transition);
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px 10px;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}

.panel-header i { color: var(--primary); font-size: 1rem; }

.panel-toggle-btn {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    font-size: 1rem;
    padding: 2px;
    border-radius: var(--radius-xs);
    transition: var(--transition);
}

.panel-toggle-btn:hover { color: var(--primary); background: var(--primary-light); }

.field-search {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 8px 10px 6px;
    padding: 6px 10px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1.5px solid transparent;
    transition: var(--transition);
}

.field-search:focus-within {
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.field-search i { color: var(--text-light); font-size: 0.85rem; }

.field-search input {
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.78rem;
    color: var(--text);
    width: 100%;
    font-family: inherit;
}

.clear-search-btn {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0;
    transition: var(--transition);
}

.clear-search-btn:hover { color: var(--accent-red); }

/* 数据概览 */
.data-overview {
    border-bottom: 1px solid var(--border);
}

.overview-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.overview-header:hover { background: var(--surface-hover); }

.overview-header .toggle-arrow { margin-left: auto; transition: transform 0.2s; }
.overview-header.collapsed .toggle-arrow { transform: rotate(-90deg); }

.overview-content {
    padding: 0 10px 8px;
    max-height: 200px;
    overflow-y: auto;
    transition: var(--transition-slow);
}

.overview-content.collapsed { max-height: 0; padding: 0 10px; overflow: hidden; }

.overview-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.overview-card {
    padding: 8px 10px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    text-align: center;
}

.overview-card .ov-label {
    font-size: 0.65rem;
    color: var(--text-light);
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.overview-card .ov-value {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
}

/* 字段分类 */
.field-category { border-bottom: 1px solid var(--border-light); }
.field-category:last-child { flex: 1; display: flex; flex-direction: column; border-bottom: none; }

.category-title {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}

.category-title:hover { background: var(--surface-hover); }

.field-count {
    margin-left: 4px;
    background: var(--bg);
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 0.65rem;
    color: var(--text-light);
}

.category-title .toggle-arrow { margin-left: auto; transition: transform 0.2s; font-size: 0.9rem; }
.category-title.collapsed .toggle-arrow { transform: rotate(-90deg); }

.field-list {
    padding: 0 6px 4px;
    overflow-y: auto;
    max-height: 30vh;
    transition: var(--transition-slow);
}

.field-category:last-child .field-list {
    max-height: none;
    flex: 1;
    min-height: 0;
}

.field-list.collapsed { max-height: 0; padding: 0 6px; overflow: hidden; }

.field-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    margin: 2px 0;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    cursor: grab;
    transition: var(--transition);
    user-select: none;
    border: 1.5px solid transparent;
    position: relative;
}

.field-tag:active { cursor: grabbing; }

.field-tag.dimension { background: #eff6ff; color: #1d4ed8; }
.field-tag.dimension:hover { background: #dbeafe; border-color: #93c5fd; box-shadow: var(--shadow-xs); }

.field-tag.metric { background: #f0fdf4; color: #15803d; }
.field-tag.metric:hover { background: #dcfce7; border-color: #86efac; box-shadow: var(--shadow-xs); }

body.dark .field-tag.dimension { background: #1e293b; color: #93c5fd; }
body.dark .field-tag.dimension:hover { background: #1e3a5f; border-color: #3b82f6; }
body.dark .field-tag.metric { background: #14291a; color: #86efac; }
body.dark .field-tag.metric:hover { background: #1a3a24; border-color: #22c55e; }

.field-tag .field-icon { font-size: 0.85rem; flex-shrink: 0; }
.field-tag .field-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field-tag .type-switch-hint { display: none; font-size: 0.6rem; color: var(--text-light); margin-left: auto; white-space: nowrap; }
.field-tag:hover .type-switch-hint { display: inline; }
.field-tag .type-override-icon { font-size: 0.65rem; color: var(--primary); opacity: 0.7; }
.field-tag.dragging { opacity: 0.4; transform: scale(0.95); }
.field-tag.search-highlight { background: #fef3c7 !important; border-color: #f59e0b !important; }
body.dark .field-tag.search-highlight { background: #422006 !important; border-color: #f59e0b !important; }

/* ===== 右侧工作区 ===== */
.workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg);
}

/* 筛选器栏 */
.filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    gap: 12px;
    flex-shrink: 0;
    min-height: 38px;
}

.filter-bar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    overflow-x: auto;
}

.filter-bar-left > i { color: var(--primary); font-size: 0.9rem; flex-shrink: 0; }
.filter-label { font-size: 0.72rem; color: var(--text-secondary); font-weight: 600; flex-shrink: 0; }

.filter-chips { display: flex; gap: 6px; flex-wrap: nowrap; overflow-x: auto; }

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: var(--radius-xl);
    font-size: 0.7rem;
    font-weight: 500;
    white-space: nowrap;
    animation: chipIn 0.2s ease;
}

@keyframes chipIn { from { opacity: 0; transform: scale(0.8); } to { opacity: 1; transform: scale(1); } }

.filter-chip .chip-remove {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0;
    opacity: 0.6;
    transition: var(--transition);
}

.filter-chip .chip-remove:hover { opacity: 1; }

.add-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 10px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-xl);
    background: transparent;
    color: var(--text-light);
    font-size: 0.7rem;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    font-family: inherit;
}

.add-filter-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

.filter-bar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.agg-selector, .sort-selector, .null-selector {
    display: flex;
    align-items: center;
    gap: 4px;
}

.agg-label, .sort-label, .null-label {
    font-size: 0.68rem;
    color: var(--text-light);
    white-space: nowrap;
}

.agg-select, .sort-select, .null-select {
    padding: 3px 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--surface);
    color: var(--text);
    font-size: 0.7rem;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    transition: var(--transition);
}

.agg-select:focus, .sort-select:focus, .null-select:focus { border-color: var(--primary); }

/* 配置区域 */
.config-area {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    overflow-y: auto;
    flex-shrink: 0;
    max-height: 320px;
}

.drop-zone-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-width: 0;
    overflow: visible;
    position: relative;
}

.drop-zone-wrapper .drop-zone-label {
    flex-shrink: 0;
    width: 140px;
    min-width: 140px;
    padding-top: 4px;
    margin-bottom: 0;
    flex-wrap: wrap;
    row-gap: 4px;
}

.drop-zone-wrapper .drop-zone,
.drop-zone-wrapper .pivot-agg-inline {
    flex: 1;
    min-width: 0;
}

.drop-zone-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0;
    padding-left: 2px;
    white-space: nowrap;
    overflow: visible;
}

.axis-style-select {
    margin-left: 0;
    padding: 3px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 0.65rem;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    transition: var(--transition);
    position: relative;
    z-index: 2;
    min-width: 70px;
    flex-shrink: 0;
    width: 100%;
}

.axis-style-select:focus { border-color: var(--primary); }
.axis-style-select:hover { border-color: var(--primary); color: var(--primary); }

.drop-zone {
    min-height: 38px;
    padding: 4px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    background: var(--bg);
    transition: var(--transition);
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.drop-zone.drag-over {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.drop-placeholder {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--text-muted);
    font-size: 0.72rem;
    padding: 2px 6px;
    width: 100%;
    justify-content: center;
}

.drop-placeholder i { font-size: 0.9rem; }

.placed-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    border-radius: 14px;
    font-size: 0.72rem;
    font-weight: 500;
    background: var(--primary);
    color: white;
    cursor: default;
    animation: tagIn 0.2s ease;
}

.placed-tag.left-y { background: var(--accent-blue); }
.placed-tag.right-y { background: var(--accent-red); }
.placed-tag.x-axis { background: #8b5cf6; }
.placed-tag.group-tag { background: var(--accent-orange); color: #1a1a1a; }

.placed-tag .remove-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    cursor: pointer;
    font-size: 0.65rem;
    transition: var(--transition);
    border: none;
    color: inherit;
    padding: 0;
    line-height: 1;
}

.placed-tag .remove-btn:hover { background: rgba(255,255,255,0.6); }

/* 指标聚合方式选择器 */
.metric-agg-select {
    padding: 1px 4px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 8px;
    background: rgba(255,255,255,0.2);
    color: inherit;
    font-size: 0.62rem;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    transition: var(--transition);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    text-align: center;
    min-width: 42px;
}

.metric-agg-select:hover { background: rgba(255,255,255,0.35); border-color: rgba(255,255,255,0.5); }
.metric-agg-select:focus { background: rgba(255,255,255,0.4); }

.metric-agg-select option {
    background: var(--surface);
    color: var(--text);
    font-size: 0.72rem;
}

/* 数据表格视图中的指标列 */
.data-table th.metric-col { color: var(--accent-green); }
.data-table th.dim-col { color: var(--accent-blue); }
.data-table td.metric-cell { font-variant-numeric: tabular-nums; }

@keyframes tagIn { from { opacity: 0; transform: scale(0.8); } to { opacity: 1; transform: scale(1); } }

.drop-zone-wrapper.hidden { display: none; }

/* 图表标题栏 */
.chart-title-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}

.chart-title-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    font-family: inherit;
    padding: 4px 0;
}

.chart-title-input::placeholder { color: var(--text-muted); font-weight: 400; }

.title-edit-btn {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
}

.title-edit-btn:hover { color: var(--primary); }

/* KPI指标卡区域 */
.kpi-area {
    padding: 10px 16px;
    background: var(--bg);
    flex-shrink: 0;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}

.kpi-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    border: 1px solid var(--border-light);
}

.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.kpi-card .kpi-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kpi-card .kpi-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.2;
}

.kpi-card .kpi-sub {
    font-size: 0.65rem;
    color: var(--text-light);
    margin-top: 4px;
}

.kpi-card .kpi-trend { font-size: 0.7rem; margin-top: 4px; font-weight: 600; }
.kpi-card .kpi-trend.up { color: var(--accent-green); }
.kpi-card .kpi-trend.down { color: var(--accent-red); }

/* ===== 图表区域 ===== */
.chart-area {
    flex: 1;
    padding: 12px 16px;
    position: relative;
    overflow: hidden;
    min-height: 0;
}

.chart-canvas {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.chart-empty {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-light);
    pointer-events: none;
}

.chart-empty i { font-size: 3.5rem; margin-bottom: 12px; display: block; opacity: 0.2; }
.chart-empty p { font-size: 0.92rem; margin-bottom: 4px; }
.chart-empty .hint { font-size: 0.78rem; opacity: 0.6; }
.chart-empty kbd {
    display: inline-block;
    padding: 1px 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.72rem;
    font-family: inherit;
}
.chart-empty.hidden { display: none; }

/* ===== 数据表格视图（可视化样式） ===== */
.viz-table-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 12px 16px;
    min-height: 0;
}

.viz-table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: var(--surface);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    border: 1px solid var(--border-light);
    border-bottom: none;
}

.viz-table-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
}

.viz-table-title i { color: var(--primary); }

.viz-table-info { font-size: 0.72rem; color: var(--text-secondary); }

.viz-table-container {
    flex: 1;
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    box-shadow: var(--shadow-sm);
}

/* ===== 数据透视表 ===== */
.pivot-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 12px 16px;
    min-height: 0;
}

.pivot-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: var(--surface);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    border: 1px solid var(--border-light);
    border-bottom: none;
    gap: 12px;
    flex-wrap: wrap;
}

.pivot-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    flex-shrink: 0;
}

.pivot-title i { color: var(--primary); }

.pivot-config {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.pivot-config-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pivot-config-item label {
    font-size: 0.68rem;
    color: var(--text-light);
    white-space: nowrap;
    font-weight: 500;
}

.pivot-select {
    padding: 3px 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--surface);
    color: var(--text);
    font-size: 0.7rem;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    transition: var(--transition);
    max-width: 140px;
}

.pivot-select:focus { border-color: var(--primary); }

.pivot-apply-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.pivot-apply-btn:hover { background: var(--primary-dark); }

.pivot-table-container {
    flex: 1;
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.pivot-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 200px;
    color: var(--text-light);
    text-align: center;
    gap: 8px;
}

.pivot-empty i { font-size: 2.5rem; opacity: 0.2; }
.pivot-empty p { font-size: 0.85rem; }

/* 透视表样式 */
.pivot-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}

/* 透视表拖拽标签样式 */
.placed-tag.pivot-row-tag { background: #8b5cf6; }
.placed-tag.pivot-col-tag { background: #06b6d4; }
.placed-tag.pivot-metric-tag { background: #22c55e; }

/* 透视表配置区聚合方式内联选择器 */
.pivot-agg-wrapper { }
.pivot-agg-inline { padding: 4px; }
.pivot-agg-select-inline {
    width: 100%;
    padding: 6px 10px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    background: var(--bg);
    color: var(--text);
    font-size: 0.78rem;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    transition: var(--transition);
    text-align: center;
}
.pivot-agg-select-inline:focus { border-color: var(--primary); background: var(--primary-light); }
.pivot-agg-select-inline:hover { border-color: var(--primary); }

/* 透视表提示文字 */
.pivot-hint {
    font-size: 0.72rem;
    color: var(--text-light);
    font-weight: 400;
}

/* 透视表指标列头 */
.pivot-table th.pivot-metric-header {
    background: #f0fdf4;
    color: #15803d;
    font-size: 0.7rem;
    font-weight: 500;
}
body.dark .pivot-table th.pivot-metric-header {
    background: #14291a;
    color: #86efac;
}

.pivot-table th {
    position: sticky;
    top: 0;
    background: var(--bg);
    padding: 8px 12px;
    text-align: center;
    font-weight: 600;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    white-space: nowrap;
    z-index: 2;
}

.pivot-table th.pivot-row-header {
    text-align: left;
    background: var(--primary-light);
    color: var(--primary);
    position: sticky;
    left: 0;
    z-index: 3;
}

.pivot-table th.pivot-col-header {
    background: #eff6ff;
    color: #1d4ed8;
}

body.dark .pivot-table th.pivot-col-header {
    background: #1e293b;
    color: #93c5fd;
}

.pivot-table th.pivot-total-header {
    background: #fef3c7;
    color: #92400e;
}

body.dark .pivot-table th.pivot-total-header {
    background: #422006;
    color: #fbbf24;
}

.pivot-table td {
    padding: 6px 12px;
    border: 1px solid var(--border-light);
    color: var(--text);
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.pivot-table td.pivot-row-label {
    text-align: left;
    font-weight: 500;
    background: var(--surface);
    position: sticky;
    left: 0;
    z-index: 1;
    border-right: 2px solid var(--border);
}

.pivot-table td.pivot-total-cell {
    font-weight: 700;
    background: #fffbeb;
    color: #92400e;
}

body.dark .pivot-table td.pivot-total-cell {
    background: #1c1a0e;
    color: #fbbf24;
}

.pivot-table tr.pivot-total-row td {
    font-weight: 700;
    background: #fef3c7;
    color: #92400e;
    border-top: 2px solid var(--accent-orange);
}

body.dark .pivot-table tr.pivot-total-row td {
    background: #422006;
    color: #fbbf24;
}

.pivot-table tr:hover td:not(.pivot-row-label) { background: var(--surface-hover); }

/* 透视表热力图着色 */
.pivot-table td.heat-low { background: #f0fdf4; }
.pivot-table td.heat-mid { background: #fef3c7; }
.pivot-table td.heat-high { background: #fee2e2; }
body.dark .pivot-table td.heat-low { background: #14291a; }
body.dark .pivot-table td.heat-mid { background: #422006; }
body.dark .pivot-table td.heat-high { background: #3b1010; }

/* 数据表格 */
.table-area {
    background: var(--surface);
    border-top: 1px solid var(--border);
    max-height: 40vh;
    display: flex;
    flex-direction: column;
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.table-actions { display: flex; align-items: center; gap: 10px; }

.table-info { font-size: 0.72rem; color: var(--text-secondary); font-weight: 400; }

.table-close-btn {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition);
}

.table-close-btn:hover { color: var(--accent-red); }

.table-container {
    overflow: auto;
    flex: 1;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}

.data-table th {
    position: sticky;
    top: 0;
    background: var(--bg);
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    z-index: 1;
}

.data-table td {
    padding: 6px 12px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text);
    white-space: nowrap;
}

.data-table tr:hover td { background: var(--surface-hover); }

/* ===== 弹窗 ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.15s ease;
    backdrop-filter: blur(2px);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: modalIn 0.2s ease;
}

.modal-content.modal-sm { max-width: 440px; }

@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 0.95rem; font-weight: 700; color: var(--text); }

.modal-close {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    font-size: 1.2rem;
    transition: var(--transition);
    padding: 4px;
    border-radius: var(--radius-xs);
}

.modal-close:hover { color: var(--accent-red); background: rgba(238,102,102,0.1); }

.modal-body {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: var(--text);
    margin-bottom: 6px;
    cursor: pointer;
}

.form-group label input[type="checkbox"] {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
}

.form-input, .form-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 0.82rem;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
    margin-top: 4px;
}

.form-input:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.form-input:disabled { opacity: 0.5; cursor: not-allowed; }

.primary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 20px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    width: 100%;
}

.primary-btn:hover { background: var(--primary-dark); box-shadow: 0 2px 8px rgba(99,102,241,0.3); }

/* 筛选类型标签页 */
.filter-type-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg);
    border-radius: var(--radius-md);
    padding: 3px;
}

.filter-type-tab {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.72rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    white-space: nowrap;
    flex: 1;
    justify-content: center;
}

.filter-type-tab:hover { color: var(--primary); background: var(--primary-light); }
.filter-type-tab.active { background: var(--primary); color: white; box-shadow: 0 2px 6px rgba(99,102,241,0.3); }
.filter-type-tab i { font-size: 0.85rem; }

.filter-panel { margin-bottom: 12px; }

/* 筛选值搜索 */
.filter-values-search {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1.5px solid transparent;
    transition: var(--transition);
    margin-bottom: 6px;
}

.filter-values-search:focus-within {
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.filter-values-search i { color: var(--text-light); font-size: 0.85rem; }

.filter-values-search input {
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.78rem;
    color: var(--text);
    width: 100%;
    font-family: inherit;
}

/* 值筛选操作按钮 */
.filter-values-actions {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
}

.filter-val-action {
    padding: 3px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    background: transparent;
    color: var(--text-light);
    font-size: 0.68rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.filter-val-action:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

/* 筛选值列表 */
.filter-values-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px;
}

.filter-value-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    font-size: 0.78rem;
    color: var(--text);
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: var(--transition);
}

.filter-value-item:hover { background: var(--primary-light); }

.filter-value-item input[type="checkbox"] { accent-color: var(--primary); }

/* 范围筛选行 */
.filter-range-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.filter-range-sep {
    font-size: 1.2rem;
    color: var(--text-light);
    padding-bottom: 18px;
    flex-shrink: 0;
}

/* 筛选预览 */
.filter-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    margin-top: 8px;
    margin-bottom: 4px;
}

.filter-preview i { color: var(--primary); font-size: 0.9rem; flex-shrink: 0; }
.filter-preview span { font-size: 0.75rem; color: var(--text-secondary); }

/* 筛选chip增强 - 不同类型不同颜色 */
.filter-chip.type-compare { background: #fef3c7; color: #92400e; }
.filter-chip.type-range { background: #dbeafe; color: #1d4ed8; }
.filter-chip.type-string { background: #f0fdf4; color: #15803d; }
body.dark .filter-chip.type-compare { background: #422006; color: #fbbf24; }
body.dark .filter-chip.type-range { background: #1e293b; color: #93c5fd; }
body.dark .filter-chip.type-string { background: #14291a; color: #86efac; }

/* 快捷键列表 */
.shortcut-list { display: flex; flex-direction: column; gap: 6px; }

.shortcut-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
}

.shortcut-item kbd {
    display: inline-block;
    padding: 2px 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.72rem;
    font-family: inherit;
    font-weight: 600;
    color: var(--text-secondary);
    box-shadow: 0 1px 0 var(--border);
}

.shortcut-item span { color: var(--text-secondary); font-size: 0.78rem; }

/* 配置列表 */
.config-list { display: flex; flex-direction: column; gap: 6px; }

.config-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.config-item:hover { background: var(--primary-light); }

.config-item-info { flex: 1; }
.config-item-name { font-size: 0.82rem; font-weight: 600; color: var(--text); }
.config-item-time { font-size: 0.68rem; color: var(--text-light); margin-top: 2px; }

.config-item-actions { display: flex; gap: 6px; }

.config-item-actions button {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 4px;
    border-radius: var(--radius-xs);
    transition: var(--transition);
}

.config-item-actions button:hover { color: var(--accent-red); background: rgba(238,102,102,0.1); }
.config-item-actions button.load-btn:hover { color: var(--primary); background: var(--primary-light); }

/* ===== 全屏 ===== */
.fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.2s ease;
}

.fullscreen-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.fullscreen-header span { font-size: 0.95rem; font-weight: 600; color: var(--text); }

.fullscreen-close {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.82rem;
    font-family: inherit;
    transition: var(--transition);
}

.fullscreen-close:hover { border-color: var(--accent-red); color: var(--accent-red); }

.fullscreen-chart { flex: 1; padding: 16px; }

/* ===== 右键菜单 ===== */
.context-menu {
    position: fixed;
    z-index: 9999;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 4px 0;
    min-width: 170px;
    display: none;
    animation: menuFadeIn 0.12s ease;
}

.context-menu.visible { display: block; }

@keyframes menuFadeIn { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: translateY(0); } }

.context-menu-title {
    padding: 5px 12px 6px;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 3px;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 12px;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 0.78rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    text-align: left;
}

.context-menu-item:hover { background: var(--primary-light); color: var(--primary); }
.context-menu-item i:first-child { font-size: 0.9rem; width: 16px; text-align: center; color: var(--text-secondary); }
.context-menu-item:hover i:first-child { color: var(--primary); }
.context-menu-item span { flex: 1; }
.context-menu-item .check-icon { font-size: 0.85rem; color: var(--primary); opacity: 0; transition: var(--transition); }
.context-menu-item.active .check-icon { opacity: 1; }
.context-menu-item.active { color: var(--primary); font-weight: 600; }

/* ===== Toast通知 ===== */
.toast-container {
    position: fixed;
    top: 60px;
    right: 16px;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 0.82rem;
    color: var(--text);
    animation: toastIn 0.25s ease;
    max-width: 320px;
}

.toast.success { border-left: 3px solid var(--accent-green); }
.toast.error { border-left: 3px solid var(--accent-red); }
.toast.info { border-left: 3px solid var(--primary); }

.toast i { font-size: 1.1rem; flex-shrink: 0; }
.toast.success i { color: var(--accent-green); }
.toast.error i { color: var(--accent-red); }
.toast.info i { color: var(--primary); }

@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

.toast.fade-out { animation: toastOut 0.25s ease forwards; }
@keyframes toastOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(20px); } }

/* ===== 底部 ===== */
.app-footer {
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border-top: 1px solid var(--border);
    font-size: 0.72rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.app-footer a { text-decoration: none; font-weight: 600; }
.app-footer a:hover { text-decoration: underline; }

/* ===== 数据导入 ===== */
.import-drop-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 36px 20px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    background: var(--bg);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    gap: 8px;
}

.import-drop-area:hover, .import-drop-area.drag-over {
    border-color: var(--primary);
    background: var(--primary-light);
}

.import-drop-area i { font-size: 2.5rem; color: var(--primary); opacity: 0.6; }
.import-drop-area p { font-size: 0.85rem; color: var(--text-secondary); }
.import-drop-area .import-hint { font-size: 0.72rem; color: var(--text-light); }

.import-file-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    margin-top: 12px;
}

.import-file-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--primary);
}

.import-reselect {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border: 1px solid var(--primary);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--primary);
    font-size: 0.72rem;
    cursor: pointer;
    font-family: inherit;
    transition: var(--transition);
}

.import-reselect:hover { background: var(--primary); color: white; }

/* 字段映射弹窗 */
.mapping-desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 14px;
    line-height: 1.5;
}

.mapping-list {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.mapping-row {
    display: flex;
    align-items: center;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border-light);
    gap: 12px;
    transition: var(--transition);
}

.mapping-row:last-child { border-bottom: none; }
.mapping-row:hover { background: var(--surface-hover); }

.mapping-row .mapping-field-name {
    flex: 1;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mapping-row .mapping-sample {
    font-size: 0.7rem;
    color: var(--text-light);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mapping-row .mapping-type-select {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 0.75rem;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    transition: var(--transition);
    min-width: 90px;
}

.mapping-row .mapping-type-select:focus { border-color: var(--primary); }

.mapping-row .mapping-type-select.type-dimension { border-color: #93c5fd; background: #eff6ff; color: #1d4ed8; }
.mapping-row .mapping-type-select.type-metric { border-color: #86efac; background: #f0fdf4; color: #15803d; }

body.dark .mapping-row .mapping-type-select.type-dimension { border-color: #3b82f6; background: #1e293b; color: #93c5fd; }
body.dark .mapping-row .mapping-type-select.type-metric { border-color: #22c55e; background: #14291a; color: #86efac; }

.mapping-actions {
    display: flex;
    gap: 10px;
    margin-top: 14px;
}

.mapping-actions .primary-btn { flex: 2; }

.secondary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    flex: 1;
}

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

/* ===== 计算字段 ===== */
.add-calc-field-bar {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border-light);
}

.add-calc-field-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    width: 100%;
    padding: 6px 10px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.add-calc-field-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.add-calc-field-btn i { font-size: 0.9rem; }

.form-textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 0.82rem;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    outline: none;
    transition: var(--transition);
    resize: vertical;
    line-height: 1.5;
}

.form-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.calc-field-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-height: 120px;
    overflow-y: auto;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
}

.calc-field-chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    font-size: 0.7rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.calc-field-chip:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.calc-ops-hint {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.calc-op {
    display: inline-block;
    padding: 2px 8px;
    background: var(--bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xs);
    font-size: 0.7rem;
    color: var(--text-light);
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

.calc-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    border: 1px solid var(--border-light);
}

.calc-preview-label {
    font-size: 0.75rem;
    color: var(--text-light);
    flex-shrink: 0;
}

.calc-preview-value {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

.calc-preview-value.error { color: var(--accent-red); }

.field-tag.calculated { background: #fef3c7; color: #92400e; }
.field-tag.calculated:hover { background: #fde68a; border-color: #f59e0b; box-shadow: var(--shadow-xs); }
body.dark .field-tag.calculated { background: #422006; color: #fbbf24; }
body.dark .field-tag.calculated:hover { background: #4a2c0a; border-color: #f59e0b; }

/* ===== 隐藏 ===== */
.hidden { display: none !important; }

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

/* ===== 全局拖拽上传遮罩 ===== */
.global-drop-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(99, 102, 241, 0.12);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
    pointer-events: all;
}
.global-drop-overlay.hidden {
    display: none;
}
.global-drop-content {
    text-align: center;
    padding: 48px 64px;
    border-radius: 20px;
    border: 3px dashed #6366f1;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 8px 40px rgba(99, 102, 241, 0.18);
    animation: globalDropPulse 1.5s ease-in-out infinite;
}
body.dark .global-drop-content {
    background: rgba(30, 30, 34, 0.95);
    border-color: #818cf8;
    box-shadow: 0 8px 40px rgba(99, 102, 241, 0.3);
}
.global-drop-content i {
    font-size: 56px;
    color: #6366f1;
    display: block;
    margin-bottom: 16px;
}
.global-drop-content p {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0;
}
body.dark .global-drop-content p {
    color: #f0f0f0;
}
.global-drop-hint {
    font-size: 13px !important;
    font-weight: 400 !important;
    color: #9ca3af !important;
    margin-top: 8px !important;
}
@keyframes globalDropPulse {
    0%, 100% { transform: scale(1); border-color: #6366f1; }
    50% { transform: scale(1.02); border-color: #818cf8; }
}

/* ===== 响应式 ===== */
@media (max-width: 1024px) {
    .top-bar { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 6px; }
    .top-bar-center { order: 3; width: 100%; overflow-x: auto; }
    .field-panel { width: 200px; min-width: 200px; }
    .config-area { max-height: 260px; }
    .filter-bar { flex-wrap: wrap; }
    .filter-bar-right { width: 100%; justify-content: flex-start; }
}

@media (max-width: 768px) {
    .main-layout { flex-direction: column; }
    .field-panel { width: 100%; min-width: auto; max-height: 180px; border-right: none; border-bottom: 1px solid var(--border); }
    .field-list { display: flex; flex-wrap: wrap; max-height: none; }
    .field-tag { flex: 0 0 auto; }
}
