/* SmartPOS Hub — CRUD kit (2026-10-25). Docs + copy-paste markup: _context/42-CRUD-KIT.md
   Loaded app-wide after smartpos-ui.css + smartpos-dialogs.css (layouts/partials/css.blade.php).
   Part A = global fixes that need no markup (border bug, DataTables on phones, uploader, bootstrap-fileinput).
   Part B = opt-in classes, prefix .spx- (page header, filter card, table card, form sections, save bar, modals,
            view modal key–value / lines / totals, chips, empty state, KPI row).
   Rules: colours ONLY via --spu-* tokens (per-business theme), rectangular controls (6px / 4px radius), 40px tap
   targets on phones, logical properties (RTL). */

/* ================================================================= A1. border bug (owner item 6, 2026-10-25)
   Bootstrap 3 gives .table-responsive a 1px #ddd border below 768px, so on phones every page that wraps its
   DataTable in <div class="table-responsive"> (units, brands, selling price groups, purchase returns …) showed a
   grey frame around "Show 25 entries" + the table. Cards (.box, widget, .spx-card) keep their own border. */
@media (max-width: 767px) {
    .table-responsive { border: 0; margin-bottom: 0; }
    .table-responsive > .table { margin-bottom: 0; }
}

/* ================================================================= A2. DataTables on phones / tablets */
/* tables wider than their card scroll inside the card (wrapper added by smartpos-crud.js on init.dt when the
   page did not wrap the table in .table-responsive / scrollX) */
.spx-dt-scroll, .spx-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.spx-dt-scroll > .table, .spx-scroll > .table { margin-bottom: 0; }
.dataTables_wrapper { max-width: 100%; }
@media (max-width: 767px) {
    /* stacked toolbar: length + buttons + search each take the full row, search input full width */
    .dataTables_wrapper > .row:first-child, .dataTables_wrapper > .row.margin-bottom-20 { gap: 8px; }
    .dataTables_wrapper > .row:first-child > [class*="col-"],
    .dataTables_wrapper > .row.margin-bottom-20 > [class*="col-"] { flex: 1 1 100%; text-align: start; margin-inline-start: 0; }
    .dataTables_wrapper .dt-buttons { justify-content: flex-start; }
    .dataTables_wrapper .dt-buttons > .tw-dw-btn, .dataTables_wrapper .dt-buttons > .btn { min-height: 36px; }
    .dataTables_wrapper .dataTables_filter, .dataTables_wrapper .dataTables_filter label { display: flex; width: 100%; }
    .dataTables_wrapper .dataTables_filter input { flex: 1 1 auto; width: 100%; min-width: 0; height: 40px !important; }
    .dataTables_wrapper .dataTables_length select { height: 40px !important; }
    .dataTables_wrapper .dataTables_info { text-align: center; }
    .dataTables_wrapper .dataTables_paginate { text-align: center; float: none !important; }
    .dataTables_wrapper .pagination > li > a, .dataTables_wrapper .pagination > li > span { min-width: 40px; height: 40px; }
}

/* ================================================================= A3. modals on phones (extends smartpos-dialogs.css) */
@media (max-width: 767px) {
    .modal-body .table-responsive, .modal-body .spx-scroll { margin-inline: 0; }
    .modal-body { overflow-wrap: anywhere; }
    .modal-body .form-group[class*="col-"] { width: 100%; }
}

/* ================================================================= A4. bootstrap-fileinput (product image, business logo,
   shipping documents …) — keep the plugin, just align it with the design system */
.file-input .file-preview { border: 1px dashed var(--spu-line-strong); border-radius: var(--spu-radius-md); padding: 8px; }
.file-input .file-drop-zone { border: 1px dashed var(--spu-line-strong); border-radius: var(--spu-radius-md); }
.file-input .file-caption.form-control, .file-input .file-caption .form-control { border-radius: var(--spu-radius); }
.file-input .input-group-btn > .btn:last-child, .file-input .btn-file { border-start-end-radius: var(--spu-radius); border-end-end-radius: var(--spu-radius); }
.file-input .kv-file-content img { border-radius: var(--spu-radius-xs); }

/* ================================================================= A5. drag-and-drop uploader (public/js/smartpos-upload.js)
   The real <input type=file> stays inside .spx-upload__zone, transparent and stretched over it: click, keyboard and
   native drop all go to the real input, so name / accept / multiple / change handlers are unchanged. */
.spx-upload { display: block; width: 100%; max-width: 100%; margin: 2px 0 4px; }
.spx-upload__zone {
    position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; min-height: 72px; padding: 14px 16px;
    background: var(--spu-surface-2); border: 1.5px dashed var(--spu-line-strong); border-radius: var(--spu-radius-md);
    color: var(--spu-text); text-align: start; cursor: pointer; transition: border-color .15s, background-color .15s, box-shadow .15s;
}
.spx-upload__zone:hover { border-color: var(--spu-primary-line); background: var(--spu-primary-tint, var(--spu-surface-2)); }
.spx-upload__zone:focus-within { border-color: var(--spu-primary); box-shadow: 0 0 0 3px var(--spu-ring); }
.spx-upload.is-dragover .spx-upload__zone { border-color: var(--spu-primary); border-style: solid; background: var(--spu-primary-soft); }
.spx-upload.is-disabled .spx-upload__zone { opacity: .55; cursor: not-allowed; }
.spx-upload__zone > input[type="file"] {
    position: absolute !important; inset: 0; width: 100% !important; height: 100% !important; max-width: none !important;
    margin: 0 !important; padding: 0 !important; opacity: 0 !important; cursor: pointer; z-index: 2; font-size: 0; border: 0 !important;
}
.spx-upload.is-disabled .spx-upload__zone > input[type="file"] { cursor: not-allowed; }
.spx-upload__icon {
    flex: 0 0 auto; width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--spu-radius-md); background: var(--spu-primary-soft); color: var(--spu-primary-text, var(--spu-primary));
}
.spx-upload__icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.spx-upload__text { min-width: 0; flex: 1 1 0; line-height: 1.4; }
.spx-upload__zone > label.error, .spx-upload__zone > .help-block { flex: 1 1 100%; order: 5; margin: 4px 0 0; position: relative; z-index: 3; }
.spx-upload__title { display: block; font-size: 14px; font-weight: 600; color: var(--spu-ink); }
.spx-upload__browse { color: var(--spu-primary-text, var(--spu-primary)); text-decoration: underline; text-underline-offset: 2px; }
.spx-upload__hint { display: block; margin-top: 2px; font-size: 12.5px; color: var(--spu-muted); }
.spx-upload__files { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.spx-upload__files:empty { display: none; }
.spx-upload__file {
    display: flex; align-items: center; gap: 10px; min-width: 0; padding: 6px 6px 6px 8px; padding-inline: 8px 6px;
    background: var(--spu-surface); border: 1px solid var(--spu-line); border-radius: var(--spu-radius-md);
}
.spx-upload__file.is-error { border-color: var(--spu-danger); background: var(--spu-danger-soft); }
.spx-upload__thumb {
    flex: 0 0 auto; width: 40px; height: 40px; border-radius: var(--spu-radius-xs); background: var(--spu-surface-2) center / cover no-repeat;
    border: 1px solid var(--spu-line); display: inline-flex; align-items: center; justify-content: center; color: var(--spu-muted);
    font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; overflow: hidden;
}
.spx-upload__meta { min-width: 0; flex: 1 1 auto; line-height: 1.3; }
.spx-upload__name { display: block; font-size: 13px; font-weight: 600; color: var(--spu-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spx-upload__size { display: block; font-size: 12px; color: var(--spu-muted); }
.spx-upload__file.is-error .spx-upload__size { color: var(--spu-danger-ink); }
.spx-upload__btn {
    flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0;
    background: transparent; border: 1px solid transparent; border-radius: var(--spu-radius); color: var(--spu-muted); cursor: pointer;
}
.spx-upload__btn:hover { background: var(--spu-surface-2); border-color: var(--spu-line); color: var(--spu-danger); }
.spx-upload__btn:focus-visible { outline: 2px solid var(--spu-ring); outline-offset: 1px; }
.spx-upload__btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spx-upload__msg { display: block; margin-top: 6px; font-size: 12.5px; color: var(--spu-danger); }
.spx-upload__msg:empty { display: none; }
/* compact variant (table rows, narrow columns): data-spx-upload="compact" */
.spx-upload--compact .spx-upload__zone { min-height: 44px; padding: 8px 10px; gap: 8px; }
.spx-upload--compact .spx-upload__icon { width: 28px; height: 28px; }
.spx-upload--compact .spx-upload__icon svg { width: 16px; height: 16px; }
.spx-upload--compact .spx-upload__title { font-size: 13px; }
.spx-upload--compact .spx-upload__hint { display: none; }
@media (max-width: 767px) {
    .spx-upload__zone { min-height: 64px; padding: 12px; }
    .spx-upload__btn { width: 40px; height: 40px; }
}
/* drop target on a custom picker (data-spx-drop="#input"), e.g. the brand logo boxes */
[data-spx-drop].is-dragover { outline: 2px dashed var(--spu-primary); outline-offset: 3px; background-color: var(--spu-primary-soft); }

/* ================================================================= B1. page header */
.spx-page-head {
    display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 16px;
    padding: 24px 24px 0; position: relative;   /* 22b; smartpos-ui.css §16 sets the same inside the app shell */
}
.spx-page-head__main { min-width: 0; flex: 1 1 320px; display: flex; align-items: flex-start; gap: 12px; }
.spx-page-head__text { min-width: 0; }
.spx-page-icon {
    flex: 0 0 auto; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--spu-radius-md); background: var(--spu-primary-soft); color: var(--spu-primary-text, var(--spu-primary));
}
.spx-page-icon svg, .spx-ico svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.spx-page-icon > i { font-size: 18px; }
.spx-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 0 0 4px; padding: 0; list-style: none; font-size: 12.5px; color: var(--spu-muted); }
.spx-crumbs > li { display: inline-flex; align-items: center; gap: 4px; }
.spx-crumbs > li + li::before { content: "/"; color: var(--spu-subtle); margin-inline-end: 2px; }
.spx-crumbs a { color: var(--spu-muted); }
.spx-crumbs a:hover { color: var(--spu-primary-text, var(--spu-primary)); }
.spx-page-title, .content-header > h1.spx-page-title {
    margin: 0; font-size: 26px; line-height: 1.2; font-weight: 700; letter-spacing: -.01em; color: var(--spu-ink);
}
.spx-page-help { margin: 4px 0 0; font-size: 14px; color: var(--spu-muted); max-width: 72ch; }
.spx-page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-inline-start: auto; }
.spx-page-actions > .pull-right, .spx-page-actions > .pull-left { float: none !important; margin: 0 !important; }
@media (max-width: 767px) {
    .spx-page-head { padding: 16px 16px 0; align-items: stretch; }
    .spx-page-title, .content-header > h1.spx-page-title { font-size: 21px; }
    .spx-page-help { font-size: 13px; }
    .spx-page-icon { width: 40px; height: 40px; }
    .spx-page-actions { width: 100%; margin-inline-start: 0; }
    .spx-page-actions > .tw-dw-btn, .spx-page-actions > .btn, .spx-page-actions > a { flex: 1 1 auto; min-height: 40px; justify-content: center; }
}

/* ================================================================= B2. cards (table card, generic card) */
.spx-card {
    background: var(--spu-surface); border: 1px solid var(--spu-line); border-radius: var(--spu-radius-lg);
    box-shadow: var(--spu-shadow-xs); margin-bottom: 24px; min-width: 0;
}
.spx-card__head {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 16px 20px;
    border-bottom: 1px solid var(--spu-line);
}
.spx-card__head--plain { border-bottom: 0; padding-bottom: 4px; }
.spx-card__title { margin: 0; font-size: 16px; font-weight: 600; line-height: 1.35; color: var(--spu-ink); flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 8px; }
.spx-card__title small, .spx-card__sub { display: block; font-size: 13px; font-weight: 400; color: var(--spu-muted); }
.spx-card__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-inline-start: auto; }
.spx-card__actions > .pull-right, .spx-card__actions > .pull-left { float: none !important; margin: 0 !important; }
.spx-card__head > .spx-card__actions { margin-bottom: 0; }
.spx-card__body { padding: 20px; min-width: 0; }
.spx-card__body--flush { padding: 0; }
.spx-card__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--spu-line); }
/* DataTable inside a table card: toolbar on the card's padding, table edge-to-edge-ish */
.spx-table-card .dataTables_wrapper .table { margin-bottom: 0; }
.spx-table-card .table-responsive { border: 0; margin-bottom: 0; }
.spx-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 12px; margin-bottom: 12px; }
.spx-toolbar > .form-group { margin: 0; min-width: 180px; }
.spx-toolbar__grow { flex: 1 1 auto; }
@media (max-width: 767px) {
    .spx-card__head { padding: 12px 16px; }
    .spx-card__body { padding: 16px; }
    .spx-card__foot { padding: 12px 16px; }
    .spx-card__actions { width: 100%; margin-inline-start: 0; }
    .spx-card__actions > .tw-dw-btn, .spx-card__actions > .btn, .spx-card__actions > a { flex: 1 1 auto; min-height: 40px; justify-content: center; }
    .spx-toolbar > .form-group { flex: 1 1 100%; min-width: 0; }
}

/* ================================================================= B3. filter card (<details>, collapsible on phones) */
.spx-filter { background: var(--spu-surface); border: 1px solid var(--spu-line); border-radius: var(--spu-radius-lg); box-shadow: var(--spu-shadow-xs); margin-bottom: 24px; }
.spx-filter > summary {
    display: flex; align-items: center; gap: 12px; padding: 12px 20px; cursor: pointer; list-style: none;
    font-size: 14px; font-weight: 600; color: var(--spu-ink); border-radius: var(--spu-radius-lg); user-select: none;
}
.spx-filter > summary::-webkit-details-marker { display: none; }
.spx-filter > summary::after {
    content: ""; margin-inline-start: auto; width: 9px; height: 9px; border-inline-end: 2px solid var(--spu-muted); border-bottom: 2px solid var(--spu-muted);
    transform: rotate(45deg) translate(-2px, -2px); transition: transform .2s;
}
.spx-filter[open] > summary::after { transform: rotate(-135deg) translate(-2px, -2px); }
.spx-filter > summary:hover { background: var(--spu-surface-2); }
.spx-filter > summary:focus-visible { outline: 2px solid var(--spu-ring); outline-offset: 2px; }
.spx-filter[open] > summary { border-bottom: 1px solid var(--spu-line); border-radius: var(--spu-radius-lg) var(--spu-radius-lg) 0 0; }
.spx-filter__body { padding: 16px 20px 20px; }
.spx-filter__count { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--spu-radius-xs); background: var(--spu-primary); color: var(--spu-on-primary, #fff); font-size: 11.5px; font-weight: 700; }
.spx-filter__count:empty { display: none; }
.spx-filter__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* ================================================================= B4. form grid + section cards + save bar */
.spx-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.spx-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.spx-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.spx-grid--1 { grid-template-columns: minmax(0, 1fr); }
.spx-grid > .form-group, .spx-grid > [class*="col-"] { width: auto; float: none; padding-inline: 0; min-width: 0; }
.spx-grid::before, .spx-grid::after { content: none; }
.spx-span-2 { grid-column: span 2; }
.spx-span-full { grid-column: 1 / -1; }
.spx-section {
    background: var(--spu-surface); border: 1px solid var(--spu-line); border-radius: var(--spu-radius-lg);
    box-shadow: var(--spu-shadow-xs); margin-bottom: 24px;
}
.spx-section__head { display: flex; align-items: flex-start; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--spu-line); }
.spx-section__title { margin: 0; font-size: 15px; font-weight: 600; color: var(--spu-ink); line-height: 1.35; }
.spx-section__help { margin: 4px 0 0; font-size: 13px; color: var(--spu-muted); }
.spx-section__body { padding: 20px; }
.spx-ico {
    flex: 0 0 auto; width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--spu-radius-md); background: var(--spu-primary-soft); color: var(--spu-primary-text, var(--spu-primary));
}
.spx-ico svg { width: 18px; height: 18px; }
.spx-ico--success { background: var(--spu-success-soft); color: var(--spu-success); }
.spx-ico--danger { background: var(--spu-danger-soft); color: var(--spu-danger); }
.spx-ico--warning { background: var(--spu-warning-soft); color: var(--spu-warning); }
.spx-ico--info { background: var(--spu-info-soft); color: var(--spu-info); }
.spx-help { margin: 4px 0 0; font-size: 12.5px; color: var(--spu-muted); }
.spx-inline-eq { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.spx-inline-eq > .form-control, .spx-inline-eq > select { flex: 1 1 160px; width: auto; }
.spx-inline-eq > .spx-inline-eq__label { font-weight: 600; color: var(--spu-ink); white-space: nowrap; }
.spx-check { display: flex; align-items: flex-start; gap: 10px; margin: 4px 0 12px; font-weight: 500; color: var(--spu-text); cursor: pointer; }
.spx-check > input[type="checkbox"], .spx-check > input[type="radio"] { width: 18px; height: 18px; margin: 1px 0 0; flex: 0 0 auto; accent-color: var(--spu-primary); }
.spx-savebar {
    position: sticky; bottom: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px;
    margin: 16px 0 0; padding: 12px 16px; padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    background: color-mix(in srgb, var(--spu-surface) 94%, transparent); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
    border: 1px solid var(--spu-line); border-radius: var(--spu-radius-lg); box-shadow: var(--spu-shadow-md);
}
.spx-savebar__note { margin-inline-end: auto; font-size: 13px; color: var(--spu-muted); }
@media (max-width: 991px) {
    .spx-grid--3, .spx-grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 767px) {
    .spx-grid, .spx-grid--3, .spx-grid--4 { grid-template-columns: minmax(0, 1fr); }
    .spx-span-2 { grid-column: auto; }
    .spx-section__head { padding: 12px 16px; }
    .spx-section__body { padding: 16px; }
    .spx-savebar { margin-inline: -4px; border-radius: var(--spu-radius-md); }
    .spx-savebar > .tw-dw-btn, .spx-savebar > .btn { flex: 1 1 auto; min-height: 44px; }
    .spx-savebar__note { flex-basis: 100%; }
}

/* ================================================================= B5. modals (opt-in, on .modal-dialog) */
.spx-modal-title { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
.spx-modal-title .modal-title { margin: 0; }
.spx-modal-title p, .spx-modal-sub { margin: 2px 0 0; font-size: 13px; font-weight: 400; color: var(--spu-muted); }
.spx-modal .modal-body > .row { margin-inline: 0; }
.spx-modal .modal-body > .row > [class*="col-"] { padding-inline: 0; }
.spx-modal .modal-footer > .tw-dw-btn, .spx-modal .modal-footer > .btn { min-width: 96px; }
@media (min-width: 768px) {
    .spx-modal.modal-dialog { margin-top: 48px; }
    .spx-modal--md.modal-dialog { width: 640px; }
}
/* phones: near full-screen sheet, body scrolls, header + footer stay on screen */
@media (max-width: 767px) {
    .spx-modal.modal-dialog { margin: 0; width: 100%; max-width: 100%; min-height: 100%; display: flex; }
    .spx-modal > .modal-content {
        flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; border-radius: 0; box-shadow: none; /* min-width:0 = wide tables scroll inside instead of widening the sheet (stx 2026-10-25) */
    }
    .spx-modal > .modal-content > form { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
    .spx-modal .modal-header { border-radius: 0; }
    .spx-modal .modal-body { flex: 1 1 auto; }
    .spx-modal .modal-footer { border-radius: 0; margin-top: auto; }
    .modal:has(> .spx-modal) { padding: 0 !important; }
}

/* ================================================================= B6. view-details modal: key–value grid, line items, totals, chips */
.spx-kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 20px; margin: 0 0 16px; }
.spx-kv > div { min-width: 0; }
.spx-kv dt { font-size: 12px; font-weight: 600; color: var(--spu-muted); text-transform: none; letter-spacing: .01em; margin: 0 0 2px; }
.spx-kv dd { margin: 0; font-size: 14px; color: var(--spu-ink); overflow-wrap: anywhere; }
.spx-kv--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.spx-kv--boxed { padding: 16px; background: var(--spu-surface-2); border: 1px solid var(--spu-line); border-radius: var(--spu-radius-md); }
.spx-subhead { display: flex; align-items: center; gap: 8px; margin: 24px 0 12px; font-size: 14px; font-weight: 600; color: var(--spu-ink); }
.spx-subhead:first-child { margin-top: 0; }
.spx-lines-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--spu-line); border-radius: var(--spu-radius-md); margin-bottom: 16px; }
.spx-lines { width: 100%; margin: 0; border-collapse: separate; border-spacing: 0; font-size: 13.5px; background: var(--spu-surface); }
.spx-lines > thead > tr > th {
    padding: 10px 12px; background: var(--spu-surface-2); color: var(--spu-muted); font-size: 12px; font-weight: 600;
    text-align: start; white-space: nowrap; border-bottom: 1px solid var(--spu-line);
}
.spx-lines > tbody > tr > td { padding: 10px 12px; color: var(--spu-text); border-bottom: 1px solid var(--spu-line); vertical-align: top; }
.spx-lines > tbody > tr:last-child > td { border-bottom: 0; }
.spx-lines > tbody > tr:nth-child(even) > td { background: color-mix(in srgb, var(--spu-surface-2) 60%, var(--spu-surface)); }
.spx-lines .spx-num, .spx-lines th.spx-num { text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
.spx-lines > tfoot > tr > td, .spx-lines > tfoot > tr > th { padding: 10px 12px; border-top: 1px solid var(--spu-line); font-weight: 600; color: var(--spu-ink); }
.spx-totals { margin: 0 0 16px auto; width: min(360px, 100%); display: grid; gap: 0; border: 1px solid var(--spu-line); border-radius: var(--spu-radius-md); overflow: hidden; }
.spx-totals > div { display: flex; justify-content: space-between; gap: 16px; padding: 8px 14px; border-bottom: 1px solid var(--spu-line); }
.spx-totals > div:last-child { border-bottom: 0; }
.spx-totals dt { margin: 0; font-weight: 500; color: var(--spu-muted); }
.spx-totals dd { margin: 0; font-weight: 600; color: var(--spu-ink); text-align: end; font-variant-numeric: tabular-nums; }
.spx-totals > .is-grand { background: var(--spu-surface-2); }
.spx-totals > .is-grand dt, .spx-totals > .is-grand dd { color: var(--spu-ink); font-weight: 700; font-size: 15px; }
.spx-totals > .is-due dd { color: var(--spu-danger); }
.spx-note { padding: 12px 16px; background: var(--spu-surface-2); border: 1px solid var(--spu-line); border-radius: var(--spu-radius-md); color: var(--spu-text); white-space: pre-line; }
.spx-chip {
    display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 8px; border-radius: var(--spu-radius-xs);
    font-size: 12px; font-weight: 600; line-height: 1; white-space: nowrap; vertical-align: middle;
    background: var(--spu-surface-2); color: var(--spu-text); border: 1px solid var(--spu-line);
}
.spx-chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.spx-chip--plain::before { content: none; }
.spx-chip--success { background: var(--spu-success-soft); color: var(--spu-success-ink); border-color: color-mix(in srgb, var(--spu-success) 25%, transparent); }
.spx-chip--danger { background: var(--spu-danger-soft); color: var(--spu-danger-ink); border-color: color-mix(in srgb, var(--spu-danger) 25%, transparent); }
.spx-chip--warning { background: var(--spu-warning-soft); color: var(--spu-warning-ink); border-color: color-mix(in srgb, var(--spu-warning) 25%, transparent); }
.spx-chip--info { background: var(--spu-info-soft); color: var(--spu-info-ink); border-color: color-mix(in srgb, var(--spu-info) 25%, transparent); }
.spx-chip--primary { background: var(--spu-primary-soft); color: var(--spu-primary-text, var(--spu-primary)); border-color: var(--spu-primary-line); }
@media (max-width: 767px) {
    .spx-kv, .spx-kv--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
    .spx-totals { width: 100%; }
}
@media (max-width: 400px) {
    .spx-kv, .spx-kv--2 { grid-template-columns: minmax(0, 1fr); }
}

/* ================================================================= B7. empty state */
.spx-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 40px 16px; color: var(--spu-muted); }
.spx-empty__icon { width: 52px; height: 52px; display: inline-flex; align-items: center; justify-content: center; margin-bottom: 6px; border-radius: var(--spu-radius-lg); background: var(--spu-primary-soft); color: var(--spu-primary-text, var(--spu-primary)); }
.spx-empty__icon svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.spx-empty__title { margin: 0; font-size: 16px; font-weight: 600; color: var(--spu-ink); }
.spx-empty__text { margin: 0; max-width: 46ch; font-size: 13.5px; }
.spx-empty__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 8px; }

/* ================================================================= B8. KPI / stat row */
.spx-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.spx-kpi {
    display: flex; align-items: flex-start; gap: 12px; min-width: 0; padding: 16px;
    background: var(--spu-surface); border: 1px solid var(--spu-line); border-radius: var(--spu-radius-lg); box-shadow: var(--spu-shadow-xs);
}
.spx-kpi__body { min-width: 0; }
.spx-kpi__label { display: block; font-size: 12.5px; font-weight: 600; color: var(--spu-muted); }
.spx-kpi__value { display: block; margin-top: 4px; font-size: 22px; font-weight: 700; line-height: 1.2; color: var(--spu-ink); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.spx-kpi__meta { display: block; margin-top: 2px; font-size: 12px; color: var(--spu-muted); }
.spx-kpi__meta.is-up { color: var(--spu-success); }
.spx-kpi__meta.is-down { color: var(--spu-danger); }
@media (max-width: 767px) {
    .spx-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
    .spx-kpi { padding: 12px; gap: 8px; }
    .spx-kpi .spx-ico { display: none; }
    .spx-kpi__value { font-size: 18px; }
}

/* ================================================================= utilities */
.spx-muted { color: var(--spu-muted); }
.spx-nowrap { white-space: nowrap; }
@media (max-width: 767px) { .spx-hide-phone { display: none !important; } }
@media (prefers-reduced-motion: reduce) {
    .spx-upload__zone, .spx-filter > summary::after { transition: none; }
}
@media (max-width: 767px) { .spx-card, .spx-filter, .spx-section { margin-bottom: 16px; } }   /* 22b phones */
