/* Liability Map. Filter dropdown, chip and modal shells come from v2-styles.css;
   the severity badge colours come from jobs/deficiencies/index.css. */

.liability-page {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ===== Exposure strip ===== */
.exposure-strip {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
}

.exposure-card {
    position: relative;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px 18px;
    overflow: hidden;
}

/* Accent rail rather than a filled card, so five of them side by side stay calm. */
.exposure-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: #cbd5e1;
}

.exposure-primary::before { background: linear-gradient(180deg, #dc2626, #f59e0b); }
.exposure-danger::before { background: #dc2626; }
.exposure-warn::before { background: #f59e0b; }

.exposure-label {
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.exposure-value {
    margin-top: 6px;
    font-size: 30px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.exposure-primary .exposure-value {
    background: linear-gradient(90deg, #b91c1c, #ea580c);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.exposure-sub {
    margin-top: 6px;
    font-size: 12px;
    color: #64748b;
}

/* ===== Toolbar ===== */
.map-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.map-modes {
    display: inline-flex;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
}

.map-mode {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: none;
    background: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s ease;
}

.map-mode:hover { color: #0f172a; }

.map-mode.active {
    background: #ffffff;
    color: #0f172a;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

.map-filters {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-menu { position: relative; }

/* ===== Include-resolved switch ===== */
.map-switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.map-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.map-switch-track {
    width: 36px;
    height: 20px;
    border-radius: 999px;
    background: #cbd5e1;
    position: relative;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.map-switch-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ffffff;
    transition: transform 0.2s ease;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.25);
}

.map-switch input:checked + .map-switch-track { background: #059669; }
.map-switch input:checked + .map-switch-track .map-switch-thumb { transform: translateX(16px); }
.map-switch input:focus-visible + .map-switch-track { outline: 2px solid #93c5fd; outline-offset: 2px; }

.map-switch-label {
    font-size: 13px;
    color: #475569;
    font-weight: 500;
}

/* ===== Layout ===== */
.liability-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 16px;
    min-height: 620px;
}

.map-shell {
    position: relative;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    background: #f4f6f8;
}

#liability-map {
    position: absolute;
    inset: 0;
}

/* ===== Map overlays ===== */
.map-legend {
    position: absolute;
    left: 14px;
    bottom: 14px;
    z-index: 2;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px 14px;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
}

.legend-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin-bottom: 8px;
}

.legend-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #334155;
    padding: 2px 0;
}

.legend-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-note {
    margin-left: auto;
    color: #94a3b8;
    font-size: 11px;
}

.band-critical { background: #dc2626; }
.band-high { background: #ea580c; }
.band-moderate { background: #d97706; }
.band-low { background: #0891b2; }

.legend-help {
    margin-top: 10px;
    padding: 0;
    background: none;
    border: none;
    color: #1e40af;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-help:hover { text-decoration: underline; }

.map-gap-banner {
    position: absolute;
    top: 14px;
    left: 14px;
    right: 14px;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 251, 235, 0.97);
    border: 1px solid #fde68a;
    color: #92400e;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 13px;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.1);
}

.map-gap-link {
    margin-left: auto;
    background: none;
    border: none;
    color: #92400e;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    text-decoration: underline;
    white-space: nowrap;
}

.map-empty {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: #f8fafc;
    color: #94a3b8;
}

.map-empty i { font-size: 40px; }
.map-empty p { margin: 0; font-size: 14px; }

/* ===== Info window ===== */
.liability-info {
    font-size: 13px;
    color: #1e293b;
    min-width: 260px;
}

.info-band {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 8px;
}

.info-title {
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.3;
}

.info-sub {
    font-size: 12px;
    color: #64748b;
    margin-top: 2px;
}

.info-metrics {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin: 12px 0;
    padding: 10px 0;
    border-top: 1px solid #f1f5f9;
    border-bottom: 1px solid #f1f5f9;
}

.info-metric {
    display: flex;
    flex-direction: column;
    font-size: 10px;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.info-metric span {
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
    text-transform: none;
    letter-spacing: 0;
}

.info-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
    font-size: 11px;
}

.info-bar-label { width: 86px; color: #64748b; flex-shrink: 0; }
.info-bar-count { width: 22px; text-align: right; font-weight: 600; }

.info-bar {
    flex: 1;
    height: 7px;
    background: #f1f5f9;
    border-radius: 999px;
    overflow: hidden;
}

.info-bar-fill {
    display: block;
    height: 100%;
    border-radius: 999px;
}

/* Reuse the severity palette as solid fills for the bars. */
.info-bar-fill.severity-unclassified { background: #991b1b; }
.info-bar-fill.severity-critical { background: #dc2626; }
.info-bar-fill.severity-impairment { background: #2563eb; }
.info-bar-fill.severity-noncritical { background: #f59e0b; }

.info-findings-title {
    margin-top: 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
}

.info-findings {
    list-style: none;
    margin: 6px 0 0 0;
    padding: 0;
}

.info-findings li {
    padding: 5px 0;
    border-bottom: 1px solid #f1f5f9;
}

.info-findings li:last-child { border-bottom: none; }

.info-findings a {
    color: #1e40af;
    font-weight: 500;
    text-decoration: none;
    display: block;
}

.info-findings a:hover { text-decoration: underline; }

.info-finding-meta {
    display: block;
    font-size: 11px;
    color: #94a3b8;
    margin-top: 1px;
}

.info-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

/* ===== Rail ===== */
.liability-rail {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.rail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.rail-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 8px;
}

.rail-header h3 i { color: #dc2626; }

.rail-count {
    font-size: 11px;
    color: #94a3b8;
}

.rail-body {
    flex: 1;
    overflow-y: auto;
    max-height: 620px;
    padding: 6px;
}

.rail-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
    padding: 10px;
    background: none;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    transition: all 0.15s ease;
}

.rail-item:hover {
    background: #f8fafc;
    border-color: #e2e8f0;
}

.rail-item.active {
    background: #eff6ff;
    border-color: #bfdbfe;
}

.rail-rank {
    flex-shrink: 0;
    width: 20px;
    font-size: 11px;
    font-weight: 700;
    color: #94a3b8;
    padding-top: 2px;
    font-variant-numeric: tabular-nums;
}

.rail-main {
    flex: 1;
    min-width: 0;
}

.rail-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #0f172a;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rail-meta {
    display: block;
    font-size: 11px;
    color: #94a3b8;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rail-track {
    display: block;
    height: 5px;
    background: #f1f5f9;
    border-radius: 999px;
    margin: 6px 0 4px;
    overflow: hidden;
}

.rail-fill {
    display: block;
    height: 100%;
    border-radius: 999px;
}

.rail-stats {
    display: block;
    font-size: 11px;
    color: #64748b;
}

.rail-score {
    flex-shrink: 0;
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
    font-variant-numeric: tabular-nums;
    padding-top: 2px;
}

/* ===== Scoring modal ===== */
.scoring-intro {
    font-size: 13px;
    color: #334155;
    line-height: 1.6;
    margin: 0 0 14px 0;
}

.scoring-heading {
    margin: 18px 0 8px;
    font-size: 13px;
    font-weight: 700;
    color: #0f172a;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.scoring-table { margin-bottom: 12px; }

.scoring-note {
    display: flex;
    gap: 10px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 12.5px;
    color: #92400e;
    line-height: 1.55;
    margin: 0 0 8px 0;
}

.scoring-note i { margin-top: 2px; }

.scoring-intro code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

.text-muted {
    color: #94a3b8;
    font-size: 13px;
    font-style: italic;
    padding: 12px;
    margin: 0;
}

@media (max-width: 1400px) {
    .exposure-strip { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1100px) {
    .liability-layout {
        grid-template-columns: 1fr;
    }

    .map-shell { min-height: 460px; }
    .rail-body { max-height: 380px; }
}

@media (max-width: 700px) {
    .exposure-strip { grid-template-columns: 1fr 1fr; }
    .map-toolbar { align-items: flex-start; flex-direction: column; }
}
