/* ============================================================
   SSRM Dashboard V2 — Design Tokens & Responsive Rules
   Extends Bootstrap 5 vars, extends app.css.
   ============================================================ */

/* --- Design tokens ----------------------------------------- */
:root {
    /* Brand */
    --color-navy:        #003E73;
    --color-navy-light:  #005a9e;
    --color-navy-dark:   #002a50;

    /* Risk levels — from DefaultRiskMatrixColor */
    --risk-low:          #008000;
    --risk-moderate:     #00FF00;
    --risk-medium:       #FFFF00;
    --risk-high:         #FF8000;
    --risk-extreme:      #FF0000;

    /* Semantic aliases */
    --color-kpi-blue:    #1565c0;
    --color-kpi-red:     #d32f2f;
    --color-kpi-green:   #2e7d32;

    /* Surface */
    --surface-card:      #ffffff;
    --surface-hover:     #f8f9fa;
    --surface-page:      #f0f2f5;

    /* Borders */
    --border:            #dde1ea;
    --border-light:      #eaecf2;

    /* Text */
    --text-primary:      #1e2a3a;
    --text-secondary:    #4a5568;
    --text-muted:        #8896a7;

    /* Card */
    --card-radius:       8px;
    --card-shadow:       0 1px 4px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.04);

    /* Spacing */
    --widget-gap:        14px;

    /* Spinner */
    --spinner-size:      2rem;
    --spinner-border:    4px;
    --spinner-speed:     0.75s;
}

/* --- Spinner ----------------------------------------------- */
.dashboard-spinner {
    display: inline-block;
    width:  var(--spinner-size);
    height: var(--spinner-size);
    border: var(--spinner-border) solid rgba(0, 62, 115, 0.2);
    border-top-color: var(--color-navy);
    border-radius: 50%;
    animation: dashboard-spin var(--spinner-speed) linear infinite;
}

@keyframes dashboard-spin {
    to { transform: rotate(360deg); }
}

/* --- KPI Cards --------------------------------------------- */
.kpi-card {
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: var(--card-radius);
    padding: 14px 16px;
    box-shadow: var(--card-shadow);
    position: relative;
    overflow: hidden;
    transition: box-shadow 0.2s;
}
.kpi-card::after {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
}
.kpi-card.k-blue::after  { background: var(--color-kpi-blue); }
.kpi-card.k-red::after   { background: var(--color-kpi-red); }
.kpi-card.k-green::after { background: var(--color-kpi-green); }
.kpi-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}
.kpi-card .kpi-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}
.kpi-card .kpi-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 0;
    margin-bottom: 6px;
}
.kpi-icon {
    position: absolute;
    right: 14px;
    top: 14px;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}
.kpi-card.k-blue .kpi-icon { background: rgba(21,101,192,0.1); color: var(--color-kpi-blue); }
.kpi-card.k-red .kpi-icon  { background: rgba(211,47,47,0.1);  color: var(--color-kpi-red); }
.kpi-card.k-green .kpi-icon { background: rgba(46,125,50,0.1); color: var(--color-kpi-green); }

/* --- Column gutter overrides ------------------------------- */
/* Eliminate horizontal gutter between KPI cards (hot-reload safe, no rebuild needed) */
.row:has(.kpi-card) {
    --bs-gutter-x: 0;
}
/* Eliminate horizontal gutter between Risk Matrix and right panel */
.dashboard-stretch-row {
    --bs-gutter-x: 0;
}

/* --- Section headers --------------------------------------- */
.dashboard-section-header {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 10px;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.dashboard-section-header::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* --- Widget section ---------------------------------------- */
.dashboard-widget {
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    overflow: hidden;
}
.row > [class*="col-"] > .dashboard-widget {
    height: 100%;
}
.dashboard-stretch-row .dashboard-widget {
    height: 100%;
    min-height: 0;
}
.dashboard-stretch-row .dashboard-widget-body {
    overflow-y: auto;
    min-height: 0;
}
.dashboard-widget-header {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f5f6fa;
}
.dashboard-widget-title {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0;
}
.dashboard-widget-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
}
.dashboard-widget-body {
    padding: 14px 16px;
}
.card-action-btn {
    height: 26px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: #fff;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s;
}
.card-action-btn:hover {
    border-color: #1a7fd4;
    color: #1a7fd4;
}
.card-action-btn--active {
    background: #f0f4ff;
    border-color: #acc4ee;
    color: #1565c0;
}

/* --- Risk Distribution ------------------------------------- */
.rdist-layout {
    display: flex;
    gap: 16px;
    align-items: center;
}
.rdist-donut-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.rdist-donut {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    position: relative;
}
.rdist-donut-hole {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 52px; height: 52px;
    background: #fff;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.rdist-hole-val {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary, #222);
    line-height: 1;
}
.rdist-hole-lbl {
    font-size: 8.5px;
    color: #888;
}
.rdist-donut-title {
    font-size: 11px;
    font-weight: 600;
    color: #555;
    text-align: center;
}
.rdist-legend {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.rdist-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}
.rdist-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}
.rdist-label {
    font-size: 11px;
    color: #555;
    width: 52px;
    flex-shrink: 0;
}
.rdist-bar-track {
    flex: 1;
    background: #ebebeb;
    border-radius: 3px;
    height: 6px;
    overflow: hidden;
}
.rdist-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
    min-width: 2px;
}
.rdist-count {
    font-size: 11px;
    font-weight: 600;
    color: #333;
    min-width: 18px;
    text-align: right;
}

/* --- Risk Matrix ------------------------------------------- */
.dashboard-risk-matrices-row {
    display: flex;
    gap: 64px;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    padding: 16px 0;
}
.dashboard-risk-matrices-row > * {
    flex: 0 0 auto;
    min-width: 224px;
}
.risk-matrix-combined-row {
    display: flex;
    gap: 48px;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
}
.risk-matrix-wrapper {
    width: 304px;
    margin: 0 auto;
    display: flex;
    align-items: stretch;
}
.risk-matrix-main {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: 1fr auto auto;
    flex: 1;
    min-width: 0;
}
.risk-matrix-ylabel {
    transform: rotate(-90deg);
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-navy);
    display: flex;
    align-items: center;
    justify-content: center;
    padding-right: 4px;
    flex-shrink: 0;
    white-space: nowrap;
    transform-origin: center center;
    width: 1.5em;
}
.risk-matrix-yticks {
    grid-column: 1;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding-right: 2px;
}
.risk-matrix-ytick {
    font-size: 0.65rem;
    color: #6c757d;
    text-align: right;
    padding-right: 2px;
    line-height: 1;
}
.risk-matrix-grid {
    grid-column: 2;
    grid-row: 1;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: 0;
    aspect-ratio: 1 / 1;
    width: 100%;
    border: 1px solid #999;
}
.risk-matrix-cell {
    position: relative;
    border: 1px solid rgba(0,0,0,0.15);
    border-radius: 0;
}
.risk-matrix-xticks {
    grid-column: 2;
    grid-row: 2;
    position: relative;
    height: 1.2em;
}
.risk-matrix-xtick {
    position: absolute;
    font-size: 0.65rem;
    color: #6c757d;
    white-space: nowrap;
    transform: translateX(-50%);
}
.risk-matrix-xlabel {
    grid-column: 2;
    grid-row: 3;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-navy);
}

/* Data points inside cells */
.risk-matrix-dot {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    transform: translate(-50%, 50%);
    z-index: 1;
    cursor: default;
}
.risk-matrix-dot.dot-blue {
    background: #2196F3;
    border: 1.5px solid #fff;
}
.risk-matrix-dot.dot-combined {
    background: #dc3545;
    border: 3px solid #2196F3;
}
.risk-matrix-dot.dot-red {
    background: #dc3545;
    border: 1.5px solid #fff;
}
.risk-matrix-dot.dot-combined {
    background: #dc3545;
    border: 3px solid #003E73;
}

/* --- Risk Matrix legend ------------------------------------ */
.card-legend {
    display: flex;
    gap: 12px;
    align-items: center;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--text-secondary);
}
.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid;
}
.legend-dot--mitigated {
    border-style: dashed;
}
.matrix-action-btn {
    width: 26px;
    height: 26px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: #fff;
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.15s;
}
.matrix-action-btn:hover {
    border-color: #1a7fd4;
    color: #1a7fd4;
}
.matrix-action-group {
    position: absolute;
    right: 0;
    top: 0;
    display: flex;
    flex-direction: row;
    gap: 4px;
}

/* --- PDF export overrides ---------------------------------- */
.pdf-exporting .matrix-action-group,
.pdf-exporting .pdf-hide {
    display: none !important;
}

/* --- Responsive breakpoints -------------------------------- */

/* Tablet (≤768px) */
@media (max-width: 768px) {
    .dashboard-filter-bar {
        flex-wrap: wrap;
    }
    .dashboard-filter-bar > * {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    .kpi-card .kpi-value {
        font-size: 1.5rem;
    }
}

/* Mobile (≤576px) */
@media (max-width: 576px) {
    .dashboard-widget {
        padding: 0.75rem;
    }
    .kpi-card {
        padding: 1rem;
    }
    .kpi-card .kpi-value {
        font-size: 1.25rem;
    }
}

/* Top Risk List */
.hr-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 10px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: #fff;
    transition: border-color 0.15s;
}
.hr-item:hover { border-color: #003E73; }
.hr-item-rank {
    width: 22px; height: 22px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}
.hr-item-rank.r1 { background: #FF0000; }
.hr-item-rank.r2 { background: #FF8000; }
.hr-item-rank.r3 { background: #FFFF00; color: #000; }
.hr-item-rank.r4 { background: #00FF00; color: #000; }
.hr-item-rank.r5 { background: #008000; }
.hr-item-info { flex: 1; min-width: 0; }
.hr-item-name { font-size: 12px; font-weight: 600; color: #333; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hr-item-type { font-size: 10.5px; color: #888; }
.hr-item-risk { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.hr-item-badges { display: flex; gap: 3px; }

/* Sticky filter strip */
.dashboard-filter-strip {
    flex-shrink: 0;
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 4px 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    z-index: 10;
}
.dashboard-filter-strip .dashboard-filter-bar {
    margin-bottom: 0;
}
.filter-label {
    font-size: 11.5px;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
}
.filter-btn {
    height: 30px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: #fff;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.15s;
}
.filter-btn:hover {
    border-color: #1a7fd4;
    color: #1a7fd4;
}
.filter-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.dashboard-filter-bar .btn-outline-secondary {
    height: 30px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: #fff;
    color: var(--text-primary);
    font-size: 12px;
    padding: 0 8px;
    transition: all 0.15s;
}
.dashboard-filter-bar .btn-outline-secondary:hover,
.dashboard-filter-bar .btn-outline-secondary:focus {
    border-color: #1a7fd4;
    color: #1a7fd4;
    background: #fff;
    box-shadow: none;
}
.dashboard-filter-bar .btn-outline-secondary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Failure mode (Leak / Cold) chip checkboxes */
.failure-mode-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding-left: 4px;
    border-left: 1px solid var(--border);
    margin-left: 2px;
    height: 30px;
}
.failure-mode-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 26px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: #fff;
    color: var(--text-muted);
    font-size: 11.5px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s;
    margin: 0;
}
.failure-mode-chip input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}
.failure-mode-chip .failure-mode-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #cfd4da;
    transition: all 0.15s;
}
.failure-mode-chip:hover {
    border-color: #b6bcc4;
}
.failure-mode-chip--leak.is-active {
    border-color: #dc3545;
    background: rgba(220, 53, 69, 0.08);
    color: #b02a37;
}
.failure-mode-chip--leak.is-active .failure-mode-dot {
    background: #dc3545;
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.18);
}
.failure-mode-chip--cold.is-active {
    border-color: #2196F3;
    background: rgba(33, 150, 243, 0.08);
    color: #0f6cbd;
}
.failure-mode-chip--cold.is-active .failure-mode-dot {
    background: #2196F3;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.18);
}

/* Dashboard scroll area */
.dashboard-scroll-area {
    flex: 1;
    overflow-y: auto;
    background: var(--surface-page);
    scrollbar-width: thin;
    scrollbar-color: #c0c0c0 transparent;
}
.dashboard-scroll-area::-webkit-scrollbar {
    width: 6px;
}
.dashboard-scroll-area::-webkit-scrollbar-track {
    background: transparent;
}
.dashboard-scroll-area::-webkit-scrollbar-thumb {
    background: #c0c0c0;
    border-radius: 3px;
}
.dashboard-scroll-area::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* --- Savings Chart ----------------------------------------- */
.savings-chart {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.savings-subtitle {
    font-size: 10.5px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.savings-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.savings-label {
    font-size: 11px;
    color: var(--text-secondary);
    width: 120px;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.savings-bar-wrap {
    flex: 1;
    background: var(--border-light);
    border-radius: 4px;
    height: 18px;
    overflow: hidden;
    position: relative;
}
.savings-bar {
    height: 100%;
    border-radius: 4px;
    display: flex;
    align-items: center;
    padding-left: 8px;
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    min-width: 0;
}
.savings-bar--leak { background: linear-gradient(90deg, #e53935, #ef9a9a); }
.savings-bar--cold { background: linear-gradient(90deg, #1565c0, #90caf9); }
.savings-value {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-primary);
    min-width: 60px;
    text-align: right;
}
.savings-totals {
    margin-top: 12px;
    display: flex;
    gap: 10px;
}
.savings-total-card {
    flex: 1;
    border-radius: 6px;
    padding: 8px;
    text-align: center;
}
.savings-total-card--leak {
    background: #fff8e1;
    border: 1px solid #fde68a;
}
.savings-total-card--leak .savings-total-label { color: #78350f; }
.savings-total-card--leak .savings-total-value { color: #d32f2f; }
.savings-total-card--cold {
    background: #e3f2fd;
    border: 1px solid #90caf9;
}
.savings-total-card--cold .savings-total-label { color: #0d47a1; }
.savings-total-card--cold .savings-total-value { color: #1565c0; }
.savings-total-label {
    font-size: 10px;
    font-weight: 600;
}
.savings-total-value {
    font-size: 16px;
    font-weight: 700;
}

/* --- Type Breakdown ---------------------------------------- */
.type-bars {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.type-bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.type-bar-label {
    font-size: 11.5px;
    color: var(--text-secondary);
    width: 150px;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.type-bar-track {
    flex: 1;
    background: var(--border-light);
    border-radius: 4px;
    height: 14px;
    overflow: hidden;
}
.type-bar-fill {
    height: 100%;
    border-radius: 4px;
}
.type-bar-count {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 28px;
    text-align: right;
}
.type-risk-section {
    margin-top: 16px;
}
.type-risk-title {
    font-size: 10.5px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}
.type-risk-rows {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.type-risk-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
}
.type-risk-name {
    color: var(--text-secondary);
    width: 140px;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.type-risk-badges {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.risk-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    height: 20px;
    border-radius: 3px;
    font-size: 10.5px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
}
.risk-badge--extreme { background: #FF0000; }
.risk-badge--high { background: #FF8000; }
.risk-badge--medium { background: #FFFF00; color: #333; }
.risk-badge--low { background: #008000; }

/* --- Summary Table ----------------------------------------- */
.summary-table {
    width: 100%;
    border-collapse: collapse;
}
.summary-table th {
    background: var(--bg-table-hd, #f5f6fa);
    padding: 8px 12px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}
.summary-table th.center { text-align: center; }
.summary-table th.right { text-align: right; }
/* Non-sortable headers (collapsed widget): no sort affordance (#6313). */
.summary-table--static th { cursor: default; }
.summary-table td {
    padding: 9px 12px;
    font-size: 12px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}
.summary-table td.center { text-align: center; }
.summary-table td.right { text-align: right; }
.summary-table tr:nth-child(even) td { background: #fafbfd; }
.summary-table tr:hover td { background: #f0f4ff; }
.summary-table tr:last-child td { border-bottom: none; }
.type-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10.5px;
    font-weight: 600;
}
.cost-saving { color: var(--color-kpi-green, #2e7d32); font-weight: 600; }
.cost-zero { color: var(--text-muted); }

/* Top-N label shown next to the Application Risk Summary title (#6313).
   No .pdf-hide: it must print so the PDF reads as an intentional top-N ranking. */
.top4-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 20px;
    padding: 0 9px;
    border-radius: 11px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .2px;
    background: #fdecea;
    color: #b3261e;
    border: 1px solid #f3c6c1;
}
.top4-pill svg { width: 11px; height: 11px; }

/* --- Steam Trap Select Grid -------------------------------- */
.sts-filter-bar {
    background: #f9f9fb;
    border: 1px solid var(--border-light);
    border-radius: 6px;
}
.sts-filter-label {
    font-size: 10.5px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .3px;
}
.sts-filter-select {
    font-size: 12px;
}

.sts-grid-wrapper {
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden; /* fallback for browsers without overflow: clip */
    overflow: clip;   /* does not create a scroll container; preserves sticky inside sts-grid-scroll */
    background: var(--surface-card);
}
.sts-grid-toolbar {
    background: #f5f6fa;
    border-bottom: 1px solid var(--border-light);
}
.sts-selected-count {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--color-navy, #003E73);
}
.sts-search-box {
    width: 200px;
    font-size: 12px;
}
.sts-grid-scroll {
    max-height: 360px;
    overflow-y: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Grid row selection highlight */
.sts-row-selected td {
    background: #d6ecfa !important;
}
.sts-row-selected:hover td {
    background: #c4e2f7 !important;
}
.sts-col-cb {
    width: 44px;
    text-align: center;
    position: sticky;
    left: 0;
    z-index: 2;
}
.sts-col-cb .form-check-input {
    width: 1.15rem;
    height: 1.15rem;
    margin: 0 !important;
    vertical-align: middle;
    cursor: pointer;
}
th.sts-col-cb {
    background: var(--bg-table-hd, #f5f6fa);
    text-align: center;
    vertical-align: middle;
    padding: 8px 4px !important;
}
/* position: sticky on .sts-col-cb makes both th and td containing blocks —
   use absolute centering so Bootstrap margin-top/vertical-align cannot interfere */
th.sts-col-cb .form-check-input,
td.sts-col-cb .form-check-input {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0 !important;
}
td.sts-col-cb {
    background: var(--surface-card, #fff);
    padding: 9px 4px !important;
}
.summary-table tr:nth-child(even) td.sts-col-cb { background: #fafbfd; }
.summary-table tr:hover td.sts-col-cb { background: #f0f4ff; }
.sts-row-selected td.sts-col-cb { background: #d6ecfa !important; }
.sts-row-selected:hover td.sts-col-cb { background: #c4e2f7 !important; }

/* Selected summary / tag box */
.sts-selected-summary {
    background: #f9f9fb;
    border: 1px solid var(--border-light);
    border-radius: 6px;
}
.sts-summary-label {
    font-size: 10.5px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .3px;
}
.sts-tag-list {
    max-height: 72px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.sts-tag {
    display: inline-block;
    background: #e1effe;
    color: #1e40af;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.5;
    margin-right: 5px;
    margin-bottom: 3px;
    white-space: nowrap;
}
.sts-tag-remove {
    display: inline-block;
    cursor: pointer;
    font-weight: 700;
    color: #6b7280;
    font-size: 13px;
    line-height: 1;
    margin-left: 4px;
}
.sts-tag-remove:hover {
    color: #dc2626;
}
