:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --background-color: #f3f4f6;
    --sidebar-bg: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    --card-bg: #ffffff;
    --text-main: #111827;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --transition: all 0.3s ease;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-main);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
    display: flex;
}

/* 动画 */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

/* 布局 */
.app-container {
    display: flex;
    width: 100%;
    height: 100%;
}

/* 侧边栏 */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    z-index: 10;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: white;
    font-weight: bold;
    font-size: 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.nav-item {
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    color: inherit;
    font-weight: 500;
}

.nav-item:hover {
    color: white;
    background-color: rgba(255,255,255,0.05);
}

.nav-item.active {
    color: var(--sidebar-text-active);
    background-color: var(--primary-color);
    border-right: 3px solid white;
}

.nav-item svg {
    width: 20px;
    height: 20px;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    font-size: 0.875rem;
    color: white;
}

/* 主内容区 */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    position: relative;
    background-color: #f8fafc;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-title {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.025em;
}

/* 组件基础 */
.card {
    background-color: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: var(--transition);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    outline: none;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-secondary {
    background-color: white;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-secondary:hover {
    background-color: #f9fafb;
    border-color: #d1d5db;
}

.btn-danger {
    background-color: #fee2e2;
    color: var(--danger-color);
}

.btn-ghost {
    background-color: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    color: var(--text-main);
    background-color: rgba(0,0,0,0.05);
}

.input-group {
    margin-bottom: 1rem;
}

.label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    transition: var(--transition);
    outline: none;
    font-family: inherit;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* 颜色工具类 */
.text-green { color: var(--success-color); }
.text-orange { color: var(--warning-color); }
.text-red { color: var(--danger-color); }
.text-gray { color: var(--text-secondary); }
.bg-green-100 { background-color: #d1fae5; }
.bg-red-100 { background-color: #fee2e2; }
.bg-gray-100 { background-color: #f3f4f6; }
.font-bold { font-weight: 700; }
.font-mono { font-family: 'SF Mono', SFMono-Regular, ui-monospace, 'DejaVu Sans Mono', monospace; }

/* === 新版折叠面板 Dashboard 样式 === */

/* 1. 顶部控制栏 */
.dashboard-top-bar {
    display: flex;
    gap: 1rem;
    align-items: center;
    background: white;
    padding: 1rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 200px;
    position: relative;
}

.search-box svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    width: 16px;
    height: 16px;
}

.search-box input {
    padding-left: 2.25rem;
}

.filter-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.filter-chip {
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
    background: white;
}

.filter-chip.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* 2. 列表行布局 (Category Row) */
.category-row {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
    transition: var(--transition);
    overflow: hidden;
}

.category-row:hover {
    box-shadow: var(--shadow-md);
    border-color: #cbd5e1;
}

.category-row.pinned {
    border-left: 4px solid var(--warning-color);
}

/* 表头行样式 */
.category-header-row {
    display: grid;
    /* 定义8列栅格 */
    grid-template-columns: 50px 1.2fr 220px 2fr 1.2fr 0.9fr 0.9fr 60px;
    gap: 1rem;
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 0.5rem;
}

.category-header {
    display: grid;
    /* 定义8列栅格 */
    grid-template-columns: 50px 1.2fr 220px 2fr 1.2fr 0.9fr 0.9fr 60px;
    gap: 1rem;
    padding: 1rem;
    align-items: center;
    cursor: pointer;
}

.category-header:hover {
    background-color: #fafafa;
}

/* 列样式 */
.col-action { display: flex; justify-content: center; align-items: center; color: #cbd5e1; }
.col-action.active { color: var(--warning-color); }

.col-info h3 { font-size: 1rem; font-weight: 600; margin-bottom: 0.25rem; }
.col-info .sub-text { font-size: 0.75rem; color: var(--text-secondary); }
.col-info .tag { 
    display: inline-block; font-size: 0.7rem; padding: 2px 6px; 
    border-radius: 4px; background: #f1f5f9; color: #475569; margin-top: 4px; 
}

/* 代表 ASIN 链接样式 */
.col-img {
    display: flex;
    justify-content: center;
    align-items: center;
}

.asin-link {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    padding: 2px 6px;
    background-color: #e0e7ff;
    border-radius: 4px;
    transition: var(--transition);
}

.asin-link:hover {
    background-color: var(--primary-color);
    color: white;
}

.col-comp { font-size: 0.875rem; }
.comp-badge { font-weight: 600; padding: 2px 6px; border-radius: 4px; font-size: 0.75rem; }
.comp-low { color: #059669; background: #d1fae5; }
.comp-med { color: #d97706; background: #fef3c7; }
.comp-high { color: #dc2626; background: #fee2e2; }
.homogeneity-indicator { display: flex; gap: -5px; margin-top: 4px; align-items: center; font-size: 0.75rem; color: var(--text-secondary); }

/* 视觉机会条 (旧) */
.viz-opportunity { width: 100%; display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: #e2e8f0; margin-bottom: 4px; }
.viz-bar-a { background: var(--success-color); }
.viz-bar-b { background: #3b82f6; }
.viz-bar-c { background: #94a3b8; }
.viz-score { font-size: 0.8rem; font-weight: 600; font-family: var(--font-mono); }

/* 视觉机会字母等级 (新) */
.viz-grades-container {
    display: flex;
    gap: 2px;
    margin-bottom: 4px;
}

.viz-grade {
    font-size: 0.9rem;
    font-weight: 800;
    font-family: var(--font-mono);
    width: 18px;
    text-align: center;
}

.viz-grade-s { color: #ef4444; } /* Red */
.viz-grade-a { color: #f59e0b; } /* Orange */
.viz-grade-b { color: #10b981; } /* Green */
.viz-grade-c { color: #64748b; } /* Slate */
.viz-grade-d { color: #94a3b8; } /* Gray */

.col-profit .big-num { font-size: 1.1rem; font-weight: 700; font-family: var(--font-mono); }
.col-profit .sub-num { font-size: 0.75rem; color: var(--text-secondary); }

/* 3. 详情展开区 (Details) */
.category-details {
    background-color: #f8fafc;
    border-top: 1px solid var(--border-color);
    padding: 1.5rem;
    display: none;
}
.category-details.open { display: block; animation: fadeIn 0.3s; }

/* 4. 产品计算卡片 (Calculator Card) */
.calc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.calc-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    padding: 1rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.calc-header { display: flex; gap: 0.75rem; }
.calc-img { width: 64px; height: 64px; object-fit: contain; border-radius: 4px; border: 1px solid #f1f5f9; }
.calc-title { 
    flex: 1; 
    font-size: 0.85rem; 
    line-height: 1.3; 
    overflow: hidden; 
    text-overflow: ellipsis;
    display: -webkit-box; 
    -webkit-line-clamp: 2; 
    /* 忽略非标准属性警告: 这是实现多行文本截断的必要属性 */
    -webkit-box-orient: vertical; 
}
/* 标题链接样式 */
.calc-title a:hover {
    text-decoration: underline;
    color: var(--primary-color);
}

.calc-meta { font-size: 0.75rem; color: var(--text-secondary); margin-top: 4px; display: flex; gap: 8px; }

/* 图片等级行 */
.image-grade-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    background-color: #f8fafc;
    border-radius: 6px;
    cursor: help;
}

.grade-badge {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    color: white;
}

.grade-badge-s { background-color: #ef4444; }
.grade-badge-a { background-color: #f59e0b; }
.grade-badge-c { background-color: #10b981; }

.grade-score {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-main);
    font-family: var(--font-mono);
}

/* 计算器表单区 */
.calc-form {
    background: #f8fafc;
    border: 1px solid #f1f5f9;
    border-radius: 6px;
    padding: 0.75rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.calc-field { display: flex; flex-direction: column; gap: 2px; }
.calc-field label { font-size: 0.7rem; color: #64748b; }
.calc-field input { 
    padding: 4px 8px; font-size: 0.85rem; border: 1px solid #cbd5e1; border-radius: 4px; 
    font-family: var(--font-mono); color: #334155; width: 100%;
}
.calc-field input:focus { border-color: var(--primary-color); outline: none; }

/* 结果区 */
.calc-result {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.5rem;
    border-top: 1px dashed #e2e8f0;
}
.result-box { text-align: right; }
.result-label { font-size: 0.7rem; color: #94a3b8; display: block; }
.result-val { font-size: 1.25rem; font-weight: 800; font-family: var(--font-mono); }
.margin-high { color: var(--success-color); }
.margin-med { color: var(--warning-color); }
.margin-low { color: #9ca3af; }

.calc-actions { display: flex; justify-content: flex-end; margin-top: 0.25rem; }
.btn-save { padding: 4px 12px; font-size: 0.75rem; }

/* 移动端适配 */
@media (max-width: 1024px) {
    /* 隐藏表头 */
    .category-header-row { display: none; }

    .category-header {
        grid-template-columns: 40px 1fr 1fr 40px; /* 简化列 */
        grid-template-areas: 
            "star info img action"
            "star metrics metrics action";
        gap: 0.5rem;
    }
    .col-action { grid-area: action; }
    .col-info { grid-area: info; }
    .col-img { grid-area: img; }
    /* 隐藏部分列在移动端 */
    .col-viz, .col-comp, .col-sales { display: none; }
    
    /* 移动端自定义显示 */
    .mobile-metrics { display: flex; grid-area: metrics; gap: 1rem; font-size: 0.8rem; color: #64748b; }
}

/* 原始样式保留 */
.auth-page { width: 100%; height: 100vh; background-color: #f3f4f6; display: flex; justify-content: center; align-items: center; padding: 2rem; }
.auth-container { width: 100%; max-width: 1000px; height: 600px; background: white; border-radius: var(--radius-lg); box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); display: flex; overflow: hidden; }
.auth-brand-side { flex: 1.2; background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%); color: white; padding: 4rem; display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; }
.auth-form-side { flex: 1; padding: 3rem; display: flex; align-items: center; justify-content: center; background-color: white; }
.brand-content { z-index: 2; }
.brand-content h1 { font-size: 2.5rem; margin-bottom: 1.5rem; font-weight: 800; line-height: 1.2; }
.brand-content p { font-size: 1.1rem; opacity: 0.9; line-height: 1.6; font-weight: 300; }
.brand-decoration { position: absolute; bottom: -20px; right: -20px; width: 400px; height: 400px; opacity: 0.6; pointer-events: none; }
.auth-card-inner { width: 100%; max-width: 320px; }
.tabs { display: flex; border-bottom: 1px solid var(--border-color); margin-bottom: 1.5rem; }
.tab-item { padding: 0.75rem 1.5rem; cursor: pointer; border-bottom: 2px solid transparent; color: var(--text-secondary); font-weight: 500; transition: var(--transition); }
.tab-item:hover { color: var(--primary-color); }
.tab-item.active { color: var(--primary-color); border-bottom-color: var(--primary-color); }
.task-list { display: flex; flex-direction: column; gap: 1rem; }
.task-item { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem; background: white; border-radius: var(--radius-md); box-shadow: var(--shadow-sm); transition: var(--transition); cursor: pointer; border: 1px solid transparent; }
.task-item:hover { border-color: var(--primary-color); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.status-badge { padding: 0.25rem 0.75rem; border-radius: 9999px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; }
.status-pending { background: #f3f4f6; color: #6b7280; }
.status-processing { background: #e0e7ff; color: #4f46e5; }
.status-success, .status-completed { background: #d1fae5; color: #059669; }
.status-fail { background: #fee2e2; color: #dc2626; }
.status-paused { background: #fef3c7; color: #d97706; }
.file-upload-zone { border: 2px dashed var(--border-color); border-radius: var(--radius-lg); padding: 2rem; text-align: center; cursor: pointer; background-color: #f9fafb; }
.hidden { display: none !important; }

/* 图片上传预览样式 */
.image-preview-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}
.image-chip {
    position: relative;
    width: 72px;
    height: 72px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
    background: #f8fafc;
    box-shadow: var(--shadow-sm);
}
.image-chip img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.image-chip .remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 50%;
    background: rgba(0,0,0,0.55);
    color: #fff;
    font-size: 12px;
    line-height: 18px;
    text-align: center;
    cursor: pointer;
}
.image-chip .remove-btn:hover {
    background: rgba(0,0,0,0.7);
}

/* === Interaction Feedback Enhancements === */

/* Spin animation (used for button loading state) */
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Pulse glow animation (used on status badge after pause/resume) */
@keyframes pulseGlow {
    0% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.55); transform: scale(1); }
    65% { box-shadow: 0 0 0 8px rgba(79, 70, 229, 0); transform: scale(1.06); }
    100% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0); transform: scale(1); }
}

/* Button loading state: dim + spin icon */
.btn.loading {
    opacity: 0.75;
    cursor: not-allowed;
    pointer-events: none;
}
.btn.loading svg {
    transform-origin: 50% 50%;
    animation: spin 0.9s linear infinite;
}

/* Status badge pulse feedback */
.status-badge.pulse {
    animation: pulseGlow 0.9s ease-out 1;
}
