/*
 * mobile.css — DC Witness Safety Map responsive layer
 *
 * MODAL FIXES (this revision):
 *   - #ov, #sub-ov z-index 99999 (above #hdr's 400)
 *   - Phone (≤480px): modal is a CENTERED CARD (94vw, rounded
 *     all sides) sitting in the area below the fixed header.
 *     Card height capped so it never extends behind the header;
 *     overflow-y: auto so long hearing/charge lists scroll
 *     INSIDE the card. Sticky #mh keeps the title and ✕ close
 *     button pinned at the top of the card while content scrolls.
 *   - Tablet (481-768px): centered floating modal with padding
 *     pushed below the header.
 *   - -webkit-overflow-scrolling: touch for iOS momentum scroll.
 *   - overscroll-behavior: contain prevents scroll-chaining to
 *     the page underneath when reaching modal top/bottom.
 *
 * STATS VIEW INTERLEAVE (≤768px, "Both" cities selected):
 *   display:contents on each city wrapper, `order` reorders
 *   so DC and Baltimore sections alternate by type.
 *   Each chart title auto-prefixed with "DC — " / "Baltimore — ".
 *
 * Pair with: var _tblPageSize = 20;  in table.js
 */


/* === ALL SIZES === */

#fsum {
  display: inline-flex; flex-wrap: wrap; align-items: baseline;
  gap: 4px 6px; font-size: 13px; color: var(--ink-2); letter-spacing: -.01em;
}
.fsum-lbl, .fsum-scope-item, .fsum-stack-i { font-weight: 600; color: var(--ink-1); }
.fsum-n     { font-weight: 700; color: var(--ink-1); font-variant-numeric: tabular-nums; }
.fsum-q     { color: var(--ink-3); }
.fsum-sep   { margin-left: -3px; color: var(--ink-3); }
.fsum-comma { margin-left: -4px; color: var(--ink-3); }
.fsum-stack { display: inline-flex; flex-direction: column; gap: 1px; vertical-align: baseline; }
#ftags { display: none !important; }
#tblview tbody tr.has-cases td { cursor: pointer; }
body:has(#vtab-map:not(.on)) .lbs,
body:has(#vtab-map:not(.on)) .bar-sep { display: none !important; }


/* === ≥ 1600 === */
@media (min-width: 1600px) {
  #hdr-top { gap: 18px; padding: 0 28px; }
  #fbar    { gap: 10px; padding: 0 28px; }
  .lbs     { gap: 3px; }
  #brand-text     { font-size: 16.5px; }
  #brand-icon     { width: 40px; height: 40px; }
  #brand-logo-img { width: 30px; height: 30px; }
  #srchwrap       { height: 42px; }
  #srch           { font-size: 15px; }
  .vtab           { font-size: 14.5px; padding: 7px 20px; }
  .hbtn           { font-size: 13px; padding: 7px 14px; }
  #fsum           { font-size: 15px; gap: 5px 7px; }
  .fdrop-btn { font-size: 14.5px; height: 40px; padding: 7px 20px; }
  .city-chip { font-size: 13.5px; padding: 7px 17px; }
  .lb        { font-size: 13.5px; padding: 7px 19px; }
  .lbs       { padding: 4px; }
  #clear-all { font-size: 13px; padding: 7px 14px; }
  .fdrop-menu     { min-width: 460px; max-height: 680px; border-radius: 20px; }
  .fm-hd          { font-size: 12.5px; padding: 20px 28px 15px; letter-spacing: .09em; }
  .fm-body        { padding: 20px 28px; gap: 16px; }
  .fm-label       { font-size: 16px; }
  .fm-hint        { font-size: 14px; }
  .fchk           { font-size: 16px; padding: 8px 0; gap: 14px; }
  .fchk input     { width: 18px; height: 18px; }
  .fchk-dot       { width: 12px; height: 12px; }
  .fchk-group-hd  { font-size: 12px; padding: 14px 0 6px; }
  .fchk-list      { max-height: 380px; }
  .preset-btn     { font-size: 14.5px; padding: 8px 17px; border-radius: 11px; }
  .fm-date, .fm-sel { font-size: 16px; padding: 11px 14px; }
  .fm-actions     { padding: 16px 28px 20px; gap: 12px; }
  .fm-apply, .fm-clear { font-size: 15.5px; padding: 12px 20px; }
  #leg                       { min-width: 200px; padding: 14px 16px; bottom: 28px; left: 22px; }
  #leg > div:first-child     { font-size: 11px !important; letter-spacing: .08em !important; margin-bottom: 8px !important; }
  #leg > div                 { margin-bottom: 6px !important; gap: 8px !important; }
  #leg > div > span:first-child { width: 11px !important; height: 11px !important; }
  #leg > div > span:last-child  { font-size: 12.5px !important; }
}


/* === ≥ 1280 === */
@media (min-width: 1280px) {
  #hdr-top { gap: 14px; padding: 0 22px; }
  #fbar    { gap: 8px; padding: 0 22px; }
  .lbs     { gap: 3px; }
  #brand-text     { font-size: 15px; }
  #brand-icon     { width: 38px; height: 38px; }
  #brand-logo-img { width: 28px; height: 28px; }
  #srchwrap       { height: 40px; }
  #srch           { font-size: 14px; }
  .vtab           { font-size: 13.5px; padding: 6px 18px; }
  .hbtn           { font-size: 12.5px; padding: 6px 13px; }
  #fsum           { font-size: 14px; gap: 5px 6px; }
  .fdrop-btn { font-size: 14px; height: 38px; padding: 6px 18px; }
  .city-chip { font-size: 13px; padding: 6px 16px; }
  .lb        { font-size: 13px; padding: 6px 18px; }
  #clear-all { font-size: 12.5px; padding: 6px 12px; }
  .fdrop-menu     { min-width: 400px; max-height: 600px; border-radius: 18px; }
  .fm-hd          { font-size: 12px; padding: 18px 24px 14px; letter-spacing: .08em; }
  .fm-body        { padding: 18px 24px; gap: 14px; }
  .fm-label       { font-size: 15px; }
  .fm-hint        { font-size: 13.5px; }
  .fchk           { font-size: 15px; padding: 7px 0; gap: 13px; }
  .fchk input     { width: 17px; height: 17px; }
  .fchk-dot       { width: 11px; height: 11px; }
  .fchk-group-hd  { font-size: 11.5px; padding: 12px 0 5px; }
  .fchk-list      { max-height: 320px; }
  .preset-btn     { font-size: 14px; padding: 7px 15px; border-radius: 10px; }
  .fm-date, .fm-sel { font-size: 15px; padding: 10px 13px; }
  .fm-actions     { padding: 14px 24px 18px; gap: 10px; }
  .fm-apply, .fm-clear { font-size: 14.5px; padding: 11px 18px; }
  #leg                       { min-width: 175px; padding: 12px 14px; bottom: 26px; left: 20px; }
  #leg > div:first-child     { font-size: 10px !important; letter-spacing: .07em !important; margin-bottom: 7px !important; }
  #leg > div                 { margin-bottom: 5px !important; gap: 7px !important; }
  #leg > div > span:first-child { width: 10px !important; height: 10px !important; }
  #leg > div > span:last-child  { font-size: 11.5px !important; }
}


/* === ≤ 1024 === */
@media (max-width: 1024px) {
  #hdr-top { padding: 0 14px; gap: 8px; }
  #fbar    { padding: 0 14px; gap: 5px; }
  #brand-tagline { display: none !important; }
  .hbtn { padding: 5px 10px; font-size: 11px; }
}


/* === ≤ 768 === */
@media (max-width: 768px) {

  html, body {
    overflow-x: hidden !important;
    max-width: 100vw;
    -webkit-overflow-scrolling: touch;
  }

  #hdr-top {
    display: flex; flex-wrap: wrap; align-items: center;
    padding: 8px 12px; gap: 8px; row-gap: 7px;
    height: auto; min-height: 50px;
  }

  #hdr-brand {
    flex-shrink: 1; min-width: 0; order: 1; gap: 8px; overflow: hidden;
  }
  #hdr-brand > div:not(#brand-icon) {
    min-width: 0; overflow: hidden; flex: 1 1 auto;
  }

  #hdr-right { flex-shrink: 0; order: 3; margin-left: auto; gap: 5px; }
  #brand-icon { width: 32px; height: 32px; flex-shrink: 0; }
  #brand-logo-img { width: 24px; height: 24px; }
  #brand-text {
    display: block;
    font-size: 12px; font-weight: 600;
    letter-spacing: -.02em; line-height: 1.15;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .hbtn { padding: 5px 10px; font-size: 11px; }
  #srchwrap { height: 36px; }

  #fbar {
    height: auto; min-height: 40px;
    display: flex; flex-wrap: wrap; overflow-x: visible;
    padding: 6px 10px 8px; gap: 5px; row-gap: 6px; align-items: center;
  }

  .lbs {
    flex-basis: 100% !important; flex-wrap: nowrap !important;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; padding: 2px;
    border-radius: var(--radius-pill); max-width: 100%;
  }
  .lbs::-webkit-scrollbar { display: none; }
  .lb { flex-shrink: 0; white-space: nowrap; }
  .bar-sep { display: none; }

  #fsum {
    font-size: 11.5px; justify-content: center; padding: 4px;
  }

  .fdrop-menu {
    max-width: calc(100vw - 16px);
    min-width: min(260px, calc(100vw - 16px));
    max-height: calc(100vh - var(--hdr-h) - 24px);
    left: 8px !important; right: 8px;
  }
  .fdrop-menu .fchk span { white-space: normal; word-break: break-word; line-height: 1.35; }
  .fdrop-menu .fchk-list { max-height: 240px; }

  #tblview {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding-bottom: 88px !important;
  }
  #tblview table { min-width: 880px; }
  #tblview thead th, #tblview tbody td { padding: 9px 10px; font-size: 11.5px; }

  #tblview thead th {
    position: sticky; top: 0; background: var(--paper-2); z-index: 4;
  }
  #tblview tbody td:nth-child(2) {
    position: sticky; left: 0; background: var(--white); z-index: 2;
    box-shadow: 1px 0 0 var(--line-2);
  }
  #tblview thead th:nth-child(2) {
    position: sticky; left: 0; top: 0; background: var(--paper-2); z-index: 5;
  }
  #tblview tbody tr:hover td:nth-child(2),
  #tblview tbody tr.is-open td:nth-child(2) { background: var(--paper-2); }

  .tbl-expand-btn { width: 32px !important; height: 32px !important; font-size: 12px; }
  .tbl-td-chev { width: 44px !important; padding: 0 6px !important; }
  .tbl-zoom-ico { padding: 8px !important; font-size: 14px !important; }
  .tbl-td-zoom  { width: 50px !important; }

  #tbl-pager {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
    background: var(--white); border-top: 0.5px solid var(--line);
    box-shadow: 0 -2px 12px rgba(0,0,0,.06);
    padding: 8px 12px 10px !important;
    flex-direction: column; align-items: stretch; gap: 6px;
  }
  .pager-info { text-align: center; font-size: 10.5px; }
  .pager-btns {
    justify-content: center; flex-wrap: nowrap; gap: 2px;
    max-width: 100vw; overflow-x: auto; padding-bottom: 2px;
  }
  .pager-btns::-webkit-scrollbar { display: none; }
  .pager-btn { padding: 5px 10px; font-size: 11px; min-width: 30px; flex-shrink: 0; }
  .pager-num { min-width: 28px; }

  #tblview tbody tr.tbl-acc-row > td.tbl-acc-cell {
    padding: 0 !important; background: var(--paper) !important; border: none !important;
  }
  #tblview tbody tr.tbl-acc-row .acc-wrap {
    position: sticky; left: 0;
    width: 100vw; max-width: 100vw; box-sizing: border-box;
    padding: 12px; margin: 0;
    flex-direction: column; gap: 10px; overflow-x: hidden;
  }
  #tblview tbody tr.tbl-acc-row .acc-case {
    min-width: 0 !important; width: 100%; max-width: 100%;
    box-sizing: border-box; padding: 14px 16px;
    overflow-wrap: break-word; word-break: break-word;
  }
  .ch-desc, .modal-charge-item .ch-desc {
    white-space: normal !important; text-overflow: clip !important;
    overflow: visible !important; min-width: 0 !important;
  }
  .acc-charge-row, .acc-charge-main,
  .acc-hrg-summary, .acc-hrg-foot { flex-wrap: wrap; }

  /* ============================================================
     STATS VIEW — INTERLEAVE DC ↔ Baltimore
     ============================================================ */
  .stats-dual-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    align-items: start !important;
  }
  .stats-dual-grid > div { display: contents !important; }

  /* DC = first wrapper's children → odd orders */
  .stats-dual-grid > div:nth-child(1) > *:nth-child(1) { order:  1; }
  .stats-dual-grid > div:nth-child(1) > *:nth-child(2) { order:  3; }
  .stats-dual-grid > div:nth-child(1) > *:nth-child(3) { order:  5; }
  .stats-dual-grid > div:nth-child(1) > *:nth-child(4) { order:  7; }
  .stats-dual-grid > div:nth-child(1) > *:nth-child(5) { order:  9; }
  .stats-dual-grid > div:nth-child(1) > *:nth-child(6) { order: 11; }
  .stats-dual-grid > div:nth-child(1) > *:nth-child(7) { order: 13; }

  /* Baltimore = second wrapper's children → even orders */
  .stats-dual-grid > div:nth-child(2) > *:nth-child(1) { order:  2; }
  .stats-dual-grid > div:nth-child(2) > *:nth-child(2) { order:  4; }
  .stats-dual-grid > div:nth-child(2) > *:nth-child(3) { order:  6; }
  .stats-dual-grid > div:nth-child(2) > *:nth-child(4) { order:  8; }
  .stats-dual-grid > div:nth-child(2) > *:nth-child(5) { order: 10; }
  .stats-dual-grid > div:nth-child(2) > *:nth-child(6) { order: 12; }
  .stats-dual-grid > div:nth-child(2) > *:nth-child(7) { order: 14; }

  .stats-dual-grid > div:nth-child(1) .stat-bar-title::before {
    content: "DC — ";
    color: #1B4F8A;
    font-weight: 800;
  }
  .stats-dual-grid > div:nth-child(2) .stat-bar-title::before {
    content: "Baltimore — ";
    color: #9C2A2A;
    font-weight: 800;
  }

  #statview { padding: 16px !important; }

  .stat-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 10px !important;
    margin-bottom: 14px !important;
  }
  .stat-card {
    padding: 14px 16px !important;
    border-radius: 11px;
    min-width: 0; box-sizing: border-box;
  }
  .stat-num {
    font-size: 22px !important;
    letter-spacing: -.03em !important;
    line-height: 1.15 !important;
  }
  .stat-lbl {
    font-size: 10px !important;
    margin-top: 4px !important;
    line-height: 1.3 !important;
  }
  .stat-bar-wrap {
    padding: 16px !important;
    margin-bottom: 14px !important;
    border-radius: 11px;
    box-sizing: border-box; max-width: 100%;
  }
  .stat-bar-title {
    font-size: 10px !important;
    margin-bottom: 12px !important;
  }

  /* ============================================================
     ★ MODAL — close button must stay below the fixed header ★
     Header z-index is 400, modal overlay is 2000 (from base CSS).
     On iOS Safari backdrop-filter can break z-index ordering
     between elements, so we defensively bump z-index and cap
     modal height so the modal sits BELOW the header band.
     ============================================================ */
  #ov, #sub-ov {
    z-index: 99999 !important;
  }

  /* Tablet (centered floating modal) */
  #ov {
    padding-top: calc(var(--hdr-h) + 12px) !important;
    align-items: flex-start;
  }
  #mb {
    width: 96vw; max-width: 96vw;
    max-height: calc(100vh - var(--hdr-h) - 24px) !important;
    border-radius: 16px;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  #mh { padding: 16px 16px 12px; }
  #mt { font-size: 15px; }
  .mtabs { padding: 0 12px; overflow-x: auto; scrollbar-width: none; }
  .mtabs::-webkit-scrollbar { display: none; }
  .mtab       { padding: 10px 12px; font-size: 11.5px; }
  .mtab-panel { padding: 16px 14px; max-width: 100%; overflow-x: hidden; overflow-wrap: break-word; }
  .mtab-panel * { max-width: 100%; box-sizing: border-box; }
  .dg         { grid-template-columns: 1fr 1fr; }

  #sub-panel { width: 94vw; border-radius: 16px; }
  #sub-hd    { padding: 18px 18px 14px; }

  .leaflet-control-zoom a {
    width: 36px !important; height: 36px !important;
    line-height: 36px !important; font-size: 18px !important;
  }
  .leaflet-popup-content-wrapper { max-width: calc(100vw - 32px) !important; }

  #leg {
    bottom: 18px; left: 12px;
    min-width: 130px; max-width: 165px;
    padding: 8px 10px;
  }
  #leg > div:first-child     { font-size: 8.5px !important; letter-spacing: .06em !important; margin-bottom: 4px !important; }
  #leg > div                 { margin-bottom: 3px !important; gap: 5px !important; }
  #leg > div > span:first-child { width: 8px !important; height: 8px !important; border-width: 1px !important; }
  #leg > div > span:last-child  { font-size: 10px !important; }
}


/* === 481–768 tablet === */
@media (max-width: 768px) and (min-width: 481px) {
  :root { --hdr-h: 210px; }
  :root:has(#vtab-tbl.on),
  :root:has(#vtab-stat.on) { --hdr-h: 170px; }
  :root:has(#vtab-map.on):has(#fsum:not(:empty))  { --hdr-h: 240px; }
  :root:has(#vtab-stat.on):has(#fsum:not(:empty)) { --hdr-h: 200px; }
}


/* === ≤ 480 phone === */
@media (max-width: 480px) {

  :root { --hdr-h: 170px; }
  :root:has(#vtab-tbl.on),
  :root:has(#vtab-stat.on)                       { --hdr-h: 95px; }
  :root:has(#vtab-map.on):has(#fsum:not(:empty)) { --hdr-h: 200px; }

  /* Filter pills */
  #fbar .fdrop-btn {
    padding: 4px 7px !important; height: 24px !important;
    font-size: 9px !important; letter-spacing: -.03em !important;
    border-radius: var(--radius-pill) !important;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    gap: 0; min-width: 0; flex-shrink: 1;
  }
  #fbar .fchev { display: none !important; }
  #fbar .lb {
    padding: 3px 9px !important;
    font-size: 9.5px !important; letter-spacing: -.025em !important;
    border-radius: var(--radius-pill) !important; white-space: nowrap;
  }
  #fbar .city-chips {
    background: var(--paper-2); border-radius: var(--radius-pill);
    padding: 1px; gap: 1px; display: flex; flex: 0 1 auto; min-width: 0;
  }
  #fbar .city-chip {
    padding: 3px 6px !important;
    font-size: 8.5px !important; letter-spacing: -.03em !important;
    border-radius: var(--radius-pill) !important;
    white-space: nowrap; min-width: 0; flex-shrink: 1;
    overflow: hidden; text-overflow: ellipsis;
  }
  #fbar #clear-all {
    padding: 3px 7px !important; height: 24px;
    font-size: 9px !important; letter-spacing: -.03em !important;
    border-radius: var(--radius-pill) !important;
    white-space: nowrap; min-width: 0; flex-shrink: 1;
  }

  /* Header rows */
  #hdr-top { padding: 8px 10px; gap: 7px; row-gap: 6px; align-items: center; }

  body:has(#vtab-tbl.on)  #hdr-top > div:has(#srchwrap),
  body:has(#vtab-stat.on) #hdr-top > div:has(#srchwrap) { display: none !important; }
  body:has(#vtab-tbl.on) #fsum      { display: none !important; }
  body:has(#vtab-tbl.on) #hdr-right { display: none !important; }

  #viewtabs {
    flex: 0 0 auto !important; flex-basis: auto !important; width: auto !important;
    order: 2 !important; margin: 0 0 0 auto !important;
    padding: 2px; gap: 1px; justify-content: center;
  }
  .vtab {
    padding: 4px 7px !important;
    font-size: 9.5px !important; letter-spacing: -.02em !important;
    white-space: nowrap;
  }

  body:has(#vtab-map.on) #hdr-right {
    flex-shrink: 0; margin: 0; order: 3 !important;
  }
  body:has(#vtab-map.on) #hdr-right:has(#fsum:not(:empty)) {
    flex-basis: 100% !important; width: 100%;
    justify-content: center; margin: 0;
  }
  body:has(#vtab-map.on) #hdr-right:not(:has(#fsum:not(:empty))) {
    display: none;
  }
  body:has(#vtab-map.on) #hdr-top > div:has(#srchwrap) {
    flex-basis: 100% !important; max-width: 100% !important;
    order: 4 !important; margin: 0 !important;
  }

  /* Filter bar */
  #fbar {
    display: flex !important; flex-wrap: wrap !important; overflow-x: hidden !important;
    padding: 5px !important; gap: 3px !important; row-gap: 6px !important;
    align-items: center;
  }
  #fbar > *:not(.lbs) {
    flex: 0 1 auto; min-width: 0; flex-shrink: 1; white-space: nowrap;
  }
  #fbar #clear-all { order: 50; }
  #fbar .lbs { flex-basis: 100% !important; order: 100; margin: 0; }
  #fbar .bar-sep,
  #fbar #ftags { display: none !important; }

  /* Brand */
  #hdr-brand { gap: 7px; }
  #brand-icon { width: 30px; height: 30px; }
  #brand-text {
    display: block;
    font-size: 11px; font-weight: 600;
    line-height: 1.15; letter-spacing: -.02em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  #hdr-right .hbtn {
    padding: 0 !important; width: 36px; height: 36px;
    font-size: 0; justify-content: center; align-items: center; gap: 0;
  }
  #hdr-right .hbtn svg { width: 14px; height: 14px; flex-shrink: 0; }
  #srchwrap { height: 34px; }
  #srch { font-size: 11px; }
  #fsum {
    font-size: 11px; gap: 3px 5px; padding: 4px; justify-content: center;
  }
  .fdrop-menu {
    left: 6px !important; right: 6px;
    max-width: calc(100vw - 12px); border-radius: 12px;
  }
  .fdrop-menu .fchk-list { max-height: 260px; }
  .fdrop-menu .fchk      { padding: 5px 0; font-size: 13px; }
  .fm-body               { padding: 10px 14px; gap: 7px; }
  .fm-actions            { padding: 8px 14px 10px; }
  .fm-hd                 { padding: 10px 14px 7px; }
  .lbs { padding: 2px !important; }

  /* === Stats view (phone tweaks; interleave inherited from 768px block) === */
  #statview { padding: 12px !important; }
  .stats-dual-grid { gap: 8px !important; }

  .stats-dual-grid div[style*="repeat(3,minmax"],
  .stats-dual-grid div[style*="repeat(3, minmax"] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 6px !important;
  }

  .stats-dual-grid > div > div:first-child h2 { font-size: 13px !important; }
  .stats-dual-grid > div > div:first-child    { margin-bottom: 8px !important; }
  .stats-dual-grid > div > div:first-child span[style*="font-size:11px"] {
    font-size: 10px !important;
  }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important; margin-bottom: 12px !important;
  }

  .stat-card,
  .stats-dual-grid .stat-card {
    padding: 11px 13px !important; border-radius: 10px;
    min-width: 0; box-sizing: border-box;
  }
  .stats-dual-grid .stat-card[style*="padding:11px 13px"],
  .stats-dual-grid .stat-card[style*="padding: 11px 13px"] {
    padding: 10px 11px !important;
  }
  .stat-num,
  .stats-dual-grid .stat-num {
    font-size: 17px !important; letter-spacing: -.03em !important; line-height: 1.1 !important;
  }
  .stats-dual-grid .stat-num[style*="font-size:19px"] { font-size: 17px !important; }
  .stat-lbl,
  .stats-dual-grid .stat-lbl {
    font-size: 9px !important; margin-top: 3px !important; line-height: 1.25 !important;
  }
  .stats-dual-grid .stat-lbl[style*="font-size:10px"] { font-size: 9px !important; }

  .stat-bar-wrap {
    padding: 12px 13px !important; margin-bottom: 10px !important;
    border-radius: 10px; box-sizing: border-box; max-width: 100%;
  }
  .stat-bar-title {
    font-size: 9px !important; letter-spacing: .04em !important; margin-bottom: 9px !important;
  }

  .sbar-row   { gap: 5px !important; margin-bottom: 3px !important; }
  .sbar-lbl   { width: 88px !important; font-size: 9.5px !important; }
  .sbar-val   { width: 28px !important; font-size: 9px !important; }
  .sbar-track { height: 4px !important; }

  .stat-bar-wrap div[style*="width:140px"] { width: 90px !important; min-width: 90px !important; }
  .stat-bar-wrap div[style*="width:130px"] { width: 90px !important; min-width: 90px !important; }
  .stat-bar-wrap div[style*="width:100px"] { width: 55px !important; min-width: 55px !important; }
  .stat-bar-wrap th[style*="min-width:130px"] { min-width: 80px !important; }

  .stat-bar-wrap[style*="overflow-x:auto"],
  .stat-bar-wrap[style*="overflow-x: auto"] { overflow-x: auto !important; }
  .stat-bar-wrap table { font-size: 10px !important; }
  .stat-bar-wrap table th,
  .stat-bar-wrap table td { padding: 4px 6px !important; }

  #monthly-chart-wrap > div:first-of-type {
    flex-wrap: wrap !important; gap: 3px !important; margin-bottom: 8px !important;
  }
  #monthly-chart-wrap button {
    font-size: 8.5px !important; padding: 3px 6px !important; margin: 1px !important;
  }
  #monthly-chart-wrap button > span[style*="width:7px"] {
    width: 6px !important; height: 6px !important;
  }
  #monthly-chart-wrap input[type="range"] { width: 100% !important; }
  #monthly-chart-wrap svg { max-width: 100% !important; height: auto !important; }
  #monthly-chart-wrap select[onchange*="statSetWindow"] {
    font-size: 10px !important; padding: 2px 4px !important;
  }

  .stat-bar-wrap select[onchange*="statSet"] {
    font-size: 10px !important; padding: 2px 5px !important;
  }
  .stat-bar-wrap span[style*="font-size:11px"][style*="color:var(--slate-500)"] {
    font-size: 10px !important;
  }
  .stat-bar-wrap span[style*="font-size:10px"][style*="color:var(--slate-400)"] {
    font-size: 9px !important;
  }

  .stat-bar-wrap div[style*="width:36px"] {
    width: 30px !important; font-size: 8.5px !important;
  }
  .stat-bar-wrap div[style*="width:30px"][style*="font-size:10px"] {
    width: 28px !important; font-size: 9px !important;
  }
  .stat-bar-wrap div[style*="width:32px"][style*="font-size:9px"] {
    width: 30px !important;
  }
  .stat-bar-wrap span[style*="font-size:10px"][style*="color:var(--slate-600)"] {
    font-size: 9px !important;
  }

  /* Table on phone */
  #tblview thead th, #tblview tbody td { padding: 8px; font-size: 11px; }
  #tblview table { min-width: 820px; }
  .tbl-expand-btn { width: 34px !important; height: 34px !important; font-size: 13px !important; }
  .tbl-td-chev { width: 44px !important; }

  #tblview tbody tr.tbl-acc-row .acc-wrap { padding: 8px; gap: 8px; }
  #tblview tbody tr.tbl-acc-row .acc-case { padding: 12px 14px; border-radius: 10px; }
  .acc-case-num { font-size: 12px; word-break: break-all; }
  .acc-meta-row { gap: 5px; }
  .acc-chip { min-width: 48px; padding: 3px 7px; }
  .acc-chip-lbl { font-size: 8px; }

  #tbl-pager { padding: 7px 10px 9px !important; }
  .pager-info { font-size: 10.5px; }
  .pager-btn  { padding: 5px 9px; font-size: 11px; min-width: 30px; }
  .pager-num  { min-width: 26px; }

  /* ============================================================
     ★ PHONE MODAL — centered card, scroll inside ★
     - Sits centered in the area BELOW the fixed header
     - Card width 94vw with side margins
     - Fully rounded corners (card, not bottom-sheet)
     - #mb scrolls vertically when content (long hearings/charges
       lists) exceeds the height cap
     - Sticky #mh keeps title + close button pinned at top of card
       while content scrolls
     - z-index 99999 defends against backdrop-filter stacking
       quirks on iOS Safari
     ============================================================ */
  #ov, #sub-ov {
    z-index: 99999 !important;
  }

  #ov {
    /* Pad the overlay so the card centers in the area BELOW the header */
    padding: calc(var(--hdr-h) + 12px) 12px 12px !important;
    align-items: center !important;
    justify-content: center !important;
  }
  #mb {
    width: 94vw; max-width: 94vw;
    max-height: calc(100vh - var(--hdr-h) - 24px) !important;
    border-radius: 16px !important;          /* card style */
    margin: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    box-shadow: 0 24px 60px rgba(0,0,0,.32),
                0 6px 20px rgba(0,0,0,.18);
  }
  .mtab-panel { overflow-x: hidden; }
  .mtab-panel * { max-width: 100%; box-sizing: border-box; }
  .dg, .dg2, .date-grid, .hdet-grid { grid-template-columns: 1fr; gap: 6px 0; }
  .hrow { gap: 6px; padding: 9px 10px; }

  /* Subscribe panel — same centered-card treatment */
  #sub-ov {
    padding: calc(var(--hdr-h) + 12px) 12px 12px !important;
    align-items: center !important;
    justify-content: center !important;
  }
  #sub-panel {
    width: 94vw; max-width: 94vw;
    max-height: calc(100vh - var(--hdr-h) - 24px) !important;
    border-radius: 16px !important;
    margin: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    box-sizing: border-box;
    box-shadow: 0 24px 60px rgba(0,0,0,.32),
                0 6px 20px rgba(0,0,0,.18);
  }

  #leg {
    bottom: 14px; left: 10px;
    min-width: 108px; max-width: 138px;
    padding: 7px 9px; border-radius: 10px;
  }
  #leg > div:first-child     { font-size: 8px !important; letter-spacing: .05em !important; margin-bottom: 3px !important; }
  #leg > div                 { margin-bottom: 2px !important; gap: 5px !important; }
  #leg > div > span:first-child { width: 7px !important; height: 7px !important; border-width: 1px !important; }
  #leg > div > span:last-child  { font-size: 9.5px !important; }
}


/* === iOS safe-area === */
@supports (padding: max(0px)) {
  @media (max-width: 768px) {
    #loc-btn   { bottom: max(18px, env(safe-area-inset-bottom)); }
    #leg       { bottom: max(14px, calc(env(safe-area-inset-bottom) + 2px)); }
    #mb        { padding-bottom: max(0px, env(safe-area-inset-bottom)); }
    #tbl-pager { padding-bottom: max(10px, calc(env(safe-area-inset-bottom) + 6px)) !important; }
    #tblview   { padding-bottom: calc(88px + env(safe-area-inset-bottom)) !important; }
  }
}


/* === Landscape phone === */
@media (max-height: 480px) and (orientation: landscape) {
  :root { --hdr-h: 110px; }
  #hdr-top { min-height: 44px; padding: 6px 12px; }
  .fdrop-menu            { max-height: calc(100vh - 90px); }
  .fdrop-menu .fchk-list { max-height: 140px; }
  #leg { padding: 6px 8px; min-width: 100px; }
}
