:root {
    --primary-color: #3299CC;
    --secondary-color: #FFA500;
    --accent-color: #20B2AA;
    --background-color: #ffffff;
    --text-color: #333333;
    --border-color: #e0e0e0;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --chart-bg: #ffffff;
    --grid-color: #f5f5f5;
}

[data-theme="dark"] {
    --primary-color: #5AA3D0;
    --secondary-color: #FFB84D;
    --accent-color: #4DC7B0;
    --background-color: #1a1a1a;
    --text-color: #e0e0e0;
    --border-color: #404040;
    --shadow-color: rgba(255, 255, 255, 0.1);
    --chart-bg: #2a2a2a;
    --grid-color: #333333;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: all 0.3s ease;
}

header {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    padding: 1.5rem 2rem;
    box-shadow: 0 2px 10px var(--shadow-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

header h1 {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 1rem;
    font-weight: 300;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.controls button {
    padding: 0.75rem 1.5rem;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.controls button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.chart-nav {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1rem;
    background: var(--chart-bg);
    border-radius: 15px;
    box-shadow: 0 2px 10px var(--shadow-color);
}

.nav-btn {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-color);
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.nav-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.nav-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.chart-section {
    display: none;
    animation: fadeIn 0.5s ease;
}

.chart-section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chart-section h2 {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 2rem;
    color: var(--text-color);
    font-weight: 300;
}

.chart-container {
    background: var(--chart-bg);
    border-radius: 15px;
    padding: 2rem;
    box-shadow: 0 2px 15px var(--shadow-color);
}

.chart-row {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.chart-box {
    background: var(--chart-bg);
    border-radius: 10px;
    padding: 1rem;
    box-shadow: 0 2px 8px var(--shadow-color);
    position: relative;
}

.full-width {
    flex: 1 1 100%;
    min-height: 400px;
}

.half-width {
    flex: 1 1 calc(50% - 1rem);
    min-height: 350px;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: var(--chart-bg);
    margin: 5% auto;
    padding: 2rem;
    border-radius: 15px;
    width: 80%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.3);
    position: relative;
}

.close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    color: var(--text-color);
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close:hover {
    color: var(--primary-color);
}

#dataEditor {
    margin-bottom: 2rem;
}

.data-input-group {
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--grid-color);
    border-radius: 8px;
}

.data-input-group h4 {
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.data-input {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.data-input label {
    min-width: 120px;
    font-weight: 500;
}

.data-input input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    background: var(--chart-bg);
    color: var(--text-color);
    font-size: 1rem;
}

#saveData {
    padding: 0.75rem 2rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
}

#saveData:hover {
    background: var(--accent-color);
    transform: translateY(-2px);
}

footer {
    text-align: center;
    padding: 2rem;
    background: var(--chart-bg);
    border-top: 1px solid var(--border-color);
    margin-top: 3rem;
}

/* 响应式设计 */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }
    
    .controls {
        flex-direction: column;
        align-items: center;
    }
    
    .chart-nav {
        flex-direction: column;
        align-items: center;
    }
    
    .nav-btn {
        width: 100%;
        max-width: 300px;
    }
    
    .chart-row {
        flex-direction: column;
    }
    
    .half-width {
        flex: 1 1 100%;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
}

@media (max-width: 480px) {
    main {
        padding: 1rem;
    }
    
    .chart-container {
        padding: 1rem;
    }
    
    header {
        padding: 1rem;
    }
}

/* 图表特定样式 */
.chart-title {
    text-align: center;
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--text-color);
    font-weight: 500;
}

.chart-legend {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 3px;
}

/* 子图网格布局 */
.subplot-grid-3x2 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 1rem;
    min-height: 400px;
}

.subplot-grid-2x2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 1rem;
    min-height: 400px;
}

.subplot-item {
    background: var(--chart-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 180px;
    box-shadow: 0 2px 4px var(--shadow-color);
}

.custom-layout-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 1rem;
    min-height: 400px;
}

.custom-layout-item {
    background: var(--chart-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 180px;
    box-shadow: 0 2px 4px var(--shadow-color);
}

.custom-gridspec-layout {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
    min-height: 300px;
}

.custom-gridspec-layout-2 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 1rem;
    min-height: 450px;
}

.gridspec-item {
    background: var(--chart-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    box-shadow: 0 2px 4px var(--shadow-color);
}

/* 布局样式修饰 */
.constrained-layout {
    padding: 0.5rem;
}

.tight-layout {
    gap: 0.25rem;
}

.tight-layout .subplot-item {
    padding: 0.5rem;
    min-height: 160px;
}

/* 响应式子图布局 */
@media (max-width: 768px) {
    .subplot-grid-3x2 {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(3, 1fr);
    }
    
    .subplot-grid-2x2 {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(2, 1fr);
    }
    
    .custom-layout-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(3, 1fr);
    }
    
    .custom-gridspec-layout {
        grid-template-columns: 1fr;
    }
    
    .custom-gridspec-layout-2 {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(4, 1fr);
    }
    
    .gridspec-item {
        min-height: 100px;
    }
}

@media (max-width: 480px) {
    .subplot-grid-3x2,
    .subplot-grid-2x2,
    .custom-layout-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }
    
    .subplot-item,
    .custom-layout-item,
    .gridspec-item {
        min-height: 120px;
    }
}

/* 加载动画 */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 300px;
    font-size: 1.2rem;
    color: var(--primary-color);
}

.loading::after {
    content: '';
    width: 30px;
    height: 30px;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}