/* Tool-first shell and reporting surfaces. Calculator details live separately.
   Keep responsive refinements in screen media so printed evidence stays legible. */
@media screen {
  html { scroll-padding-top: 24px; }
  body { line-height: 1.55; }
  h1 { font-size: clamp(28px, 2.5vw, 36px); font-weight: 620; letter-spacing: -1px; }
  h2 { font-size: 17px; letter-spacing: -.25px; }
  button, input, select, textarea { font-size: 13px; }
  button, a.primary, a.secondary { min-height: 42px; }
  input, select, textarea { min-width: 0; min-height: 44px; background: var(--surface-raised); }
  input:focus, select:focus, textarea:focus { border-color: var(--accent); }
  .secondary { border-color: var(--border-subtle); }
  .secondary:hover { border-color: var(--border-control); }
  .primary { font-weight: 650; }
  a { color: var(--information); }
  .workspace { padding-bottom: 48px; }
  .sidebar { padding: 18px 12px; }
  .brand { gap: 10px; padding: 0 4px 22px; border-bottom: 1px solid var(--border-subtle); margin-bottom: 10px; }
  .brand-mark { border: 0; width: 32px; flex-basis: 32px; font-size: 24px; font-weight: 600; color: var(--accent); }
  .brand strong { font-size: 17px; letter-spacing: -.3px; }
  .nav-list { gap: 5px; }
  .nav-group { margin: 15px 12px 6px; font-size: 12px; }
  .nav-group:not(:first-child) { border-top: 1px solid var(--border-subtle); padding-top: 22px; margin-top: 20px; }
  .nav-item { min-height: 44px; padding: 9px 11px; gap: 12px; font-size: 13px; border-radius: 7px; }
  .nav-item.active { color: var(--accent); background: var(--selection); box-shadow: none; }
  .nav-item svg { width: 19px; height: 19px; }
  .connection-card { padding: 24px 10px 18px; font-size: 12px; }
  .status-dot { width: 8px; height: 8px; flex-basis: 8px; }
  .sidebar-footnote { margin-left: 10px; }
  .utility-bar { min-height: 68px; margin-bottom: 25px; }
  .workspace-label { display: none; }
  .utility-actions { width: auto; margin-left: auto; justify-content: flex-end; }
  .command-trigger { width: min(460px, 65%); justify-content: flex-start; font-weight: 400; color: var(--text-secondary); }
  .command-trigger kbd { margin-left: auto; }
  #themeToggle { border-color: transparent; background: transparent; color: var(--text-secondary); }
  .topbar { margin-bottom: 22px; }
  .view-subtitle { max-width: 720px; font-size: 14px; }
  .topbar-actions { flex-shrink: 0; }
  #printButton { border-color: transparent; padding-inline: 10px; color: var(--text-secondary); background: transparent; }
  .dataset-purpose { background: none; border-left: 1px solid var(--border-subtle); border-radius: 0; padding-left: 12px; }
  .calculator-active #datasetPurpose { display: none; }
  .panel-header { padding: 16px 20px; }
  .panel-body { padding: 20px; }
  .panel-kicker { font-size: 12px; }

  /* A first-time visitor sees tools they can use, not unavailable balances. */
  .command-welcome { padding: 16px 0 24px; max-width: 740px; }
  .command-welcome h2 { font-size: clamp(25px, 2.4vw, 34px); font-weight: 550; letter-spacing: -.7px; margin-bottom: 10px; }
  .command-welcome p { font-size: 15px; color: var(--text-secondary); margin-bottom: 0; max-width: 620px; }
  .command-grid { grid-template-columns: minmax(0, 1.45fr) minmax(270px, .85fr); gap: 20px; margin-bottom: 24px; }
  .working-tools .panel-header { border-bottom: 0; padding-bottom: 4px; }
  .command-tools { display: grid; grid-template-rows: repeat(3, 1fr); }
  .tool-row { padding: 22px 20px; gap: 16px; }
  .tool-row .feature-icon { width: 28px; height: 28px; color: var(--accent); }
  .tool-row h3 { font-size: 16px; margin-bottom: 5px; }
  .tool-row p { font-size: 13px; }
  .tool-row .outline-action { border-color: var(--border-subtle); color: var(--text-primary); }
  .tool-row-primary .outline-action { background: var(--accent); color: var(--accent-foreground); border-color: var(--accent); }
  .data-attention dl { padding: 0 20px; }
  .data-attention dl>div { grid-template-columns: 1fr; gap: 6px; padding: 18px 0; }
  .data-attention dt { color: var(--text-primary); font-size: 12px; font-weight: 600; }
  .data-attention dd { font-size: 13px; }
  .data-attention>.secondary { margin: 18px 20px; width: calc(100% - 40px); }
  .context-band { background: transparent; border: 0; padding: 0; gap: 20px; margin: 0 0 28px; }
  .context-band dd { font-size: 13px; }
  .context-band dt { font-size: 12px; }
  .financial-prerequisites { padding: 0; }
  .financial-prerequisites>summary { cursor: pointer; padding: 18px 20px; font-size: 14px; font-weight: 550; }
  .financial-prerequisites>summary span { color: var(--text-secondary); font-size: 12px; font-weight: 400; margin-left: 12px; }
  .financial-prerequisites[open]>summary { border-bottom: 1px solid var(--border-subtle); margin-bottom: 20px; }
  .financial-prerequisites .panel { margin: 0 20px 20px; }

  /* Context stays compact and can be collapsed; source freshness stays visible. */
  .history-controls { background: var(--surface); border: 1px solid var(--border-subtle); border-radius: var(--radius); overflow: clip; }
  .history-controls>summary, body:not(.calculator-active) .history-controls>summary { display: list-item; border: 0; border-radius: 0; background: transparent; padding: 15px 20px; font-weight: 550; color: var(--text-primary); }
  .history-controls[open]>summary { border-bottom: 1px solid var(--border-subtle); margin: 0; }
  .history-controls>summary:focus-visible { outline-offset: -3px; }
  .history-controls>summary span { font-weight: 400; }
  .filters { border: 0; margin: 0; border-radius: 0; padding: 16px 20px; gap: 12px; }
  .filter-workbench { margin: 0; padding: 0 20px 16px; }
  .filter-chip { background: var(--surface-raised); border: 0; font-size: 12px; }
  .data-source-summary { margin: 0 20px 16px; }
  .freshness-panel { padding: 12px 16px; gap: 12px; border: 1px solid var(--border-subtle); border-left: 3px solid var(--warning); background: var(--warning-surface); }
  .freshness-panel[data-state="fresh"] { background: var(--positive-surface); }
  .freshness-panel[data-state="error"] { background: var(--negative-surface); }
  .freshness-copy p { font-size: 12px; }
  .freshness-stats { gap: 16px; }
  .freshness-stats dt { font-size: 11px; }

  /* Aligned summaries, with one shared surface rather than a wall of cards. */
  .metric-grid { gap: 0; background: var(--surface); border: 1px solid var(--border-subtle); border-radius: var(--radius); margin-bottom: 20px; overflow: hidden; }
  .metric { border: 0; border-left: 1px solid var(--border-subtle); border-radius: 0; margin: 18px 0; padding: 0 20px; background: transparent; }
  .metric:first-child { border-left: 0; }
  .metric>span { color: var(--text-primary); font-size: 13px; margin-bottom: 12px; }
  .metric strong { font-size: clamp(25px, 2.3vw, 34px); font-weight: 550; letter-spacing: -.7px; }
  .metric small { font-size: 12px; line-height: 1.55; margin-top: 9px; }
  .metric>.metric-icon { display: none; }
  .metric-lineage-action { color: var(--text-secondary); text-decoration: underline; text-underline-offset: 3px; font-size: 11px; }
  .performance-panel { margin-bottom: 20px; }
  .performance-rates { padding: 20px; gap: 20px; }
  .performance-rate { border-left-width: 1px; padding-left: 18px; }
  .performance-rate:first-child { border-left: 0; padding-left: 0; }
  .performance-rate strong { font-size: 28px; font-weight: 550; }
  .performance-note { padding: 0 20px 16px; }
  .analytics-grid, .ops-grid { gap: 20px; }
  .bar-list { padding: 20px; gap: 18px; }
  .bar-row { gap: 14px; font-size: 13px; }
  .bar-track, .trend-track { height: 7px; border-radius: 3px; }
  .trend { padding: 20px; }
  .trend-svg { height: 190px; }
  .journey-explorer { margin: 20px 0 0; }
  .journey-explorer>summary, .source-performance-panel>summary, .terminology-panel>summary { font-size: 14px; padding: 17px 20px; }
  .performance-table-wrap { padding: 0 12px 12px; }
  th, td { padding: 14px 16px; }
  thead th { font-weight: 500; }
  .table-actions { gap: 16px; }
  .table-controls { padding: 14px 20px; }
  .table-controls details summary { border-color: var(--border-subtle); }
  .table-controls-status { font-size: 12px; }
  .table-wrap { scrollbar-color: var(--border-control) var(--surface-raised); }
  .table-wrap:focus-visible, .performance-table-wrap:focus-visible { outline-offset: -3px; }
  .settings-list { padding: 20px; gap: 20px; }
  .settings-list dt, .settings-list dd { font-size: 13px; }
  .dialog-header { padding: 24px; }
  .record-details { padding: 8px 24px 24px; }
  .dialog-actions { padding: 16px 24px; }
  .record-section-title { font-size: 14px; padding-block: 14px; }
  .record-field, .record-field-list>div { padding-block: 12px; }
  .command-dialog { width: min(620px, calc(100vw - 32px)); }
  .command-search { padding: 20px; }
  .command-results { padding: 0 12px; }
  .command-result { min-height: 46px; }
  #commandSearch { font-size: 16px; }
  .command-hint { padding: 18px 24px; }
}

@media screen and (min-width: 1200px) {
  .filters { grid-template-columns: minmax(130px, .9fr) minmax(190px, 1.5fr) minmax(140px, 1fr) 145px 145px; }
  .search-field { grid-column: span 4; }
}
@media screen and (min-width: 1680px) {
  :root { --gutter: 36px; }
  .filters { grid-template-columns: 145px minmax(190px, 1.3fr) minmax(130px, 1fr) 145px 145px minmax(160px, 1fr) auto; }
  .search-field { grid-column: auto; }
}
@media screen and (max-width: 1250px) {
  .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric:nth-child(4) { border-left: 0; }
  .ledger-metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .ledger-metric-grid .metric:nth-child(4) { border-left: 1px solid var(--border-subtle); }
  .command-grid { grid-template-columns: 1fr; }
  .data-attention dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
}
@media screen and (max-width: 1000px) {
  :root { --sidebar-width: 64px; --gutter: 22px; }
  .sidebar { padding-inline: 6px; }
  .brand { padding-inline: 4px; }
  .nav-item { padding: 10px; justify-content: center; }
  .nav-list { gap: 9px; }
  .ledger-metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ledger-metric-grid .metric:nth-child(3) { border-left: 0; }
  .topbar-actions { flex-shrink: 1; }
  #printButton { display: none; }
}
@media screen and (max-width: 600px) {
  :root { --gutter: 16px; }
  button, input, select, textarea { font-size: 14px; }
  input, select, textarea { font-size: 16px; }
  button, a.primary, a.secondary { min-height: 44px; }
  .sidebar { padding: 12px 16px; }
  .brand, .sidebar-collapsed .brand { border: 0; margin: 0; padding: 0; }
  .brand-mark { width: 28px; flex-basis: 28px; font-size: 23px; }
  .nav-item, .sidebar-collapsed .nav-item { justify-content: flex-start; padding: 12px; font-size: 14px; }
  .nav-group:not(:first-child) { margin-top: 6px; padding-top: 12px; }
  .utility-bar { min-height: 64px; margin-bottom: 20px; }
  .command-trigger { width: auto; max-width: 65%; padding-inline: 10px; }
  .command-trigger span { font-size: 12px; }
  #themeToggle { font-size: 12px; padding-inline: 8px; }
  .topbar { margin-bottom: 20px; gap: 14px; }
  .view-subtitle { font-size: 14px; }
  .topbar-actions { gap: 8px; }
  .dataset-purpose { font-size: 11px; }
  .panel-header, .panel-body { padding: 16px; }
  .command-welcome { padding: 4px 0 24px; }
  .command-welcome h2 { font-size: 27px; }
  .command-grid { gap: 16px; }
  .tool-row { padding: 20px 16px; }
  .tool-row button { justify-content: space-between; text-align: left; }
  .data-attention dl { display: block; padding: 0 16px; }
  .data-attention dl>div { padding-block: 14px; }
  .context-band { gap: 16px 12px; }
  .financial-prerequisites>summary { padding: 16px; }
  .financial-prerequisites>summary span { display: block; margin: 6px 0 0; }
  .financial-prerequisites .panel { margin: 0 10px 16px; }
  .history-controls>summary, body:not(.calculator-active) .history-controls>summary { padding: 14px 16px; }
  .filters { padding: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters>label:has(input[type="date"]) { grid-column: 1/-1; }
  .filter-workbench { padding: 0 16px 16px; }
  .freshness-panel { padding: 12px; }
  .freshness-stats { display: none; }
  .metric-grid, .ledger-metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { padding: 0 14px; margin-block: 16px; }
  .metric:nth-child(odd) { border-left: 0; }
  .metric:nth-child(even) { border-left: 1px solid var(--border-subtle); }
  .metric:last-child:nth-child(odd) { grid-column: 1/-1; border-top: 1px solid var(--border-subtle); padding-top: 16px; margin-top: 0; }
  .metric strong { font-size: 27px; }
  .performance-rates { gap: 20px 12px; padding: 16px; }
  .performance-rate { padding-left: 12px; }
  .performance-rate:nth-child(odd) { padding-left: 0; border-left: 0; }
  .performance-note { padding: 0 16px 16px; }
  .table-actions { gap: 8px; }
  .table-controls { padding: 12px 16px; }
  .bar-list, .trend { padding: 16px; }
  .bar-row { font-size: 12px; }
  .dialog-header { padding: 20px 16px; }
  .record-details { padding: 8px 16px 20px; }
  .dialog-actions { padding: 12px 16px; }
}

@media screen and (min-width: 601px) {
  .sidebar-collapsed .brand { padding-inline: 4px; }
  .sidebar-collapsed .nav-item { justify-content: center; }
}

@media print {
  .command-welcome { margin-bottom: 16px; }
  .financial-prerequisites { border: 0; }
}
