:root {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #242424;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --accent-blue: #3b82f6;
    --accent-green: #10b981;
    --accent-orange: #f59e0b;
    --accent-red: #ef4444;
    --border-color: #333333;
    --shadow: rgba(0, 0, 0, 0.5);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

header {
    background-color: var(--bg-secondary);
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.search-bar {
    display: flex;
    gap: 1rem;
}

.search-bar input {
    padding: 0.5rem 1rem;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.9rem;
    min-width: 300px;
}

.search-bar select {
    padding: 0.5rem 1rem;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.container {
    display: flex;
    min-height: calc(100vh - 80px);
}

.sidebar {
    width: 250px;
    background-color: var(--bg-secondary);
    padding: 1.5rem;
    border-right: 1px solid var(--border-color);
    flex-shrink: 0;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.nav-btn {
    padding: 0.75rem 1rem;
    background-color: transparent;
    border: none;
    color: var(--text-secondary);
    text-align: left;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.nav-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-btn.active {
    background-color: var(--accent-blue);
    color: white;
}

.filters {
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.filters h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.filters label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.filters input[type="checkbox"] {
    accent-color: var(--accent-blue);
}

.priority-filters {
    margin-top: 1rem;
}

.priority-filters h4 {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

h2 {
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
}

h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

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

.stat-card {
    background-color: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.stat-card .value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-blue);
    margin-bottom: 0.5rem;
}

.stat-card .label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.chart-container {
    background-color: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.chart-container canvas {
    max-height: 300px;
}

.toolbar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.toolbar button {
    padding: 0.5rem 1rem;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.toolbar button:hover {
    background-color: var(--accent-blue);
    border-color: var(--accent-blue);
}

.variables-table {
    background-color: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.variable-row {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.2s;
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
    gap: 1rem;
    align-items: center;
}

.variable-row:hover {
    background-color: var(--bg-tertiary);
}

.variable-row .name {
    font-weight: 600;
}

.variable-row .category {
    color: var(--accent-blue);
}

.variable-row .priority {
    color: var(--accent-orange);
}

.variable-row .frequency {
    color: var(--text-secondary);
}

.variable-row .coefficient {
    color: var(--accent-green);
}

.priority-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

.priority-1 { background-color: var(--accent-red); color: white; }
.priority-2 { background-color: var(--accent-orange); color: white; }
.priority-3 { background-color: var(--accent-green); color: white; }
.priority-4 { background-color: var(--accent-blue); color: white; }

.sections-tree {
    background-color: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    padding: 1.5rem;
}

.section-item {
    margin-left: 1.5rem;
    padding: 0.5rem 0;
}

.section-item.level-0 {
    margin-left: 0;
}

.section-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.section-content {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.network-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.network-legend {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    background-color: var(--bg-secondary);
    border-radius: 4px;
    border: 1px solid var(--border-color);
    align-items: center;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
    user-select: none;
}

.legend-item:hover {
    background-color: var(--bg-tertiary);
}

.legend-item.hidden {
    opacity: 0.4;
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #fff;
}

.legend-item[data-category="core_value"] .legend-color {
    background: linear-gradient(135deg, var(--accent-red), #dc2626);
}

.legend-item[data-category="hard_constraint"] .legend-color {
    background: linear-gradient(135deg, var(--accent-orange), #d97706);
}

.legend-item[data-category="soft_constraint"] .legend-color {
    background: linear-gradient(135deg, var(--accent-green), #059669);
}

.legend-item[data-category="factor"] .legend-color {
    background: linear-gradient(135deg, var(--accent-blue), #2563eb);
}

.network-controls button {
    padding: 0.5rem 1rem;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.network-controls button:hover {
    background-color: var(--accent-blue);
    border-color: var(--accent-blue);
}

#network-graph {
    background-color: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    height: 600px;
    overflow: hidden;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
}

.modal-content {
    background-color: var(--bg-secondary);
    margin: 5% auto;
    padding: 2rem;
    border-radius: 8px;
    width: 80%;
    max-width: 800px;
    border: 1px solid var(--border-color);
    max-height: 80vh;
    overflow-y: auto;
}

.close {
    float: right;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
}

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

#variable-detail {
    margin-top: 1rem;
}

.detail-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.detail-header h3 {
    margin: 0;
    font-size: 1.5rem;
}

.detail-section {
    margin-bottom: 1.5rem;
}

.detail-section h4 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--accent-blue);
}

.detail-section p {
    color: var(--text-secondary);
}

.mentions-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.mention-item {
    background-color: var(--bg-tertiary);
    padding: 0.75rem;
    border-radius: 4px;
    border-left: 3px solid var(--accent-blue);
}

.mention-context {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

@media (max-width: 1024px) {
    .container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .nav-menu {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .variable-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
}
