/* ==========================================================================
   宝之通增长中台 · base.css — 设计 tokens / reset / 排版基础
   --------------------------------------------------------------------------
   设计原则:
   - 克制、专业、信息密度优先;不用大渐变、不用阴影堆叠。
   - 主色 blue (#2563eb),用于强调与状态;辅以中性灰/足够对比背景。
   - 8 倍数间距体系;统一圆角 6/8/10;字体大小 12/13/14/16/18。
   - 所有 class 名保留以兼容现有模板。
   ========================================================================== */

/* ----- Design Tokens ----- */
:root {
    /* 布局 */
    --sidebar-width: 240px;
    --topbar-height: 56px;

    /* 色彩 · 侧栏（深蓝黑，比纯灰黑更有品牌气质） */
    --sidebar-bg: #0d1426;
    --sidebar-light: #0a101f;

    /* 色彩 · 页面 */
    --page-bg: #f3f5fa;
    --surface: #ffffff;
    --surface-soft: #f8fafd;
    --surface-muted: #eef2f7;
    --surface-border: #e4e9f1;
    --border-strong: #cbd5e1;

    /* 色彩 · 文字 */
    --text-main: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --text-faint: #94a3b8;

    /* 色彩 · 强调（蓝→靛渐变品牌体系） */
    --accent: #2563eb;
    --accent-dark: #1d4ed8;
    --accent-pressed: #1e40af;
    --accent-soft: #eff4ff;
    --accent-softer: #f6f9ff;
    --accent-line: #93c5fd;
    --brand-grad-from: #2563eb;
    --brand-grad-to: #4f46e5;
    --brand-gradient: linear-gradient(135deg, var(--brand-grad-from), var(--brand-grad-to));

    /* 色彩 · 语义 */
    --success: #059669;
    --success-dark: #047857;
    --success-darker: #065f46;
    --success-soft: #ecfdf5;
    --warning: #d97706;
    --warning-dark: #92400e;
    --warning-soft: #fffbeb;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --danger-light: #fca5a5;
    --danger-pressed: #991b1b;
    --info: #2563eb;
    --info-soft: #eff6ff;

    /* 间距 (4px 基数) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;

    /* 控件 */
    --control-height: 36px;
    --control-height-sm: 32px;
    --touch-min: 44px;
    --content-max-width: 1440px;

    /* 字号 */
    --fs-xs: 0.75rem;    /* 12px */
    --fs-sm: 0.8125rem;  /* 13px */
    --fs-base: 0.875rem; /* 14px */
    --fs-lg: 1rem;       /* 16px */
    --fs-xl: 1.125rem;   /* 18px */

    /* 行高 */
    --lh-tight: 1.35;
    --lh-base: 1.5;
    --lh-relaxed: 1.65;

    /* 动效 */
    --motion-fast: 100ms;
    --motion-base: 150ms;
    --motion-slow: 250ms;
    --easing: cubic-bezier(0.4, 0, 0.2, 1);

    /* 层级 */
    --z-base: 1;
    --z-sticky: 100;
    --z-overlay: 1000;
    --z-modal: 1050;
    --z-toast: 9000;

    /* 圆角 */
    --radius-xs: 5px;
    --radius-sm: 7px;
    --radius-md: 10px;
    --radius-lg: 14px;

    /* 阴影（冷调多层柔影，卡片浮起感更自然） */
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05), 0 2px 8px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 2px 4px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 4px 8px rgba(15, 23, 42, 0.05), 0 16px 48px rgba(15, 23, 42, 0.14);
    --shadow-brand: 0 4px 14px rgba(37, 99, 235, 0.32);

    /* 焦点环 */
    --shadow-focus: 0 0 0 3px rgba(37, 99, 235, 0.2);

    /* 客户等级色 */
    --grade-a: var(--danger);
    --grade-b: var(--warning);
    --grade-c: var(--accent);
    --grade-x: #6b7280;

    /* 响应式断点 (与 Bootstrap 5 对齐) */
    --bp-sm: 480px;
    --bp-md: 768px;
    --bp-lg: 992px;
    --bp-xl: 1200px;
}

/* ----- Reset ----- */
*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Microsoft YaHei", "Helvetica Neue", sans-serif;
    font-size: var(--fs-base);
    line-height: var(--lh-base);
    color: var(--text-main);
    background: var(--page-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 数字默认等宽对齐：金额/计数列上下行数字纵向对齐，商务报表质感 */
body { font-variant-numeric: tabular-nums; }

a {
    color: var(--accent);
    text-decoration: none;
    text-underline-offset: 2px;
    transition: color var(--motion-fast) var(--easing);
}
a:hover { color: var(--accent-dark); }

/* ----- 滚动条 ----- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ----- 文本选中色 ----- */
::selection { background: var(--accent-soft); color: var(--accent-pressed); }
::-moz-selection { background: var(--accent-soft); color: var(--accent-pressed); }

/* ----- 焦点可见性 (无障碍) ----- */
:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

/* ----- 减少动效偏好 ----- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ----- CRM 工作区 design tokens（原 crm-tokens.css，合并减少请求数）----- */
:root {
    --crm-row-height: 44px;
    --crm-chip-height: 28px;
    --crm-toolbar-gap: 10px;
    --crm-shell-gap: 12px;
    --crm-flash-success-bg: var(--success-soft);
    --crm-flash-warning-bg: var(--warning-soft);
    --crm-inline-hint-bg: rgba(37, 99, 235, 0.06);
}

/* === merged from commercial-enhancements.css === */
/* ==========================================================================
   商业级设计系统增强 - Design System Enhancement
   --------------------------------------------------------------------------
   目标：将系统提升到商业级SaaS产品水准

   改进重点：
   1. 更专业的配色方案
   2. 更细腻的阴影系统
   3. 更流畅的动效
   4. 更友好的交互反馈
   5. 更统一的视觉语言
   ========================================================================== */

:root {
    /* ===== 增强的阴影系统 ===== */
    /* 商业级产品需要细腻的层次感 */
    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.05);

    /* 品牌色阴影 - 用于强调元素 */
    --shadow-accent: 0 4px 14px 0 rgba(37, 99, 235, 0.15);
    --shadow-accent-lg: 0 10px 30px -5px rgba(37, 99, 235, 0.25);

    /* ===== 增强的动效系统 ===== */
    --motion-instant: 50ms;
    --motion-fast: 120ms;
    --motion-base: 180ms;
    --motion-slow: 280ms;
    --motion-slower: 400ms;

    /* 专业的缓动函数 */
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-in-out-circ: cubic-bezier(0.85, 0, 0.15, 1);
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);

    /* ===== 增强的色彩系统 ===== */
    /* 更丰富的品牌色阶梯 */
    --accent-50: #eff6ff;
    --accent-100: #dbeafe;
    --accent-200: #bfdbfe;
    --accent-300: #93c5fd;
    --accent-400: #60a5fa;
    --accent-500: #3b82f6;
    --accent-600: #2563eb; /* 主品牌色 */
    --accent-700: #1d4ed8;
    --accent-800: #1e40af;
    --accent-900: #1e3a8a;

    /* 成功色阶梯 */
    --success-50: #ecfdf5;
    --success-500: #10b981;
    --success-600: #059669;
    --success-700: #047857;

    /* 警告色阶梯 */
    --warning-50: #fffbeb;
    --warning-500: #f59e0b;
    --warning-600: #d97706;
    --warning-700: #b45309;

    /* 危险色阶梯 */
    --danger-50: #fef2f2;
    --danger-500: #ef4444;
    --danger-600: #dc2626;
    --danger-700: #b91c1c;

    /* ===== 增强的间距系统 ===== */
    --space-0: 0;
    --space-px: 1px;
    --space-0-5: 2px;
    --space-7: 28px;
    --space-8: 40px;
    --space-9: 48px;
    --space-10: 56px;
    --space-12: 64px;
    --space-16: 80px;

    /* ===== 圆角系统补充 ===== */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 20px;
    --radius-3xl: 24px;
    --radius-full: 9999px;

    /* ===== 模糊效果 ===== */
    --blur-sm: blur(4px);
    --blur-md: blur(8px);
    --blur-lg: blur(16px);
    --blur-xl: blur(24px);

    /* ===== 新增：玻璃态效果 ===== */
    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(255, 255, 255, 0.18);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
}

/* ==========================================================================
   商业级组件增强
   ========================================================================== */

/* ===== Loading 状态 ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: var(--blur-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-overlay);
    animation: fadeIn var(--motion-base) var(--ease-smooth);
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--accent-100);
    border-top-color: var(--accent);
    border-radius: var(--radius-full);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* 骨架屏 - 商业级加载体验 */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--surface-muted) 0%,
        var(--surface-soft) 50%,
        var(--surface-muted) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-md);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
    border-radius: var(--radius-sm);
}

.skeleton-text:last-child {
    width: 70%;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
}

.skeleton-button {
    height: 36px;
    width: 100px;
    border-radius: var(--radius-md);
}

/* ===== 空状态组件 ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-10) var(--space-6);
    text-align: center;
    min-height: 320px;
}

.empty-state-icon {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-5);
    border-radius: var(--radius-2xl);
    background: var(--accent-50);
    color: var(--accent);
    font-size: 2rem;
    box-shadow: var(--shadow-sm);
}

.empty-state-title {
    font-size: var(--fs-xl);
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: var(--space-2);
}

.empty-state-description {
    font-size: var(--fs-base);
    color: var(--text-muted);
    max-width: 480px;
    line-height: var(--lh-relaxed);
    margin-bottom: var(--space-5);
}

.empty-state-actions {
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
    justify-content: center;
}

/* ===== 改进的卡片样式 ===== */
.card-elevated {
    box-shadow: var(--shadow-md);
    transition: box-shadow var(--motion-base) var(--ease-smooth);
}

.card-elevated:hover {
    box-shadow: var(--shadow-lg);
}

.card-interactive {
    cursor: pointer;
    transition: all var(--motion-base) var(--ease-smooth);
}

.card-interactive:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.card-interactive:active {
    transform: translateY(0);
}

/* ===== 改进的按钮样式 ===== */
.btn {
    position: relative;
    overflow: hidden;
    transition: all var(--motion-base) var(--ease-smooth);
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        45deg,
        transparent,
        rgba(255, 255, 255, 0.15),
        transparent
    );
    transform: translateX(-100%);
    transition: transform var(--motion-slow) var(--ease-smooth);
}

.btn:hover::before {
    transform: translateX(100%);
}

.btn-primary {
    box-shadow: var(--shadow-accent);
}

.btn-primary:hover {
    box-shadow: var(--shadow-accent-lg);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

/* ===== 改进的表单元素 ===== */
.form-control,
.form-select {
    transition: all var(--motion-base) var(--ease-smooth);
}

.form-control:focus,
.form-select:focus {
    box-shadow: 0 0 0 3px var(--accent-100),
                var(--shadow-sm);
}

/* ===== Toast 通知 ===== */
.toast-container {
    position: fixed;
    top: var(--space-6);
    right: var(--space-6);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    max-width: 420px;
}

.toast {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    box-shadow: var(--shadow-xl);
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    animation: slideInRight var(--motion-base) var(--ease-out-expo);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast-success .toast-icon { color: var(--success); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-error .toast-icon { color: var(--danger); }
.toast-info .toast-icon { color: var(--accent); }

.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-weight: 600;
    font-size: var(--fs-sm);
    color: var(--text-main);
    margin-bottom: 2px;
}

.toast-message {
    font-size: var(--fs-xs);
    color: var(--text-secondary);
    line-height: var(--lh-base);
}

.toast-close {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--motion-fast) var(--ease-smooth);
}

.toast-close:hover {
    background: var(--surface-muted);
    color: var(--text-main);
}

/* ===== 徽标增强 ===== */
.badge-modern {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: var(--fs-xs);
    font-weight: 500;
    line-height: 1;
}

.badge-modern.badge-success {
    background: var(--success-50);
    color: var(--success-700);
}

.badge-modern.badge-warning {
    background: var(--warning-50);
    color: var(--warning-700);
}

.badge-modern.badge-danger {
    background: var(--danger-50);
    color: var(--danger-700);
}

.badge-modern.badge-info {
    background: var(--accent-50);
    color: var(--accent-700);
}

/* ===== 数据表格增强 ===== */
.table-modern {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table-modern thead th {
    background: var(--surface-soft);
    color: var(--text-secondary);
    font-size: var(--fs-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: var(--space-3) var(--space-4);
    border-bottom: 2px solid var(--surface-border);
}

.table-modern tbody tr {
    transition: background var(--motion-fast) var(--ease-smooth);
}

.table-modern tbody tr:hover {
    background: var(--surface-soft);
}

.table-modern tbody td {
    padding: var(--space-4);
    border-bottom: 1px solid var(--surface-border);
    color: var(--text-main);
    font-size: var(--fs-base);
}

/* ===== 进度条增强 ===== */
.progress-modern {
    height: 8px;
    background: var(--surface-muted);
    border-radius: var(--radius-full);
    overflow: hidden;
    box-shadow: var(--shadow-inner);
}

.progress-bar-modern {
    height: 100%;
    background: var(--brand-gradient);
    border-radius: var(--radius-full);
    transition: width var(--motion-slow) var(--ease-out-expo);
    box-shadow: 0 0 8px rgba(37, 99, 235, 0.4);
}

/* ===== 响应式改进 ===== */
@media (max-width: 768px) {
    .toast-container {
        left: var(--space-4);
        right: var(--space-4);
        max-width: none;
    }

    .empty-state {
        padding: var(--space-8) var(--space-4);
        min-height: 240px;
    }

    .empty-state-icon {
        width: 64px;
        height: 64px;
        font-size: 1.5rem;
    }
}

/* ===== 微交互增强 ===== */
.hover-lift {
    transition: transform var(--motion-base) var(--ease-smooth);
}

.hover-lift:hover {
    transform: translateY(-2px);
}

.hover-glow {
    transition: box-shadow var(--motion-base) var(--ease-smooth);
}

.hover-glow:hover {
    box-shadow: var(--shadow-accent-lg);
}

/* ===== 焦点状态增强 ===== */
*:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

button:focus-visible,
.btn:focus-visible {
    outline-offset: 3px;
}

