/* Responsive layer: adapts every screen from the 1440 px desktop design down to a 375 px phone.
   Loaded by base.html after every page stylesheet (so equal-specificity rules here win) and before print.css.
   Desktop-first; nothing above 1280 px changes, so the 1440 design stays pixel-faithful.

   Breakpoints (custom properties cannot be used inside @media, so they are fixed here; tokens.css documents them):
     ≤ 1280  compact   tighter gutters, top bar tightens, grids reflow
     ≤ 1024  tablet    asides move below the content or collapse; 3-column forms → 2; recruiter cards 2 per row;
                       wide tables scroll inside their card
     ≤  768  phone-l   the top bar folds into a menu; forms → 1 column; row tables stack; stepper condenses;
                       footer bar wraps; tab strips scroll sideways
     ≤  480  phone     16 px gutters, dialogs full screen, everything single column
   Every breakpoint is screen-only, so print.css keeps printing the desktop layout.
   Colours, sizes and radii only through tokens.css. */

/* ── Desktop defaults for the small-screen-only pieces ─────────────────────── */
.collapsible__summary, .stepper-compact { display: none; }
.collapsible > .card { width: 100%; }

/* Fieldsets default to min-inline-size: min-content, which lets a row of pills or segments push a card wider
   than the screen. Every fieldset in the app is a layout box, so let it shrink like a div. */
fieldset { min-inline-size: 0; }
/* Visually hidden labels inside a table are absolutely positioned: keep their containing block inside the table so
   they are clipped by its horizontal scroller instead of widening the page. */
.grid-table { position: relative; }
/* Same for the charts' visually hidden data tables: a table cannot shrink below its content, so its wrapper clips it
   (the 4 px margin keeps focus rings on the chart links visible). */
.bars-wrap, .donut-wrap { position: relative; overflow: clip; overflow-clip-margin: var(--sp-1); }

/* ═══════════════════════════════════════════════════════════════════════════
   ≤ 1280 — compact
   ═══════════════════════════════════════════════════════════════════════════ */
@media screen and (max-width: 1280px) {
  :root { --gutter: 32px; }

  /* Auth split: the brand panel gives way, the form column keeps its width. */
  .auth__brand { width: auto; flex: 1 1 auto; min-width: 0; padding: var(--sp-12) var(--sp-12); }
  .auth__column { flex: 0 0 min(var(--auth-form-w), 55%); width: auto; padding-left: var(--sp-6); padding-right: var(--sp-6); }
  .auth__headline { font-size: var(--fs-display-xl); }
  .auth__logo { width: min(290px, 100%); }

  .donut-card { width: 420px; }
  .result__body { gap: var(--sp-8); }
  .aside--cv { width: 380px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   ≤ 1024 — tablet
   ═══════════════════════════════════════════════════════════════════════════ */
@media screen and (max-width: 1024px) {
  :root { --gutter: 24px; --main-pad-top: 28px; --main-pad-top-record: 24px; }
  .main { gap: var(--sp-7); }

  /* Top bar: smaller gaps; the account menu shows the avatar only (name and role stay in its label);
     the CTA shortens to "New record" (its accessible name stays the full label). */
  .topbar__panel { margin-left: var(--sp-8); gap: var(--sp-4); }
  .topbar__nav { gap: 0; }
  .topbar__right { gap: var(--sp-4); }
  .user-menu__text { display: none; }
  .topbar__cta { padding: 0 var(--sp-3_5); }
  .topbar__cta-long { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
  .topbar__cta-short { display: inline; }
  .topbar__tab { padding: 0 var(--sp-2_5); }

  /* Page header and sub-header wrap. */
  .page-header { flex-wrap: wrap; align-items: flex-start; }
  .page-header__right { flex-wrap: wrap; }
  .subheader { flex-direction: column; align-items: stretch; gap: var(--sp-4); }
  .subheader__right { flex-wrap: wrap; flex-shrink: 1; }
  .subheader__titlerow { flex-wrap: wrap; row-gap: var(--sp-2); }

  /* Content + aside layouts become one column; asides follow the content (or collapse, see .collapsible). */
  .layout, .pool-layout, .reports-layout, .record-layout, .profile-layout, .record-upload {
    flex-direction: column; align-items: stretch;
  }
  .aside, .aside--cv, .aside--interview, .aside--profile, .aside--upload, .aside--filters { width: auto; }
  .aside--sticky, .record-layout .aside--sticky { position: static; max-height: none; overflow: visible; }
  .record-upload__card, .record-search { width: auto; flex-shrink: 1; }
  /* Asides with several cards sit side by side while there is room. */
  .aside--profile, .aside--cv, .aside--interview { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; }

  /* Collapsible Filters / Report builder: a full-width bar above the results. */
  .collapsible__summary {
    display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3);
    min-height: var(--h-control-lg); padding: 0 var(--sp-5); list-style: none; cursor: pointer;
    border: 1px solid var(--border-card); border-radius: var(--radius-lg); background: var(--bg-surface);
    font-family: var(--font-display); font-size: var(--fs-h2-xs); line-height: var(--lh-heading);
  }
  .collapsible__summary::-webkit-details-marker { display: none; }
  .collapsible__summary::after {
    content: ""; width: 10px; height: 10px; flex-shrink: 0; margin-top: -4px;
    border-right: 1.8px solid var(--text-tertiary); border-bottom: 1.8px solid var(--text-tertiary); transform: rotate(45deg);
  }
  .collapsible[open] > .collapsible__summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-bottom-color: transparent; }
  .collapsible[open] > .collapsible__summary::after { transform: rotate(-135deg); margin-top: 4px; }
  .collapsible__hint { margin-left: auto; font-family: var(--font-body); font-size: var(--fs-caption); color: var(--text-secondary); }
  .collapsible[open] > .card { border-top-left-radius: 0; border-top-right-radius: 0; border-top: 0; }
  .collapsible[open] > .card > .filters__head .filters__title,
  .collapsible[open] > .card > .builder__head .builder__title { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
  .collapsible[open] > .card > .filters__head { justify-content: flex-end; }

  /* Forms: three columns → two. */
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field--span3 { grid-column: 1 / -1; }
  .repeat-row__grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* Dashboard: recruiter cards two per row; activity and donut stack. */
  .recruiter-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-lower { flex-direction: column; }
  .donut-card { width: auto; }

  /* Progress list: fixed tracks for the dots, the badge and Open so the text columns share the rest. */
  .candidate-list__table { --cols: 1.3fr 1.6fr 1.3fr 0.8fr 0.8fr 64px 104px 1.5fr 72px; --col-gap: 12px; }
  .candidate-list__table .candidate-list__open { padding: 0 var(--sp-2); }

  /* Reports. */
  .quick-reports { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* Profile. */
  .profile-attribution { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3_5) var(--sp-6); }
  .placement-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .add-submission__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
  .add-submission__submit { justify-self: start; }

  /* Admin. */
  .admin-two { grid-template-columns: minmax(0, 1fr); }
  .cities-search { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .institutions-search { grid-template-columns: minmax(0, 1fr) auto; }
  .invite-panel__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
  .invite-panel__submit { justify-self: start; }
  .audit-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .audit-filters .field:last-child { grid-column: 1 / -1; }
  .dept-layout { grid-template-columns: minmax(0, 1fr); row-gap: var(--sp-5); }
  .dept-list__items { flex-direction: row; flex-wrap: wrap; gap: var(--sp-2); }
  .dept-list__area { flex-basis: 100%; margin: var(--sp-2) 0 0; padding: 0; }
  .dept-list__area:first-of-type { margin-top: 0; }
  .dept-list__item { border: 1px solid var(--border-control); gap: var(--sp-2_5); }
  .dept-list input:checked + .dept-list__item { border-color: var(--navy-900); }

  /* Wide tables scroll sideways inside their card; the first column stays pinned. */
  .grid-table--scroll { overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
  .grid-table--scroll > thead, .grid-table--scroll > tbody { min-width: var(--table-min, 720px); }
  .grid-table--scroll > tfoot { position: sticky; left: 0; }
  .grid-table--scroll th:first-child, .grid-table--scroll td:first-child {
    position: sticky; left: 0; z-index: 1; align-self: stretch; display: flex; flex-direction: column; justify-content: center;
    background: var(--bg-surface); box-shadow: 1px 0 0 var(--border-hairline);
  }
  .grid-table--scroll .roles-pane__empty td:first-child { position: static; box-shadow: none; }
  .comparison__table { --table-min: 800px; }
  .users-table .grid-table { --table-min: 1000px; }
  .clients-table .grid-table { --table-min: 820px; }
  .flagged .grid-table { --table-min: 900px; }
  .roles-pane .grid-table { --table-min: 640px; }
  .submissions-card .grid-table { --table-min: 680px; }
  #countries-table { --table-min: 560px; }
  /* The pinned column of the recruiter comparison keeps its avatar + name on one line. */
  .comparison__table td.comparison__who { flex-direction: row; justify-content: flex-start; align-items: center; }
  .users-table td:first-child { flex-direction: row; justify-content: flex-start; align-items: center; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   ≤ 768 — phone landscape / large phone
   ═══════════════════════════════════════════════════════════════════════════ */
@media screen and (max-width: 768px) {
  :root { --gutter: 20px; --main-pad-top: 24px; --main-pad-top-record: 20px; }
  .main { gap: var(--sp-6); }

  /* ── Top bar: logo + menu button; the panel drops down under the bar ── */
  .topbar { position: relative; z-index: 50; }
  .topbar__menu-button {
    display: inline-flex; align-items: center; gap: var(--sp-2); height: var(--size-hit); min-width: var(--size-hit);
    margin-right: calc(-1 * var(--sp-2)); padding: 0 var(--sp-2_5); border-radius: var(--radius-md);
    color: var(--gold-500); font-size: var(--fs-ui); font-weight: var(--fw-semibold); cursor: pointer;
  }
  .topbar__menu-button:hover { background: var(--navy-800); }
  .topbar__menu-close { display: none; }
  .topbar.is-open .topbar__menu-open { display: none; }
  .topbar.is-open .topbar__menu-close { display: inline; }
  .topbar__panel {
    display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 50;
    height: auto; max-height: calc(100vh - var(--header-h)); max-height: calc(100dvh - var(--header-h)); overflow-y: auto;
    margin: 0; padding: var(--sp-2) var(--gutter) var(--sp-5);
    flex-direction: column; align-items: stretch; gap: var(--sp-4);
    background: var(--bg-brand); border-top: 1px solid var(--navy-800); box-shadow: var(--shadow-dialog);
  }
  .topbar.is-open .topbar__panel { display: flex; }
  .topbar__nav { flex-direction: column; height: auto; gap: 0; }
  .topbar__tab {
    height: var(--h-control-lg); padding: 0 var(--sp-3); border-bottom: 1px solid var(--navy-800);
    font-size: var(--fs-body-md);
  }
  .topbar__tab[aria-current="page"] { border-bottom-color: var(--navy-800); box-shadow: inset 3px 0 0 var(--gold-500); padding-left: var(--sp-4); }
  .topbar__right { flex-direction: column; align-items: stretch; gap: var(--sp-4); }
  .topbar__cta { height: var(--h-control-lg); }
  .topbar__cta-long { position: static; width: auto; height: auto; margin: 0; overflow: visible; clip: auto; clip-path: none; }
  .topbar__cta-short { display: none; }
  .topbar .user-menu { display: none; }
  .topbar__account { display: flex; flex-direction: column; gap: var(--sp-3); padding-top: var(--sp-4); border-top: 1px solid var(--navy-800); }
  .topbar__account-who { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
  .topbar__account-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
  .topbar__account-text .user-menu__role { overflow-wrap: anywhere; }
  .topbar__signout { align-self: flex-start; background: transparent; border-color: var(--navy-100); color: var(--text-inverse); }
  .topbar__signout:hover { background: var(--navy-800); color: var(--text-inverse); }

  /* ── Type ── */
  .page-header__title { font-size: var(--fs-display-sm); }
  .subheader__title { font-size: var(--fs-display-xs); }
  .results-toolbar__big { font-size: var(--fs-display-xs); }
  .card--p28, .card--p32 { padding: var(--sp-5); }
  .card--p24 { padding: var(--sp-5); }

  /* ── Generic flex rows wrap ── */
  .card__head, .card__titlerow, .section-head, .table-footer, .table-toolbar, .card__foot,
  .dialog__foot, .export-foot, .cvx-foot, .result__foot, .placement-card__foot, .kept-as-new, .parse-banner,
  .visa-matrix__foot, .activity-more, .drafts-list__row, .suggestion__top, .match-row, .uploaded-file, .parse-cta {
    flex-wrap: wrap;
  }
  .card__right { flex-shrink: 1; flex-wrap: wrap; }
  .parse-banner { align-items: flex-start; }
  /* The legend may shrink below its badges' width, so they wrap instead of pushing the page wider at phone width. */
  .parse-banner__legend { flex-wrap: wrap; flex-shrink: 1; min-width: 0; max-width: 100%; }

  /* Segmented controls (period switch) and pill groups wrap instead of pushing the page wider. */
  .segmented { display: flex; flex-wrap: wrap; max-width: 100%; }
  .segmented--period, .period-switch, .page-header__right { width: 100%; }
  .segmented:not(.segmented--form):not(.segmented--compact) .segmented__option { flex: 1 1 auto; padding: 0 var(--sp-3); }
  .segmented--form { height: auto; min-height: var(--h-control); }
  .segmented--form .segmented__option { min-width: 0; }
  .segmented--compact { flex-wrap: wrap; }
  .pills { max-width: 100%; }
  .pill { max-width: 100%; }

  /* Tab strips scroll sideways inside their row (the underline is drawn inside the tab so it is not clipped). */
  .tab-strip, .recruiter-tabs { overflow-x: auto; overflow-y: hidden; scrollbar-width: none; gap: var(--sp-5); }
  .tab-strip::-webkit-scrollbar, .recruiter-tabs::-webkit-scrollbar { display: none; }
  .tab-strip__tab, .recruiter-tabs__tab { flex-shrink: 0; white-space: nowrap; margin-bottom: 0; border-bottom: 0; }
  .tab-strip__tab[aria-current="page"], .tab-strip input:checked + .tab-strip__tab,
  .recruiter-tabs input:checked + .recruiter-tabs__tab { box-shadow: inset 0 -2px 0 var(--navy-900); }
  .tab-strip input:focus-visible + .tab-strip__tab, .recruiter-tabs input:focus-visible + .recruiter-tabs__tab { outline-offset: -2px; }

  /* ── Forms: one column ── */
  .form-grid, .form-grid--2 { grid-template-columns: minmax(0, 1fr); }
  .field--span2, .field--span3 { grid-column: 1 / -1; }
  .language-grid { grid-template-columns: minmax(0, 1fr); }
  .input--search { width: 100%; max-width: 100%; }
  .chip-box__input { min-width: min(180px, 100%); }
  .visa-row { grid-template-columns: minmax(0, 1fr); row-gap: var(--sp-2); padding: var(--sp-3) 0; }
  .visa-row__options { flex-wrap: wrap; justify-content: flex-start; }
  .visa-row__sponsorship { padding-left: 0; border-left: 0; }
  .visa-picker .select { width: 100%; }
  .status-card__controls { grid-template-columns: minmax(0, 1fr); row-gap: var(--sp-3); }
  .status-card__buttons { justify-content: flex-start; flex-wrap: wrap; }
  .roles-pane__add, .roles-pane__add:has(.roles-pane__name input:not(:placeholder-shown)), .roles-pane__add.has-error {
    grid-template-columns: minmax(0, 1fr); row-gap: var(--sp-2_5);
  }
  .roles-pane__submit { justify-self: start; }
  .progress-filters__wide { grid-column: 1 / -1; }
  .progress-filters__summary { display: flex; align-items: center; min-height: var(--size-hit); }
  /* Admin departments: one sideways-scrolling row instead of 21 wrapped pills. */
  .dept-list__items { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; padding-bottom: var(--sp-1_5); }
  .dept-list__area { flex: 0 0 auto; flex-basis: auto; align-self: center; margin: 0 var(--sp-1) 0 var(--sp-2); }
  .dept-list__area:first-of-type { margin-left: 0; }
  .dept-list__item { flex: 0 0 auto; white-space: nowrap; }

  /* ── Record steps ── */
  .stepper { display: none; }
  .stepper-compact { display: block; margin: 0; font-size: var(--fs-ui); font-weight: var(--fw-semibold); color: var(--text-tertiary); }
  .footer-bar {
    height: auto; min-height: 0; flex-wrap: wrap; gap: var(--sp-2_5) var(--sp-3);
    padding: var(--sp-3) var(--gutter) calc(var(--sp-3) + env(safe-area-inset-bottom, 0px));
  }
  .footer-bar > :first-child { flex: 1 1 100%; min-width: 0; }
  .footer-bar__status { flex-wrap: wrap; font-size: var(--fs-caption); row-gap: var(--sp-1); }
  .footer-bar__actions { flex: 1 1 100%; flex-wrap: wrap; gap: var(--sp-2); }
  .footer-bar__actions .btn { flex: 1 1 auto; height: var(--h-control-sm); padding: 0 var(--sp-3_5); }
  .footer-bar__actions .btn--primary { flex-basis: 100%; }
  .record-upload__card { padding: var(--sp-5); }
  .record-search { padding: var(--sp-5); }
  .parse-cta .btn--cta { padding: 0 var(--sp-6); }

  /* ── Row tables stack into cards: label/value cells in two columns ── */
  .grid-table--stack { --stack-gap: var(--sp-3); }
  .grid-table--stack > thead { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
  .grid-table--stack tbody tr {
    grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--sp-4); row-gap: var(--stack-gap);
    align-items: start; min-height: 0; padding: var(--sp-4) 0;
  }
  .grid-table--stack tbody tr:first-child { border-top: 1px solid var(--border-control); }
  .grid-table--stack tbody td:first-child { grid-column: 1 / -1; }
  .grid-table--stack td.is-end { justify-self: stretch; text-align: left; }
  .grid-table--stack td[data-label]::before {
    content: attr(data-label); display: block; margin-bottom: 2px;
    font-size: var(--fs-micro); font-weight: var(--fw-semibold); letter-spacing: var(--ls-th-sm); text-transform: uppercase; color: var(--text-secondary);
  }
  .grid-table--stack td:empty { display: none; }
  .grid-table--stack .grid-table__empty td, .grid-table--stack tr.grid-table__empty { padding: 0; }
  .grid-table--stack tbody tr.grid-table__empty { grid-template-columns: minmax(0, 1fr); }

  /* Awaiting interview rows: action button across the card. */
  .inbox-table td.cell-actions { grid-column: 1 / -1; }
  .inbox-table .cell-actions .inbox-row__action { width: 100%; }
  .interview-menu { width: min(340px, calc(100vw - 2 * var(--gutter))); }
  /* Pool rows: name with the interviewer's avatar on the right. */
  .pool-grid tbody td:first-child { grid-column: 1; grid-row: 1; }
  .pool-grid tbody td:last-child { grid-column: 2; grid-row: 1; justify-self: end; }
  /* Progress rows: name with "Open" on the right; the latest submission spans the card. */
  .candidate-list__table tbody td:first-child { grid-column: 1; grid-row: 1; align-self: center; }
  .candidate-list__table tbody td.candidate-list__action { grid-column: 2; grid-row: 1; justify-self: end; }
  .candidate-list__table .candidate-list__open { width: auto; padding: 0 var(--sp-5); }
  .candidate-list__table tbody td.candidate-list__latest { grid-column: 1 / -1; }
  /* Audit rows: when + who on one line, what underneath. */
  .audit-table .grid-table--stack tbody tr, .grid-table--stack#audit-latest tbody tr { grid-template-columns: auto minmax(0, 1fr); row-gap: var(--sp-1_5); padding: var(--sp-3) 0; }
  .audit-table .grid-table--stack tbody td:first-child, #audit-latest tbody td:first-child { grid-column: 1; }
  .audit-table .grid-table--stack tbody td:last-child, #audit-latest tbody td:last-child { grid-column: 1 / -1; }

  /* ── Dashboard ── */
  .inbox-toolbar__search { width: 100%; }
  .inbox-toolbar .pills { flex-wrap: wrap; }
  .dropzone { align-items: flex-start; }
  .donut-card .donut-wrap { gap: var(--sp-6); }

  /* ── Progress ── */
  .candidate-list__form { gap: var(--sp-5); }
  .candidate-list__head { flex-direction: column; align-items: stretch; gap: var(--sp-4); }
  .candidate-list__search { width: 100%; }
  .comparison { gap: var(--sp-4); }

  /* ── Pool ── */
  .results-toolbar { flex-wrap: wrap; gap: var(--sp-3) var(--sp-4); }
  .results-toolbar__actions { flex: 1 1 100%; flex-wrap: wrap; }
  .results-toolbar__sort { flex: 1 1 200px; width: auto; }

  /* ── Reports ── */
  .result__body { flex-direction: column; align-items: stretch; gap: var(--sp-6); }
  .result__body .donut-wrap { align-self: center; }
  .result__legend { width: 100%; }
  .result__sentence { font-size: var(--fs-h2-sm); }
  .result__actions { flex-wrap: wrap; }
  .legend-strip { flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); }
  .bars__row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "label label" "track track" "nums nums"; row-gap: var(--sp-1_5); padding: var(--sp-3) 0; }
  .bars__label { grid-area: label; }
  .bars__track { grid-area: track; }
  .bars__nums { grid-area: nums; justify-content: flex-start; flex-wrap: wrap; white-space: normal; column-gap: var(--sp-3); }
  .bars__total { margin-left: auto; }

  /* ── Profile ── */
  .pipeline__step { width: auto; flex: 0 1 96px; min-width: 64px; }
  .pipeline__label { font-size: var(--fs-caption); overflow-wrap: anywhere; }
  .profile-tabs { padding: 0 var(--gutter); }
  .read-kv .kv__row { grid-template-columns: 160px minmax(0, 1fr); }
  .kept-as-new { align-items: flex-start; }

  /* ── Dialogs ── */
  .dialog { max-width: calc(100vw - 2 * var(--sp-4)); max-height: calc(100dvh - 2 * var(--sp-4)); padding: var(--sp-6) var(--sp-5); gap: var(--sp-5); }
  .dialog__actions { flex-wrap: wrap; }
  .export-foot__actions, .cvx-foot__actions { flex-wrap: wrap; }

  /* ── Auth: the brand panel becomes a compact logo header ── */
  .auth { flex-direction: column; }
  .auth__brand { flex: 0 0 auto; width: auto; min-height: 0; padding: var(--sp-5) var(--gutter); border-right: 0; border-bottom: 1px solid var(--gold-500); }
  .auth__monogram, .auth__copy, .auth__foot { display: none; }
  .auth__logo { width: 200px; }
  .auth__column { flex: 1 0 auto; width: auto; min-height: 0; padding: var(--sp-10) var(--gutter) var(--sp-8); gap: var(--sp-10); justify-content: flex-start; }
  .auth__spacer { display: none; }
  .auth__card, .auth__footer { width: 100%; max-width: var(--auth-col-w); }
  .auth__title { font-size: var(--fs-display-sm); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   ≤ 640 — narrow tablet / large phone (intermediate reflows)
   ═══════════════════════════════════════════════════════════════════════════ */
@media screen and (max-width: 640px) {
  .recruiter-cards { grid-template-columns: minmax(0, 1fr); }
  .placement-grid, .add-submission__grid, .invite-panel__grid, .audit-filters { grid-template-columns: minmax(0, 1fr); }
  .audit-filters .field:last-child { grid-column: auto; }
  .invite-panel__errors { display: none; }
  .aside--profile, .aside--cv, .aside--interview { grid-template-columns: minmax(0, 1fr); }
  .export-columns, .cvx-options { grid-template-columns: minmax(0, 1fr); }
  .dup-compare { grid-template-columns: minmax(0, 1fr); }

  /* Profile pipeline: vertical, node + label per line. */
  .pipeline { flex-direction: column; align-items: stretch; }
  .pipeline__step { flex-direction: row; flex: none; width: auto; min-width: 0; gap: var(--sp-3); }
  .pipeline__label { text-align: left; font-size: var(--fs-ui-sm); }
  .pipeline__connector { flex: none; width: 1px; height: var(--sp-3_5); margin: var(--sp-1) 0 var(--sp-1) calc(var(--size-status-node) / 2); }
  .status-stepper { flex-direction: column; align-items: stretch; gap: var(--sp-2); }
  .status-stepper__step { flex-direction: row; width: auto; text-align: left; }
  .status-stepper__step::before { display: none; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   ≤ 480 — phone
   ═══════════════════════════════════════════════════════════════════════════ */
@media screen and (max-width: 480px) {
  :root { --gutter: 16px; --main-pad-top: 20px; --main-pad-top-record: 16px; }
  .main { gap: var(--sp-5); padding-bottom: var(--sp-8); }
  .main--record-upload { padding-bottom: var(--sp-8); }

  .page-header__title { font-size: var(--fs-display-xs); }
  .subheader { padding: var(--sp-4) var(--gutter); }
  .subheader__title { font-size: var(--fs-h2-xl); }
  .subheader__right .btn { flex: 1 1 auto; }
  .card, .card--p20, .card--p24, .card--p28, .card--p32 { padding: var(--sp-4); }
  .card__title--xl { font-size: var(--fs-h2-sm); }
  .card__title--lg, .card__title, .card__title--md { font-size: var(--fs-h2-sm); }
  .recruiter-card__big { font-size: var(--fs-display-lg); }
  .recruiter-card__number { height: auto; }

  /* Chips wrap their text rather than overflow. */
  .chip { max-width: 100%; height: auto; min-height: var(--h-chip); white-space: normal; padding-top: 2px; padding-bottom: 2px; }

  /* Row grids inside forms. */
  .repeat-row__grid--2, .repeat-row__grid--4 { grid-template-columns: minmax(0, 1fr); }
  .repeat-row { padding: var(--sp-3_5); }
  .location-adder { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: var(--sp-2); }
  .location-adder > :last-child { grid-column: 1 / -1; }
  .money { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .money > :first-child { grid-column: 1 / -1; }
  .language-row__controls { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) 44px; }
  /* A certification the CV names: its words on one line, the picker and remove button on the next. */
  .cert-unmatched__row { grid-template-columns: minmax(0, 1fr) 44px; row-gap: var(--sp-1_5); }
  .cert-unmatched__label { grid-column: 1 / -1; }
  .language-adder { max-width: none; }
  /* List editor dialog: its rows carry inline grid templates (name + fixed-width extras, move and hide buttons),
     so on a phone they switch to a wrapping flex row: the name takes the first line, the controls the next. */
  .list-editor__row { display: flex !important; flex-wrap: wrap; align-items: center; gap: var(--sp-2); padding-bottom: var(--sp-2); border-bottom: 1px solid var(--border-hairline); }
  .list-editor__row > :first-child { flex: 1 1 100%; min-width: 0; }
  .list-editor__row > * { flex: 0 1 auto; min-width: 0; }
  .list-editor__row > .select, .list-editor__row > .input, .list-editor__row > .field { flex: 1 1 120px; }
  .list-editor__row[aria-hidden="true"] { display: none !important; }
  .list-editor__row .field__error { flex-basis: 100%; }
  .list-editor__row .row { flex-wrap: wrap; min-width: 0; }
  .list-editor__row .nowrap { white-space: normal; overflow-wrap: anywhere; }
  .filters__pair--money { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* Key/value lists: narrower labels; the profile's read-only tabs stack label over value. */
  .kv__row { grid-template-columns: minmax(96px, 38%) minmax(0, 1fr); }
  .read-kv .kv__row { grid-template-columns: minmax(0, 1fr); row-gap: 2px; }
  .activity-item { grid-template-columns: 32px minmax(0, 1fr); row-gap: 2px; }
  .activity-item__time { grid-column: 2; }
  .activity__item { flex-wrap: wrap; row-gap: 2px; }
  .activity__time { margin-left: calc(32px + var(--sp-3_5)); }
  .activity__text { flex-basis: calc(100% - 32px - var(--sp-3_5)); }
  .profile-attribution { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: var(--sp-3_5) var(--gutter); gap: var(--sp-3) var(--sp-4); }
  .profile-attribution__who { flex-wrap: wrap; row-gap: 2px; }

  /* Donuts shrink; the legend goes under the donut. */
  .donut-wrap { flex-direction: column; align-items: stretch; gap: var(--sp-5); }
  .donut-wrap .donut { align-self: center; }
  .donut--260 { width: 200px; height: 200px; }
  .result__body .donut--260 .donut__value { font-size: var(--fs-display-lg); }
  .legend-table th.is-end, .legend-table td.is-end { width: 64px; }
  .legend-table tbody tr, .legend-table tfoot tr { font-size: var(--fs-body); }
  .legend-table tbody td { padding-top: var(--sp-2); padding-bottom: var(--sp-2); }
  .quick-report__link { padding: var(--sp-2_5) var(--sp-3); }
  .result__actions, .result__actions .btn { width: 100%; }

  /* Buttons that end a form take the full width. */
  .dialog__actions, .export-foot__actions, .cvx-foot__actions { width: 100%; }
  .dialog__actions .btn, .export-foot__actions .btn, .cvx-foot__actions .btn { flex: 1 1 auto; }
  .status-card__buttons .btn { flex: 1 1 auto; }

  /* Dialogs: full screen. */
  .dialog, .dialog--620, .dialog--520 {
    width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0;
    padding: var(--sp-5) var(--gutter) calc(var(--sp-5) + env(safe-area-inset-bottom, 0px));
  }
  .dialog--960 { width: 100vw; }
  .dialog__title { font-size: var(--fs-h2-lg); }

  .toast-host { right: var(--sp-4); left: var(--sp-4); bottom: calc(var(--sp-4) + var(--toast-lift, 0px)); width: auto; max-width: none; }

  /* Auth. */
  .auth__column { padding-top: var(--sp-8); }
  .auth__title { font-size: var(--fs-display-xs); }
  .auth__logo { width: 170px; }
}
