/* Dashboard. Colors come from the tokens in app.css (PilarCare teal, validated for light and dark). */
.page-dash { height: auto; min-height: 100%; }
.dash { max-width: 1280px; margin: 0 auto; padding: 20px 16px 48px; }
.dash-title { font-size: 24px; margin: 0; }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; margin-bottom: 16px; }
.presets { display: flex; gap: 6px; }
.preset[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.custom { display: flex; gap: 8px; }
.custom label { display: grid; gap: 2px; }
.custom input { width: 150px; padding: 5px 8px; }
.state { padding: 24px; text-align: center; }
.state.error { color: var(--danger); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card h2 { margin: 0 0 2px; font-size: 16px; text-transform: none; letter-spacing: 0; color: var(--text); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }

/* Headline figures */
.top { display: grid; grid-template-columns: minmax(260px, 1fr) 2fr; gap: 16px; margin-bottom: 16px; }
.hero { display: grid; align-content: center; gap: 6px; }
.kpi-label { margin: 0; font-size: 13px; color: var(--muted); }
.hero-value { margin: 0; font-size: 64px; line-height: 1; font-weight: 700; letter-spacing: -0.02em; }
.meter { height: 8px; border-radius: 4px; background: color-mix(in srgb, var(--series-1) 18%, var(--surface)); overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: var(--series-1); border-radius: 4px; transition: width 0.4s ease; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: 16px; }
.kpi { display: grid; align-content: start; gap: 4px; }
.kpi-value { margin: 0; font-size: 30px; line-height: 1.1; font-weight: 700; }

/* Chart grid */
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.charts .wide { grid-column: 1 / -1; }
.legend { display: flex; gap: 16px; list-style: none; margin: 0; padding: 0; font-size: 13px; color: var(--text); }
.legend li { display: flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.swatch.s1 { background: var(--series-1); }
.swatch.s2 { background: var(--series-2); }
.empty-chart { padding: 28px 8px; text-align: center; color: var(--muted); }

/* Column charts: <= 24px wide, 4px rounded data end, square at the baseline, 2px surface gap. */
.chart { display: grid; grid-template-columns: 34px 1fr; grid-template-rows: 180px 22px; column-gap: 8px; }
.yaxis { position: relative; font-size: 11px; color: var(--muted); }
.yaxis span { position: absolute; right: 0; transform: translateY(50%); line-height: 1; font-variant-numeric: tabular-nums; }
.plot { position: relative; border-bottom: 1px solid var(--baseline); }
.gridline { position: absolute; left: 0; right: 0; height: 1px; background: var(--grid); }
.cols { position: absolute; inset: 0; display: flex; align-items: stretch; }
.col { flex: 1; min-width: 0; display: flex; justify-content: center; align-items: flex-end; position: relative; }
.col:hover { background: color-mix(in srgb, var(--series-1) 7%, transparent); }
.stack { width: 72%; max-width: 24px; min-width: 2px; height: 100%; display: flex; flex-direction: column-reverse; gap: 2px; }
.seg { flex: none; background: var(--series-1); }
.seg.s2 { background: var(--series-2); }
.seg.top { border-radius: 4px 4px 0 0; }
.peak { position: absolute; font-size: 11px; font-weight: 600; transform: translateY(-100%); padding-bottom: 3px; white-space: nowrap; }
.xaxis { grid-column: 2; position: relative; font-size: 11px; color: var(--muted); }
.xaxis span { position: absolute; top: 6px; transform: translateX(-50%); white-space: nowrap; }
.xaxis span.first { transform: none; }
.xaxis span.last { transform: translateX(-100%); }

/* Horizontal bars */
.hbars { display: grid; gap: 10px; }
.hrow { display: grid; grid-template-columns: minmax(96px, 38%) 1fr; align-items: center; gap: 10px; }
.hlabel { font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hline { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hfill { height: 14px; border-radius: 0 4px 4px 0; min-width: 2px; width: calc((100% - 70px) * var(--w, 0)); }
.hval { font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hval small { color: var(--muted); }

/* Table views and tables */
.tbl { margin-top: 12px; font-size: 13px; }
.tbl summary { cursor: pointer; color: var(--muted); }
.tbl summary:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
table.data th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--border); }
table.data td { padding: 6px 8px; border-bottom: 1px solid var(--grid); font-variant-numeric: tabular-nums; }
table.data th.num, table.data td.num { text-align: right; }

.defs summary { cursor: pointer; font-weight: 600; }
.defs dl { margin: 12px 0 0; display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13px; }
.defs dt { font-weight: 600; }
.defs dd { margin: 0; color: var(--muted); }

.tip {
  position: fixed; z-index: 20; pointer-events: none; max-width: 260px;
  background: var(--brand-ink); color: #fff; padding: 8px 10px; border-radius: 8px;
  font-size: 12px; line-height: 1.4; white-space: pre-line; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

@media (max-width: 900px) {
  .top { grid-template-columns: 1fr; }
  .charts { grid-template-columns: 1fr; }
  .hero-value { font-size: 52px; }
  .toolbar { align-items: stretch; }
  .custom { flex-wrap: wrap; }
  .defs dl { grid-template-columns: 1fr; }
}
