/* --- CORE DESIGN SYSTEM --- */
:root {
    /* Color Palette */
    --bg-base: #080c14;
    --bg-surface: rgba(16, 22, 38, 0.6);
    --bg-surface-opaque: #0f1626;
    --border-color: rgba(255, 255, 255, 0.06);
    --border-highlight: rgba(255, 255, 255, 0.12);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --color-accent: hsl(263, 90%, 65%);
    --color-accent-glow: rgba(139, 92, 246, 0.25);
    --color-cyan: hsl(190, 90%, 50%);
    --color-cyan-glow: rgba(6, 182, 212, 0.25);
    
    --color-success: hsl(142, 72%, 45%);
    --color-warning: hsl(38, 92%, 50%);
    --color-danger: hsl(0, 84%, 60%);
    --color-danger-glow: rgba(239, 68, 68, 0.2);

    /* Fonts & Radii */
    --font-heading: 'Outfit', 'Inter', -apple-system, sans-serif;
    --font-body: 'Inter', -apple-system, sans-serif;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    
    /* Animation Timing */
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.6;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(139, 92, 246, 0.1) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(6, 182, 212, 0.08) 0%, transparent 45%);
    background-attachment: fixed;
    min-height: 100vh;
}

.app-container {
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* --- HEADER AREA --- */
.app-header {
    background: var(--bg-surface);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-icon {
    font-size: 2.2rem;
    filter: drop-shadow(0 0 8px var(--color-cyan-glow));
}

.logo-text h1 {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.6rem;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #fff 0%, #cbd5e1 50%, var(--color-cyan) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text .subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.author-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 6px 14px;
    border-radius: 50px;
}

.author-info {
    display: flex;
    flex-direction: column;
    text-align: right;
}

.author-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.author-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-cyan) 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    box-shadow: 0 0 10px var(--color-accent-glow);
}

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

/* Width Helpers */
.full-width {
    grid-column: span 2;
}

.half-width {
    grid-column: span 1;
}

/* --- CARD STRUCTURES --- */
.card {
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.card:hover {
    border-color: var(--border-highlight);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.card-header h3 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.3px;
    color: var(--text-primary);
}

.card-header .card-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.card-header.border-bottom {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
}

/* --- HERO CARD --- */
.hero-card {
    background: linear-gradient(135deg, rgba(17, 24, 48, 0.85) 0%, rgba(10, 15, 30, 0.95) 100%);
    border: 1px solid rgba(139, 92, 246, 0.15);
    border-radius: var(--radius-lg);
    padding: 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 32px;
    box-shadow: 0 8px 32px rgba(139, 92, 246, 0.05);
}

.hero-content {
    max-width: 60%;
}

.hero-content h2 {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.75rem;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #fff 0%, var(--color-cyan) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-content p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.hero-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    flex-grow: 1;
}

.hero-stat-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: var(--transition-smooth);
}

.hero-stat-item:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--border-highlight);
    transform: translateY(-2px);
}

.stat-value {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 2.1rem;
    letter-spacing: -1px;
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* Status colors */
.text-danger {
    color: var(--color-danger);
    text-shadow: 0 0 10px var(--color-danger-glow);
}

/* --- CHARTS --- */
.chart-container {
    position: relative;
    width: 100%;
    height: 300px;
}

/* --- CORRELATION MATRIX GRID --- */
.correlation-grid-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 10px;
}

.corr-header-row {
    display: flex;
    justify-content: flex-end;
}

.corr-header-label {
    width: 60px;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    text-align: center;
    word-wrap: break-word;
}

.corr-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.corr-row-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    flex-grow: 1;
}

.corr-cells {
    display: flex;
    gap: 4px;
}

.corr-cell {
    width: 60px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    transition: var(--transition-smooth);
    position: relative;
    cursor: default;
}

.corr-cell:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-6px);
    background: #0f172a;
    color: #fff;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    white-space: nowrap;
    border: 1px solid var(--border-highlight);
    z-index: 10;
}

/* --- INTERACTIVE SANDBOX ENGINE --- */
.sandbox-layout {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 32px;
}

.sandbox-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

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

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.form-group input, 
.form-group select {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9rem;
    transition: var(--transition-smooth);
}

.form-group input:focus, 
.form-group select:focus {
    outline: none;
    border-color: var(--color-cyan);
    background: rgba(255, 255, 255, 0.07);
    box-shadow: 0 0 10px var(--color-cyan-glow);
}

.input-desc {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Sandbox results section */
.sandbox-results {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    justify-content: center;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.results-header h4 {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 600;
}

.running-indicator {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--color-cyan);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.running-indicator::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--color-cyan);
    box-shadow: 0 0 8px var(--color-cyan);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.9); opacity: 0.6; }
    50% { transform: scale(1.3); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.6; }
}

.result-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.score-display, 
.stress-display {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.score-numeric-container {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.score-value {
    font-family: var(--font-heading);
    font-size: 2.8rem;
    font-weight: 800;
    line-height: 1;
    color: #fff;
    transition: var(--transition-smooth);
}

.score-max {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-muted);
}

.score-bar-bg {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50px;
    overflow: hidden;
}

.score-bar-fill {
    height: 100%;
    border-radius: 50px;
    background: linear-gradient(90deg, var(--color-danger) 0%, var(--color-warning) 50%, var(--color-success) 100%);
    width: 0%;
    transition: width 0.5s ease-out;
}

.score-comment {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Stress Risk Gauge */
.stress-badge {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
}

.risk-meter-container {
    position: relative;
    width: 100%;
    height: 32px;
    margin-top: 6px;
    display: flex;
    align-items: center;
}

.risk-meter-gradient {
    width: 100%;
    height: 10px;
    border-radius: 50px;
    background: linear-gradient(90deg, var(--color-success) 0%, var(--color-warning) 45%, var(--color-danger) 75%, hsl(0, 84%, 45%) 100%);
}

.risk-meter-needle {
    position: absolute;
    width: 4px;
    height: 18px;
    background: #fff;
    border-radius: 50px;
    top: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8), 0 0 15px #000;
    transition: left 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2;
}

.risk-meter-labels {
    position: absolute;
    width: 100%;
    top: 20px;
    display: flex;
    justify-content: space-between;
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* --- BUTTONS --- */
.btn {
    border: none;
    border-radius: var(--radius-sm);
    padding: 12px 20px;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: var(--color-accent);
    color: #fff;
    box-shadow: 0 4px 14px var(--color-accent-glow);
}

.btn-primary:hover {
    background: hsl(263, 90%, 70%);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--border-highlight);
}

.btn-full {
    width: 100%;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.75rem;
}

/* Badges */
.badge {
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    width: fit-content;
}

.badge-accent {
    background: var(--color-accent-glow);
    color: hsl(263, 100%, 75%);
    border: 1px solid rgba(139, 92, 246, 0.3);
}

/* --- DATA TABLE --- */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.85rem;
    background: rgba(10, 15, 30, 0.3);
}

.data-table th, 
.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    font-weight: 600;
}

.data-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.explorer-filters {
    display: flex;
    gap: 12px;
}

.explorer-filters select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 6px 12px;
    font-size: 0.8rem;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pagination-buttons {
    display: flex;
    gap: 8px;
}

.table-footer {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 12px;
}

/* --- RISK REPORT SECTION --- */
.hidden {
    display: none !important;
}

.report-actions {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.report-wrapper {
    background: #0d1222;
    border: 2px solid var(--color-cyan);
    border-radius: var(--radius-lg);
    padding: 40px;
    color: #f8fafc;
    box-shadow: 0 10px 40px rgba(6, 182, 212, 0.1);
}

.report-banner {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    border-bottom: 3px double var(--border-color);
    padding-bottom: 20px;
    margin-bottom: 30px;
}

.banner-title h2 {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.6rem;
    color: var(--color-cyan);
    letter-spacing: 0.5px;
}

.banner-title p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.report-metadata {
    text-align: right;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.report-section-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 40px;
    margin-bottom: 32px;
}

.section-title {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-cyan);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.report-kpi-block {
    display: flex;
    gap: 20px;
    margin-bottom: 16px;
}

.kpi-score, 
.kpi-stress {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    padding: 14px 20px;
    border-radius: var(--radius-md);
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.kpi-num {
    font-size: 2.2rem;
    font-weight: 800;
    color: #fff;
    font-family: var(--font-heading);
}

.kpi-val {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--color-warning);
    height: 44px;
    display: flex;
    align-items: center;
}

.kpi-name {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
}

.report-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.risk-driver-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.risk-driver-list li {
    background: rgba(239, 68, 68, 0.05);
    border-left: 3px solid var(--color-danger);
    padding: 8px 12px;
    font-size: 0.85rem;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.risk-driver-list li.warning {
    background: rgba(245, 158, 11, 0.05);
    border-left-color: var(--color-warning);
}

.mitigation-protocols-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-top: 16px;
}

.mitigation-card {
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
}

.mitigation-card h5 {
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mitigation-card p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.report-footer {
    border-top: 1px solid var(--border-color);
    margin-top: 40px;
    padding-top: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.disclaimer {
    max-width: 60%;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.sign-off {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    font-style: italic;
    border-top: 1px solid var(--text-muted);
    padding-top: 4px;
}

/* --- FOOTER BAR --- */
.app-footer-bar {
    border-top: 1px solid var(--border-color);
    margin-top: 20px;
    padding-top: 20px;
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* --- RESPONSIVENESS --- */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .full-width, .half-width {
        grid-column: span 1;
    }
    
    .sandbox-layout {
        grid-template-columns: 1fr;
        gap: 24px;
    }
}

@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .author-badge {
        align-self: flex-end;
    }
    
    .hero-card {
        flex-direction: column;
        align-items: stretch;
    }
    
    .hero-content {
        max-width: 100%;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .report-section-grid {
        grid-template-columns: 1fr;
    }
    
    .mitigation-protocols-grid {
        grid-template-columns: 1fr;
    }
}

/* --- PRINT RULES --- */
@media print {
    body {
        background: #fff !important;
        color: #000 !important;
    }
    
    /* Hide everything that isn't the report */
    .app-container > *:not(#risk-report-card),
    #risk-report-card .report-actions,
    .no-print {
        display: none !important;
    }
    
    #risk-report-card {
        display: block !important;
        grid-column: span 2 !important;
        border: none !important;
        padding: 0 !important;
        box-shadow: none !important;
        background: #fff !important;
        color: #000 !important;
    }
    
    .report-wrapper {
        border: 2px solid #000 !important;
        background: #fff !important;
        color: #000 !important;
        box-shadow: none !important;
        padding: 20px !important;
    }
    
    .banner-title h2 {
        color: #000 !important;
    }
    
    .section-title {
        color: #000 !important;
        border-bottom: 1px solid #000 !important;
    }
    
    .kpi-score, 
    .kpi-stress {
        border: 1px solid #000 !important;
        background: #f8fafc !important;
        color: #000 !important;
    }
    
    .kpi-num, .kpi-val {
        color: #000 !important;
    }
    
    .risk-driver-list li {
        background: #f8fafc !important;
        border-left: 3px solid #000 !important;
        color: #000 !important;
    }
    
    .mitigation-card {
        border: 1px solid #000 !important;
        background: #f8fafc !important;
    }
    
    .mitigation-card h5, .mitigation-card p, .report-text {
        color: #000 !important;
    }
    
    .report-footer {
        border-top: 1px solid #000 !important;
    }
}
