/* ==========================================================================
   Executive report family - masthead, bands, metrics, charts, narrative
   ==========================================================================

   Shared by all five reporting surfaces: Weekly Executive Report (the
   reference implementation), Weekly Summary, Retention, Headcount and
   Recruiting.

   This file EXTENDS the Phase B component system; it does not compete with
   it. Buttons, forms, tables, cards, status pills, alerts and modals all
   come from components.css unchanged - what is added here is the vocabulary
   a report needs and an application screen does not: a masthead, section
   bands, metric tiles, chart cards with their supporting tables, target and
   variance indicators, cohort labels, narrative blocks and data-quality
   notices.

   Load order: after components.css, before main.css. Nothing here uses
   !important; the page-specific layer still wins where it must.

   No gradients behind charts, tables or dense narrative. The one gradient
   in this file is the masthead, and it runs top-to-bottom from #173567 to
   #1D4484 - measured across the full span, white clears 9.49:1 and the
   light-blue subtitle 5.36:1.
   ========================================================================== */

/* ==========================================================================
   1. MASTHEAD
   One pattern for every report: title, subtitle, as-of metadata, scope
   selector. Restrained by design - it must not push the first numbers below
   the fold on screen, or waste a page in print.
   ========================================================================== */

.report-masthead {
  /* The vertical ramp (#173567 -> #1D4484), not the right-to-left one.
     The RTL ramp ends at #46669A, where the light-blue subtitle measures
     only 3.27:1 - below the body-text threshold. On this ramp the worst
     case across the whole span is 5.36:1 for the subtitle and 9.49:1 for
     white, so every piece of text clears it at every point. */
  /* BUILD 2 - THE FLAGSHIP HERO.

     This was a dark-blue gradient panel with white text. The approved
     Executive Summary rendering opens instead with a LIGHT hero: a frosted
     panel on the pale canvas, a large dark-blue display title, and the
     reporting controls grouped at the right. That is what makes the page
     read as the product's front page rather than as a printed report
     header, and it is why the dark ramp is gone.

     Every text colour below changed with it, and each is measured against
     this surface rather than against the ramp it used to sit on. */
  background: var(--surface-frosted-strong);
  border: 1px solid var(--surface-frosted-border);
  color: var(--text-primary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(var(--frost-blur));
  padding: var(--space-8) var(--space-8);
  margin-bottom: var(--space-7);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-6);
  flex-wrap: wrap;
}

.report-masthead-text {
  min-width: 0;
}

/* Barlow Black. Build 2 drops the uppercase and raises the size to the
   display step: the rendering's title is large, mixed-case and the single
   loudest thing on the page. Brand Book p20 permits uppercase on short
   headlines; it does not require it, and at this size mixed case is what
   reads as a product title rather than as a banner. */
.report-masthead h1 {
  margin: 0;
  font-size: var(--type-display-size);
  line-height: var(--type-display-line);
  font-weight: var(--type-display-weight);
  letter-spacing: var(--type-display-tracking);
  color: var(--brand-primary);
  overflow-wrap: anywhere;
}

.report-masthead-subtitle {
  margin: var(--space-2) 0 0;
  font-size: var(--type-body-size);
  color: var(--text-muted);
  max-width: 62ch;
}

.report-masthead-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-7);
  margin-top: var(--space-4);
}

.report-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.report-meta-label {
  font-size: var(--type-caption-size);
  font-weight: var(--font-weight-label);
  letter-spacing: var(--type-metric-label-tracking);
  text-transform: uppercase;
  color: var(--text-muted);
}

.report-meta-value {
  font-size: var(--type-body-sm-size);
  font-weight: var(--font-weight-subhead);
  color: var(--text-primary);
}

/* The reporting-scope panel the rendering groups at the right of the hero:
   a bounded plate rather than loose controls, so the scope reads as one
   decision instead of three unrelated widgets. */
.report-masthead-controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 248px;
  padding: var(--space-5);
  background: var(--surface-default);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
}

.report-masthead-controls label {
  font-size: var(--type-caption-size);
  font-weight: var(--font-weight-label);
  text-transform: uppercase;
  letter-spacing: var(--type-metric-label-tracking);
  color: var(--text-muted);
}

/* Export sits in the masthead beside the scope selector, because what you
   export is what the selector currently shows. It is chrome, not content,
   so print.css drops it - a printed report carrying its own Export buttons
   is the same mistake as a printed report carrying the sidebar. */
.report-export {
  display: flex;
  gap: var(--space-2);
}

.report-export .btn {
  flex: 1;
}

.report-export-label {
  font-size: var(--type-caption-size);
  font-weight: var(--font-weight-label);
  text-transform: uppercase;
  letter-spacing: var(--type-metric-label-tracking);
  color: var(--text-muted);
  margin-top: var(--space-3);
}

/* Progress and failure for an operation that takes a noticeable moment.
   It is an aria-live region, so it is announced as well as shown, and it
   keeps its box height only when it has something to say. */
.report-export-status {
  font-size: var(--type-caption-size);
  color: var(--text-muted);
  margin: 0;
  min-height: 1lh;
}

.report-export-status.is-error {
  color: var(--status-danger-text);
  font-weight: var(--font-weight-label);
}

.report-export .btn:disabled {
  opacity: 0.6;
  cursor: progress;
}

.report-masthead-controls select {
  padding: var(--space-3) var(--space-4);
  min-height: var(--control-height);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-default);
  color: var(--text-primary);
  font-family: inherit;
  font-size: var(--type-body-sm-size);
}

@media (max-width: 768px) {
  .report-masthead {
    flex-direction: column;
    padding: var(--space-5);
  }

  .report-masthead-controls {
    width: 100%;
  }
}

/* ==========================================================================
   2. SECTION BANDS
   The structural rhythm of a report. Dark blue for framing, white for the
   working surface beneath - never a blue card containing blue content.
   ========================================================================== */

.report-section {
  margin-bottom: var(--space-9);
}

/* BUILD 2. This was a solid navy bar spanning the content width - the
   loudest element on a page whose point is the figures underneath it. The
   approved rendering has no such bar: a section announces itself with a
   dark-blue title and a rule, and the surfaces below it carry the weight.

   The rule is a bottom border rather than a filled block, so the band
   still reads as a divider between sections without competing with the
   page title above or the data below. */
.report-band {
  padding: 0 0 var(--space-3);
  margin: 0 0 var(--space-5);
  border-bottom: 2px solid var(--brand-light-subtle);
  color: var(--brand-primary);
  font-size: var(--type-section-size);
  line-height: var(--type-section-line);
  font-weight: var(--type-section-weight);
}

/* The note sat in a bordered box tucked under the navy bar, which only
   made sense while the bar was a filled block it could hang from. With the
   band now a titled rule, the note is simply the sentence beneath it. */
.report-band-note {
  margin: calc(var(--space-5) * -1) 0 var(--space-5);
  padding: 0;
  border: 0;
  background: none;
  font-size: var(--type-body-sm-size);
  color: var(--text-muted);
}

.report-subsection {
  margin-bottom: var(--space-7);
}

.report-subsection-title {
  font-size: var(--type-subhead-size);
  font-weight: var(--type-subhead-weight);
  color: var(--brand-primary);
  margin: 0 0 var(--space-4);
}

/* ==========================================================================
   3. METRIC TILES AND KPI SUMMARY
   ========================================================================== */

.report-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-5);
  margin-bottom: var(--space-7);
}

.metric-tile {
  background: var(--surface-default);
  border: 1px solid var(--border-default);
  border-left: 3px solid var(--brand-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
  box-shadow: var(--shadow-card);
}

.metric-tile-label {
  font-size: var(--type-metric-label-size);
  font-weight: var(--font-weight-label);
  letter-spacing: var(--type-metric-label-tracking);
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.metric-tile-value {
  font-size: var(--type-metric-value-size);
  line-height: var(--type-metric-value-line);
  font-weight: var(--type-metric-value-weight);
  color: var(--brand-primary);
}

/* A percentage is never shown without the population it was taken over. */
.metric-tile-support {
  font-size: var(--type-helper-size);
  color: var(--text-muted);
  margin-top: var(--space-2);
}

.metric-tile.is-good {
  border-left-color: var(--status-success-text);
}

.metric-tile.is-caution {
  border-left-color: var(--status-warning-text);
}

.metric-tile.is-concern {
  border-left-color: var(--status-danger-text);
}

/* ==========================================================================
   4. CHART CARD
   A chart and its supporting table are ONE unit. The table is not a
   fallback - it is the accessible and printable form of the same data, and
   print rules keep the pair together.
   ========================================================================== */

.chart-card {
  background: var(--surface-default);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-6);
  margin-bottom: var(--space-5);
}

.chart-card-title {
  font-size: var(--type-card-title-size);
  font-weight: var(--type-card-title-weight);
  color: var(--brand-primary);
  margin: 0 0 var(--space-2);
}

.chart-card-note {
  font-size: var(--type-helper-size);
  color: var(--text-muted);
  margin: 0 0 var(--space-5);
}

/* Explicit height: a canvas with no height collapses, and
   maintainAspectRatio:false hands sizing to the container. */
.chart-canvas-wrap {
  position: relative;
  height: 320px;
}

.chart-canvas-wrap.is-tall {
  height: 380px;
}

@media (max-width: 768px) {
  .chart-canvas-wrap,
  .chart-canvas-wrap.is-tall {
    height: 260px;
  }
}

/* ==========================================================================
   5. TARGET, VARIANCE AND COHORT LABELS
   Each carries a word or a glyph as well as a colour.
   ========================================================================== */

.target-indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--type-caption-size);
  font-weight: var(--font-weight-label);
  color: var(--text-secondary);
}

.target-indicator::before {
  content: "\2504";
  color: var(--chart-target);
  font-weight: 700;
}

.variance {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-weight: var(--font-weight-subhead);
  font-variant-numeric: tabular-nums;
}

.variance.is-positive {
  color: var(--chart-positive);
}

.variance.is-positive::before {
  content: "\25B2";
  font-size: 0.8em;
}

.variance.is-negative {
  color: var(--chart-negative);
}

.variance.is-negative::before {
  content: "\25BC";
  font-size: 0.8em;
}

.variance.is-neutral {
  color: var(--text-muted);
}

.variance.is-neutral::before {
  content: "\2013";
}

/* Cohort label - the date window a percentage was taken over. Small, but
   load-bearing: the three retention milestones are separate cohorts and
   must never read as one denominator. */
.cohort-label {
  display: block;
  font-size: var(--type-caption-size);
  font-weight: var(--font-weight-body);
  color: var(--text-muted);
  margin-top: 2px;
}

.supporting-count {
  font-size: var(--type-caption-size);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   6. NARRATIVE AND TAKEAWAY
   ========================================================================== */

.report-narrative {
  background: var(--surface-default);
  border: 1px solid var(--border-default);
  border-left: 3px solid var(--brand-primary);
  border-radius: var(--radius-md);
  padding: var(--space-5) var(--space-6);
  font-size: var(--type-body-size);
  line-height: var(--type-body-line);
}

/* The Executive Takeaway is the one block that should read differently from
   everything around it. Light-blue surface with brand text - measured
   8.42:1 - rather than a dark panel, so it stays readable in print without
   background graphics enabled. */


/* ==========================================================================
   7. STATE SURFACES - no data, unavailable, data quality
   ========================================================================== */

.report-empty,
.report-unavailable {
  background: var(--surface-default);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-8) var(--space-7);
  text-align: center;
  color: var(--text-muted);
}

.report-empty-title {
  font-size: var(--type-card-title-size);
  font-weight: var(--type-card-title-weight);
  color: var(--text-secondary);
  margin: 0 0 var(--space-3);
}

.report-empty p {
  margin: 0 auto;
  max-width: 62ch;
}

/* A shrinking denominator must be visible on the report, not discovered
   later as unexplained drift. Amber surface, brand text, and an icon - the
   meaning does not depend on the colour. */
/* This element is toggled with the `hidden` attribute, and `display` here
   is exactly what used to defeat it - see the [hidden] guard in base.css,
   which is what stops that. The rule stays as it is; the guard is the fix. */
.data-quality-notice {
  display: flex;
  gap: var(--space-3);
  background: var(--status-warning-surface);
  border-left: 3px solid var(--status-warning-text);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  margin-top: var(--space-5);
  font-size: var(--type-helper-size);
  color: var(--brand-primary);
}

.data-quality-notice::before {
  content: "\25B2";
  flex: none;
  font-size: 0.9em;
}

.report-footnote {
  margin-top: var(--space-4);
  font-size: var(--type-caption-size);
  color: var(--text-muted);
}

/* A table cell holding a SENTENCE rather than a value.

   .data-table sets `white-space: nowrap` on every cell, which is right for
   names, dates, percentages and ratings - the things tables are usually made
   of. It is wrong for a manager's written comment: the Low Rated and
   Observations tables carry free text, and on one line the comment ran past
   the edge of the card and left the reader dragging a horizontal scrollbar
   through the exact sentences the section exists to convey.

   THE SELECTOR IS `.data-table td.cell-narrative`, NOT `.cell-narrative`.

   That is the whole fix, and the first attempt got it wrong. `.data-table td`
   is one class plus one type - specificity (0,1,1). A bare `.cell-narrative`
   is one class - (0,1,0). It loses, in every browser, no matter that
   reports.css is loaded after components.css: specificity is resolved before
   source order is ever consulted. The declaration was present, correct and
   completely inert. `td.cell-narrative` inside `.data-table` is (0,2,1) and
   actually wins.

   WIDTH IS LOCKED TO THE TABLE, HEIGHT IS NOT.

   `width: 100%` makes this the column that absorbs whatever width is left
   after the value columns have taken what they need - so the table stays at
   the width of its card and the comment wraps inside it, growing the row
   downwards instead of pushing the table sideways. `.table-card` keeps its
   `overflow-x: auto` for genuinely wide numeric tables; this column simply
   no longer needs it.

   `vertical-align: top` matters once a row can be several lines tall: the
   name and the rating belong beside the FIRST line of the comment, not
   floating in the middle of it. */
.data-table td.cell-narrative,
.data-table th.cell-narrative {
  white-space: normal;
  vertical-align: top;
  width: 100%;
  /* A floor so the column is not squeezed to a few characters by the nowrap
     columns beside it, and a ceiling so a wide screen does not stretch a
     sentence to a 200-character measure, which is as hard to read as a
     column that is too thin. */
  min-width: 18rem;
  max-width: 46rem;
  line-height: var(--type-body-line);
  /* For a pasted URL or any unbroken token, which would otherwise be a
     single unbreakable word and reintroduce the overflow on its own. */
  overflow-wrap: anywhere;
}

/* The floor comes down with the viewport. The text still wraps - it simply
   wraps sooner - so an ordinary comment needs no horizontal scrolling at any
   of these widths. */
@media (max-width: 768px) {
  .data-table td.cell-narrative,
  .data-table th.cell-narrative {
    min-width: 12rem;
  }
}

@media (max-width: 480px) {
  .data-table td.cell-narrative,
  .data-table th.cell-narrative {
    min-width: 8rem;
  }
}

/* ==========================================================================
   7b. DRILL-DOWN AFFORDANCE
   A retention value the reader can open. The whole value is the control -
   the percentage AND its supporting count - because "87.5% (7 of 8)" is one
   fact, and making only the digits clickable would be a 30px target inside
   a 140px statement.
   ========================================================================== */

.value-drilldown {
  display: inline-flex;
  align-items: center;
  /* 44px of vertical target without making the row taller than its
     neighbours: the padding supplies the hit area, the negative margin
     gives the space back to the table. */
  min-height: 44px;
  margin: calc(var(--space-3) * -1) calc(var(--space-3) * -1);
  padding: var(--space-3);
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  font: inherit;
  color: var(--brand-primary);
  font-weight: var(--font-weight-label);
  cursor: pointer;
  text-align: left;
  /* The underline is the non-colour affordance. Dotted rather than solid so
     it reads as "openable", not as a visited link, and so the value is still
     legible in greyscale and in forced-colors mode. */
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
  transition: background var(--motion-fast) var(--motion-ease),
    color var(--motion-fast) var(--motion-ease);
}

.value-drilldown:hover {
  background: var(--brand-primary-subtle);
  text-decoration-style: solid;
}

.value-drilldown:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring);
  outline-offset: 2px;
}

/* ==========================================================================
   7c. DRILL-DOWN MODAL CONTENT
   The modal frame itself is components.css's - only what goes inside it is
   described here, so the report and the Retention Dashboard keep the same
   dialog.
   ========================================================================== */

.modal-summary {
  background: var(--brand-light-surface);
  border: 1px solid var(--brand-light);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
  margin-bottom: var(--space-5);
}

/* The number the reader clicked, restated at the top of what it opened, so
   the modal can be checked against the table without scrolling back. */
.modal-summary-headline {
  margin: 0 0 var(--space-4);
  font-size: var(--type-subhead-size);
  font-weight: var(--font-weight-subhead);
  color: var(--brand-primary);
}

/* Label/value pairs. A definition list rather than a table because these are
   facts about one thing, not rows of comparable things. */
.modal-summary-facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-2) var(--space-5);
  margin: 0;
  font-size: var(--type-body-sm-size);
}

.modal-summary-facts dt {
  color: var(--text-muted);
  font-weight: var(--font-weight-label);
}

.modal-summary-facts dd {
  margin: 0;
  color: var(--text-primary);
}

.population-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
  border-bottom: 1px solid var(--border-default);
}

.population-tab {
  min-height: 40px;
  padding: var(--space-3) var(--space-5);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  font: inherit;
  font-weight: var(--font-weight-label);
  color: var(--text-secondary);
  cursor: pointer;
}

.population-tab:hover {
  background: var(--brand-primary-subtle);
  color: var(--brand-primary);
}

/* Selected state carries a rule and a weight change, not only a colour. */
.population-tab[aria-selected="true"] {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
}

.population-tab:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring);
  outline-offset: -2px;
}

/* Loading, error and empty all render as one paragraph, so they cannot drift
   into three different shapes. */
.modal-message {
  margin: var(--space-6) 0;
  color: var(--text-muted);
  text-align: center;
}

.modal-message.is-error {
  color: var(--status-danger-text);
  font-weight: var(--font-weight-label);
}

/* The dialog scrolls internally; the page behind it must not. */
body.has-modal-open {
  overflow: hidden;
}

/* ==========================================================================
   7d. EXPORT BUILDER
   Filters beside columns on a wide screen, stacked below it. Nothing here
   is a new component - the controls are .form-field, .btn and .table-card
   from components.css; only the two-column arrangement is local.
   ========================================================================== */

.export-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-7);
  margin-bottom: var(--space-6);
}

@media (max-width: 960px) {
  .export-layout {
    grid-template-columns: 1fr;
  }
}

.export-column-group {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: var(--space-2) var(--space-4);
  margin-bottom: var(--space-5);
}

/* The whole row is the label, so the checkbox has a full-width hit area
   rather than a 13px target. */
.export-column {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--type-body-sm-size);
}

.export-column:hover {
  background: var(--brand-primary-subtle);
}

.export-column input {
  flex: none;
  min-width: 18px;
  min-height: 18px;
}

.export-column:focus-within {
  outline: var(--focus-ring-width) solid var(--focus-ring);
  outline-offset: 1px;
}

#emailListResult textarea {
  width: 100%;
  margin-bottom: var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--type-body-sm-size);
}

/* ==========================================================================
   8. REPORT TABLES
   Built on .data-table from components.css. Only report-specific behaviour
   lives here: grouped headers, summary rows and numeric alignment.
   ========================================================================== */

.report-table-grouped th {
  text-align: center;
}

.report-table-grouped th:first-child {
  text-align: left;
}

.report-table-group-head {
  border-left: 1px solid var(--border-strong);
  border-right: 1px solid var(--border-strong);
}

.report-table-grouped td:not(:first-child) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* The reporting week the whole report is anchored to. */
.report-row-current td {
  font-weight: var(--font-weight-subhead);
  background: var(--brand-light-surface);
}

.report-row-summary td {
  font-weight: var(--font-weight-subhead);
  border-top: 2px solid var(--border-strong);
  background: var(--surface-sunken);
}

/* A blank cell means "not reported" and must never read as zero. */
.value-missing {
  color: var(--text-muted);
}

.report-footer {
  margin-top: var(--space-9);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border-default);
  font-size: var(--type-caption-size);
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  gap: var(--space-5);
  flex-wrap: wrap;
}

/* Only shown when printed - see print.css. */
.report-print-header {
  display: none;
}

/* ==========================================================================
   9. SIDE-BY-SIDE REPORT BLOCKS
   ========================================================================== */

.report-split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: var(--space-5);
}
