/* trends.css — Activity → Trends. Sparklines and line charts are inline SVG tinted with CSS variables. */

.trends {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.trends .trends-body {
    flex: 1;
    overflow: auto;
    padding: 14px 16px 24px;
}

.trends-toolbar .trends-range {
    display: inline-flex;
    gap: 2px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 2px;
    background: var(--surface-2);
}

.trends-toolbar .trends-range button {
    border: none;
    box-shadow: none;
    min-width: 36px;
    padding: 3px 8px;
    font-variant-numeric: tabular-nums;
}

.trends-toolbar .trends-range button.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

.trends-compare {
    font-size: 11px;
}

.trends-status {
    max-width: 420px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.trends-admin {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* section headers: title · count badge · right-aligned controls */
.trends-h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 22px 0 10px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.trends-section:first-child .trends-h3 {
    margin-top: 0;
}

.trends-h3-right {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 400;
}

.trends-h3-right input.quick-filter {
    width: 180px;
}

.trends-h3-right button.active {
    background: var(--accent-soft);
    color: var(--accent);
}

.trends-empty {
    padding: 12px 14px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--r-md);
    color: var(--muted);
    margin: 0;
}

.trends-wrap {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    overflow: auto;
    max-height: 520px;
    background: var(--surface);
}

table.trends-grid {
    width: 100%;
}

table.trends-grid th.sortable {
    cursor: pointer;
    user-select: none;
}

table.trends-grid tr.trends-row {
    cursor: pointer;
}

table.trends-grid tr.trends-row-open td {
    background: var(--accent-soft);
}

table.trends-grid td.trends-query {
    /* width:% + max-width:0 lets the ellipsis shrink the column instead of pushing the sparkline off-screen */
    width: 34%;
    max-width: 0;
    min-width: 220px;
    font-family: var(--mono);
    font-size: 11.5px;
}

.trends-query-text {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.trends-role {
    font-family: inherit;
    font-size: 10.5px;
}

td.trends-obj {
    font-family: var(--mono);
    font-size: 11.5px;
    white-space: nowrap;
}

.trends-spark-cell {
    width: 108px;
    padding: 2px 8px !important;
}

.trends-warn {
    color: var(--warn);
    font-weight: 600;
}

.trends-up {
    color: var(--warn);
}

.trends-down {
    color: var(--ok);
}

/* regression badge */
.badge.trends-reg {
    text-transform: none;
    letter-spacing: 0;
    font-variant-numeric: tabular-nums;
}

.badge.trends-reg-bad {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: transparent;
}

.badge.trends-reg-warn {
    background: var(--warn-soft);
    color: var(--warn);
}

.badge.trends-reg-good {
    background: var(--ok-soft);
    color: var(--ok);
}

/* sparklines */
svg.trend-spark {
    display: block;
    width: 96px;
    height: 26px;
    color: var(--accent);
    overflow: visible;
}

svg.trend-spark polyline {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linejoin: round;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
}

svg.trend-spark circle {
    fill: currentColor;
}

svg.trend-spark line {
    stroke: var(--border-strong);
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}

svg.trend-spark.trend-spark-bad {
    color: var(--danger);
}

svg.trend-spark.trend-spark-warn {
    color: var(--warn);
}

svg.trend-spark.trend-spark-empty {
    color: var(--muted);
}

svg.trend-spark-kpi {
    width: 100%;
    height: 30px;
    margin-top: 6px;
}

/* detail drawer */
table.trends-grid tr.trends-drawer td {
    padding: 0 !important;
    max-width: none;
    background: var(--surface-2);
    cursor: default;
}

.trends-drawer-body {
    padding: 12px 14px 14px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.trends-drawer-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.trends-drawer-actions {
    margin-left: auto;
    display: inline-flex;
    gap: 6px;
}

.trends-chart-wrap {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface);
    padding: 8px 10px 6px;
}

.trends-db-chart {
    margin-top: 12px;
}

svg.trend-chart {
    display: block;
    width: 100%;
    height: 180px;
    color: var(--text);
    font-family: var(--mono);
}

.trends-db-chart svg.trend-chart {
    height: 150px;
}

svg.trend-chart .trend-grid {
    stroke: var(--border);
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}

svg.trend-chart .trend-axis {
    stroke: var(--border-strong);
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}

svg.trend-chart .trend-tick {
    fill: var(--muted);
    font-size: 10px;
}

svg.trend-chart .trend-chart-empty {
    fill: var(--muted);
    font-size: 12px;
}

svg.trend-chart .trend-line {
    fill: none;
    stroke-width: 1.6;
    stroke-linejoin: round;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
}

svg.trend-chart .trend-line.trend-s1, svg.trend-chart .trend-dot.trend-s1 {
    stroke: var(--accent);
    fill: none;
}

svg.trend-chart .trend-dot.trend-s1 {
    fill: var(--accent);
}

svg.trend-chart .trend-line.trend-s2 {
    stroke: var(--warn);
    stroke-dasharray: 4 3;
}

svg.trend-chart .trend-dot.trend-s2 {
    fill: var(--warn);
}

.trend-legend {
    display: flex;
    gap: 14px;
    margin-top: 6px;
    font-size: 11px;
    color: var(--muted);
}

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

.trend-legend-swatch {
    display: inline-block;
    width: 16px;
    height: 0;
    border-top: 2px solid var(--accent);
}

.trend-legend-swatch.trend-s2 {
    border-top: 2px dashed var(--warn);
}

pre.trends-sql {
    margin: 10px 0 0;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface);
    font-family: var(--mono);
    font-size: 11.5px;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 220px;
    overflow: auto;
    color: var(--text);
}

.trends-breakdown {
    margin: 8px 0 0;
    font-size: 11.5px;
}

.trends-cards {
    padding: 0;
    /* 8 tiles: 4 × 2 on a desktop width instead of 5 + 3 with a ragged second row */
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}

.trends-kpi .mon-card-value {
    font-size: 18px;
}

.trends-foot {
    font-size: 11px;
}

/* ---------------------------------------------------------------- query-plan drilldown */

.trends-plan {
    margin: 8px 0 0;
}

.trends-plan-head {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-bottom: 6px;
}

.chip.trends-plan-chip {
    font-size: 11px;
    max-width: 340px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chip.trends-plan-chip.chip-ok {
    background: var(--ok-soft);
    color: var(--ok);
    font-weight: 600;
}

.trends-plan-status {
    margin: 0;
    font-size: 11.5px;
}

.trends-plan-reason {
    margin: 4px 0 0;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface);
}
