:root {
    --bg: #FFFFFF;
    --card-bg: #F6F9FC;
    --card-border: #DCE6F0;
    --text-primary: #12233D;
    --text-secondary: #5B7089;
    --accent-new: #2563EB;
    --pulse: #2563EB;
    --error: #DC2626;
  }

  * { box-sizing: border-box; }

  .mw-widget {
    background: var(--bg);
    color: var(--text-primary);
    font-family: 'IBM Plex Sans', sans-serif;
    padding: 24px;
    border-radius: 12px;
    max-width: 1140px;
    margin: 40px auto;
    border: 1px solid var(--card-border);
    box-shadow: 0 1px 3px rgba(18, 35, 61, 0.06);
  }

  .mw-header {
    margin-bottom: 14px;
  }

  .mw-title {
    font-family: 'Fraunces', serif;
    font-weight: 600;
    font-size: 32px;
    margin: 0;
  }

  .mw-footer {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 16px;
  }

  .mw-updated {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
  }

  .mw-disclaimer {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0;
  }

  .mw-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--pulse);
    animation: mw-pulse 2s ease-in-out infinite;
  }

  @keyframes mw-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
  }

  @media (prefers-reduced-motion: reduce) {
    .mw-pulse { animation: none; }
  }

  .mw-stats-note {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 20px 0 14px;
  }

  .mw-tabs-card {
    /* Bleeds flush with .mw-widget's own 24px padding (both sides) so the
       tab row starts exactly at the widget's edge instead of sitting
       indented inside the general content padding. width must stay auto
       here — pairing an explicit width (e.g. 100%) with negative margins
       on both sides over-constrains the box equation, and the browser
       silently drops the specified right margin to compensate. */
    width: auto;
    margin: 0 -24px 16px;
    /* Matches .mw-tab-panels' own corner shape and clips to it, since the
       panel's top-right curve recedes ~8px inward while .mw-tabs-nav's
       border-bottom is a dead-straight line reaching the same x as the
       panel's right edge — without this, that straight line visibly
       overshoots past where the curve has already turned inward. */
    border-radius: 0 8px 8px 8px;
    overflow: hidden;
  }

  .mw-tab-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
  }

  .mw-tabs-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    border-bottom: 1px solid var(--card-border);
    padding: 0 4px;
  }

  .mw-tab-label {
    display: inline-block;
    padding: 10px 18px;
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-secondary);
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    margin-bottom: -1px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease, color 0.15s ease;
  }

  .mw-tab-label:hover {
    background: #FFFFFF;
    color: var(--text-primary);
  }

  .mw-tab-panels {
    background: var(--bg);
    border: 1px solid var(--card-border);
    border-top: none;
    border-radius: 0 8px 8px 8px;
    padding: 12px;
  }

  .mw-tab-panel {
    display: none;
  }

  /* Active-tab wiring: each radio's :checked state shows its own panel and
     visually promotes its own label (fixed set of property-type tabs, so
     hardcoding the 4 ids here is simpler than a generic selector). */
  #mw-tab-single_family:checked ~ .mw-tab-panels #mw-panel-single_family,
  #mw-tab-condos:checked ~ .mw-tab-panels #mw-panel-condos,
  #mw-tab-multi_family:checked ~ .mw-tab-panels #mw-panel-multi_family,
  #mw-tab-vacant_lots:checked ~ .mw-tab-panels #mw-panel-vacant_lots {
    display: block;
  }

  #mw-tab-single_family:checked ~ .mw-tabs-nav .mw-tab-label--single_family,
  #mw-tab-condos:checked ~ .mw-tabs-nav .mw-tab-label--condos,
  #mw-tab-multi_family:checked ~ .mw-tabs-nav .mw-tab-label--multi_family,
  #mw-tab-vacant_lots:checked ~ .mw-tabs-nav .mw-tab-label--vacant_lots {
    background: var(--bg);
    color: var(--text-primary);
    border-bottom-color: var(--bg);
  }

  #mw-tab-single_family:focus-visible ~ .mw-tabs-nav .mw-tab-label--single_family,
  #mw-tab-condos:focus-visible ~ .mw-tabs-nav .mw-tab-label--condos,
  #mw-tab-multi_family:focus-visible ~ .mw-tabs-nav .mw-tab-label--multi_family,
  #mw-tab-vacant_lots:focus-visible ~ .mw-tabs-nav .mw-tab-label--vacant_lots {
    outline: 2px solid var(--accent-new);
    outline-offset: 2px;
  }

  .mw-table-scroll {
    overflow-x: auto;
  }

  .mw-stats-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 6px;
  }

  .mw-stats-table thead th {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0 6px 4px;
    text-align: center;
    white-space: nowrap;
  }

  .mw-stats-table-label-col {
    text-align: left !important;
  }

  .mw-stats-table tbody tr {
    background: var(--card-bg);
  }

  .mw-stats-table td {
    padding: 9px 6px;
    border-top: 1px solid var(--card-border);
    border-bottom: 1px solid var(--card-border);
    text-align: center;
  }

  .mw-stats-cell {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px;
  }

  .mw-stats-row--snapshot {
    margin-top: 8px;
  }

  .mw-stats-table tbody tr.mw-trend-row {
    background: transparent;
    visibility: collapse;
  }

  .mw-stats-table tbody tr.mw-trend-row:has(.mw-trend-details[open]) {
    visibility: visible;
  }

  .mw-stats-table .mw-trend-row .mw-trend-cell {
    border: none;
    padding: 4px 12px 8px;
  }

  .mw-trend-details {
    margin: 0;
  }

  .mw-trend-summary {
    display: none;
  }

  .mw-trend-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font: inherit;
    color: inherit;
    background: none;
    border: none;
    margin: 0;
    padding: 0;
    cursor: pointer;
    user-select: none;
  }

  .mw-trend-trigger:hover,
  .mw-trend-trigger:focus-visible {
    color: var(--accent-new);
  }

  .mw-trend-caret {
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--accent-new);
    transition: transform 0.15s ease;
    flex-shrink: 0;
  }

  .mw-trend-trigger.is-open .mw-trend-caret {
    transform: rotate(180deg);
  }

  .mw-trend-chart-wrap {
    width: 100%;
    margin-top: 10px;
  }

  .mw-trend-canvas-box {
    position: relative;
    width: 100%;
    height: 220px;
  }

  .mw-trend-canvas {
    width: 100% !important;
    height: 100% !important;
  }

  .mw-trend-empty {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 6px 0 0;
  }

  /* Partial/missing daily_activity_snapshots coverage note — see
     renderActivityDataNote() in views/market-report.php. Same font-size/
     color treatment as .mw-trend-empty above, for the same reason: a
     small, clearly secondary disclaimer, not an error state. */
  .mw-untracked-note {
    padding: 8px 12px !important;
    text-align: left;
    font-size: 12px;
    font-style: italic;
    color: var(--text-secondary);
  }

  .mw-stats-row-label {
    padding-left: 12px !important;
    text-align: left;
    font-size: 13px;
    font-weight: 500;
    border-left: 1px solid var(--card-border);
    border-radius: 8px 0 0 8px;
    white-space: normal;
  }

  .mw-stats-cell:last-child {
    border-right: 1px solid var(--card-border);
    border-radius: 0 8px 8px 0;
    font-weight: 600;
  }

  .mw-stat-badge {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 600;
    font-size: 14px;
    padding: 6px 8px;
    border-radius: 6px;
    display: block;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
  }

  a.mw-stat-badge {
    text-decoration: none;
    cursor: pointer;
  }

  a.mw-stat-badge:hover,
  a.mw-stat-badge:focus-visible {
    filter: brightness(1.12);
  }

  /* Inline, always-visible filter cluster — sits inside .mw-tabs-nav
     alongside the tab labels (tabs left via source order, filters pushed
     right via justify-content: space-between on the shared flex parent).
     No dropdown/positioning of its own needed anymore: flex-wrap on
     .mw-tabs-nav already lets this whole cluster drop to its own line
     below the tabs on narrow screens instead of cramping or scrolling. */
  .mw-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 6px 4px;
    /* Pushes just this cluster to the right, leaving the tab labels
       bunched together with .mw-tabs-nav's own small gap instead of
       spreading apart too (which plain justify-content: space-between
       on the shared flex parent would do to every item, tabs included). */
    margin-left: auto;
  }

  .mw-filter {
    display: flex;
    align-items: center;
  }

  /* Labels stay in the DOM for screen readers/form semantics but are
     visually redundant next to a ZIP placeholder and self-explanatory
     timeframe values, so they're hidden rather than shown inline —
     keeps this cluster compact and visually secondary to the tabs. */
  .mw-filter label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .mw-filter input,
  .mw-filter select {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px;
    padding: 6px 8px;
    border: 1px solid var(--card-border);
    border-radius: 6px;
    background: #FFFFFF;
    color: var(--text-primary);
    height: 32px;
    box-sizing: border-box;
  }

  .mw-filter input {
    width: 90px;
  }

  .mw-filters button {
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 12px;
    font-weight: 600;
    background: var(--accent-new);
    color: white;
    border: none;
    padding: 0 14px;
    border-radius: 6px;
    cursor: pointer;
    height: 32px;
  }

  .mw-filters button:focus-visible,
  .mw-filters input:focus-visible,
  .mw-filters select:focus-visible {
    outline: 2px solid var(--accent-new);
    outline-offset: 2px;
  }

  .mw-filters a {
    font-size: 12px;
    color: var(--text-secondary);
  }

  .mw-error {
    color: var(--error);
    font-size: 14px;
  }
