/* Hand Hygiene Audit Dashboard — app styles (on top of /assets/labs.css) */
.app-page .page-title { margin-bottom: 18px; }
.app-block { margin-top: 20px; }
.h-sm { font-size: 22px; margin: 0 0 14px; }
.sub { margin: -8px 0 12px; }
.step2 { margin-top: 22px; }
.block-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 8px; }
.grid-fields { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.field-msg { min-height: 1.4em; margin: 10px 0 0; font-size: 14px; color: var(--muted); }
.field-msg.err { color: var(--danger); font-weight: 600; }
.field-msg.ok { color: var(--ok); font-weight: 600; }
.field-msg.warn { color: var(--warn); font-weight: 600; }
.danger { color: var(--danger) !important; border-color: color-mix(in srgb, var(--danger) 45%, var(--line)) !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.file-btn { cursor: pointer; position: relative; }
.file-btn:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
code { font-family: var(--mono); font-size: 0.92em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }

/* Tabs */
.tabs { display: flex; gap: 6px; margin-top: 22px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { font: inherit; font-weight: 650; background: none; border: 0; border-bottom: 3px solid transparent; color: var(--muted); padding: 12px 16px; cursor: pointer; white-space: nowrap; min-height: 48px; }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tab:hover { color: var(--text); }

/* Record */
.moment-grid { display: grid; gap: 10px; grid-template-columns: repeat(5, 1fr); }
@media (max-width: 760px) { .moment-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 380px) { .moment-grid { grid-template-columns: 1fr; } }
.moment { font: inherit; text-align: left; display: flex; gap: 10px; align-items: center; min-height: 64px; padding: 10px 12px; border-radius: var(--radius-sm); border: 1.5px solid var(--line); background: var(--bg); color: var(--text); cursor: pointer; }
.moment strong { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-size: 15px; }
.moment span { font-size: 14px; line-height: 1.3; }
.moment[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.moment[aria-pressed="true"] strong { background: var(--accent); color: var(--accent-ink); }
.action-grid { display: grid; gap: 12px; grid-template-columns: repeat(3, 1fr); }
@media (max-width: 520px) { .action-grid { gap: 8px; } .act { font-size: 16px; min-height: 64px; padding: 4px; } .act span { font-size: 11px; } }
.act { font: inherit; font-weight: 700; font-size: 18px; min-height: 72px; border-radius: var(--radius-sm); border: 1.5px solid var(--line); background: var(--bg); color: var(--text); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.act span { font-size: 13px; font-weight: 500; color: var(--muted); }
.act-rub, .act-wash { border-color: color-mix(in srgb, var(--ok) 55%, var(--line)); }
.act-missed { border-color: color-mix(in srgb, var(--danger) 55%, var(--line)); }
.act:hover, .moment:hover { background: var(--surface); }
.act:active { transform: translateY(1px); }
.session-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; }
.session-bar p { margin: 0; }
.paste summary { cursor: pointer; font-weight: 650; color: var(--accent); padding: 4px 0; }

/* Dashboard */
.filters { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; margin-top: 20px; padding: 16px; }
.filters label { flex: 1 1 140px; font-size: 14px; }
.filters .btn { flex: none; }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin: 20px 0 6px; }
.stat { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; }
.stat .k { font-size: 13px; color: var(--muted); }
.stat .v { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.stat.hero .v { font-size: 48px; }
.stat .sub { margin: 2px 0 0; }
.stat.goal .v { font-size: 20px; display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.stat.goal .icon { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; font-weight: 800; flex: none; }
.stat.goal.met .icon { background: var(--ok); color: var(--bg); }
.stat.goal.below .icon { background: var(--warn); color: var(--bg); }
.chart-pair { display: grid; gap: 0 20px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.chart-pair > *, #dash-body > * { min-width: 0; }
@media (max-width: 900px) { .chart-pair { grid-template-columns: minmax(0, 1fr); } }

/* Chart tokens: series hue validated with the dataviz palette checks (light #008c7e, dark #19a89a). */
.viz-root { --viz-series: #008c7e; --viz-band: rgba(0, 140, 126, 0.12); --viz-grid: #e6e8eb; --viz-axis: #52606f; --viz-ink: #0b1f3a; --viz-surface: #ffffff; --viz-track: #eef1f3; }
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .viz-root { --viz-series: #19a89a; --viz-band: rgba(25, 168, 154, 0.16); --viz-grid: #253041; --viz-axis: #a8b3c0; --viz-ink: #eef2f6; --viz-surface: #121821; --viz-track: #1f2833; }
}
:root[data-theme="dark"] .viz-root { --viz-series: #19a89a; --viz-band: rgba(25, 168, 154, 0.16); --viz-grid: #253041; --viz-axis: #a8b3c0; --viz-ink: #eef2f6; --viz-surface: #121821; --viz-track: #1f2833; }
.chart-wrap { position: relative; }
.hh-chart { width: 100%; height: auto; overflow: visible; font-family: var(--font); }
.hh-chart:focus { outline: none; }
.hh-chart:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; border-radius: 6px; }
.hh-chart .grid { stroke: var(--viz-grid); stroke-width: 1; }
.hh-chart .axis { fill: var(--viz-axis); font-size: 12px; font-variant-numeric: tabular-nums; }
.hh-chart .series { stroke: var(--viz-series); stroke-width: 2; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.hh-chart .band { fill: var(--viz-band); }
.hh-chart .band-line { stroke: var(--viz-series); stroke-opacity: 0.35; stroke-width: 6; stroke-linecap: round; }
.hh-chart .dot { fill: var(--viz-series); stroke: var(--viz-surface); stroke-width: 2; }
.hh-chart .dot.hollow { fill: var(--viz-surface); stroke: var(--viz-series); }
.hh-chart .goal { stroke: var(--viz-ink); stroke-width: 1.5; stroke-dasharray: 6 4; }
.hh-chart .goal-label, .hh-chart .end-label { fill: var(--viz-ink); font-size: 12px; font-weight: 650; }
.hh-chart .crosshair { stroke: var(--viz-axis); stroke-width: 1; }
.hh-chart .hit { cursor: crosshair; }
.chart-block .viz-root { padding-top: 4px; }
.tooltip { position: absolute; z-index: 3; pointer-events: none; background: var(--bg); color: var(--text); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 10px; padding: 8px 12px; font-size: 13px; line-height: 1.4; max-width: 260px; }
.tooltip strong { display: block; font-size: 16px; }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 10px 4px 0; margin: 0; font-size: 13px; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 8px; }
.key { display: inline-block; flex: none; }
.key-line { width: 18px; height: 2px; background: var(--viz-series); }
.key-band { width: 18px; height: 10px; border-radius: 3px; background: var(--viz-band); }
.key-hollow { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--viz-series); }
.key-goal { width: 18px; height: 0; border-top: 2px dashed var(--text); }
#legend-time .key-line, #legend-time .key-band, #legend-time .key-hollow { --viz-series: #008c7e; --viz-band: rgba(0, 140, 126, 0.18); }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) #legend-time .key-line, :root:where(:not([data-theme="light"])) #legend-time .key-band, :root:where(:not([data-theme="light"])) #legend-time .key-hollow { --viz-series: #19a89a; --viz-band: rgba(25, 168, 154, 0.24); } }

/* Bars (HTML, so text stays readable at any width) */
.bars { display: grid; gap: 8px; }
.bar-row { position: relative; display: grid; grid-template-columns: minmax(90px, 32%) 1fr 15ch; gap: 10px; align-items: center; padding: 6px 4px; border-radius: 8px; font-size: 14px; }
.bar-row:hover, .bar-row:focus-visible { background: var(--surface); }
.bar-label { overflow-wrap: anywhere; line-height: 1.25; }
.bar-track { position: relative; height: 24px; background: var(--viz-track); border-radius: 4px; }
.bar-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--viz-series); border-radius: 0 4px 4px 0; }
.bar-fill.thin-n { background: repeating-linear-gradient(135deg, var(--viz-series) 0 6px, color-mix(in srgb, var(--viz-series) 70%, var(--viz-surface)) 6px 9px); }
.bar-ci { position: absolute; top: 50%; height: 2px; margin-top: -1px; background: var(--viz-ink); opacity: 0.55; }
.bar-goal { position: absolute; top: -4px; bottom: -4px; width: 0; border-left: 2px dashed var(--viz-ink); }
.bar-val { font-variant-numeric: tabular-nums; line-height: 1.25; overflow-wrap: anywhere; }
.bar-val .n { margin-left: 6px; font-size: 13px; }
.bar-val .below { display: block; color: var(--warn); font-weight: 650; font-size: 12px; }
@media (hover: none) { .bar-tip { display: none; } }
.bar-tip { top: 100%; left: 30%; margin-top: 4px; }
@media (max-width: 520px) {
  .bar-row { grid-template-columns: 1fr 15ch; }
  .bar-track { grid-column: 1 / -1; grid-row: 2; }
}

/* Tables */
.table-view { margin-top: 12px; }
.table-view summary { cursor: pointer; font-size: 14px; font-weight: 650; color: var(--accent); padding: 4px 0; }
.table-scroll { position: relative; overflow-x: auto; margin-top: 8px; }
.table-scroll:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
table.data { border-collapse: collapse; width: 100%; font-size: 14px; }
table.data th, table.data td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data thead th { font-size: 13px; color: var(--muted); font-weight: 650; }
table.data td.num { font-variant-numeric: tabular-nums; }
#records .btn.sm { min-height: 34px; }
@media (forced-colors: active) { .bar-fill { background: CanvasText; } .bar-track { border: 1px solid CanvasText; } }
.bar-key { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 0; margin: 4px 0 18px; font-size: 13px; color: var(--muted); }
.bar-key li { display: flex; align-items: center; gap: 8px; }
.key-stripe { width: 18px; height: 10px; border-radius: 2px; background: repeating-linear-gradient(135deg, #008c7e 0 4px, #8fcfc8 4px 6px); }
.key-ci { width: 18px; height: 2px; background: var(--text); opacity: 0.6; }
.role-pick { display: block; max-width: 420px; margin-bottom: 18px; }
.tally-form { display: block; }
.tally-role { display: block; max-width: 360px; margin: 10px 0 12px; }
.tally-grid { border-collapse: collapse; width: 100%; min-width: 320px; }
@media (max-width: 520px) { .tally-grid { min-width: 0; table-layout: fixed; } .tally-grid th, .tally-grid td { padding: 6px 3px; font-size: 12px; } .tally-grid th[scope="row"] { width: 38%; } .tally-grid td input { min-width: 0; padding-left: 6px; padding-right: 2px; } }
.tally-grid th, .tally-grid td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; }
.tally-grid td input { width: 100%; min-width: 52px; }
.tally-grid thead th { color: var(--muted); font-size: 13px; }
.tally-form .btn { margin-top: 14px; }
.presets { margin-top: 0; flex-basis: 100%; }
.dash-actions { margin-top: 16px; }
.dash-actions .field-msg { margin: 0; }
#table-matrix table.data td { white-space: nowrap; font-variant-numeric: tabular-nums; }
.presets .btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.save-error { font-weight: 600; }
