:root {
    --primary: #2563eb; 
    --primary-dark: #1e40af;
    --bg: #f8fafc;      
    --card-bg: #ffffff; 
    --card-border: rgba(0,0,0,0.05);
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --accent: #10b981;
    --danger: #ef4444;
    --transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    --safe-top: env(safe-area-inset-top, 20px);
    --safe-bottom: env(safe-area-inset-bottom, 10px);
}

* {
    margin: 0; padding: 0; box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    position: fixed;
    background: var(--bg);
}

body {
    display: flex;
    flex-direction: column;
    padding-top: var(--safe-top);
}

#app {
    display: none;
    flex: 1;
    width: 100%;
    flex-direction: column;
    position: relative;
    height: 100dvh;
}

.main-container {
    flex: 1;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: calc(85px + var(--safe-bottom));
    -webkit-overflow-scrolling: touch;
}

/* Splash Oficial */
#splash {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: #ffffff; display: flex; flex-direction: column;
    justify-content: center; align-items: center; z-index: 9999;
    transition: opacity 0.5s ease;
}
#splash img {
    width: 220px;
    height: auto;
    object-fit: contain;
    margin-bottom: 20px;
    mix-blend-mode: multiply; /* Removes white background from the logo */
    background: transparent;
}

/* Header */
header {
    padding: 15px 20px;
    display: flex; justify-content: space-between; align-items: center;
    position: sticky; top: 0; background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    z-index: 100; border-bottom: 1px solid var(--card-border);
}
header h2 { font-size: 1.6rem; font-weight: 800; color: var(--text-primary); letter-spacing: -0.5px; }

/* Views Separation Fix */
.view-section { display: none; width: 100%; min-height: 100%; height: auto; padding-bottom: 20px;}
.view-section.active { display: block; animation: fIn 0.3s ease-out; }
.fade-in { animation: fIn 0.3s ease-out; }
.fade-in { animation: fIn 0.3s ease-out; }

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

/* Tab Bar - Universal Fix */
.tab-bar {
    position: fixed; bottom: 0; left: 0; width: 100%;
    height: calc(65px + var(--safe-bottom));
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px);
    border-top: 1px solid var(--card-border);
    display: flex; justify-content: space-around; align-items: center;
    padding: 0 10px calc(var(--safe-bottom) + 5px); 
    z-index: 1000;
    box-shadow: 0 -4px 10px rgba(0,0,0,0.02);
}

.tab-item {
    display: flex; flex-direction: column; align-items: center;
    color: #94a3b8; font-size: 0.62rem; font-weight: 700; gap: 4px;
    transition: var(--transition); flex: 1; padding-top: 10px;
}
.tab-item i { font-size: 1.4rem; transition: transform 0.3s; }
.tab-item.active { color: var(--primary); }
.tab-item.active i { transform: translateY(-2px); }

/* Case Cards */
.case-card {
    background: var(--card-bg); margin: 15px; padding: 24px 24px 24px 35px;
    border-radius: 22px; border: 1px solid var(--card-border);
    box-shadow: var(--shadow); transition: var(--transition);
    position: relative; overflow: hidden;
}
.case-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: #cbd5e1; }
.case-card.status-pending::before { background: var(--primary); }
.case-card.status-approved::before { background: var(--accent); }
.case-card.status-denied::before { background: var(--danger); }
.case-card.status-review::before { background: #f59e0b; }
.case-card:active { transform: scale(0.98); background: #f8fafc; }

.status-badge {
    position: absolute; top: 24px; right: 24px;
    padding: 6px 14px; border-radius: 20px; font-size: 0.72rem;
    background: #eff6ff; color: var(--primary); font-weight: 800;
}
.case-card h3 { font-size: 1.15rem; font-weight: 800; color: #1e293b; margin-bottom: 6px; padding-right: 80px; }
.case-card .case-number { font-size: 0.8rem; color: var(--text-secondary); font-family: 'Monaco', monospace; letter-spacing: 0.5px; }
.case-card .last-update { font-size: 0.75rem; color: var(--text-secondary); margin-top: 15px; font-weight: 600; }

/* AI Section */
.ai-insight {
    background: #ffffff; border: 1px solid var(--card-border);
    padding: 24px; border-radius: 28px; margin: 20px;
    box-shadow: var(--shadow);
}
.ai-header {
    display: flex; align-items: center; gap: 10px; margin-bottom: 24px;
    color: var(--primary); font-weight: 900; text-transform: uppercase;
    font-size: 0.75rem; letter-spacing: 1px;
}

/* Charts */
.chart-container { display: flex; flex-direction: column; align-items: center; margin-bottom: 30px; }
.donut-chart {
    width: 160px; height: 160px; border-radius: 50%;
    background: conic-gradient(var(--primary) 0%, #f1f5f9 0%);
    display: flex; justify-content: center; align-items: center;
    position: relative; transition: background 1.5s cubic-bezier(0.16, 1, 0.3, 1);
}
.donut-chart::after { content: ''; position: absolute; width: 130px; height: 130px; background: #ffffff; border-radius: 50%; }
.chart-center { position: relative; z-index: 10; text-align: center; }
.chart-value { font-size: 2.2rem; font-weight: 900; color: var(--text-primary); }
.chart-label { font-size: 0.65rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; }

/* Stats */
.stats-list { display: flex; flex-direction: column; gap: 10px; margin-top: 20px;}
.stat-item { display: flex; align-items: center; padding: 16px; background: #f8fafc; border-radius: 16px; border: 1px solid #e2e8f0; }
.stat-dot { width: 10px; height: 10px; border-radius: 50%; margin-right: 14px; }
.stat-label { flex: 1; font-size: 0.95rem; font-weight: 700; color: #334155; }
.stat_pct { color: var(--text-secondary); font-size: 0.85rem; margin-right: 14px; }
.stat_count { font-weight: 800; color: var(--text-primary); }

/* Next Step Card */
.next-step-card {
    background: var(--primary); color: white;
    padding: 28px; border-radius: 28px; margin: 20px;
    box-shadow: 0 15px 30px rgba(37, 99, 235, 0.3);
}
.next-step-label { font-size: 0.65rem; text-transform: uppercase; font-weight: 800; opacity: 0.8; margin-bottom: 10px; letter-spacing: 1.5px; display: flex; justify-content: space-between;}
.next-step-title { font-size: 1.4rem; font-weight: 800; line-height: 1.2; margin-bottom: 20px; }
.next-step-metrics { display: flex; gap: 30px; padding-top: 15px; border-top: 1px solid rgba(255,255,255,0.15); }
.metric-item div:first-child { font-size: 0.65rem; opacity: 0.8; text-transform: uppercase; font-weight: 800; margin-bottom: 4px; }
.metric-item div:last-child { font-size: 1.1rem; font-weight: 800; }

/* Floating UI (FAB & Modals) */
.fab {
    position: fixed; bottom: calc(85px + var(--safe-bottom)); right: 25px;
    width: 60px; height: 60px; border-radius: 30px;
    background: var(--primary); color: white; display: flex;
    justify-content: center; align-items: center;
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.4); z-index: 500; font-size: 1.4rem;
    transition: transform 0.3s;
}
.fab:active { transform: scale(0.9); }

.modal {
    position: fixed; bottom: 0; left: 0; width: 100%; background: #ffffff;
    border-radius: 35px 35px 0 0; padding: 30px 25px calc(var(--safe-bottom) + 30px);
    transform: translateY(100%); transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1); z-index: 2000;
    max-height: 94dvh; overflow-y: auto; border-top: 1px solid var(--card-border);
    box-shadow: 0 -10px 40px rgba(0,0,0,0.1);
}
.modal.active { transform: translateY(0); }
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); opacity: 0; pointer-events: none; transition: 0.3s; z-index: 1900; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.modal-overlay.active { opacity: 1; pointer-events: auto; }

/* Forms */
.btn { width: 100%; padding: 18px; border-radius: 18px; border: none; font-weight: 800; font-size: 1.1rem; cursor: pointer; transition: 0.2s; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: white; box-shadow: 0 8px 20px rgba(37, 99, 235, 0.25); }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-size: 0.8rem; font-weight: 800; color: #64748b; text-transform: uppercase; letter-spacing: 1px; }
.form-group input, .form-group select { width: 100%; padding: 16px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 14px; color: #0f172a; font-size: 1rem; font-weight: 500; }
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--primary); background: #ffffff; }

/* Timeline */
.timeline { margin: 30px 25px; border-left: 2px solid #e2e8f0; padding-left: 25px; }
.timeline-item { position: relative; margin-bottom: 30px; }
.timeline-item::before { content: ''; position: absolute; left: -36px; top: 0; width: 20px; height: 20px; border-radius: 50%; background: #e2e8f0; border: 4px solid #ffffff; }
.timeline-item.active::before { background: var(--primary); }
.timeline-date { font-size: 0.75rem; color: var(--text-secondary); font-weight: 800; }
.timeline-status { font-weight: 700; margin-top: 4px; font-size: 1rem; color: #1e293b; }

/* News Pulse Carousel */
.news-pulse-container { padding: 15px; background: #ffffff; }
.news-slider {
    height: 200px; position: relative; overflow: hidden;
    border-radius: 28px; background: linear-gradient(135deg, #1e3a8a 0%, #172554 100%);
    color: white; padding: 25px; box-shadow: 0 15px 35px rgba(30, 58, 138, 0.2);
    cursor: pointer;
}

.news-item {
    position: absolute; top: 25px; left: 25px; bottom: 25px; right: 25px;
    opacity: 0; transform: scale(0.95); pointer-events: none;
    transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex; flex-direction: column; justify-content: center;
}
.news-item.active { opacity: 1; transform: scale(1); pointer-events: auto; }

.news-tag { 
    font-size: 0.6rem; font-weight: 900; text-transform: uppercase; 
    background: rgba(255,255,255,0.15); padding: 5px 12px; border-radius: 20px; 
    width: fit-content; margin-bottom: 15px; letter-spacing: 1px;
}
.news-title { font-size: 1.25rem; font-weight: 800; line-height: 1.2; margin-bottom: 10px; }
.news-source { font-size: 0.75rem; opacity: 0.6; font-weight: 600; display: flex; align-items: center; gap: 6px; }

.slider-dots { display: flex; gap: 6px; justify-content: center; margin-top: 15px; }
.dot { width: 6px; height: 6px; background: #e2e8f0; border-radius: 50%; transition: 0.3s; }
.dot.active { width: 22px; background: var(--primary); border-radius: 10px; }

/* News Detail Modal Overhaul */
.news-detail-modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: #ffffff; z-index: 3000; transform: translateY(100%);
    transition: var(--transition); overflow-y: auto;
}
.news-detail-modal.active { transform: translateY(0); }

/* Confetti Layer */
#confetti-canvas { pointer-events: none; z-index: 9999; position: fixed; top: 0; left: 0; }

/* Directory List */
.directory-item {
    display: flex; align-items: center; padding: 18px; margin: 10px 15px;
    background: white; border-radius: 18px; border: 1px solid var(--card-border);
    box-shadow: var(--shadow); transition: 0.2s;
}
.directory-item:active { transform: scale(0.98); background: #f8fafc; }
.dir-icon { width: 45px; height: 45px; border-radius: 12px; background: #eff6ff; color: var(--primary); display: flex; justify-content: center; align-items: center; font-size: 1.2rem; margin-right: 15px; }
.dir-info h4 { font-size: 1rem; font-weight: 800; color: #1e293b; margin-bottom: 4px; }
.dir-info p { font-size: 0.75rem; color: var(--text-secondary); }

/* Tablet Resp. */
@media (min-width: 768px) {
    .main-container { max-width: 600px; margin: 0 auto; box-shadow: 0 0 50px rgba(0,0,0,0.05); background: white; }
    .tab-bar { max-width: 600px; left: 50%; transform: translateX(-50%); border-radius: 40px 40px 0 0; }
    header { max-width: 600px; left: 50%; transform: translateX(-50%); width: 100%; }
    .modal { max-width: 600px; left: 50%; transform: translateX(-50%) translateY(100%); border-radius: 35px 35px 0 0; }
    .modal.active { transform: translateX(-50%) translateY(0); }
    .fab { margin-right: calc((100vw - 600px) / 2); }
}

/* Toast Notification */
.toast {
    position: fixed; top: -100px; left: 50%; transform: translateX(-50%);
    background: #10b981; color: white; padding: 12px 25px; border-radius: 30px;
    font-weight: 800; font-size: 0.9rem; z-index: 9999; box-shadow: 0 10px 25px rgba(16, 185, 129, 0.4);
    transition: top 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast.show { top: calc(env(safe-area-inset-top, 20px) + 15px); }

/* Physical Scroll Carousel */
.news-slider-physical {
    display: flex; gap: 15px; overflow-x: auto; scroll-snap-type: x mandatory;
    padding-bottom: 20px; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.news-slider-physical::-webkit-scrollbar { display: none; }

.news-item-physical {
    min-width: 90vw; scroll-snap-align: center;
    background: linear-gradient(135deg, #1e3a8a 0%, #172554 100%); color: white;
    padding: 30px 25px; border-radius: 28px; box-shadow: 0 15px 35px rgba(30, 58, 138, 0.2);
    cursor: pointer; display: flex; flex-direction: column; justify-content: center;
    transition: transform 0.2s;
}
.news-item-physical:active { transform: scale(0.98); }

@media (min-width: 768px) {
    .news-item-physical { min-width: calc(600px - 30px); }
}
