/* ======================================================================
   Settings → Agent quality (js/agent-metrics-admin.js)
   Chart chrome uses the app tokens; the two series colors are the dataviz
   reference slots 1-2 (blue, orange), validated on the white card surface:
   CVD ΔE 24.7, normal-vision ΔE 33.6, both >= 3:1 contrast.
   ====================================================================== */

.agent-metrics {
    --am-series-1: #2a78d6;
    --am-series-2: #eb6834;
    --am-surface: var(--bg-surface);
    --am-grid: rgb(var(--gray-150));
    --am-axis: rgb(var(--gray-300));
    --am-target: rgb(var(--gray-500));
    display: flex;
    flex-direction: column;
    gap: 24px;
    transition: opacity var(--duration-base) var(--ease-out);
}

/* Refetch keeps the frame: the previous render stays, dimmed */
.agent-metrics.is-loading {
    opacity: 0.55;
    pointer-events: none;
}

.am-filters {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.am-filters .am-range {
    width: 160px;
}

.am-scope {
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

.am-notice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    font-size: var(--text-sm);
    color: var(--text-body);
    background: rgb(var(--amber-50));
    border: 1px solid rgb(var(--amber-200));
    border-radius: var(--radius-md);
}

.am-notice-error {
    background: rgb(var(--red-50));
    border-color: rgb(var(--red-200));
}

.am-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.am-table-wrap {
    overflow-x: auto;
}

.am-table-wrap .data-table td,
.am-table-wrap .data-table th {
    white-space: nowrap;
}

.am-table-wrap .cell-num {
    font-variant-numeric: tabular-nums;
}

.am-targets .am-now {
    color: var(--text-primary);
    font-weight: var(--weight-semibold);
}

.am-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.am-empty {
    padding: 16px 0;
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

/* ---------- Charts: small multiples ---------- */

.am-chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px 24px;
}

.am-chart {
    margin: 0;
    min-width: 0;
}

.am-chart-title {
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
}

.am-legend {
    display: flex;
    gap: 14px;
    margin-top: 4px;
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

.am-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Line keys, not boxes: the legend mirrors the 2px line mark */
.am-legend-key,
.am-tooltip-key {
    display: inline-block;
    width: 14px;
    height: 2px;
    border-radius: 1px;
}

.am-key-1 { background: var(--am-series-1); }
.am-key-2 { background: var(--am-series-2); }

.am-chart-body {
    position: relative;
    margin-top: 6px;
}

.am-svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
    font-family: var(--font-sans);
}

.am-svg:focus-visible {
    outline: none;
    box-shadow: var(--ring-focus);
    border-radius: var(--radius-sm);
}

.am-grid {
    stroke: var(--am-grid);
    stroke-width: 1;
}

.am-axis {
    stroke: var(--am-axis);
    stroke-width: 1;
}

.am-tick {
    font-size: 11px;
    fill: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

/* The target is a threshold, so it is the one dashed rule */
.am-target {
    stroke: var(--am-target);
    stroke-width: 1;
    stroke-dasharray: 4 3;
}

.am-target-label,
.am-end-label {
    font-size: 11px;
    fill: var(--text-secondary);
}

.am-end-label {
    fill: var(--text-primary);
    font-weight: var(--weight-semibold);
}

.am-line {
    fill: none;
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.am-line.am-s1 { stroke: var(--am-series-1); }
.am-line.am-s2 { stroke: var(--am-series-2); }

/* Dots carry a 2px ring in the surface color so they stay legible over lines */
.am-dot,
.am-active-dot {
    stroke: var(--am-surface);
    stroke-width: 2;
}

.am-dot.am-s1,
.am-active-dot.am-s1 { fill: var(--am-series-1); }
.am-dot.am-s2,
.am-active-dot.am-s2 { fill: var(--am-series-2); }

.am-crosshair {
    stroke: var(--am-axis);
    stroke-width: 1;
}

.am-hit {
    fill: transparent;
    pointer-events: all;
    cursor: crosshair;
}

.am-chart-empty {
    position: absolute;
    inset: 0 0 26px 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-xs);
    color: var(--text-secondary);
    pointer-events: none;
}

.am-tooltip {
    position: absolute;
    top: 4px;
    z-index: 5;
    min-width: 120px;
    padding: 8px 10px;
    font-size: var(--text-xs);
    color: var(--text-body);
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    pointer-events: none;
}

.am-tooltip[hidden] {
    display: none;
}

.am-tooltip-date {
    margin-bottom: 4px;
    color: var(--text-secondary);
}

.am-tooltip-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.am-tooltip-row strong {
    color: var(--text-primary);
    font-weight: var(--weight-semibold);
}

.am-tooltip-label {
    color: var(--text-secondary);
}

/* ---------- Table view ---------- */

.am-table-view {
    margin-top: 16px;
}

.am-table-view > summary {
    cursor: pointer;
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-link);
}

.am-table-view > summary:hover {
    color: var(--text-link-hover);
}

.am-table-view[open] > summary {
    margin-bottom: 8px;
}
