:root {
    --bg-color: #0f172a;
    --navy-dark: #f8fafc;
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --white: #ffffff;
    --accent-blue: #3b82f6;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --accent-red-bg: rgba(239, 68, 68, 0.15);
    --accent-red-border: rgba(239, 68, 68, 0.3);
    --border-color: rgba(255, 255, 255, 0.15);
    
    /* Glassmorphism Variables */
    --glass-bg: rgba(15, 23, 42, 0.65);
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    --sidebar-glass: rgba(2, 6, 23, 0.75); 
    
    --radius-md: 16px;
    --radius-lg: 24px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    background: linear-gradient(135deg, #020617 0%, #0f172a 100%);
    background-attachment: fixed;
    color: var(--text-main);
    line-height: 1.6;
    position: relative;
    overflow-x: hidden;
}

/* DECORATIVE BLOBS */
.bg-shape {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
    opacity: 0.6;
}
.shape-1 {
    width: 500px;
    height: 500px;
    background: #4338ca;
    top: -100px;
    left: -100px;
}
.shape-2 {
    width: 600px;
    height: 600px;
    background: #0369a1;
    bottom: -200px;
    right: -100px;
}
.shape-3 {
    width: 400px;
    height: 400px;
    background: #be185d;
    top: 30%;
    left: 40%;
}

/* APP CONTAINER & SIDEBAR */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    background-color: var(--sidebar-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--white);
    width: 260px;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
    position: sticky;
    top: 0;
    height: 100vh;
    box-shadow: 4px 0 24px rgba(0,0,0,0.1);
    flex-shrink: 0;
    z-index: 10;
}

.sidebar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tab-btn {
    background-color: transparent;
    color: #94a3b8;
    border: none;
    padding: 1rem;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    text-align: left;
}

.tab-btn:hover {
    color: var(--white);
    background-color: rgba(255,255,255,0.05);
}

.quick-prompt-btn:hover {
    background-color: #f1f5f9;
    color: var(--navy-dark);
}

.dynamic-chart-container {
    padding: 1rem;
    margin-bottom: 1rem;
    background-color: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
}

.tab-btn.active {
    background-color: rgba(255,255,255,0.15);
    color: var(--white);
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* LAYOUT & CONTAINERS */
.main-content {
    flex: 1;
    padding: 2rem;
    max-width: calc(100vw - 260px); /* prevent overflow */
    display: flex;
    flex-direction: column;
    gap: 2rem;
    min-width: 0;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* COMMON COMPONENTS */
.card {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
    border: var(--glass-border);
    padding: 1.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px 0 rgba(31, 38, 135, 0.1);
}

/* ZONA SETUP & FILTERS */
.setup-header-container {
    margin-bottom: 1.5rem;
}

.filter-bar {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    padding: 1rem 1.5rem;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: var(--radius-lg);
    border: var(--glass-border);
    box-shadow: var(--glass-shadow);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.filter-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
}

.filter-group select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text-main);
    outline: none;
    background-color: rgba(0, 0, 0, 0.2);
    min-width: 150px;
}

.filter-group select option {
    background-color: #0f172a;
    color: #e2e8f0;
}

.setup-header {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--navy-dark);
    margin-bottom: 0.25rem;
}

.story-text {
    font-size: 1.05rem;
    color: var(--text-muted);
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}

.kpi-card {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.kpi-title {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.kpi-value {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--navy-dark);
    line-height: 1.1;
}

.kpi-value.positive { color: var(--accent-green); }
.kpi-value.negative { color: var(--accent-red); }

/* ZONA CONFLICT */
.conflict-header-label {
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--accent-red);
    text-transform: uppercase;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert-wrapper {
    background: var(--accent-red-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--accent-red-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.alert-panel {
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--accent-red-border);
}

.alert-panel-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.alert-panel-left h3 {
    color: #991b1b;
    font-size: 1.125rem;
    font-weight: 700;
    margin: 0;
}

.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
}

.badge-red { background-color: #dc2626; }
.badge-orange { background-color: #ea580c; }

.btn-narasi {
    background-color: #991b1b;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background-color 0.2s;
}

.btn-narasi:hover {
    background-color: #7f1d1d;
}

.alert-tabs {
    display: flex;
    background-color: rgba(0, 0, 0, 0.15);
    border-bottom: 1px solid var(--accent-red-border);
}

.alert-tab {
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
    color: #94a3b8;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    font-weight: 500;
}

.alert-tab.active {
    color: #dc2626;
    border-bottom: 2px solid #dc2626;
    font-weight: 600;
}

.anomaly-content-container {
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.15);
}

.anomaly-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.anomaly-list li {
    position: relative;
    padding-left: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.anomaly-list li:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.anomaly-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #ea580c;
}

.anomaly-title {
    font-weight: 600;
    color: var(--navy-dark);
    margin-bottom: 0.25rem;
    font-size: 1rem;
}

.anomaly-desc {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-family: monospace;
}

.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.chart-container {
    width: 100%;
    height: 350px;
    position: relative;
}

.chart-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--navy-dark);
}

/* ZONA RESOLUTION */
.resolution-grid {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 1.5rem;
}

.ai-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    height: 100%;
}

.ai-panel h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--navy-dark);
    margin: 0;
    display: flex;
    align-items: center;
}

.summary-table-panel h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--navy-dark);
    margin-bottom: 0.5rem;
}

.ai-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.model-badge {
    border: 1px solid var(--border-color);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-family: monospace;
    color: var(--text-muted);
}


.ai-chatbox {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 1rem;
    border: var(--glass-border);
    min-height: 150px;
    overflow-y: auto;
    font-size: 0.95rem;
    color: var(--text-main);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

.ai-input-area {
    display: flex;
    gap: 0.75rem;
}

.ai-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: var(--glass-border);
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-main);
    border-radius: 12px;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

.ai-input:focus {
    background: rgba(0, 0, 0, 0.5);
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.quick-prompts {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.quick-prompts span {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.quick-prompt-btn {
    background-color: var(--white);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 0.4rem 0.8rem;
    border-radius: 999px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.quick-prompt-btn:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    background-color: #f0f9ff;
}


.btn-primary {
    background-color: var(--accent-blue);
    color: #ffffff;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    background-color: #2563eb;
}

.btn-primary:disabled {
    background-color: #cbd5e1;
    cursor: not-allowed;
}

.table-responsive {
    overflow-x: auto;
}

.summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.summary-table th {
    text-align: left;
    padding: 0.75rem;
    border-bottom: 2px solid var(--border-color);
    color: var(--text-muted);
    font-weight: 600;
}

.summary-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--navy-dark);
    font-weight: 500;
}

.summary-table tr:last-child td {
    border-bottom: none;
}

/* TABLEAU ZONE */
.tableau-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.tableau-link {
    color: var(--accent-blue);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.tableau-link:hover {
    text-decoration: underline;
}

.tableau-container {
    width: 100%;
    min-height: 850px;
    background-color: #e2e8f0;
    border-radius: var(--radius-md);
    overflow: auto;
}

.tableau-container iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* TOOLTIP D3 */
.tooltip {
    position: absolute;
    text-align: center;
    padding: 0.5rem;
    font-size: 0.8rem;
    background: #1e293b;
    color: #f8fafc;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10;
}

@media (max-width: 1024px) {
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .charts-grid { grid-template-columns: 1fr; }
    .resolution-grid { grid-template-columns: 1fr; }
}
