/* web/css/analytics.css
 *
 * The analytics board (web/boards/analytics.js) and the cost in the
 * conversation header. Uses only the tokens base.css defines, so a change to
 * the palette reaches it without an edit here.
 *
 * The panel itself is `.dash`, which supplies the flex column, the `hidden`
 * rule, the header and the scrolling body; everything below is `an-`.
 */

/* ── header ──────────────────────────────────────────────────────────── */

.an-head-cost { font-variant-numeric: tabular-nums; cursor: help; }
.an-head-budget { margin-left: var(--sp-1); font-variant-numeric: tabular-nums; }
button.an-head-budget { color: var(--text-3); }
button.an-head-budget.tripped { color: var(--red); }
.an-budget-input { width: 8ch; font: inherit; padding: 0 var(--sp-1); }
.an-budget-error { color: var(--red); margin-left: var(--sp-1); }

/* ── range ───────────────────────────────────────────────────────────── */

/* The shared .seg track (dialogs.css), placed by .dash-tools. */
#an-range { gap: 2px; }

/* ── figures ─────────────────────────────────────────────────────────── */

.an-kpis {
    display: grid;
    grid-template-columns: 1.4fr repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}
.an-kpi {
    padding: 14px 16px;
    border-radius: var(--r-lg);
    background: var(--s1);
    border: 1px solid var(--outline-soft);
}
.an-kpi-label { font-size: var(--fs-sm); color: var(--text-3); }
.an-kpi-value {
    margin-top: 6px;
    font: 500 var(--fs-3xl)/1.15 var(--sans);
    color: var(--text);
}
/* The one display figure on the page; no type token goes this large. */
.an-kpi-hero .an-kpi-value { font-size: 36px; }
.an-kpi-note { margin-top: 4px; font-size: var(--fs-sm); color: var(--text-3); }

.an-warn {
    margin: 0 0 16px;
    font-size: var(--fs-sm);
    color: var(--yellow);
}

/* ── cards ───────────────────────────────────────────────────────────── */

.an-card {
    padding: 14px 16px 16px;
    margin-bottom: 16px;
    border-radius: var(--r-lg);
    background: var(--s1);
    border: 1px solid var(--outline-soft);
    min-width: 0;
}
.an-card-head {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 12px;
}
.an-card-title { margin: 0; font: 500 var(--fs-md)/1.3 var(--sans); color: var(--text-2); }
.an-link {
    margin-left: auto;
    font-size: var(--fs-sm);
    color: var(--text-3);
}
.an-link:hover { color: var(--text); text-decoration: underline; }
.an-empty { margin: 0; font-size: var(--fs-md); color: var(--text-3); }
.an-note { margin: 0 0 10px; font-size: var(--fs-sm); color: var(--text-3); }
.an-codex .an-table + .an-table { margin-top: 12px; }

.an-split {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
    gap: 16px;
}

/* ── the daily chart ─────────────────────────────────────────────────── */
/* One series, so no legend: the card title names it. Columns are the hover
   target, wider than the bar they hold. */

.an-chart {
    position: relative;
    height: 200px;
    margin-left: 52px;
}
.an-grid { position: absolute; inset: 0; pointer-events: none; }
.an-tick {
    position: absolute;
    left: 0;
    right: 0;
    border-top: 1px solid var(--outline-soft);
}
.an-tick span {
    position: absolute;
    right: calc(100% + 8px);
    top: -7px;
    font-size: var(--fs-xs);
    color: var(--text-4);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.an-cols {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: stretch;
}
.an-col {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0 1px; /* the surface gap between touching bars */
    border-radius: var(--r-xs);
}
.an-col[data-on="1"] { background: var(--s2); }
.an-bar {
    width: 100%;
    max-width: 24px;
    min-height: 0;
    border-radius: 4px 4px 0 0;
    background: var(--blue);
}
.an-col[data-on="1"] .an-bar { filter: brightness(1.2); }

.an-xaxis {
    display: flex;
    margin: 6px 0 0 52px;
}
.an-xaxis span {
    flex: 1;
    min-width: 0;
    overflow: visible;
    white-space: nowrap;
    font-size: var(--fs-xs);
    color: var(--text-4);
    text-align: center;
}

.an-tip {
    position: absolute;
    top: 6px;
    z-index: 2;
    min-width: 180px;
    padding: 10px 12px;
    border-radius: var(--r);
    background: var(--s3);
    border: 1px solid var(--outline);
    box-shadow: var(--shadow-pop);
    pointer-events: none;
}
.an-tip-title { font-size: var(--fs-sm); color: var(--text-3); }
.an-tip-value { margin: 2px 0 6px; font: 500 var(--fs-xl)/1.2 var(--sans); color: var(--text); }
.an-tip-row { font-size: var(--fs-sm); line-height: 1.6; color: var(--text-2); white-space: nowrap; }

/* ── tables ──────────────────────────────────────────────────────────── */

.an-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-sm);
}
.an-table th {
    padding: 0 8px 8px;
    text-align: left;
    font-weight: 500;
    color: var(--text-3);
    border-bottom: 1px solid var(--outline-soft);
}
.an-table td {
    padding: 7px 8px;
    color: var(--text-2);
    border-bottom: 1px solid var(--outline-soft);
}
.an-table tr:last-child td { border-bottom: 0; }
.an-table th:first-child, .an-table td:first-child { padding-left: 0; }
.an-table th:last-child, .an-table td:last-child { padding-right: 0; }
.an-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.an-name {
    color: var(--text);
    max-width: 0;
    width: 40%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.an-barcell { width: 30%; }
.an-hbar {
    height: 10px;
    min-width: 2px;
    border-radius: 0 4px 4px 0;
    background: var(--blue);
}
.an-row-link { cursor: pointer; }
/* The name is the row's keyboard handle; the click on the row does the work. */
.an-open { padding: 0; color: inherit; font: inherit; text-align: left; }
.an-row-link:hover td { background: var(--s2); }

/* A narrow window: the figures wrap two to a row and the split stacks. */
@media (max-width: 900px) {
    .an-kpis { grid-template-columns: repeat(2, 1fr); }
    .an-split { grid-template-columns: minmax(0, 1fr); }
}
