/* Paying and collecting coming apart on a repair (#2009): the warning's
   buttons, the marker a job keeps, and the two counts over the list. */

/* A warning with buttons of its own (Modal.choose). The safe one is first;
   they wrap on a phone rather than run off the box, and each is a full
   finger high. */
.modal-choices { flex-wrap: wrap; justify-content: flex-start; }
.modal-choices .btn { min-height: 44px; flex: 1 1 auto; }

/* UNPAID on a collected job that owes; PAID · NOT COLLECTED on a paid job
   still in the shop. */
/* No nowrap: in the list's narrow Shopify column the marker wraps (#2139,
   components.css) rather than run under the buttons beside it. */
.ri-mismatch { font-weight: 700; letter-spacing: 0.02em; }

/* How many jobs carry each marker. A button: pressing it shows only those. */
.repair-mismatch-count {
    border: 0; cursor: pointer; margin-left: 0.35rem;
    font-family: inherit; font-weight: 700; white-space: nowrap;
}
.repair-mismatch-count.is-on { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (max-width: 767px) {
    .repair-mismatch-count { min-height: 36px; padding: 0.4rem 0.8rem; font-size: 0.8rem; }
}

/* Take payment, opened from a warning: the job's own three pay buttons. */
.pay-sheet { display: flex; margin-top: 0.75rem; min-width: 0; }
/* On a phone the three must share the box (#2049). A grid column of 1fr
   won't go narrower than its words, and "SPLIT CASH + CARD" on one line is
   159px, so the third tile ran 19px off a 375px screen. Here the columns
   may shrink and the label may wrap. */
.pay-sheet .rp-pay-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); min-width: 0; }
.pay-sheet .rp-pay-tile { min-width: 0; white-space: normal; overflow-wrap: anywhere; }
/* With Gift card (#3555) there are four: two by two, so none is squeezed. */
.pay-sheet .rp-pay-tiles:has(> .rp-pay-gift) { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* ── Paid and Collected on each job card (#2009) ──────────────────────────────
   Two shortcuts beside Parts and Edit, in the pay buttons' outline look
   (#2007): a transparent button, a 2px line and the label in capitals. Paid
   is the cash green (tokens.css --pay-cash-*); Collected is a plain slate
   line, so it isn't read as Paid card's blue. */
.ri-shortcuts { display: inline-flex; gap: 4px; align-items: center; order: 1; }
.ri-paid, .ri-collected {
    --pay-line: var(--text-muted);
    --pay-text: var(--text-strong);
    background: transparent; border: 2px solid var(--pay-line); color: var(--pay-text);
    font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; white-space: nowrap;
}
.ri-paid { --pay-line: var(--pay-cash-line); --pay-text: var(--pay-cash-text); }
.ri-paid:hover:not(:disabled), .ri-collected:hover:not(:disabled) {
    background: color-mix(in srgb, var(--pay-line) 16%, transparent);
}

/* "#127 marked Collected" with Undo: a full finger high, under the words. */
.toast-action { display: block; margin-top: 0.4rem; min-height: 44px; padding: 0 1rem; font-weight: 700; }

/* The list (wider than a phone): the last column grows to hold the two
   buttons beside the pin. These are the board's own column lists from
   components.css with only that last figure changed;
   tests/test_card_shortcuts_2009.py fails if the two drift apart. */
@media (min-width: 769px) {
    .repairs-list-header,
    .repair-item {
        grid-template-columns: 48px 56px minmax(140px, 1.4fr) minmax(180px, 2fr) 130px 90px 130px 120px 90px 104px 184px;
    }
    /* Where the columns don't fit and the list scrolls sideways (a tablet,
       or a laptop with the sidebar open), the buttons stay in view at the
       right edge instead of scrolling off with the last column. */
    .repair-item .ri-actions {
        position: sticky; right: 0; z-index: 1;
        /* The page's colour: the list has no box of its own (components.css). */
        background: var(--bg);
        box-shadow: -8px 0 8px -8px rgba(0, 0, 0, 0.18);
        align-self: stretch; padding: 0 6px 0 4px;
    }
    .repair-item.overdue .ri-actions {
        background: linear-gradient(rgba(198, 40, 40, 0.05), rgba(198, 40, 40, 0.05)), var(--bg);
    }
    .ri-actions .ri-shortcuts .btn { padding: 2px 7px; font-size: 0.78rem; min-height: 30px; justify-content: center; }
    /* The two labels side by side are wider than this column (#2050),
       and a wider one would push the full-width list past its box on a
       1680px screen. So here the two sit one over the other... */
    .ri-shortcuts { flex-direction: column; align-items: stretch; gap: 3px; }
    /* 1408px: the least the stacked list above needs (see components.css,
       which switches its tight grid at the same figure). At 1380 a list
       between the two scrolled sideways, on a 1710px screen (#2056). */
    @container (max-width: 1408px) {
        /* ...and side by side in the narrower list, which has the room. */
        .repairs-list-header,
        .repair-item {
            grid-template-columns: 34px 44px minmax(90px, 1.1fr) minmax(120px, 1.6fr) 92px 68px 94px 82px 70px 78px 262px;
        }
        /* A four-figure amount ("PAY €1234.50") beside the Collected button
           ran 15px past this column (#2056). A wider column would push the list
           sideways on a 1440px screen, so the two buttons give up padding
           and letter spacing instead; their height is untouched. Anything
           longer still wraps under rather than running out of the cell. */
        .ri-shortcuts { flex-direction: row; align-items: center; gap: 4px; flex-wrap: wrap; min-width: 0; }
        .ri-actions .ri-shortcuts .btn { padding: 2px 4px; font-size: 0.75rem; letter-spacing: 0; }
    }
    /* A list under 640px (an iPad held upright: about 500px beside the
       sidebar, #2296) scrolls sideways whatever it does, and the 262px
       column stuck to its right edge took half of what showed, over the job.
       Here the buttons stack in a column about a quarter of the list wide
       and Pin, Edit and Parts wrap under them. Written as min-width 0 and
       max-width so the width figure above stays the only plain
       "(max-width: Npx)" query in this file
       (tests/test_repairs_list_wide_desktop_2056.py counts them). */
    @container (min-width: 0px) and (max-width: 640px) {
        .repairs-list-header,
        .repair-item {
            grid-template-columns: 34px 44px minmax(90px, 1.1fr) minmax(120px, 1.6fr) 92px 68px 94px 82px 70px 78px 152px;
        }
        .repair-item .ri-actions { flex-wrap: wrap; }
        .ri-shortcuts { flex-direction: column; align-items: stretch; flex: 1 1 100%; }
    }
}
/* A list narrower than its columns scrolled sideways, past the stuck buttons
   (#3971). Measured 12 Nov 2026: the eleven columns need 1001-1111px, and the
   list is 512px on an upright iPad (820), 716px on a landscape one (1024) and
   872px at 1180. So the columns that only repeat what the job panel shows drop
   out as the list narrows, most dispensable first: In, Shopify and Priority
   (below 1120px, what all eleven need), then the photo and Description, then
   Cost. Customer / Bike, Status, Due and the buttons always stay. The overdue
   red edge still marks a late job; the panel (a tap on the row) shows
   everything. Header cells are matched by position, as index.html has no
   classes on them. Written with a min-width 0 so the width figure in
   components.css stays the only plain "(max-width: Npx)" query counted by
   tests/test_repairs_list_wide_desktop_2056.py. */
@media (min-width: 769px) {
    @container (min-width: 0px) and (max-width: 1120px) {
        .repairs-list-header > :nth-child(6), .repairs-list-header > :nth-child(8), .repairs-list-header > :nth-child(10),
        .repair-item > .ri-priority, .repair-item > .ri-in, .repair-item > .ri-shopify { display: none; }
        .repairs-list-header,
        .repair-item {
            grid-template-columns: 34px 44px minmax(90px, 1.1fr) minmax(100px, 1.6fr) 92px 94px 70px 262px;
        }
    }
    @container (min-width: 0px) and (max-width: 900px) {
        .repairs-list-header > :nth-child(1), .repairs-list-header > :nth-child(4),
        .repair-item > .ri-media, .repair-item > .ri-desc { display: none; }
        .repairs-list-header,
        .repair-item {
            grid-template-columns: 44px minmax(90px, 1fr) 92px 94px 70px 262px;
        }
    }
    /* Cost stays only while the list is wider than the 695px the six columns
       need; 700 leaves a hair of room (was 640, which scrolled 21-41px sideways
       at 800-820 beside the icon rail, #3979). */
    @container (min-width: 0px) and (max-width: 700px) {
        .repairs-list-header > :nth-child(9), .repair-item > .ri-cost { display: none; }
        .repairs-list-header,
        .repair-item {
            grid-template-columns: 44px minmax(80px, 1fr) 92px 94px 262px;
        }
    }
    @container (min-width: 0px) and (max-width: 640px) {
        .repairs-list-header,
        .repair-item {
            grid-template-columns: 44px minmax(80px, 1fr) 92px 94px 152px;
        }
    }
    /* The five columns above need 499px with their padding; the list is 461px
       at 769 with the sidebar open and 492px at 800 (#3984). Under 520 they
       give up a little width each (412px of columns, 449 with padding), so
       the Collected button stays in the list rather than past its right edge. */
    @container (min-width: 0px) and (max-width: 520px) {
        .repairs-list-header,
        .repair-item {
            grid-template-columns: 40px minmax(56px, 1fr) 82px 82px 152px;
        }
    }
}
/* Touch screens up to a laptop's width: a full finger high. */
@media (min-width: 769px) and (max-width: 1366px) {
    .ri-actions .ri-shortcuts .btn { min-height: 44px; }
}

/* Phone card: the shortcuts lead the buttons row, each as wide as the other.
   On a narrow phone they take a row of their own above Parts and Edit. */
@media (max-width: 768px) {
    .ri-shortcuts { order: 0; flex: 2 1 0; gap: var(--sp-2); }
    .ri-shortcuts .btn { flex: 1 1 0; justify-content: center; }
    .ri-actions { flex-wrap: wrap; }
    /* The Status dropdown as a compact chip (#2009): as wide as its words,
       not the whole row. Tapping it opens the list as before. */
    .ri-status-select.ri-status-chip {
        flex: 0 1 auto; width: auto; max-width: 100%;
        border-radius: 999px; padding: 0 var(--sp-3);
        font-size: 0.88rem;
    }
}
@media (max-width: 480px) {
    .ri-shortcuts { flex: 1 1 100%; }
}

/* The Payment filter's longest choice ("Draft order or order raised
   (unpaid)") is wider than a phone. A flex item won't shrink below its
   content unless told it may, so the box pushed the whole Repairs page
   426px wide on a 375px phone, measured while fitting the buttons above. */
.repair-filter-field { min-width: 0; }

/* ── The job panel's footer on a phone (#2052) ────────────────────────────────
   Three tall pay tiles and a second row took about a quarter of a phone
   screen, over the list being worked on. On a narrow screen the footer is
   one slim row: a single pay button (the card's, opening the Take payment
   box), the draft order or order link, ↻ and the status badge. It wraps to a
   second slim line only when a job has more to say (out of date, voided,
   a marker). Wider than a phone the tiles stay: there is room, and one press
   fewer at the counter. */
.rp-pay-slim { display: none; }
/* The tiles may shrink and their labels wrap wherever they are drawn, so
   "SPLIT CASH + CARD" is never cut off in a narrow panel. */
.rp-pay-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rp-pay-tiles .rp-pay-tile { min-width: 0; white-space: normal; overflow-wrap: anywhere; }
@media (max-width: 767px) {
    .repair-panel-footer .rp-pay-tiles { display: none; }
    .repair-panel-footer .rp-pay-slim { display: inline-flex; order: -1; }
    .repair-panel-footer {
        padding-top: 0.5rem; padding-left: 0.75rem; padding-right: 0.75rem;
        gap: 0.3rem 0.4rem;
    }
    /* Ready for Collection shares its line with the pay button rather than
       taking a whole one to itself. With no pay button (a job not yet
       priced) the refresh (↻) takes that place, rather than a row of its
       own under Draft order (Neil, 8 Nov 2026); with one, the ↻ shares
       Draft order's line with the payment badge as before (#3227). */
    .repair-panel-footer .btn-primary { flex: 1 1 auto; order: -3; }
    .repair-panel-footer:not(:has(.rp-pay-slim)) .btn-ghost { order: -2; }
    /* Every control a full finger high, none stretched taller. */
    .repair-panel-footer .btn {
        min-height: 44px; padding-top: 0; padding-bottom: 0;
        align-items: center; white-space: nowrap; font-size: 0.9rem;
    }
    .repair-panel-footer .btn-ghost { min-width: 44px; justify-content: center; }
    /* Badges and the "this order was voided" line keep their place, in the
       same slim line height, and may wrap rather than run off the edge. */
    .repair-panel-footer .badge,
    .repair-panel-footer > span { white-space: normal !important; overflow-wrap: anywhere; max-width: 100%; }
    /* The payment badge shares the order link's line and wraps its words
       inside the space left, rather than dropping to a third row (#3228). */
    .repair-panel-footer .rp-pay-badge { flex: 1 1 6.5rem; min-width: 0; text-align: center; }

    /* Compact bar (#3862): Total, its labour count and the figure share one
       line; the "pay in the app" notice is a short, small line. Rows of
       buttons stay a finger high (44px), everything else gives its room back. */
    .repair-panel-footer { padding-top: 0.35rem; padding-bottom: max(0.4rem, env(safe-area-inset-bottom)); gap: 0.25rem 0.4rem; }
    /* The Total once (#3874): the last line of the jobs and parts list, not
       the pinned footer, which holds the Pay button and no figure of its own. */
    .repair-panel-footer .rp-job-totalbar { display: none; }
    .rp-list-total {
        display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 0.5rem;
        margin-top: 0.4rem; padding-top: 0.5rem; border-top: 1px solid var(--border);
    }
    .rp-jobbar-amount { order: 2; font-size: 1.1rem; }
    .rp-jobbar-hint { flex: 0 1 auto; margin-right: auto; font-size: 0.75rem; min-width: 0; }
    .repair-panel-footer .rp-pay-in-app { padding: 0 0.4rem; font-size: 0.72rem; line-height: 1.3; }
    .rp-hide-phone { display: none; }
}
@media (min-width: 768px) { .rp-phone-only { display: none; } }
