/* ================================================================= */
/* MARYLAND PARCEL DASHBOARD THEME - REUSABLE STYLESHEET             */
/* ================================================================= */

/* 1. MASTER VARIABLES (Maryland State Colors) */
:root {
    --md-blue: #162e51;       
    --md-light-blue: #005ea2; 
    --md-border: #dee2e6;     
    --md-bg-light: #f8f9fa;   
    --md-hover: #f0f4f8;      
    --md-th-bg: #f4f6f9;      
}

/* 2. GLOBAL RESETS & TYPOGRAPHY */
html, body { height: 100%; width: 100%; margin: 0; padding: 0; overflow-x: hidden; background-color: #ffffff; }
body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; color: #212529; display: flex; flex-direction: column; }
.sp-dashboard-container { padding: 10px 20px; max-width: 1500px; margin: 0 auto; flex: 1; width: 100%; display: flex; flex-direction: column; box-sizing: border-box; min-height: 0; height: 100%; }

/* 3. ACCESSIBILITY UTILITIES */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; top: -1000px; left: -1000px; background: var(--md-blue); color: white; padding: 12px; z-index: 1000; font-weight: bold; text-decoration: none; }
.skip-link:focus { top: 0; left: 0; }
*:focus-visible { outline: 3px solid var(--md-light-blue); outline-offset: 2px; }

/* 4. HERO HEADER & FORMS */
.hero { margin-bottom: 15px; padding-bottom: 12px; border-bottom: 3px solid var(--md-light-blue); flex-shrink: 0; background: #fff; }
.eyebrow { margin: 0 0 6px; font-size: 0.8rem; font-weight: 700; color: var(--md-light-blue); text-transform: uppercase; letter-spacing: 0.5px; }
.hero h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 2.2rem; font-weight: 400; line-height: 1.2; color: #212529; }
.hero__lede { margin: 8px 0 0; font-size: 1.05rem; color: #555555; }

.global-filters-box { background-color: var(--md-bg-light); border: 1px solid var(--md-border); border-radius: 4px; padding: 12px 15px; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-bottom: 15px; flex-shrink: 0; }
.field { display: flex; flex-direction: column; gap: 4px; width: 100%; }
.usa-label { font-weight: 700; font-size: 0.9rem; color: #000000; margin: 0; }
.usa-select { width: 100%; padding: 6px 10px; font-size: 0.95rem; border: 1px solid #757575; border-radius: 4px; background-color: #ffffff; color: #212529; cursor: pointer; font-family: inherit; }
.usa-select:focus { outline: 2px solid var(--md-light-blue); outline-offset: 2px; }

/* 5. TABS & NAVIGATION */
.dashboard-tabs { display: flex; gap: 15px; margin-bottom: 10px; position: relative; z-index: 2; flex-shrink: 0; overflow-x: auto; align-items: center; }
.dashboard-tabs button { background: transparent; color: var(--md-light-blue); border: none; font-weight: 700; font-size: 0.95rem; cursor: pointer; padding: 8px 12px; transition: all 0.15s; white-space: nowrap; border-radius: 2px; }
.dashboard-tabs button[aria-pressed="true"] { background: var(--md-light-blue); color: #fff; }
.dashboard-tabs button:hover:not([aria-pressed="true"]) { text-decoration: underline; background: var(--md-hover); }

/* 6. STRUCTURAL PANELS & BUTTONS */
#dashboardContent { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.module-view { display: flex !important; flex-direction: column; flex: 1; min-height: 0; }
.module-view[style*="none"] { display: none !important; }

.unified-panel, .expandable-panel { background: #fff; border: 1px solid var(--md-border); border-radius: 4px; display: flex; flex-direction: column; flex: 1; min-height: 0; box-shadow: 0 2px 8px rgba(0,0,0,0.04); overflow: hidden; }

.module-toolbar-internal { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 15px; padding: 10px 15px; border-bottom: 1px solid var(--md-border); background: var(--md-bg-light); flex-shrink: 0; }
.module-toolbar-internal .panel-headings h2 { margin: 0; font-size: 1.25rem; font-weight: 700; color: #212529; }
.module-toolbar-internal .panel-headings .subtitle { color: #555; font-size: 0.85rem; margin-top: 2px; font-weight: 500;}

.toolbar-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.toolbar-controls .usa-select, .map-toolbar .usa-select { width: auto; min-width: 180px; padding: 6px 10px; }

.table-header-bar { display: flex; justify-content: space-between; align-items: center; padding: 8px 15px; border-bottom: 1px solid var(--md-border); background: var(--md-bg-light); flex-shrink: 0; }
.table-title-small { font-weight: 700; color: var(--md-blue); font-size: 0.95rem; }

.expand-btn { background: #fff; border: 1px solid var(--md-border); border-radius: 4px; padding: 6px 12px; font-size: 0.85rem; font-weight: 600; cursor: pointer; color: var(--md-blue); display: inline-flex; align-items: center; gap: 6px; transition: all 0.15s; white-space: nowrap; height: 32px; box-sizing: border-box;}
.expand-btn:hover { background: var(--md-hover); }
.download-btn { background-color: var(--md-light-blue); color: #ffffff; padding: 6px 12px; border-radius: 4px; font-weight: 600; font-size: 0.85rem; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; transition: all 0.15s; border: none; white-space: nowrap; height: 32px; box-sizing: border-box;}
.download-btn:hover { background-color: var(--md-blue); color: #ffffff; }

.is-fullscreen { position: fixed !important; top: 0; left: 0; right: 0; bottom: 0; width: 100vw !important; height: 100vh !important; z-index: 99999; margin: 0 !important; border-radius: 0 !important; background: #fff; display: flex; flex-direction: column; }

/* 7. DATA TABLES */
.table-responsive { width: 100%; flex: 1 1 auto; min-height: 0; overflow: auto; background: #fff; -webkit-overflow-scrolling: touch; position: relative; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.9rem; white-space: nowrap; }
#mainTable { min-width: 600px; } 

th, td { padding: 10px 15px; text-align: right; border-bottom: 1px solid var(--md-border); border-right: 1px solid var(--md-border); }
th:first-child, td:first-child { text-align: left; }
caption { display: none; } 

thead th { background-color: var(--md-th-bg); color: #212529; font-weight: 700; text-align: center; position: sticky; top: 0; z-index: 10; border-top: none; box-shadow: 0 1px 0 rgba(0,0,0,0.1); }
tbody th[scope="row"] { text-align: left; font-weight: 500; background: #ffffff; color: #212529; position: sticky; left: 0; z-index: 5; border-right: 2px solid var(--md-border); box-shadow: 2px 0 5px rgba(0,0,0,0.05); } 
thead th:first-child { position: sticky; left: 0; top: 0; z-index: 15; text-align: left; border-right: 2px solid var(--md-border); box-shadow: 2px 0 5px rgba(0,0,0,0.05); }

tbody tr:nth-child(even) td, tbody tr:nth-child(even) th[scope="row"] { background: var(--md-bg-light); }
tbody tr:hover td, tbody tr:hover th[scope="row"] { background-color: var(--md-hover); color: var(--md-blue); transition: background-color 0.1s ease; cursor: default; }
.row-level-0 th[scope="row"], .row-level-0 td { background-color: var(--md-hover) !important; font-weight: 700; color: var(--md-blue); }
.summary-row th[scope="row"], .summary-row td { background-color: var(--md-bg-light) !important; font-weight: 700; color: var(--md-blue); border-top: 2px solid var(--md-border); }

/* 8. LAYOUT SPLITS & CHART CARDS */
.map-toolbar { flex: none; display: flex; flex-direction: row; justify-content: space-between; align-items: center; padding: 10px 15px; margin-bottom: 15px; flex-wrap: wrap; gap: 15px; background: var(--md-bg-light); border: 1px solid var(--md-border); border-radius: 4px; }
.split-container { display: flex; flex-direction: row; gap: 15px; flex: 1; min-height: 0; }
.map-wrapper { flex: 0 0 60%; display: flex; flex-direction: column; min-width: 0; position: relative; padding: 0;} 
#mapContainer { flex: 1; min-height: 0; background: #e2e8f0; position: relative; overflow: hidden; border-radius: 4px; border: 1px solid var(--md-border); }

#mapControlsUI { position: absolute; top: 15px; left: 15px; background: rgba(255,255,255,0.95); padding: 10px 15px; border-radius: 4px; box-shadow: 0 2px 8px rgba(0,0,0,0.15); z-index: 50; pointer-events: none; border: 1px solid var(--md-border); }
#mapOverlayTitle { font-weight: 700; color: #212529; font-size: 1rem; line-height: 1.2; margin-bottom: 2px;}
#mapOverlaySubtitle { font-size: 0.8rem; color: #555; font-weight: 500; }

.charts-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; overflow-y: auto; padding: 20px; min-width: 0; flex: none; border-bottom: 1px solid var(--md-border); }
.chart-card { background: #ffffff; display: flex; flex-direction: column; min-height: 350px; min-width: 0; width: 100%; box-sizing: border-box; border: 1px solid var(--md-border); border-radius: 4px; padding: 15px; box-shadow: 0 1px 3px rgba(0,0,0,0.02);}
.chart-card.full-width { grid-column: span 2; }
.chart-card.compact-height { min-height: 220px; }
.chart-card h3 { margin: 0 0 5px 0; font-size: 1.1rem; color: #212529; text-align: left; font-weight: 700;}
.chart-card p.chart-sub { margin: 0 0 10px 0; font-size: 0.85rem; color: #666; }
.chart-container { flex: 1; position: relative; width: 100%; min-height: 150px;}

.interval-chart-panel { flex: none; height: 260px; display: flex; flex-direction: column; padding: 15px 20px; border-bottom: 1px solid var(--md-border); }
.interval-table-panel { flex: 1; display: flex; flex-direction: column; min-height: 0; background: #fff; }

/* 9. FOOTER */
.institutional-footer { background-color: var(--md-bg-light); border-top: 1px solid var(--md-border); padding: 10px 15px; flex-shrink: 0; font-size: 0.8rem; color: #555; line-height: 1.4; }
.institutional-footer p { margin: 2px 0; }
.institutional-footer p.bold-source { color: #212529; font-weight: 700; }
#loadingSpinner { text-align: center; padding: 40px 20px; font-size: 1.1rem; font-weight: 600; color: var(--md-blue); margin-top: 15px; flex: 1;}

/* 10. MOBILE OPTIMIZATIONS */
@media (max-width: 1024px) {
    html, body { height: auto; min-height: 100vh; overflow-x: hidden; }
    .sp-dashboard-container { height: auto; min-height: 100vh; }
    .dashboard-main-panel, .module-view { flex: none; height: auto; overflow: visible; }
    .split-container { flex-direction: column; overflow: visible; height: auto; flex: none;}
    .map-wrapper { flex: none; height: auto; margin-bottom: 15px; border: none; }
    #mapContainer { flex: none !important; height: 400px !important; }
    .expandable-panel, .unified-panel { flex: none; height: auto; }
    .table-responsive { min-height: 350px; }
    .interval-chart-panel { height: auto; min-height: 280px; }
    .interval-table-panel { flex: none; height: auto; }
}

@media (max-width: 768px) {
    .global-filters-box { grid-template-columns: 1fr; }
    .charts-grid { grid-template-columns: 1fr; padding: 15px; gap: 15px; min-width: 0; }
    .chart-card.full-width { grid-column: span 1; }
    .chart-card { min-height: 280px; padding: 15px; min-width: 0; }
    .map-toolbar, .module-toolbar-internal { flex-direction: column; align-items: stretch; }
    .map-toolbar .usa-select { width: 100%; }
    .toolbar-controls { width: 100%; flex-direction: column; align-items: stretch; }
    .toolbar-controls .usa-select { width: 100%; min-width: 0; }
    .toolbar-controls .expand-btn, .toolbar-controls .download-btn { width: 100%; justify-content: center; }
}