/* ERP web UI - layout, components and tables. Colours are defined once as tokens.
   Trex Pi brand (style book "Marupe leaf", web kit trexpi.css v2.0): bright greens on white and light neutrals, no dark
   fills or backgrounds anywhere (the deep ink is for text only), Verdana for headings and Tahoma for text. */

:root {
    --bg: #f3f7f5;
    --surface: #ffffff;
    --surface-muted: #f3f7f5;
    --text: #243029;
    --text-muted: #51635a;
    --border: #e2eee7;
    /* text-safe green: links, active states, outlines; white text on it reads well */
    --primary: #187c50;
    --primary-hover: #146943;
    --primary-soft: #eaf9f0;
    /* the brand green: primary buttons (ink text on it, as the web kit) */
    --brand: #2fbf71;
    --brand-hover: #45c77f;
    --brand-ink: #243029;
    --danger: #c94040;
    --danger-soft: #fbeded;
    --success: #187c50;
    --success-soft: #eaf9f0;
    --warning: #9a6110;
    --warning-soft: #fdf3e3;
    --info: #2b6a8f;
    --info-soft: #eaf3f8;
    --steel: #7e9187;
    --sidebar-bg: #ffffff;
    --sidebar-text: #51635a;
    --sidebar-active: #eaf9f0;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(36, 48, 41, .06), 0 1px 3px rgba(36, 48, 41, .06);
    --shadow-lg: 0 12px 32px rgba(36, 48, 41, .14);
    --sidebar-width: 240px;
    --font-head: Verdana, Geneva, "DejaVu Sans", sans-serif;
    --font-body: Tahoma, Verdana, "DejaVu Sans", sans-serif;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
}

body {
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
    /* Checkboxes, radios and range sliders in the brand's text-safe green, not the browser's blue */
    accent-color: var(--primary);
}

/* Every text box, select and text area has the field look, also outside a .form-field (tables, toolbars, card rows);
   :where() keeps it at zero specificity, so a component's own rule always wins */
:where(input:not([type="checkbox"], [type="radio"], [type="file"], [type="range"], [type="color"], [type="hidden"],
        [type="submit"], [type="button"], [type="reset"], [type="image"]), select, textarea) {
    box-sizing: border-box;
    max-width: 100%;
    padding: .45rem .6rem;
    border: 1px solid #c3d4ca;
    border-radius: 8px;
    font: inherit;
    background: var(--surface);
    color: var(--text);
}

:where(input:not([type="checkbox"], [type="radio"], [type="file"], [type="range"], [type="color"], [type="hidden"],
        [type="submit"], [type="button"], [type="reset"], [type="image"]), select, textarea):focus {
    outline: 2px solid var(--primary-soft);
    border-color: var(--primary);
}

:where(input, select, textarea):disabled {
    background: var(--surface-muted);
    color: var(--text-muted);
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

h1, h2, h3 {
    margin: 0;
    line-height: 1.25;
    font-family: var(--font-head);
    color: var(--text);
}

.skip-link {
    position: absolute;
    left: -999px;
}

.skip-link:focus {
    left: 1rem;
    top: 1rem;
    z-index: 1000;
    background: var(--surface);
    padding: .5rem 1rem;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

.muted {
    color: var(--text-muted);
}

/* ------------------------------------------------------------ layout */

.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 50;
}

.brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 1.1rem 1.25rem;
    color: var(--text);
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 1rem;
}

.brand-logo {
    flex: none;
    width: 30px;
    height: 30px;
}

.brand-sub {
    font-weight: 400;
    color: var(--primary);
}

.topbar-title .brand-logo {
    width: 24px;
    height: 24px;
    vertical-align: -6px;
}

.nav {
    flex: 1;
    overflow-y: auto;
    padding: .25rem .75rem 1rem;
}

/* Phase 12 menu (js/nav.js): links, area buttons (top level) and Back share one look */
.nav-link, .nav-area, .nav-back {
    display: flex;
    align-items: center;
    gap: .7rem;
    width: 100%;
    padding: .5rem .75rem;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--sidebar-text);
    font: inherit;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
}

.nav-link i, .nav-area i, .nav-back i, .nav-area-title i {
    width: 1.1rem;
    text-align: center;
    color: var(--steel);
}

.nav-link:hover, .nav-area:hover, .nav-back:hover {
    background: var(--surface-muted);
    color: var(--text);
    text-decoration: none;
}

.nav-link:focus-visible, .nav-area:focus-visible, .nav-back:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: -2px;
}

.nav-link.active {
    background: var(--sidebar-active);
    color: var(--primary);
    font-weight: 700;
}

.nav-link.active i {
    color: var(--primary);
}

.nav-label {
    flex: 1;
    min-width: 0;
}

/* The area that holds the current page (top level) */
.nav-area.current {
    color: var(--primary);
    font-weight: 700;
}

.nav-area.current i {
    color: var(--primary);
}

.nav-area .nav-area-chevron {
    width: auto;
    font-size: .75rem;
    color: var(--steel);
}

.nav-back {
    color: var(--text-muted);
    font-size: .9rem;
}

.nav-area-title {
    display: flex;
    align-items: center;
    gap: .7rem;
    margin: .75rem .75rem .35rem;
    padding-top: .75rem;
    border-top: 1px solid var(--border);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--primary);
}

/* Activities and Messages: overdue / due today and awaiting a reply */
.nav-badge {
    flex: none;
    min-width: 1.4rem;
    padding: .05rem .4rem;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    line-height: 1.3;
    text-align: center;
}

.nav-link.active .nav-badge {
    background: var(--primary);
    color: #fff;
}

.nav [hidden] {
    display: none;
}

.account {
    border-top: 1px solid var(--border);
    padding: .9rem 1rem;
    display: flex;
    flex-direction: column;
    gap: .6rem;
}

.account-info {
    display: flex;
    align-items: center;
    gap: .6rem;
}

.account-info > i {
    font-size: 1.6rem;
    color: var(--steel);
}

.account-name {
    color: var(--text);
    font-weight: 600;
    overflow-wrap: anywhere;
}

.account-role {
    font-size: .8rem;
    color: var(--text-muted);
}

.main {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-width);
}

.topbar {
    display: none;
}

.view {
    padding: 1.75rem 2rem 3rem;
    max-width: 1400px;
    outline: none;
}

/* ------------------------------------------------------------ page */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.page-header h1 {
    font-size: 1.6rem;
}

.page-subtitle {
    margin: .25rem 0 0;
    color: var(--text-muted);
}

.back-link {
    display: inline-block;
    margin-bottom: .35rem;
    font-size: .9rem;
}

.page-actions, .card-actions, .row-actions {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}

.row-actions {
    justify-content: flex-end;
    flex-wrap: nowrap;
}

.card, .table-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.25rem;
}

.card {
    padding: 1.1rem 1.25rem;
}

.card > .table-card, .card > .async-section > .table-card {
    border: 0;
    box-shadow: none;
    margin: 0 -1.25rem -1.1rem;
    border-radius: 0 0 var(--radius) var(--radius);
}

/* A list with more content after it in the same card (a heading and a second list, the messages and buttons of a
   preview): still the card's full width, but with its bottom line and the space below - the negative bottom margin
   of the last list pulled the next part over the list's last row */
.card > .table-card:not(:last-child) {
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
}

.card-intro {
    margin: -.4rem 0 .9rem;
}

/* Filters of a card's list (country, year, ...) above its table */
.card-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .6rem 1rem;
    margin: 0 -1.25rem;
    padding: .2rem 1.25rem .75rem;
    border-bottom: 1px solid var(--border);
}

/* Long country names must not widen the page on phones */
.card-filters .filter {
    max-width: 100%;
    min-width: 0;
}

.card-filters .filter select {
    min-width: 0;
    max-width: 100%;
}

.card-filters-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    margin-left: auto;
}

.async-section.is-loading > * {
    opacity: .45;
    transition: opacity .15s;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: .9rem;
}

.card-header h2 {
    font-size: 1.05rem;
}

.detail-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: .9rem 1.5rem;
    margin: 0;
}

.detail-item dt {
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
}

.detail-item dd {
    margin: .15rem 0 0;
    overflow-wrap: anywhere;
}

/* ------------------------------------------------------------ dashboard */

.metric-label {
    font-size: .82rem;
    color: var(--text-muted);
    font-weight: 600;
}

.metric-value {
    font-size: 1.45rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- dashboard: sections, key figures, charts */
.dash-section {
    --accent: var(--primary);
    --accent-soft: var(--primary-soft);
    margin-bottom: 1.75rem;
}

.dash-aftersales {
    --accent: var(--primary);
    --accent-soft: var(--primary-soft);
}

.dash-pricing {
    --accent: var(--primary);
    --accent-soft: var(--primary-soft);
}

.dash-stock {
    --accent: var(--primary);
    --accent-soft: var(--primary-soft);
}

.dash-finance {
    --accent: var(--success);
    --accent-soft: var(--success-soft);
}

.dash-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: .85rem;
}

.dash-section-head h2 {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin: 0;
    font-size: 1.1rem;
}

.dash-section-icon {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-size: .9rem;
}

.dash-link {
    font-size: .85rem;
    font-weight: 600;
    white-space: nowrap;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

/* A section with one or two figures: tiles about as wide as in the fuller sections, not stretched over the row */
.kpi-grid-few {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr));
}

.kpi {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: .45rem;
    min-width: 0;
    padding: 1rem 1.1rem 1rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    color: var(--text);
    overflow: hidden;
}

.kpi::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--accent);
}

a.kpi:hover {
    text-decoration: none;
    border-color: var(--accent);
    transform: translateY(-1px);
}

.kpi-head {
    display: flex;
    align-items: center;
    gap: .55rem;
    min-width: 0;
}

.kpi-icon {
    flex: none;
    display: grid;
    place-items: center;
    width: 1.9rem;
    height: 1.9rem;
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: .85rem;
}

/* A long label wraps to a second line instead of being cut off */
.kpi-label {
    min-width: 0;
    overflow-wrap: anywhere;
    line-height: 1.25;
    font-size: .82rem;
    font-weight: 600;
    color: var(--text-muted);
}

.kpi-value {
    display: flex;
    align-items: baseline;
    gap: .35rem;
    overflow: hidden;
    white-space: nowrap;
    font-size: clamp(1.35rem, 1.05rem + .9vw, 1.85rem);
    font-weight: 700;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.01em;
}

.kpi-unit {
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.kpi-note {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .78rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.dash-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.dash-charts .card,
.dash-section > .card {
    margin: 0;
}

.dash-chart h3 {
    margin: 0;
    font-size: .95rem;
}

.dash-chart-box {
    position: relative;
    height: 260px;
    margin-top: .75rem;
}

.dash-empty {
    margin: 1.5rem 0 .5rem;
    color: var(--text-muted);
}

@media (max-width: 600px) {
    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: .6rem;
    }

    .kpi {
        padding: .8rem .8rem .8rem 1rem;
    }

    .kpi-icon {
        display: none;
    }

    .kpi-value {
        font-size: 1.25rem;
    }

    .kpi-note {
        white-space: normal;
    }
}

/* A chart on a row of its own (e.g. a bar per account manager) */
.dash-charts .dash-chart-full {
    grid-column: 1 / -1;
}

@media (min-width: 1100px) {
    .dash-charts:has(.dash-chart-wide) {
        grid-template-columns: 2fr 1fr;
    }

    .dash-charts .dash-chart-wide:only-child,
    .dash-charts .dash-chart:only-child {
        grid-column: 1 / -1;
    }
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.summary-card {
    padding: 1rem 1.1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    border-left-width: 4px;
}

.summary-info { border-left-color: var(--info); }
.summary-success { border-left-color: var(--success); }
.summary-warning { border-left-color: var(--warning); }
.summary-neutral { border-left-color: var(--text-muted); }

/* ------------------------------------------------------------ tabs */

.tabs {
    margin-bottom: 1.25rem;
}

.tab-list {
    display: flex;
    gap: .25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
    overflow-x: auto;
}

.tab {
    border: 0;
    background: none;
    padding: .6rem 1rem;
    font: inherit;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
}

.tab[aria-selected="true"] {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-panel:focus {
    outline: none;
}

.tab-count {
    margin-left: .4rem;
    padding: 0 .45rem;
    border-radius: 999px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    font-size: .75rem;
}

/* ------------------------------------------------------------ tables */

.table-toolbar {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    flex: 1 1 240px;
    max-width: 360px;
}

.search-box i {
    position: absolute;
    left: .7rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: .85rem;
}

.search-input {
    width: 100%;
    padding: .45rem .75rem .45rem 2rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    background: var(--surface-muted);
}

.table-count {
    color: var(--text-muted);
    font-size: .85rem;
    margin-right: auto;
}

.table-scroll {
    position: relative; /* contains the absolutely positioned (visually hidden) header labels */
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th, .data-table td {
    padding: .6rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    white-space: nowrap;
}

/* Free-text columns wrap instead of widening the table */
.data-table td.wrap {
    white-space: normal;
    min-width: 14rem;
    max-width: 28rem;
}

.data-table th {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    background: var(--surface-muted);
    white-space: nowrap;
    user-select: none;
}

.data-table th.sortable {
    cursor: pointer;
}

.data-table th[aria-sort="ascending"] .sort-indicator::after { content: " ▲"; }
.data-table th[aria-sort="descending"] .sort-indicator::after { content: " ▼"; }

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.data-table tr.clickable {
    cursor: pointer;
}

.data-table tr.clickable:hover, .data-table tr.clickable:focus {
    background: var(--primary-soft);
    outline: none;
}

.data-table td.empty {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem 1rem;
}

/* The totals row of a report table (e.g. the aging buckets): set off from the rows above, in bold */
.data-table tfoot th, .data-table tfoot td {
    border-top: 2px solid var(--border);
    border-bottom: 0;
    background: var(--surface-muted);
    font-weight: 700;
}

.data-table tfoot th {
    font-size: inherit;
    text-transform: none;
    letter-spacing: normal;
    color: var(--text);
}

.align-right {
    text-align: right !important;
    font-variant-numeric: tabular-nums;
}

.actions-col {
    width: 1%;
    white-space: nowrap;
}

/* Server-paged tables: filters in the toolbar, pager in the footer */
.filter {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .85rem;
    color: var(--text-muted);
}

.filter select, .filter input:not([type="checkbox"]):not([type="radio"]) {
    padding: .4rem .5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    color: var(--text);
    background: var(--surface);
}

.filter .lookup {
    width: 14rem;
}

.table-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: .6rem 1rem;
    border-top: 1px solid var(--border);
    font-size: .85rem;
    color: var(--text-muted);
}

.pager {
    display: flex;
    gap: .4rem;
}

.data-table.is-loading tbody {
    opacity: .45;
    transition: opacity .15s;
}

.error-text {
    color: var(--danger) !important;
}

/* Type-ahead lookup (customers, vendors, products, orders) */
.lookup {
    position: relative;
    width: 100%;
}

.lookup > i {
    position: absolute;
    left: .65rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: .8rem;
    pointer-events: none;
}

.lookup .lookup-input {
    width: 100%;
    padding: .5rem .65rem .5rem 1.9rem;
    border: 1px solid #c3d4ca;
    border-radius: 8px;
    font: inherit;
    background: var(--surface);
    color: var(--text);
}

.lookup .lookup-input:focus {
    outline: 2px solid var(--primary-soft);
    border-color: var(--primary);
}

.lookup .lookup-input:disabled {
    background: var(--surface-muted);
    color: var(--text-muted);
}

/* A lookup in a filter bar keeps the room for its search icon (the filter inputs' padding would cover it) */
.filter .lookup input.lookup-input {
    padding-left: 1.9rem;
}

.lookup-list {
    position: absolute;
    z-index: 30;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    margin: 0;
    padding: .25rem;
    list-style: none;
    max-height: 16rem;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
}

.lookup-list li {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: .45rem .6rem;
    border-radius: 6px;
    cursor: pointer;
}

.lookup-list li small {
    color: var(--text-muted);
    white-space: nowrap;
}

.lookup-list li.active, .lookup-list li:hover {
    background: var(--primary-soft);
}

.lookup-list li.lookup-empty {
    color: var(--text-muted);
    cursor: default;
}

/* ------------------------------------------------------------ buttons and badges */

.btn {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .5rem .95rem;
    border-radius: 8px;
    border: 1px solid transparent;
    font: inherit;
    font-weight: 600;
    font-size: .9rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, border-color .15s;
}

/* the class sets display: hidden buttons (e.g. the only lot row's remove) stay hidden */
.btn[hidden] {
    display: none;
}

.btn:disabled {
    opacity: .6;
    cursor: progress;
}

.btn-sm {
    padding: .3rem .6rem;
    font-size: .82rem;
}

.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-hover); color: var(--brand-ink); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-muted); border-color: #c3d4ca; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-muted); color: var(--text); }
.btn-ghost-danger { background: transparent; color: var(--danger); }
.btn-ghost-danger:hover { background: var(--danger-soft); }
.btn-ghost-light { background: transparent; color: var(--primary); border-color: var(--brand); }
.btn-ghost-light:hover { background: var(--sidebar-active); color: var(--primary); }

.badge {
    display: inline-block;
    padding: .12rem .55rem;
    border-radius: 999px;
    font-size: .76rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-success { background: var(--success-soft); color: var(--success); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-neutral { background: var(--surface-muted); color: var(--text-muted); border: 1px solid var(--border); }

/* ------------------------------------------------------------ notices, loading */

.notice, .error-panel {
    display: flex;
    gap: .75rem;
    align-items: flex-start;
    padding: .85rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
}

/* A notice shown only when needed (e.g. the credit note limit warning) is hidden with the attribute */
.notice[hidden] {
    display: none;
}

.notice-warning {
    background: var(--warning-soft);
    color: var(--warning);
    border: 1px solid #fde68a;
}

.notice-info {
    background: var(--info-soft);
    color: var(--info);
    border: 1px solid #bae6fd;
}

.notice > i {
    margin-top: .2rem;
}

.notice p {
    margin: .2rem 0 0;
}

.error-panel {
    background: var(--danger-soft);
    color: #991b1b;
    border: 1px solid #fecaca;
    align-items: center;
}

.error-panel > div {
    flex: 1;
}

.error-panel p {
    margin: .2rem 0 0;
}

.loading {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 3rem 0;
    color: var(--text-muted);
    justify-content: center;
}

.spinner {
    width: 1.2rem;
    height: 1.2rem;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.erp-banner {
    position: sticky;
    top: 0;
    z-index: 200;
    padding: .75rem 1.25rem;
    background: #fef3c7;
    color: #92400e;
    border-bottom: 1px solid #f59e0b;
    font-weight: 600;
    text-align: center;
}

/* ------------------------------------------------------------ toasts */

.toasts {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    z-index: 1100;
    max-width: min(420px, calc(100vw - 2rem));
}

.toast {
    display: flex;
    gap: .6rem;
    align-items: flex-start;
    padding: .75rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    border-left: 4px solid var(--steel);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
    transition: opacity .4s, transform .4s;
}

.toast i { margin-top: .2rem; }
.toast-success { border-left-color: var(--brand); }
.toast-success i { color: var(--success); }
.toast-error { border-left-color: var(--danger); background: var(--danger-soft); }
.toast-error i { color: var(--danger); }
.toast-warning { border-left-color: var(--warning); background: var(--warning-soft); }
.toast-warning i { color: var(--warning); }
.toast-leaving { opacity: 0; transform: translateY(8px); }

/* ------------------------------------------------------------ dialogs and forms */

.modal {
    border: 0;
    border-radius: 14px;
    padding: 0;
    width: min(560px, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    box-shadow: var(--shadow-lg);
    color: var(--text);
}

.modal-wide {
    width: min(780px, calc(100vw - 2rem));
}

.modal::backdrop {
    background: rgba(15, 23, 42, .5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.1rem 1.4rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.15rem;
}

.modal-close {
    border: 0;
    background: none;
    font-size: 1.1rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: .25rem .5rem;
}

.modal-body {
    padding: 1.2rem 1.4rem 2rem;
    overflow-y: auto;
    max-height: calc(100vh - 12rem);
    min-height: 12rem;
}

.modal-body > p {
    margin-top: 0;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    padding: .9rem 1.4rem;
    border-top: 1px solid var(--border);
    background: var(--surface-muted);
}

.form-intro {
    color: var(--text-muted);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: .9rem 1rem;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: .3rem;
}

.form-field-wide {
    grid-column: 1 / -1;
}

.form-field label {
    font-size: .85rem;
    font-weight: 600;
}

.form-field input, .form-field select, .form-field textarea {
    width: 100%;
    padding: .5rem .65rem;
    border: 1px solid #c3d4ca;
    border-radius: 8px;
    font: inherit;
    background: var(--surface);
    color: var(--text);
}

.form-field input:focus, .form-field select:focus, .form-field textarea:focus, .search-input:focus {
    outline: 2px solid var(--primary-soft);
    border-color: var(--primary);
}

.form-field input:disabled, .form-field select:disabled {
    background: var(--surface-muted);
    color: var(--text-muted);
}

.form-check {
    flex-direction: row;
    align-items: center;
    gap: .5rem;
    grid-column: 1 / -1;
}

.form-check input {
    width: 1.05rem;
    height: 1.05rem;
}

.form-check label {
    font-weight: 500;
}

.form-check:has(.form-check-text) {
    align-items: flex-start;
}

.form-check:has(.form-check-text) input {
    margin-top: .2rem;
}

.form-check-text {
    display: flex;
    flex-direction: column;
    gap: .1rem;
    min-width: 0;
}

.required {
    color: var(--danger);
}

.form-help {
    color: var(--text-muted);
    font-size: .78rem;
}

/* Below a document date (js/calendar.js): the proposal, a hint, or the warning about a non-working day */
.date-note:empty {
    display: none;
}

.date-warning {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem .5rem;
    padding: .4rem .6rem;
    border: 1px solid #fde68a;
    border-radius: 8px;
    background: var(--warning-soft);
    color: var(--warning);
    font-size: .8rem;
}

/* Several choices (roles of a user, permissions of a role) */
.form-fieldset {
    border: 0;
    margin: 0;
    padding: 0;
    min-width: 0;
}

.form-fieldset > legend {
    padding: 0;
    margin-bottom: .3rem;
    font-size: .85rem;
    font-weight: 600;
}

.form-fieldset > .form-help {
    display: block;
    margin-bottom: .5rem;
}

.check-groups {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: .75rem;
}

.check-group {
    margin: 0;
    padding: .6rem .8rem .7rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-muted);
    min-width: 0;
}

.check-group-plain {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: .2rem 1rem;
}

.check-group > legend {
    padding: 0 .3rem;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.check-item {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    padding: .25rem 0;
}

.check-item input {
    flex: none;
    width: 1.05rem;
    height: 1.05rem;
    margin: .15rem 0 0;
}

.check-item label {
    font-size: .9rem;
    font-weight: 500;
    cursor: pointer;
}

.check-item .form-help {
    display: block;
}

.check-all {
    border-bottom: 1px solid var(--border);
    margin-bottom: .2rem;
    padding-bottom: .4rem;
}

.check-all label {
    font-weight: 600;
}

/* A form on the page itself (company settings) */
.form-panel-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: .5rem;
    margin-top: 1.1rem;
}

.number-example {
    font-family: var(--font-body);
    font-variant-numeric: tabular-nums;
    font-size: .88em;
    padding: .05rem .35rem;
    border-radius: 4px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    color: var(--text);
}

.form-error {
    padding: .7rem .9rem;
    margin-bottom: 1rem;
    border-radius: 8px;
    background: var(--danger-soft);
    color: #991b1b;
    border: 1px solid #fecaca;
}


/* Filter bar of a server-searched list (filter first: nothing is read before a filter is chosen) */
.table-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem 1rem;
    padding: .6rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-muted);
}

.table-filters .filter {
    min-width: 0;
    max-width: 100%;
}

.table-filters .filter select {
    min-width: 0;
    max-width: 16rem;
}

.filter-text input {
    width: 9rem;
}

.data-table td.empty .fa-filter {
    margin-right: .2rem;
}

/* Several values of a filter (statuses): a drop-down of checkboxes */
.multi-select {
    position: relative;
}

.multi-select > summary {
    display: flex;
    align-items: center;
    gap: .5rem;
    min-width: 8rem;
    max-width: 16rem;
    padding: .4rem .6rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    list-style: none;
}

.multi-select > summary::-webkit-details-marker {
    display: none;
}

.multi-select > summary:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

.multi-select > summary i {
    font-size: .7rem;
    color: var(--text-muted);
}

.multi-select-value {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.multi-select-panel {
    position: absolute;
    z-index: 30;
    top: calc(100% + 4px);
    left: 0;
    min-width: 100%;
    width: max-content;
    max-width: min(18rem, calc(100vw - 2rem));
    max-height: 18rem;
    overflow-y: auto;
    padding: .4rem .75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    color: var(--text);
}

.multi-select-panel .check-group-plain {
    grid-template-columns: 1fr;
}

/* Tables whose rows are chosen with checkboxes */
.select-col {
    width: 1%;
}

.select-col input {
    width: 1.05rem;
    height: 1.05rem;
    margin: 0;
    vertical-align: middle;
}

/* Wizards (new shipment, new invoice): numbered steps */
.wizard-step .card-header {
    margin-bottom: .6rem;
}

.wizard-step-body > p:last-child {
    margin-bottom: 0;
}

.wizard-customer {
    max-width: 32rem;
}

.wizard-table {
    margin: 0 -1.25rem .75rem;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.qty-input {
    width: 5.5rem;
    padding: .35rem .5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    text-align: right;
}

.qty-input:invalid {
    border-color: var(--danger);
}

.cell-note {
    display: block;
}

.wizard-weight {
    margin: .25rem 0 0;
}

.wizard-country {
    margin-bottom: .75rem;
}

/* Carrier quotes of a new shipment: one radio button per carrier service */
.quote-options {
    margin-bottom: 1rem;
}

.quote-list {
    margin: 0;
    padding: .5rem .75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    min-width: 0;
}

.quote-list > legend {
    padding: 0 .3rem;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.quote-option {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .4rem 0;
    border-bottom: 1px solid var(--border);
}

.quote-option:last-child {
    border-bottom: 0;
}

.quote-option input {
    flex: none;
    width: 1.05rem;
    height: 1.05rem;
    margin: .2rem 0 0;
}

.quote-option label {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0 1rem;
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.quote-name {
    font-weight: 600;
}

.quote-price {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.quote-option small {
    grid-column: 1 / -1;
}

.quote-submit {
    justify-content: flex-end;
}

.quote-result {
    margin-top: 1rem;
}

/* ------------------------------------------------------------ catalogue and stock (js/catalogue.js) */

.features-editor .feature-list {
    list-style: none;
    margin: 0 0 .5rem;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: .4rem;
}

.feature-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto;
    gap: .4rem;
    align-items: center;
}

.feature-buttons {
    display: flex;
    gap: .15rem;
}

.feature-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .75rem;
}

.feature-empty {
    margin: 0 0 .5rem;
}

.feature-table th[scope="row"] {
    font-weight: 600;
    white-space: nowrap;
}

.product-overview .detail-list {
    margin-bottom: 1.25rem;
}

.overview-section {
    border-top: 1px solid var(--border);
    padding-top: .9rem;
    margin-top: .9rem;
}

.overview-section h3 {
    margin: 0 0 .6rem;
    font-size: .95rem;
}

.overview-section p {
    margin: 0;
}

.chip-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
}

.chip {
    display: inline-block;
    max-width: 100%;
    padding: .2rem .65rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-muted);
    font-size: .85rem;
    overflow-wrap: anywhere;
}

.chip-primary {
    border-color: var(--primary);
    background: var(--primary-soft);
}

/* Phase 6: fields hidden by the form (e.g. the stock fields of a virtual product) */
.form-field[hidden], .form-help[hidden] {
    display: none;
}

.virtual-help {
    margin-top: -.6rem;
}

.overview-section .feature-note {
    margin-bottom: .6rem;
    font-size: .85rem;
}

/* AllFeatures: one row group per feature name, the name spanning its values */
.feature-table tbody.feature-group + tbody.feature-group {
    border-top: 2px solid var(--border);
}

.feature-table th[scope="rowgroup"] {
    font-weight: 600;
    white-space: nowrap;
    vertical-align: top;
}

.category-features {
    margin-bottom: .75rem;
}

/* Picture galleries (js/pictures.js): thumbnails in order, the first marked main */
.picture-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem .9rem;
    margin-bottom: .75rem;
}

.picture-upload {
    position: relative;
}

.picture-upload:focus-within {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.picture-upload:has(input:disabled) {
    opacity: .6;
    cursor: progress;
}

.picture-upload-status:empty {
    display: none;
}

.picture-upload-status {
    margin-bottom: .75rem;
    padding: .6rem .8rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-muted);
}

.picture-upload-status progress {
    width: 100%;
    max-width: 320px;
}

.upload-summary {
    margin: 0 0 .35rem;
    font-weight: 600;
}

.upload-list {
    list-style: none;
    margin: .35rem 0 0;
    padding: 0;
    font-size: .85rem;
}

.upload-list li {
    display: flex;
    flex-wrap: wrap;
    gap: .2rem .6rem;
}

.upload-name {
    overflow-wrap: anywhere;
}

.upload-done { color: var(--success); }
.upload-error { color: var(--danger); }
.upload-busy, .upload-waiting { color: var(--text-muted); }

.picture-empty {
    margin: 0;
}

.picture-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr));
    gap: .75rem;
}

.picture-list[hidden] {
    display: none;
}

.picture-item {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
    min-width: 0;
}

.picture-item-main {
    border-color: var(--primary);
}

.picture-figure {
    margin: 0;
    flex: 1;
}

.picture-frame {
    position: relative;
    aspect-ratio: 4 / 3;
    background: var(--surface-muted);
}

.picture-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* An image that cannot be read: its alternative text in an empty box */
.picture-broken {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: .5rem;
    font-size: .8rem;
    color: var(--text-muted);
    text-align: center;
}

.picture-main {
    position: absolute;
    top: .4rem;
    left: .4rem;
}

.picture-caption {
    padding: .45rem .6rem 0;
    font-size: .85rem;
    overflow-wrap: anywhere;
}

.picture-actions {
    display: flex;
    justify-content: flex-end;
    gap: .1rem;
    padding: .3rem .4rem .4rem;
}

.category-filter {
    margin-bottom: 1rem;
}

.category-list {
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

.category-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-width: 0;
}

.category-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .3rem .6rem;
    padding: .8rem 1.1rem;
    cursor: pointer;
}

.category-summary::marker {
    color: var(--text-muted);
}

.category-name {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.category-body {
    padding: 0 1.1rem 1rem;
    min-width: 0;
}

.category-body > p {
    margin: 0 0 .75rem;
}

.category-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: .75rem;
}

.assign-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1rem;
    margin-bottom: .75rem;
}

.assign-toolbar .filter {
    flex: 1 1 14rem;
    min-width: 0;
}

.assign-toolbar .filter input,
.assign-toolbar .filter select {
    flex: 1 1 auto;
    min-width: 0;
}

.assign-toolbar .search-input {
    padding-left: .75rem;
}

.assign-results {
    min-height: 4rem;
}

.assign-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: .5rem;
    margin-top: .75rem;
}

.assign-actions > span {
    margin-right: auto;
}

.stock-import-form input[type="file"] {
    padding: .4rem;
}

.stock-import-actions {
    flex-direction: row;
    flex-wrap: wrap;
    gap: .5rem;
}

.format-list {
    margin: 0;
    padding-left: 1.2rem;
}

.format-list li + li {
    margin-top: .3rem;
}

/* ------------------------------------------------------------ customers, suppliers and portals (js/parties.js, js/portal-admin.js) */

/* Two lines in one table cell: the main text, then a smaller muted line */
.cell-stack {
    display: flex;
    flex-direction: column;
    gap: .1rem;
    min-width: 0;
}

.cell-stack > small {
    color: var(--text-muted);
    overflow-wrap: anywhere;
}

.badge-row {
    display: inline-flex;
    flex-wrap: wrap;
    gap: .3rem;
}

.status-stack {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: .1rem;
}

/* The main address and main contact above the details of a customer or supplier */
.party-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.party-summary-item {
    padding: .75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-muted);
    overflow-wrap: anywhere;
}

.party-summary-item h3 {
    margin: 0 0 .4rem;
    font-size: .8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
}

.party-summary-item address {
    font-style: normal;
}

.iban {
    font-family: var(--font-body);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Portal access of a customer's contact: status, role and the account actions */
.portal-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: .3rem;
    min-width: 11rem;
    /* The account actions wrap instead of widening the contacts table */
    max-width: 20rem;
}

.portal-status {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem;
}

.portal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
}

/* A one-time secret (temporary password) with its copy button */
.secret-box {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    margin-top: 1rem;
}

.secret-box label {
    font-weight: 600;
}

.secret-row {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.secret-value {
    flex: 1 1 12rem;
    min-width: 0;
    padding: .5rem .65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-muted);
    font-family: var(--font-body);
    font-variant-numeric: tabular-nums;
    font-size: 1rem;
}

.dialog-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: .5rem;
    margin-top: 1rem;
}

.similar-customers {
    display: block;
    margin-top: .5rem;
}

.pre-line {
    white-space: pre-line;
}

/* ------------------------------------------------------------ integration hub (js/integration.js) */

.notice-success {
    background: var(--success-soft);
    color: var(--success);
    border: 1px solid #a8e6cf;
}

.direction {
    white-space: nowrap;
}

.direction i {
    color: var(--text-muted);
}

/* Long values without spaces (URLs, file names, errors) break instead of widening a table or dialog */
.cell-break {
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* A heading row inside a form grid */
.form-section {
    border-top: 1px solid var(--border);
    padding-top: .75rem;
    margin-top: .25rem;
}

.form-section h3 {
    margin: 0;
    font-size: .95rem;
}

.form-section .form-help {
    margin: .25rem 0 0;
}

.form-label {
    font-size: .85rem;
    font-weight: 600;
}

/* Name/value rows: extra HTTP headers, outbound column mapping */
.kv-list {
    display: flex;
    flex-direction: column;
    gap: .4rem;
    margin: .4rem 0;
}

.kv-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: .4rem;
    align-items: center;
}

.kv-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: .25rem;
}

/* Inbound mapping: a canonical field and the partner's source per row */
.mapping-list {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    margin-top: .4rem;
}

.mapping-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
    gap: .5rem;
    align-items: center;
    padding: .3rem 0;
    border-bottom: 1px solid var(--border);
}

.mapping-row:last-child {
    border-bottom: 0;
}

.mapping-field {
    display: flex;
    flex-direction: column;
    gap: .05rem;
    min-width: 0;
}

.mapping-field code, .push-url, .payload-excerpt {
    font-family: var(--font-body);
    font-variant-numeric: tabular-nums;
}

.mapping-field small {
    color: var(--text-muted);
    font-weight: 400;
    overflow-wrap: anywhere;
}

.push-url {
    display: block;
    padding: .45rem .65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-muted);
    overflow-wrap: anywhere;
}

/* The channel form's steps */
.wizard-steps {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
}

.wizard-step-button {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .35rem .7rem .35rem .4rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: .85rem;
    cursor: pointer;
}

.wizard-step-number {
    display: inline-grid;
    place-items: center;
    width: 1.45rem;
    height: 1.45rem;
    border-radius: 50%;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    font-weight: 600;
    font-size: .8rem;
}

.wizard-step-button.done .wizard-step-number {
    background: var(--success-soft);
    border-color: #a8e6cf;
    color: var(--success);
}

.wizard-step-button[aria-current="step"] {
    border-color: var(--primary);
    background: var(--primary-soft);
    font-weight: 600;
}

.wizard-step-button[aria-current="step"] .wizard-step-number {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.wizard-section {
    border: 0;
    margin: 0;
    padding: 0;
    min-width: 0;
}

.wizard-section > legend {
    padding: 0;
    margin-bottom: .75rem;
    font-weight: 600;
}

.dialog-subheading {
    margin: 1.25rem 0 .5rem;
    font-size: 1rem;
}

.recent-messages {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: .35rem;
}

/* A message's payload: text as received, scrollable inside the dialog */
.payload-excerpt {
    margin: 0;
    padding: .75rem 1rem;
    max-height: 22rem;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-muted);
    font-size: .82rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* ------------------------------------------------------------ purchasing (js/purchasing.js) */

/* A button inside a notice (e.g. "Recalculate VAT" of a purchase order with legacy VAT) */
.notice-actions {
    margin-top: .6rem;
}

/* Net, VAT and gross totals below the lines of a purchase order or purchase invoice */
.doc-totals {
    display: grid;
    gap: .2rem;
    width: min(100%, 20rem);
    margin: 1rem 0 0 auto;
}

.doc-total {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.doc-total dt {
    color: var(--text-muted);
}

.doc-total dd {
    margin: 0;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.doc-total-grand {
    padding-top: .35rem;
    border-top: 1px solid var(--border);
    font-weight: 700;
}

.doc-total-grand dt {
    color: var(--text);
}

/* The lines editor of a manual purchase invoice */
.pi-lines-section {
    margin-top: 1.25rem;
}

.pi-lines-section h3 {
    margin: 0 0 .6rem;
    font-size: 1rem;
}

.pi-lines {
    display: grid;
    gap: .75rem;
}

.pi-line {
    min-width: 0;
    margin: 0;
    padding: .75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-muted);
}

.pi-line > legend {
    padding: 0 .3rem;
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.pi-line-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 2fr) minmax(5rem, .7fr) minmax(6rem, .9fr) minmax(8rem, 1fr);
    gap: .6rem .75rem;
    align-items: end;
}

.pi-line-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: .4rem;
}

.pi-lines-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .5rem 1rem;
    margin-top: .75rem;
}

.pi-lines-footer .wizard-weight {
    margin: 0;
}

@media (max-width: 900px) {
    .pi-line-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .pi-line-description, .pi-line-product {
        grid-column: 1 / -1;
    }
}

@media (max-width: 480px) {
    .pi-line-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .pi-line {
        padding: .6rem .7rem;
    }
}

/* ------------------------------------------------------------ sales orders, shipments and invoices (js/sales.js) */

/* Where an order came from: ERP, Shop, Business portal, Integration */
.source-badge {
    background: var(--surface-muted);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.source-shop { background: #eaf9f0; color: #187c50; border-color: #a8e6cf; }
.source-business { background: #d4f2e2; color: #146943; border-color: #7ddcae; }
.source-integration { background: var(--surface-muted); color: var(--text); border-color: var(--border); }

/* The VAT treatment of a document */
.vat-badge {
    background: var(--info-soft);
    color: var(--info);
}

.vat-reverse-charge { background: var(--warning-soft); color: var(--warning); }
.vat-export, .vat-zero-rated, .vat-exempt { background: var(--surface-muted); color: var(--text-muted); border: 1px solid var(--border); }

/* The reverse-charge note, printed on the invoice: shown above the details */
.vat-note {
    border-left-width: 4px;
}

.vat-note-text {
    display: block;
    margin-top: .2rem;
    font-weight: 600;
    overflow-wrap: anywhere;
}

/* Net, VAT and gross totals: label left, amount right */
.vat-totals {
    display: grid;
    gap: .35rem;
    max-width: 26rem;
    margin: 0 0 .75rem auto;
}

.vat-total-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
}

.vat-total-row dt {
    color: var(--text-muted);
}

.vat-total-row dd {
    margin: 0;
    font-variant-numeric: tabular-nums;
    text-align: right;
    overflow-wrap: anywhere;
}

.vat-total-gross {
    padding-top: .35rem;
    border-top: 1px solid var(--border);
    font-size: 1.05rem;
}

/* A refused change with what to do about it (e.g. insufficient stock, customer without address) */
.problem-box[hidden] {
    display: none;
}

.problem-box {
    align-items: flex-start;
}

.problem-box > i {
    margin-top: .2rem;
}

.problem-box strong {
    overflow-wrap: anywhere;
}

.stock-note {
    margin: .9rem 0 0;
}

/* ------------------------------------------------------------ small screens */

@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform .2s;
    }

    .menu-open .sidebar {
        transform: none;
        box-shadow: var(--shadow-lg);
    }

    .main {
        margin-left: 0;
    }

    /* Finger-sized menu entries in the drawer */
    .nav-link, .nav-area, .nav-back {
        min-height: 44px;
    }

    .topbar {
        display: flex;
        align-items: center;
        gap: .5rem;
        padding: .5rem 1rem;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        position: sticky;
        top: 0;
        z-index: 40;
    }

    .topbar-title {
        font-weight: 700;
    }

    .view {
        padding: 1.25rem 1rem 2.5rem;
    }

    .card-filters-actions {
        margin-left: 0;
    }
}

@media (max-width: 600px) {
    /* Filters one per row, label and control side by side */
    .table-filters .filter {
        flex: 1 1 100%;
    }

    .table-filters .filter > span:first-child {
        flex: 0 0 6.5rem;
    }

    .table-filters .filter select,
    .table-filters .filter input,
    .table-filters .filter .lookup,
    .table-filters .multi-select {
        flex: 1 1 auto;
        width: auto;
        min-width: 0;
        max-width: none;
    }

    .multi-select > summary {
        max-width: none;
    }

    .multi-select-panel {
        left: auto;
        right: 0;
    }

    .search-box {
        max-width: none;
    }
}

@media (max-width: 480px) {
    .check-groups, .check-group-plain {
        grid-template-columns: 1fr;
    }

    .feature-row {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .feature-row .feature-value {
        grid-column: 1;
    }

    .feature-row .feature-buttons {
        grid-column: 2;
        grid-row: 1 / span 2;
        flex-direction: column;
    }

    .card-header {
        flex-wrap: wrap;
    }

    /* Integration forms: the field above its source, steps as numbers only */
    .mapping-row {
        grid-template-columns: 1fr;
        gap: .25rem;
    }

    .kv-row {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .kv-row > input:nth-child(2) {
        grid-column: 1;
    }

    .kv-row > button {
        grid-column: 2;
        grid-row: 1 / span 2;
    }

    /* The step's name stays readable for screen readers */
    .wizard-step-button > span:last-child {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .wizard-step-button {
        padding: .3rem;
    }

    .modal-footer {
        flex-wrap: wrap;
    }

    .vat-totals {
        max-width: none;
        margin-left: 0;
    }

    .problem-box {
        flex-wrap: wrap;
    }
}

/* ------------------------------------------------------------ Administration > Modules (Phase 8) */

.module-id {
    font-size: .75rem;
    font-family: var(--font-body);
    font-variant-numeric: tabular-nums;
}

.module-problem {
    color: var(--danger);
    font-weight: 600;
}

.module-problem a {
    color: var(--danger);
    font-weight: 400;
}

/* An on/off switch (a checkbox with role="switch"); the label next to it says On or Off, so colour is not the only signal */
.module-switch-cell {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    white-space: nowrap;
}

.module-switch {
    appearance: none;
    position: relative;
    width: 2.4rem;
    height: 1.35rem;
    margin: 0;
    border-radius: 999px;
    background: var(--border);
    cursor: pointer;
    transition: background .15s ease;
}

.module-switch::before {
    content: "";
    position: absolute;
    top: .15rem;
    left: .15rem;
    width: 1.05rem;
    height: 1.05rem;
    border-radius: 50%;
    background: var(--surface);
    box-shadow: var(--shadow);
    transition: transform .15s ease;
}

.module-switch:checked {
    background: var(--success);
}

.module-switch:checked::before {
    transform: translateX(1.05rem);
}

.module-switch:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.module-switch:disabled {
    cursor: not-allowed;
    opacity: .55;
}

/* Paged tables: go to page ("Page [3] of 120" + Go) */
.page-nav {
    display: flex;
    align-items: center;
    gap: .4rem;
}

.page-jump {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
}

.page-jump[hidden],
.page-label[hidden] {
    display: none;
}

.page-input {
    width: 4.5em;
    padding: .2rem .35rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
    text-align: center;
}

.page-input[aria-invalid="true"] {
    border-color: var(--danger);
}

/* ---------------------------------------------------------------- Phase 12: role dashboard (js/dash-*.js) */
.dash-myday {
    --accent: var(--primary);
    --accent-soft: var(--primary-soft);
}

.dash-resolve {
    --accent: var(--warning);
    --accent-soft: var(--warning-soft);
}

.dash-products {
    --accent: var(--primary);
    --accent-soft: var(--primary-soft);
}

.dash-warehouse {
    --accent: var(--primary);
    --accent-soft: var(--primary-soft);
}

.dash-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.dash-cards .dash-card {
    margin: 0;
}

.dash-card {
    display: flex;
    flex-direction: column;
    gap: .6rem;
    min-width: 0;
    border-top: 3px solid var(--accent);
}

.dash-card-wide {
    grid-column: 1 / -1;
}

.dash-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    min-width: 0;
}

.dash-card-title {
    display: flex;
    align-items: center;
    gap: .55rem;
    min-width: 0;
    margin: 0;
    font-size: .95rem;
    overflow-wrap: anywhere;
}

.dash-card-icon {
    flex: none;
    display: grid;
    place-items: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: .8rem;
}

.dash-count {
    flex: none;
    min-width: 1.9rem;
    padding: .1rem .55rem;
    border-radius: 999px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: .8rem;
    font-weight: 700;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.dash-count-warning {
    background: var(--warning-soft);
    border-color: transparent;
    color: var(--warning);
}

.dash-count-danger {
    background: var(--danger-soft);
    border-color: transparent;
    color: var(--danger);
}

.dash-count-success {
    background: var(--success-soft);
    border-color: transparent;
    color: var(--success);
}

.dash-card-note {
    margin: 0;
    color: var(--text-muted);
    font-size: .82rem;
}

.dash-card-empty {
    margin: .25rem 0;
    font-size: .88rem;
}

.dash-card-empty .fa-circle-check {
    color: var(--success);
}

.dash-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.dash-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem .75rem;
    padding: .55rem 0;
    border-top: 1px solid var(--border);
}

.dash-row:first-child {
    border-top: 0;
    padding-top: .2rem;
}

.dash-row-main {
    display: flex;
    flex: 1 1 12rem;
    flex-direction: column;
    min-width: 0;
}

.dash-row-title {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.dash-row-detail {
    color: var(--text-muted);
    font-size: .8rem;
    overflow-wrap: anywhere;
}

.dash-row-danger .dash-row-title,
.dash-row-danger .dash-row-detail {
    color: var(--danger);
}

.dash-row-aside {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .85rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.dash-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    flex-basis: 100%;
}

.dash-type {
    display: grid;
    place-items: center;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: .75rem;
}

.dash-card-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin-top: auto;
    padding-top: .35rem;
}

.dash-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
}

.dash-show-all {
    margin-left: auto;
    font-size: .85rem;
    font-weight: 600;
    white-space: nowrap;
}

.dash-unavailable {
    border-top-color: var(--border);
}

.dash-unavailable-text {
    margin: 0;
    color: var(--text-muted);
    font-size: .88rem;
}

.dash-figures {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 130px), 1fr));
    gap: .6rem;
    margin-bottom: .25rem;
}

.dash-section > .dash-figures {
    margin-bottom: 1rem;
}

.dash-figure {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    min-width: 0;
    padding: .6rem .75rem;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
}

a.dash-figure:hover {
    text-decoration: none;
    border-color: var(--accent);
}

.dash-figure-value {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.dash-figure-label {
    color: var(--text-muted);
    font-size: .78rem;
    font-weight: 600;
    line-height: 1.25;
}

.dash-figure-warning {
    background: var(--warning-soft);
    border-color: transparent;
}

.dash-figure-warning .dash-figure-value {
    color: var(--warning);
}

.dash-figure-danger {
    background: var(--danger-soft);
    border-color: transparent;
}

.dash-figure-danger .dash-figure-value {
    color: var(--danger);
}

.dash-progress-list {
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

.dash-progress-head {
    display: flex;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: .3rem;
    font-size: .85rem;
}

.dash-progress-head strong {
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.dash-progress-track {
    height: .6rem;
    border-radius: 999px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    overflow: hidden;
}

.dash-progress-bar {
    height: 100%;
    border-radius: 999px;
    background: var(--accent);
}

.dash-progress-done .dash-progress-bar {
    background: var(--success);
}

@media (max-width: 600px) {
    .dash-cards {
        grid-template-columns: minmax(0, 1fr);
        gap: .75rem;
    }

    .dash-figures {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dash-figure-value {
        font-size: 1.15rem;
    }

    .dash-section-head {
        flex-wrap: wrap;
        gap: .4rem;
    }

    /* Row actions are touch targets on a phone */
    .dash-row-actions .btn {
        min-height: 2.5rem;
    }
}

/* ------------------------------------------------------------ Phase 12 WP8: activities, messages, credit control, purchase suggestions */

.activities-overdue {
    color: var(--danger);
    font-weight: 600;
}

.activities-type {
    white-space: nowrap;
}

.activities-meta {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem;
}

.activities-auto {
    gap: .3rem;
}

.activities-counts {
    margin-bottom: 1rem;
}

.activities-section-title,
.activities-history-title {
    margin: 1rem 0 .5rem;
    font-size: 1rem;
}

.activities-history {
    margin: 0;
    padding-left: 1.2rem;
    display: grid;
    gap: .5rem;
}

.activities-history-head {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
}

.messages-unread {
    font-weight: 700;
}

.messages-thread {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
    display: grid;
    gap: .75rem;
}

.messages-bubble {
    max-width: 46rem;
    padding: .7rem .9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-muted);
}

.messages-staff {
    margin-left: auto;
    background: var(--primary-soft);
    border-color: #a8e6cf;
}

.messages-bubble-head {
    display: flex;
    flex-wrap: wrap;
    gap: .2rem;
    margin-bottom: .35rem;
    font-size: .88rem;
}

.messages-body {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.messages-reply {
    display: grid;
    gap: .4rem;
}

.messages-reply textarea {
    width: 100%;
    padding: .5rem .6rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
}

.credit-hold-banner {
    flex-wrap: wrap;
}

.credit-hold-banner .notice-actions {
    display: flex;
    gap: .5rem;
    margin-left: auto;
}

.credit-call-link {
    margin-right: .4rem;
}

.credit-late {
    color: var(--danger);
}

.suggestions-filters {
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.suggestions-groups {
    display: grid;
    gap: 1rem;
}

.suggestions-group-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: .5rem;
    margin-bottom: .6rem;
}

.suggestions-include {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    font-weight: 600;
}

.suggestions-qty {
    width: 5.5rem;
    padding: .3rem .4rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
    text-align: right;
}

.suggestions-hint {
    display: block;
    color: var(--warning);
}

@media (max-width: 600px) {
    .messages-staff {
        margin-left: 1.5rem;
    }

    .credit-hold-banner .notice-actions {
        margin-left: 0;
    }
}

/* Phase 13 WP7: the delivery promise of a carrier option (shipment wizard) */
.delivery-promise {
    color: var(--success);
}

.delivery-promise-late {
    color: var(--warning);
}

/* ------------------------------------------------------------ base controls
   Every drop-down, and the text/date/number fields of page toolbars, look like the filters' and forms' controls. Pages
   that build a select or a toolbar field of their own (Manifests, Printers, Waves, Walking order, Cycle counts,
   Transfers, Purchase suggestions, 3PL stock, ...) showed the browser's default control. :where() keeps these rules at
   the lowest specificity, so every more specific rule (filters, form fields, scan pages) still wins. */
:where(select),
:where(.toolbar, .card-toolbar, .page-filter) :where(input:not([type="checkbox"], [type="radio"], [type="file"], [type="range"], [type="color"])) {
    padding: .4rem .5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    color: var(--text);
    background: var(--surface);
}

:where(select):focus,
:where(.toolbar, .card-toolbar, .page-filter) :where(input:not([type="checkbox"], [type="radio"], [type="file"], [type="range"], [type="color"])):focus {
    outline: 2px solid var(--primary-soft);
    border-color: var(--primary);
}

:where(select):disabled {
    background: var(--surface-muted);
    color: var(--text-muted);
}

/* The filter bars of the Phase 12/13 pages (Count review, Manifests, Printers > Jobs, Transfers, Waves: a .toolbar of
   label + control pairs and buttons) had no style of their own: laid out and labelled like the list filters */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem .5rem;
    margin-bottom: .75rem;
}

.toolbar > label {
    font-size: .85rem;
    color: var(--text-muted);
}

.toolbar > label:not(:first-child) {
    margin-left: .6rem;
}

.toolbar > select {
    max-width: 16rem;
}

/* ------------------------------------------------------------ grouped sections (Settings)
   page.js groupedTabs: a side list of groups and their sections beside the section's content, instead of one long
   row of tabs that had to be scrolled sideways; on a phone a drop-down with the same groups. */
.sections {
    display: grid;
    grid-template-columns: 13rem minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;
}

.section-menu {
    position: sticky;
    top: 1rem;
}

.section-nav {
    display: flex;
    flex-direction: column;
    gap: .85rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    padding: .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.section-group {
    display: flex;
    flex-direction: column;
    gap: .1rem;
}

.section-group-title {
    margin: 0 0 .25rem;
    padding: 0 .6rem;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.section-link {
    border: 0;
    border-left: 3px solid transparent;
    border-radius: 6px;
    background: none;
    padding: .35rem .6rem;
    font: inherit;
    text-align: left;
    color: var(--text);
    cursor: pointer;
}

.section-link:hover {
    background: var(--surface-muted);
}

.section-link:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

.section-link[aria-current="page"] {
    border-left-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 600;
}

.section-panel {
    min-width: 0;
}

.section-panel:focus {
    outline: none;
}

/* the drop-down replaces the list below 1200px, so the section has the width of the page (tables need it) */
.section-picker {
    display: none;
    width: 100%;
}

@media (max-width: 1200px) {
    .sections {
        grid-template-columns: minmax(0, 1fr);
        gap: 1rem;
    }

    .section-menu {
        position: static;
    }

    .section-nav {
        display: none;
    }

    .section-picker {
        display: block;
    }
}

/* Finance Ledger WP3: the match dialog (js/matching.js) - proposal buttons, amount inputs, the running total */
.match-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin: 0.75rem 0;
}

.match-amount {
    width: 8rem;
    text-align: right;
}

.match-total {
    margin-top: 0.75rem;
    font-weight: 600;
}

/* Finance Ledger WP4: the ledger views (js/ledger-views.js, customer-account.js, audit.js) */
.toolbar-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin: 0.5rem 0 0.75rem;
}

.toolbar-row .card-actions {
    margin-left: auto;
}

.ledger-summary {
    margin: 0;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.form-row .field {
    flex: 1 1 16rem;
    min-width: 0;
}

.form-row .field input {
    width: 100%;
}

.lookup-results {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.25rem;
}

.audit-json, .raw-text {
    max-height: 20rem;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.85rem;
}

/* Finance Ledger: a detail list followed by the form of the same record (Bank setup > account) */
.detail-list + .form-grid {
    margin-top: 1.25rem;
}

/* Finance Ledger WP9: requested and offered conditions of an application side by side (one below the other on a
   phone) */
.two-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
    gap: 1rem 1.5rem;
}

.two-columns h3, .card-subtitle {
    margin: 0 0 .6rem;
    font-size: 1rem;
}

/* Finance Ledger WP10: the region sections below a country's global set of delivery methods */
.region-methods {
    margin-top: 1.25rem;
}

/* Finance Ledger WP8: the verification code the signer compares with the phone (Contracts to sign) */
.verification-code {
    margin: .75rem 0;
    font-size: 1.75rem;
    letter-spacing: .15em;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* Settings > Delivery methods: the country picker above the country's methods (not a table of every country) */
.delivery-country {
    display: grid;
    gap: .75rem;
    padding: 1rem 1.25rem;
}

.delivery-country-pick {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: .5rem 1rem;
}

.delivery-country-pick .form-field {
    flex: 0 1 26rem;
    min-width: 0;
}

.delivery-country-label {
    font-size: .85rem;
    font-weight: 600;
}

.delivery-country-summary {
    margin: 0 0 .55rem;
}

.chip-button {
    font: inherit;
    font-size: .85rem;
    color: var(--text);
    cursor: pointer;
}

.chip-button:hover {
    border-color: var(--brand);
}

.chip-button.chip-primary {
    color: var(--primary);
    font-weight: 600;
}

/* Settings sections (grouped side list): one setting per row - its label and help on the left, a control sized to its
   content on the right - instead of a grid whose wide number boxes, ragged help texts and orphaned fields looked
   untidy; the save button sits under the controls. Narrow screens stack label, control and help. */
.section-panel .form-panel .form-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
}

.section-panel .form-panel :where(.form-field:not(.form-check, .form-fieldset)) {
    display: grid;
    grid-template-columns: minmax(10rem, 20rem) minmax(0, 1fr);
    column-gap: 1.5rem;
    row-gap: .15rem;
    align-items: start;
    padding: .75rem 0;
    border-top: 1px solid var(--border);
}

.section-panel .form-panel :where(.form-field:not(.form-check, .form-fieldset)) > label {
    grid-column: 1;
    grid-row: 1;
    padding-top: .45rem;
}

.section-panel .form-panel :where(.form-field:not(.form-check, .form-fieldset)) > .form-help {
    grid-column: 1;
    grid-row: 2;
}

/* The control (input, select, lookup, ...) on the right; an add-on below it */
.section-panel .form-panel :where(.form-field:not(.form-check, .form-fieldset) > :not(label, .form-help, datalist)) {
    grid-column: 2;
    grid-row: 1 / span 2;
    justify-self: start;
    width: 100%;
    max-width: 26rem;
}

.section-panel .form-panel :where(.form-field:not(.form-check, .form-fieldset) > :not(label, .form-help, datalist) ~ :not(label, .form-help, datalist)) {
    grid-row: 3;
}

/* Numbers, amounts and dates need a short box, not a full-width one */
.section-panel .form-panel .form-field > input:is([type="number"], [type="date"], [type="time"]) {
    max-width: 10rem;
}

.section-panel .form-panel .form-field > textarea {
    max-width: 40rem;
}

.section-panel .form-panel .form-check,
.section-panel .form-panel .form-fieldset {
    padding: .75rem 0;
    border-top: 1px solid var(--border);
}

.section-panel .form-panel .form-check input {
    flex: none;
}

.section-panel .form-panel .form-panel-actions {
    justify-content: flex-start;
    margin-top: 0;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

@media (max-width: 720px) {
    .section-panel .form-panel :where(.form-field:not(.form-check, .form-fieldset)) {
        grid-template-columns: minmax(0, 1fr);
    }

    .section-panel .form-panel :where(.form-field:not(.form-check, .form-fieldset)) > label { grid-row: 1; padding-top: 0; }
    .section-panel .form-panel :where(.form-field:not(.form-check, .form-fieldset) > :not(label, .form-help, datalist)) { grid-column: 1; grid-row: 2; }
    .section-panel .form-panel :where(.form-field:not(.form-check, .form-fieldset)) > .form-help { grid-row: 3; }
    .section-panel .form-panel :where(.form-field:not(.form-check, .form-fieldset) > :not(label, .form-help, datalist) ~ :not(label, .form-help, datalist)) { grid-row: 4; }
}

/* Settings > Payments: the providers table fits its card (short boxes, wrapping headings) */
.payment-providers th {
    white-space: normal;
}

.payment-providers th,
.payment-providers td {
    padding-left: .6rem;
    padding-right: .6rem;
}

.payment-providers td {
    vertical-align: middle;
}

.payment-providers input[type="text"] {
    width: 100%;
    min-width: 7rem;
}

.payment-providers .qty-input {
    width: 4.5rem;
}

/* A region's method changes sit indented inside the methods card: tighter cells so the table fits without scrolling */
.region-methods .data-table th,
.region-methods .data-table td {
    padding-left: .6rem;
    padding-right: .6rem;
}

.provider-facts {
    font-weight: 400;
    color: var(--text-muted);
    white-space: nowrap;
}

.provider-missing {
    color: var(--danger);
    font-weight: 600;
}
