:root {
    --bg-color: #0f172a;
    --surface-color: rgba(30, 41, 59, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #8F35E6;
    --accent-hover: #BB76FF;
    --danger-color: #ef4444;
    --success-color: #10b981;
    --glass-blur: blur(12px);
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-family);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    background-image: radial-gradient(circle at 15% 50%, rgba(143, 53, 230, 0.15), transparent 25%), radial-gradient(circle at 85% 30%, rgba(6, 182, 212, 0.15), transparent 25%);
}

a {
    color: var(--accent-color);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--accent-hover);
}

#app {
    display: flex;
    width: 100%;
    height: 100vh;
}

.mobile-header {
    display: none;
}
.sidebar-overlay {
    display: none;
}
.btn-icon {
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--text-primary);
    border: none;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
    outline: none;
}
.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar {
    width: 260px;
    background: var(--surface-color);
    backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--border-color);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex-shrink: 0;
}

.sidebar-logo {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 32px;
    background: linear-gradient(90deg, #8F35E6, #06B6D4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-item {
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    font-weight: 500;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(143, 53, 230, 0.15);
    color: var(--accent-hover);
}

.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.03) 75%);
    background-size: 400% 100%;
    animation: shimmer 1.5s infinite linear;
    border-radius: 4px;
}
@keyframes shimmer {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}
.skeleton-title { height: 24px; width: 120px; margin-bottom: 16px; }
.skeleton-text { height: 24px; width: 60%; margin-bottom: 24px; }
.skeleton-btn { height: 36px; width: 100px; border-radius: 8px; }
.skeleton-tr { display: flex; gap: 16px; margin-bottom: 12px; padding: 12px 0; border-bottom: 1px solid var(--border-color); }
.skeleton-td { height: 20px; flex: 1; }

.glass-panel {
    background: var(--surface-color);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease;
}

.glass-panel:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 24px;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.stat-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-title {
    font-size: 14px;
    color: var(--text-secondary);
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
}

.table-container {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
}

th,
td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

th {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.sticky-col {
    position: sticky;
    right: 0;
    background: #1e293b;
    z-index: 1;
    /* 使用 inset 向内画阴影，防止被相邻的单元格盖住 */
    box-shadow: inset 1px 0 0 var(--border-color);
}

th.sticky-col {
    z-index: 2;
    background: #1e293b;
}

.btn {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    outline: none;
}

.btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.btn.active {
    box-shadow: 0 0 0 2px var(--bg-color), 0 0 0 4px white;
}

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

.btn-danger:hover {
    background: #dc2626;
}

input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: 8px;
    outline: none;
}

input:focus {
    border-color: var(--accent-color);
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 32px;
    width: 400px;
    max-width: 90%;
    transform: scale(0.95);
    transition: transform 0.3s;
}

.modal-backdrop.active .modal {
    transform: scale(1);
}

.modal-header {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 16px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

#login-page {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 0;
    left: 0;
    background: var(--bg-color);
    z-index: 200;
}

.login-box {
    width: 360px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.hidden {
    display: none !important;
}

.pagination {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    justify-content: flex-end;
    align-items: center;
}

.search-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.chart-row {
    display: flex;
    gap: 24px;
}
.chart-main {
    flex: 2;
    min-width: 0;
}
.chart-side {
    flex: 1;
    min-width: 0;
}
.attr-filters {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

/* Mobile Adaptation */
@media (max-width: 768px) {
    #app {
        flex-direction: column;
    }
    .mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px;
        background: var(--surface-color);
        border-bottom: 1px solid var(--border-color);
        backdrop-filter: var(--glass-blur);
        z-index: 50;
    }
    .desktop-logo {
        display: none !important;
    }
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        background: #1E293B; /* Solid background on mobile */
        border-right: 1px solid var(--border-color);
    }
    .sidebar.active {
        transform: translateX(0);
    }
    .sidebar-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(2px);
        z-index: 90;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }
    .sidebar-overlay.active {
        opacity: 1;
        pointer-events: auto;
    }
    .nav-item {
        padding: 12px 16px;
        font-size: 16px;
    }
    .main-content {
        padding: 16px;
    }
    .search-bar {
        flex-wrap: wrap;
    }
    .search-bar input {
        width: 100% !important;
        flex: 1 1 100%;
    }
    .search-bar button {
        flex: 1;
    }
    .glass-panel {
        padding: 16px;
    }
    .grid-4 {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 16px;
    }
    .grid-2 {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .chart-row {
        flex-direction: column;
        gap: 16px;
    }
    .chart-main, .chart-side {
        width: 100%;
        flex: none;
    }
    .attr-filters {
        flex-wrap: wrap;
    }
    .attr-filters button {
        flex: 1 1 calc(33.333% - 12px);
    }
    .login-box {
        width: 90%;
        max-width: 400px;
        padding: 24px;
    }
}
/* Skeleton Loading */
.skeleton-block, .skeleton-card {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.03) 25%, rgba(255, 255, 255, 0.08) 50%, rgba(255, 255, 255, 0.03) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 16px;
    border: 1px solid var(--border-color);
}
.skeleton-card {
    height: 120px;
}
.skeleton-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}
@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
