/* ==========================================================================
   VIZ-MARKET-EXPLORER  -  CoStar market explorer (table + chart), shared by
   the industrial and multifamily regional pages. Data: <type>-msa-data.js,
   generated from each companion workbook's All Metros and Annual History
   tabs. All rules are scoped to .mkt-explorer so nothing leaks.
   ========================================================================== */

.mkt-explorer {
    color-scheme: light;
    --ie-ink: #23282E;
    --ie-body: #3D434B;
    --ie-muted: #6B7280;
    --ie-hair: #E6DFD3;
    --ie-grid: #ECE7DE;
    --ie-red: #A31F34;
    --ie-blue: #4472C4;
    --ie-orange: #ED7D31;
    --ie-gray: #6B6B6B;
    --ie-paper: #FAF8F4;
    background: #fff;
    border: 1px solid var(--ie-hair);
    border-radius: 8px;
    padding: 1.1rem 1.25rem 1.25rem;
    margin: 1.25rem 0 2rem;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    color: var(--ie-body);
}
.mkt-explorer * { box-sizing: border-box; }

/* ---- control bar (sits between the table and the chart) ---- */
.ie-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem 1.1rem;
    padding: 0.9rem 0 0.85rem;
    border-top: 1px solid var(--ie-hair);
    border-bottom: 1px solid var(--ie-hair);
    margin-top: 0.6rem;
}
.ie-field-search { margin-left: auto; }
.ie-more-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 0.4rem; }
.ie-toggle { display: inline-flex; border: 1px solid var(--ie-red); border-radius: 999px; overflow: hidden; background: #fff; }
.ie-toggle-opt {
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--ie-red);
    background: transparent;
    border: none;
    padding: 0.42rem 0.8rem;
    cursor: pointer;
}
.ie-toggle-opt.ie-toggle-on { background: var(--ie-red); color: #fff; }
.ie-toggle-opt:not(.ie-toggle-on):hover { background: #FBF0F1; }
.ie-metric-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem; margin-top: 0.75rem; font-size: 0.85rem; }
.ie-metric-label { font-weight: 700; color: var(--ie-ink); margin-right: 0.2rem; }
.ie-metric {
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ie-ink);
    background: var(--ie-paper);
    border: 1px solid var(--ie-hair);
    border-radius: 999px;
    padding: 0.28rem 0.75rem;
    cursor: pointer;
}
.ie-metric:hover { border-color: var(--ie-red); color: var(--ie-red); }
.ie-metric.ie-metric-on { background: var(--ie-red); border-color: var(--ie-red); color: #fff; }
.ie-hint-warn { color: var(--ie-red); font-weight: 600; }
.ie-chip-swatch { display: inline-block; width: 12px; height: 4px; border-radius: 2px; margin-right: 0.15rem; vertical-align: 2px; }
.ie-tip-swatch { display: inline-block; width: 12px; height: 4px; border-radius: 2px; margin-right: 0.35rem; vertical-align: 2px; }
.ie-field { display: flex; flex-direction: column; gap: 0.25rem; }
.ie-field label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ie-muted);
}
.ie-field select, .ie-field input[type="search"], .ie-field input[type="number"] {
    font: inherit;
    font-size: 0.9rem;
    color: var(--ie-ink);
    background: #fff;
    border: 1px solid #C9C2B6;
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    min-width: 140px;
}
.ie-field input[type="search"] { min-width: 170px; }
.ie-range { display: flex; align-items: center; gap: 0.4rem; }
.ie-field .ie-num { min-width: 0; width: 88px; padding-right: 0.3rem; }
.ie-range-to, .ie-range-unit { font-size: 0.85rem; color: var(--ie-muted); }
.ie-more {
    display: block;
    margin: 0;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ie-red);
    background: transparent;
    border: none;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.ie-table-wrap.ie-expanded { max-height: none; }
.ie-field select:focus, .ie-field input:focus { outline: 2px solid rgba(163,31,52,0.35); outline-offset: 1px; }
.ie-count { font-size: 0.85rem; color: var(--ie-muted); }
.ie-btn {
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--ie-red);
    background: #fff;
    border: 1px solid var(--ie-red);
    border-radius: 999px;
    padding: 0.3rem 0.8rem;
    cursor: pointer;
}
.ie-btn:hover { background: #FBF0F1; }

/* ---- table ---- */
.ie-table-wrap {
    max-height: 460px;
    overflow: auto;
    border: 1px solid var(--ie-hair);
    border-radius: 6px;
}
.ie-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.84rem;
    min-width: 1040px;
}
.ie-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--ie-red);
    color: #fff;
    font-weight: 600;
    font-size: 0.76rem;
    line-height: 1.2;
    text-align: right;
    padding: 0.5rem 0.55rem;
    cursor: pointer;
    user-select: none;
    white-space: normal;
    vertical-align: bottom;
    border-bottom: 2px solid #7E1628;
}
.ie-table th.ie-left { text-align: left; }
.ie-table th.ie-check { cursor: default; width: 34px; text-align: left; }
.ie-table th.ie-check input[type="checkbox"] { width: 15px; height: 15px; accent-color: #fff; cursor: pointer; vertical-align: middle; }
.ie-table th:hover { background: #8B1A2E; }
.ie-table th .ie-sort { display: inline-block; width: 0.9em; opacity: 0.55; font-size: 0.7em; }
.ie-table th.ie-sorted .ie-sort { opacity: 1; }
.ie-table td {
    padding: 0.42rem 0.55rem;
    border-bottom: 1px solid var(--ie-grid);
    text-align: right;
    color: var(--ie-body);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.ie-table td.ie-left { text-align: left; }
.ie-table td.ie-name { font-weight: 600; color: var(--ie-ink); }
.ie-table tbody tr:nth-child(even) td { background: #FAFAF8; }
.ie-table tbody tr:hover td { background: #F4EEEA; }
.ie-table tbody tr.ie-on td { background: #FBEFF1; }
.ie-table tbody tr.ie-on td.ie-name { color: var(--ie-red); }
.ie-table input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--ie-red); cursor: pointer; }
.ie-table td.ie-neg { color: #B3261E; }
.ie-empty { padding: 1rem; color: var(--ie-muted); font-size: 0.9rem; }

/* ---- selection chips ---- */
.ie-selbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin: 0.9rem 0 0.5rem;
    font-size: 0.85rem;
}
.ie-selbar .ie-sellabel { font-weight: 700; color: var(--ie-ink); margin-right: 0.2rem; }
.ie-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--ie-paper);
    border: 1px solid var(--ie-hair);
    border-radius: 999px;
    padding: 0.2rem 0.55rem 0.2rem 0.7rem;
    font-size: 0.8rem;
    color: var(--ie-ink);
}
.ie-chip button {
    border: none;
    background: transparent;
    color: var(--ie-muted);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.1rem;
}
.ie-chip button:hover { color: var(--ie-red); }
.ie-hint { color: var(--ie-muted); font-size: 0.82rem; }

/* ---- chart ---- */
.ie-chart-title {
    font-family: 'Source Serif 4', Georgia, 'Times New Roman', serif;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--ie-ink);
    margin: 0.6rem 0 0.2rem;
    text-align: center;
}
.ie-chart-sub { text-align: center; font-size: 0.82rem; color: var(--ie-muted); margin-bottom: 0.4rem; }
.ie-chart-wrap { position: relative; width: 100%; }
.ie-chart { width: 100%; height: auto; display: block; }
.ie-chart text { font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; fill: var(--ie-body); }
.ie-chart .ie-axis-lbl { font-size: 13px; fill: var(--ie-muted); }
.ie-chart .ie-tick { font-size: 12.5px; }
.ie-chart .ie-grid { stroke: var(--ie-grid); stroke-width: 1; }
.ie-chart .ie-zero { stroke: #333; stroke-width: 1; }
.ie-chart .ie-hover-band { fill: rgba(163,31,52,0.06); }
.ie-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem 1.4rem;
    font-size: 0.82rem;
    color: var(--ie-body);
    margin: 0.35rem 0 0.2rem;
}
.ie-legend i { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px; margin-right: 0.4rem; }
.ie-legend i.ie-line { height: 3px; border-radius: 2px; vertical-align: 3px; }
.ie-tip {
    position: absolute;
    pointer-events: none;
    background: #fff;
    border: 1px solid var(--ie-hair);
    border-radius: 6px;
    box-shadow: 0 4px 14px rgba(35,40,46,0.14);
    padding: 0.45rem 0.6rem;
    font-size: 0.78rem;
    color: var(--ie-body);
    line-height: 1.45;
    opacity: 0;
    transition: opacity 0.12s;
    white-space: nowrap;
    z-index: 5;
}
.ie-tip b { color: var(--ie-ink); }
.mkt-explorer .ie-note { font-size: 0.8rem; color: var(--ie-muted); margin: 0.5rem 0 0; line-height: 1.45; }

@media (max-width: 720px) {
    .mkt-explorer { padding: 0.8rem; }
    .ie-field select, .ie-field input[type="search"], .ie-field input[type="number"] { min-width: 140px; }
    .ie-field-search { margin-left: 0; }
    .ie-chart .ie-tick { font-size: 16px; }
    .ie-chart .ie-axis-lbl { font-size: 16px; }
}
