/* ROI CRM Design System - Professional B2B SaaS Style */

:root {
    /* Color System - Warm CRM (活力销售主题) */
    --primary: #f97316;
    --primary-dark: #ea580c;
    --primary-light: #fb923c;
    --primary-bg: #fff7ed;
    
    --success: #10b981;
    --success-bg: #d1fae5;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --info: #3b82f6;
    --info-bg: #eff6ff;
    --blue: #3b82f6;
    --blue-bg: #eff6ff;
    --purple: #7c3aed;
    --purple-bg: #f0e6ff;
    --info: #f97316;
    --info-bg: #fff7ed;
    
    /* Neutral Colors */
    --gray-50: #f8f6f4;
    --gray-100: #f0eeeb;
    --gray-200: #e5e2dc;
    --gray-300: #d4d0c9;
    --gray-400: #a8a29e;
    --gray-500: #78716c;
    --gray-600: #57534e;
    --gray-700: #44403c;
    --gray-800: #292524;
    --gray-900: #1c1917;
    
    /* Background */
    --bg-primary: #f8f6f4;
    --bg-secondary: #ffffff;
    --bg-sidebar: #1a365d;
    --bg-sidebar-hover: rgba(255,255,255,0.06);
    --bg-sidebar-active: rgba(255,255,255,0.1);
    
    /* Text */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-white: #ffffff;
    
    /* Border */
    --border: #e5e2dc;
    --border-light: #eef2f6;
    
    /* Shadow */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.1);
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius: 6px;
    --radius-md: 8px;
    --radius-lg: 10px;
    --radius-xl: 12px;
    --radius-full: 9999px;
    
    /* Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
    
    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'SF Mono', Monaco, Consolas, monospace;
    
    --text-xs: 12px;
    --text-sm: 14px;
    --text-base: 16px;
    --text-lg: 18px;
    --text-xl: 22px;
    --text-2xl: 28px;
    --text-3xl: 32px;
    
    --leading-tight: 1.25;
    --leading-normal: 1.55;
    --leading-relaxed: 1.625;
    
    /* Z-index */
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-modal: 1000;
    --z-toast: 1100;
    
    /* Transition */
    --transition-fast: 100ms ease;
    --transition-base: 140ms ease;
    --transition-slow: 300ms ease;

    /* Legacy compatibility aliases */
    --border-color: var(--border);
    --accent: var(--primary);
    --bg-tertiary: var(--gray-50);
    --text-tertiary: var(--text-muted);
    --error: var(--danger);
    --error-light: var(--danger-bg);
    --success-light: var(--success-bg);
    --font-mono: 'SF Mono', Monaco, Consolas, monospace;
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    overflow: hidden;
}

body {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: var(--leading-normal);
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Layout */
.layout {
    display: flex;
    min-height: 100vh;
}

.main-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
    overflow: hidden;
    margin-left: 240px;
    transition: margin-left 0.2s ease;
}

.sidebar.collapsed ~ .main-wrap {
    margin-left: 64px;
}

/* Sidebar */
.sidebar {
    width: 240px;
    background: #1a365d;
    color: rgba(255,255,255,0.65);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: var(--z-sticky);
    transition: width 0.2s ease;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255,255,255,0.06);
}

/* Thin sidebar scrollbar */
.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.18); }

.sidebar.collapsed {
    width: 64px;
}

.sidebar.collapsed .sidebar-brand,
.sidebar.collapsed .menu-label,
.sidebar.collapsed .menu-item span,
.sidebar.collapsed .menu-arrow,
.sidebar.collapsed .sidebar-user .user-text,
.sidebar.collapsed .sidebar-user button {
    display: none;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 0;
}

.sidebar.collapsed .sidebar-logo {
    margin: 0;
}

.sidebar.collapsed .menu-item {
    justify-content: center;
    padding: 12px 0;
    margin: 0;
    border-radius: 0;
}

.sidebar.collapsed .sidebar-user {
    justify-content: center;
    padding: 8px 0;
}

.sidebar.collapsed .sidebar-user > div {
    justify-content: center;
}

.sidebar-user {
    padding: 10px 16px;
    flex-shrink: 0;
    border-top: 1px solid rgba(255,255,255,0.08);
    background: rgba(0,0,0,0.15);
}

.sidebar-bell {
    margin-left: auto;
    cursor: pointer;
    opacity: 0.7;
    font-size: 16px;
    padding: 4px;
    line-height: 1;
    transition: opacity 0.15s;
}
.sidebar-bell:hover { opacity: 1; }

.sidebar-toggle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    z-index: 5;
    transition: color 0.15s;
}

.sidebar.collapsed .sidebar-toggle {
    right: auto;
    left: 50%;
    transform: translateX(-50%);
}

.sidebar-toggle:hover {
    color: #fff;
}

.sidebar-header {
    height: 56px;
    padding: 0 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
}

.sidebar-logo {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--text-sm);
}

.sidebar-brand {
    font-size: var(--text-lg);
    font-weight: 600;
    letter-spacing: -0.025em;
}

.sidebar-menu {
    flex: 1;
}

.menu-section {
    padding: 4px 0;
}

.menu-label {
    padding: 8px 24px 4px;
    font-size: 12px;
    font-weight: 600;
    color: #adb5bd;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 36px;
    padding: 0 16px;
    margin: 0 8px 2px;
    border-radius: var(--radius);
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
    transition: all .15s;
}

.menu-item:hover {
    background: rgba(255,255,255,0.06);
    color: #fff;
}

.menu-item.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-weight: 600;
    position: relative;
}

.menu-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}

.menu-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.7;
}
.menu-item:hover svg,
.menu-item.active svg { opacity: 1; }

.menu-item .badge {
    margin-left: auto;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--primary);
    color: #fff;
    font-size: 12px;
    line-height: 18px;
    text-align: center;
    font-weight: 600;
}

/* Submenu */
.has-submenu > .submenu {
    display: none;
    padding-left: 16px;
}

.has-submenu.open > .submenu {
    display: block;
}

/* 父级菜单样式 */
.menu-parent {
    font-weight: 600;
    color: #fff;
}.menu-parent:hover {
    background: var(--bg-sidebar-hover);
}

.menu-arrow {
    margin-left: auto;
    transition: transform var(--transition-fast);
    opacity: 0.6;
}

.has-submenu.open .menu-arrow {
    transform: rotate(90deg);
}

/* 子菜单项样式 */
.submenu-item {
    font-size: 14px;
    padding: 0 16px;
    height: 36px;
    margin: 0;
    color: rgba(255,255,255,0.55);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
}

.submenu-item:hover {
    color: #fff;
    background: rgba(255,255,255,0.08);
}

.submenu-item.active {
    background: rgba(251,176,64,0.15);
    color: #fbb040;
    font-weight: 600;
    position: relative;
}

.submenu-item.active::before {
    content: '';
    position: absolute;
    left: -16px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 18px;
    background: #fbb040;
    border-radius: 0 3px 3px 0;
}

/* Main Content */
.main {
    flex: 1;
    padding: var(--space-5);
    overflow-y: auto;
    min-height: 0;
}

.main::-webkit-scrollbar { width: 5px; }
.main::-webkit-scrollbar-track { background: transparent; }
.main::-webkit-scrollbar-thumb { background: rgba(0,0,0,.08); border-radius: 3px; }
.main::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.15); }

.main.main-scroll {
    overflow-y: auto;
}

/* Header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.page-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Cards */
.card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: none;
    box-shadow: var(--shadow);
    transition: box-shadow .2s;
}

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

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    padding: 24px;
}

.card-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-light);
    background: var(--gray-100);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-3);
}

.stat-icon.blue { background: var(--info-bg); color: var(--info); }
.stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-icon.yellow { background: var(--warning-bg); color: var(--warning); }
.stat-icon.red { background: var(--danger-bg); color: var(--danger); }

.stat-icon svg {
    width: 20px;
    height: 20px;
}

.stat-value {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.stat-label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-top: var(--space-1);
}

.stat-change {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    margin-top: var(--space-2);
    font-size: var(--text-xs);
    font-weight: 500;
}

.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 36px;
    padding: 5px 18px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
    font-family: inherit;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn svg {
    width: 16px;
    height: 16px;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

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

.btn-secondary:hover:not(:disabled) {
    color: var(--primary);
    border-color: var(--primary-dark);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #73d13d;
    border-color: #73d13d;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #ff7875;
    border-color: #ff7875;
}

.btn-ghost {
    background: transparent;
    color: var(--text-primary);
    border-color: transparent;
    padding: 2px 6px;
    height: auto;
    font-size: 14px;
    font-weight: 400;
}

.btn-ghost:hover:not(:disabled) {
    background: rgba(0,0,0,.04);
    color: var(--primary);
}

.btn-sm {
    height: 30px;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 600;
}

.btn-lg {
    height: 46px;
    padding: 12px 32px;
    font-size: 16px;
}

.btn-icon {
    padding: 0;
    width: 32px;
    height: 32px;
}

.btn-icon.btn-sm {
    width: 24px;
    height: 24px;
}

/* Tables */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: var(--gray-100);
    border-bottom: 2px solid var(--border);
}

th {
    padding: 12px 16px;
    text-align: left;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: .3px;
    white-space: nowrap;
}

td {
    padding: 12px 16px;
    font-size: 14px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
}

tbody tr:hover td {
    background: var(--gray-50);
}

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

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: var(--text-xs);
    font-weight: 500;
    border-radius: var(--radius-full);
    line-height: 1.5;
}

.badge-blue { background: var(--info-bg); color: var(--info); }
.badge-green { background: var(--success-bg); color: var(--success); }
.badge-yellow { background: var(--warning-bg); color: var(--warning); }
.badge-red { background: var(--danger-bg); color: var(--danger); }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* Batch action bar */
.batch-bar {
  position: sticky;
  bottom: 0;
  background: var(--bg-secondary);
  border-top: 2px solid var(--primary);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  z-index: var(--z-sticky);
}

/* Forms */
.form-group {
    margin-bottom: var(--space-5);
}

.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.form-label .required {
    color: var(--danger);
    margin-left: 2px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 12px;
    font-size: var(--text-sm);
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(249,115,22,0.2);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
}

.form-input:disabled {
    background: var(--gray-100);
    cursor: not-allowed;
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

.form-hint {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    margin-top: var(--space-1);
}

.form-error {
    font-size: var(--text-xs);
    color: var(--danger);
    margin-top: var(--space-1);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: 0 6px 16px 0 rgba(0,0,0,.08), 0 3px 6px -4px rgba(0,0,0,.12), 0 9px 28px 8px rgba(0,0,0,.05);
    width: 100%;
    max-width: 520px;
    max-height: 80vh;
    overflow: hidden;
    transform: scale(0.95) translateY(10px);
    transition: transform var(--transition-base);
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    padding: 20px 24px 0;
    border-bottom: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all .15s;
}

.modal-close:hover {
    background: var(--gray-100);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    max-height: calc(80vh - 100px);
}

.modal-footer {
    padding: 0 24px 20px;
    border-top: none;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.modal-lg {
    max-width: 640px;
}

.modal-xl {
    max-width: 800px;
}

/* Global modal standardization */
.crm-modal-standard {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 16px !important;
    z-index: var(--z-modal) !important;
}

.crm-modal-standard.crm-modal-use-active:not(.active) {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.crm-modal-standard.crm-modal-use-active.active {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

.crm-modal-standard.crm-modal-legacy-toggle[style*="display: none"] {
    pointer-events: none !important;
}

.crm-modal-standard .crm-modal-dialog,
.crm-modal-standard > .modal,
.crm-modal-standard > .modal-content {
    margin: 0 auto !important;
    position: relative !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    transform: none !important;
    max-height: calc(100vh - 32px) !important;
    overflow: auto !important;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: var(--space-5);
}

.tab {
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 400;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all .15s;
    margin-bottom: -2px;
    white-space: nowrap;
}

.tab:hover {
    color: var(--primary);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-5);
    flex-wrap: wrap;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

/* Search */
.search-input {
    position: relative;
}

.search-input input {
    padding-left: 36px;
}

.search-input input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(249,115,22,0.1);
}

.search-input svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

/* Filter */
.filter-group {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px 4px;
}

.pagination-info {
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.pagination-buttons {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.page-btn {
    min-width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 400;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all .15s;
}

.page-btn:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
}

.page-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: var(--space-12) var(--space-6);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    color: var(--gray-300);
    margin-bottom: var(--space-4);
}

.empty-state-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.empty-state-desc {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-5);
}

/* 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);
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 10px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
    border: 1px solid var(--border);
    min-width: 200px;
    animation: slideIn .3s ease;
}

.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-warning { border-left: 4px solid var(--warning); }
.toast-info { border-left: 4px solid var(--info); }

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Loading */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-12);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .6s linear infinite;
}

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

/* Skeleton */
.skeleton {
    background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Dropdown */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: var(--space-1);
    min-width: 160px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-dropdown);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition-fast);
}

.dropdown.open .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.dropdown-item:hover {
    background: var(--gray-50);
}

.dropdown-item svg {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: var(--space-1) 0;
}

/* Progress */
.progress {
    height: 10px;
    background: var(--gray-200);
    border-radius: 100px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.danger { background: var(--danger); }

/* Tooltip */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    padding: var(--space-1) var(--space-2);
    font-size: var(--text-xs);
    color: white;
    background: var(--gray-800);
    border-radius: var(--radius-sm);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-fast);
    z-index: var(--z-dropdown);
}

[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-8px);
}

/* Avatar */
.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 400;
}

.avatar-sm { width: 24px; height: 24px; font-size: 12px; }
.avatar-lg { width: 40px; height: 40px; font-size: 16px; }

/* Status Dot */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.online { background: var(--success); }
.status-dot.offline { background: var(--gray-400); }
.status-dot.busy { background: var(--danger); }

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        width: 64px;
    }
    
    .sidebar-brand,
    .menu-label,
    .menu-item span,
    .has-submenu > .menu-item::after {
        display: none;
    }
    
    .sidebar-header {
        justify-content: center;
        padding: var(--space-4);
    }
    
    .menu-item {
        justify-content: center;
        padding: var(--space-3);
    }
    
    .main-wrap {
        margin-left: 64px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 240px;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar-brand,
    .menu-label,
    .menu-item span,
    .has-submenu > .menu-item::after {
        display: block;
    }
    
    .sidebar-header {
        justify-content: flex-start;
        padding: var(--space-5) var(--space-6);
    }
    
    .menu-item {
        justify-content: flex-start;
        padding: var(--space-2) var(--space-3);
    }
    
    .main-wrap {
        margin-left: 0;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .toolbar-left,
    .toolbar-right {
        width: 100%;
    }
}

/* Utility Classes */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.text-muted { color: var(--text-secondary); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.w-full { width: 100%; }
.hidden { display: none; }

/* === Taste-Skill Parameters === */
[data-density="compact"] .card,
[data-density="compact"] .section,
[data-density="compact"] .panel,
[data-density="compact"] .card-body {
  padding: var(--space-3) !important;
  margin-bottom: var(--space-2) !important;
}
[data-density="compact"] .sidebar { width: 200px; }
[data-density="compact"] .sidebar-menu { padding: var(--space-2) 0; }

[data-density="comfortable"] .card,
[data-density="comfortable"] .section,
[data-density="comfortable"] .panel,
[data-density="comfortable"] .card-body {
  padding: var(--space-6) !important;
  margin-bottom: var(--space-4) !important;
}
[data-density="comfortable"] .sidebar { width: 260px; }

[data-motion="low"] * {
  transition-duration: 0.05s !important;
  animation-duration: 0.05s !important;
}
[data-motion="high"] * {
  transition-duration: 0.3s !important;
}
[data-motion="high"] .card:hover,
[data-motion="high"] .panel:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md) !important;
}

/* ====== Layout: TopBar, ContextPanel, Scroll, Skeleton ====== */

.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: 40px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-light);
  background: #f8f9fa;
  flex-shrink: 0;
}
.topbar-search { position: relative; }
.topbar-search input {
  width: 200px; height: 30px; padding: 2px 12px 2px 30px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius); font-size: 12px;
  background: var(--bg-secondary);
  color: var(--text-primary);
}
.topbar-search input::placeholder { color: var(--text-muted); font-size: 12px; }
.topbar-search svg {
  position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  width: 13px; height: 13px; color: var(--text-muted);
}

/* Tab bar row - between topbar and main */
.tab-bar-row {
  display: flex;
  align-items: center;
  height: 36px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: #f5f5f5;
  flex-shrink: 0;
}

/* Topbar multi-page tabs */
.topbar-tabs {
  display: flex;
  align-items: center;
  gap: 0;
  flex: 1;
  height: 100%;
  min-width: 0;
}
.topbar-tabs {
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: hidden;
  overflow-y: hidden;
  flex: 1;
  height: 100%;
  min-width: 0;
}
.topbar-tabs-inner {
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  padding: 0 4px;
  flex: 1;
  height: 100%;
  min-width: 0;
}
.topbar-tabs-inner::-webkit-scrollbar { display: none; }
.topbar-tabs-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  font-size: 10px;
  padding: 0;
  line-height: 1;
  border-radius: 4px;
  transition: all .15s;
}
.topbar-tabs-arrow:hover {
  color: var(--text-primary);
  background: rgba(0,0,0,.04);
}
.topbar-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
  flex-shrink: 0;
  border: none;
  background: transparent;
  font-family: inherit;
  position: relative;
}
.topbar-tab:hover {
  color: var(--text-primary);
  background: rgba(0,0,0,.04);
}
.topbar-tab.active {
  color: var(--primary);
  background: rgba(0,0,0,.08);
  font-weight: 600;
}
.topbar-tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 4px;
  right: 4px;
  height: 2px;
  background: var(--primary);
  border-radius: 1px 1px 0 0;
}
.topbar-tab .tab-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  font-size: 12px;
  line-height: 1;
  color: var(--text-muted);
  margin-left: 2px;
  flex-shrink: 0;
}
.topbar-tab .tab-close:hover {
  background: rgba(0,0,0,.08);
  color: var(--text-primary);
}

.context-panel {
  width: 0; overflow: hidden;
  background: var(--bg-primary);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: width 0.25s ease; flex-shrink: 0;
}
.context-panel.open { width: 480px; }
.context-panel .panel-header {
  display: flex; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  gap: 6px; flex-shrink: 0;
}
.context-panel .panel-tabs { display: flex; gap: 0; overflow-x: auto; flex-shrink: 0; }
.context-panel .panel-tab {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 12px; cursor: pointer; font-size: 13px;
  border: 1px solid var(--border); border-bottom: none;
  border-radius: 6px 6px 0 0; background: var(--gray-50);
  white-space: nowrap; color: var(--text-secondary);
  margin-right: -1px;
}
.context-panel .panel-tab.active {
  background: var(--bg-primary); color: var(--primary);
  border-bottom: 2px solid var(--primary);
  font-weight: 600;
}
.context-panel .panel-tab .close {
  margin-left: 4px; font-size: 14px; color: var(--text-muted);
  cursor: pointer; line-height: 1;
}
.context-panel .panel-body { flex: 1; overflow-y: auto; padding: 14px; }
.context-panel.open + .panel-overlay {
  display: block; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.2); z-index: 5;
}

.table-vscroll {
    overflow-x: auto;
}
.table-vscroll::-webkit-scrollbar { height: 5px; }
.table-vscroll::-webkit-scrollbar-track { background: transparent; }
.table-vscroll::-webkit-scrollbar-thumb { background: rgba(0,0,0,.08); border-radius: 3px; }
.table-vscroll::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.15); }

.sk-item {
  background: linear-gradient(90deg,var(--gray-100) 25%,var(--gray-200) 50%,var(--gray-100) 75%);
  background-size: 200% 100%; animation: sk-shimmer 1.5s infinite; border-radius: 6px;
}
@keyframes sk-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.sk-row { display: flex; gap: 12px; padding: 10px 0; }
.sk-cell { height: 16px; }

@media (max-width: 1024px) {
  .context-panel.open {
    width: 100%; position: fixed; right: 0; top: 0; bottom: 0;
    z-index: 10; box-shadow: -4px 0 12px rgba(0,0,0,0.1);
  }
  .context-panel.open + .panel-overlay { z-index: 9; }
}

/* ====== PageTabs Bar ====== */

.page-tabs-bar {
  display: flex;
  align-items: center;
  height: 38px;
  min-height: 38px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  flex-shrink: 0;
  margin-left: 240px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.8);
}

.main.collapsed + .page-tabs-bar,
.main.collapsed ~ .page-tabs-bar,
.page-tabs-bar.collapsed {
  margin-left: 64px;
}

/* ====== PageTabs ====== */

.page-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  color: rgba(0,0,0,.55);
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  transition: all .15s;
  flex-shrink: 0;
  user-select: none;
  position: relative;
  margin-top: 4px;
}
.page-tab:hover {
  background: rgba(255,255,255,.7);
  color: rgba(255,255,255,0.8);
  border-color: var(--border);
}
.page-tab.active {
  color: #f97316;
  background: #fff;
  border-color: #e5e2dc;
  font-weight: 500;
  box-shadow: 0 -2px 0 0 #f97316;
  margin-top: 4px;
}
.page-tab .page-tab-close {
  font-size: 14px;
  color: rgba(0,0,0,.3);
  cursor: pointer;
  line-height: 1;
  border-radius: 3px;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .1s;
}
.page-tab .page-tab-close:hover {
  color: rgba(0,0,0,.6);
  background: rgba(0,0,0,.06);
}
.page-tabs-scroll::-webkit-scrollbar {
  height: 0;
}
.page-tabs-scroll::-webkit-scrollbar-track { background: transparent; }
.page-tabs-scroll::-webkit-scrollbar-thumb { background: rgba(0,0,0,.12); border-radius: 2px; }

/* ====== Stats Grid ====== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-5);
  margin-bottom: var(--space-6);
}

.stat-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.stat-icon {
  width: 40px; height: 40px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: var(--space-3);
}
.stat-icon svg { width: 20px; height: 20px; }
.stat-icon.blue { background: var(--info-bg); color: var(--info); }
.stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-icon.yellow { background: var(--warning-bg); color: var(--warning); }
.stat-icon.purple { background: #f0e6ff; color: #7c3aed; }

/* Ant Design card-style stat card (cd) */
.cd { background: var(--bg-secondary); border-radius: var(--radius-lg); padding: 24px; border: none; box-shadow: var(--shadow); transition: box-shadow .2s; }
.cd:hover { box-shadow: var(--shadow-md); }
.stat-label { font-size: var(--text-xs); color: var(--text-secondary); margin-bottom: var(--space-1); }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.stat-trend { font-size: var(--text-xs); margin-top: var(--space-1); }

/* ====== Ant Design Toggle Switch ====== */
.toggle {
  display: inline-flex;
  align-items: center;
  width: 44px;
  height: 22px;
  background: var(--gray-200);
  border-radius: 11px;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background .2s;
  vertical-align: middle;
}
.toggle.on { background: var(--primary); }
.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle.on::after { transform: translateX(22px); }

/* ====== Ant Design Tag ====== */
.tag-antd {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 7px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 400;
  gap: 4px;
  border: 1px solid transparent;
}
.tag-mantine-s { background: rgba(64,192,87,.1); color: #40c057; border-color: rgba(64,192,87,.3); }
.tag-mantine-w { background: rgba(250,176,5,.1); color: #fab005; border-color: rgba(250,176,5,.3); }
.tag-mantine-e { background: rgba(250,82,82,.1); color: #fa5252; border-color: rgba(250,82,82,.3); }
.tag-mantine-i { background: rgba(34,139,230,.1); color: #228be6; border-color: rgba(34,139,230,.3); }

/* ====== Button Click Feedback ====== */
.btn.is-clicking,
button.is-clicking,
[role="button"].is-clicking {
  transform: scale(0.97);
}

/* ====== Ant Design Progress ====== */
.progress-antd {
  height: 8px;
  background: var(--gray-200);
  border-radius: 100px;
  overflow: hidden;
  margin: 4px 0;
}
.progress-antd .fill { height: 100%; border-radius: 100px; transition: width .3s; }
.progress-antd .fill.p { background: var(--primary); }
.progress-antd .fill.s { background: var(--success); }
.progress-antd .fill.w { background: var(--warning); }
.progress-antd .fill.d { background: var(--danger); }

/* ====== Ant Design Status Dot ====== */
.status-dot-antd { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.status-dot-mantine.success { background: #40c057; }
.status-dot-mantine.warning { background: #fab005; }
.status-dot-mantine.error { background: #fa5252; }

/* ====== Ant Design Alert Banner ====== */
.alert-antd {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  border: 1px solid;
}
.alert-mantine-s { background: rgba(64,192,87,.1); color: #40c057; border-color: rgba(64,192,87,.3); }
.alert-mantine-w { background: rgba(250,176,5,.1); color: #fab005; border-color: rgba(250,176,5,.3); }
.alert-mantine-e { background: rgba(250,82,82,.1); color: #fa5252; border-color: rgba(250,82,82,.3); }
.alert-mantine-i { background: rgba(34,139,230,.1); color: #228be6; border-color: rgba(34,139,230,.3); }
