:root {
    --bg-dark: #0f172a;
    --bg-darker: #020617;
    --primary: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.5);
    --secondary: #10b981;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
}

[data-theme="light"] {
    --bg-dark: #f8fafc;
    --bg-darker: #f1f5f9;
    --text-main: #0f172a;
    --text-muted: #475569;
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] body {
    background-image: 
        radial-gradient(at 0% 0%, rgba(241, 245, 249, 1) 0, transparent 50%), 
        radial-gradient(at 100% 100%, rgba(219, 234, 254, 0.6) 0, transparent 50%);
}

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

body {
    background-color: var(--bg-darker);
    background-image: 
        radial-gradient(at 0% 0%, rgba(15, 23, 42, 1) 0, transparent 50%), 
        radial-gradient(at 100% 100%, rgba(30, 58, 138, 0.4) 0, transparent 50%);
    color: var(--text-main);
    font-family: var(--font-body);
    min-height: 100vh;
    line-height: 1.6;
    background-attachment: fixed;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--glass-border);
    flex-wrap: wrap;
    gap: 1.5rem;
}

.header-content h1 {
    font-family: var(--font-heading);
    font-size: 2.8rem;
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 0.2rem;
}

.highlight {
    color: transparent;
    background: linear-gradient(90deg, #60a5fa, #34d399);
    -webkit-background-clip: text;
    background-clip: text;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
    font-weight: 300;
}

/* Status Badge */
.status-badge {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 1.2rem;
    border-radius: 999px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    backdrop-filter: blur(10px);
    height: fit-content;
}

.sync-status {
    margin-top: 1rem;
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1.25rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.sync-status.updating .sync-icon {
    display: inline-block;
    animation: rotate 2s linear infinite;
}

.sync-status.ready {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.2);
    color: #34d399;
}

.sync-status.error {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.cached .dot { background-color: #f59e0b; box-shadow: 0 0 10px rgba(245, 158, 11, 0.5); }
.live .dot { background-color: var(--secondary); box-shadow: 0 0 10px var(--secondary); }

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2.5fr 1fr;
    gap: 2.5rem;
}

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

.section-title {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-main);
}

.icon {
    font-size: 1.6rem;
}

/* Alerts Grid */
.alerts-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.alert-banner {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-radius: 0.75rem;
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.alert-banner.crítico {
    border-left: 5px solid #ef4444;
    background: rgba(239, 68, 68, 0.05);
}

.alert-banner.oportunidad {
    border-left: 5px solid #10b981;
    background: rgba(16, 185, 129, 0.05);
}

.alert-banner.informativo {
    border-left: 5px solid #3b82f6;
    background: rgba(59, 130, 246, 0.05);
}

.alert-icon {
    font-size: 1.5rem;
}

.alert-text {
    font-size: 0.95rem;
    color: var(--text-main);
}

.alert-text strong {
    color: var(--text-main);
    font-weight: 700;
    margin-right: 0.5rem;
}

/* Glass Cards */
.cards-wrapper {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    padding: 1.5rem;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.2);
}

.card.featured {
    grid-column: 1 / -1;
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.9));
    border: 1px solid rgba(59, 130, 246, 0.4);
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.15);
}

.card-icon {
    font-size: 2.2rem;
    margin-bottom: 1rem;
    display: inline-block;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 0.75rem;
}

.card h3 {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    margin-bottom: 0.7rem;
    color: var(--text-main);
    font-weight: 600;
}

.card p {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.7;
}

.error-card {
    border-color: rgba(239, 68, 68, 0.5);
    background: rgba(239, 68, 68, 0.1);
}

/* Dimension Cards */
.section-subtitle {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    color: var(--text-main);
    margin-bottom: 1rem;
}

.dimensions-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.dimension-card {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.dimension-card > div:last-child {
    margin-top: auto;
}

.dim-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.dim-header h3 {
    font-size: 1.4rem;
    margin: 0;
    color: var(--primary);
    font-family: var(--font-heading);
}

.tendencia-badge {
    background: rgba(16, 185, 129, 0.15);
    color: var(--secondary);
    padding: 0.5rem 0.8rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.dim-resumen {
    font-size: 1.05rem;
    color: var(--text-main);
    margin-bottom: 1.2rem;
    line-height: 1.6;
}

.hallazgos-container {
    background: rgba(15, 23, 42, 0.5);
    padding: 1.2rem;
    border-radius: 0.5rem;
    margin-bottom: 1.2rem;
    border-left: 3px solid var(--primary);
}

[data-theme="light"] .hallazgos-container {
    background: rgba(59, 130, 246, 0.08);
}

.hallazgos-container h5 {
    color: var(--text-muted);
    margin-bottom: 0.8rem;
    font-family: var(--font-heading);
    font-size: 1rem;
}

.hallazgos-container ul {
    list-style-type: none;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.hallazgos-container li {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.hallazgo-comuna {
    color: #94a3b8;
    font-size: 0.8rem;
    margin-left: 0.3rem;
}

.implicancia-box {
    background: rgba(59, 130, 246, 0.1);
    border: 1px dashed rgba(59, 130, 246, 0.4);
    padding: 1rem;
    border-radius: 0.5rem;
    font-size: 0.95rem;
    color: var(--text-main);
}

.btn-toggle-detail {
    background: transparent;
    color: var(--primary);
    border: 1px solid rgba(96, 165, 250, 0.4);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-toggle-detail:hover {
    background: rgba(96, 165, 250, 0.1);
    border-color: #60a5fa;
    color: #93c5fd;
}

/* Oportunidades */
.opportunity-card {
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.95));
    border: 1px solid rgba(245, 158, 11, 0.4);
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.15);
    display: flex;
    flex-direction: column;
}

.op-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.8rem;
    gap: 1rem;
}

.op-header h4 {
    font-size: 1.2rem;
    color: #fbbf24;
    margin: 0;
    font-family: var(--font-heading);
}

.op-level {
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    background: rgba(245, 158, 11, 0.2);
    color: #fcd34d;
}

.opportunity-card p {
    color: var(--text-main);
    font-size: 0.95rem;
    flex-grow: 1;
}

.op-footer {
    margin-top: 1rem;
    padding-top: 0.8rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    color: var(--text-muted);
}

/* News Cards */
.news-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.news-card {
    display: flex;
    flex-direction: column;
}

.news-card p {
    flex-grow: 1;
}

.news-card h4 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.news-source {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.news-date {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.news-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 1rem;
    color: var(--secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s;
}

.news-link:hover {
    color: #34d399;
}

.news-link span {
    transition: transform 0.2s;
}

.news-link:hover span {
    transform: translateX(4px);
}

/* Contest Cards */
.contest-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.contest-card h4 {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.contest-inst {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.contest-deadline {
    font-size: 0.8rem;
    color: #fca5a5;
    font-weight: 600;
    background: rgba(239, 68, 68, 0.15);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

/* Charts */
.charts-wrapper {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.chart-card {
    display: flex;
    flex-direction: column;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.chart-header h3 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    color: var(--text-main);
    margin: 0;
}

.chart-current {
    text-align: right;
}

.chart-current .value {
    display: block;
    font-size: 1.4rem;
    font-weight: 700;
    font-family: var(--font-heading);
    color: var(--text-main);
    line-height: 1.2;
}

.chart-current .unit {
    font-size: 0.75rem;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.canvas-container {
    position: relative;
    height: 150px;
    width: 100%;
    margin-top: auto;
}

/* Tools Sidebar */
.tools-sidebar {
    position: sticky;
    top: 2rem;
}

.tools-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.tool-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.2rem;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 0.75rem;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
}

.tool-card:hover {
    background: rgba(51, 65, 85, 0.8);
    border-color: var(--primary);
    transform: translateX(8px);
}

[data-theme="light"] .tool-card:hover {
    background: rgba(59, 130, 246, 0.08);
}

.tool-icon {
    font-size: 1.5rem;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0.75rem;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

.tool-icon.ai {
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.tool-card.gov:hover {
    border-color: var(--secondary);
}

.tool-info h4 {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    margin-bottom: 0.2rem;
    color: var(--text-main);
}

.tool-info p {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Footer */
footer {
    margin-top: 4rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
    padding-top: 2rem;
    border-top: 1px solid var(--glass-border);
}

.tool-card.highlight-tool {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(37, 99, 235, 0.2));
    border: 1px solid rgba(59, 130, 246, 0.5);
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.2);
}

.tool-card.highlight-tool:hover {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.3), rgba(37, 99, 235, 0.3));
    border-color: #60a5fa;
    transform: translateX(12px) scale(1.02);
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .app-container {
        padding: 1rem;
    }
    
    .header-content h1 {
        font-size: 2rem;
    }
    
    .dashboard-grid {
        gap: 1.5rem;
    }
}

/* Theme Toggle & Logo Styles */
.theme-toggle {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
    backdrop-filter: blur(10px);
}

.theme-toggle:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: #60a5fa;
}

.brand-logo {
    height: 48px;
    width: auto;
    object-fit: contain;
    transition: filter 0.3s;
}

[data-theme="light"] .brand-logo {
    filter: invert(1) brightness(0.2);
}

/* Fix colors in light mode (Redundant after refactor) */
