/* Shared styles for every page of the system.
   The values come from tokens.css; the newer components are in components.css. */

@import url("/css/tokens.css");
@import url("/css/components.css");

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: var(--text-md);
    line-height: 1.45;
    background: var(--page);
    color: var(--text);
}

[hidden] {
    display: none !important;
}

/* Header */

.header {
    background: var(--ink);
    color: var(--on-dark);
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.header h2 {
    margin: 0;
    font-size: var(--text-lg);
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.header-user {
    font-size: 14px;
    opacity: 0.9;
}

/* Layout */

.container {
    padding: var(--space-5);
    max-width: 1320px;
    margin: 0 auto;
}

.panel {
    background: var(--surface);
    padding: var(--space-4);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: var(--space-4);
}

.panel h1,
.panel h3 {
    margin-top: 0;
}

.panel.narrow {
    max-width: 460px;
}

.muted {
    color: var(--muted);
}

/* Buttons */

button,
.button {
    background: var(--ink);
    color: white;
    border: none;
    min-height: var(--control-height);
    padding: 0 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    font-size: var(--text-md);
}

button:focus-visible,
.button:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.button-primary {
    background: var(--brand);
}

.button-primary:hover {
    background: var(--brand-dark);
}

.button-block {
    width: 100%;
    min-height: 44px;
    font-size: var(--text-lg);
    margin-top: var(--space-4);
}

/* Forms */

label {
    display: block;
    margin: 10px 0 4px;
    font-weight: bold;
    font-size: var(--text-sm);
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="tel"],
input[type="search"],
select,
textarea {
    width: 100%;
    min-height: var(--control-height);
    padding: 6px 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: var(--text-md);
    font-family: inherit;
    background: white;
    color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: var(--focus-ring);
}

.form-actions {
    margin-top: 16px;
}

.message {
    margin-top: 12px;
    min-height: 20px;
    font-size: 14px;
}

.message.error {
    color: var(--danger);
}

.message.success {
    color: var(--success);
}

.notice {
    background: var(--warning-bg);
    color: var(--warning-text);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-4);
}

/* Tables */

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

th,
td {
    padding: var(--cell-padding);
    border-bottom: 1px solid var(--border);
    text-align: center;
}

th {
    background: var(--surface-alt);
    white-space: nowrap;
    font-size: var(--text-sm);
}

/* Every table, as the day's movement (the owner's choice): a frame, and
   thick lines between every two columns and every two rows (the owner asked) */
table {
    border: 2px solid #9c9288;
}

th,
td {
    border-inline-start: 2px solid #b3a99f;
    border-bottom: 2px solid #cfc6bc;
}

th:first-child,
td:first-child {
    border-inline-start: none;
}

tbody tr:hover td {
    background: #fcfaf7;
}

td.start,
th.start {
    text-align: start;
}

tr.group-row td {
    background: #f1e7dc;
    font-weight: bold;
    text-align: start;
}

.key {
    color: var(--muted);
    font-size: 12px;
    direction: ltr;
    display: inline-block;
}

/* Dashboard cards */

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
}

.card {
    background: var(--surface);
    padding: var(--space-5);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
}

.card h3 {
    margin-top: 0;
}

.card[data-href] {
    cursor: pointer;
}

.card[data-href]:hover {
    outline: 2px solid var(--brand);
}

.card.soon {
    opacity: 0.6;
}

.card small {
    color: var(--muted);
}

/* Tabs */

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.tab {
    background: #e9dfd4;
    color: var(--text);
}

.tab.active {
    background: var(--brand);
    color: white;
}

/* Small labels */

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    background: #e9dfd4;
}

.badge.yes {
    background: #dcfce7;
    color: var(--success);
}

.badge.no {
    background: #fee2e2;
    color: var(--danger);
}

.big-number {
    font-size: 34px;
    font-weight: bold;
    direction: ltr;
    display: inline-block;
}

.total {
    margin-top: 20px;
    font-size: 22px;
    font-weight: bold;
}

input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* Login page */

body.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a, #1e293b);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 430px;
    background: #ffffff;
    border-radius: 22px;
    padding: 40px 32px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.25);
}

.login-card h1 {
    margin: 0;
    text-align: center;
    color: #0f172a;
    font-size: 28px;
}

.login-card .logo {
    width: 75px;
    height: 75px;
    margin: 0 auto 20px;
    border-radius: 20px;
    background: #2563eb;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    font-weight: bold;
}

.login-card .subtitle {
    text-align: center;
    color: #64748b;
    margin: 10px 0 30px;
    font-size: 15px;
}

.login-card label {
    color: #334155;
}

.login-card input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.login-card .login-button {
    width: 100%;
    margin-top: 20px;
    padding: 15px;
    background: #2563eb;
    font-size: 17px;
    font-weight: bold;
}

.login-card .login-button:hover {
    background: #1d4ed8;
}

.login-card .message {
    text-align: center;
    color: var(--danger);
}

.login-card .footer {
    text-align: center;
    color: #94a3b8;
    margin-top: 25px;
    font-size: 13px;
}

/* Toolbars above lists */

.toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.toolbar input[type="text"],
.toolbar input[type="date"],
.toolbar input[type="search"],
.toolbar select {
    width: auto;
    min-width: 170px;
    flex: 1;
}

.toolbar label {
    margin: 0;
    font-weight: normal;
    display: flex;
    align-items: center;
    gap: 6px;
}

.pager {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
    margin-top: 14px;
}

.button-small {
    min-height: 28px;
    padding: 0 10px;
    font-size: var(--text-sm);
}

.actions {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
}

.number {
    direction: ltr;
    display: inline-block;
}

tr.inactive td {
    color: var(--muted);
}

/* Dialogs */

dialog {
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow-raised);
    padding: var(--space-5);
    width: min(720px, 94vw);
    max-height: 92vh;
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.45);
}

dialog h3 {
    margin-top: 0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 4px 16px;
}

.form-grid .wide {
    grid-column: 1 / -1;
}

.check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: normal;
    margin-top: 18px;
}

.dialog-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
}

.link {
    color: var(--brand-dark);
    cursor: pointer;
    text-decoration: underline;
    background: none;
    padding: 0;
    min-height: 0;
    font-size: inherit;
}

/* Printable invoice */

body.print-page {
    background: white;
}

.print-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 14px 20px;
    background: var(--page);
}

.invoice-sheet {
    max-width: 800px;
    margin: 0 auto;
    padding: 24px;
}

/* Letterhead of invoices and printed reports: the logo beside the shop's details */

.letterhead {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 14px;
}

/* The logo file is square with a wide empty margin. The box shows its middle
   at the logo's own proportions: nothing is stretched, only margin is hidden. */
.letterhead-logo {
    flex: none;
    width: 190px;
    aspect-ratio: 20 / 13;
    object-fit: cover;
    border-radius: 8px;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
}

.letterhead-text h1,
.letterhead-text p {
    margin: 0 0 4px;
}

.letterhead-name {
    font-size: 26px;
}

.invoice-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    border-top: 2px solid var(--text);
    border-bottom: 1px solid var(--text);
    padding: 10px 0 6px;
    margin-bottom: 16px;
}

.invoice-head h1,
.invoice-head h2,
.invoice-head p {
    margin: 0 0 6px;
}

.invoice-totals {
    width: auto;
    min-width: 280px;
    margin-inline-start: auto;
}

.invoice-foot {
    text-align: center;
    margin-top: 30px;
}

.signatures {
    display: flex;
    justify-content: space-around;
    gap: 30px;
    margin-top: 50px;
}

.signature {
    flex: 1;
    max-width: 240px;
    border-top: 1px solid var(--text);
    padding-top: 6px;
    text-align: center;
}

/* Barcode labels */

.label-note {
    padding: 0 20px;
}

.labels {
    display: flex;
    flex-wrap: wrap;
    gap: 2mm;
    padding: 4mm;
}

.label {
    width: 50mm;
    height: 30mm;
    border: 1px dashed var(--border, #ccc);
    padding: 1.5mm;
    text-align: center;
    overflow: hidden;
    break-inside: avoid;
    font-size: 9px;
    line-height: 1.2;
}

.label-name {
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.label .barcode {
    width: 100%;
    height: 12mm;
    display: block;
}

.label-code {
    direction: ltr;
    letter-spacing: 1px;
}

.label-price {
    font-weight: bold;
    font-size: 11px;
    direction: ltr;
}

/* Paper size, chosen in the settings. A4 is the default page of the browser;
   the thermal roll is a named page 80 mm wide and as long as the document. */
/* Every A4 page says which page it is: "صفحة 1 من 2" */
@page {
    @bottom-center {
        content: "صفحة " counter(page) " من " counter(pages);
        font-size: 9pt;
    }
}

@page thermal {
    size: 80mm auto;
    margin: 3mm;

    @bottom-center {
        content: none;
    }
}

/* Reports have many columns */
@page report {
    size: A4 landscape;
    margin: 10mm;
}

body.paper-thermal .invoice-sheet {
    max-width: 74mm;
    padding: 8px;
    font-size: 12px;
}

body.paper-thermal .letterhead {
    flex-direction: column;
    text-align: center;
    gap: 6px;
}

body.paper-thermal .letterhead-logo {
    width: 44mm;
}

body.paper-thermal .letterhead-name {
    font-size: 16px;
}

body.paper-thermal .invoice-head {
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
}

body.paper-thermal .invoice-head h2 {
    font-size: 15px;
    text-align: center;
}

body.paper-thermal table th,
body.paper-thermal table td {
    padding: 3px 2px;
    font-size: 11px;
}

body.paper-thermal .invoice-totals {
    min-width: 0;
    width: 100%;
}

body.paper-thermal .signatures {
    margin-top: 24px;
    gap: 10px;
}

/* Reports */

.report-section {
    margin-top: 26px;
}

.report-section .toolbar h3 {
    margin: 0;
    flex: 1;
}

.report-page .card .big-number {
    display: block;
    font-size: 22px;
    margin: 4px 0;
}

tfoot td {
    font-weight: bold;
    border-top: 2px solid var(--text);
}

/* Shown on paper only: the letterhead of a printed report */
.print-only {
    display: none;
}

@media print {
    .no-print {
        display: none !important;
    }

    .print-only {
        display: flex;
        border-bottom: 2px solid var(--text);
        padding-bottom: 10px;
    }

    /* On paper the letterhead has a fixed size and is never split across
       pages. The logo is an image, so it prints with its own colours whatever
       the printer's "background graphics" setting is; its width is set and
       its height follows from its proportions. */
    .letterhead {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .letterhead-logo {
        width: 46mm;
        border-radius: 2mm;
    }

    body.paper-thermal {
        page: thermal;
    }

    body.paper-thermal .invoice-sheet {
        max-width: none;
        font-size: 10pt;
    }

    body.paper-thermal .letterhead-logo {
        width: 40mm;
    }

    body.paper-thermal .letterhead-name {
        font-size: 13pt;
    }

    body.paper-thermal .letterhead-text p {
        font-size: 9pt;
    }

    .letterhead-name {
        font-size: 18pt;
    }

    .letterhead-text p {
        font-size: 10.5pt;
    }

    .report-page .panel {
        box-shadow: none;
        padding: 0;
    }

    /* A report is wider than an invoice: it prints on a landscape page, uses
       its whole width, and lets headings and amounts wrap inside their cells,
       so that no column is cut off at the edge of the paper. */
    body.report-page {
        page: report;
    }

    .report-page .container {
        max-width: none;
        padding: 0;
    }

    .report-page .table-wrap {
        overflow: visible;
    }

    .report-page table {
        font-size: 9px;
    }

    .report-page th,
    .report-page td {
        padding: 3px;
        white-space: normal;
    }

    /* The coloured pill of a signed amount takes room a wide table lacks;
       on paper the sign and the colour of the text say the same */
    .report-page .badge {
        padding: 0;
        font-size: inherit;
        background: none;
    }

    .report-page tr {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .report-page thead {
        display: table-header-group;
    }

    .report-page .card {
        box-shadow: none;
        border: 1px solid var(--text);
        padding: 10px;
    }

    .invoice-sheet {
        max-width: none;
        padding: 0;
    }

    th {
        background: none;
    }
}

/* The day's movement (approved by the owner): lines between the columns and
   under every operation, as in the previous system */
.report-lines .report-section table {
    border-collapse: collapse;
    border: 2px solid #9c9288;
}

/* A vertical line between every two columns, and one under every operation */
.report-lines .report-section th,
.report-lines .report-section td {
    border-inline-start: 2px solid #b3a99f;
    border-bottom: 2px solid #cfc6bc;
}

.report-lines .report-section th:first-child,
.report-lines .report-section td:first-child {
    border-inline-start: none;
}

/* The head: dark, with its own lines a little lighter */
.report-lines .report-section thead th {
    background: var(--ink-soft);
    color: var(--on-dark);
    border-inline-start-color: var(--on-dark-muted);
}

/* Two shades, one operation after the other, as before */
.report-lines .report-section tbody tr:nth-child(even) td {
    background: var(--surface-alt);
}

.report-lines .report-section tfoot td {
    border-top: 2px solid var(--ink);
}

/* Correcting an invoice: each device of a line with its own box */
.correction-form {
    margin-top: var(--space-4);
    border-top: 2px solid var(--border);
    padding-top: var(--space-3);
}

.correction-device {
    display: block;
    white-space: nowrap;
}

/* The employees' bonus: choosing the materials of a rule, and «بونصي» on the home page */
dialog.wide-dialog {
    width: min(860px, 96vw);
}

.bonus-groups {
    display: grid;
    gap: 6px;
    max-height: 340px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
}

.bonus-group-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.bonus-group-head strong {
    min-width: 140px;
}

.bonus-group-items,
.bonus-results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 4px 12px;
    padding: 6px 0;
}

.bonus-group-items .actions {
    grid-column: 1 / -1;
}

.bonus-product {
    font-weight: normal;
}

.bonus-summary {
    margin-top: 12px;
    padding: 10px;
    border-radius: 8px;
    background: var(--surface-alt);
}

.bonus-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.chip-remove {
    padding: 0 6px;
    min-height: 0;
    background: transparent;
    color: inherit;
    border: none;
    cursor: pointer;
}

.bonus-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    margin: 10px 0;
}

.bonus-tile {
    padding: 12px;
    border-radius: 10px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
}

.bonus-tile .number {
    display: block;
    font-size: 1.4em;
    font-weight: bold;
    margin-top: 4px;
}

/* The quick look on the home page: a material's quantity, cost and price */
.quick-look-search {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 1.3rem;
    color: var(--muted);
}

.quick-look-search input {
    font-size: 1rem;
    min-height: 46px;
}

.quick-look-results {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.quick-look-results:empty {
    display: none;
}

.quick-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) repeat(3, minmax(110px, 160px));
    gap: 12px;
    align-items: center;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
}

.quick-name {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.quick-name span {
    font-size: var(--text-sm);
}

.quick-figure {
    display: flex;
    flex-direction: column;
    text-align: center;
}

.quick-figure span {
    font-size: var(--text-sm);
    color: var(--muted);
}

.quick-figure b {
    font-size: 1.15rem;
    font-variant-numeric: tabular-nums;
}

.quick-figure.in b {
    color: var(--success);
}

.quick-figure.out b {
    color: var(--danger);
}

.quick-figure.price b {
    color: var(--brand);
}

.quick-places {
    grid-column: 1 / -1;
    font-size: var(--text-sm);
}

@media (max-width: 700px) {
    .quick-card {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .quick-name {
        grid-column: 1 / -1;
    }
}

/* The closing: the drawer into the safe */
.safe-move {
    margin: 12px 0;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-alt);
}

.safe-keep {
    max-width: 260px;
    margin-top: 8px;
}

/* WhatsApp: reminding a customer of his debt */
.whatsapp-button,
.button-small.whatsapp-button {
    background: #25d366;
    border-color: #25d366;
    color: #fff;
}

.whatsapp-button:hover {
    background: #1fb658;
}

.segmented-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 8px 0;
}

/* ==== On a phone (under 760 wide). Nothing here touches the shop's screen ====
   A table marked .phone-rows turns into rows of two lines: the name and the
   amount large on the first, the details small on the second. Its cells say
   what they are: .ph-main (the name), .ph-amount, .ph-meta (small details,
   data-ph as their word), .ph-hide (not on a phone), .ph-full (a line of its own). */

@media (max-width: 760px) {
    body {
        font-size: 15px;
    }

    .container,
    body.embedded .container {
        padding: 10px;
    }

    .panel {
        padding: 12px;
        border-radius: 14px;
    }

    .header {
        padding: 10px 12px;
    }

    button,
    .button {
        min-height: 40px;
    }

    .toolbar {
        gap: 8px;
    }

    .toolbar input[type="text"],
    .toolbar input[type="search"],
    .toolbar select {
        min-width: 0;
        flex: 1 1 100%;
    }

    .toolbar input[type="date"] {
        min-width: 0;
        flex: 1;
    }

    .toolbar label {
        flex: 1 1 45%;
    }

    .toolbar .button-primary {
        flex: 1 1 100%;
    }

    .pager {
        justify-content: center;
    }

    /* A dialog takes the whole screen; its buttons stay at the bottom */
    dialog,
    dialog.wide-dialog {
        width: 100vw;
        max-width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        margin: 0;
        border-radius: 0;
        padding: 14px 12px 0;
    }

    dialog .dialog-actions {
        position: sticky;
        bottom: 0;
        background: var(--surface);
        padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
        margin-top: 12px;
        border-top: 1px solid var(--border);
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    dialog .dialog-actions button {
        flex: 1 1 40%;
    }

    /* ---- Lists in two lines ---- */

    table.phone-rows {
        border: none;
        margin-top: 8px;
    }

    table.phone-rows thead {
        display: none;
    }

    table.phone-rows tbody {
        display: grid;
        gap: 8px;
    }

    table.phone-rows tr {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        gap: 2px 10px;
        padding: 10px 12px;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 12px;
    }

    table.phone-rows tr[data-tap] {
        cursor: pointer;
    }

    table.phone-rows tr[data-tap]:active {
        background: var(--surface-alt);
    }

    table.phone-rows tr.inactive {
        opacity: 0.6;
    }

    /* The line between the two lines */
    table.phone-rows tr::after {
        content: "";
        order: 3;
        flex-basis: 100%;
        height: 0;
    }

    table.phone-rows td {
        display: block;
        border: none !important;
        padding: 0;
        text-align: start;
        background: none !important;
    }

    table.phone-rows td.ph-main {
        order: 1;
        flex: 1 1 0;
        min-width: 0;
        font-weight: 700;
        font-size: 1rem;
    }

    table.phone-rows td.ph-amount {
        order: 2;
        font-weight: 800;
        font-size: 1.05rem;
        white-space: nowrap;
    }

    table.phone-rows td.ph-meta {
        order: 4;
        color: var(--muted);
        font-size: 0.82rem;
    }

    table.phone-rows td.ph-meta .number {
        font-size: inherit;
    }

    table.phone-rows td[data-ph]::before {
        content: attr(data-ph) " ";
    }

    table.phone-rows td.ph-full {
        order: 5;
        flex-basis: 100%;
    }

    table.phone-rows td.ph-hide,
    table.phone-rows td.ph-meta:empty {
        display: none;
    }

    table.phone-rows tfoot {
        display: block;
        margin-top: 8px;
    }

    table.phone-rows tfoot tr {
        background: var(--surface-alt);
    }
}

/* The totals of a document as a block: on a phone only */
.ph-sums {
    display: none;
}

@media (max-width: 760px) {
    .ph-sums {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
        margin: 12px 0;
    }

    .ph-sums + .total,
    #detailTotals {
        display: none;
    }

    .ph-sum {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 8px;
        padding: 8px 10px;
        border-radius: 10px;
        background: var(--surface-alt);
        font-size: 0.85rem;
    }

    .ph-sum b {
        font-variant-numeric: tabular-nums;
    }

    .ph-sum.big {
        grid-column: 1 / -1;
        font-size: 1.05rem;
        background: var(--ink);
        color: #fff;
    }

    .ph-sum.owes b,
    table.phone-rows td.ph-owes {
        color: #b91c1c;
    }

    #detailInfo {
        font-size: 0.85rem;
    }
}

@media (max-width: 760px) {
    .toolbar.ph-folded {
        flex-wrap: wrap;
    }

    .toolbar.ph-folded > :first-child {
        flex: 1 1 0;
        min-width: 0;
    }

    .toolbar.ph-folded > .ph-filter-toggle {
        flex: 0 0 auto;
    }

    .toolbar.ph-folded:not(.ph-open) > :not(:first-child):not(.ph-filter-toggle):not(.button-primary) {
        display: none !important;
    }
}

/* A table not laid out for the phone: each row a block, each cell with its column's name */
@media screen and (max-width: 760px) {
    table.phone-auto {
        border: none;
    }

    table.phone-auto thead {
        display: none;
    }

    table.phone-auto tbody,
    table.phone-auto tfoot {
        display: grid;
        gap: 8px;
    }

    table.phone-auto tr {
        display: block;
        padding: 8px 12px;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 12px;
    }

    table.phone-auto td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        padding: 4px 0;
        border: none !important;
        border-bottom: 1px dashed var(--border) !important;
        text-align: end;
        background: none !important;
        min-height: 0;
    }

    table.phone-auto td:last-child {
        border-bottom: none !important;
    }

    table.phone-auto td:first-child {
        font-weight: 700;
    }

    table.phone-auto td[data-col]::before {
        content: attr(data-col);
        color: var(--muted);
        font-size: 0.8rem;
        font-weight: 600;
        text-align: start;
        flex: 0 0 auto;
        max-width: 45%;
    }

    table.phone-auto td:empty,
    table.phone-auto td[data-col=""]::before {
        display: none;
    }

    /* A message in a row of its own ("no results") */
    table.phone-auto td[colspan] {
        justify-content: center;
        text-align: center;
    }

    table.phone-auto td[colspan]::before {
        display: none;
    }

    table.phone-auto td input,
    table.phone-auto td select {
        max-width: 60%;
    }

    .table-wrap:has(> table.phone-auto),
    .table-wrap:has(> table.phone-rows) {
        overflow-x: visible;
    }
}

@media screen and (max-width: 760px) {
    /* A long name (a backup file, an IMEI) breaks instead of widening the page */
    table.phone-auto td,
    table.phone-rows td {
        overflow-wrap: anywhere;
        min-width: 0;
    }
}

/* A material's other barcodes */
.extra-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 4px 0 8px;
}

.extra-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 4px 3px 10px;
    border-radius: 999px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
}

.extra-remove {
    min-height: 24px;
    width: 24px;
    padding: 0;
    border-radius: 50%;
    background: none;
    color: var(--danger);
    font-weight: 800;
}

.extra-add {
    display: flex;
    gap: 8px;
}

.extra-add input {
    flex: 1;
}

/* The repair shop's home: its board and its counter first */
.repair-home {
    margin-bottom: 14px;
}

.repair-home-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
}

.repair-home-button {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    gap: 0 14px;
    align-items: center;
    min-height: 96px;
    padding: 16px 20px;
    border: none;
    border-radius: 18px;
    color: #fff;
    text-align: start;
    box-shadow: 0 6px 18px rgb(31 36 48 / 14%);
}

.repair-home-button.board {
    background: linear-gradient(135deg, #1f2430, #3b4256);
}

.repair-home-button.intake {
    background: linear-gradient(135deg, #e07a3f, #b95d27);
}

.repair-home-button span {
    grid-row: span 2;
    font-size: 2.2rem;
}

.repair-home-button b {
    font-size: 1.3rem;
}

.repair-home-button small {
    opacity: 0.85;
}

.repair-home-numbers {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.repair-number {
    display: grid;
    padding: 10px 14px;
    border-radius: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
}

.repair-number b {
    font-size: 1.5rem;
}

.repair-number span {
    color: var(--muted);
    font-size: 0.85rem;
}

.repair-number.ready b {
    color: #15803d;
}

.repair-number.wait b {
    color: #b45309;
}

.repair-number.late b {
    color: #b91c1c;
}
