/* Card metric explorer. Chart colors are shared with the reading guide. */
.metrics-page {
  --series-mean: #4dd4ac;
  --series-median: #8faeff;
  --series-value: #4dd4ac;
  max-width: 1480px;
  padding-top: 30px;
}
.metrics-page [hidden] { display: none !important; }
.metrics-page a, .metrics-page button, .metrics-page select, .metrics-page summary { -webkit-tap-highlight-color: transparent; }
.metrics-page :is(button, a, input, select, summary, [tabindex]):focus-visible { outline: 2px solid var(--warm); outline-offset: 3px; }
.metrics-page button:disabled { cursor: not-allowed; filter: none; opacity: .45; }
.metrics-page header { margin-bottom: 25px; padding-bottom: 23px; }
.metrics-page .dashboard-nav { margin-bottom: 28px; }
.explorer-intro { display: flex; justify-content: space-between; align-items: end; gap: 24px; }
.explorer-description { color: var(--muted); font-size: .87rem; margin: 7px 0 0; }
.explorer-mark { color: #738b9c; font-size: .7rem; letter-spacing: .12em; white-space: nowrap; }
.explorer-main { gap: 24px; }
.subject-panel { display: flex; flex-wrap: wrap; align-items: center; gap: 20px 26px; min-width: 0; }
.segmented-control { display: inline-flex; border: 1px solid var(--line); border-radius: 11px; padding: 4px; background: rgba(16, 26, 37, .8); gap: 3px; }
.segmented-control button { color: #a7b8c5; background: transparent; border-radius: 7px; font-size: .88rem; font-weight: 550; padding: 9px 20px; }
.segmented-control button[aria-pressed="true"] { color: #8cf1ce; background: #213d38; box-shadow: inset 0 0 0 1px rgba(91, 223, 182, .12); }
.subject-field { min-width: 0; }
.subject-field > label { color: var(--muted); font-size: .76rem; margin-right: 10px; }
.subject-field > select { min-width: 190px; }
#stock-form { display: grid; grid-template-columns: auto minmax(160px, 330px); gap: 5px 12px; align-items: center; }
#stock-form label { color: var(--muted); font-size: .76rem; }
.stock-input-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.stock-input-row button { padding-inline: 12px; font-size: .82rem; }
.field-hint { color: #8195a5; font-size: .69rem; grid-column: 2; }
.subject-heading { display: flex; gap: 20px; align-items: center; justify-content: space-between; }
.subject-heading h1 { font-size: clamp(1.85rem, 3.5vw, 2.7rem); letter-spacing: -.04em; line-height: 1.2; margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.subject-subtitle { color: var(--muted); font-size: .77rem; margin: 8px 0 0; overflow-wrap: anywhere; }
.subject-heading-actions { display: flex; align-items: center; gap: 16px; }
.catalog-count { color: var(--muted); font-size: .76rem; text-align: right; }
.metrics-page .refresh-button { font-size: .77rem; padding: 7px 13px; }
.explorer-layout { display: grid; grid-template-columns: minmax(0, 1fr) 254px; gap: 24px; align-items: start; }
.explorer-workspace, .explorer-notes { min-width: 0; }
.metric-controls { border: 1px solid var(--line); border-radius: 13px; padding: 20px; background: linear-gradient(135deg, rgba(20, 34, 48, .82), rgba(16, 26, 37, .85)); }
.metric-selection { display: grid; grid-template-columns: minmax(0, 1fr) minmax(180px, .65fr); gap: 16px; }
.metric-selection:has(#statistics-field[hidden]) { grid-template-columns: minmax(0, 1fr); }
.field { display: grid; gap: 7px; min-width: 0; }
.field > span { color: #a1b2bf; font-size: .73rem; }
.field :is(input, select) { width: 100%; font-size: .85rem; min-height: 40px; }
.metric-choice select { color: #eef6fa; font-weight: 620; }
.metric-context { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; color: var(--muted); margin: 12px 0 18px; min-height: 25px; font-size: .73rem; }
.metric-context .pill { font-size: .67rem; }
.context-separator { color: #527080; }
.range-toolbar { display: flex; gap: 12px; align-items: end; border-top: 1px solid rgba(38, 55, 70, .7); padding-top: 17px; }
.range-fields { display: grid; grid-template-columns: minmax(0, 1fr) 10px minmax(0, 1fr); gap: 10px; align-items: end; flex: 1; min-width: 0; }
.range-dash { color: #667e8d; padding-bottom: 9px; text-align: center; font-size: .8rem; }
#apply-range { white-space: nowrap; min-height: 40px; font-size: .81rem; }
.range-presets { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin: 14px 0 -2px; }
.preset-label { color: #7f95a5; font-size: .69rem; margin-right: 6px; }
.range-presets button { background: transparent; color: #a1b3c0; font-size: .72rem; font-weight: 500; border-radius: 5px; padding: 5px 10px; }
.range-presets button[aria-pressed="true"] { color: #83e8c8; background: rgba(77, 212, 172, .1); }
.series-feedback { margin: 14px 2px; }
.load-status { color: #8fa8b7; font-size: .76rem; margin: 0; min-height: 18px; }
.load-error { border: 1px solid rgba(255, 143, 157, .33); border-radius: 9px; background: rgba(255, 143, 157, .07); color: #ffc0c7; padding: 12px 14px; font-size: .83rem; overflow-wrap: anywhere; }
.series-content { display: grid; gap: 18px; }
.latest-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.latest-cards > * { min-width: 0; background: rgba(16, 26, 37, .86); border: 1px solid var(--line); border-radius: 11px; padding: 16px 18px; }
.latest-cards :is(h3, .stat-label, .metric-label, .latest-label) { color: #a3b7c5; font-size: .73rem; font-weight: 500; margin: 0 0 7px; }
.latest-cards :is(strong, .stat-value, .metric-value) { display: block; font-size: clamp(1.45rem, 2.5vw, 1.85rem); font-weight: 640; letter-spacing: -.035em; font-variant-numeric: tabular-nums; line-height: 1.35; overflow-wrap: anywhere; }
.latest-cards :is(p, .stat-meta, .metric-meta) { color: #839bac; font-size: .7rem; margin: 7px 0 0; }
.latest-cards [data-statistic="mean"] strong { color: var(--series-mean); }
.latest-cards [data-statistic="median"] strong { color: var(--series-median); }
.latest-cards .statistic-mean strong, .latest-cards .statistic-value strong { color: var(--series-mean); }
.latest-cards .statistic-median strong { color: var(--series-median); }
.latest-cards .latest-period { color: #adbdc8; margin-top: 8px; }
.latest-cards .latest-note { color: #7893a5; margin-top: 3px; font-size: .67rem; }
.chart-panel { background: rgba(14, 24, 34, .83); border: 1px solid var(--line); border-radius: 13px; padding: 21px 22px 15px; min-width: 0; }
.chart-heading-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; }
.chart-heading-row .section-label { color: #8199aa; font-size: .62rem; letter-spacing: .13em; }
.chart-heading-row h2 { font-size: 1rem; font-weight: 650; margin: 5px 0 0; }
.series-legend { display: flex; flex-wrap: wrap; justify-content: end; gap: 8px 15px; font-size: .71rem; color: #a6b9c6; }
.series-legend > * { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch, .reading-swatch { flex: 0 0 auto; width: 16px; height: 3px; border-radius: 3px; display: inline-block; }
.mean-swatch, .legend-swatch.mean, .legend-swatch.value { background: var(--series-mean); }
.median-swatch, .legend-swatch.median { background: var(--series-median); }
.legend-item::before { content: ""; width: 16px; height: 3px; border-radius: 3px; background: var(--series-mean); }
.legend-item.statistic-median::before { background: repeating-linear-gradient(90deg, var(--series-median) 0 6px, transparent 6px 9px); }
.metric-chart { min-height: 280px; width: 100%; min-width: 0; position: relative; }
.metric-chart svg, .sample-chart svg { display: block; max-width: 100%; width: 100%; overflow: visible; }
.metric-chart svg { min-height: 260px; }
.metric-chart svg text, .sample-chart svg text { fill: #8097a8; font-family: inherit; }
.metric-chart .chart-axis-label, .sample-chart .chart-axis-label { font-size: 10px; font-variant-numeric: tabular-nums; }
.metric-chart .chart-empty-label { font-size: 11px; }
.chart-grid, .grid-line, .chart-grid-line { stroke: rgba(127, 152, 172, .13); stroke-width: 1; }
.chart-zero-line { stroke: #516677; stroke-width: 1; stroke-dasharray: 4 4; }
.chart-cursor { stroke: #acc3d2; stroke-width: 1; stroke-dasharray: 3 4; pointer-events: none; }
.chart-axis, .axis-line { stroke: #2e4454; stroke-width: 1; }
.series-line { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.series-line.mean, .series-line.value { stroke: var(--series-mean); }
.series-line.median { stroke: var(--series-median); }
.chart-detail { border-top: 1px solid rgba(38, 55, 70, .65); color: #a1b6c5; font-size: .73rem; min-height: 37px; padding-top: 11px; margin: 9px 0 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.sample-section { padding-top: 18px; margin-top: 10px; }
.sample-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 9px; }
.sample-heading h3 { color: #bccbd4; font-size: .75rem; font-weight: 600; margin: 0; }
.sample-heading span { color: #7c93a3; font-size: .65rem; }
.sample-chart { min-height: 70px; }
.coverage-label { color: #7f96a6; border-top: 1px solid rgba(38, 55, 70, .65); padding-top: 12px; margin: 13px 0 0; font-size: .69rem; }
.series-table-panel { min-width: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: rgba(16, 26, 37, .55); }
.table-heading-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 17px 20px; }
.table-heading-row h2 { font-size: .9rem; margin: 0; }
.table-heading-row .hint { font-size: .68rem; margin: 4px 0 0; }
.table-heading-row button { font-size: .72rem; padding: 7px 10px; }
.series-table-scroll { max-height: 390px; overflow: auto; scrollbar-color: #354d5f #101a25; }
#series-table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .78rem; font-variant-numeric: tabular-nums; }
#series-table th, #series-table td { padding: 11px 20px; text-align: right; white-space: nowrap; border-top: 1px solid rgba(38, 55, 70, .6); }
#series-table th { background: #142230; color: #8fa5b5; font-size: .7rem; font-weight: 550; }
#series-table thead th { position: sticky; top: 0; z-index: 1; }
#series-table :is(th, td):first-child { text-align: left; }
#series-table tbody tr:hover { background: rgba(77, 212, 172, .035); }
#series-table td { color: #c1d0da; }
.metric-empty { display: grid; justify-items: center; text-align: center; border: 1px dashed #314454; border-radius: 13px; background: rgba(16, 26, 37, .5); padding: 58px 24px; }
.empty-symbol { display: grid; place-items: center; width: 43px; height: 43px; border: 1px solid var(--line); border-radius: 50%; color: #7693a5; margin-bottom: 15px; }
.metric-empty h2 { font-size: 1rem; margin: 0 0 9px; }
.metric-empty p { max-width: 380px; color: var(--muted); font-size: .8rem; margin: 0; }
.explorer-notes { display: grid; gap: 17px; }
.notes-card { border: 1px solid #243746; border-radius: 12px; padding: 21px 20px; background: rgba(16, 26, 37, .56); }
.notes-card > .section-label { color: #809baa; font-size: .62rem; letter-spacing: .12em; }
.notes-card > h2 { font-size: .98rem; font-weight: 600; margin: 12px 0 22px; }
.reading-item { display: grid; grid-template-columns: 16px minmax(0, 1fr); align-items: start; gap: 10px; margin-top: 19px; }
.reading-item .reading-swatch { margin-top: 9px; }
.reading-item h3 { font-size: .81rem; font-weight: 600; margin: 0 0 5px; }
.reading-item p { color: #8ba3b3; font-size: .73rem; line-height: 1.75; margin: 0; }
.reading-tip { border-top: 1px solid var(--line); color: #a0b7c5; font-size: .73rem; line-height: 1.8; padding-top: 16px; margin: 20px 0 0; }
.source-card > p:not(.section-label) { color: #95acbb; font-size: .73rem; line-height: 1.8; margin: 12px 0 0; overflow-wrap: anywhere; }
.calculation-details { border-top: 1px solid var(--line); margin-top: 17px; padding-top: 14px; }
.calculation-details summary { color: #b2c8d5; font-size: .74rem; cursor: pointer; }
.calculation-details ul { padding-left: 16px; margin: 13px 0 0; color: #8fa7b7; font-size: .7rem; line-height: 1.85; }
.calculation-details li + li { margin-top: 8px; }
.explorer-footnote { color: #718b9d; font-size: .69rem; line-height: 1.8; margin: 0; padding: 0 5px; }

/* Small cross-page entry; the original Cards layout remains unchanged. */
.metrics-entry { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 17px 20px; border: 1px solid #305147; border-radius: 11px; background: linear-gradient(110deg, rgba(77, 212, 172, .085), rgba(16, 26, 37, .65)); color: #e0f3ed; text-decoration: none; }
.metrics-entry strong { display: block; font-size: .88rem; font-weight: 650; }
.metrics-entry p { color: #8facac; font-size: .76rem; margin: 4px 0 0; }
.metrics-entry > span { color: #78dfbc; font-size: 1.2rem; padding-inline: 4px; }
.metrics-entry:hover { border-color: var(--accent); }
.metrics-entry:focus-visible { outline: 2px solid var(--warm); outline-offset: 3px; }

@media (max-width: 1100px) {
  .metrics-page { padding-inline: 28px; }
  .explorer-layout { grid-template-columns: minmax(0, 1fr) 224px; gap: 18px; }
  .notes-card { padding: 18px 16px; }
  .metric-controls { padding: 17px; }
  .range-toolbar { flex-wrap: wrap; }
  .range-fields { flex-basis: 100%; }
  #apply-range { margin-left: auto; }
}
@media (max-width: 880px) {
  .explorer-layout { grid-template-columns: minmax(0, 1fr); }
  .explorer-notes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .explorer-footnote { grid-column: 1 / -1; }
  .range-toolbar { flex-wrap: nowrap; }
  .range-fields { flex-basis: auto; }
  .explorer-mark { display: none; }
}
@media (max-width: 580px) {
  .metrics-page { padding: 23px 16px 45px; }
  .metrics-page .dashboard-nav { gap: 24px; margin-bottom: 24px; }
  .explorer-description { max-width: 310px; font-size: .8rem; line-height: 1.8; }
  .explorer-main { gap: 20px; }
  .subject-panel { align-items: stretch; }
  .segmented-control { width: 100%; }
  .segmented-control button { flex: 1; padding: 9px 8px; font-size: .82rem; }
  .subject-field { width: 100%; }
  .subject-field > label { display: block; margin: 0 0 7px; }
  .subject-field > select { width: 100%; }
  #stock-form { grid-template-columns: minmax(0, 1fr); gap: 7px; }
  .field-hint { grid-column: 1; }
  .subject-heading { align-items: start; gap: 12px; }
  .subject-heading-actions { flex-direction: column-reverse; align-items: end; gap: 7px; }
  .catalog-count { font-size: .65rem; max-width: 116px; }
  .subject-subtitle { font-size: .7rem; }
  .metric-controls { padding: 16px 14px; }
  .metric-selection { grid-template-columns: minmax(0, 1fr); gap: 13px; }
  .metric-context { gap: 7px; margin-bottom: 15px; font-size: .69rem; }
  .range-toolbar { flex-wrap: wrap; gap: 13px; }
  .range-fields { flex-basis: 100%; gap: 6px; grid-template-columns: minmax(0, 1fr) 8px minmax(0, 1fr); }
  .range-fields input, .range-fields select { padding-inline: 7px; font-size: .76rem; }
  #apply-range { width: 100%; }
  .range-presets { gap: 2px; }
  .range-presets button { padding-inline: 7px; font-size: .69rem; }
  .preset-label { margin-right: 2px; font-size: .66rem; }
  .latest-cards { gap: 9px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics-page:has(#quarter-fields:not([hidden])) .latest-cards { grid-template-columns: minmax(0, 1fr); }
  .latest-cards > * { padding: 14px 12px; }
  .latest-cards :is(strong, .stat-value, .metric-value) { font-size: 1.45rem; }
  .chart-panel { padding: 17px 13px 13px; }
  .chart-heading-row { gap: 10px; align-items: start; }
  .series-legend { gap: 5px 10px; font-size: .65rem; }
  .metric-chart { min-height: 210px; }
  .metric-chart svg { min-height: 190px; }
  .chart-detail { font-size: .67rem; line-height: 1.7; }
  .sample-heading span { font-size: .62rem; }
  .table-heading-row { padding: 15px 14px; }
  #series-table th, #series-table td { padding: 11px 14px; }
  .explorer-notes { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .notes-card { padding: 19px 18px; }
  .notes-card > h2 { margin-bottom: 15px; }
  .reading-item { margin-top: 14px; }
  .metrics-entry { padding: 15px; }
  .metrics-entry p { font-size: .71rem; }
}
@media (prefers-reduced-motion: reduce) {
  .metrics-page *, .metrics-page *::before, .metrics-page *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
