/* ================================================================================
   ChildMetrix Component Classes
   ================================================================================

   Reusable component styles that replace inline styling across Shiny apps.
   Depends on design-tokens.css for CSS variables.

   Usage: Import design-tokens.css first, then this file.
   ================================================================================ */

/* ===== PAGE CONTAINERS ===== */

.cm-page-container {
  background: var(--cm-bg-card);
  border: 1px solid var(--cm-border);
  border-radius: var(--cm-radius-sm);
  padding: var(--cm-space-5);
  box-shadow: var(--cm-shadow-sm);
  margin-bottom: var(--cm-space-4);
}

.cm-summary-card {
  position: relative;
  background: var(--cm-bg-card);
  padding: var(--cm-space-5) var(--cm-space-6);
  border-radius: var(--cm-radius-md);
  box-shadow: var(--cm-shadow-md);
  margin-bottom: var(--cm-space-5);
}

.cm-viz-container {
  position: relative;
  background: transparent;
  padding: var(--cm-space-2) var(--cm-space-5) var(--cm-space-5) var(--cm-space-2);
  margin-bottom: var(--cm-space-4);
}

/* ===== HEADERS ===== */

.cm-page-title {
  font-size: var(--cm-text-xl);
  font-weight: var(--cm-font-bold);
  color: var(--cm-primary);
  margin: 0;
  letter-spacing: var(--cm-tracking-tight);
}

.cm-page-subtitle {
  font-size: var(--cm-text-md);
  font-weight: var(--cm-font-normal);
  color: var(--cm-text-muted);
  margin: var(--cm-space-2) 0 0 0;
  line-height: var(--cm-leading-relaxed);
}

.cm-section-title {
  font-size: var(--cm-text-lg);
  font-weight: var(--cm-font-semibold);
  color: var(--cm-text-primary);
  margin-bottom: var(--cm-space-1);
}

.cm-section-description {
  font-size: var(--cm-text-base);
  font-weight: var(--cm-font-normal);
  color: var(--cm-text-muted);
  line-height: var(--cm-leading-normal);
  margin-bottom: var(--cm-space-2);
}

/* ===== CONTEXT HEADERS (for viz containers) ===== */

.cm-context-header {
  padding-bottom: 0;
  margin-bottom: var(--cm-space-4);
}

.cm-header-divider {
  border-bottom: 1px solid var(--cm-border);
  padding-bottom: var(--cm-space-4);
  margin-bottom: var(--cm-space-5);
}

/* Specific header for indicator pages */
.cm-indicator-header {
  padding-top: var(--cm-space-1);
  padding-bottom: 0;
  margin-bottom: var(--cm-space-6);
}

/* ===== PILLS ===== */

.cm-pill {
  display: inline-block;
  padding: 4px 10px;
  line-height: 1;
  border-radius: 999px;
  font-size: var(--cm-text-sm);
  font-weight: var(--cm-font-semibold);
  white-space: nowrap;
}

/* Center the capital letters, not the font's line box (whose extra top space made text sit low). */
@supports (text-box: trim-both cap alphabetic) {
  .cm-pill {
    text-box: trim-both cap alphabetic;
    padding: 6px 10px;
  }
}

/* Pill types */
.cm-pill--period {
  background: var(--cm-primary);
  color: white;
}

.cm-pill--state {
  background: var(--cm-status-dq);
  color: white;
}

.cm-pill--legend {
  display: inline-flex;
  align-items: center;
  gap: var(--cm-space-2);
  font-weight: var(--cm-font-medium);
  color: var(--cm-text-light);
  background: transparent;
  padding: 0;
  text-box: normal;
}

/* Status pills */
.cm-pill--status {
  font-size: var(--cm-text-base);
}

.cm-pill--better {
  background-color: var(--cm-status-better-bg);
  color: white;
}

.cm-pill--worse {
  background-color: var(--cm-status-worse-bg);
  color: var(--cm-status-worse-text);
}

.cm-pill--nodiff {
  background-color: var(--cm-status-nodiff-bg);
  color: var(--cm-nodiff-text);
}

.cm-pill--dq {
  background-color: var(--cm-status-dq-bg);
  color: var(--cm-status-dq-text);
}

/* Rank pill */
.cm-pill--rank {
  background-color: var(--cm-border);
  color: var(--cm-text-light);
  font-size: var(--cm-text-base);
}

/* ===== PILLS ROW (container for pills) ===== */

.cm-pills-row {
  display: flex;
  align-items: center;
  gap: var(--cm-space-2);
  margin-bottom: var(--cm-space-3);
  flex-wrap: wrap;
}

/* ===== KPI CARDS ===== */

.cm-kpi-card {
  background: var(--cm-bg-card);
  border: 1px solid var(--cm-border);
  border-radius: var(--cm-radius-lg);
  padding: var(--cm-space-4);
  box-shadow: var(--cm-shadow-sm);
  position: relative;
  display: flex;
  flex-direction: column;
}

.cm-kpi-title {
  font-size: var(--cm-kpi-title-size);
  font-weight: var(--cm-font-semibold);
  color: var(--cm-text-dark);
  margin-bottom: var(--cm-space-1);
  line-height: var(--cm-leading-tight);
}

.cm-kpi-subtitle {
  font-size: var(--cm-kpi-subtitle-size);
  color: var(--cm-text-muted);
  margin-bottom: var(--cm-space-3);
  line-height: var(--cm-leading-normal);
}

.cm-kpi-value {
  font-size: var(--cm-kpi-value-size);
  font-weight: var(--cm-font-bold);
  color: var(--cm-text-dark);
}

.cm-kpi-unit {
  font-size: var(--cm-kpi-unit-size);
  color: var(--cm-text-muted);
}

.cm-kpi-interpretation {
  background: var(--cm-bg-subtle);
  border-radius: var(--cm-radius-lg);
  padding: var(--cm-space-3);
  margin-top: var(--cm-space-2);
}

/* KPI Grid Layout */
.cm-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 350px));
  gap: var(--cm-space-4);
  margin-bottom: var(--cm-space-4);
  justify-content: start;
  align-items: start;
}

/* ===== STATUS INDICATORS ===== */

.cm-status-dot {
  width: 12px;
  height: 12px;
  border-radius: var(--cm-radius-full);
  flex-shrink: 0;
  position: absolute;
  top: var(--cm-space-3);
  right: var(--cm-space-3);
}

.cm-status-dot--better { background: var(--cm-status-better); }
.cm-status-dot--worse { background: var(--cm-status-worse); }
.cm-status-dot--nodiff { background: var(--cm-status-nodiff); }
.cm-status-dot--dq { background: var(--cm-status-dq); }

/* ===== LEGEND COMPONENTS ===== */

.cm-legend-line {
  width: 20px;
  height: 0;
  border-top: 2px dashed var(--cm-status-national);
  display: inline-block;
  vertical-align: middle;
}

.cm-legend-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--cm-space-4);
  margin-top: var(--cm-space-3);
}

.cm-legend-item {
  display: flex;
  align-items: center;
  gap: var(--cm-space-2);
  font-size: var(--cm-text-sm);
  color: var(--cm-text-muted);
}

/* ===== FOOTNOTES & SOURCE ===== */

.cm-source {
  font-size: var(--cm-text-xs);
  line-height: var(--cm-leading-relaxed);
  color: var(--cm-text-muted);
  margin-top: var(--cm-space-4);
  padding-top: var(--cm-space-3);
  border-top: 1px solid var(--cm-border);
}

.cm-source p,
.cm-source .cm-source__note,
.cm-source .cm-source__line {
  margin: 0 0 4px;
}

.cm-source p:last-child,
.cm-source .cm-source__note:last-child,
.cm-source .cm-source__line:last-child {
  margin-bottom: 0;
}

.cm-footnote {
  font-size: var(--cm-text-xs);
  color: var(--cm-text-muted);
  margin-top: var(--cm-space-3);
  font-style: italic;
}

.cm-viz-notes {
  font-size: var(--cm-text-xs);
  color: var(--cm-text-muted);
  margin-top: var(--cm-space-3);
}

/* ===== DOWNLOAD BUTTON ===== */

.cm-download {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--cm-font-family);
  color: var(--cm-text-light);
  background: var(--cm-bg-card);
  border: 1px solid var(--cm-border);
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
}

.cm-download:hover:not(:disabled) {
  color: var(--cm-primary);
  border-color: var(--cm-primary);
}

.cm-download:disabled {
  opacity: 0.65;
  cursor: wait;
}

.cm-download svg {
  flex-shrink: 0;
}

.cm-download-actions {
  display: flex;
  gap: var(--cm-space-2);
  flex-shrink: 0;
}

.cm-download-actions--overlay {
  position: absolute;
  top: var(--cm-space-4);
  right: var(--cm-space-4);
  z-index: 100;
}

.cm-download-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--cm-border);
  border-radius: var(--cm-radius-sm);
  background: var(--cm-bg-card);
  color: var(--cm-text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.cm-download-icon:hover:not(:disabled) {
  background: var(--cm-bg-subtle);
  color: var(--cm-primary);
}

.cm-download-icon:disabled {
  opacity: 0.65;
  cursor: wait;
}

.cm-download-btn {
  position: absolute;
  top: var(--cm-space-4);
  right: var(--cm-space-4);
  z-index: 100;
}

/* ===== CONTENT PAGES (Presentations, Notes, AH4EC notes, etc.) ===== */

.cm-content-page,
.cm-presentations-page,
.cm-notes-page {
  font-family: var(--cm-font-family);
  font-size: var(--cm-content-body-size);
  line-height: var(--cm-leading-relaxed);
  background: var(--cm-bg-page);
  color: var(--cm-text-primary);
  min-height: 100vh;
  /* border-box keeps scrollHeight == viewport when content is short; without it the portal's
     iframe auto-resize adds the vertical padding on every tick and the frame grows forever. */
  box-sizing: border-box;
  margin: 0;
  padding: var(--cm-space-6) var(--cm-space-8);
}

.cm-content-page .cm-page-title {
  font-size: var(--cm-content-title-size);
  font-weight: var(--cm-font-semibold);
}

.cm-content-page .cm-page-subtitle {
  font-size: var(--cm-content-body-size);
}

.cm-content-page__inner,
.cm-presentations-page__inner,
.cm-notes-page__inner {
  max-width: 48rem;
  margin-right: auto;
}

.cm-content-page__intro {
  margin-bottom: var(--cm-space-8);
}

.cm-content-page .cm-section-title {
  font-size: var(--cm-content-section-size);
  font-weight: var(--cm-font-semibold);
  margin-top: var(--cm-space-8);
  margin-bottom: var(--cm-space-4);
  padding-bottom: var(--cm-space-2);
  border-bottom: 2px solid var(--cm-border);
  color: var(--cm-primary);
}

.cm-note-block {
  background: var(--cm-bg-subtle);
  border-left: 4px solid var(--cm-primary);
  border-radius: 0 var(--cm-radius-md) var(--cm-radius-md) 0;
  padding: var(--cm-space-5);
  margin-bottom: var(--cm-space-6);
  line-height: var(--cm-leading-relaxed);
  color: var(--cm-text-light);
}

.cm-note-block h3 {
  font-size: var(--cm-content-body-size);
  font-weight: var(--cm-font-semibold);
  color: var(--cm-text-primary);
  margin: 0 0 var(--cm-space-2) 0;
}

.cm-note-block p {
  margin: 0;
}

.cm-note-block p + p {
  margin-top: var(--cm-space-2);
}

.cm-note-block .cm-note-detail {
  font-size: var(--cm-content-body-size);
  color: var(--cm-text-muted);
}

.cm-note-callout {
  background: var(--cm-status-dq-bg);
  border-radius: var(--cm-radius-sm);
  padding: var(--cm-space-3);
  color: var(--cm-status-dq-text);
  font-size: var(--cm-text-base);
}

.cm-term {
  color: var(--cm-primary);
  font-weight: var(--cm-font-semibold);
}

.cm-link-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: var(--cm-content-body-size);
}

.cm-link-list li {
  margin-bottom: var(--cm-space-2);
}

.cm-link-list a {
  color: var(--cm-primary);
  text-decoration: none;
}

.cm-link-list a:hover {
  text-decoration: underline;
}

/* CFSR Notes & Resources: each section is a .cm-tablecard; its tables use .cm-table with
   left-aligned, wrapping text (.cm-table--notes). */

table.cm-table.cm-table--notes thead th {
  text-align: left;
  vertical-align: bottom;
}

table.cm-table.cm-table--notes thead th.cm-num {
  text-align: right;
}

table.cm-table.cm-table--notes tbody th,
table.cm-table.cm-table--notes tbody td {
  text-align: left;
  vertical-align: top;
  white-space: normal;
  line-height: var(--cm-leading-normal);
  border-bottom: 1px solid var(--cm-table-divider);
}

table.cm-table.cm-table--notes tbody th {
  color: var(--cm-text-primary);
  font-weight: var(--cm-font-semibold);
}

table.cm-table.cm-table--notes tbody td.cm-num {
  text-align: right;
  white-space: nowrap;
}

table.cm-table.cm-table--notes tbody tr:last-child th {
  border-bottom: none;
}

table.cm-table.cm-table--notes tbody tr:hover th {
  background: #f8fafc;
}

table.cm-table.cm-table--terms tbody th {
  width: 13rem;
}

.cm-tablecard .cm-tablesubtitle a,
.cm-notes-section > p a,
table.cm-table.cm-table--notes a {
  color: var(--cm-primary);
}

.cm-notes-table-note {
  margin: var(--cm-space-3) 0 0 0;
  font-size: var(--cm-text-base);
  color: var(--cm-text-muted);
}

.cm-resource-list li {
  margin-bottom: var(--cm-space-4);
}

.cm-resource-list a {
  font-weight: var(--cm-font-semibold);
}

.cm-resource-meta {
  display: block;
  color: var(--cm-text-muted);
}


/* Presentations list (CFSR portal) */

.cm-presentations-list {
  list-style: none;
  padding: 0;
  margin: var(--cm-space-6) 0 0;
  display: flex;
  flex-direction: column;
  gap: var(--cm-space-3);
}

.cm-presentation-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--cm-space-3);
  border: 1px solid var(--cm-border);
  border-radius: var(--cm-radius-lg);
  padding: var(--cm-space-5);
  background: var(--cm-bg-card);
}

@media (min-width: 640px) {
  .cm-presentation-card {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.cm-presentation-card__title {
  font-size: var(--cm-text-lg);
  font-weight: var(--cm-font-semibold);
  color: var(--cm-text-dark);
  margin: 0;
}

.cm-presentation-card__meta {
  font-size: var(--cm-text-xs);
  color: var(--cm-text-muted);
  margin: 2px 0 0;
}

.cm-presentations-page__footer {
  font-size: var(--cm-text-xs);
  color: var(--cm-text-muted);
  border-top: 1px solid var(--cm-border);
  padding-top: var(--cm-space-4);
  margin-top: var(--cm-space-6);
}

.cm-presentations-message {
  font-size: var(--cm-text-sm);
  color: var(--cm-text-muted);
}

.cm-presentation-card__warning {
  margin: 0.35rem 0 0;
  color: #92400e;
  font-size: 0.8rem;
  max-width: 36rem;
}

.cm-presentations-message--error {
  color: var(--cm-status-worse-text);
}

/* Hide download button during export */
.cm-exporting .cm-download-btn,
.cm-exporting .cm-download,
.cm-exporting .cm-download-actions,
.cm-exporting .cm-download-icon {
  display: none !important;
}

.cm-exporting .cm-hover-hint,
.cm-exporting .cm-hover-tooltip {
  display: none !important;
}

/* Hover cues don't belong in PNG downloads */
.cm-exporting .cm-def-text {
  text-decoration: none;
}

/* html2canvas (PNG downloads) draws pill text lower than the browser: about
   0.8px in identity and status/rank pills. Move the padding up by that much
   so the download matches the page. Measured 2026-09-28; the deck screenshot uses real Chrome and is
   unaffected. */
.cm-exporting .cm-pill-id {
  padding-top: 2.2px;
  padding-bottom: 3.8px;
}

.cm-exporting .cm-pill {
  padding-top: 3.2px;
  padding-bottom: 4.8px;
}

@supports (text-box: trim-both cap alphabetic) {
  .cm-exporting .cm-pill {
    padding-top: 5.2px;
    padding-bottom: 6.8px;
  }
}

.cm-exporting .cm-pill--legend {
  padding: 0;
}

/* ===== CHART CONTAINERS ===== */

.cm-chart-container {
  margin-bottom: var(--cm-space-4);
}

.cm-chart-header {
  margin-bottom: var(--cm-space-3);
}

.cm-chart-title {
  font-size: var(--cm-text-3xl);
  font-weight: var(--cm-font-bold);
  color: var(--cm-text-dark);
  margin-bottom: var(--cm-space-2);
}

.cm-chart-period {
  font-size: var(--cm-text-xl);
  font-style: italic;
  color: var(--cm-text-label);
  margin-bottom: var(--cm-space-2);
}

.cm-chart-description {
  font-size: var(--cm-text-base);
  color: var(--cm-text-primary);
  margin-bottom: var(--cm-space-3);
}

.cm-chart-footnote {
  font-size: var(--cm-text-xs);
  color: var(--cm-text-label);
  margin-top: var(--cm-space-3);
}

/* ===== DATA TABLE STANDARD (cm-data-table) ===== */

.cm-tablecard {
  background: var(--cm-bg-card);
  border: 1px solid var(--cm-border);
  border-radius: var(--cm-radius-sm);
  padding: var(--cm-space-6);
  margin-bottom: var(--cm-space-5);
}

.cm-tablebar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--cm-space-4);
  margin-bottom: var(--cm-space-4);
}

.cm-tablebar__text {
  min-width: 0;
}

.cm-tabletitle {
  margin: 0 0 2px;
  font-size: var(--cm-text-xl);
  font-weight: var(--cm-font-semibold);
  color: var(--cm-text-dark);
}

.cm-tablesubtitle {
  margin: 0;
  font-size: var(--cm-text-md);
  font-weight: var(--cm-font-normal);
  color: var(--cm-text-muted);
  line-height: var(--cm-leading-normal);
}

.cm-source-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--cm-space-2);
  margin-top: var(--cm-space-3);
}

.cm-tablebar__text > .cm-source-pills:first-child {
  margin-top: 0;
  margin-bottom: var(--cm-space-3);
}

.cm-pill-id {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: var(--cm-font-semibold);
}

.cm-pill-id.state {
  background: var(--cm-pill-id-state-bg);
  color: var(--cm-primary);
  border: 1px solid var(--cm-pill-id-state-border);
}

.cm-pill-id.profile {
  background: var(--cm-bg-subtle);
  color: var(--cm-text-light);
  border: 1px solid var(--cm-border);
}

.cm-scroll {
  overflow-x: auto;
}

table.cm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--cm-text-base);
  font-variant-numeric: tabular-nums;
}

table.cm-table th,
table.cm-table td {
  padding: var(--cm-space-2) var(--cm-space-3);
  white-space: nowrap;
}

table.cm-table thead th {
  background: var(--cm-primary);
  color: #fff;
  font-size: var(--cm-text-sm);
  font-weight: var(--cm-font-semibold);
  text-align: center;
  vertical-align: bottom;
  border-radius: 0;
}

table.cm-table thead th.cm-lead {
  text-align: left;
}

table.cm-table tbody td {
  text-align: center;
  color: var(--cm-text-light);
  border-bottom: 1px solid var(--cm-table-divider);
}

table.cm-table tbody td.cm-lead {
  text-align: left;
  color: var(--cm-text-primary);
  font-weight: var(--cm-font-medium);
  white-space: normal;
}

.cm-def-trigger {
  display: inline;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  text-align: inherit;
  cursor: help;
  vertical-align: baseline;
}

/* Header triggers sit on the blue header row: white text, light dotted underline. */
.cm-def-trigger.cm-def-trigger--header,
.cm-def-trigger.cm-def-trigger--header:hover,
.cm-def-trigger.cm-def-trigger--header:focus {
  color: #fff;
  font-weight: inherit;
}

.cm-def-trigger.cm-def-trigger--header .cm-def-text,
.cm-def-trigger.cm-def-trigger--header:hover .cm-def-text,
.cm-def-trigger.cm-def-trigger--header:focus .cm-def-text {
  text-decoration-color: rgba(255, 255, 255, 0.75);
}

/* Dotted underline in the text color = "hover for more"; a solid colored underline would read as a link. */
.cm-def-text {
  text-decoration: underline dotted;
  text-decoration-color: var(--cm-text-muted);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.cm-def-trigger:hover,
.cm-def-trigger:focus {
  color: var(--cm-text-primary);
}

.cm-def-trigger:hover .cm-def-text,
.cm-def-trigger:focus .cm-def-text {
  text-decoration-color: currentColor;
}

table.cm-table tbody tr:hover td {
  background: #f8fafc;
}

.cm-def-trigger:focus-visible {
  outline: 2px solid var(--cm-accent);
  outline-offset: 2px;
}

.cm-hover-hint {
  font-weight: var(--cm-font-normal);
  opacity: 0.85;
}

.cm-table-hint {
  margin: 0 0 var(--cm-space-2);
  font-size: var(--cm-text-xs);
  color: var(--cm-text-muted);
}

table.cm-table tbody tr:last-child td {
  border-bottom: none;
}

.cm-sub {
  display: block;
  font-size: var(--cm-text-xs);
  color: var(--cm-text-muted);
  margin-top: 1px;
  font-weight: var(--cm-font-normal);
  white-space: normal;
}

/* Opt-in: sticky lead column for wide/scrolling tables (AH4EC trend). */
.cm-table--stickylead td.cm-lead,
.cm-table--stickylead th.cm-lead {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--cm-bg-card);
}

.cm-table--stickylead thead th.cm-lead {
  z-index: 2;
  background: var(--cm-primary);
  color: #fff;
}

/* Opt-in: in-table sparkline (AH4EC Trend column). */
.cm-spark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  vertical-align: middle;
  color: var(--cm-nodiff-text);
}

.cm-spark svg,
.cm-spark__svg {
  display: block;
  overflow: visible;
}

.cm-spark__arrow {
  font-size: 11px;
  font-weight: var(--cm-font-bold);
  line-height: 1;
}

.cm-spark--desired { color: var(--cm-primary); }
.cm-spark--against { color: var(--cm-worse-text); }
.cm-spark--flat { color: var(--cm-nodiff-text); }

/* ===== LEGACY GRID TABLES ===== */

.cm-table-header {
  display: grid;
  padding: var(--cm-space-3) 0;
  border-bottom: 2px solid var(--cm-border);
  font-size: var(--cm-text-base);
  font-weight: var(--cm-font-semibold);
  color: var(--cm-text-muted);
  background: transparent;
}

.cm-table-row {
  display: grid;
  padding: var(--cm-space-3) 0;
  border-bottom: 1px solid var(--cm-border-light);
  font-size: var(--cm-text-lg);
  color: var(--cm-text-light);
  align-items: center;
  transition: background-color 0.15s ease;
}

.cm-table-row:hover {
  background-color: var(--cm-bg-subtle);
}

.cm-table-cell {
  padding: 0 var(--cm-space-2);
}

.cm-table-cell--bold {
  font-weight: var(--cm-font-semibold);
  color: var(--cm-text-primary);
}

/* CFSR Performance Summary table (7-column grid) */
.cm-summary-shell {
  font-family: var(--cm-font-family);
  background-color: var(--cm-bg-page);
  margin: 0;
  padding: 0;
}

.cm-summary-shell .container-fluid {
  padding: var(--cm-space-6);
  max-width: 1200px;
  margin-left: 0;
  margin-right: auto;
}

.indicator-table {
  margin: var(--cm-space-2) 0 0 0;
}

.indicator-header {
  display: grid;
  grid-template-columns: var(--cm-indicator-grid-cols);
  gap: var(--cm-space-2);
  padding: var(--cm-space-2) var(--cm-space-3);
  margin-bottom: var(--cm-space-2);
  background: var(--cm-primary);
  color: #fff;
  border-radius: var(--cm-radius-sm);
  font-size: var(--cm-text-sm);
  font-weight: var(--cm-font-semibold);
  align-items: center;
}

.indicator-header span {
  color: #fff;
}

.indicator-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.indicator-row {
  display: grid;
  grid-template-columns: var(--cm-indicator-grid-cols);
  gap: var(--cm-space-2);
  padding: var(--cm-space-2) var(--cm-space-3);
  font-size: var(--cm-text-base);
  color: var(--cm-text-light);
  line-height: var(--cm-leading-normal);
  border-bottom: 1px solid var(--cm-border-light);
  align-items: center;
}

.indicator-row:last-child {
  border-bottom: none;
}

.indicator-name {
  font-weight: var(--cm-font-medium);
}

.indicator-value,
.rsp-value {
  font-weight: var(--cm-font-semibold);
}

.national-standard {
  font-weight: var(--cm-font-semibold);
}

.period-value {
  font-size: var(--cm-text-base);
  color: var(--cm-text-light);
}

.cm-summary-card.exporting .cm-download-btn {
  display: none;
}

@media (max-width: 768px) {
  .cm-summary-shell .container-fluid {
    padding: var(--cm-space-4);
  }
}

body.export-mode .cm-summary-shell .container-fluid {
  max-width: 960px;
  margin-left: auto;
  margin-right: auto;
}

body.export-mode .indicator-header {
  font-size: var(--cm-text-xs);
}

body.export-mode .indicator-row {
  font-size: var(--cm-text-sm);
}

body.export-mode .cm-source,
body.export-mode .cm-footnote {
  white-space: normal !important;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

body.export-mode .cm-download-btn,
body.export-mode .cm-download,
body.export-mode .cm-download-actions,
body.export-mode .cm-download-icon {
  display: none !important;
}

body.export-mode .cm-hover-hint,
body.export-mode .cm-hover-tooltip {
  display: none !important;
}

/* ...or in the deck's Summary screenshot */
body.export-mode .cm-def-text {
  text-decoration: none;
}

/* PPT/chromote capture: slide title carries the page heading */
body.export-mode .cm-header-divider {
  display: none;
}

/* PPT/chromote capture: flat white canvas — no grey page, card shadow, or padding */
body.export-mode {
  background: #ffffff;
}

body.export-mode .cm-summary-shell,
body.export-mode .cm-summary-shell .container-fluid {
  background: #ffffff;
  padding: 0;
  margin: 0;
  max-width: none;
}

body.export-mode #summary-container {
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  padding: 0;
  margin: 0;
}

body.export-mode #summary-export {
  background: #ffffff;
  overflow: visible;
  padding-bottom: 12px;
}

body.export-mode #summary-export table.cm-table th,
body.export-mode #summary-export table.cm-table td {
  padding-top: 14px;
  padding-bottom: 14px;
}


body.export-mode #summary-export .cm-source {
  display: block;
  max-width: 100%;
}

/* ===== EMPTY STATES ===== */

.cm-empty-state {
  text-align: center;
  padding: var(--cm-space-8);
  color: var(--cm-text-muted);
  font-size: var(--cm-text-md);
}

/* ===== LOADING STATES ===== */

.cm-loading {
  text-align: center;
  padding: var(--cm-space-8);
  color: var(--cm-text-muted);
}

/* ===== ERROR STATES ===== */

.cm-error {
  background: #fee2e2;
  border: 1px solid var(--cm-status-worse);
  border-radius: var(--cm-radius-sm);
  padding: var(--cm-space-4);
  color: var(--cm-status-worse-text);
  margin: var(--cm-space-4) 0;
}

/* ===== UTILITY CLASSES ===== */

.cm-text-center {
  text-align: center;
}

.cm-text-right {
  text-align: right;
}

.cm-hidden {
  display: none !important;
}

/* Font size utilities */
.cm-text-xs { font-size: var(--cm-text-xs); }
.cm-text-sm { font-size: var(--cm-text-sm); }
.cm-text-base { font-size: var(--cm-text-base); }
.cm-text-md { font-size: var(--cm-text-md); }
.cm-text-lg { font-size: var(--cm-text-lg); }
.cm-text-xl { font-size: var(--cm-text-xl); }
.cm-text-2xl { font-size: var(--cm-text-2xl); }
.cm-text-3xl { font-size: var(--cm-text-3xl); }

.cm-mt-0 { margin-top: 0; }
.cm-mt-1 { margin-top: var(--cm-space-1); }
.cm-mt-2 { margin-top: var(--cm-space-2); }
.cm-mt-3 { margin-top: var(--cm-space-3); }
.cm-mt-4 { margin-top: var(--cm-space-4); }
.cm-mt-5 { margin-top: var(--cm-space-5); }
.cm-mt-6 { margin-top: var(--cm-space-6); }

.cm-mb-0 { margin-bottom: 0; }
.cm-mb-1 { margin-bottom: var(--cm-space-1); }
.cm-mb-2 { margin-bottom: var(--cm-space-2); }
.cm-mb-3 { margin-bottom: var(--cm-space-3); }
.cm-mb-4 { margin-bottom: var(--cm-space-4); }
.cm-mb-5 { margin-bottom: var(--cm-space-5); }
.cm-mb-6 { margin-bottom: var(--cm-space-6); }
