:root {
    /* 现代调色板 - Referenced from 22.html */
    --primary: #E8534F;        /* 淡红色主色 */
    --primary-hover: #D13E3A;
    --secondary: #64748B;      /* 高级灰文本 */
    --bg-page: #F8FAFC;        /* 极淡的灰蓝背景，护眼 */
    --bg-surface: #FFFFFF;     /* 纯白表面 */
    --border-color: #E2E8F0;   /* 极细边框 */
    --text-main: #0F172A;      /* 近乎黑的深蓝 */
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    
    /* 阴影体系 */
    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
    
    --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif; }

body { background-color: var(--bg-page); color: var(--text-main); height: 100vh; overflow: hidden; }

/* 通用原子类 */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.w-full { width: 100%; }
.text-sm { font-size: 14px; }
.text-xs { font-size: 12px; }
.font-bold { font-weight: 600; }
.text-gray { color: var(--secondary); }
.text-primary { color: var(--primary); }
.cursor-pointer { cursor: pointer; }
.hidden { display: none !important; }

/* 标题 */
/* Fix 6: Hide duplicate titles on pages */
#right > h3 { display: none !important; }

/* 按钮与输入框 */
.btn, .default-btn, .tint-btn {
    padding: 10px 20px; border-radius: 8px; border: 1px solid transparent; 
    font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.2s;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    text-decoration: none;
}
.btn-primary, .default-btn { background: var(--primary); color: white; box-shadow: var(--shadow-xs); border: none; }
.btn-primary:hover, .default-btn:hover { background: var(--primary-hover); transform: translateY(-1px); color: white; }
.btn-white, .tint-btn { background: white; border-color: var(--border-color); color: var(--text-main); }
.btn-white:hover, .tint-btn:hover { border-color: var(--primary); color: var(--primary); }

/* 输入框 */
/* Fix 7: Adjust input height and padding to prevent text cutoff */
input.form-control, select.form-control, textarea.form-control {
    width: 100%; padding: 8px 12px; border: 1px solid var(--border-color);
    border-radius: 8px; background: white; outline: none; transition: 0.2s;
    font-size: 14px; color: var(--text-main);
    box-shadow: none;
    height: 40px; /* Ensure sufficient height */
    line-height: 1.5;
}
textarea.form-control { height: auto; } /* Let textarea grow */

input.form-control:focus, select.form-control:focus, textarea.form-control:focus { 
    border-color: var(--primary); 
    box-shadow: 0 0 0 3px rgba(232, 83, 79, 0.15); 
}

/* ================= 登录页 (极简居中风格) ================= */
.login-container {
    width: 100%; height: 100%; display: flex; background: white;
}
.login-sidebar {
    width: 40%; background: #F1F5F9; display: flex; align-items: center; justify-content: center;
    position: relative; overflow: hidden;
}
/* 装饰圆 */
.deco-circle {
    position: absolute; border-radius: 50%; background: linear-gradient(135deg, #bfdbfe 0%, #eff6ff 100%);
    width: 400px; height: 400px; top: -100px; right: -100px; opacity: 0.5;
}
.login-main {
    flex: 1; display: flex; align-items: center; justify-content: center; flex-direction: column;
}
.login-form-box { width: 380px; }
.login-title { font-size: 24px; font-weight: bold; margin-bottom: 8px; }
.login-subtitle { color: var(--secondary); margin-bottom: 32px; font-size: 14px; }

/* ================= 主布局 (High Specificity Overrides for #app) ================= */

/* App Container - Force Flex Layout */
#app { 
    width: 100%; 
    height: 100vh; 
    display: flex !important; 
    flex-direction: row !important;
    overflow: hidden !important; 
    background-color: var(--bg-page) !important;
}

/* Sidebar - Override ylb.css fixed positioning */
#app .left, #app .sidebar {
    width: 240px !important; 
    min-width: 240px !important;
    height: 100% !important;
    background: var(--bg-surface) !important; 
    border-right: 1px solid var(--border-color) !important;
    display: flex !important; 
    flex-direction: column !important; 
    padding: 0 !important; 
    z-index: 100;
    position: relative !important; /* Kill fixed position */
    left: auto !important;
    bottom: auto !important;
    box-shadow: none !important;
}

/* Fix 1: Logo Section */
#app .left .brand {
    height: 64px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-color);
}

/* Use background image for logo to ensure it displays as requested */
#app .left .brand .brand-icon {
    width: 100%;
    height: 40px;
    background-image: url('../img/index_logo.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: left center;
}
/* Hide text if using image logo */
#app .left .brand span { display: none; }
#app .left .brand i { display: none; }


/* Fix 2: Sidebar Scroll Area */
#app .left .sidebar-scroll {
    flex: 1 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    width: 100% !important;
}

/* Custom Scrollbar for Sidebar */
#app .left .sidebar-scroll::-webkit-scrollbar {
    width: 6px;
    background: transparent;
}
#app .left .sidebar-scroll::-webkit-scrollbar-track {
    background: transparent;
}
#app .left .sidebar-scroll::-webkit-scrollbar-thumb {
    background-color: transparent;
    border-radius: 4px;
    transition: background-color 0.3s;
}
#app .left .sidebar-scroll:hover::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
}

/* Sidebar Navigation Container */
#app .left .dhview {
    width: 100% !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column !important;
}

/* Sidebar List Items */
#app .left .dhview ul {
    width: 100% !important;
    padding: 0 12px !important;
    margin: 0 !important;
}

#app .left .dhview ul li {
    width: 100% !important;
    height: auto !important;
    line-height: 1.5 !important;
    margin-bottom: 4px !important;
    text-indent: 0 !important;
    background: transparent !important;
    border-radius: 8px !important;
}

#app .left .dhview a {
    text-decoration: none !important;
    display: block !important;
}

/* Menu Labels (Categories) - 卡片背景便于与下方导航区分 */
#app .left .dhview .menu-label,
.menu-label {
    padding: 10px 14px !important;
    margin-top: 14px !important;
    margin-bottom: 8px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #475569 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    background: #F1F5F9 !important;
    border-radius: 8px !important;
    border: 1px solid var(--border-color, #E2E8F0) !important;
}

/* Nav Item Styling */
/* Fix 3: Align nav items */
#app .left .dhview ul a li.nav-li, .nav-item {
    padding: 10px 24px !important; 
    cursor: pointer; 
    color: var(--secondary) !important; 
    font-size: 14px !important; 
    font-weight: 500 !important;
    display: flex !important; 
    align-items: center !important; 
    justify-content: flex-start !important; 
    gap: 12px !important; 
    border-radius: 8px !important;
    transition: all 0.2s !important;
}

/* Hover & Active States */
#app .left .dhview ul a:hover li.nav-li, 
#app .left .dhview ul a.selected li.nav-li, 
.nav-item:hover, 
.nav-item.active {
    background: #FEF2F2 !important; 
    color: var(--primary) !important; 
}

/* Icons */
#app .left .dhview ul a li.nav-li .icon, .nav-item i { 
    margin: 0 !important; 
    width: 18px !important; 
    height: 18px !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    font-size: 16px !important;
}

/* User Account Section - Fixed at bottom of sidebar */
/* Fix 2: Ensure account stays at bottom */
#app .left .account {
    position: relative !important; /* Kill absolute */
    bottom: auto !important;
    left: auto !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 16px 20px !important;
    background: var(--bg-surface) !important;
    border-top: 1px solid var(--border-color) !important;
    border-radius: 0 !important;
    display: block !important;
    flex-shrink: 0 !important;
}

/* Account Inner Layout */
#app .left .account .user-wrapper {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    width: 100% !important;
}

#app .left .account .user-avatar {
    width: 36px !important;
    height: 36px !important;
    border-radius: 50% !important;
    background: #f1f5f9 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: var(--secondary);
    font-size: 20px;
}

#app .left .account .user-info {
    flex: 1 !important;
    overflow: hidden !important;
    text-align: left !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
}

#app .left .account .user-name {
    font-size: 14px !important;
    font-weight: 600 !important;
    color: var(--text-main) !important;
    margin-bottom: 2px !important;
    padding: 0 !important;
}

#app .left .account .user-role {
    font-size: 12px !important;
    color: var(--secondary) !important;
}

#app .left .account .exit-btn {
    color: var(--secondary) !important;
    cursor: pointer !important;
    padding: 4px !important;
    font-size: 16px !important;
}
#app .left .account .exit-btn:hover {
    color: var(--danger) !important;
}

/* Hide legacy elements */
#app .left .account .version { display: none !important; }


/* Main Content Area (#right) */
#app #right {
    flex: 1 !important;
    margin-left: 0 !important;
    height: 100% !important;
    overflow-y: auto !important; /* Enable scrolling */
    background: var(--bg-page) !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 0 !important;
}

.main-content {
    flex: 1 !important;
    margin-left: 0 !important;
    height: 100% !important;
    overflow: hidden !important;
    background: var(--bg-page) !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 0 !important;
}

/* Topbar */
.topbar {
    height: 64px; 
    background: var(--bg-surface); 
    border-bottom: 1px solid var(--border-color);
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    padding: 0 32px;
    flex-shrink: 0;
}
.page-title { font-size: 18px; font-weight: 600; color: var(--text-main); }

/* Fix 4: Topbar Actions Layout */
.topbar-actions {
    display: flex !important;
    align-items: center !important;
    gap: 16px;
}

/* Fix 5: Scrollable Page Content & Hide Scrollbar */
.page-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}
.page-scroll::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

/* Legacy Content Adaptation */
#right > .data-card, #right > h3, #right > .data-list {
    margin-left: 0 !important;
    width: 100% !important;
}

/* Cards */
.data-card, .card {
    background: var(--bg-surface); border: 1px solid var(--border-color);
    border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow-xs); margin-bottom: 24px;
}

/* Dashboard Overrides for Legacy Structure */
#app #right .data-card .data-card-1 .card-left {
    background: white !important;
    box-shadow: var(--shadow-xs) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-main) !important;
    border-radius: var(--radius) !important;
}

/* Tables */
.table { margin-bottom: 0; width: 100%; border-collapse: collapse; }
.table thead th {
    border-top: none; border-bottom: 1px solid var(--border-color);
    color: var(--secondary); font-weight: 500; font-size: 13px;
    padding: 14px 20px; background: #F8FAFC; text-align: left;
}
.table tbody td {
    border-top: 1px solid var(--border-color);
    color: var(--text-main); font-size: 14px;
    padding: 16px 20px; vertical-align: middle;
}
.table tr:hover td { background: #F8FAFC; }

/* Modals */
.modal-content {
    border: none !important; border-radius: var(--radius) !important; box-shadow: var(--shadow-lg) !important;
}
.modal-header {
    border-bottom: 1px solid var(--border-color) !important; padding: 20px 24px !important;
}
.modal-footer {
    border-top: 1px solid var(--border-color) !important; padding: 16px 24px !important;
}

/* Plugin Grid */
#app #right .data-list .plugin-list {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)) !important;
    gap: 24px !important;
    padding: 0 !important;
}

#app #right .data-list .plugin_card {
    width: 100% !important;
    height: auto !important;
    background: var(--bg-surface) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius) !important;
    padding: 24px !important;
    box-shadow: var(--shadow-xs) !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
}
#app #right .data-list .plugin_card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md) !important;
    border-color: var(--primary) !important;
}

/* Plugin Content */
#app #right .data-list .plugin_card .plugin_logo { margin: 0 0 16px 0 !important; }
#app #right .data-list .plugin_card .plugin_name { width: 100% !important; margin: 0 0 8px 0 !important; font-weight: 600 !important; }
#app #right .data-list .plugin_card .plugin_desc { width: 100% !important; margin: 0 0 20px 0 !important; line-height: 1.5 !important; }
#app #right .data-list .plugin_card .plugin_btn { width: 100% !important; margin: 0 !important; gap: 10px !important; }

/* User Account Fixes */
.user-card {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: var(--shadow-xs) !important;
}
.user-card-header {
    background: var(--bg-page) !important;
    color: var(--text-main) !important;
    border-bottom: 1px solid var(--border-color) !important;
}
