/* ==========================================================================
   CHAIN WEAR ANALYSIS (analysis/): sidebar of filters and tests, tabs for the
   wear chart, elongation data, test metadata and rig performance. The chart
   itself is styled in testing.css (.ec-*).
   ========================================================================== */
.an-tabs { margin-left: auto; }
.an-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 18px; align-items: start; }
.an-side { padding: 16px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 16px; max-height: calc(100vh - 140px); overflow: hidden; }
.an-main { padding: 18px 20px 20px; min-height: 480px; }

.an-sec { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.an-sec-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); display: flex; justify-content: space-between; }
.an-sec-title span { text-transform: none; letter-spacing: 0; font-weight: 500; }
.an-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.an-filter {
    display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 20px;
    border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
    font: inherit; font-size: 12.5px; cursor: pointer;
}
.an-filter i { font-size: 9px; color: var(--ink-3); }
.an-filter:hover { border-color: var(--line-strong); color: var(--ink); }
.an-filter.is-on { border-color: var(--focus); background: var(--accent-soft); color: var(--ink); }
.an-filter-menu { width: 260px; max-height: 360px; }

.an-tests { flex: 1; overflow: hidden; }
.an-tests .prop-search { margin: 0; width: 100%; }
.an-test-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.an-test-list { overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin: 0 -6px; padding: 0 6px; min-height: 120px; max-height: calc(100vh - 420px); }
.an-test { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 6px; cursor: pointer; }
.an-test:hover { background: var(--surface-2); }
.an-test.is-on { background: var(--surface-2); }
.an-test .ec-key { border: 1px solid var(--line); }
.an-test-name { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.an-test-name b { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.an-test-name small { font-size: 11.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-test-n { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.an-check { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; }

.an-controls { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; margin-bottom: 12px; }
.an-param { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); }
.an-param select, .an-param input {
    font: inherit; font-size: 12.5px; color: var(--ink); background: var(--surface);
    border: 1px solid var(--line-strong); border-radius: 6px; padding: 4px 8px; outline: none;
}
.an-param input[type=number] { width: 64px; }
.an-param select:focus, .an-param input:focus { border-color: var(--focus); }
.an-controls .seg-tabs button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.an-note { font-size: 12.5px; color: var(--ink-3); margin-top: 8px; }

.an-table { max-height: calc(100vh - 260px); overflow: auto; }
.an-table tr.is-excluded td { color: var(--ink-3); }
.an-table tbody tr[data-an-open] { cursor: pointer; }
.an-table tbody tr[data-an-open]:hover td { background: var(--surface-2); }
.an-sort { background: none; border: 0; font: inherit; color: inherit; cursor: pointer; padding: 0; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.an-sort i { font-size: 10px; }

.an-empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 60px 24px; color: var(--ink-2); }
.an-empty-state i { font-size: 30px; color: var(--ink-3); }
.an-empty-state b { color: var(--ink); font-size: 15px; }
.an-empty-state span { max-width: 560px; font-size: 13px; line-height: 1.6; }

/* Chart additions: trendlines and ±1σ bands (elongation-chart.js) */
.ec-trend { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.ec-band { opacity: 0.14; stroke: none; }
.ec-line.is-faint { opacity: 0.3; stroke-width: 1.5; }

@media (max-width: 900px) {
    .an-layout { grid-template-columns: minmax(0, 1fr); }
    .an-side { position: static; max-height: none; }
    .an-test-list { max-height: 260px; }
    .an-tabs { margin-left: 0; overflow-x: auto; max-width: 100%; }
}
