/* Executive Dashboard (app/owner): the compact ledger workspace shared by the redesigned finance and training pages.
   4px spacing scale, brand tokens only, neutral elevation, sentence-case labels, tabular numerals. Teal carries the primary actions and the main series; gold marks
   expected money and what waits for a decision. Scoped to this page (.dash-page, body[data-nav="dashboard"]): css/finance.css and css/charts stay as they are because
   the Financial Reports page shares them. Layout is CSS grid decided by the room each block really has (container queries), never fixed widths. */

/* ---------------------------------------------------------------- page shell */
/* the legacy header keeps the "System Online" badge, but as a slim bar */
body[data-nav="dashboard"] .admin-header { padding-block: 8px; }

/* .dash-page is also .admin-content, which grows to fill the viewport: a top-aligned flex column cannot stretch its rows into gaps. */
.dash-page { display: flex; flex-direction: column; align-content: flex-start; gap: 16px; width: 100%; max-width: 1440px; padding-top: 16px; padding-bottom: 32px; caret-color: var(--c-primary); }
.dash-page ::selection { background: #cde6ec; color: var(--c-text); }
.dash-page > #adminAlert { position: fixed; top: calc(var(--adm-topbar-h, 56px) + 12px); right: 24px; z-index: 200; width: min(420px, calc(100vw - 32px)); margin: 0; box-shadow: var(--e-2); }
.dash-page :where(a, button):focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 6px; }

/* ---------------------------------------------------------------- header: title, subtitle, and the two shortcuts on one row */
.dash-page .fin-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.dash-page .fin-head > div:first-child { flex: 1 1 360px; min-width: 0; }
.dash-page .fin-head h1 { margin: 0; color: var(--c-text); font-family: var(--font-sans); font-size: 1.5rem; font-weight: 650; line-height: 1.2; letter-spacing: -.02em; }
.dash-page .fin-head p { max-width: 78ch; margin: 2px 0 0; color: var(--c-text-muted); font-size: .8125rem; line-height: 1.45; }
.dash-page .fin-links { flex: 0 1 auto; display: flex; flex-wrap: wrap; max-width: 100%; gap: 8px; }
.dash-page .fin-links .dsp-btn { min-height: 36px; white-space: nowrap; }

/* slim banners: the sample-data notice, a problem loading */
.dash-page .fin-callout, .dash-page .demo-callout { margin: 0; padding: 6px 12px; border: 1px solid #e9cf9b; border-left-width: 1px; border-radius: 8px; background: #fff8e8; color: #5c3b00; font-size: .75rem; line-height: 1.45; }
.dash-page #demoNotice:empty, .dash-page #dashState:empty { display: none; }
.dash-page .fin-error { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid #f3c9c4; border-radius: 8px; font-size: .8125rem; line-height: 1.4; }
.dash-page .fin-error button { flex: none; min-height: 30px; margin-left: auto; }

/* ---------------------------------------------------------------- KPI cards: eight equal tiles, four by two where there is room, two across everywhere else */
.dash-kpis { container: kpis / inline-size; min-width: 0; }
.dash-page .kpi-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@container kpis (min-width: 900px) { .dash-page .kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.dash-page .kpi { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto 1fr; align-content: start; gap: 4px 8px; min-width: 0; padding: 14px 16px; border: 1px solid var(--c-border); border-radius: 12px; background: var(--c-surface); box-shadow: var(--e-1); }
/* two label lines are always reserved, so every number in a row starts at the same height whatever the wording */
.dash-page .kpi-label { grid-column: 1; grid-row: 1; min-height: 2.6em; color: var(--c-text-muted); font-size: .75rem; font-weight: 600; letter-spacing: 0; line-height: 1.3; text-transform: none; }
.dash-page .kpi-icon { grid-column: 2; grid-row: 1; align-self: start; width: 28px; height: 28px; border-radius: 8px; font-size: .8125rem; }
/* a currency figure never wraps: it is sized from the room its card has */
.dash-page .kpi-value { grid-column: 1 / -1; grid-row: 2; min-width: 0; overflow: hidden; font-size: clamp(1rem, 1.6cqi + .35rem, 1.625rem); font-weight: 700; line-height: 1.2; letter-spacing: -.02em; white-space: nowrap; overflow-wrap: normal; }
.dash-page .kpi-sub { grid-column: 1 / -1; grid-row: 3; font-size: .75rem; line-height: 1.4; }
@supports (grid-template-rows: subgrid) {
  .dash-page .kpi-grid { row-gap: 0; margin-bottom: -12px; }
  .dash-page .kpi { grid-row: span 3; grid-template-rows: subgrid; row-gap: 4px; margin-bottom: 12px; }
  .dash-page .kpi-label { min-height: 0; }
}
@container kpis (max-width: 340px) { .dash-page .kpi-value { font-size: .8125rem; } }
@container kpis (max-width: 520px) {
  .dash-page .kpi-grid { gap: 8px; }
  .dash-page .kpi { gap: 4px 6px; padding: 12px; }
  .dash-page .kpi-icon { width: 24px; height: 24px; font-size: .75rem; }
}

/* ---------------------------------------------------------------- panels and charts: balanced pairs on desktop, stacked below that */
.dash-charts { container: charts / inline-size; min-width: 0; }
.dash-page .fin-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
@container charts (min-width: 760px) {
  .dash-page .fin-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-page .fin-panel.dash-gauge, .dash-page .fin-panel.dash-tx, .dash-page .fin-panel.dash-activity, .dash-page .fin-panel.dash-tools { grid-column: 1 / -1; }
  .dash-page .dash-gauge #boxGauge { display: flex; align-items: center; justify-content: center; gap: 32px; }
  .dash-page .dash-gauge .gauge { flex: none; width: 180px; margin: 0; }
  .dash-page .dash-gauge .gauge-legend { min-width: 220px; margin: 0; }
}
@container charts (min-width: 980px) {
  .dash-page .fin-row { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .dash-page .fin-panel.dash-collections, .dash-page .fin-panel.dash-enrollment, .dash-page .fin-panel.dash-batches, .dash-page .fin-panel.dash-methods { grid-column: span 3; }
  .dash-page .fin-panel.dash-gauge { grid-column: span 2; }
  .dash-page .fin-panel.dash-tx { grid-column: span 4; }
  .dash-page .fin-panel.dash-activity, .dash-page .fin-panel.dash-tools { grid-column: 1 / -1; }
  .dash-page .dash-gauge #boxGauge { display: grid; align-content: start; justify-content: normal; gap: 0; padding-top: 8px; }
  .dash-page .dash-gauge .gauge { width: auto; margin: 0 auto; }
  .dash-page .dash-gauge .gauge-legend { min-width: 0; margin-top: 12px; }
}
.dash-page .fin-panel { grid-column: auto; min-width: 0; padding: 12px 16px 16px; border: 1px solid var(--c-border); border-radius: 12px; background: var(--c-surface); box-shadow: var(--e-1); }
.dash-page .fin-panel > h2, .dash-page .dash-panel-head h2 { margin: 0; color: var(--c-text); font-size: .9375rem; font-weight: 650; letter-spacing: -.01em; }
.dash-page .fin-panel .fin-note { margin: 2px 0 12px; color: var(--c-text-muted); font-size: .75rem; line-height: 1.45; }
.dash-page .dash-panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.dash-page .dash-panel-head a { flex: none; color: var(--c-primary); font-size: .8125rem; font-weight: 600; text-decoration: none; }
.dash-page .dash-panel-head a:hover { text-decoration: underline; text-underline-offset: 2px; }
.dash-page .chart-box { height: 260px; }
.dash-page .fin-empty { min-height: 72px; padding: 12px; font-size: .8125rem; }
.dash-page .fin-panel.dash-gauge { display: flex; flex-direction: column; }
.dash-page #boxGauge { display: grid; flex: 1; align-content: center; }
.dash-page .gauge { max-width: 180px; height: 180px; }
.dash-page .gauge-center b { font-size: 1.5rem; }
.dash-page .gauge-legend { gap: 4px; margin-top: 12px; font-size: .8125rem; }

/* recent transactions */
.dash-page .recent-item { grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 8px 0; font-size: .8125rem; }
.dash-page .recent-item .who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-page .recent-item .meta { min-width: 0; overflow: hidden; font-size: .75rem; text-overflow: ellipsis; white-space: nowrap; }
.dash-page .pill { padding: 2px 8px; border-radius: 6px; font-size: .75rem; font-weight: 600; }

/* recent system activity */
.dash-page .fin-table-wrap { overflow-x: auto; border: 1px solid var(--c-border); border-radius: 8px; scrollbar-width: thin; scrollbar-color: var(--c-border-strong) transparent; }
.dash-page .fin-table { font-size: .8125rem; }
.dash-page .fin-table th { padding: 9px 12px; border-bottom: 1px solid var(--c-border); background: #f8fafb; color: var(--c-text-muted); font-size: .75rem; font-weight: 600; letter-spacing: 0; text-transform: none; }
.dash-page .fin-table td { padding: 9px 12px; border-bottom: 1px solid #eef1f4; vertical-align: middle; }
.dash-page .fin-table tbody tr:hover { background: #f9fbfc; }
.dash-page .fin-panel.dash-activity .fin-table-wrap { margin-top: 8px; }

/* quick tools */
.dash-page .tool-grid { grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); gap: 8px; margin-top: 8px; }
.dash-page .tool { gap: 12px; min-width: 0; padding: 8px 12px; border-radius: 10px; font-size: .8125rem; transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease); }
.dash-page .tool:hover { border-color: #c4dde5; }
.dash-page .tool i { flex: none; width: 28px; height: 28px; border-radius: 8px; font-size: .8125rem; }

/* demo mode only: the SAMPLE marker finance.css adds to a panel title (it targets h3) follows the h2 */
.is-demo .dash-page .fin-panel > h2::after { content: " \b7  SAMPLE"; color: #92400e; font-weight: 800; letter-spacing: .04em; font-size: .72em; }

/* ---------------------------------------------------------------- phones */
@media (max-width: 680px) {
  .dash-page { gap: 12px; padding-top: 8px; }
  .dash-page > #adminAlert { right: 16px; }
  .dash-page .fin-head h1 { font-size: 1.25rem; }
  .dash-page .demo-callout { display: -webkit-box; overflow: hidden; padding: 0 12px; border-style: solid; border-color: transparent; border-width: 6px 0; outline: 1px solid #e9cf9b; outline-offset: -1px; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .dash-page .fin-panel { padding: 12px; }
  .dash-page .chart-box { height: 240px; }
}
@media (prefers-reduced-motion: reduce) { .dash-page .tool { transition: none; } }
