/* Tablets and phones. Loaded last; desktop styles are unchanged above 1100px. Printing is unaffected.
   UI release 2 B3: what a part or the page scaffold now covers left this file (the filter bar folds the old
   filter forms, the .seg wraps itself, tables fold by priority below). What stays is the navigation's shape under
   900 px, the phone's top bar, table.cards, the windows, and the page rules no part covers. */

.narrow-only { display: none; }

@media screen {
  /* ---------- Tablet (iPad portrait and smaller) ---------- */
  @media (max-width: 1100px) {
    /* Tables fold by priority (UI release 2 B3): a column marked pri-3 (th and td) goes under 1100 px; under 640 px a
       card shows it again (below). */
    th.pri-3, td.pri-3 { display: none; }
    /* All unscheduled: carrier and insurance (pri-3) fold into the patient cell so the follow-up columns stay on screen */
    .unsched-table .narrow-only { display: block; }
    .unsched-table th, .unsched-table td { padding-left: 8px; padding-right: 8px; }
    .unsched-table td.card-title { min-width: 200px; }
  }

  /* ---------- Under 900 px: no rail; the bottom bar (four pages and More) and More's sheet (UI release 1 B2) ---------- */
  @media (max-width: 899px) {
    #main-nav { display: none; }
    #bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 44; height: calc(var(--bar-h) + env(safe-area-inset-bottom));
      padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -1px 8px rgba(16, 24, 40, .05); }
    #bottom-nav > a, #nav-more { position: relative; flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
      padding: 0 2px; border: 0; background: none; color: var(--muted); text-decoration: none; font: inherit; font-size: var(--fs-11); font-weight: 600; cursor: pointer; }
    #bottom-nav > a[hidden] { display: none; }
    #bottom-nav .ic { width: 22px; height: 22px; }
    #bottom-nav .nav-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    #bottom-nav .nav-short { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    #bottom-nav > a.active, #nav-more.active, #nav-more[aria-expanded="true"] { color: var(--accent); }
    #bottom-nav .nav-badge { position: absolute; top: 5px; left: calc(50% + 4px); }
    #bottom-nav .att-dot::after { position: absolute; top: 7px; left: calc(50% - 16px); margin: 0; }
    /* Nothing hides under the bar: the page's foot, a sticky save bar, a toast sit above it. */
    main { padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom) + var(--sp-6)); }
    .savebar, .lib-picked { bottom: calc(var(--bar-h) + env(safe-area-inset-bottom)); }
    .toast { bottom: calc(var(--bar-h) + env(safe-area-inset-bottom) + var(--sp-3)); }
    /* More: the rail's pages as a sheet from the bottom, the Lists and Office pages as tiles three across, then You. */
    body.more-open .nav-scrim { display: block; position: fixed; inset: 0; z-index: 45; background: rgba(17, 24, 39, .45); }
    body.more-open #main-nav { display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 46; max-height: 85vh; overflow-y: auto; width: auto;
      border: 0; border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: var(--shadow-sheet); padding-bottom: env(safe-area-inset-bottom); animation: sheet-up .18s ease-out; }
    body.more-open .rail-in { position: static; min-height: 0; max-height: none; overflow: visible; padding: var(--sp-2) var(--sp-4) var(--sp-4); }
    .nav-sheet-head { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-1) 0 var(--sp-2); font-size: var(--fs-17); font-weight: 600; }
    .nav-close { display: grid; place-items: center; width: var(--touch-h); height: var(--touch-h); margin-right: calc(-1 * var(--sp-2)); border: 0; border-radius: var(--r-pill); background: none; color: var(--muted); cursor: pointer; }
    .nav-group { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-2); }
    .nav-group.all-in-bar { display: none; }
    .nav-group .nav-head, .nav-you .nav-head { grid-column: 1 / -1; padding: var(--sp-2) 0 0; }
    #main-nav a { flex-direction: column; justify-content: center; gap: 4px; min-height: 76px; padding: var(--sp-2) var(--sp-1); border: 1px solid var(--line); border-radius: var(--r); text-align: center; }
    #main-nav a.in-bar { display: none; }
    #main-nav a .ic { width: 24px; height: 24px; }
    #main-nav .nav-label { flex: none; white-space: normal; font-size: var(--fs-13); line-height: 1.25; }
    #main-nav .nav-badge, #main-nav .preview-tag { position: absolute; top: 6px; right: 6px; }
    #main-nav a.att-dot::after { position: absolute; top: 8px; left: 8px; margin: 0; }
    .nav-you { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); margin-top: var(--sp-3); }
    .nav-you-btn { min-height: var(--touch-h); border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--card); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; }
    .nav-collapse { display: none; }
  }

  /* ---------- Phone ---------- */
  @media (max-width: 640px) {
    main { padding: 16px 12px calc(var(--bar-h) + env(safe-area-inset-bottom) + var(--sp-6)); }
    /* The top bar: the brand, the search icon (it opens the box the full width of the bar), the name. */
    .topbar { position: relative; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); }
    .gsearch { flex: none; min-width: 0; margin-left: auto; }
    .gs-open { display: grid; }
    .gsearch input { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; border: 0; opacity: 0; pointer-events: none; }
    .gsearch.open { position: absolute; inset: 0 var(--sp-3); z-index: 61; display: flex; align-items: center; margin: 0; background: var(--accent); }
    .gsearch.open .gs-open { display: none; }
    .gsearch.open input { position: static; width: 100%; height: auto; min-height: var(--control-h); padding: 7px 12px; border: 1px solid #fff; opacity: 1; pointer-events: auto; }
    .topbar .user-chip { margin-left: 0; }
    .user-chip .role { display: none; }
    .user-chip { max-width: 45vw; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

    /* Tables that become one card per row. Cells with data-label show their column name. */
    table.cards, table.cards tbody { display: block; width: 100%; }
    table.cards thead tr:not(:first-child) { display: none; }
    table.cards thead tr:first-child { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 10px; background: #f9fafb; border-bottom: 1px solid var(--line-strong); }
    table.cards thead tr:first-child th { display: block; border: 0; padding: 0; background: none; }
    table.cards thead tr:first-child th:empty, table.cards thead th .sub { display: none; }
    table.cards thead tr:first-child th .sort { padding: 5px 9px; border: 1px solid var(--line-strong); border-radius: 999px; background: #fff; font-size: 12.5px; }
    table.cards:not(:has(.sort)) thead { display: none; }
    table.cards tbody tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
    table.cards tbody td { display: block; padding: 0; border: 0; text-align: left; min-width: 0; }
    table.cards tbody td.card-title, table.cards tbody td.empty, table.cards tbody td[colspan] { grid-column: 1 / -1; }
    table.cards tbody td.card-action { grid-column: 1 / -1; text-align: right; }
    table.cards tbody td[data-label]::before {
      content: attr(data-label); display: block; margin-bottom: 2px;
      font-size: 11px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--muted);
    }
    table.cards .chk { display: none; }
    table.cards .narrow-only { display: inline-block; }
    /* Tables fold by priority: in a card, the pri-2 and pri-3 columns come back small, their names inline. */
    table.cards tbody td.pri-2, table.cards tbody td.pri-3 { display: block; font-size: var(--fs-13); color: var(--muted); }
    table.cards tbody td.pri-2[data-label]::before, table.cards tbody td.pri-3[data-label]::before { display: inline; margin: 0 4px 0 0; }
    /* All unscheduled: the cards show carrier and insurance themselves (pri-3), so the tablet's line under the name
       goes; its Sort select replaces the column headings' sort buttons. */
    .unsched-table .narrow-only { display: none; }
    .unsched-table.cards thead { display: none; }
    .fb-sort { display: block; }
    table.cards .dnf-note { max-width: none; white-space: normal; }
    .table-scroll:has(> table.cards) { overflow: visible; }
    table.cards td.card-title > .link, table.cards td.card-title > strong { font-weight: 700; font-size: 16px; }
    /* Saved plans: name first, then date / procedures / portion (the pri-2 / pri-3 cells) in one row; tapping the card
       opens it. Present and ⋯ stay at the card's foot on one line (the cell hides with neither) */
    .plan-table.cards tbody tr { cursor: pointer; grid-template-columns: repeat(3, 1fr); }
    .plan-table.cards td.card-title { order: -1; font-size: 16px; }
    .plan-table.cards td.card-action:not(:has(.plan-present, .plan-send, .plan-resend)) { display: none; }
    .plan-table.cards tbody td.r { text-align: left; }
    /* Shorter rows (to-do list 2026-10-20): a little less padding on each card */
    .patient-page .plan-table.cards tbody tr { padding-top: 8px; padding-bottom: 8px; gap: 4px 14px; }
    .patient-page .plan-table.cards tbody td { padding: 0; }
    .patient-page .plan-table.cards td.card-action { width: auto; }
    .access-users.cards tbody tr { padding-left: 4px; padding-right: 4px; }

    .today-head { flex-wrap: wrap; gap: 6px; }
    .progress-row { flex-wrap: wrap; gap: 4px; }

    /* Windows (patient follow-up, task editor, data tables) fill the screen */
    .modal-backdrop { padding: 0; }
    .modal, .modal.wide, .modal.wide:has(#ad-table) { max-width: none; min-height: 100%; border-radius: 0; }
    .modal-body { padding: 10px; }
    .modal { min-width: 0; }
    .modal-body > *, .pat-top > div { min-width: 0; }
    .note-cell { overflow-wrap: anywhere; min-width: 160px; }
    .modal-head .icon-btn { flex: none; }
    .modal-head { padding: 14px; }
    .pat-top { gap: 10px; }
    .avatar { width: 44px; height: 44px; font-size: 20px; }
    .action-btns .btn { flex: 1 1 calc(50% - 8px); }
    .tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .tab { white-space: nowrap; }
    .form-foot { flex-wrap: wrap; }
    .form-foot .btn { flex: 1; }
    .next-row input { max-width: none; }
    .modal-foot { flex-wrap: wrap; }
    .tk-grid { grid-template-columns: 1fr 1fr; }

    /* GapCheck: a row's coloured edge goes on the card, inside its padding, clear of the appointment's time (UI patch
       P1.8; the cell has no padding here) */
    .xray-table.cards tr.x-due td:first-child, .xray-table.cards tr.x-notcovered td:first-child { box-shadow: none; }
    .xray-table.cards tr.x-due { box-shadow: inset 4px 0 0 #1d9e5b; }
    .xray-table.cards tr.x-notcovered { box-shadow: inset 4px 0 0 #e5484d; }

    /* Settings: no menu under 900 px (styles.css); the page the full width */
    .settings-layout { gap: 12px; }
    /* Settings → Follow-ups → Follow-up statuses: each status's row wraps (its name the full width, then what it does,
       Phone / Text / Email and Remove), so the table never widens the page (UI patch P1.2) */
    .status-table, .status-table tbody { display: block; }
    .status-table tr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
    .status-table td { display: block; padding: 0; min-width: 0; }
    .status-table td:first-child { flex: 1 1 100%; }
    .status-table td:nth-child(2) { flex: 1 1 160px; }
    .status-table td:last-child { width: auto; }
    .status-table .st-types { white-space: normal; }
    .access-matrix { font-size: 13px; }
    .access-matrix td, .access-matrix th { padding: 8px 6px; }

    /* Analytics */
    .chart-legend, .chart-legend .stack-key { flex-wrap: wrap; }

    /* Treatment plan preview: the paper keeps its printed size and scrolls sideways */
    .paper-wrap { margin: 0 -12px; padding: 0 12px; }

    /* ---------- Patient forms ---------- */
    /* The banner's buttons go under its sentence, side by side; the QR code sits above the link (.pair-code) */
    .forms-banner { padding: 10px 12px; }
    .forms-banner .fb-actions { width: 100%; }
    .forms-banner .fb-actions .btn { flex: 1 1 calc(50% - 6px); }
    .forms-share .copy-row input { min-width: 0; }
    .fs-pick { padding-left: 12px; }
    /* A list's buttons go under the row (cards) */
    .fu-list td.card-action { width: auto; white-space: normal; }
    .fu-list .fu-actions { justify-content: flex-start; }
    .fu-list .badge { white-space: normal; }
    /* Settings → Patient email: a letter's preview fills the phone */
    .pe-frame { height: 70vh; }
    /* Stage 5: This visit's buttons side by side under its consents; Consents needed today's card puts the patient
       first and the consents the full width; the Today / Tomorrow switch goes under the heading */
    .forms-card .fc-visit { padding: 10px; }
    .forms-card .fc-visit-acts .btn { flex: 1 1 calc(50% - 6px); }
    .fu-consents tbody td.card-title { order: -1; }
    .fu-consents tbody td[data-label="Consents"], .fu-consents tbody td[data-label="Procedures"] { grid-column: 1 / -1; }
    .fu-list .fu-day { width: 100%; }
    /* Settings → Procedure forms: the table scrolls sideways inside its card, the page doesn't */
    .procedure-forms .pr-card { padding: 2px 10px; }
    .pr-table-acts .btn { flex: 1 1 auto; }
    /* Present mode (public/present.mjs): a little less room around it, and the staff drawer the full width */
    .pm { padding: 16px 12px 96px; }
    .pm .pm-procs th, .pm .pm-procs td { padding: 8px 6px; font-size: .9em; }
    .pm .pm-tooth { width: 4em; }
    .pm .pm-totals td { padding: 6px 4px; }
    .pm-drawer, .pm .pm-drawer { width: 100vw; }
    .pm .pm-sign { padding: 14px 12px; }
    .pm .pm-sign input:not([type=checkbox]):not([type=radio]), .pm .pm-sign select { width: 100%; max-width: none; }
    .pm #pm-sign { justify-self: stretch; }
    /* Stage 2: the Tooth heading on one line; a procedure's patient name over Open Dental's description; the pictures
       one at a time the full width with ‹ › under them (two too), a little shorter; the explanation a little tighter;
       Add a picture's thumbnails two across */
    .pm th.pm-tooth { white-space: nowrap; }
    .pm .pm-name, .pm .pm-desc { display: block; }
    .pm .pm-pic, .pm .pm-pics-one .pm-pic { flex-basis: 100%; }
    .pm .pm-pic img { max-height: 50vh; }
    .pm .pm-pics-two .pm-pics-nav { display: flex; }
    .pm .pm-explain td { padding: 8px 6px 12px; }
    .pk-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    /* The plan page after a presentation: the banner and the Outcome panel the full width, their buttons wrapping */
    #plan-status { margin-bottom: 10px; }
    .override-banner, .outcome-panel { width: 100%; box-sizing: border-box; overflow-wrap: anywhere; }
    .override-banner { padding: 10px 12px; }
    .override-banner .btn { flex: 1 1 auto; }
    .outcome-panel { padding: 14px 12px; }
    .outcome-panel .oc-radios { flex-direction: column; align-items: stretch; }
    .outcome-panel .oc-radio { border-radius: 8px; }
    .outcome-panel .oc-note input { max-width: none; }
    .oc-acts .btn { flex: 1 1 calc(50% - 8px); }
    /* Stage 3: the changed banner the full width; Send, Resend and Copy link wrap; the Send dialog's buttons share the
       row; the link's box and copy button stack; a plan in the follow-up window puts Resend under its line */
    .changed-banner { width: 100%; box-sizing: border-box; padding: 10px 12px; }
    .changed-banner .btn { flex: 1 1 auto; }
    .plan-status-line .plan-send-acts { flex: 1 1 100%; }
    .plan-send-dialog { max-height: none; }
    .modal-foot:has(#ps-send) { flex-wrap: wrap; }
    .modal-foot:has(#ps-send) .spacer { display: none; }
    .modal-foot:has(#ps-send) .btn { flex: 1 1 calc(50% - 8px); }
    .plan-link .pl-copy { flex-wrap: wrap; }
    .plan-link .pl-copy .btn { flex: 1 1 100%; }
    .fu-plan { flex-wrap: wrap; }
    .fu-plan .btn { flex: 1 1 100%; }
    /* Saved plans' cards: the status under the name, before date / procedures / portion */
    .plan-table.cards td.plan-status-cell { order: -1; grid-column: 1 / -1; }
    .plan-table.cards td.plan-status-cell::before { display: none; }
    .plan-table.cards td.plan-status-cell:empty { display: none; }
    /* Stage 4: the filing lines under the plan page's status line wrap rather than widen the page; Retry (the plan
       page's and the card's) takes a line of its own; the plans banner wraps its links */
    .plan-filing-line { width: 100%; box-sizing: border-box; overflow-wrap: anywhere; }
    .plan-status-line .plan-file-retry, .plan-filing-retry .plan-file-retry { flex: 1 1 100%; width: 100%; }
    .plan-filing-retry { margin-top: 6px; }
    #plans-alert { flex-wrap: wrap; overflow-wrap: anywhere; padding: 8px 12px; }
    /* Stage 4: Present mode's due-today rows (Existing balance, Amount due today) wrap their words inside the totals */
    .pm .pm-totals tr.pm-due td:first-child { overflow-wrap: anywhere; }
    /* Stage 5: the follow-up window's Plan block puts its buttons (Present again, Resend plan, Send) under the plan's
       lines, each the full width; the Unscheduled Tx list's Plan cell fits its card (the date wraps under the badge);
       the attempt form's plan choice and the "Presented since" chip stay inside the page */
    .fu-plan-actions { flex: 1 1 100%; }
    .fu-plan-actions .btn { flex: 1 1 100%; }
    .unsched-table td.plan-col { white-space: normal; overflow-wrap: anywhere; }
    .attempt-form .af-plan select { width: 100%; }
    /* Stage 5: the Schedule's huddle badge in a shrunk block's details and the day's total wrap inside the page */
    .modal .sched-meta .plan-tag { display: inline-block; max-width: 100%; box-sizing: border-box; overflow: hidden; text-overflow: ellipsis; }
    .sched-plans { overflow-wrap: anywhere; }
    /* Stage 5: Analytics' plan tables scroll sideways inside their card, never the page; Today's "Treatment plans this
       week" puts its four numbers in two columns */
    .plan-table:not(.cards) { overflow-x: auto; max-width: 100%; }
    .plans-week .pw-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .plans-week .pw-num strong { font-size: 18px; }
  }

  /* ---------- Touch screens (iPad, phone) ---------- */
  @media (pointer: coarse) {
    /* 16px text keeps iOS Safari from zooming in when a field is tapped */
    input, select, textarea { font-size: var(--fs-input); }
    .plan-dd { padding: 7px 8px; }
    .task-check input { width: 26px; height: 26px; }
    .check input[type=checkbox] { width: 20px; height: 20px; }
    .link { padding: 4px 0; }
    .tab { padding: 11px 14px; }
    /* Patient forms: Send forms' choices are easy to tap */
    .fs-choices .check { padding: 8px 0; }
    .fs-choices .check input { width: 20px; height: 20px; }
  }
}

/* ---------- Send forms on a phone (public/forms.mjs): the four ways two by two, the boxes the full width ---------- */
@media screen and (max-width: 640px) {
  .fs-way-row .btn { flex: 1 1 calc(50% - 8px); }
  .fs-out .copy-row { flex-direction: column; align-items: stretch; }
}

/* ---------- Settings → Patient email (public/forms-email-settings.mjs): the timeline's step tabs stack above the
   chosen step's settings, both the full width ---------- */
@media screen and (max-width: 900px) {
  .email-settings .pe-steps { grid-template-columns: minmax(0, 1fr); }
}
@media screen and (max-width: 640px) {
  .email-settings .pe-panel { padding: 2px 12px 6px; }
}

/* ---------- The form editor (public/forms-editor.mjs): under 1100px one pane at a time, chosen by the tabs (Outline /
   Edit / Preview); on a phone the English and Spanish boxes stack ---------- */
@media screen and (max-width: 1100px) {
  .fe-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); }
  .fe-panes { grid-template-columns: minmax(0, 1fr); }
  .fe-page[data-pane="outline"] .fe-pane:not(.fe-pane-outline),
  .fe-page[data-pane="edit"] .fe-pane:not(.fe-pane-edit),
  .fe-page[data-pane="preview"] .fe-pane:not(.fe-pane-preview) { display: none; }
  .fe-pane-outline, .fe-pane-preview { position: static; max-height: none; }
  .fe-o-tools { display: inline-flex; }
}
@media screen and (max-width: 640px) {
  .fe-top { position: static; }
  .fe-pair { grid-template-columns: minmax(0, 1fr); }
  .fe-blank-list li { grid-template-columns: minmax(0, 1fr); }
  .fe-row { grid-template-columns: minmax(0, 1fr); }
  .fe-ctl { justify-content: flex-start; }
  .fe-pv-frame.phone { width: 100%; max-width: 390px; }
  .fe-sbs-cols { grid-template-columns: minmax(0, 1fr); }
  .fe-sbs-new { border-top: 1px dotted var(--line); padding-top: 2px; }
  .fe-sbs-head { position: static; }
  .fe-sbs-mine::before, .fe-sbs-new::before { display: block; font-size: 11px; font-weight: 600; color: var(--muted); }
  .fe-sbs-mine::before { content: 'Yours'; }
  .fe-sbs-new::before { content: 'New starter'; }
  .pf-forms-table .pf-acts { white-space: normal; }
}

/* The letter editor (public/forms-letter-editor.mjs): the same tabs as the form editor under 1100px; on a phone the
   Show panel's choices go under each flag's name */
@media screen and (max-width: 1100px) {
  .fe-page[data-mode="letter"] .fe-panes { grid-template-columns: minmax(0, 1fr); }
  .lt-o-slot .fe-o-tools { display: inline-flex; }
  .lt-frame { height: 75vh; }
}
@media screen and (max-width: 640px) {
  .lt-flag { flex-direction: column; align-items: flex-start; }
  .lt-test .copy-row { flex-direction: column; align-items: stretch; }
}

/* The text editor (public/forms-text-editor.mjs): under 1100px the text or the preview, chosen by the tabs (Edit /
   Preview); on a phone the formatting bar scrolls with the page and the typing box is shorter */
@media screen and (max-width: 1100px) {
  .fe-page[data-mode="text"] .fe-panes { grid-template-columns: minmax(0, 1fr); }
  .tx-toolbar { top: 0; }
}
@media screen and (max-width: 640px) {
  .fe-page[data-mode="text"] .fe-pane-edit { padding: 6px 10px 12px; }
  .tx-toolbar { position: static; }
  .tx-doc { min-height: 220px; padding: 10px 12px; }
  .tx-pop { position: fixed; left: 16px; right: 16px; top: auto; }
  .pf-forms-table tr.pf-pol td:first-child { padding-left: 6px; }
}

/* ---------- Compliance (public/compliance.mjs and public/compliance-*.mjs) on a phone: the menu scrolls across the
   top, the log form and My items go to one column with full-width buttons, and the People grid scrolls sideways in its
   own box while the page itself never does ---------- */
@media screen and (max-width: 640px) {
  .comp-page { overflow-x: hidden; }
  .comp-page .comp-main, .comp-main > .panel { min-width: 0; max-width: 100%; }
  .comp-main > .panel { padding: 12px; }
  .comp-log-form [role="group"] { flex-direction: column; }
  .comp-log-form [data-result] { width: 100%; min-height: 72px; }
  .comp-log-form input, .comp-log-form textarea, .comp-log-form select { width: 100%; }
  .comp-log-form label.btn { display: block !important; width: 100%; text-align: center; }
  .comp-logged-acts { flex-direction: column; }
  .comp-logged-acts .btn { width: 100%; text-align: center; }
  .comp-mine .cp-actions .btn, .comp-mine .cp-status .btn { width: 100%; }
  .comp-grid-wrap { margin: 0 -4px; max-width: calc(100vw - 24px); }
  table.comp-grid .comp-grid-name { min-width: 120px; max-width: 150px; }
  table.comp-grid thead th { min-width: 84px; }
  .comp-coming td.card-action .btn { width: 100%; text-align: center; }
  .comp-settings select, .comp-settings input[type=number], .comp-warn-grid input { max-width: none; width: 100%; }
  .comp-settings-acts .btn { width: 100%; }
  /* Beta 2: the kit's monthly check and the drill form in one column. */
  .comp-walk-row { grid-template-columns: 1fr; }
  .comp-walk-choices { display: grid; grid-template-columns: 1fr 1fr; }
  .comp-walk-choices [data-choice] { width: 100%; min-height: 56px; }
  .comp-walk-qty input { max-width: none; width: 100%; }
  .comp-kit-table td.card-action { white-space: normal; }
  .comp-kit-table td.card-action .btn { width: 100%; margin: 4px 0; text-align: center; }
  .comp-drill-form .tk-grid { grid-template-columns: 1fr; }
  .comp-drill-form input:not([type=checkbox]), .comp-drill-form textarea, .comp-drill-form select, .comp-drill-form .btn { width: 100%; }
  .comp-drill-people { flex-direction: column; }
  /* Beta 3: the trainings, their people and the settings' new rows in one column, full-width buttons. */
  .comp-train-line, .comp-train-people li, .comp-progress li { flex-direction: column; align-items: stretch; }
  .comp-train-people li .btn, .comp-train-line .btn { width: 100%; margin-left: 0; text-align: center; }
  .comp-inline { display: grid; grid-template-columns: 1fr; width: 100%; }
  .comp-inline select, .comp-train-due input[type=number] { width: 100%; max-width: none; }
  .lib-row.lib-must-read .lib-acts .btn[data-lib="read-ack"] { width: 100%; }
  /* Beta 3: the inspection binder's dates and Build binder in one column. */
  .comp-binder-range { flex-direction: column; align-items: stretch; }
  .comp-binder-range input[type=date], .comp-binder-acts .btn { width: 100%; min-width: 0; }
}

@keyframes sheet-up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { body.more-open #main-nav { animation: none; } }

/* Settings → People has nine columns and each row's ⋯ menu must not be clipped, so a scroll box won't do: under 1300 px
   the same cards phones get (table.cards above), as many fields across as fit. */
@media screen and (max-width: 1299px) {
  table.access-users.cards, table.access-users.cards tbody { display: block; width: 100%; }
  table.access-users.cards thead { display: none; }
  table.access-users.cards tbody tr { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px 14px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
  table.access-users.cards tbody td { display: block; padding: 0; border: 0; text-align: left; min-width: 0; }
  table.access-users.cards tbody td.card-title, table.access-users.cards tbody td[colspan] { grid-column: 1 / -1; }
  table.access-users.cards tbody td.card-action { grid-column: 1 / -1; text-align: right; }
  table.access-users.cards tbody td[data-label]::before {
    content: attr(data-label); display: block; margin-bottom: 2px;
    font-size: 11px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--muted);
  }
}
