/* Controls for the CNS membership dashboard directives (cns-as-of, cns-year-compare).
   These use plain inputs/selects rather than afform fields, so they don't get afform's
   layout; style them here so the controls sit in a tidy row and keep sane widths instead
   of stretching full width, and so native selects keep their dropdown arrow even when a
   theme strips it. */
.cns-asof .cns-controls,
.cns-year-compare .cns-controls,
.cns-movement .cns-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1em;
  align-items: flex-end;
  margin: 0 0 1em;
}

.cns-asof .cns-controls .cns-control,
.cns-year-compare .cns-controls .cns-control,
.cns-movement .cns-controls .cns-control {
  display: flex;
  flex-direction: column;
}

.cns-asof .cns-controls label,
.cns-year-compare .cns-controls label,
.cns-movement .cns-controls label {
  font-weight: bold;
  margin-bottom: 0.25em;
}

.cns-asof .cns-controls input,
.cns-asof .cns-controls select,
.cns-year-compare .cns-controls input,
.cns-year-compare .cns-controls select,
.cns-movement .cns-controls input,
.cns-movement .cns-controls select {
  width: auto;
  min-width: 11em;
  max-width: 16em;
  /* Keep the native dropdown arrow / date widget even if the theme hides it. */
  -webkit-appearance: auto;
  -moz-appearance: auto;
  appearance: auto;
}

/* Enclose the tables cleanly. The last row (an unstriped row) was floating because the
   table's outer border is fainter than the row dividers and the last row has no bottom
   border; match the divider colour and add a bottom line to the final row. */
.cns-asof table.table,
.cns-year-compare table.table {
  border-color: #ddd;
}
.cns-asof table.table > tbody > tr:last-child > td,
.cns-asof table.table > tbody > tr:last-child > th,
.cns-asof table.table > tfoot > tr:last-child > td,
.cns-asof table.table > tfoot > tr:last-child > th,
.cns-year-compare table.table > tbody > tr:last-child > td,
.cns-year-compare table.table > tbody > tr:last-child > th {
  border-bottom: 1px solid #ddd;
}

/* As-of caption: a muted line stating the exact date the counts are for. */
.cns-asof table.table > caption.cns-asof-caption {
  caption-side: top;
  padding: 0 0 .4em;
  color: #666;
  font-size: .9em;
  font-style: italic;
  text-align: left;
}

/* The Overall Membership Summary is a wide table (all movement columns); let it scroll sideways
   on narrow screens instead of breaking the page layout. */
.cns-summary .cns-table-scroll {
  overflow-x: auto;
}
.cns-summary table.table {
  min-width: 760px;
}

/* "By the Numbers" headline tiles above the summary table. */
.cns-summary .cns-bythenumbers {
  display: flex;
  flex-wrap: wrap;
  gap: 1em;
  margin: .25em 0 1em;
}
.cns-summary .cns-stat {
  flex: 0 1 auto;
  min-width: 11em;
  padding: .6em .9em;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #f7f7f7;
}
.cns-summary .cns-stat-value {
  font-size: 1.6em;
  font-weight: 600;
  line-height: 1.1;
}
.cns-summary .cns-stat-label {
  color: #666;
  font-size: .85em;
}
/* Gender cross-tab below the summary table — narrower than the wide movement table. */
.cns-summary .cns-gender {
  margin-top: 1.5em;
}
.cns-summary .cns-gender h3 {
  font-size: 1.1em;
  margin-bottom: .4em;
}
.cns-summary .cns-gender table.table {
  min-width: 0;
  max-width: 28em;
}

/* Membership Movement (unified Base→End report): wide table, scroll sideways on narrow screens. */
.cns-movement .cns-table-scroll {
  overflow-x: auto;
}
.cns-movement table.table {
  min-width: 860px;
}
.cns-movement table.table > caption.cns-movement-caption {
  caption-side: top;
  padding: 0 0 .4em;
  color: #666;
  font-size: .9em;
  font-style: italic;
  text-align: left;
}

/* By-the-Numbers tiles + gender table inside the unified Movement report (same look as the summary). */
.cns-movement .cns-bythenumbers {
  display: flex;
  flex-wrap: wrap;
  gap: 1em;
  margin: .25em 0 1em;
}
.cns-movement .cns-stat {
  flex: 0 1 auto;
  min-width: 11em;
  padding: .6em .9em;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #f7f7f7;
}
.cns-movement .cns-stat-value { font-size: 1.6em; font-weight: 600; line-height: 1.1; }
.cns-movement .cns-stat-label { color: #666; font-size: .85em; }
.cns-movement .cns-gender { margin-top: 1.5em; }
.cns-movement .cns-gender h3 { font-size: 1.1em; margin-bottom: .4em; }
.cns-movement .cns-gender .cns-gender-asof { color: #666; font-weight: normal; font-size: .85em; }
.cns-movement .cns-gender table.table { min-width: 0; max-width: 28em; }

/* Category Movement matrix: controls row + a from→to grid that scrolls sideways. */
.cns-cat-movement .cns-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1em;
  align-items: flex-end;
  margin: 0 0 1em;
}
.cns-cat-movement .cns-controls .cns-control { display: flex; flex-direction: column; }
.cns-cat-movement .cns-controls label { font-weight: bold; margin-bottom: 0.25em; }
.cns-cat-movement .cns-controls input,
.cns-cat-movement .cns-controls select {
  width: auto; min-width: 11em; max-width: 16em;
  -webkit-appearance: auto; -moz-appearance: auto; appearance: auto;
}
.cns-cat-movement .cns-table-scroll { overflow-x: auto; }
/* Auto width (not the Bootstrap full-width default) with fixed, equal data columns so every number
   lines up the same across every column. */
.cns-cat-movement table.cns-cat-matrix {
  width: auto;
  table-layout: fixed;
  border-collapse: collapse;
}
.cns-cat-movement table.cns-cat-matrix th:first-child,
.cns-cat-movement table.cns-cat-matrix td:first-child { width: 12em; }
.cns-cat-movement table.cns-cat-matrix th:not(:first-child),
.cns-cat-movement table.cns-cat-matrix td:not(:first-child) { width: 10rem; }
/* Every cell bordered so the from→to grid reads as a matrix. */
.cns-cat-movement table.cns-cat-matrix th,
.cns-cat-movement table.cns-cat-matrix td {
  border: 1px solid #ddd;
  padding: .4em .6em;
  vertical-align: bottom;
}
.cns-cat-movement table.cns-cat-matrix thead th { white-space: normal; }
.cns-cat-movement table.cns-cat-matrix td { white-space: nowrap; }
/* Numbers (and the to-column headers above them) right-aligned; row/corner headers left-aligned. */
/* Everything right-aligned (numbers + the to-column headers above them + the Total out / Total in
   cells, which are <th>), then just the first column (row/corner labels) back to the left. */
.cns-cat-movement table.cns-cat-matrix th,
.cns-cat-movement table.cns-cat-matrix td { text-align: right; }
.cns-cat-movement table.cns-cat-matrix th:first-child,
.cns-cat-movement table.cns-cat-matrix td:first-child { text-align: left; }
.cns-cat-movement table.cns-cat-matrix thead th { background: #f2f2f2; }
.cns-cat-movement table.cns-cat-matrix tbody th,
.cns-cat-movement table.cns-cat-matrix tfoot th { background: #f7f7f7; font-weight: 600; }
.cns-cat-movement table.cns-cat-matrix td.cns-cell-zero { color: #ccc; }
.cns-cat-movement table.cns-cat-matrix > caption.cns-movement-caption {
  caption-side: top; padding: 0 0 .4em; color: #666; font-size: .9em; font-style: italic; text-align: left;
}
.cns-cat-movement .cns-cat-empty { color: #666; font-style: italic; }
