/* styles.css — ACCESS Nexus Tracker Power BI Theme Styling */

:root {
    --pbi-bg: #EAEFF5;
    --pbi-navy: #0B3C5D;
    --pbi-navy-dark: #00263E;
    --pbi-blue: #006699;
    --pbi-card-bg: #FFFFFF;
    --pbi-border: #D1D9E6;
    --pbi-text: #1F2937;
    --pbi-muted: #6B7280;
    --font-main: 'Inter', sans-serif;
    
    --color-conflict-horiz: #EC4899;
    --color-conflict-vert: #8B5CF6;
    --color-natural-hazard: #0B3C5D;
    --color-human-induced: #10B981;
}

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

body.powerbi-theme {
    background-color: var(--pbi-bg);
    color: var(--pbi-text);
    font-family: var(--font-main);
    line-height: 1.4;
    min-height: 100vh;
    overflow-x: auto;
    padding-bottom: 50px; /* space for bottom nav */
}

.app-container {
    min-height: calc(100vh - 68px - 50px);
}

/* App Banner Header */
.app-header {
    background: linear-gradient(90deg, #FFFFFF 0%, #E2E8F0 100%);
    border-bottom: 2px solid #CBD5E1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.header-logo-img {
    height: 42px;
    width: auto;
    object-fit: contain;
    transition: transform 0.2s ease;
}

.header-logo-img:hover {
    transform: scale(1.02);
}

.access-logo-img {
    height: 38px;
    max-width: 220px;
    width: auto;
    object-fit: contain;
}

.home-access-logo {
    width: 100%;
    height: auto;
    max-height: 110px;
    object-fit: contain;
    margin-bottom: 0;
    display: block;
}

.partners-access-logo {
    max-width: 95%;
    max-height: 80vh;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    margin: 0.5rem auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    border-radius: 8px;
    background: white;
}

.kpi-icon-img {
    width: 52px;
    height: 52px;
    object-fit: contain;
    flex-shrink: 0;
}


.nexus-logo-title {
    font-weight: 800;
    font-size: 1.2rem;
    letter-spacing: 0.05em;
    color: #38BDF8;
}

.nexus-logo-sub {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    color: #F1F5F9;
}

.access-branding {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.access-text {
    font-size: 1.6rem;
    font-weight: 900;
    color: #005599;
    letter-spacing: 0.05em;
}

.btn-login-sm {
    background-color: var(--pbi-navy);
    color: white;
    border: none;
    padding: 0.4rem 0.9rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-login-sm:hover {
    background-color: var(--pbi-blue);
}

/* Page View Routing */
.page-view {
    display: none;
    width: 100%;
    min-height: calc(100vh - 68px - 50px);
    padding: 0.75rem 0;
}

.page-view.active {
    display: block;
}

/* =================================================================== */
/* 1. HOME SCREEN STYLES                                               */
/* =================================================================== */
.home-layout {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(280px, 1fr);
    gap: 1rem;
    background: white;
    border: 1px solid var(--pbi-border);
    border-left: 0;
    border-right: 0;
    border-radius: 0;
    min-height: calc(100vh - 68px - 50px - 1.5rem);
    padding: 1rem 1.25rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    box-sizing: border-box;
}

.home-narrative {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.home-narrative h2 {
    font-size: 1.45rem;
    color: var(--pbi-navy);
    margin-bottom: 0.1rem;
}

.home-subtitle {
    font-size: 0.98rem;
    font-weight: 700;
    color: #334155;
    margin-bottom: 0.4rem;
}

.home-narrative p {
    color: #475569;
    font-size: 0.92rem;
    line-height: 1.3;
    margin-bottom: 0.35rem;
}

.home-feature-list {
    margin: 0.4rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.feature-item {
    display: flex;
    gap: 0.5rem;
    background-color: #F8FAFC;
    border-left: 4px solid var(--pbi-blue);
    padding: 0.4rem 0.6rem;
    border-radius: 0 6px 6px 0;
    align-items: flex-start;
}

.feature-icon {
    font-size: 1.15rem;
    line-height: 1.2;
}

.feature-item h4 {
    color: var(--pbi-navy);
    font-size: 0.96rem;
    font-weight: 700;
    margin-bottom: 0.1rem;
}

.feature-item p {
    font-size: 0.88rem;
    line-height: 1.25;
    margin-bottom: 0;
}

.data-limitations {
    background: #EFF6FF;
    border: 1px solid #BFDBFE;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    margin-bottom: 0.35rem;
}

.data-limitations h3, .data-limitations h4 {
    color: var(--pbi-navy);
    font-size: 0.96rem;
    font-weight: 700;
    margin-bottom: 0.1rem;
}

.data-limitations p {
    font-size: 0.88rem;
    line-height: 1.25;
    margin-bottom: 0;
}
.data-limitations p + p {
    margin-top: 0.35rem;
}

.feedback-box {
    font-size: 0.88rem;
    margin-top: 0.2rem;
}

/* Home Right Blue Card Panel */
.home-menu-panel {
    background-color: var(--pbi-navy);
    color: white;
    padding: 1.15rem;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.home-menu-panel h3 {
    font-size: 1.18rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: #E2E8F0;
}

.dashboard-menu-cards {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.menu-card-btn {
    background-color: white;
    color: var(--pbi-navy);
    border: none;
    padding: 0.9rem 0.85rem;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.98rem;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    transition: transform 0.2s, background 0.2s;
}

.menu-card-btn:hover {
    transform: translateY(-2px);
    background-color: #F0F9FF;
}

.access-partner-footer {
    margin-top: 1rem;
    border-top: 1px solid rgba(255,255,255,0.2);
    padding-top: 0.65rem;
}

.access-partner-footer h2 {
    font-size: 2.3rem;
    font-weight: 900;
    letter-spacing: 0.05em;
    color: white;
}

.view-header-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    background: white;
    padding: 0.6rem 1rem;
    border-radius: 6px;
    border: 1px solid var(--pbi-border);
}

.view-header-toggle h2 {
    font-size: 1.2rem;
    color: var(--pbi-navy);
    font-weight: 700;
}

.sub-tab-buttons {
    display: flex;
    background: #E2E8F0;
    padding: 2px;
    border-radius: 4px;
}

.btn-subtab {
    background: transparent;
    border: none;
    padding: 0.35rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #64748B;
    cursor: pointer;
    border-radius: 3px;
}

.btn-subtab.active {
    background: var(--pbi-navy);
    color: white;
}


/* =================================================================== */
/* 2. KPI CARD BARS (7 & 6 Cards)                                      */
/* =================================================================== */
.kpi-bar-7 {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.5rem;
    margin-bottom: 0;
    width: 100%;
}

.kpi-card-7 {
    background-color: var(--pbi-navy);
    color: white;
    padding: 0.7rem 0.65rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
    min-width: 0;
    min-height: 88px;
    overflow: hidden;
}

.kpi-icon-img {
    width: 52px;
    height: 52px;
    object-fit: contain;
    flex-shrink: 0;
}

.kpi-text-7 h3 {
    font-size: var(--kpi-value-size, 1.45rem);
    font-weight: 800;
    color: white;
    line-height: 1.1;
    margin: 0 0 2px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kpi-text-7 span {
    font-size: 0.72rem;
    color: #94A3B8;
    line-height: 1.15;
    overflow-wrap: anywhere;
}

.kpi-bar-6 {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.5rem;
    margin-bottom: 0;
    width: 100%;
}

.kpi-card-6 {
    background-color: var(--pbi-navy);
    color: white;
    padding: 0.7rem 0.65rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
    min-width: 0;
    min-height: 88px;
    overflow: hidden;
}

.kpi-text-6 {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.kpi-text-6 h3 {
    font-size: var(--kpi-value-size, 1.55rem);
    font-weight: 800;
    color: white;
    line-height: 1.1;
    margin: 0 0 2px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kpi-text-6 span {
    font-size: 0.72rem;
    color: #94A3B8;
    line-height: 1.15;
    overflow-wrap: anywhere;
}

/* =================================================================== */
/* 3. SNAPSHOT GRID & MAPS                                             */
/* =================================================================== */
.dashboard-grid-2col {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) minmax(0, 2fr);
    gap: 0.85rem;
    margin-bottom: 0.5rem;
    min-height: 250px; /* modified */
}

.map-container-card {
    background: white;
    border: 1px solid var(--pbi-border);
    border-radius: 6px;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    height: 100%;
    position: relative;
}

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

.map-container-card .card-header-bar {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.35rem;
}

.card-header-bar h4,
.map-container-card h4,
.chart-box h4 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--pbi-navy);
}

.map-legend-inline {
    font-size: 0.85rem;
    color: #64748B;
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

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

.dot-pink { background-color: var(--color-conflict-horiz); }
.dot-purple { background-color: var(--color-conflict-vert); }
.dot-blue { background-color: var(--color-natural-hazard); }
.dot-green { background-color: var(--color-human-induced); }

.map-frame {
    width: 100%;
    height: 100%;
    min-height: 250px; /* modified */
    border-radius: 4px;
    border: 1px solid #CBD5E1;
    overflow: hidden;
    background-color: #aad3df;
}

/* ── LEAFLET TILE SEAM / WHITE LINES FIX ─────────────────────────────────────── */
/* 1. Eliminate subpixel rounding gaps and seams between raster map tiles */
.leaflet-tile {
    border: none !important;
    outline: none !important;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.leaflet-tile-container img.leaflet-tile,
.map-frame .leaflet-tile-container img {
    /* 0.5px subpixel dilation creates a seamless micro-overlap between adjacent tiles */
    width: 256.5px !important;
    height: 256.5px !important;
    max-width: none !important;
}

/* 2. Match container background to OpenStreetMap ocean color (#aad3df) so any micro-gap is invisible */
.map-frame,
.leaflet-container {
    background: #aad3df !important;
    background-color: #aad3df !important;
}

.charts-2x2-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
    min-height: 250px; /* modified */
}

.chart-box {
    background: white;
    border: 1px solid var(--pbi-border);
    border-radius: 6px;
    padding: 0.75rem;
    min-height: 250px; /* modified */
}

.chart-box h4 {
    margin-bottom: 0.4rem;
}

.echart-box {
    width: 100%;
    height: 190px;
    min-height: 250px; /* modified */
}

/* Power BI Bottom Filter Bar */
.pbi-filter-bar {
    background: white;
    border: 1px solid var(--pbi-border);
    border-radius: 6px;
    padding: 0.6rem 1rem;
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.pbi-filter {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.pbi-filter label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--pbi-navy);
}

.pbi-filter select {
    padding: 0.25rem 0.5rem;
    border: 1px solid #CBD5E1;
    border-radius: 4px;
    font-size: 0.98rem;
    background: #F8FAFC;
    color: var(--pbi-text);
}

.date-inputs {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.date-inputs input {
    padding: 0.2rem 0.4rem;
    border: 1px solid #CBD5E1;
    border-radius: 4px;
    font-size: 0.95rem;
}

/* =================================================================== */
/* 4. TREND VIEW LAYOUT                                                */
/* =================================================================== */
.trend-top-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.toggle-group {
    display: flex;
    background: var(--pbi-navy);
    border-radius: 4px;
    padding: 2px;
}

.btn-toggle {
    background: transparent;
    border: none;
    color: #94A3B8;
    padding: 0.4rem 0.8rem;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 3px;
}

.btn-toggle.active {
    background: white;
    color: var(--pbi-navy);
}

.flex-grow {
    flex-grow: 1;
    margin-bottom: 0;
}

.trend-grid-layout {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.trend-mid-col, .trend-right-col {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

/* =================================================================== */
/* 5. PARTNERS PAGE STYLES                                             */
/* =================================================================== */
.partners-container {
    background: white;
    border: 1px solid var(--pbi-border);
    border-radius: 8px;
    padding: 2.5rem;
    text-align: center;
}

.partners-top-nav {
    text-align: left;
    margin-bottom: 1rem;
}

.btn-back-circle {
    background: #F1F5F9;
    border: 1px solid #CBD5E1;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
    cursor: pointer;
}

.eu-donor-header {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.eu-flag-box {
    font-size: 3rem;
}

.eu-text {
    text-align: left;
}

.eu-text h3 {
    font-size: 1.2rem;
    color: var(--pbi-navy);
    font-weight: 700;
}

.eu-text h4 {
    font-size: 1.1rem;
    color: var(--pbi-blue);
    font-weight: 600;
}

.access-main-title h1 {
    font-size: 4.1rem;
    font-weight: 900;
    color: #005599;
    letter-spacing: 0.05em;
}

.access-main-title p {
    max-width: 700px;
    margin: 0.5rem auto 2.5rem;
    color: #475569;
    font-size: 1.05rem;
    line-height: 1.5;
}

.partner-logos-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1rem;
    margin-top: 2rem;
}

.partner-card {
    background: #F8FAFC;
    border: 1px solid #E2E8F0;
    border-radius: 6px;
    padding: 1rem 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 70px;
}

.partner-badge {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--pbi-navy);
}

.partner-badge.green { color: #16A34A; }
.partner-badge.orange { color: #EA580C; }
.partner-badge.teal { color: #0D9488; }
.partner-badge.blue { color: #2563EB; }
.partner-badge.darkgreen { color: #15803D; }
.partner-badge.purple { color: #9333EA; }
.partner-badge.lime { color: #65A30D; }
.partner-badge.oxfam { color: #16A34A; }
.partner-badge.yellow { color: #D97706; }
.partner-badge.plan { color: #0284C7; }
.partner-badge.red { color: #DC2626; }
.partner-badge.cyan { color: #06B6D4; }
.partner-badge.women { color: #DB2777; }

/* =================================================================== */
/* 6. POTENTIAL IMPACT STYLES                                          */
/* =================================================================== */
.impact-grid-layout {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(240px, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    width: 100%;
    box-sizing: border-box;
}

.impact-table-card {
    background: white;
    border: 1px solid var(--pbi-border);
    border-radius: 6px;
    padding: 0.75rem;
    min-width: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}

.impact-table-card h3, .impact-table-card h4 {
    font-size: 0.95rem;
    color: var(--pbi-navy);
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.table-scroll {
    overflow: auto;
    max-height: calc(100vh - 68px - 50px - 56px - 1.5rem - 88px - 0.5rem - 60px);
}

.impact-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.impact-data-table th {
    background: var(--pbi-navy);
    color: white;
    padding: 0.55rem 0.65rem;
    text-align: left;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 5;
    font-weight: 600;
    letter-spacing: 0.02em;
    border-bottom: 2px solid #002244;
}

.impact-data-table td {
    padding: 0.45rem 0.65rem;
    border-bottom: 1px solid #E2E8F0;
    color: #1E293B;
    vertical-align: middle;
}

.impact-data-table tbody tr:nth-child(even) {
    background-color: #F8FAFC;
}

.impact-data-table tbody tr:hover {
    background-color: #F1F5F9;
}

.impact-control-bar {
    background: white;
    border: 1px solid var(--pbi-border);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tcws-selector-box {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.tcws-selector-box label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--pbi-navy);
}

.tcws-selector-box select {
    padding: 0.3rem 0.6rem;
    border: 1px solid #CBD5E1;
    border-radius: 4px;
    font-size: 0.9rem;
}

.impact-action-buttons {
    display: flex;
    gap: 0.5rem;
}

.btn-pbi {
    background-color: var(--pbi-navy);
    color: white;
    border: none;
    padding: 0.45rem 0.85rem;
    font-size: 0.88rem;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
}

.btn-pbi-clear {
    background-color: #64748B;
    color: white;
    border: none;
    padding: 0.45rem 0.85rem;
    font-size: 0.88rem;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
}

/* =================================================================== */
/* 7. BOTTOM POWER BI TAB NAV                                          */
/* =================================================================== */
.pbi-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--pbi-navy-dark);
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    z-index: 1000;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.2);
}

.pbi-tab {
    flex: 1 1 160px;
    background: #0B3C5D;
    color: #94A3B8;
    border: none;
    padding: 0.6rem 1.5rem;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
}

.pbi-tab:hover {
    color: white;
    background: #005599;
}

.pbi-tab.active {
    background: #EAEFF5;
    color: var(--pbi-navy);
    font-weight: 800;
}

.kpi-bar-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-bottom: 0;
}

.subpage-grid {
    display: grid;
    grid-template-columns: minmax(210px, 240px) minmax(0, 1fr);
    gap: 0.5rem;
    align-items: stretch;
    margin-bottom: 0.5rem;
    min-height: calc(100vh - 68px - 50px - 56px - 1.5rem);
}

.sidebar-filter-panel {
    background: white;
    border: 1px solid var(--pbi-border);
    border-radius: 6px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    position: sticky;
    top: 1rem;
    align-self: stretch;
    height: calc(100vh - 68px - 50px - 56px - 1.5rem);
    min-height: 250px; /* modified */
    overflow-y: auto;
}

.sidebar-filter-panel h3, .sidebar-filter-panel h4 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--pbi-navy);
    border-bottom: 1px solid #E2E8F0;
    padding-bottom: 0.4rem;
    margin-bottom: 0.15rem;
}

.s-filter {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.s-filter label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--pbi-navy);
}

.s-filter select {
    padding: 0.35rem 0.5rem;
    border: 1px solid #CBD5E1;
    border-radius: 4px;
    font-size: 0.88rem;
    background: #F8FAFC;
    color: var(--pbi-text);
    width: 100%;
}

.s-filter input[type="date"],
.s-filter .date-input {
    padding: 0.38rem 0.5rem;
    border: 1px solid #CBD5E1;
    border-radius: 4px;
    font-size: 0.88rem;
    background: #F8FAFC;
    color: var(--pbi-text);
    width: 100%;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    cursor: pointer;
    box-sizing: border-box;
}

.s-filter input[type="date"]:focus,
.s-filter .date-input:focus {
    border-color: var(--pbi-navy, #003366);
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 51, 102, 0.15);
    background: #FFFFFF;
}

.trend-date-presets {
    display: flex;
    gap: 0.3rem;
    margin-top: 0.15rem;
    margin-bottom: 0.25rem;
}

.trend-date-presets .btn-preset {
    flex: 1;
    padding: 0.25rem 0.3rem;
    font-size: 0.74rem;
    font-weight: 600;
    border: 1px solid #CBD5E1;
    border-radius: 4px;
    background: #F1F5F9;
    color: var(--pbi-navy);
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
}

.trend-date-presets .btn-preset:hover {
    background: #E2E8F0;
    border-color: #94A3B8;
}

.trend-date-presets .btn-preset.active {
    background: var(--pbi-navy, #003366);
    color: #FFFFFF;
    border-color: var(--pbi-navy, #003366);
}

.sidebar-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: auto;
    padding-top: 0.5rem;
}

.btn-pbi-nav {
    background-color: var(--pbi-navy);
    color: white;
    border: none;
    padding: 0.5rem 0.75rem;
    font-size: 0.88rem;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s;
}

.btn-pbi-nav:hover {
    background-color: var(--pbi-blue);
}

.subpage-main-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 250px; /* modified */
    min-width: 0;
}

@media (min-width: 901px) {
    #view-impact-tc .subpage-main-content,
    #view-impact-eq .subpage-main-content,
    #view-impact-drought .subpage-main-content {
        min-height: calc(100vh - 68px - 50px - 56px - 1.5rem);
    }

    #view-impact-tc .impact-grid-layout,
    #view-impact-eq .impact-grid-layout,
    #view-impact-drought .impact-grid-layout {
        flex: 1;
        min-height: 250px; /* modified */
    }

    #view-impact-tc .impact-table-card,
    #view-impact-eq .impact-table-card,
    #view-impact-drought .impact-table-card,
    #view-impact-tc .map-container-card,
    #view-impact-eq .map-container-card,
    #view-impact-drought .map-container-card {
        min-height: 250px; /* modified */
        height: 100%;
    }

    #view-impact-tc .table-scroll,
    #view-impact-eq .table-scroll,
    #view-impact-drought .table-scroll {
        flex: 1;
        min-height: 250px; /* modified */
    }

    #view-impact-tc .map-frame,
    #view-impact-eq .map-frame,
    #view-impact-drought .map-frame {
        flex: 1;
        height: 100%;
        min-height: 250px; /* modified */
        overflow: hidden;
    }
}

#view-impact-tc .impact-grid-layout,
#view-impact-eq .impact-grid-layout,
#view-impact-drought .impact-grid-layout {
    height: calc(100vh - 68px - 50px - 56px - 1.5rem - 88px - 0.5rem);
    flex-shrink: 0;
}

#subview-snapshot .dashboard-grid-2col,
#view-trend .dashboard-grid-2col {
    height: calc(100vh - 68px - 50px - 56px - 1.5rem - 88px - 0.5rem);
    flex-shrink: 0;
}

#view-trend .map-container-card,
#view-trend .charts-2x2-grid,
#view-trend .chart-box,
#view-rapid-response .map-container-card,
#view-rapid-response .subpage-charts-col,
#view-rapid-response .chart-box {
    min-height: 250px; /* modified */
}

#subview-snapshot .map-frame,
#view-trend .map-frame,
#view-impact-tc .map-frame,
#view-impact-eq .map-frame,
#view-impact-drought .map-frame,
#view-rapid-response .map-frame {
    height: 100%;
    overflow: hidden;
}

#subview-snapshot .chart-box,
#view-trend .chart-box,
#view-rapid-response .chart-box {
    display: flex;
    flex-direction: column;
    min-height: 300px;
}

#subview-snapshot .echart-box,
#view-trend .echart-box,
#view-rapid-response .echart-box {
    flex: 1;
    height: auto;
    min-height: 250px;
}

#view-rapid-response .rrm-main-grid {
    flex: 1;
}

.rrm-main-grid {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) minmax(0, 2fr);
    gap: 0.5rem;
}

.subpage-charts-col {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 250px; /* modified */
}

.subpage-charts-col .chart-box {
    flex: 1;
}

.wgq-container {
    background: white;
    border: 1px solid var(--pbi-border);
    border-radius: 8px;
    padding: 1.5rem;
    position: relative;
}

.wgq-header {
    margin-bottom: 1rem;
}

.wgq-header h2 {
    font-size: 1.35rem;
    color: var(--pbi-navy);
    margin-bottom: 0.25rem;
}

.wgq-header p {
    font-size: 0.95rem;
    color: #64748B;
}

.wgq-action-bar {
    margin-top: 1.5rem;
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* RILHub Embed Optimization */
html, body {
    width: 100%;
    height: 100%;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.6);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal.active { display: flex; }

.modal-content {
    background: white;
    border-radius: 8px;
    padding: 2rem;
    width: 100%;
    max-width: 400px;
    position: relative;
}

.close-btn {
    position: absolute;
    top: 1rem; right: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
}

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.9rem; margin-bottom: 0.25rem; font-weight: 600; }
.form-group input { width: 100%; padding: 0.5rem; border: 1px solid #CBD5E1; border-radius: 4px; }
.btn-primary { background-color: var(--pbi-navy); color: white; border: none; padding: 0.6rem; border-radius: 4px; width: 100%; font-weight: 700; cursor: pointer; }

/* Multi-Select Custom Styling */
.ms-wrapper {
    position: relative;
    width: 100%;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.ms-trigger {
    width: 100%;
    padding: 0.45rem 0.6rem;
    border: 1px solid #CBD5E1;
    border-radius: 4px;
    background-color: white;
    font-size: 0.9rem;
    color: #1E293B;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    text-align: left;
    box-sizing: border-box;
    min-height: 33px;
}

.ms-trigger:hover, .ms-trigger:focus {
    border-color: #003366;
    outline: none;
}

.ms-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
    max-width: 90%;
}

.ms-badge {
    background: #003366;
    color: white;
    font-size: 0.8rem;
    font-weight: 700;
    border-radius: 10px;
    padding: 1px 6px;
    margin-left: 4px;
}

.ms-panel {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1500;
    background: white;
    border: 1px solid #CBD5E1;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: none;
    flex-direction: column;
    max-height: 250px;
    overflow: hidden;
}

.ms-panel.open {
    display: flex;
}

.ms-header {
    padding: 6px 8px;
    background: #F1F5F9;
    border-bottom: 1px solid #E2E8F0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ms-search {
    width: 100%;
    padding: 3px 6px;
    font-size: 0.85rem;
    border: 1px solid #CBD5E1;
    border-radius: 3px;
    box-sizing: border-box;
}

.ms-all-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #003366;
    cursor: pointer;
    user-select: none;
}

.ms-list {
    overflow-y: auto;
    max-height: 180px;
    padding: 2px 0;
}

.ms-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    font-size: 0.88rem;
    color: #334155;
    cursor: pointer;
    transition: background 0.12s ease;
    user-select: none;
}

.ms-item:hover {
    background: #E2E8F0;
    color: #003366;
}

.ms-item input[type="checkbox"] {
    cursor: pointer;
    accent-color: #003366;
}

/* =================================================================== */
/* 7. GOVERNMENT SOURCES VIEW STYLES                                   */
/* =================================================================== */
.gov-source-banner {
    background-color: var(--pbi-navy);
    background: linear-gradient(135deg, #00263E 0%, #003366 100%);
    color: white;
    border-radius: 8px;
    padding: 0.85rem 1.25rem;
    margin-bottom: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 38, 62, 0.15);
}

.gov-badge-header {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.gov-shield-icon {
    font-size: 1.8rem;
    background: rgba(255, 255, 255, 0.15);
    padding: 6px 12px;
    border-radius: 8px;
    flex-shrink: 0;
}

.gov-badge-header h4 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: #FFFFFF;
}

.gov-badge-header p {
    margin: 3px 0 0 0;
    font-size: 0.92rem;
    color: #E2E8F0;
    line-height: 1.35;
}

.kpi-bar-5 {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
    margin-bottom: 0;
}

.kpi-card-5 {
    background: white;
    border: 1px solid #E2E8F0;
    border-radius: 8px;
    padding: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

.kpi-text-5 h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 800;
    color: #003366;
}

.kpi-text-5 span {
    font-size: 0.82rem;
    color: #64748B;
    font-weight: 600;
}

.gov-tag-badge {
    background: #E0F2FE;
    color: #0369A1;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
    border: 1px solid #BAE6FD;
}

.rrm-link-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #EFF6FF;
    color: #1D4ED8;
    border: 1px solid #BFDBFE;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.82rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease-in-out;
    white-space: nowrap;
}

.rrm-link-badge:hover {
    background: #1D4ED8;
    color: white;
    border-color: #1D4ED8;
    box-shadow: 0 2px 4px rgba(29, 78, 216, 0.25);
    transform: translateY(-1px);
}

.no-rrm-badge {
    color: #94A3B8;
    font-size: 0.85rem;
    display: inline-block;
    padding: 0.1rem 0.3rem;
}

/* Global Power BI / ACCESS Loading Screen Overlay */
.app-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.45);
    z-index: 999999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease-out;
}

.app-loading-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.loading-card {
    background: rgba(255, 255, 255, 0.98);
    padding: 1.75rem 2.5rem;
    border-radius: 14px;
    box-shadow: 0 20px 35px -10px rgba(0, 38, 62, 0.25), 0 1px 3px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.85rem;
    border: 1px solid #E2E8F0;
    transform: scale(0.95);
    transition: transform 0.2s ease-out;
}

.app-loading-overlay.active .loading-card {
    transform: scale(1);
}

.spinner-nexus {
    width: 44px;
    height: 44px;
    border: 4px solid #E2E8F0;
    border-top: 4px solid #003366;
    border-right: 4px solid #EA580C;
    border-radius: 50%;
    animation: spinNexus 0.75s linear infinite;
}

@keyframes spinNexus {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    color: #00263E;
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: -0.01em;
}

.loading-subtext {
    color: #64748B;
    font-size: 0.98rem;
    font-weight: 500;
}

/* Power BI Chart Focus Mode / Maximize Modal */
.chart-box-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.35rem;
}

.chart-box-header h3, .chart-box-header h4 {
    margin: 0;
}

.btn-chart-focus {
    background: #F1F5F9;
    border: 1px solid #CBD5E1;
    color: #475569;
    border-radius: 4px;
    padding: 2px 7px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.btn-chart-focus:hover {
    background: var(--pbi-navy);
    color: white;
    border-color: var(--pbi-navy);
    transform: translateY(-1px);
}

.btn-map-focus,
.btn-table-export {
    position: absolute;
    top: 0.65rem;
    right: 0.75rem;
    z-index: 20;
}

.map-container-card > h4,
.map-container-card > .card-header-bar,
.impact-table-card > h4,
.wgq-header {
    padding-right: 6rem;
}

.chart-focus-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(6px);
    z-index: 99999;
    justify-content: center;
    align-items: center;
    padding: 1.5rem;
    box-sizing: border-box;
}

.chart-focus-modal.active {
    display: flex;
}

.chart-focus-card {
    background: white;
    border-radius: 12px;
    width: 94vw;
    height: 88vh;
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.chart-focus-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.85rem;
    padding-bottom: 0.65rem;
    border-bottom: 2px solid #F1F5F9;
}

.chart-focus-header h3 {
    font-size: 1.35rem;
    color: var(--pbi-navy);
    font-weight: 800;
    margin: 0;
}

.btn-close-focus {
    background: #DC2626;
    color: white;
    border: none;
    padding: 0.45rem 1rem;
    border-radius: 6px;
    font-weight: 700;
    font-size: 1.05rem;
    cursor: pointer;
    transition: background 0.15s ease;
}

.btn-close-focus:hover {
    background: #B91C1C;
}

.chart-focus-body {
    flex: 1;
    width: 100%;
    min-height: 250px; /* modified */
}

.map-frame-focused {
    flex: 1;
    height: 100% !important;
    min-height: 250px; /* modified */
}

.map-focus-placeholder {
    visibility: hidden;
}

@media (max-width: 1200px) {
    .kpi-bar-7 {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }

    .kpi-bar-6 {
        grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
    }

    .home-layout {
        grid-template-columns: 1fr;
    }

    .charts-2x2-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }

    .map-frame {
        height: 360px;
    }

    #subview-snapshot .dashboard-grid-2col,
    #view-trend .dashboard-grid-2col {
        flex-basis: auto;
    }

    #subview-snapshot .map-frame,
    #view-trend .map-frame,
    #view-rapid-response .map-frame {
        height: 360px;
    }

    #subview-snapshot .echart-box,
    #view-trend .echart-box,
    #view-rapid-response .echart-box {
        height: 240px;
    }
}

@media (max-width: 900px) {
    body.powerbi-theme {
        padding-bottom: calc(58px + env(safe-area-inset-bottom, 8px));
    }

    /* App Header - Keep compact single row */
    .app-header {
        align-items: center;
        flex-direction: row !important;
        justify-content: space-between;
        padding: 0.5rem 0.85rem;
        min-height: 52px;
        gap: 0.5rem;
    }

    .header-logo-img {
        height: 32px;
        width: auto;
        max-width: 140px;
    }

    .access-branding {
        display: flex;
        align-items: center;
        gap: 0.6rem;
        flex-wrap: nowrap;
    }

    .access-logo-img {
        height: 24px;
        width: auto;
        max-width: 110px;
    }

    .btn-login-sm {
        padding: 0.35rem 0.7rem;
        font-size: 0.78rem;
        white-space: nowrap;
    }

    /* Bottom Nav Bar - Single sleek swipeable horizontal row */
    .pbi-bottom-nav {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        height: 52px;
        min-height: 52px;
        align-items: center;
        padding: 0 4px;
        box-sizing: border-box;
    }

    .pbi-bottom-nav::-webkit-scrollbar {
        display: none;
    }

    .pbi-tab {
        flex: 0 0 auto !important;
        white-space: nowrap !important;
        font-size: 0.82rem !important;
        padding: 0.55rem 0.9rem !important;
        height: 42px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 4px;
    }

    .view-header-toggle,
    .impact-control-bar,
    .wgq-action-bar {
        align-items: stretch;
        flex-direction: column;
        gap: 0.65rem;
    }

    .sub-tab-buttons,
    .impact-action-buttons {
        flex-wrap: wrap;
    }

    .subpage-grid {
        grid-template-columns: 1fr !important;
        min-height: 0 !important;
        height: auto !important;
        align-items: start !important;
    }

    /* Reset desktop viewport height locks so elements flow naturally */
    .dashboard-grid-2col,
    .trend-grid-layout,
    .impact-grid-layout,
    .rrm-main-grid {
        grid-template-columns: 1fr;
        height: auto !important;
        min-height: 0 !important;
    }

    #subview-snapshot .dashboard-grid-2col,
    #view-trend .dashboard-grid-2col,
    #view-rapid-response .rrm-main-grid,
    #view-impact-tc .impact-grid-layout,
    #view-impact-eq .impact-grid-layout,
    #view-impact-drought .impact-grid-layout {
        height: auto !important;
        min-height: 0 !important;
        flex-basis: auto !important;
    }

    .charts-2x2-grid {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto !important;
        height: auto !important;
        gap: 0.65rem;
    }

    .chart-box-header,
    .card-header-bar {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.35rem;
    }

    .map-legend-inline {
        flex-wrap: wrap;
    }

    /* Collapsible / 2-column sidebar filters on mobile & tablet */
    .mobile-filter-toggle {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        background: var(--pbi-navy);
        color: #fff;
        border: none;
        padding: 0.6rem 0.85rem;
        border-radius: 6px;
        font-weight: 700;
        font-size: 0.86rem;
        cursor: pointer;
        margin-bottom: 0.35rem;
        grid-column: 1 / -1;
    }

    .sidebar-filter-panel {
        position: static;
        height: auto !important;
        min-height: 0 !important;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.55rem;
        padding: 0.75rem;
        align-self: auto;
        overflow: visible;
    }

    .sidebar-filter-panel h3 {
        display: none !important;
    }

    .sidebar-filter-panel.mobile-collapsed .s-filter,
    .sidebar-filter-panel.mobile-collapsed .sidebar-actions,
    .sidebar-filter-panel.mobile-collapsed .data-limitations,
    .sidebar-filter-panel.mobile-collapsed .feedback-box {
        display: none !important;
    }

    .sidebar-filter-panel.mobile-collapsed {
        display: block !important;
        padding: 0 !important;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        height: auto !important;
        min-height: 0 !important;
        margin-bottom: 0.35rem !important;
    }

    .sidebar-filter-panel .sidebar-actions,
    .sidebar-filter-panel .data-limitations,
    .sidebar-filter-panel .feedback-box {
        grid-column: 1 / -1;
    }

    /* Table headers & Export button */
    .btn-table-export {
        position: static !important;
    }

    .table-card-header {
        display: flex;
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.65rem !important;
    }

    .table-card-header > div {
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    #gov-table-search {
        flex: 1;
        min-width: 130px;
        max-width: 100% !important;
        width: auto !important;
    }

    .table-scroll {
        width: 100%;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 640px) {
    body.powerbi-theme {
        padding-bottom: calc(56px + env(safe-area-inset-bottom, 8px));
    }

    .page-view {
        padding: 0.45rem;
    }

    .home-layout,
    .partners-container,
    .wgq-container {
        padding: 0.75rem;
    }

    .home-layout {
        grid-template-columns: 1fr !important;
        min-height: 0 !important;
    }

    .home-narrative h2 {
        font-size: 1.22rem !important;
    }

    .menu-card-btn {
        padding: 0.75rem 0.85rem !important;
    }

    /* 2-Column Responsive KPI Grid (No 700px single-column wall!) */
    .kpi-bar-7,
    .kpi-bar-6,
    .kpi-bar-5,
    .kpi-bar-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 0.45rem !important;
    }

    .kpi-bar-7 > :last-child {
        grid-column: 1 / -1;
    }

    .kpi-card-7,
    .kpi-card-6,
    .kpi-card-5,
    .kpi-card-4 {
        min-height: 64px !important;
        padding: 0.5rem 0.55rem !important;
        gap: 0.45rem !important;
    }

    .kpi-icon-img {
        width: 32px !important;
        height: 32px !important;
    }

    .kpi-text-7 h3,
    .kpi-text-6 h3,
    .kpi-text-5 h3,
    .kpi-text-4 h3 {
        font-size: 1.05rem !important;
        line-height: 1.15;
    }

    .kpi-text-7 span,
    .kpi-text-6 span,
    .kpi-text-5 span,
    .kpi-text-4 span {
        font-size: 0.63rem !important;
        line-height: 1.15;
    }

    .partner-logos-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.65rem !important;
    }

    /* Charts on mobile phones */
    .charts-2x2-grid {
        grid-template-columns: 1fr !important;
        gap: 0.65rem !important;
    }

    .chart-box {
        min-height: 280px !important;
        padding: 0.65rem !important;
    }

    .echart-box {
        height: 250px !important;
    }

    .map-frame {
        height: 280px !important;
    }

    #subview-snapshot .map-frame,
    #view-trend .map-frame,
    #view-rapid-response .map-frame {
        height: 280px !important;
    }

    #subview-snapshot .echart-box,
    #view-trend .echart-box,
    #view-rapid-response .echart-box {
        height: 250px !important;
    }

    .sidebar-actions .btn {
        width: 100%;
    }

    .s-filter label {
        font-size: 0.8rem;
    }

    .s-filter select,
    .s-filter input[type="date"],
    .ms-trigger {
        min-height: 38px;
        font-size: 0.88rem;
        padding: 0.35rem 0.5rem;
    }

    /* Modal dialogs */
    .modal-content {
        width: 92% !important;
        max-width: 360px !important;
        margin: 12vh auto !important;
        padding: 1.25rem !important;
        box-sizing: border-box;
    }
}
