/* Analytics tab — charts are plain HTML/CSS, not SVG and not a chart library:
   there is no bundler here, and flex columns reflow with the card instead of
   needing viewBox math. Grid and axes stay recessive; only data carries colour.
   Kept in its own file because it is the only view that needs any of it. */

.an-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.an-select {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 7px 10px; font-size: 13px; font-family: inherit;
}
.an-select:focus { outline: none; border-color: var(--border-strong); }

.an-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.an-note { font-size: 11.5px; color: var(--muted); line-height: 1.5; margin-top: 4px; }
.an-sub { font-size: 12px; color: var(--muted); margin: -6px 0 12px; }

/* Stat tiles carrying a week-over-week delta */
.an-kpi { display: flex; flex-direction: column; gap: 5px; }
.an-kpi-value { font-family: var(--font-display); font-size: 30px; line-height: 1.1; }
.an-kpi-value .an-unit { font-size: 15px; color: var(--muted); margin-left: 2px; }
.an-kpi-label { font-size: 12px; color: var(--muted); }
.an-kpi-delta { font-size: 11.5px; font-weight: 600; }
.an-kpi-delta.up { color: var(--green); }
.an-kpi-delta.down { color: var(--red); }
.an-kpi-delta.flat { color: var(--muted); }

/* Stacked weekly columns */
.an-chart { display: flex; align-items: flex-end; gap: 6px; height: 190px; position: relative; }
.an-chart-grid { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.an-chart-grid span { border-top: 1px solid var(--chart-grid); }
.an-col { flex: 1 1 0; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; position: relative; }
.an-col-total { font-size: 10.5px; color: var(--muted); text-align: center; margin-bottom: 3px; }
.an-seg { border-radius: 0; min-height: 2px; }
/* 4px rounded data-end on the topmost segment; the stack sits on the baseline. */
.an-seg:first-of-type { border-top-left-radius: 4px; border-top-right-radius: 4px; }
.an-col.sel .an-seg { outline: 1px solid var(--text-dim); outline-offset: 1px; }
.an-col.sel .an-col-total { color: var(--text); font-weight: 700; }
.an-col:hover .an-seg { filter: brightness(1.18); }
.an-xaxis { display: flex; gap: 6px; margin-top: 8px; }
.an-xtick { flex: 1 1 0; min-width: 0; font-size: 10px; color: var(--muted); text-align: center; overflow: hidden; white-space: nowrap; }
.an-xtick.sel { color: var(--text); font-weight: 700; }

.an-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px; }
.an-legend-item { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-dim); }
.an-swatch { width: 10px; height: 10px; border-radius: 0; flex-shrink: 0; }

.an-tooltip {
  position: fixed; z-index: 60; pointer-events: none; opacity: 0; transition: opacity .1s;
  background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 8px 10px; font-size: 12px; line-height: 1.55; box-shadow: var(--shadow); max-width: 250px;
}
.an-tooltip.show { opacity: 1; }
.an-tooltip .tt-title { font-weight: 700; margin-bottom: 4px; color: var(--text); }
.an-tooltip .tt-row { display: flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--text-dim); }
.an-tooltip .tt-row .tt-val { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }

/* Table view — so identity is never carried by colour alone */
.an-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.an-table th, .an-table td { padding: 6px 8px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
.an-table th:first-child, .an-table td:first-child { text-align: left; }
.an-table th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.an-table td { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.an-table tr.sel td { color: var(--text); font-weight: 700; }
.an-scroll { overflow-x: auto; }

/* Funnel — one series, so direct labels stand in for a legend */
.an-funnel { display: flex; flex-direction: column; }
.an-funnel-meta { display: flex; align-items: baseline; gap: 8px; font-size: 12.5px; margin-bottom: 5px; }
.an-funnel-meta .fn-label { color: var(--text-dim); }
.an-funnel-meta .fn-count { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.an-funnel-track { background: var(--surface-2); border-radius: 0; height: 22px; overflow: hidden; }
.an-funnel-fill { height: 100%; background: var(--chart-1); border-radius: 0; }
.an-funnel-drop {
  display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted);
  padding: 4px 0 4px 10px; margin: 2px 0 2px 8px; border-left: 1px solid var(--border);
}
.an-funnel-drop.leak { color: var(--red); border-left-color: var(--red-dim); }

/* Velocity gauges — measured against a methodology target, not a past average */
.an-gauge { margin-bottom: 16px; }
.an-gauge:last-child { margin-bottom: 0; }
.an-gauge-head { display: flex; align-items: baseline; gap: 8px; font-size: 12.5px; margin-bottom: 6px; }
.an-gauge-head .g-label { color: var(--text-dim); }
.an-gauge-head .g-value { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.an-gauge-track { position: relative; background: var(--surface-2); border-radius: 0; height: 10px; }
.an-gauge-fill { height: 100%; border-radius: 0; background: var(--chart-2); }
.an-gauge-fill.good { background: var(--green); }
.an-gauge-fill.warn { background: var(--yellow); }
.an-gauge-fill.bad { background: var(--red); }
.an-gauge-marker { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text-dim); border-radius: 0; }
.an-gauge-foot { display: flex; justify-content: space-between; gap: 10px; font-size: 10.5px; color: var(--muted); margin-top: 6px; }

/* Segment comparison rows */
.an-seg-row { display: grid; grid-template-columns: 116px 1fr 84px; align-items: center; gap: 10px; padding: 5px 0; }
.an-seg-name { font-size: 12.5px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-seg-track { background: var(--surface-2); border-radius: 0; height: 16px; overflow: hidden; }
.an-seg-fill { height: 100%; background: var(--chart-2); border-radius: 0; }
.an-seg-val { font-size: 12px; color: var(--text-dim); text-align: right; font-variant-numeric: tabular-nums; }
.an-seg-val .sv-n { color: var(--muted); font-size: 11px; }
/* Thin samples stay visible but visibly weaker — a 100% rate off 2 prospects
   should not read like a finding. */
.an-thin .an-seg-fill { opacity: .4; }
.an-thin .an-seg-name, .an-thin .an-seg-val { opacity: .65; }

/* Next-week plan */
.an-target { display: flex; gap: 14px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--border); }
.an-target:last-child { border-bottom: none; }
.an-target-num { font-family: var(--font-display); font-size: 24px; line-height: 1.15; color: var(--accent-text); min-width: 62px; }
.an-target-body { flex: 1; min-width: 0; }
.an-target-label { font-size: 13px; font-weight: 600; }
.an-target-why { font-size: 11.5px; color: var(--muted); line-height: 1.5; margin-top: 2px; }
.an-target-last { font-size: 11px; color: var(--text-dim); margin-top: 3px; }

.an-callout {
  background: var(--surface-2); border: 1px solid var(--border); border-left: 2px solid var(--accent);
  border-radius: var(--radius-sm); padding: 12px 14px; font-size: 13px; line-height: 1.6; color: var(--text-dim);
}
.an-callout strong { color: var(--text); }
.an-callout.warn { border-left-color: var(--red); }

.an-review h3 { font-size: 14px; margin: 18px 0 6px; color: var(--text); }
.an-review h3:first-child { margin-top: 0; }
.an-review ul { margin: 0 0 4px; padding-left: 18px; }
.an-review li { font-size: 13px; color: var(--text-dim); line-height: 1.6; margin-bottom: 5px; }
.an-review li strong { color: var(--text); }

@media (max-width: 860px) {
  .an-chart { height: 150px; }
  .an-seg-row { grid-template-columns: 88px 1fr 72px; gap: 8px; }
  .an-xtick { font-size: 9px; }
  .an-kpi-value { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) {
  .an-tooltip { transition: none; }
}
