/* =========================================================
   Regional Performance - self-contained feature stylesheet.
   Extends the dashboard design tokens (dashboard.css); it does not
   replace them. Layout mirrors EVs / Dealer Insights / Used Vehicle
   Insights: full-width rows on a 12-column grid, no tabs, no
   section-level headings beyond the card titles, no placeholder surfaces.
   ========================================================= */

.rp-shell {
    --rp-row-h: calc(100vh - 200px);
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--rail-w);
    grid-template-areas: "nav main rail";
    height: 100vh;
    overflow: hidden;
}

.rp-main {
    grid-area: main;
    min-width: 0;
    height: 100%;
    overflow-y: hidden;
    overflow-x: hidden;
    padding-right: 4px;
    display: flex;
    flex-direction: column;
    gap: var(--gutter);
    scrollbar-width: thin;
    scrollbar-color: var(--border-panel) transparent;
}

    .rp-main::-webkit-scrollbar {
        width: 8px;
    }

    .rp-main::-webkit-scrollbar-thumb {
 background: var(--border-panel);
        border-radius: 4px;
    }

/* ---------- Page header ---------- */

.rp-page-head {
    margin: 0;
    flex: 0 0 auto;
}

/* ---------- Cards ---------- */

.rp-card {
  background: var(--bg-panel);
    border: 1px solid var(--border-panel);
  border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.rp-card-title {
    margin: 0 0 4px;
  font-size: var(--fs-card-title);
    font-weight: 500;
    color: var(--text-hi);
    text-transform: uppercase;
    letter-spacing: .06em;
}

/* ---------- Full-width row (12-column grid), equal-height panes ---------- */

.rp-row-2 {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    gap: var(--gutter);
    flex: 1 1 auto;
    min-height: 0;
    align-items: stretch;
}

.rp-table-card,
.rp-map-card {
    height: var(--rp-row-h);
    min-height: 0;
}

/* ---------- Provinces table (no scroll - fixed 9-row + total set) ---------- */

.rp-table-wrap {
    flex: 1 1 auto;
    overflow: hidden;
    min-height: 0;
 display: flex;
    flex-direction: column;
}

.rp-table {
    width: 100%;
    height: 100%;
    border-collapse: collapse;
    font-size: var(--fs-meta);
    table-layout: fixed;
}

    .rp-table tbody,
    .rp-table thead,
    .rp-table tfoot {
        width: 100%;
 }

    .rp-table th,
    .rp-table td {
        padding: 6px 8px;
      text-align: right;
        white-space: nowrap;
        overflow: hidden;
     text-overflow: ellipsis;
    }

    .rp-table th:last-child,
    .rp-table td:last-child {
        padding-right: 16px;
    }

    .rp-table th:first-child,
    .rp-table td:first-child {
        text-align: left;
    }

    .rp-table thead th {
        color: var(--text-lo);
   text-transform: uppercase;
        letter-spacing: .04em;
        font-weight: 600;
      border-bottom: 1px solid var(--border-panel);
    }

    .rp-table tbody td {
        color: var(--text-hi);
  border-bottom: 1px solid var(--border-panel);
    }

    .rp-table tbody td:first-child {
        color: var(--text-hi);
    }

    .rp-table td.rp-table-value {
        color: var(--text-hi);
        font-variant-numeric: tabular-nums lining-nums;
    }

    .rp-table tfoot th,
    .rp-table tfoot td {
        color: var(--text-hi);
      font-weight: 700;
        font-size: 1.05em;
        border-top: 1px solid var(--border-panel);
        padding-top: 10px;
    }

.rp-table-loading {
  text-align: center;
    color: var(--text-lo);
}

.rp-key-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
}

.rp-delta-up {
    color: var(--pos-green);
}

.rp-delta-down {
    color: var(--brand-green-text);
}

/* ---------- Map card: KPI strip + map (no legend - categorical fill) ---------- */

.rp-map-total {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px 10px;
    padding-bottom: 10px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--border-panel);
    flex: 0 0 auto;
}

.rp-map-total-value {
    font-size: var(--fs-kpi-value);
    font-weight: 700;
    color: var(--text-hi);
    font-variant-numeric: tabular-nums lining-nums;
}

.rp-map-total-sub {
    font-size: var(--fs-meta);
    color: var(--text-lo);
}

.rp-map-total-delta {
    font-size: clamp(0.85rem, 1vw, 1.1rem);
    font-weight: 600;
}

.rp-map-total-compare {
    font-size: var(--fs-meta);
    font-weight: 500;
    color: var(--text-lo);
}

.rp-map-wrap {
    position: relative;
    width: 100%;
 flex: 1 1 auto;
    min-height: 0;
}

.rp-map-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

    .rp-map-svg svg {
 width: 100%;
  height: 100%;
        display: block;
    }

    .rp-map-svg [data-province] {
        transition: fill .2s ease;
    stroke: #050710;
   stroke-width: 1.5px;
    }

.rp-map-labels {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.rp-map-pill {
    position: absolute;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    padding: 3px 7px;
    min-width: 58px;
    background: rgba(7, 9, 15, .9);
  border: 1px solid var(--border-panel);
    border-radius: 5px;
    white-space: nowrap;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
}

.rp-map-pill-name {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-mid);
    text-transform: none;
    letter-spacing: normal;
}

.rp-map-pill-value {
  font-size: 12px;
    font-weight: 700;
    color: var(--text-hi);
    font-variant-numeric: tabular-nums lining-nums;
}

.rp-empty {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-lo);
}

/* ---------- Source footer ---------- */

.rp-source {
    font-size: var(--fs-meta);
    color: var(--text-lo);
    border-top: 1px solid var(--border-panel);
    margin: 0;
    padding-top: 8px;
    padding-bottom: 8px;
    flex: 0 0 auto;
}

/* ---------- Loading overlay ---------- */

.rp-loading {
    position: fixed;
    inset: 0;
    z-index: 50;
display: grid;
    place-items: center;
    background: rgba(7, 9, 15, .78);
    color: var(--text-mid);
    font-size: 13px;
    font-weight: 600;
    transition: opacity .2s ease;
}

.rp-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* =========================================================
   Breakpoints
   ========================================================= */

@media (max-width: 1279px) {
    .rp-row-2 {
        grid-template-columns: minmax(0, 1fr);
   flex: 0 0 auto;
 }

    .rp-table-card,
    .rp-map-card {
        height: 560px;
    }

    .rp-table-wrap {
        max-height: none;
    }

    .rp-shell {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
        grid-template-areas:
  "nav main"
    "nav rail";
        height: auto;
        overflow: visible;
    }

    .rp-main {
        overflow: visible;
        height: auto;
    }

    .rp-map-pill {
        padding: 3px 6px;
        min-width: 50px;
    }

  .rp-map-pill-name {
        font-size: 9px;
    }

    .rp-map-pill-value {
        font-size: 11px;
    }
}

@media (max-width: 1023px) {
    .rp-shell {
      grid-template-columns: minmax(0, 1fr);
      grid-template-areas:
        "nav"
   "main";
        height: auto;
    overflow: visible;
    }

    .rp-main {
  overflow: visible;
        height: auto;
    }
}

/* Low-height displays: keep the page inside roughly one-and-a-bit screens. */
@media (max-height: 920px) {
    .rp-shell {
        --rp-row-h: calc(100vh - 180px);
    }

    .rp-card {
   padding: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .rp-loading {
        transition: none;
    }

    .rp-map-svg [data-province] {
        transition: none;
    }
}
