/* === FCC / USWDS Styling === */
body { font-family: 'Open Sans', Helvetica, Arial, sans-serif; color: #212529; background: #f1f1f1; font-size: 1.08rem; line-height: 1.6; }
.container-fluid { padding-left: 30px; padding-right: 30px; }


/* Page header — matches fcc.gov nav */
.page-header { background-color: rgb(19, 66, 139); background-image: url('bg-pattern-header.png'); background-repeat: repeat; background-size: auto; color: #fff; padding: 14px 0; margin: 0; border: 0; box-shadow: inset 0 -11px 30px 0 rgba(0,0,0,.3); position: relative; z-index: 10; font-family: 'Open Sans', Helvetica, Arial, sans-serif; }
.page-header .container-fluid { display: flex; align-items: center; position: relative; }
.page-header .fcc-logo { width: 150px; height: auto; flex-shrink: 0; }
.page-header h1 { margin: 0; font-size: 1.7rem; font-weight: 600; position: absolute; left: 50%; transform: translateX(-50%); white-space: nowrap; }
.page-header .data-date { font-size: 1.05rem; opacity: 0.85; margin-left: auto; }

/* Tabs */
.nav-tabs { border-bottom: 3px solid #13428b; margin-top: 0; background: #fff; }
.nav-tabs > li > a { color: #13418A; font-weight: 600; border: none; border-radius: 0; padding: 12px 24px; margin-right: 0; font-size: 1rem; }
.nav-tabs > li > a:hover { background: #e8f0fe; border: none; }
.nav-tabs > li.active > a,
.nav-tabs > li.active > a:hover,
.nav-tabs > li.active > a:focus { color: #fff; background: #13428b; border: none; }
.tab-content { background: #fff; border: 1px solid #ddd; border-top: none; min-height: 600px; }
.tab-pane { padding: 20px; }

/* KPI Cards */
.kpi-card { background: #13418A; color: #fff; border-radius: 4px; padding: 16px; text-align: center; margin-bottom: 15px; }
.kpi-card .kpi-label { font-size: 0.85rem; text-transform: uppercase; opacity: 0.85; margin-bottom: 4px; }
.kpi-card .kpi-value { font-size: 2rem; font-weight: 700; }
.kpi-card.kpi-secondary { background: #fff; color: #212121; border: 1px solid #ddd; }
.kpi-card.kpi-secondary .kpi-value { color: #13418A; }

/* Sidebar filters */
.filter-sidebar { background: #f9fafb; border-right: 1px solid #ddd; padding: 20px; }
.filter-sidebar h4 { font-size: 1.05rem; font-weight: 700; color: #13418A; margin-top: 0; margin-bottom: 15px; text-transform: uppercase; letter-spacing: 0.5px; }
.filter-group { margin-bottom: 20px; }
.filter-group label { font-weight: 600; font-size: 0.95rem; color: #333; display: block; margin-bottom: 4px; }
.filter-group input[type="date"] { width: 100%; padding: 6px 8px; border: 2px solid #13418A; border-radius: 3px; font-size: 0.95rem; }
.filter-group .checkbox label { font-weight: 400; font-size: 0.95rem; }
.filter-group select { width: 100%; padding: 6px 8px; border: 2px solid #13418A; border-radius: 3px; font-size: 0.95rem; }
.btn-reset { width: 100%; background: #fff; color: #13418A; border: 2px solid #13418A; border-radius: 3px; padding: 8px; font-weight: 600; cursor: pointer; }
.btn-reset:hover { background: #13418A; color: #fff; }

/* Charts */
.chart-panel { border: 1px solid #ddd; border-radius: 4px; padding: 15px; margin-bottom: 15px; background: #fff; }
.chart-panel h5 { font-size: 1.0rem; font-weight: 700; margin-top: 0; margin-bottom: 10px; color: #333; }
.chart-container { position: relative; width: 100%; height: 250px; }

/* Map */
#overview-map, #drilldown-map { height: 300px; border-radius: 4px; border: 1px solid #ddd; }
#drilldown-map { height: 200px; }

/* Drilldown */
.search-bar { margin-bottom: 20px; }
.search-bar .input-group { max-width: 100%; }
.search-bar .form-control { border: 2px solid #13418A; border-radius: 3px 0 0 3px; font-size: 1.05rem; height: 44px; }
.search-bar .btn-search { background: linear-gradient(to bottom, #1a5bb8, #13418A); color: #fff; border: 2px solid #0d2d6b; border-radius: 0 4px 4px 0; font-weight: 600; padding: 6px 22px; height: 44px; font-size: 1.05rem; cursor: pointer; box-shadow: 0 2px 4px rgba(0,0,0,.2); }
.search-bar .btn-search:hover { background: linear-gradient(to bottom, #13418A, #0d2d6b); box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.search-bar .btn-search:active { background: #0d2d6b; box-shadow: inset 0 2px 4px rgba(0,0,0,.3); }

.results-list { max-height: 600px; overflow-y: auto; border: 1px solid #ddd; border-radius: 4px; background: #fff; }
.result-card { padding: 12px 15px; border-bottom: 1px solid #eee; cursor: pointer; }
.result-card:hover { background: #f5f8ff; }
.result-card.active { background: #e8f0fe; border-left: 4px solid #13418A; }
.result-card .file-number { font-weight: 700; font-size: 1.0rem; color: #13418A; }
.result-card .applicant-name { font-size: 0.95rem; color: #555; }
.result-card .receipt-info { font-size: 0.85rem; color: #888; }

/* Trend cards */
.trend-card { background: #fff; border: 1px solid #e0e0e0; border-radius: 4px; padding: 10px 14px; margin-bottom: 10px; }
.trend-card .trend-label { font-size: 0.88rem; color: #555; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trend-card .trend-value { font-size: 1.2rem; font-weight: 700; }
.trend-card .trend-detail { font-size: 0.82rem; color: #888; margin-top: 2px; }
.trend-up { color: #ff253a; }
.trend-down { color: #2e8540; }
.trend-new { color: #13428b; }
.trend-flat { color: #aeb0b5; }

/* Status badges */
.badge-status { padding: 3px 8px; border-radius: 3px; font-size: 0.8rem; font-weight: 600; text-transform: uppercase; }
.badge-pending { background: #13418A; color: #fff; }
.badge-submitted { background: #4a90d9; color: #fff; }
.badge-assigned { background: #2f69b2; color: #fff; }
.badge-referred { background: #13418A; color: #fff; }
.badge-granted { background: #2e8540; color: #fff; }
.badge-denied { background: #ff253a; color: #fff; }
.badge-expired { background: #aeb0b5; color: #fff; }
.badge-open { background: #ffbe2e; color: #333; }
.badge-closed { background: #2e8540; color: #fff; }

/* Friday Report */
.fr-kpi-row { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.fr-kpi { flex: 1; min-width: 130px; background: #fff; border: 1px solid #e0e0e0; border-radius: 4px; padding: 12px 10px; text-align: center; }
.fr-kpi .fr-kpi-label { font-size: 0.8rem; text-transform: uppercase; color: #555; margin-bottom: 2px; letter-spacing: 0.02em; }
.fr-kpi .fr-kpi-value { font-size: 2.2rem; font-weight: 700; color: #13418A; line-height: 1.1; }
.fr-kpi .fr-kpi-sub { font-size: 0.85rem; color: #666; margin-top: 2px; }
.fr-kpi .fr-kpi-wow { font-size: 0.85rem; margin-top: 4px; }
.fr-section { margin-bottom: 20px; }
.fr-section h5 { font-size: 1.0rem; font-weight: 700; color: #333; margin-top: 0; margin-bottom: 12px; border-bottom: 2px solid #13418A; padding-bottom: 6px; }
.fr-pipeline-bar { display: flex; height: 28px; border-radius: 4px; overflow: hidden; margin: 10px 0; }
.fr-pipeline-bar .fr-seg { display: flex; align-items: center; justify-content: center; font-size: 0.8rem; font-weight: 600; color: #fff; }
.fr-week-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.fr-week-table th { background: #13428b; color: #fff; padding: 8px 12px; text-align: left; font-weight: 600; font-size: 0.85rem; }
.fr-week-table td { padding: 8px 12px; border-bottom: 1px solid #eee; }
.fr-week-table tr:hover { background: #f9fbff; }
.fr-week-header { background: #f1f1f1; font-size: 1.1rem; font-weight: 700; color: #13418A; padding: 12px 15px; border-radius: 4px 4px 0 0; border: 1px solid #ddd; border-bottom: none; margin-top: 15px; }
.fr-entity-compact th, .fr-entity-compact td { padding: 6px 8px; font-size: 0.85rem; }
.fr-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.fr-sortable:hover { background: #0d2d6b; }
.fr-sortable .fa { margin-left: 4px; opacity: 0.6; }

@media print {
  body { background: #fff !important; font-size: 10pt !important; }
  .page-header, .nav-tabs, .filter-sidebar, #csv-overlay,
  #btn-save-datajs, #btn-diagnostics, #diagnostics-panel,
  #btn-export-friday, #btn-print-friday, #btn-export-filtered,
  #btn-print-overview, #preset-group,
  #overview-map { display: none !important; }
  .container-fluid { padding: 0 !important; }
  .tab-content { border: none !important; }
  .tab-pane { display: none !important; }
  #overview { display: block !important; padding: 10px 0 !important; }
  #overview-print-header { display: block !important; }
  .col-md-9, .col-md-12, .col-sm-8, .col-sm-12 { width: 100% !important; float: none !important; }
  .kpi-card { break-inside: avoid; page-break-inside: avoid; }
  .chart-panel { break-inside: avoid; page-break-inside: avoid; }
  .chart-container { height: 220px !important; }
  #kpi-cards-row { margin-bottom: 10px !important; }
  .col-md-8, .col-md-4 { width: 50% !important; }
  #overview-map + .chart-panel,
  #overview-map ~ .chart-panel { width: 100% !important; }
  body.print-friday #overview { display: none !important; }
  body.print-friday #friday-report { display: block !important; padding: 0 !important; }
  #fr-print-header { display: none; }
  body.print-friday #fr-print-header { display: block !important; }
  body.print-friday #overview-print-header { display: none !important; }
  .fr-kpi-row { gap: 8px !important; }
  .fr-kpi { min-width: 0 !important; padding: 10px !important; }
  .fr-section { break-inside: avoid; page-break-inside: avoid; }
}

/* Timeline — fork-join */
.timeline-container { border: 1px solid #ddd; border-radius: 4px; padding: 20px; margin-bottom: 15px; background: #fff; }
.timeline-container h5 { font-size: 1.0rem; font-weight: 700; margin-top: 0; margin-bottom: 15px; }
.tl-flow { display: flex; align-items: stretch; gap: 0; }
.tl-node { display: flex; flex-direction: column; align-items: center; justify-content: center; flex-shrink: 0; padding: 0 12px; }
.tl-dot { width: 22px; height: 22px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px currentColor; }
.tl-node-label { font-size: 0.8rem; font-weight: 600; margin-top: 6px; text-align: center; color: #333; }
.tl-node-date { font-size: 0.75rem; color: #888; text-align: center; }
.tl-connector { display: flex; align-items: center; width: 30px; flex-shrink: 0; }
.tl-connector-line { width: 100%; height: 3px; background: #ddd; }
.tl-branches { flex: 1; display: flex; flex-direction: column; gap: 6px; padding: 8px 0; position: relative; }
.tl-branches::before, .tl-branches::after { content: ''; position: absolute; width: 3px; background: #ddd; top: 0; bottom: 0; }
.tl-branches::before { left: 0; }
.tl-branches::after { right: 0; }
.tl-branch { display: flex; align-items: center; gap: 0; position: relative; }
.tl-branch-line-left { width: 16px; height: 3px; background: #ddd; flex-shrink: 0; }
.tl-branch-line-right { width: 16px; height: 3px; background: #ddd; flex-shrink: 0; }
.tl-branch-bar { flex: 1; display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border-radius: 4px; font-size: 0.85rem; min-height: 36px; position: relative; }
.tl-branch-bar .tl-charge-name { font-weight: 600; }
.tl-branch-bar .tl-charge-dates { font-size: 0.8rem; opacity: 0.85; }
.tl-branch-bar .tl-charge-status { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; }
.tl-branch-open { background: #fff8e8; border: 2px solid #ffbe2e; }
.tl-branch-closed { background: #e8f5e9; border: 2px solid #2e8540; }
.tl-no-charges { flex: 1; display: flex; align-items: center; justify-content: center; padding: 12px; color: #888; font-size: 0.9rem; font-style: italic; }

/* Detail table */
.detail-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.detail-table th { background: #f0f4ff; padding: 8px 12px; text-align: left; border-bottom: 2px solid #ddd; font-weight: 600; font-size: 0.9rem; color: #333; cursor: pointer; }
.detail-table th:hover { background: #e0e8f8; }
.detail-table td { padding: 8px 12px; border-bottom: 1px solid #eee; }
.detail-table tr:hover { background: #f9fbff; }

/* CSV fallback overlay */
.csv-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.7); z-index: 9999; display: flex; align-items: center; justify-content: center; }
.csv-overlay-box { background: #fff; padding: 40px; border-radius: 8px; text-align: center; max-width: 500px; }
.csv-overlay-box h3 { color: #13418A; margin-top: 0; }
.csv-drop-zone { border: 3px dashed #13418A; border-radius: 8px; padding: 40px 20px; margin: 20px 0; cursor: pointer; transition: background 0.2s; }
.csv-drop-zone:hover, .csv-drop-zone.dragover { background: #e8f0fe; }
.csv-drop-zone .fa { font-size: 3rem; color: #13418A; margin-bottom: 10px; }
