@font-face {
    font-family: "GVENT Workspace";
    src: url("fonts/RobotoCondensed-Regular.ttf") format("truetype");
    font-style: normal;
    font-weight: 400;
    font-display: swap;
}

/* Modern platform layer: native top-layer dialogs, resilient focus and motion. */
html {
    scrollbar-gutter: stable;
}

body {
    min-height: 100dvh;
}

.page-content {
    container-name: workspace;
    container-type: inline-size;
}

.skip-link {
    position: fixed;
    z-index: 300;
    top: 8px;
    left: 8px;
    padding: 9px 12px;
    border: 2px solid var(--accent);
    border-radius: var(--radius);
    background: var(--brand-ink);
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    transform: translateY(-150%);
}

.skip-link:focus {
    transform: translateY(0);
}

:where(a, button, summary, input, select, textarea, [tabindex]):focus-visible {
    outline: 2px solid #146ef5;
    outline-offset: 2px;
}

:where(button, summary, .button, .icon-button) {
    touch-action: manipulation;
}

.app-dialog {
    max-width: calc(100vw - 24px);
    max-height: calc(100dvh - 24px);
    margin: auto;
    padding: 0;
    overflow: auto;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--paper);
    color: var(--text);
    opacity: 0;
    transform: translateY(8px) scale(.99);
    transition: opacity 160ms ease, transform 160ms ease, overlay 160ms allow-discrete, display 160ms allow-discrete;
}

.app-dialog[open] {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.app-dialog::backdrop {
    background: rgba(15, 18, 22, .58);
    backdrop-filter: blur(2px);
    opacity: 1;
    transition: opacity 160ms ease, overlay 160ms allow-discrete, display 160ms allow-discrete;
}

@starting-style {
    .app-dialog[open] {
        opacity: 0;
        transform: translateY(8px) scale(.99);
    }

    .app-dialog[open]::backdrop {
        opacity: 0;
    }
}

.confirm-dialog {
    width: min(460px, calc(100vw - 24px));
}

.confirm-dialog-card {
    display: grid;
    gap: 16px;
    margin: 0;
    padding: 20px;
}

.confirm-dialog-card > header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.confirm-dialog-card > header > div {
    display: grid;
    gap: 2px;
}

.confirm-dialog-card h2,
.confirm-dialog-card p {
    margin: 0;
}

.confirm-dialog-card p {
    color: var(--muted-strong);
    font-size: 13px;
}

.confirm-dialog-card > footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.confirm-dialog-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid #e1a3a3;
    border-radius: var(--radius);
    background: var(--red-soft);
    color: var(--red);
}

.button.confirm-danger {
    border-color: #a92d2d;
    background: #b93434;
    color: #fff;
}

.button.confirm-danger:hover {
    border-color: #8f2020;
    background: #9f2929;
}

.toast-region {
    position: fixed;
    z-index: 320;
    right: 18px;
    bottom: 18px;
    display: grid;
    gap: 8px;
    width: min(390px, calc(100vw - 28px));
    pointer-events: none;
}

.app-toast {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 30px;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    padding: 8px 8px 8px 13px;
    border: 1px solid #8fb5a9;
    border-left: 4px solid var(--teal);
    border-radius: var(--radius);
    background: var(--paper);
    box-shadow: 0 12px 32px rgba(20, 24, 28, .18);
    color: var(--text-strong);
    font-size: 12px;
    pointer-events: auto;
    transition: opacity 160ms ease, transform 160ms ease;
}

.app-toast.is-error {
    border-color: #e1a3a3;
    border-left-color: var(--red);
}

.app-toast.is-leaving {
    opacity: 0;
    transform: translateY(6px);
}

.toast-close {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--muted-strong);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
}

.toast-close:hover {
    background: var(--paper-soft);
    color: var(--text-strong);
}

.line-order-actions {
    display: grid;
    grid-template-columns: 34px 34px;
    gap: 4px;
}

.line-order-actions .icon-button {
    border-color: var(--border);
    background: var(--paper);
}

.line-order-actions .move-up svg {
    transform: rotate(180deg);
}

.line-drag-handle::after {
    content: "Alt + Pfeiltaste";
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

@container workspace (max-width: 900px) {
    .company-settings-layout,
    .user-editor-grid,
    .audit-command-bar {
        grid-template-columns: 1fr;
    }

    .footer-settings-preview {
        position: static;
    }
}

@supports (text-wrap: balance) {
    h1,
    h2,
    .section-heading h2 {
        text-wrap: balance;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* Settings use persistent tabs on wide screens and an explicit section picker on phones. */
.settings-mobile-nav {
    display: none;
}

@media (max-width: 720px) {
    .subnav.settings-desktop-nav {
        display: none;
    }

    .settings-mobile-nav {
        position: relative;
        z-index: 40;
        display: block;
        margin: 0 0 14px;
    }

    .settings-mobile-nav > summary {
        display: grid;
        grid-template-columns: 38px minmax(0, 1fr) 24px;
        align-items: center;
        gap: 10px;
        min-height: 56px;
        padding: 8px 11px;
        overflow: hidden;
        border: 1px solid var(--border-strong);
        border-radius: 7px;
        background: var(--paper);
        box-shadow: 0 3px 12px rgba(0, 0, 0, .08);
        cursor: pointer;
        list-style: none;
    }

    .settings-mobile-nav > summary::-webkit-details-marker {
        display: none;
    }

    .settings-mobile-nav > summary:focus-visible {
        outline: 3px solid color-mix(in srgb, var(--accent) 42%, transparent);
        outline-offset: 2px;
    }

    .settings-mobile-nav-icon {
        display: inline-grid;
        place-items: center;
        width: 38px;
        height: 38px;
        flex: 0 0 38px;
        border: 1px solid var(--border-strong);
        border-radius: 7px;
        background: var(--paper-soft);
        color: var(--text-strong);
    }

    .settings-mobile-nav-icon svg {
        width: 18px;
        height: 18px;
    }

    .settings-mobile-nav-current,
    .settings-mobile-nav-menu a > span:nth-child(2) {
        display: grid;
        min-width: 0;
        gap: 2px;
    }

    .settings-mobile-nav-current small,
    .settings-mobile-nav-menu small {
        overflow: hidden;
        color: var(--muted);
        font-size: 10px;
        line-height: 1.2;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .settings-mobile-nav-current strong,
    .settings-mobile-nav-menu strong {
        overflow: hidden;
        color: var(--text-strong);
        font-size: 13px;
        line-height: 1.25;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .settings-mobile-nav-chevron {
        width: 18px;
        height: 18px;
        transition: transform 180ms cubic-bezier(.2, .75, .2, 1);
    }

    .settings-mobile-nav[open] .settings-mobile-nav-chevron {
        transform: rotate(180deg);
    }

    .settings-mobile-nav-menu {
        position: absolute;
        top: calc(100% + 7px);
        right: 0;
        left: 0;
        display: grid;
        max-height: min(504px, calc(var(--visual-viewport-height, 100dvh) - 150px - var(--safe-area-bottom)));
        padding: 6px;
        overflow-y: auto;
        overscroll-behavior: contain;
        border: 1px solid var(--border-strong);
        border-radius: 7px;
        background: var(--paper);
        box-shadow: 0 18px 46px rgba(0, 0, 0, .28);
        animation: settings-menu-in 180ms cubic-bezier(.2, .75, .2, 1) both;
    }

    .settings-mobile-nav-menu a {
        display: grid;
        grid-template-columns: 38px minmax(0, 1fr) 20px;
        align-items: center;
        gap: 10px;
        min-height: 58px;
        padding: 7px;
        border: 1px solid transparent;
        border-radius: 6px;
        color: var(--text);
        text-decoration: none;
    }

    .settings-mobile-nav-menu a + a {
        border-top-color: var(--border);
        border-top-left-radius: 0;
        border-top-right-radius: 0;
    }

    .settings-mobile-nav-menu a.active {
        border-color: color-mix(in srgb, var(--accent) 66%, var(--border));
        background: var(--accent-soft);
    }

    .settings-mobile-nav-menu a.active .settings-mobile-nav-icon {
        border-color: var(--accent);
        background: var(--accent);
        color: var(--brand-ink);
    }

    .settings-mobile-nav-menu a > svg:last-child {
        width: 17px;
        height: 17px;
        color: var(--muted);
    }

    @keyframes settings-menu-in {
        from { opacity: 0; transform: translateY(-5px) scale(.99); }
        to { opacity: 1; transform: translateY(0) scale(1); }
    }
}

@media (max-width: 720px) and (prefers-reduced-motion: reduce) {
    .settings-mobile-nav-menu {
        animation: none;
    }

    .settings-mobile-nav-chevron {
        transition: none;
    }
}

/* Unified mobile creation and document-cart experience. */
@media (max-width: 720px) {
    body:has(.mobile-document-dock) .page-content {
        padding-bottom: calc(var(--mobile-tabbar-height) + 104px);
    }

    body:has(.mobile-document-dock) .toast-region {
        bottom: calc(var(--mobile-tabbar-height) + 76px);
    }

    .mobile-tabbar .mobile-tab-create {
        overflow: visible;
    }

    .mobile-tabbar .mobile-tab-create .mobile-create-glyph {
        position: relative;
        display: grid;
        place-items: center;
        width: 50px;
        height: 50px;
        border: 1px solid #231f20;
        border-radius: 50%;
        background: #fff200;
        box-shadow: 0 7px 18px rgba(20, 24, 28, .24), inset 0 1px rgba(255, 255, 255, .8);
        color: #231f20;
        transform: translateY(-11px);
        transition: transform 180ms cubic-bezier(.2, .8, .2, 1), box-shadow 180ms ease, background-color 180ms ease;
    }

    .mobile-tabbar .mobile-tab-create .mobile-create-glyph .app-icon {
        width: 22px;
        height: 22px;
        padding: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
        transform: none;
        transition: transform 180ms cubic-bezier(.2, .8, .2, 1);
    }

    .mobile-tabbar .mobile-tab-create > span:last-child {
        transform: translateY(-7px);
    }

    .mobile-tabbar .mobile-tab-create:active .mobile-create-glyph,
    .mobile-tabbar .mobile-tab-create.is-touching .mobile-create-glyph {
        box-shadow: 0 3px 9px rgba(20, 24, 28, .2);
        transform: translateY(-8px) scale(.94);
    }

    .mobile-tabbar .mobile-tab-create[aria-expanded="true"] .mobile-create-glyph .app-icon {
        transform: rotate(45deg);
    }

    .mobile-create-sheet,
    .app-dialog.mobile-create-sheet:not(.confirm-dialog) {
        height: min(90dvh, 780px);
        border-radius: 18px 18px 0 0;
        background: var(--paper);
        box-shadow: 0 -18px 64px rgba(0, 0, 0, .28);
        transition: transform 320ms cubic-bezier(.22, 1, .36, 1), opacity 180ms ease, overlay 180ms allow-discrete, display 180ms allow-discrete;
    }

    .mobile-create-sheet.is-sheet-dragging {
        transition: none;
    }

    .mobile-sheet-grabber {
        height: 28px;
        min-height: 28px;
        background: var(--paper);
        cursor: grab;
        touch-action: none;
    }

    .mobile-sheet-grabber span {
        width: 42px;
        height: 5px;
        border-radius: 3px;
        background: var(--border-strong);
    }

    .mobile-create-header {
        min-height: 60px;
        padding: 2px 18px 11px;
        cursor: grab;
        touch-action: none;
    }

    .mobile-create-header button {
        touch-action: manipulation;
    }

    .mobile-create-search {
        margin-right: 18px;
        margin-left: 18px;
    }

    .mobile-create-content {
        padding-right: 18px;
        padding-left: 18px;
    }

    .invoice-lines-table.is-live-grid tbody {
        gap: 7px;
        padding: 8px;
    }

    .invoice-lines-table.is-live-grid .invoice-line-row,
    .invoice-lines-table.is-live-grid .invoice-line-row.is-section,
    .invoice-lines-table.is-live-grid .invoice-line-row.is-text,
    .invoice-lines-table.is-live-grid .invoice-line-row.is-spacer {
        position: relative;
        grid-template-columns: 36px minmax(0, 1fr) auto 44px !important;
        min-height: 72px;
        gap: 7px;
        padding: 9px 6px;
        border-left-width: 3px;
        background: var(--paper);
        transition: border-color 160ms ease, background-color 160ms ease;
    }

    .invoice-lines-table.is-live-grid .invoice-line-row > td:nth-child(1) {
        grid-column: 1;
        grid-row: 1;
        align-content: center;
    }

    .invoice-lines-table.is-live-grid .invoice-line-row > td:nth-child(2),
    .invoice-lines-table.is-live-grid .invoice-line-row > td:nth-child(4),
    .invoice-lines-table.is-live-grid .invoice-line-row > td:nth-child(5),
    .invoice-lines-table.is-live-grid .invoice-line-row > td:nth-child(6),
    .invoice-lines-table.is-live-grid .invoice-line-row > td:nth-child(7) {
        display: none;
    }

    .invoice-lines-table.is-live-grid .invoice-line-row > td:nth-child(3) {
        grid-column: 2;
        grid-row: 1;
        align-content: center;
    }

    .invoice-lines-table.is-live-grid .invoice-line-row > td:nth-child(8) {
        grid-column: 3;
        grid-row: 1;
        align-content: center;
        min-width: 68px;
        text-align: right;
    }

    .invoice-lines-table.is-live-grid .invoice-line-row > td:nth-child(9) {
        grid-column: 4;
        grid-row: 1;
        align-content: start;
    }

    .invoice-lines-table.is-live-grid .invoice-line-row > td:nth-child(3)::before,
    .invoice-lines-table.is-live-grid .invoice-line-row > td:nth-child(8)::before,
    .invoice-lines-table.is-live-grid .invoice-line-row > td:nth-child(9)::before {
        display: none;
    }

    .mobile-line-kind {
        display: block;
        margin-bottom: 1px;
        color: var(--muted);
        font-size: 9px;
        font-weight: 700;
        line-height: 1.2;
        text-transform: uppercase;
    }

    .invoice-line-row .inline-line-title {
        min-height: 28px;
        padding: 2px 0;
        border-color: transparent;
        font-size: 14px;
    }

    .mobile-line-expand {
        display: inline-grid;
        width: 44px;
        height: 44px;
        border-color: transparent;
        background: transparent;
    }

    .mobile-line-expand svg,
    .mobile-line-expand img {
        transition: transform 180ms ease;
    }

    .invoice-line-row .inline-line-actions {
        display: none;
    }

    .invoice-lines-table.is-live-grid .invoice-line-row.is-mobile-expanded {
        grid-template-columns: 36px minmax(0, 1fr) minmax(82px, .55fr) 44px !important;
        background: var(--paper-soft);
    }

    .invoice-line-row.is-mobile-expanded .mobile-line-expand svg,
    .invoice-line-row.is-mobile-expanded .mobile-line-expand img {
        transform: rotate(180deg);
    }

    .invoice-lines-table.is-live-grid .invoice-line-row.is-mobile-expanded > td:nth-child(1) {
        grid-row: 1 / span 2;
    }

    .invoice-lines-table.is-live-grid .invoice-line-row.is-mobile-expanded > td:nth-child(2) {
        display: grid;
        grid-column: 2 / 4;
        grid-row: 2;
    }

    .invoice-lines-table.is-live-grid .invoice-line-row.is-mobile-expanded > td:nth-child(4) {
        display: grid;
        grid-column: 2 / 4;
        grid-row: 3;
    }

    .invoice-lines-table.is-live-grid .invoice-line-row.is-mobile-expanded > td:nth-child(5) {
        display: grid;
        grid-column: 2;
        grid-row: 4;
    }

    .invoice-lines-table.is-live-grid .invoice-line-row.is-mobile-expanded > td:nth-child(6) {
        display: grid;
        grid-column: 3;
        grid-row: 4;
    }

    .invoice-lines-table.is-live-grid .invoice-line-row.is-mobile-expanded > td:nth-child(7) {
        display: grid;
        grid-column: 2;
        grid-row: 5;
    }

    .invoice-lines-table.is-live-grid .invoice-line-row.is-mobile-expanded > td:nth-child(9) {
        grid-row: 1 / span 5;
    }

    .invoice-line-row.is-mobile-expanded .inline-line-actions {
        display: flex;
        align-items: center;
        flex-direction: column;
        margin-top: 4px;
    }

    .invoice-line-row.is-mobile-expanded .line-rich-text {
        min-width: 0;
        border-color: var(--border);
        background: var(--paper);
    }

    .invoice-lines-table.is-live-grid .invoice-line-row.is-section.is-mobile-expanded > td:nth-child(n + 5):nth-child(-n + 8),
    .invoice-lines-table.is-live-grid .invoice-line-row.is-text.is-mobile-expanded > td:nth-child(n + 5):nth-child(-n + 8),
    .invoice-lines-table.is-live-grid .invoice-line-row.is-spacer.is-mobile-expanded > td:nth-child(n + 5):nth-child(-n + 8) {
        display: none;
    }

    .mobile-document-dock {
        position: fixed;
        z-index: 23;
        right: max(10px, var(--safe-area-right));
        bottom: calc(var(--mobile-tabbar-height) + 9px);
        left: max(10px, var(--safe-area-left));
        display: grid;
        grid-template-columns: auto auto minmax(104px, 1fr);
        align-items: center;
        gap: 10px;
        min-height: 58px;
        padding: 7px;
        border: 1px solid #3a3a37;
        border-radius: 8px;
        background: #231f20;
        box-shadow: 0 12px 34px rgba(20, 24, 28, .26);
        color: #fff;
        transition: opacity 160ms ease, transform 220ms cubic-bezier(.22, 1, .36, 1);
    }

    .mobile-document-dock > span {
        padding-left: 5px;
        color: #bfc1bd;
        font-size: 10px;
        white-space: nowrap;
    }

    .mobile-document-dock > strong {
        color: #fff;
        font-size: 16px;
        white-space: nowrap;
    }

    .mobile-document-dock .button {
        justify-self: stretch;
        min-width: 0;
        height: 44px;
        color: #231f20;
    }

    .position-sheet-scrim {
        position: fixed;
        z-index: 260;
        inset: 0;
        width: 100%;
        height: 100%;
        padding: 0;
        border: 0;
        background: rgba(8, 10, 12, .62);
        opacity: 0;
        pointer-events: none;
        transition: opacity 180ms ease;
        backdrop-filter: blur(2px);
    }

    .position-composer-zone .position-quick-add,
    .position-composer-zone .sale-cart-composer {
        position: fixed;
        z-index: 270;
        right: 0;
        bottom: 0;
        left: 0;
        display: grid;
        width: 100%;
        max-height: min(88dvh, calc(var(--visual-viewport-height, 100dvh) - var(--safe-area-top) - 8px));
        margin: 0;
        padding-bottom: calc(14px + var(--safe-area-bottom));
        overflow-x: visible;
        overflow-y: auto;
        border: 1px solid var(--border-strong);
        border-width: 1px 0 0;
        border-radius: 18px 18px 0 0;
        background: var(--paper);
        box-shadow: 0 -20px 60px rgba(0, 0, 0, .3);
        opacity: 0;
        pointer-events: none;
        transform: translateY(calc(105% + var(--composer-drag, 0px)));
        transition: transform 320ms cubic-bezier(.22, 1, .36, 1), opacity 160ms ease;
    }

    .position-composer-zone.is-open .position-sheet-scrim {
        opacity: 1;
        pointer-events: auto;
    }

    .position-composer-zone.is-open .position-quick-add,
    .position-composer-zone.is-open .sale-cart-composer {
        opacity: 1;
        pointer-events: auto;
        transform: translateY(var(--composer-drag, 0px));
    }

    .position-composer-zone.is-open .mobile-document-dock {
        opacity: 0;
        pointer-events: none;
        transform: translateY(12px);
    }

    .position-composer-zone.is-dragging .position-quick-add,
    .position-composer-zone.is-dragging .sale-cart-composer {
        transition: none;
    }

    .position-sheet-header {
        display: flex;
        grid-column: 1 / -1;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        min-height: 78px;
        margin: -1px -1px 4px;
        padding: 18px 16px 9px;
        border-bottom: 1px solid var(--border);
        cursor: grab;
        touch-action: none;
    }

    .position-sheet-header::before {
        position: absolute;
        top: 7px;
        left: 50%;
        width: 42px;
        height: 5px;
        border-radius: 3px;
        background: var(--border-strong);
        content: "";
        transform: translateX(-50%);
    }

    .position-sheet-header > div {
        display: grid;
        gap: 1px;
    }

    .position-sheet-header .eyebrow,
    .position-sheet-header strong,
    .position-sheet-header small {
        margin: 0;
    }

    .position-sheet-header strong {
        font-size: 18px;
    }

    .position-sheet-header small {
        color: var(--muted);
        font-size: 10px;
    }

    .position-composer-zone .position-quick-add {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 11px;
        align-items: start;
        padding: 0 14px calc(14px + var(--safe-area-bottom));
        border-top-color: var(--border-strong);
    }

    .position-composer-zone .position-quick-add > label,
    .position-composer-zone .position-quick-add > label:not(.quick-type):not(.quick-item):not(.quick-spacer-color) {
        display: grid !important;
        gap: 4px;
        min-width: 0;
        color: var(--muted-strong);
        font-size: 10px;
    }

    .position-composer-zone .position-quick-add .quick-type,
    .position-composer-zone .position-quick-add .quick-item,
    .position-composer-zone .position-quick-add .quick-spacer-color,
    .position-composer-zone .position-quick-add .quick-description-mobile,
    .position-composer-zone .position-quick-add .quick-deposit,
    .position-composer-zone .position-quick-add > button,
    .position-composer-zone .position-quick-add .quick-add-state {
        grid-column: 1 / -1;
    }

    .position-composer-zone .position-quick-add .position-add-mark {
        display: none;
    }

    .position-composer-zone .position-quick-add input,
    .position-composer-zone .position-quick-add select,
    .position-composer-zone .position-quick-add textarea,
    .position-composer-zone .position-quick-add .item-search-control {
        min-height: 44px;
        font-size: 16px;
    }

    .position-composer-zone .position-quick-add textarea {
        padding: 9px;
        resize: vertical;
    }

    .position-composer-zone .position-quick-add .quick-deposit {
        display: flex !important;
        justify-content: flex-start;
        min-height: 44px;
        padding: 0 4px;
    }

    .position-composer-zone .position-quick-add .icon-button.primary {
        display: inline-flex;
        width: 100%;
        height: 48px;
        gap: 8px;
        border-radius: 6px;
    }

    .position-composer-zone .position-quick-add .icon-button.primary > span {
        display: inline;
    }

    .position-composer-zone .position-quick-add .quick-add-state {
        display: block;
        min-height: 16px;
        text-align: center;
    }

    .position-composer-zone .item-search-results,
    .position-composer-zone .position-quick-add .item-search-results {
        position: absolute;
        top: calc(100% + 4px);
        right: 0;
        bottom: auto;
        left: 0;
        width: auto;
        max-height: min(42dvh, 330px);
        border-radius: 6px;
        box-shadow: 0 16px 44px rgba(0, 0, 0, .28);
    }

    .position-composer-zone .sale-cart-composer {
        grid-template-rows: auto minmax(0, 1fr);
    }

    .position-composer-zone .sale-cart-heading {
        display: none;
    }

    .position-composer-zone .sale-cart-form {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 11px;
        align-items: start;
        padding: 10px 14px calc(14px + var(--safe-area-bottom));
        overflow-y: auto;
    }

    .position-composer-zone .sale-cart-form .sale-item-select,
    .position-composer-zone .sale-cart-form .sale-deposit-toggle,
    .position-composer-zone .sale-cart-form .sale-note,
    .position-composer-zone .sale-cart-form > button,
    .position-composer-zone .sale-cart-form .quick-add-state {
        grid-column: 1 / -1;
    }

    .position-composer-zone .sale-cart-form input,
    .position-composer-zone .sale-cart-form .item-search-control {
        min-height: 44px;
        font-size: 16px;
    }

    .position-composer-zone .sale-cart-form > button {
        min-height: 48px;
    }

    .position-composer-zone .sale-cart-form .quick-add-state {
        min-height: 16px;
        color: var(--teal);
        text-align: center;
    }

    .has-position-composer body {
        overflow: hidden;
    }
}

/* Dark mode keeps operational density while lifting contrast between surfaces. */
html[data-theme="dark"] .topbar,
html[data-theme="dark"] .mobile-tabbar,
html[data-theme="dark"] .is-standalone .mobile-tabbar,
html[data-theme="dark"] .mobile-sheet-grabber {
    background: var(--chrome);
}

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .global-search,
html[data-theme="dark"] .item-search-control,
html[data-theme="dark"] .command-center-search,
html[data-theme="dark"] .mobile-create-search input {
    border-color: var(--border-strong);
    background-color: var(--paper-soft);
    color: var(--text-strong);
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
    color: #7f878d;
}

html[data-theme="dark"] .invoice-line-row.is-saving td,
html[data-theme="dark"] .invoice-line-row.is-text td,
html[data-theme="dark"] .invoice-line-row.is-section td,
html[data-theme="dark"] .line-rich-toolbar.ql-toolbar.ql-snow,
html[data-theme="dark"] .position-quick-add,
html[data-theme="dark"] .icon-file-drop,
html[data-theme="dark"] .item-inline-sync.is-linked {
    background: var(--paper-soft);
}

html[data-theme="dark"] .invoice-line-row.is-section td {
    border-top-color: #8f969b;
}

html[data-theme="dark"] .invoice-line-row.is-spacer td {
    color: #231f20;
}

html[data-theme="dark"] .line-drag-handle:hover,
html[data-theme="dark"] .rich-text-toolbar button:hover,
html[data-theme="dark"] .rich-text-toolbar button.ql-active,
html[data-theme="dark"] .line-rich-toolbar.ql-toolbar.ql-snow button:hover,
html[data-theme="dark"] .line-rich-toolbar.ql-toolbar.ql-snow button.ql-active {
    background: var(--accent-soft) !important;
    color: var(--accent) !important;
}

html[data-theme="dark"] .document-preview-dialog,
html[data-theme="dark"] .document-preview-canvas,
html[data-theme="dark"] .pdf-viewer-stage {
    background: #0c0f11;
}

html[data-theme="dark"] .document-preview-page,
html[data-theme="dark"] .document-preview-page iframe,
html[data-theme="dark"] .document-preview-canvas iframe,
html[data-theme="dark"] .pdf-viewer-page {
    background: #fff;
    color-scheme: light;
}

html[data-theme="dark"] .badge,
html[data-theme="dark"] .status-badge {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08);
}

html[data-theme="dark"] .icon-studio-stage {
    background-color: var(--paper-soft);
    background-image: linear-gradient(90deg, var(--border) 1px, transparent 1px), linear-gradient(var(--border) 1px, transparent 1px);
}

html[data-theme="dark"] .icon-studio-caption,
html[data-theme="dark"] .promote-line-button {
    color: var(--text-strong);
}

html[data-theme="dark"] .sidebar .brand-logo {
    filter: invert(1) grayscale(1) brightness(1.9);
}

html[data-theme="dark"] .theme-toggle {
    color: #ffe900;
}

html[data-theme="dark"] .app-toast,
html[data-theme="dark"] .line-options-panel,
html[data-theme="dark"] .quick-create-menu,
html[data-theme="dark"] .item-search-results {
    box-shadow: 0 18px 48px rgba(0, 0, 0, .42);
}

@media (forced-colors: active) {
    .main-nav a.active,
    .badge,
    .button,
    .icon-button,
    .record-icon {
        border: 1px solid CanvasText;
        forced-color-adjust: auto;
    }

    .connection-dot.online {
        background: Highlight;
    }
}

@font-face {
    font-family: "GVENT Workspace";
    src: url("fonts/RobotoCondensed-Bold.ttf") format("truetype");
    font-style: normal;
    font-weight: 700;
    font-display: swap;
}

/* sevDesk cache, synchronization and login */
.cache-command-bar,
.remote-sync-panel,
.user-menu {
    display: flex;
    align-items: center;
}

.cache-command-bar {
    justify-content: space-between;
    gap: 18px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-bottom: 0;
    background: var(--paper);
}

.cache-command-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cache-state {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}

.cache-state > div,
.remote-sync-panel > div {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.cache-state strong,
.remote-sync-panel strong {
    font-size: 13px;
}

.cache-state small,
.remote-sync-panel small {
    overflow: hidden;
    color: var(--muted);
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cache-state.is-stale .connection-dot {
    background: var(--amber);
}

.remote-sync-panel {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) auto;
    gap: 12px;
    padding: 13px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--paper-soft);
}

.remote-sync-panel.is-linked {
    border-color: #b9dcd4;
    background: var(--teal-soft);
}

.remote-sync-panel .record-icon {
    width: 36px;
    height: 36px;
}

.invoice-cache-table .position {
    width: 28%;
    max-width: 360px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.order-cache-table {
    min-width: 900px;
    table-layout: fixed;
}

.order-cache-table th:nth-child(1) { width: 72px; }
.order-cache-table th:nth-child(2) { width: 122px; }
.order-cache-table th:nth-child(3) { width: 82px; }
.order-cache-table th:nth-child(4) { width: 155px; }
.order-cache-table th:nth-child(6) { width: 106px; }
.order-cache-table th:nth-child(7) { width: 104px; }
.order-cache-table th:nth-child(8) { width: 142px; }
.order-cache-table .position { width: auto; max-width: none; }
.order-cache-table td:nth-child(4) .task-title strong { white-space: normal; }

.invoice-pdf-button {
    color: var(--blue);
}

.invoice-number-cell {
    display: grid;
    gap: 2px;
    min-width: 94px;
}

.invoice-number-cell strong {
    color: var(--text-strong);
    font-size: 12px;
    white-space: nowrap;
}

.invoice-number-cell span {
    color: var(--muted);
    font-size: 10px;
}

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

.record-actions.invoice-list-actions {
    width: 90px;
    min-width: 90px;
    gap: 0;
}

.invoice-list-actions > form {
    display: inline-flex;
    margin: 0;
}

.invoice-list-actions .icon-button {
    position: relative;
    width: 30px;
    min-width: 30px;
    height: 30px;
    border-color: var(--border-strong);
    border-radius: 0;
    background: var(--paper);
}

.invoice-list-actions > * + * {
    margin-left: -1px;
}

.invoice-list-actions > .icon-button:first-child,
.invoice-list-actions > form:first-child .icon-button {
    border-radius: var(--radius) 0 0 var(--radius);
}

.invoice-list-actions > .icon-button:last-child,
.invoice-list-actions > form:last-child .icon-button {
    border-radius: 0 var(--radius) var(--radius) 0;
}

.invoice-list-actions .icon-button:hover,
.invoice-list-actions .icon-button:focus-visible {
    z-index: 1;
    border-color: #aeb4ba;
    background: var(--paper-soft);
}

.invoice-list-actions .invoice-open-button {
    color: var(--text-strong);
}

.invoice-list-actions .invoice-pdf-button {
    color: var(--blue);
}

.invoice-cache-table th:last-child,
.invoice-cache-table td:last-child {
    position: sticky;
    right: 0;
    z-index: 2;
    width: 112px;
    min-width: 112px;
    padding-right: 11px;
    padding-left: 11px;
    background: var(--paper);
    box-shadow: -1px 0 0 var(--border);
}

.invoice-cache-table thead th:last-child {
    z-index: 3;
    background: var(--brand-ink);
}

.status-200,
.status-750 {
    background: var(--amber-soft);
    color: var(--amber);
}

.status-1000 {
    background: var(--teal-soft);
    color: var(--teal);
}

.status-50 {
    background: var(--red-soft);
    color: var(--red);
}

.user-menu {
    gap: 7px;
    padding-left: 10px;
    border-left: 1px solid var(--border);
}

.user-menu > a {
    max-width: 130px;
    overflow: hidden;
    color: var(--muted-strong);
    font-size: 12px;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-menu form {
    margin: 0;
}

.profile-workspace {
    width: min(720px, 100%);
}

.profile-form {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.login-body {
    min-height: 100vh;
    margin: 0;
    background: #f1f2f3;
}

.login-shell {
    display: grid;
    grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.1fr);
    width: min(920px, calc(100% - 40px));
    min-height: 540px;
    margin: max(40px, 8vh) auto;
    overflow: hidden;
    border: 1px solid #d5d8dc;
    border-radius: 8px;
    background: var(--paper);
    box-shadow: 0 18px 55px rgba(18, 22, 26, 0.12);
}

.login-brand {
    display: flex;
    justify-content: flex-end;
    flex-direction: column;
    padding: 42px;
    background: #231f20;
    color: #ffffff;
}

.login-brand img {
    width: min(300px, 100%);
    filter: invert(1);
}

.login-brand p {
    margin: 18px 0 0;
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
}

.login-panel {
    display: flex;
    justify-content: center;
    flex-direction: column;
    gap: 22px;
    padding: clamp(32px, 7vw, 72px);
}

.login-heading h1 {
    margin: 7px 0 8px;
    font-size: 30px;
    line-height: 1.15;
}

.login-heading p,
.login-setup p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.55;
}

.login-form {
    display: grid;
    gap: 16px;
}

.login-form label {
    display: grid;
    gap: 6px;
}

.login-form label > span {
    color: var(--muted-strong);
    font-size: 12px;
    font-weight: 650;
}

.login-form input {
    min-height: 44px;
}

.login-setup {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 12px;
    padding: 15px;
    border: 1px solid #c8dcd7;
    border-radius: var(--radius);
    background: var(--teal-soft);
}

.login-setup svg {
    width: 24px;
    color: var(--teal);
}

.login-footnote {
    color: var(--muted);
    font-size: 10px;
}

@media (max-width: 760px) {
    .cache-command-bar {
        align-items: stretch;
        flex-direction: column;
    }

    .cache-command-bar .button {
        width: 100%;
    }

    .cache-command-actions {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        width: 100%;
    }

    .cache-command-actions form {
        min-width: 0;
    }

    .remote-sync-panel {
        grid-template-columns: 38px minmax(0, 1fr);
    }

    .remote-sync-panel .check-label {
        grid-column: 1 / -1;
    }

    .login-shell {
        grid-template-columns: 1fr;
        width: min(100% - 24px, 520px);
        min-height: 0;
        margin: 12px auto;
    }

    .login-brand {
        min-height: 150px;
        padding: 26px;
    }

    .login-brand img {
        width: 210px;
    }

    .login-panel {
        padding: 30px 24px;
    }
}

:root {
    color-scheme: light;
    --canvas: #e9ece9;
    --paper: #f8f9f7;
    --paper-soft: #eef1ee;
    --paper-raised: #ffffff;
    --control: #ffffff;
    --chrome: rgba(248, 249, 247, .96);
    --row-stripe: #f2f4f1;
    --row-hover: #fffbd9;
    --button-surface: #ffffff;
    --button-surface-hover: #f3f5f2;
    --button-border: #aeb8b1;
    --button-shadow: 0 1px 1px rgba(20, 24, 28, .08), inset 0 1px rgba(255, 255, 255, .72);
    --button-shadow-hover: 0 2px 5px rgba(20, 24, 28, .11), inset 0 1px rgba(255, 255, 255, .82);
    --button-radius: 5px;
    --sidebar: #e5e8e4;
    --sidebar-panel: #231f20;
    --text: #303432;
    --text-strong: #202321;
    --muted: #68706b;
    --muted-strong: #4d5550;
    --border: #cfd5d0;
    --border-strong: #b5beb7;
    --accent: #fff200;
    --accent-hover: #f1df00;
    --accent-strong: #575000;
    --accent-soft: #fffdd8;
    --brand-ink: #231f20;
    --teal: #178070;
    --teal-soft: #e9f6f2;
    --blue: #2d6cdf;
    --blue-soft: #edf3ff;
    --amber: #a96808;
    --amber-soft: #fff6df;
    --red: #c63838;
    --red-soft: #fff0f0;
    --shadow-soft: 0 1px 2px rgba(20, 24, 28, .07), 0 8px 24px rgba(20, 24, 28, .055);
    --radius: 4px;
    --sidebar-width: 244px;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --canvas: #101416;
    --paper: #1a1f22;
    --paper-soft: #22282c;
    --paper-raised: #20262a;
    --control: #14191c;
    --chrome: rgba(26, 31, 34, .97);
    --row-stripe: #1d2326;
    --row-hover: #2b2b19;
    --button-surface: #20262a;
    --button-surface-hover: #282f33;
    --button-border: #4b555b;
    --button-shadow: 0 1px 2px rgba(0, 0, 0, .34), inset 0 1px rgba(255, 255, 255, .045);
    --button-shadow-hover: 0 2px 6px rgba(0, 0, 0, .4), inset 0 1px rgba(255, 255, 255, .07);
    --sidebar: #171a1d;
    --sidebar-panel: #0b0d0f;
    --text: #d9dcde;
    --text-strong: #f5f6f6;
    --muted: #969da2;
    --muted-strong: #c0c5c8;
    --border: #343a3f;
    --border-strong: #4a5258;
    --accent-hover: #ffe900;
    --accent-strong: #fff45b;
    --accent-soft: #39380f;
    --teal: #54c6ae;
    --teal-soft: #15352f;
    --blue: #75a5e8;
    --blue-soft: #182d47;
    --amber: #efb557;
    --amber-soft: #3d3018;
    --red: #f08787;
    --red-soft: #442326;
    --shadow-soft: 0 1px 2px rgba(0, 0, 0, .28), 0 12px 32px rgba(0, 0, 0, .18);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--canvas);
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    background: var(--canvas);
    color: var(--text);
    font-family: "GVENT Workspace", "Segoe UI", Arial, sans-serif;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.45;
    letter-spacing: 0;
}

button,
input,
select,
textarea {
    font: inherit;
    letter-spacing: 0;
}

button,
summary,
a {
    -webkit-tap-highlight-color: transparent;
}

svg {
    display: block;
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1,
h2,
h3,
strong {
    color: var(--text-strong);
}

h1 {
    margin-bottom: 3px;
    font-family: "GVENT Workspace", "Arial Narrow", sans-serif;
    font-size: 23px;
    font-weight: 700;
    line-height: 1.15;
}

h2 {
    margin-bottom: 6px;
    font-size: 18px;
    font-weight: 650;
    line-height: 1.25;
}

h3 {
    margin-bottom: 5px;
    font-size: 14px;
    font-weight: 650;
}

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 18px 12px 14px;
    border-right: 1px solid #242424;
    background: var(--sidebar-panel);
}

.sidebar::before {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 4px;
    background: var(--accent);
    content: "";
}

.sidebar-header,
.brand-lockup,
.connection-row,
.topbar,
.topbar-actions,
.command-bar,
.command-actions,
.section-heading,
.table-meta,
.panel-title,
.record-actions,
.hero-actions,
.document-command-bar,
.document-status,
.billing-run-header,
.task-card-top,
.task-card-footer,
.timeline-head,
.pagination {
    display: flex;
    align-items: center;
}

.sidebar-header {
    justify-content: space-between;
    gap: 10px;
    min-height: 76px;
    padding: 0 6px 14px;
}

.brand-lockup {
    display: grid;
    gap: 4px;
    color: #ffffff;
    text-decoration: none;
}

.brand-logo {
    display: block;
    width: 112px;
    height: 49px;
    object-fit: contain;
    object-position: left center;
}

.brand-lockup div,
.connection-row div,
.master-pane-heading div,
.page-intro,
.table-meta > div,
.record-identity,
.master-row-copy {
    display: grid;
    min-width: 0;
}

.brand-lockup span {
    color: #a9a9a4;
    font-size: 11px;
    font-weight: 400;
}

.main-nav {
    display: grid;
    gap: 22px;
}

.nav-group {
    display: grid;
    gap: 3px;
}

.nav-label {
    padding: 0 10px 6px;
    color: #777772;
    font-family: "GVENT Workspace", "Arial Narrow", sans-serif;
    font-size: 11px;
    font-weight: 400;
    text-transform: uppercase;
}

.main-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 36px;
    padding: 0 10px;
    border-radius: var(--radius);
    color: #c7c7c2;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: background 120ms ease, color 120ms ease;
}

.main-nav a svg {
    width: 17px;
    height: 17px;
    color: #92928d;
}

.main-nav a:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.main-nav a.active {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    background: var(--accent);
    box-shadow: none;
    color: var(--brand-ink);
    font-weight: 700;
}

.main-nav a.active::after {
    position: absolute;
    z-index: -1;
    top: -68px;
    right: -20px;
    width: 108px;
    height: 190px;
    background: url("brand/duesen-fokus-black.svg") center / cover no-repeat;
    content: "";
    opacity: .09;
}

.main-nav a.active svg {
    color: var(--brand-ink);
}

.sidebar-brand-badge {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    display: grid;
    justify-items: start;
    gap: 4px;
    margin-top: auto;
    padding: 10px 11px 9px;
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    background: var(--accent);
}

.sidebar-header .sidebar-brand-badge {
    flex: 1 1 auto;
    width: min(166px, 100%);
    min-height: 62px;
    margin-top: 0;
    padding: 10px 12px 8px;
}

.sidebar-brand-badge::after {
    position: absolute;
    z-index: -1;
    top: -54px;
    right: -24px;
    width: 100px;
    height: 180px;
    background: url("brand/duesen-fokus-black.svg") center / cover no-repeat;
    content: "";
    opacity: .12;
}

.sidebar-brand-badge img {
    display: block;
    width: 86px;
    height: auto;
}

.sidebar-header .sidebar-brand-badge img {
    width: 116px;
}

.sidebar-brand-badge span {
    color: var(--brand-ink);
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
}

.sidebar-header .sidebar-brand-badge span {
    font-size: 10px;
    font-weight: 650;
    text-transform: none;
}

.sidebar-status {
    display: grid;
    gap: 9px;
    margin-top: auto;
    padding: 14px 9px 2px;
    border-top: 1px solid #30302f;
}

.connection-row {
    gap: 8px;
}

.connection-row strong,
.connection-row span {
    font-size: 11px;
    line-height: 1.3;
}

.connection-row strong {
    color: #ededeb;
}

.connection-row span {
    color: #8f8f8a;
}

.connection-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #b6bac0;
}

.connection-dot.online {
    background: var(--teal);
    box-shadow: 0 0 0 3px var(--teal-soft);
}

.sidebar-scrim,
.sidebar-close.icon-button,
.mobile-menu.icon-button {
    display: none;
}

.sidebar-close.icon-button {
    color: #d8d8d3;
}

.sidebar-close.icon-button:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.workspace-main {
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    justify-content: space-between;
    gap: 24px;
    min-height: 74px;
    padding: 12px clamp(20px, 3vw, 44px);
    border-bottom: 1px solid var(--border);
    background: var(--chrome);
    box-shadow: inset 0 -3px var(--accent);
    backdrop-filter: blur(14px);
}

.page-intro p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
}

.topbar-actions,
.command-actions,
.record-actions,
.hero-actions {
    gap: 8px;
}

.hero-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
    min-width: 0;
}

.hero-actions form {
    margin: 0;
}

.page-content {
    width: 100%;
    max-width: 1660px;
    margin: 0 auto;
    padding: 26px clamp(20px, 3vw, 44px) 56px;
}

.button,
.icon-button {
    position: relative;
    border: 1px solid var(--button-border);
    border-radius: var(--button-radius);
    background: var(--button-surface);
    box-shadow: var(--button-shadow);
    color: var(--text-strong);
    cursor: pointer;
    text-decoration: none;
    user-select: none;
    transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease, box-shadow 150ms ease, transform 100ms ease;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 36px;
    padding: 0 13px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.button svg {
    width: 16px;
    height: 16px;
}

.button svg,
.icon-button svg,
.icon-button img {
    opacity: .88;
    transition: opacity 150ms ease;
}

.button.primary,
.icon-button.primary {
    border-color: #c9bd00;
    background: var(--accent);
    color: var(--brand-ink);
    box-shadow: 0 1px 2px rgba(75, 62, 0, .2), inset 0 -1px rgba(75, 62, 0, .18), inset 0 1px rgba(255, 255, 255, .52);
}

.button.primary:hover,
.icon-button.primary:hover {
    border-color: #aaa000;
    background: var(--accent-hover);
    box-shadow: 0 2px 5px rgba(75, 62, 0, .2), inset 0 -1px rgba(75, 62, 0, .2), inset 0 1px rgba(255, 255, 255, .58);
}

.button.secondary,
.button.compact {
    border-color: var(--button-border);
    background: var(--button-surface);
    color: var(--text-strong);
}

.button:hover,
.button.secondary:hover,
.button.compact:hover,
.button.ghost:hover {
    border-color: var(--border-strong);
    background: var(--button-surface-hover);
    box-shadow: var(--button-shadow-hover);
}

.button.ghost {
    border-color: transparent;
    background: transparent;
    box-shadow: none;
    color: var(--muted-strong);
}

.button.compact {
    min-height: 30px;
    padding: 0 9px;
    font-size: 12px;
}

.button.danger {
    color: var(--red);
}

.button.danger:not(.ghost):not(.confirm-danger) {
    border-color: color-mix(in srgb, var(--red) 42%, var(--button-border));
}

.button.danger:hover,
.icon-button.danger:hover {
    border-color: var(--red);
    background: var(--red-soft);
    color: var(--red);
}

.button.disabled,
.button:disabled {
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.45;
    pointer-events: none;
}

.button.full-width {
    width: 100%;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    color: var(--muted-strong);
}

.icon-button:hover {
    border-color: var(--border-strong);
    background: var(--button-surface-hover);
    box-shadow: var(--button-shadow-hover);
    color: var(--text-strong);
}

.button:hover svg,
.icon-button:hover svg,
.icon-button:hover img {
    opacity: 1;
}

.button:not(:disabled):active,
.icon-button:not(:disabled):active {
    box-shadow: inset 0 1px 2px rgba(20, 24, 28, .18);
    transform: translateY(1px);
}

.button.ghost:active {
    box-shadow: none;
}

.sidebar-close.icon-button {
    border-color: rgba(255, 255, 255, .12);
    background: rgba(255, 255, 255, .045);
    box-shadow: none;
}

.global-search,
.search-field {
    position: relative;
    display: flex;
    align-items: center;
}

.global-search {
    width: min(250px, 24vw);
}

.global-search > svg,
.search-field > svg {
    position: absolute;
    left: 11px;
    z-index: 1;
    width: 16px;
    height: 16px;
    color: #8a9096;
    pointer-events: none;
}

.global-search input,
.search-field input {
    padding-left: 35px;
}

.global-search .global-search-results {
    top: calc(100% + 7px);
    right: 0;
    left: auto;
    width: min(360px, calc(100vw - 32px));
}

form[data-live-submit].is-updating {
    opacity: 0.65;
    pointer-events: none;
}

.quick-create {
    position: relative;
}

.quick-create summary {
    list-style: none;
}

.quick-create summary::-webkit-details-marker {
    display: none;
}

.quick-create-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 50;
    display: grid;
    width: 286px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--paper);
    box-shadow: 0 18px 48px rgba(18, 22, 26, 0.16);
}

.quick-create:not([open]) > .quick-create-menu { display: none; }

.quick-create-menu a {
    display: grid;
    grid-template-columns: 28px 1fr;
    gap: 8px;
    align-items: start;
    padding: 10px;
    border-radius: var(--radius);
    color: var(--text);
    text-decoration: none;
}

.quick-create-menu a:hover {
    background: var(--canvas);
}

.quick-create-menu svg {
    margin-top: 2px;
    color: var(--accent);
}

.quick-create-menu span,
.quick-create-menu strong,
.quick-create-menu small {
    display: block;
}

.quick-create-menu strong {
    font-size: 13px;
}

.quick-create-menu small {
    margin-top: 1px;
    color: var(--muted);
    font-size: 11px;
}

.notice {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin-bottom: 16px;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--paper);
    color: var(--muted-strong);
}

.notice svg {
    width: 17px;
    height: 17px;
    margin-top: 1px;
}

.notice.success {
    border-color: #bee0d8;
    background: var(--teal-soft);
    color: #126657;
}

.notice.warning {
    border-color: #ead395;
    background: var(--amber-soft);
    color: #7b510c;
}

.notice.error {
    border-color: #efc4c4;
    background: var(--red-soft);
    color: #9f2929;
}

.inline-notice {
    margin: 12px 16px;
}

code {
    padding: 2px 5px;
    border-radius: 4px;
    background: #eceef0;
    color: #3d4248;
    font-size: 0.92em;
}

.empty-state {
    display: grid;
    justify-items: center;
    gap: 5px;
    min-height: 180px;
    padding: 36px 20px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    color: var(--muted);
    text-align: center;
}

.empty-state svg {
    width: 24px;
    height: 24px;
    margin-bottom: 6px;
}

.empty-state h3,
.empty-state p {
    margin-bottom: 0;
}

.empty-compact {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 72px;
    padding: 14px;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}

.command-bar {
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.command-copy {
    display: grid;
}

.command-copy strong {
    font-size: 13px;
}

.command-copy span {
    color: var(--muted);
    font-size: 11px;
}

.project-editor-grid {
    width: min(100%, 920px);
    margin: 0 auto 18px;
}

.project-record-editor {
    padding: 24px;
}

.project-record-editor > .stack-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.project-record-editor > .stack-form label:last-of-type {
    grid-column: 1 / -1;
}

.project-record-editor > .stack-form > .button {
    justify-self: end;
    grid-column: 1 / -1;
}

.composer {
    margin-bottom: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--paper);
}

.composer summary {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    align-items: center;
    min-height: 48px;
    padding: 0 14px;
    cursor: pointer;
    list-style: none;
}

.composer summary::-webkit-details-marker {
    display: none;
}

.composer summary > span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.composer summary > span svg {
    width: 16px;
    height: 16px;
    color: var(--accent);
}

.composer summary small {
    color: var(--muted);
    font-size: 11px;
}

.composer[open] summary > svg {
    transform: rotate(180deg);
}

.composer-body {
    padding: 15px;
    border-top: 1px solid var(--border);
    background: var(--paper-soft);
}

.search-field {
    width: min(520px, 52vw);
}

.search-field .icon-button {
    position: absolute;
    right: 2px;
    width: 32px;
    height: 32px;
    border-color: transparent;
    background: transparent;
    box-shadow: none;
}

.toolbar,
.panel-section,
.table-section,
.record-browser,
.billing-run,
.master-detail,
.customer-hero,
.document-heading,
.draft-inspector {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--paper);
}

.toolbar,
.panel-section,
.customer-hero,
.document-heading,
.draft-inspector {
    padding: 20px;
}

.toolbar,
.table-section,
.customer-hero,
.record-browser,
.billing-run,
.master-detail {
    margin-bottom: 18px;
}

.section-heading,
.table-meta,
.panel-title,
.billing-run-header {
    justify-content: space-between;
    gap: 16px;
}

.section-heading {
    align-items: flex-start;
    margin-bottom: 16px;
}

.section-heading p,
.form-section-heading p,
.detail-header p,
.billing-run-header p,
.document-heading p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
}

.table-section {
    overflow: hidden;
}

.table-meta {
    min-height: 52px;
    padding: 10px 15px;
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    font-size: 12px;
}

.table-meta strong {
    font-size: 13px;
}

.table-meta > div span {
    margin-top: 1px;
}

.panel-title {
    margin-bottom: 13px;
    color: var(--muted);
    font-size: 12px;
}

.metric-strip,
.stat-grid,
.summary-band {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 18px;
    border: 1px solid var(--border);
    border-top: 3px solid var(--accent);
    border-radius: var(--radius);
    background: var(--paper);
}

.stat-grid-six {
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

.customer-stats {
    width: 100%;
}

.stat-grid.customer-stats article {
    padding: 7px 12px;
}

.stat-grid.customer-stats span {
    font-size: 9px;
    line-height: 1.2;
}

.stat-grid.customer-stats strong {
    margin-top: 2px;
    font-size: 17px;
    line-height: 1.1;
}

.metric-strip > div,
.stat-grid article,
.summary-band > div {
    min-width: 0;
    padding: 15px 17px;
    border-right: 1px solid var(--border);
}

.metric-strip > div:last-child,
.stat-grid article:last-child,
.summary-band > div:last-child {
    border-right: 0;
}

.metric-strip span,
.stat-grid span,
.summary-band span,
.record-metric small,
.document-total span,
.document-total small,
.eyebrow {
    display: block;
    color: var(--muted);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.metric-strip strong,
.stat-grid strong,
.summary-band strong {
    display: block;
    margin-top: 5px;
    overflow: hidden;
    font-family: "GVENT Workspace", "Arial Narrow", sans-serif;
    font-size: 22px;
    font-weight: 400;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.metric-attention {
    box-shadow: inset 3px 0 var(--accent);
}

.workspace-grid,
.customer-work-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 18px;
    align-items: start;
}

.workspace-stack,
.workspace-side {
    display: grid;
    gap: 18px;
    min-width: 0;
}

.workspace-stack > *,
.workspace-side > * {
    margin-bottom: 0;
}

.action-list,
.status-summary,
.timeline {
    display: grid;
}

.action-list a {
    display: grid;
    gap: 2px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
}

.action-list a:last-child {
    border-bottom: 0;
}

.action-list a:hover strong {
    color: var(--accent);
}

.action-list strong {
    font-size: 13px;
}

.action-list span {
    color: var(--muted);
    font-size: 11px;
}

.status-summary {
    gap: 2px;
}

.status-summary div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 31px;
    color: var(--muted);
    font-size: 12px;
}

.status-summary strong {
    font-size: 13px;
}

.record-browser {
    overflow: hidden;
}

.browser-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 66px;
    padding: 12px 17px;
    border-bottom: 1px solid var(--border);
}

.browser-heading h2,
.browser-heading p {
    margin-bottom: 0;
}

.browser-heading p,
.browser-heading > span {
    color: var(--muted);
    font-size: 11px;
}

.record-list {
    display: grid;
}

.record-row {
    position: relative;
    display: grid;
    grid-template-columns: 38px minmax(230px, 1.4fr) repeat(3, minmax(120px, 0.7fr)) 28px 18px;
    gap: 12px;
    align-items: center;
    min-height: 68px;
    padding: 9px 15px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
}

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

.record-row:hover {
    background: #fafbfb;
}

.record-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 7px;
    background: #eff1f3;
    color: #676d74;
}

.record-icon svg {
    width: 16px;
    height: 16px;
}

.record-icon.record-initials {
    flex: 0 0 34px;
    color: var(--brand-ink);
    font-size: 11px;
    font-weight: 750;
}

.record-icon.record-image {
    flex: 0 0 34px;
    overflow: hidden;
}

.record-icon.record-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.customer-heading-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.customer-heading-row .record-icon {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
}

.visual-editor {
    display: grid;
    grid-template-columns: 54px repeat(3, minmax(0, 1fr));
    align-items: end;
    gap: 12px;
}

.visual-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 54px;
}

.visual-preview .record-icon {
    width: 46px;
    height: 46px;
    flex-basis: 46px;
}

.visual-editor .span-2 {
    grid-column: span 2;
}

.record-icon.item-service {
    background: var(--blue-soft);
    color: var(--blue);
}

.record-icon.item-deposit {
    background: var(--amber-soft);
    color: var(--amber);
}

.record-identity strong,
.master-row-copy strong {
    overflow: hidden;
    font-size: 13px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.record-identity small,
.master-row-copy small,
.record-metric small {
    overflow: hidden;
    color: var(--muted);
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.record-metric {
    min-width: 0;
}

.record-metric strong {
    display: block;
    margin-top: 2px;
    overflow: hidden;
    color: var(--muted-strong);
    font-size: 12px;
    font-weight: 550;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sync-mark,
.row-chevron {
    color: #a0a5aa;
}

.sync-mark.is-synced {
    color: var(--teal);
}

.sync-mark svg,
.row-chevron {
    width: 16px;
    height: 16px;
}

.master-detail {
    display: grid;
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
    min-height: 650px;
    overflow: hidden;
}

.master-pane {
    min-width: 0;
    border-right: 1px solid var(--border);
    background: var(--paper-soft);
}

.master-pane-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 58px;
    padding: 10px 12px 10px 15px;
    border-bottom: 1px solid var(--border);
    background: var(--paper);
}

.master-pane-heading strong {
    font-size: 13px;
}

.master-pane-heading span {
    color: var(--muted);
    font-size: 11px;
}

.master-list {
    max-height: calc(100vh - 240px);
    overflow-y: auto;
}

.master-row {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    min-height: 58px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
}

.master-row:hover {
    background: var(--paper);
}

.master-row.is-selected {
    background: var(--paper);
    box-shadow: inset 3px 0 var(--accent);
}

.row-state {
    color: var(--red);
    font-size: 10px;
    font-weight: 600;
}

.item-view-switch {
    display: inline-flex;
    min-height: 36px;
    overflow: hidden;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--paper);
}

.item-view-switch a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 10px;
    border-right: 1px solid var(--border);
    color: var(--muted-strong);
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
}

.item-view-switch a:last-child { border-right: 0; }
.item-view-switch a.active { background: #1f2328; color: #ffffff; }
.item-view-switch svg { width: 15px; height: 15px; }

.item-grid-section {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--paper);
}

.item-grid-wrap {
    max-height: calc(100vh - 230px);
    overflow: auto;
}

.item-grid-table {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
}

.item-grid-table th {
    position: sticky;
    top: 0;
    z-index: 4;
    height: 34px;
    padding: 0 8px;
    border-right: 1px solid #3a3d40;
    border-bottom: 1px solid #3a3d40;
    background: #24272b;
    color: #f4f4f2;
    font-size: 10px;
    font-weight: 650;
    text-align: left;
    white-space: nowrap;
}

.item-grid-table td {
    height: 36px;
    padding: 0;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: var(--paper);
}

.item-grid-table tbody tr:last-child td { border-bottom: 0; }
.item-grid-table th:nth-child(1),
.item-grid-table td:nth-child(1) { position: sticky; left: 0; z-index: 3; width: 38px; min-width: 38px; max-width: 38px; }
.item-grid-table th:nth-child(1) { z-index: 6; background: #1c1f22; text-align: center; }
.item-grid-table th:nth-child(2),
.item-grid-table td:nth-child(2) { width: 130px; min-width: 130px; }
.item-grid-table th:nth-child(3),
.item-grid-table td:nth-child(3) { width: 250px; min-width: 250px; }
.item-grid-table th:nth-child(4),
.item-grid-table td:nth-child(4) { width: 150px; min-width: 150px; }
.item-grid-table th:nth-child(5),
.item-grid-table td:nth-child(5) { width: 140px; min-width: 140px; }
.item-grid-table th:nth-child(6),
.item-grid-table td:nth-child(6) { width: 90px; min-width: 90px; }
.item-grid-table th:nth-child(7),
.item-grid-table td:nth-child(7) { width: 100px; min-width: 100px; }
.item-grid-table th:nth-child(8),
.item-grid-table td:nth-child(8) { width: 100px; min-width: 100px; }
.item-grid-table th:nth-child(9),
.item-grid-table td:nth-child(9) { width: 75px; min-width: 75px; }
.item-grid-table th:nth-child(10),
.item-grid-table td:nth-child(10) { width: 170px; min-width: 170px; }
.item-grid-table th:nth-child(11),
.item-grid-table td:nth-child(11) { width: 180px; min-width: 180px; }
.item-grid-table th:nth-child(12),
.item-grid-table td:nth-child(12),
.item-grid-table th:nth-child(13),
.item-grid-table td:nth-child(13) { width: 78px; min-width: 78px; text-align: center; }
.item-grid-table th:nth-child(14),
.item-grid-table td:nth-child(14) { width: 115px; min-width: 115px; }
.item-grid-table th:nth-child(15),
.item-grid-table td:nth-child(15) { width: 145px; min-width: 145px; }
.item-grid-table th:nth-child(16),
.item-grid-table td:nth-child(16) { width: 240px; min-width: 240px; }
.item-grid-table th:nth-child(17),
.item-grid-table td:nth-child(17) { width: 38px; min-width: 38px; }

.item-grid-number {
    background: #f0f1ef !important;
    color: var(--muted);
    font-size: 10px;
    font-weight: 650;
    text-align: center;
}

.item-grid-table input:not([type="checkbox"]),
.item-grid-table select {
    width: 100%;
    min-width: 0;
    height: 35px;
    padding: 0 8px;
    border: 0;
    border-radius: 0;
    background: transparent;
    font-size: 11px;
}

.item-grid-table input:focus,
.item-grid-table select:focus {
    position: relative;
    z-index: 2;
    outline: 2px solid #146ef5;
    outline-offset: -2px;
    background: var(--control);
}

.item-grid-check input { width: 16px; height: 16px; }
.item-grid-check input:disabled { opacity: 0.3; }

.item-grid-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 37px;
    height: 35px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.item-grid-remove:hover { background: #fbd9d9; color: var(--red); }
.item-grid-remove svg { width: 15px; height: 15px; }

.item-grid-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 62px;
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    background: var(--paper-soft);
}

.item-grid-save {
    display: flex;
    align-items: center;
    gap: 16px;
}

.detail-pane {
    min-width: 0;
    background: var(--paper);
}

.detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    min-height: 110px;
    padding: 22px 24px;
    border-bottom: 1px solid var(--border);
}

.detail-header h2 {
    margin: 5px 0 4px;
    font-size: 23px;
}

.record-form {
    display: grid;
}

.form-section {
    display: grid;
    grid-template-columns: minmax(170px, 220px) minmax(0, 1fr);
    gap: 26px;
    padding: 22px 24px;
    border-bottom: 1px solid var(--border);
}

.form-section-heading h3 {
    margin-bottom: 3px;
}

.form-grid,
.filter-form,
.stack-form {
    display: grid;
    gap: 12px;
}

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

.form-grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.span-2,
.wide-field {
    grid-column: span 2;
}

.toggle-stack {
    display: grid;
    align-content: start;
    gap: 8px;
    padding-top: 21px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 24px;
    background: var(--paper-soft);
}

label {
    display: grid;
    gap: 5px;
    min-width: 0;
}

label > span,
.month-switcher label span {
    color: var(--muted-strong);
    font-size: 11px;
    font-weight: 550;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--control);
    color: var(--text-strong);
    font-size: 13px;
    outline: none;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

input,
select {
    height: 36px;
    padding: 0 10px;
}

textarea {
    min-height: 84px;
    padding: 9px 10px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: #8b9fbe;
    box-shadow: 0 0 0 3px rgba(45, 108, 223, 0.09);
}

.hex-color-picker {
    --selected-color: #000000;
    display: grid;
    grid-template-columns: 38px minmax(86px, 1fr);
    align-items: center;
    gap: 6px;
    width: 100%;
    max-width: 184px;
    min-width: 0;
}

.hex-color-picker input[type="color"] {
    width: 38px;
    min-width: 38px;
    height: 36px;
    padding: 3px;
    overflow: hidden;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--paper);
    cursor: pointer;
}

.hex-color-picker input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.hex-color-picker input[type="color"]::-webkit-color-swatch {
    border: 0;
    border-radius: 2px;
}

.hex-color-picker input[type="color"]::-moz-color-swatch {
    border: 0;
    border-radius: 2px;
}

.hex-color-picker .hex-color-value {
    min-width: 0;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    text-transform: uppercase;
}

.hex-color-picker .hex-color-value[aria-invalid="true"] {
    border-color: var(--red);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--red) 13%, transparent);
}

.check-label {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 30px;
    color: var(--text);
    cursor: pointer;
}

.check-label input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--accent);
}

.check-label > span {
    color: var(--text);
    font-size: 12px;
}

.danger-zone {
    display: flex;
    justify-content: flex-end;
    padding: 14px 24px 18px;
    border-top: 1px solid var(--border);
}

.filter-form {
    grid-template-columns: minmax(220px, 1.5fr) repeat(5, minmax(110px, 1fr)) auto;
    align-items: end;
}

.task-form {
    grid-template-columns: repeat(4, minmax(130px, 1fr));
}

.task-form .wide-field {
    grid-column: span 2;
}

.monthly-form {
    grid-template-columns: minmax(280px, 1fr) minmax(160px, 210px) auto;
}

.recurrence-form,
.draft-line-form,
.item-form {
    grid-template-columns: repeat(4, minmax(130px, 1fr));
}

.board-filter {
    grid-template-columns: minmax(240px, 1fr) 180px 180px auto;
    padding: 12px 15px;
    border-bottom: 1px solid var(--border);
}

.inner-toolbar {
    margin: 0;
    border: 0;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    background: var(--paper-soft);
}

.editor-toolbar {
    background: var(--paper-soft);
}

.split-grid {
    display: grid;
    grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
    gap: 18px;
    margin-bottom: 18px;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    min-width: 960px;
    border-collapse: collapse;
}

.table-wrap.compact table {
    min-width: 680px;
}

th,
td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

th {
    padding-top: 9px;
    padding-bottom: 8px;
    border-top: 3px solid var(--accent);
    background: var(--brand-ink);
    color: #ffffff;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
}

td {
    color: var(--muted-strong);
    font-size: 12px;
}

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

.table-section tbody tr:nth-child(even) td {
    background: var(--row-stripe);
}

tbody tr:hover td {
    background: var(--row-hover);
}

.strong {
    color: var(--text-strong);
    font-weight: 600;
}

.amount {
    text-align: right;
    white-space: nowrap;
}

.position {
    max-width: 460px;
}

.empty {
    height: 110px;
    color: var(--muted);
    text-align: center;
}

.inline-link,
.back-link {
    color: var(--blue);
    font-weight: 550;
    text-decoration: none;
}

.inline-link:hover,
.back-link:hover {
    text-decoration: underline;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    background: #eff1f3;
    color: var(--muted-strong);
    font-size: 10px;
    font-weight: 650;
    white-space: nowrap;
}

.status-done,
.status-sent_to_sevdesk {
    background: var(--teal-soft);
    color: #126657;
}

.status-in_progress,
.type-service,
.type-delivery {
    background: var(--blue-soft);
    color: #275cae;
}

.status-waiting,
.type-billing,
.type-inventory,
.priority-high {
    background: var(--amber-soft);
    color: #80550d;
}

.status-cancelled,
.priority-urgent {
    background: var(--red-soft);
    color: #a52d2d;
}

.priority-low {
    background: #f1effd;
    color: #5b4bb1;
}

.status-100,
.status-backlog {
    background: #eceff3;
    color: #4d5663;
}

.status-200,
.status-in_progress {
    background: #e7f0ff;
    color: #1458b5;
}

.status-300,
.status-cancelled {
    background: #fde8e7;
    color: #a52d2d;
}

.status-500,
.status-done {
    background: #e5f5ed;
    color: #176347;
}

.status-750,
.status-waiting {
    background: #f1edff;
    color: #6045a7;
}

.status-1000,
.status-sent_to_sevdesk {
    background: #dff3f0;
    color: #126657;
}

.status-local_ready {
    border-color: #58a789;
    background: #d9f1e5;
    color: #0b5c3e;
}

.status-50 {
    background: #f8dfe1;
    color: #85212a;
}

.status-todo {
    background: #fff1cf;
    color: #76520f;
}

.type-offer {
    background: #fff1cf;
    color: #76520f;
}

.type-invoice {
    background: #e8ebef;
    color: #303942;
}

.type-order-confirmation {
    background: #e7f0ff;
    color: #1458b5;
}

.type-delivery-note {
    background: #e5f5ed;
    color: #176347;
}

.due-date {
    color: var(--muted-strong);
    font-size: 11px;
    font-weight: 550;
    white-space: nowrap;
}

.due-date.overdue {
    color: var(--red);
}

.count-hot,
.count-muted {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 27px;
    height: 27px;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 650;
}

.count-hot {
    background: var(--red-soft);
    color: var(--red);
}

.count-muted {
    background: #eff1f3;
    color: var(--muted-strong);
}

.inline-status-form {
    display: grid;
    grid-template-columns: minmax(104px, 1fr) auto;
    gap: 5px;
    min-width: 165px;
}

.inline-status-form select {
    height: 30px;
    font-size: 11px;
}

.status-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 11px 15px;
    border-bottom: 1px solid var(--border);
}

.status-strip span {
    padding: 4px 8px;
    border-radius: 999px;
    background: #f0f2f4;
    color: var(--muted);
    font-size: 10px;
}

.status-strip strong {
    margin-left: 3px;
    font-size: 10px;
}

.board-scroll {
    overflow-x: auto;
    padding: 14px;
}

.board-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(240px, 1fr));
    gap: 10px;
    min-width: 1480px;
}

.board-column {
    min-height: 340px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--paper-soft);
}

.board-column > header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 42px;
    padding: 0 11px;
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    font-size: 10px;
    font-weight: 650;
    text-transform: uppercase;
}

.task-card-list {
    display: grid;
    align-content: start;
    gap: 8px;
    padding: 9px;
}

.task-card {
    display: grid;
    min-width: 0;
    gap: 8px;
    padding: 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--paper);
    box-shadow: 0 1px 2px rgba(20, 24, 28, 0.04);
}

.task-card h3,
.task-card p {
    margin-bottom: 0;
    min-width: 0;
    overflow-wrap: anywhere;
}

.task-card p,
.task-description {
    color: var(--muted);
    font-size: 11px;
}

.task-card-top,
.task-card-footer {
    justify-content: space-between;
    gap: 7px;
}

.task-card-footer {
    align-items: flex-start;
    min-width: 0;
    flex-wrap: wrap;
}

.task-card .record-actions,
.task-card .inline-status-form {
    min-width: 0;
    max-width: 100%;
    flex-wrap: wrap;
}

.task-title {
    display: grid;
}

.task-title span {
    color: var(--muted);
    font-size: 10px;
}

.dashboard-task-list {
    display: grid;
}

.dashboard-task-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(92px, auto) 18px;
    align-items: center;
    gap: 14px;
    min-height: 58px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    color: inherit;
    text-decoration: none;
}

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

.dashboard-task-row:hover {
    background: var(--paper-soft);
}

.dashboard-task-copy,
.dashboard-task-due {
    display: grid;
    min-width: 0;
}

.dashboard-task-copy strong,
.dashboard-task-copy small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dashboard-task-copy small,
.dashboard-task-due small {
    color: var(--muted);
    font-size: 10px;
}

.dashboard-task-badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 5px;
}

.dashboard-task-due {
    text-align: right;
}

.dashboard-task-row > .app-icon {
    width: 16px;
    height: 16px;
    color: var(--muted);
}

@media (max-width: 680px) {
    .dashboard-task-row {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 7px 10px;
    }

    .dashboard-task-badges {
        grid-column: 1;
        justify-content: flex-start;
    }

    .dashboard-task-due {
        grid-column: 2;
        grid-row: 1;
    }

    .dashboard-task-row > .app-icon {
        display: none;
    }
}

.task-table {
    width: 100%;
    table-layout: fixed;
}

.task-table th:nth-child(1) { width: 24%; }
.task-table th:nth-child(2) { width: 17%; }
.task-table th:nth-child(3) { width: 12%; }
.task-table th:nth-child(4) { width: 11%; }
.task-table th:nth-child(5) { width: 10%; }
.task-table th:nth-child(6) { width: 9%; }
.task-table th:nth-child(7) { width: 210px; }

.task-table td,
.task-table a,
.task-title strong,
.task-title span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.task-table .record-actions {
    flex-wrap: nowrap;
}

.customer-task-section .table-wrap {
    overflow-x: hidden;
}

.task-table-customer {
    min-width: 0;
}

.task-table-customer th:nth-child(1) { width: 30%; }
.task-table-customer th:nth-child(2) { width: 13%; }
.task-table-customer th:nth-child(3) { width: 13%; }
.task-table-customer th:nth-child(4) { width: 12%; }
.task-table-customer th:nth-child(5) { width: 10%; }
.task-table-customer th:nth-child(6) { width: 22%; }

.task-table-customer th,
.task-table-customer td {
    padding-right: 10px;
    padding-left: 10px;
}

.task-table-customer .record-actions {
    gap: 5px;
    min-width: 0;
}

.task-table-customer .inline-status-form {
    flex: 1;
    grid-template-columns: minmax(0, 1fr) 30px;
    min-width: 0;
}

.task-table-customer .inline-status-form select {
    width: 100%;
    min-width: 0;
}

.timeline {
    gap: 0;
}

.timeline-item {
    display: grid;
    gap: 5px;
    padding: 10px 0 10px 14px;
    border-bottom: 1px solid var(--border);
    box-shadow: inset 2px 0 #dadddf;
}

.timeline-item:last-child {
    border-bottom: 0;
}

.timeline-head {
    justify-content: space-between;
    color: var(--muted);
    font-size: 10px;
}

.timeline-item p,
.timeline-item small {
    margin: 0;
    color: var(--muted-strong);
    font-size: 11px;
}

.timeline-action {
    justify-self: start;
}

.customer-hero {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

.customer-hero h2 {
    margin: 6px 0 10px;
    font-size: 21px;
}

.customer-data-panel {
    margin-bottom: 18px;
    padding: 0;
    overflow: hidden;
}

.customer-data-summary {
    display: grid;
    grid-template-columns: 34px minmax(190px, auto) minmax(0, 1fr) 18px;
    gap: 10px;
    align-items: center;
    min-height: 58px;
    padding: 10px 14px;
    cursor: pointer;
    list-style: none;
}

.customer-data-summary::-webkit-details-marker {
    display: none;
}

.customer-data-summary:hover {
    background: var(--paper-soft);
}

.customer-data-summary-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    color: var(--accent-strong);
    background: var(--paper);
}

.customer-data-summary-icon svg {
    width: 16px;
    height: 16px;
}

.customer-data-summary-copy {
    display: grid;
    gap: 2px;
}

.customer-data-summary-copy strong {
    font-size: 12px;
}

.customer-data-summary-copy small,
.customer-data-summary-meta {
    color: var(--muted);
    font-size: 10px;
}

.customer-data-summary-meta {
    overflow: hidden;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.customer-data-chevron {
    width: 16px;
    height: 16px;
    transition: transform .16s ease;
}

.customer-data-panel[open] .customer-data-chevron {
    transform: rotate(180deg);
}

.customer-data-body {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.customer-data-form {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    align-items: end;
}

.customer-data-form > input[type="hidden"] {
    display: none;
}

.customer-data-wide {
    grid-column: span 2;
}

.customer-data-form > details {
    align-self: stretch;
}

.customer-data-save {
    justify-self: start;
}

.customer-delete-action {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}

.customer-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.customer-meta span {
    padding: 4px 7px;
    border-radius: 4px;
    background: #f0f2f4;
    color: var(--muted-strong);
    font-size: 10px;
}

.month-switcher {
    display: flex;
    align-items: flex-end;
    gap: 9px;
}

.month-switcher > svg {
    align-self: center;
    color: var(--accent);
}

.month-switcher label {
    display: grid;
}

.month-switcher input {
    width: 170px;
}

.billing-run {
    overflow: hidden;
}

.billing-run-header {
    min-height: 92px;
    padding: 17px 18px;
    border-bottom: 1px solid var(--border);
}

.billing-run-header h2 {
    margin: 4px 0 2px;
}

.billing-project-list {
    display: grid;
}

.billing-project-row {
    display: grid;
    grid-template-columns: 38px minmax(240px, 1fr) minmax(160px, 220px) auto;
    gap: 12px;
    align-items: center;
    min-height: 64px;
    padding: 9px 16px;
    border-bottom: 1px solid var(--border);
}

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

.billing-project-row:hover {
    background: #fbfbfc;
}

.billing-state {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--muted-strong);
    font-size: 11px;
    font-weight: 550;
}

.billing-state svg {
    width: 16px;
    height: 16px;
}

.billing-state.is-complete {
    color: var(--teal);
}

.billing-state.is-ready {
    color: var(--blue);
}

.billing-state.is-missing {
    color: var(--amber);
}

.draft-register .table-meta {
    min-height: 58px;
}

.document-heading {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 0;
    padding: 22px 24px;
    border-bottom-right-radius: 0;
    border-bottom-left-radius: 0;
}

.document-heading::before {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 5px;
    background: var(--accent);
    content: "";
}

.document-heading::after {
    position: absolute;
    z-index: -1;
    top: -88px;
    right: 115px;
    width: 190px;
    height: 330px;
    background: url("brand/duesen-fokus-black.svg") center / cover no-repeat;
    content: "";
    opacity: .035;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 18px;
    color: var(--muted-strong);
    font-size: 11px;
}

.back-link svg {
    width: 14px;
    height: 14px;
}

.document-heading h2 {
    margin: 5px 0 4px;
    font-family: "GVENT Workspace", "Arial Narrow", sans-serif;
    font-size: 29px;
    font-weight: 400;
}

.document-total {
    min-width: 190px;
    text-align: right;
}

.document-total strong {
    display: inline-block;
    margin: 4px 0;
    padding: 0 2px;
    box-shadow: inset 0 -9px var(--accent);
    font-family: "GVENT Workspace", "Arial Narrow", sans-serif;
    font-size: 30px;
    font-weight: 400;
}

.document-command-bar {
    justify-content: space-between;
    min-height: 52px;
    margin-bottom: 18px;
    padding: 8px 12px 8px 16px;
    border: 1px solid var(--border);
    border-top: 0;
    border-bottom-right-radius: var(--radius);
    border-bottom-left-radius: var(--radius);
    background: var(--paper-soft);
}

.document-status {
    gap: 7px;
    color: var(--muted);
    font-size: 11px;
}

.document-status strong {
    font-size: 12px;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--amber);
}

.draft-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 310px;
    gap: 18px;
    align-items: start;
}

.draft-main {
    min-width: 0;
}

.invoice-paper {
    box-shadow: var(--shadow-soft);
}

.invoice-lines-table {
    min-width: 640px;
    table-layout: fixed;
}

.invoice-lines-table th,
.invoice-lines-table td {
    padding-right: 8px;
    padding-left: 8px;
    overflow-wrap: break-word;
    word-break: normal;
}

.invoice-lines-table th:nth-child(1) { width: 60px; }
.invoice-lines-table th:nth-child(2) { width: 115px; }
.invoice-lines-table th:nth-child(4) { width: 58px; }
.invoice-lines-table th:nth-child(5) { width: 68px; }
.invoice-lines-table th:nth-child(6) { width: 42px; }
.invoice-lines-table th:nth-child(7) { width: 70px; }
.invoice-lines-table th:nth-child(8) { width: 62px; }

.invoice-lines-table td:nth-child(4),
.invoice-lines-table td:nth-child(5),
.invoice-lines-table td:nth-child(6),
.invoice-lines-table td:nth-child(7) {
    white-space: nowrap;
}

.deposit-row td {
    background: var(--paper);
}

.deposit-row td:first-child {
    box-shadow: inset 2px 0 #d8d39b;
}

.invoice-lines-table .section-row td {
    padding-top: 13px;
    padding-bottom: 8px;
    border-top: 2px solid #222222;
    background: #f6f7f8;
}

.invoice-lines-table .section-row td:first-child {
    display: table-cell;
}

.invoice-lines-table .section-row strong,
.invoice-lines-table .section-row span {
    display: block;
}

.invoice-lines-table .section-row span {
    margin-top: 2px;
    color: var(--muted);
    font-size: 11px;
}

.add-line-panel {
    scroll-margin-top: 90px;
}

.draft-inspector {
    position: sticky;
    top: 94px;
    padding: 0;
    overflow: hidden;
}

.inspector-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.inspector-heading h3 {
    margin: 3px 0 0;
}

.inspector-heading svg {
    color: var(--muted);
}

.draft-inspector .stack-form {
    padding: 16px;
}

.draft-inspector .form-grid {
    gap: 8px;
}

.inspector-totals {
    display: grid;
    padding: 4px 16px 13px;
}

.inspector-totals div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 29px;
    color: var(--muted);
    font-size: 11px;
}

.inspector-totals strong {
    font-size: 12px;
}

.inspector-totals .total-row {
    margin-top: 5px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    color: var(--text-strong);
}

.inspector-totals .total-row strong {
    font-size: 16px;
}

.draft-inspector .danger-zone {
    padding: 12px 16px 16px;
}

.pagination {
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-top: 1px solid var(--border);
}

.pagination span {
    color: var(--muted);
    font-size: 11px;
}

.segmented-tabs {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    width: fit-content;
    margin-bottom: 14px;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--paper);
}

.segmented-tabs a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 32px;
    padding: 0 12px;
    border-radius: 4px;
    color: var(--muted-strong);
    font-size: 12px;
    font-weight: 550;
    text-decoration: none;
}

.segmented-tabs a:hover,
.segmented-tabs a.active {
    background: var(--sidebar);
    color: var(--text-strong);
}

.segmented-tabs a.active {
    box-shadow: 0 1px 2px rgba(20, 24, 28, 0.08);
}

.segmented-tabs svg {
    width: 15px;
    height: 15px;
}

.operation-create-form,
.schedule-form,
.operation-line-form,
.inventory-movement-form,
.deposit-movement-form,
.time-entry-form {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.operation-create-form > .button,
.schedule-form > .button,
.operation-line-form > .button,
.inventory-movement-form > .button,
.deposit-movement-form > .button,
.time-entry-form > .button {
    align-self: end;
    justify-self: start;
}

.operation-filter-bar {
    margin-top: 14px;
}

.operation-filter-form {
    display: grid;
    grid-template-columns: minmax(210px, 1.4fr) repeat(5, minmax(120px, 0.7fr)) auto;
    gap: 8px;
    width: 100%;
    align-items: end;
}

.operation-filter-form .search-field {
    align-self: end;
}

.operation-agenda {
    overflow: hidden;
    margin-top: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--paper);
    box-shadow: var(--shadow-soft);
}

.agenda-date {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 34px;
    padding: 0 14px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: var(--paper-soft);
}

.agenda-date:first-child {
    border-top: 0;
}

.agenda-date span {
    color: var(--text-strong);
    font-size: 11px;
    font-weight: 700;
}

.agenda-date small {
    color: var(--accent-strong);
    font-size: 10px;
    font-weight: 650;
}

.operation-row {
    display: grid;
    grid-template-columns: 58px 34px minmax(220px, 1fr) minmax(110px, 0.45fr) 72px auto auto 16px;
    gap: 12px;
    align-items: center;
    min-height: 64px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    color: inherit;
    text-decoration: none;
}

.operation-row:hover,
.compact-operation-row:hover,
.schedule-row:hover,
.deposit-balance-row:hover {
    background: var(--paper-soft);
}

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

.operation-time {
    display: grid;
    color: var(--text-strong);
    font-size: 12px;
    font-weight: 700;
}

.operation-time small,
.operation-owner small,
.operation-progress small,
.operation-heading-meta span,
.compact-operation-time small,
.compact-operation-copy small,
.site-brief-row small {
    color: var(--muted);
    font-size: 10px;
    font-weight: 450;
}

.operation-owner,
.operation-progress,
.operation-heading-meta > div {
    display: grid;
    min-width: 0;
}

.operation-owner strong,
.operation-progress strong,
.operation-heading-meta strong {
    overflow: hidden;
    font-size: 11px;
    font-weight: 620;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.record-icon.operation-event {
    background: var(--blue-soft);
    color: var(--blue);
}

.record-icon.operation-beverage,
.record-icon.item-product {
    background: var(--teal-soft);
    color: var(--teal);
}

.record-icon.operation-cleaning {
    background: #f4effb;
    color: #7650a8;
}

.record-icon.operation-service,
.record-icon.operation-internal {
    background: var(--amber-soft);
    color: var(--amber);
}

.billing-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    min-height: 23px;
    padding: 0 7px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--paper-soft);
    color: var(--muted-strong);
    font-size: 10px;
    font-weight: 650;
    white-space: nowrap;
}

.billing-pill.billing-ready {
    border-color: #edd69c;
    background: var(--amber-soft);
    color: var(--amber);
}

.billing-pill.billing-drafted,
.billing-pill.billing-invoiced {
    border-color: #c9dbfa;
    background: var(--blue-soft);
    color: var(--blue);
}

.inline-plan-form {
    display: flex;
    align-items: end;
    gap: 8px;
}

.schedule-row,
.deposit-balance-row {
    display: grid;
    grid-template-columns: 36px minmax(220px, 1fr) repeat(3, minmax(120px, 0.45fr)) 34px;
    gap: 12px;
    align-items: center;
    min-height: 62px;
    padding: 9px 14px;
    border-bottom: 1px solid var(--border);
}

.deposit-balance-row {
    grid-template-columns: 36px minmax(220px, 1fr) repeat(2, minmax(120px, 0.4fr)) auto;
}

.schedule-row:last-child,
.deposit-balance-row:last-child {
    border-bottom: 0;
}

.sites-workspace {
    grid-template-columns: minmax(280px, 0.7fr) minmax(0, 1.3fr);
    align-items: start;
}

.site-list {
    display: grid;
}

.site-row {
    display: grid;
    grid-template-columns: 36px minmax(180px, 0.8fr) minmax(180px, 1fr);
    gap: 6px 12px;
    align-items: start;
    padding: 14px;
    border-bottom: 1px solid var(--border);
}

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

.site-row > p,
.site-row > small {
    margin: 0;
    color: var(--muted-strong);
    font-size: 11px;
}

.site-row > small {
    grid-column: 2 / -1;
}

.operation-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 16px;
}

.operation-heading > div:first-child {
    min-width: 0;
}

.operation-heading p {
    margin: 7px 0 0 44px;
    color: var(--muted);
    font-size: 12px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 13px;
    color: var(--muted-strong);
    font-size: 11px;
    text-decoration: none;
}

.back-link svg {
    width: 14px;
    height: 14px;
}

.operation-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.operation-title-row .record-icon {
    width: 34px;
    height: 34px;
}

.operation-title-row h2 {
    overflow-wrap: anywhere;
    margin: 2px 0 0;
    font-size: 21px;
}

.operation-heading-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(110px, auto));
    gap: 22px;
}

.operation-command-bar {
    margin-bottom: 14px;
}

.operation-primary-actions form,
.operation-lines-panel form {
    margin: 0;
}

.booked-mark {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--teal);
    font-size: 11px;
    font-weight: 650;
}

.booked-mark svg {
    width: 14px;
    height: 14px;
}

.operation-detail-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 14px;
    align-items: start;
}

.operation-main-column {
    display: grid;
    gap: 14px;
    min-width: 0;
}

.operation-inspector {
    position: sticky;
    top: 84px;
}

.operation-inspector .panel-section {
    overflow: hidden;
}

.operation-inspector .stack-form {
    padding: 14px;
}

.operation-inspector .danger-zone {
    padding: 0 14px 14px;
}

.operation-lines-table {
    min-width: 820px;
}

.inline-editor-panel {
    padding: 14px;
}

.operation-lower-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    align-items: start;
}

.checklist-list,
.time-entry-list {
    display: grid;
}

.checklist-row,
.time-entry-row {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    gap: 8px;
    align-items: center;
    min-height: 47px;
    padding: 6px 12px;
    border-bottom: 1px solid var(--border);
}

.time-entry-row {
    grid-template-columns: minmax(0, 1fr) auto 44px;
}

.checklist-row > div,
.time-entry-row > div {
    display: grid;
    min-width: 0;
}

.checklist-row strong,
.time-entry-row strong,
.time-entry-row > span {
    font-size: 11px;
    font-weight: 620;
}

.checklist-row small,
.time-entry-row small {
    overflow: hidden;
    color: var(--muted);
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.checklist-row.is-done strong {
    color: var(--muted);
    text-decoration: line-through;
}

.check-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.checklist-row.is-done .check-toggle {
    color: var(--teal);
}

.quick-add-row {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr) 44px;
    gap: 6px;
    padding: 10px 12px;
}

.mini-composer {
    border-top: 1px solid var(--border);
}

.mini-composer summary {
    display: flex;
    align-items: center;
    gap: 7px;
    min-height: 44px;
    padding: 0 12px;
    color: var(--accent-strong);
    font-size: 11px;
    font-weight: 650;
    cursor: pointer;
    list-style: none;
}

.mini-composer summary::-webkit-details-marker {
    display: none;
}

.mini-composer summary svg {
    width: 14px;
    height: 14px;
}

.time-entry-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 0 12px 12px;
}

.site-brief {
    display: grid;
    gap: 4px;
    margin: 0 14px 14px;
    padding: 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--paper-soft);
}

.site-brief strong {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
}

.site-brief strong svg {
    width: 14px;
    height: 14px;
}

.site-brief span,
.site-brief small {
    color: var(--muted-strong);
    font-size: 10px;
}

.compact-operation-list,
.site-brief-list,
.deposit-balance-list {
    display: grid;
}

.compact-operation-row {
    display: grid;
    grid-template-columns: 34px 42px minmax(0, 1fr) auto auto;
    gap: 10px;
    align-items: center;
    min-height: 55px;
    padding: 7px 12px;
    border-bottom: 1px solid var(--border);
    color: inherit;
    text-decoration: none;
}

.compact-operation-row:last-child,
.site-brief-row:last-child {
    border-bottom: 0;
}

.compact-operation-time,
.compact-operation-copy {
    display: grid;
    min-width: 0;
}

.compact-operation-time strong,
.compact-operation-copy strong {
    overflow: hidden;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.site-brief-row {
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr);
    gap: 8px;
    align-items: start;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.site-brief-row svg {
    width: 15px;
    height: 15px;
    color: var(--muted);
}

.site-brief-row span {
    display: grid;
    min-width: 0;
}

.site-brief-row strong {
    font-size: 11px;
}

.stock-overview {
    margin-top: 14px;
}

.deposit-movement-form {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.direct-sale-create-form {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    align-items: end;
}

.span-full {
    grid-column: 1 / -1;
}

.new-customer-fields {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--paper-soft);
}

.new-customer-fields.is-disabled,
.check-label.is-disabled {
    opacity: 0.48;
}

.section-kicker {
    display: flex;
    align-items: center;
    grid-column: 1 / -1;
    gap: 7px;
    color: var(--muted);
    font-size: 11px;
}

.section-kicker svg {
    width: 15px;
    height: 15px;
}

.sales-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 16px;
    align-items: start;
}

.sale-catalog-brief {
    overflow: hidden;
}

.sale-catalog-list {
    display: grid;
}

.sale-catalog-row {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) auto;
    gap: 9px;
    align-items: center;
    min-height: 55px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}

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

.sale-catalog-row > span:nth-child(2) {
    display: grid;
    min-width: 0;
}

.sale-catalog-row strong,
.sale-catalog-row small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sale-catalog-row strong {
    font-size: 11px;
}

.sale-catalog-row small,
.sale-catalog-row em {
    color: var(--muted);
    font-size: 9px;
    font-style: normal;
}

.sale-catalog-row em.low-stock {
    color: var(--red);
    font-weight: 650;
}

.document-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.document-actions .archive-composer {
    position: relative;
    border: 0;
}

.document-actions .archive-composer > summary {
    min-height: 34px;
    padding: 0 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--paper);
    color: var(--ink);
    white-space: nowrap;
}

.archive-composer[open] > summary {
    border-color: var(--ink);
}

.archive-composer > .stack-form {
    position: absolute;
    z-index: 40;
    top: calc(100% + 6px);
    right: 0;
    width: min(380px, calc(100vw - 32px));
    max-height: min(420px, 65vh);
    overflow-y: auto;
    padding: 8px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--paper);
    box-shadow: var(--shadow);
}

.archive-composer > .stack-form .inline-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 34px;
    gap: 6px;
}

.archive-composer > .stack-form .button {
    min-width: 0;
    justify-content: flex-start;
}

.status-dot.cancelled {
    background: var(--red);
}

.sale-cart-composer {
    margin-bottom: 16px;
    border: 1px solid #bddbd5;
    border-radius: var(--radius);
    background: var(--paper);
    box-shadow: var(--shadow-soft);
}

.sale-cart-heading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid #d8e9e5;
    background: var(--teal-soft);
}

.sale-cart-heading > div {
    display: grid;
}

.sale-cart-heading strong {
    font-size: 12px;
}

.sale-cart-heading span:not(.record-icon) {
    color: var(--muted-strong);
    font-size: 10px;
}

.sale-cart-form {
    display: grid;
    grid-template-columns: minmax(250px, 1.7fr) 90px 110px 125px minmax(150px, 1fr) auto;
    gap: 10px;
    align-items: end;
    padding: 13px 14px;
}

.sale-cart-form label {
    min-width: 0;
}

.sale-cart-form .check-label {
    min-height: 36px;
    margin: 0;
}

.locked-mark {
    display: inline-flex;
    color: var(--muted);
}

.locked-mark svg {
    width: 15px;
    height: 15px;
}

.notice.neutral {
    border-color: var(--border);
    background: var(--paper-soft);
    color: var(--muted-strong);
}

.document-process {
    display: grid;
    gap: 8px;
    padding: 13px 16px;
    border-top: 1px solid var(--border);
}

.document-process .panel-title {
    min-height: 22px;
    padding: 0;
    border: 0;
}

.process-hint,
.sevdesk-reference {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--paper-soft);
    color: var(--muted-strong);
    font-size: 10px;
}

.process-hint.warning {
    border-color: #ead7a9;
    background: var(--amber-soft);
}

.process-hint svg,
.sevdesk-reference svg {
    width: 16px;
    height: 16px;
    color: var(--teal);
}

.sevdesk-reference span {
    display: grid;
}

.sevdesk-reference small {
    color: var(--muted);
}

.send-invoice-composer {
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.send-invoice-composer summary {
    display: flex;
    align-items: center;
    gap: 7px;
    min-height: 36px;
    padding: 8px 10px;
    cursor: pointer;
    color: var(--text-strong);
    font-size: 11px;
}

.send-invoice-composer .stack-form {
    padding: 10px;
    border-top: 1px solid var(--border);
}

.document-downloads {
    display: grid;
    border-top: 1px solid var(--border);
}

.document-downloads a {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    color: inherit;
    text-decoration: none;
}

.document-downloads a:hover {
    background: var(--paper-soft);
}

.document-downloads a span {
    display: grid;
}

.document-downloads strong {
    font-size: 11px;
}

.document-downloads small {
    color: var(--muted);
    font-size: 9px;
}

/* Project-first workflows, live search and operational documents */
.main-nav {
    gap: 15px;
}

.quick-create-menu {
    max-height: min(720px, calc(100vh - 90px));
    overflow-y: auto;
}

.record-icon {
    border: 1px solid var(--record-border, #c8cbc9);
    background: var(--record-bg, #eff1f3);
    color: var(--record-fg, #555b61);
}

.record-icon.shape-square { border-radius: 2px; }
.record-icon.shape-rounded { border-radius: 7px; }
.record-icon.shape-circle { border-radius: 50%; }

.badge {
    border: 1px solid #c9ccd0;
    font-weight: 700;
}

.status-done,
.status-completed,
.status-delivered,
.status-returned,
.status-1000,
.status-sent_to_sevdesk {
    border-color: #58a789;
    background: #d9f1e5;
    color: #0b5c3e;
}

.status-in_progress,
.status-active,
.status-confirmed,
.status-running,
.status-200 {
    border-color: #75a5e8;
    background: #dfeaff;
    color: #124f9f;
}

.status-lead,
.status-qualifying,
.status-planned,
.status-queued,
.status-draft,
.status-100 {
    border-color: #aeb5bd;
    background: #e8ebef;
    color: #394451;
}

.status-proposal,
.status-waiting,
.status-partial,
.status-return_pending,
.status-750 {
    border-color: #c99833;
    background: #fff0bd;
    color: #744600;
}

.status-overdue,
.status-exception,
.status-failed,
.status-lost,
.status-cancelled,
.status-300,
.status-50 {
    border-color: #d16b6b;
    background: #fbd9d9;
    color: #8f1f1f;
}

.live-customer-field {
    position: relative;
    min-width: 0;
}

.combobox-input {
    position: relative;
    display: block;
}

.combobox-input > svg {
    position: absolute;
    top: 50%;
    left: 10px;
    z-index: 1;
    width: 15px;
    height: 15px;
    color: var(--muted);
    transform: translateY(-50%);
    pointer-events: none;
}

.combobox-input input {
    width: 100%;
    padding-left: 32px;
}

.combobox-results {
    position: absolute;
    top: calc(100% + 5px);
    right: 0;
    left: 0;
    z-index: 80;
    max-height: min(280px, var(--combobox-max-height, 280px));
    overflow-y: auto;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--paper);
    box-shadow: 0 16px 36px rgba(18, 22, 26, 0.15);
}

.live-customer-field.opens-up .combobox-results {
    top: auto;
    bottom: calc(100% + 5px);
}

.combobox-results:not([hidden]) {
    animation: combobox-results-in 150ms cubic-bezier(.2, .75, .2, 1) both;
    transform-origin: top center;
}

.live-customer-field.opens-up .combobox-results:not([hidden]) {
    transform-origin: bottom center;
}

@keyframes combobox-results-in {
    from { opacity: 0; transform: translateY(-4px) scale(.99); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.combobox-results button {
    display: grid;
    width: 100%;
    gap: 2px;
    padding: 9px 11px;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.combobox-results button:last-child { border-bottom: 0; }
.combobox-results button:hover,
.combobox-results button.active { background: var(--accent-soft); }
.combobox-results strong { font-size: 12px; }
.combobox-results small { color: var(--muted); font-size: 10px; }
.combobox-empty { display: block; padding: 11px; color: var(--muted); font-size: 11px; }

.workspace-form {
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--paper);
}

.form-grid-wide {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 13px;
    align-items: end;
}

.form-grid-wide .span-2 { grid-column: span 2; }
.form-grid-wide .span-full { grid-column: 1 / -1; }

.customer-create-workspace,
.document-start-shell {
    width: min(980px, 100%);
    margin: 0 auto 18px;
}

.document-start-shell {
    display: grid;
    gap: 12px;
}

.document-type-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--paper);
}

.document-type-tabs a {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 46px;
    border-right: 1px solid var(--border);
    color: var(--muted-strong);
    font-size: 12px;
    font-weight: 650;
    text-decoration: none;
}

.document-type-tabs a:last-child { border-right: 0; }
.document-type-tabs a.active { background: var(--accent); color: var(--brand-ink); }
.document-type-tabs svg { width: 16px; height: 16px; }

.documents-type-tabs {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    margin-bottom: 12px;
}

.documents-type-tabs a strong {
    min-width: 20px;
    padding: 2px 5px;
    border: 1px solid currentColor;
    border-radius: 999px;
    font-size: 9px;
    line-height: 1;
    text-align: center;
}

.filter-form.documents-filter-form {
    grid-template-columns: repeat(12, minmax(0, 1fr));
}

.documents-filter-form > label:nth-of-type(1),
.documents-filter-form > .live-customer-field {
    grid-column: span 3;
}

.documents-filter-form > label:not(:nth-of-type(1)):not(.live-customer-field),
.documents-filter-form > .button {
    grid-column: span 2;
}

.documents-filter-form > .button {
    width: 100%;
}

.documents-table {
    min-width: 900px;
    table-layout: fixed;
}

.documents-table th:nth-child(1) { width: 110px; }
.documents-table th:nth-child(2) { width: 118px; }
.documents-table th:nth-child(3) { width: 78px; }
.documents-table th:nth-child(4) { width: 160px; }
.documents-table th:nth-child(5) { width: auto; }
.documents-table th:nth-child(6) { width: 108px; }
.documents-table th:nth-child(7) { width: 94px; }
.documents-table th:nth-child(8) { width: 102px; }

.documents-table td:nth-child(4) .task-title strong {
    white-space: normal;
}

.documents-table th:last-child,
.documents-table td:last-child {
    position: sticky;
    right: 0;
    z-index: 2;
    background: var(--paper);
    box-shadow: -1px 0 0 var(--border);
}

.documents-table thead th:last-child {
    z-index: 3;
    background: var(--brand-ink);
}

.documents-table.is-compact {
    min-width: 0;
}

.documents-table.is-compact th:nth-child(1) { width: 116px; }
.documents-table.is-compact th:nth-child(2) { width: 116px; }
.documents-table.is-compact th:nth-child(3) { width: auto; }
.documents-table.is-compact th:nth-child(4) { width: 108px; }
.documents-table.is-compact th:nth-child(5) { width: 86px; }
.documents-table.is-compact th:nth-child(6) { width: 102px; }

.customer-documents-section .documents-table-wrap {
    overflow-x: hidden;
}

@media (min-width: 1051px) {
    .documents-register .documents-table-wrap {
        overflow-x: hidden;
    }
}

.subnav {
    display: flex;
    gap: 2px;
    margin-bottom: 16px;
    padding-bottom: 1px;
    overflow-x: auto;
    border-bottom: 1px solid var(--border);
}

.subnav a {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 40px;
    padding: 0 13px;
    border-bottom: 2px solid transparent;
    color: var(--muted-strong);
    font-size: 12px;
    font-weight: 650;
    text-decoration: none;
    white-space: nowrap;
}

.subnav a.active { border-bottom-color: var(--accent-hover); color: var(--text-strong); }
.subnav svg { width: 15px; height: 15px; }

.settings-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.settings-grid fieldset {
    display: grid;
    align-content: start;
    gap: 13px;
    margin: 0;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.settings-grid legend { padding: 0 5px; font-size: 12px; font-weight: 700; }
.settings-grid .form-actions { grid-column: 1 / -1; }

.company-settings-layout {
    display: grid;
    grid-template-columns: minmax(520px, 1fr) minmax(320px, .58fr);
    gap: 14px;
    align-items: start;
}

.company-settings-form {
    display: grid;
    gap: 18px;
}

.company-settings-form fieldset {
    margin: 0;
    padding: 15px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.company-settings-form legend { padding: 0 5px; font-size: 12px; font-weight: 700; }
.company-settings-form .form-actions { display: flex; justify-content: flex-end; }

.footer-settings-preview { position: sticky; top: 14px; }
.footer-settings-preview > p { margin: 12px 0 0; color: var(--muted); font-size: 10px; }

.footer-preview-sheet {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 18px;
    margin-top: 18px;
    padding-top: 12px;
    border-top: 2px solid var(--brand-ink);
    font-size: 10px;
    line-height: 1.25;
}

.footer-preview-sheet > div { display: grid; align-content: start; min-width: 0; }
.footer-preview-sheet strong { margin-bottom: 2px; color: var(--text-strong); }
.footer-preview-sheet span { overflow-wrap: anywhere; color: var(--muted-strong); }

.role-admin { border-color: #9c7a18; background: #fff0a8; color: #594300; }
.role-staff { border-color: #75a5e8; background: #dfeaff; color: #124f9f; }

.user-admin-table .task-title { min-width: 250px; }
.user-admin-table .record-actions { justify-content: flex-end; }
.user-admin-table td:last-child { width: 138px; }
.user-account-editor { width: min(860px, 100%); margin-top: 14px; }

.user-editor-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(300px, .8fr);
    gap: 14px;
    margin-top: 14px;
    align-items: start;
}

.audit-command-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: end;
    margin: 14px 0;
}

.filter-form.audit-filter-form {
    grid-template-columns: minmax(220px, 1.4fr) minmax(150px, .7fr) minmax(180px, .9fr) auto;
    margin: 0;
}

.audit-retention-form { display: flex; gap: 8px; align-items: end; }
.audit-retention-form label { width: 120px; }
.audit-log-table { min-width: 940px; table-layout: fixed; }
.audit-log-table th:nth-child(1) { width: 126px; }
.audit-log-table th:nth-child(2) { width: 104px; }
.audit-log-table th:nth-child(3) { width: 220px; }
.audit-log-table th:nth-child(4) { width: 190px; }
.audit-log-table th:nth-child(5) { width: 110px; }
.audit-log-table td strong,
.audit-log-table td small { display: block; }
.audit-log-table td small { margin-top: 2px; color: var(--muted); font-size: 9px; }

.security-enable-notice { display: flex; align-items: center; gap: 10px; margin: 14px 0; }
.security-enable-notice > span { flex: 1; }
.security-enable-notice form { margin: 0; }

@media (max-width: 1280px) {
    .company-settings-layout,
    .user-editor-grid { grid-template-columns: 1fr; }
    .footer-settings-preview { position: static; }
    .audit-command-bar { grid-template-columns: 1fr; }
    .audit-retention-form { justify-content: flex-end; }
}

@media (max-width: 720px) {
    .filter-form.audit-filter-form { grid-template-columns: 1fr; }
    .audit-retention-form { align-items: stretch; flex-direction: column; }
    .audit-retention-form label { width: 100%; }
    .footer-preview-sheet { grid-template-columns: 1fr 1fr; }
    .security-enable-notice { align-items: stretch; flex-direction: column; }
}

.document-template-form {
    display: grid;
    gap: 12px;
}

.document-template-command {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 4px 2px 8px;
}

.document-template-command h2 {
    margin: 2px 0 3px;
    font-size: 20px;
}

.document-template-command p {
    margin: 0;
    color: var(--muted);
    font-size: 11px;
}

.document-template-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--paper);
    overflow: hidden;
}

.document-template-tabs button {
    min-height: 44px;
    padding: 0 12px;
    border: 0;
    border-right: 1px solid var(--border);
    background: transparent;
    color: var(--muted-strong);
    font: inherit;
    font-size: 11px;
    font-weight: 650;
    cursor: pointer;
}

.document-template-tabs button:last-child { border-right: 0; }
.document-template-tabs button:hover { background: var(--paper-soft); }
.document-template-tabs button.active { background: var(--brand-ink); color: #fff; }

.document-template-workspace {
    display: grid;
    grid-template-columns: minmax(420px, 0.82fr) minmax(500px, 1.18fr);
    gap: 14px;
    align-items: start;
}

.document-template-fields {
    min-width: 0;
}

.document-template-panel {
    display: grid;
    gap: 16px;
}

.document-template-panel[hidden] { display: none; }

.document-template-terms {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.document-template-fields .rich-text-surface.ql-container.ql-snow,
.document-template-fields .rich-text-surface .ql-editor {
    min-height: 96px;
}

.document-template-preview {
    position: sticky;
    top: 14px;
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #d7dade;
}

.document-template-preview > header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 42px;
    padding: 0 13px;
    border-bottom: 1px solid var(--border);
    background: var(--paper);
    font-size: 11px;
}

.document-template-preview > header > span,
.document-template-preview > header > div {
    display: flex;
    align-items: center;
    gap: 7px;
}

.document-template-preview > header > span { color: var(--muted); }
.document-template-preview > header small { color: var(--muted); font-size: 10px; font-weight: 600; }

.document-template-preview > header i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #16825d;
    box-shadow: 0 0 0 2px rgba(22, 130, 93, 0.13);
}

.document-template-preview > header i.is-loading { background: #b78300; box-shadow: 0 0 0 2px rgba(183, 131, 0, 0.14); }
.document-template-preview > header i.is-error { background: #b22626; box-shadow: 0 0 0 2px rgba(178, 38, 38, 0.14); }

.template-preview-viewport {
    position: relative;
    max-height: calc(100vh - 220px);
    min-height: 560px;
    padding: 22px;
    overflow: auto;
}

.template-preview-page {
    position: relative;
    margin: 0 auto;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 10px 28px rgba(20, 24, 28, 0.18);
}

.template-preview-page iframe {
    display: block;
    border: 0;
    background: #fff;
    transform-origin: top left;
    pointer-events: none;
}

.template-preview-state {
    position: absolute;
    top: 38px;
    left: 50%;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 34px;
    padding: 0 11px;
    border: 1px solid rgba(35, 31, 32, 0.12);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 5px 16px rgba(20, 24, 28, 0.12);
    color: var(--muted-strong);
    font-size: 10px;
    font-weight: 650;
    transform: translateX(-50%);
}

.template-preview-state svg { width: 14px; height: 14px; animation: template-preview-spin 900ms linear infinite; }
.template-preview-state.is-error { color: #9d2222; }
.template-preview-state.is-error svg { animation: none; }

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

@media (max-width: 1200px) {
    .document-template-workspace { grid-template-columns: 1fr; }
    .document-template-preview { position: static; }
    .template-preview-viewport { max-height: none; }
}

@media (max-width: 720px) {
    .document-template-command { align-items: stretch; flex-direction: column; }
    .document-template-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .document-template-tabs button:nth-child(2) { border-right: 0; }
    .document-template-tabs button:nth-child(-n + 2) { border-bottom: 1px solid var(--border); }
    .document-template-terms { grid-template-columns: 1fr; }
    .template-preview-viewport { min-height: 440px; padding: 12px; }
}

.svg-upload-fields {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 120px;
    gap: 10px;
}

.workspace-grid-two {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    align-items: start;
}

.icon-preset-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 9px;
}

.icon-preset {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 2px 9px;
    align-items: center;
    min-width: 0;
    padding: 9px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.icon-preset .record-icon { grid-row: span 2; }
.icon-preset strong { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.icon-preset small { color: var(--muted); font-size: 9px; }

.crm-board {
    display: grid;
    grid-template-columns: repeat(8, minmax(210px, 1fr));
    gap: 10px;
    padding-bottom: 10px;
    overflow-x: auto;
}

.crm-column {
    min-height: 360px;
    border-top: 3px solid var(--border-strong);
    background: #eaeae7;
}

.crm-column > header {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    font-size: 11px;
    font-weight: 700;
}

.crm-column-body { display: grid; align-content: start; gap: 7px; padding: 0 7px 8px; }
.crm-project { display: grid; gap: 5px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--paper); color: inherit; text-decoration: none; box-shadow: 0 1px 2px rgba(20,24,28,.04); }
.crm-project:hover { border-color: var(--border-strong); }
.crm-project-customer,
.crm-project small { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.crm-project strong { font-size: 12px; }
.crm-project > div { display: flex; justify-content: space-between; color: var(--muted-strong); font-size: 10px; font-weight: 650; }
.crm-empty { padding: 20px 8px; color: var(--muted); font-size: 10px; text-align: center; }

.project-workspace {
    margin: 0 0 18px;
    border-top: 3px solid var(--accent);
    border-bottom: 1px solid var(--border);
    background: var(--paper);
}

.project-workspace-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding: 20px;
}

.project-workspace-head h2 { margin: 2px 0 4px; }
.project-workspace-head p { margin: 0; color: var(--muted); font-size: 11px; }
.project-workspace-actions,
.document-flow-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.project-metrics { margin: 0; border-right: 0; border-left: 0; }
.project-billing-board { border-bottom: 1px solid var(--border); background: var(--paper); }
.project-billing-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px 16px 12px; }
.project-billing-head h3 { margin: 2px 0 3px; font-size: 15px; }
.project-billing-head p { margin: 0; color: var(--muted); font-size: 10px; }
.billing-metric-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.billing-metric { position: relative; display: grid; gap: 2px; min-height: 78px; padding: 12px 15px 10px; border-right: 1px solid var(--border); }
.billing-metric:last-child { border-right: 0; }
.billing-metric::before { position: absolute; top: 0; right: 0; left: 0; height: 3px; background: var(--metric-color); content: ''; }
.billing-metric span { color: var(--muted-strong); font-size: 9px; font-weight: 700; text-transform: uppercase; }
.billing-metric strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.billing-metric small { color: var(--muted); font-size: 9px; }
.billing-metric.ready { --metric-color: #d39b14; }
.billing-metric.drafted { --metric-color: #2b6ed2; }
.billing-metric.receivable { --metric-color: #c83e3e; }
.billing-metric.invoiced { --metric-color: #18865d; }
.project-billing-table { border: 0; }
.project-billing-table table { margin: 0; }
.project-billing-empty { display: flex; align-items: center; gap: 8px; min-height: 54px; padding: 12px 16px; color: var(--muted); font-size: 10px; }
.project-billing-empty svg { width: 16px; height: 16px; }
.project-linked-records { gap: 0; }
.project-linked-records > .table-section { margin: 0; border-right: 0; border-bottom: 0; border-left: 0; border-radius: 0; box-shadow: none; }
.project-linked-records > .table-section:first-child { border-right: 1px solid var(--border); }
.table-subline { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; }

.document-flow {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    background: var(--paper);
}

.document-chain { display: flex; min-width: 0; overflow-x: auto; }
.document-chain-item { position: relative; display: grid; flex: 0 0 auto; gap: 1px; min-width: 105px; padding: 5px 18px 5px 8px; border-right: 1px solid var(--border); color: var(--muted); text-decoration: none; }
.document-chain-item::after { position: absolute; top: 50%; right: 6px; content: '›'; transform: translateY(-50%); }
.document-chain-item:last-child { border-right: 0; }
.document-chain-item:last-child::after { content: ''; }
.document-chain-item span { font-size: 9px; }
.document-chain-item strong { font-size: 11px; }
.document-chain-item.active { background: var(--accent-soft); box-shadow: inset 3px 0 var(--brand-ink), inset 0 -3px var(--accent); color: var(--accent-strong); }

.fulfillment-workbench { margin-top: 14px; overflow: hidden; }
.logistics-heading .eyebrow { margin-bottom: 2px; }
.fulfillment-head-actions { display: flex; align-items: center; gap: 8px; }
.fulfillment-head-actions form { margin: 0; }
.logistics-flow { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--border); background: var(--paper-soft); }
.logistics-flow > span { display: grid; grid-template-columns: 30px minmax(0, 1fr); grid-template-rows: auto auto; gap: 1px 8px; align-items: center; min-height: 62px; padding: 8px 12px; border-right: 1px solid var(--border); }
.logistics-flow > span:last-child { border-right: 0; }
.logistics-flow i { display: grid; grid-row: 1 / span 2; place-items: center; width: 30px; height: 30px; border: 1px solid #aeb3b6; border-radius: 5px; background: var(--paper); color: #34393d; }
.logistics-flow i svg { width: 16px; height: 16px; }
.logistics-flow small { align-self: end; color: var(--muted); font-size: 9px; }
.logistics-flow strong { align-self: start; font-size: 15px; }
.logistics-flow .is-open { background: #fff6d8; }
.logistics-flow .is-open i { border-color: #d7af41; color: #755400; }
.logistics-flow .is-exception { background: #ffeded; }
.logistics-flow .is-exception i { border-color: #d97979; color: #9d2020; }
.booking-legend { display: flex; flex-wrap: wrap; gap: 7px 18px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--paper); color: var(--muted); font-size: 9px; }
.booking-legend b { color: var(--text); }
.fulfillment-list { display: grid; gap: 8px; padding: 8px; background: var(--paper-soft); }
.fulfillment-entry { overflow: hidden; border: 1px solid var(--border); border-radius: 5px; background: var(--paper); }
.fulfillment-entry.has-material-set { border-color: #a3aaad; }
.fulfillment-row { display: grid; grid-template-columns: minmax(190px, 1.5fr) repeat(4, 82px) 116px minmax(150px, 1fr) auto; gap: 8px; align-items: end; padding: 10px 12px; }
.fulfillment-item { align-self: center; display: grid; min-width: 0; }
.fulfillment-item strong { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.fulfillment-item small { color: var(--muted); font-size: 9px; }
.fulfillment-title { display: flex; align-items: center; gap: 7px; min-width: 0; }
.bundle-badge { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 4px; padding: 2px 5px; border: 1px solid #92999d; border-radius: 4px; background: #eef0f1; color: #33393d; font-size: 8px; font-weight: 750; }
.bundle-badge svg { width: 11px; height: 11px; }
.fulfillment-row input { min-width: 0; }
.fulfillment-row input[readonly] { border-color: #c8c9c6; background: #f0f1ef; color: var(--muted); cursor: not-allowed; }
.fulfillment-row .check-label { min-height: 36px; margin: 0; }
.bundle-fulfillment { border-top: 1px solid #b9bec1; background: #f4f5f4; }
.bundle-fulfillment-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 38px; padding: 7px 12px; border-bottom: 1px solid var(--border); }
.bundle-fulfillment-heading > span { display: inline-flex; align-items: center; gap: 7px; }
.bundle-fulfillment-heading svg { width: 14px; height: 14px; }
.bundle-fulfillment-heading strong { font-size: 10px; }
.bundle-fulfillment-heading small { color: var(--muted); font-size: 9px; }
.bundle-fulfillment-row { display: grid; grid-template-columns: minmax(180px, 1.5fr) repeat(4, 76px) minmax(130px, 1fr) 90px 36px; gap: 7px; align-items: end; padding: 8px 12px 8px 32px; border-bottom: 1px solid var(--border); }
.bundle-fulfillment-row:last-child { border-bottom: 0; }
.bundle-fulfillment-item { align-self: center; display: grid; min-width: 0; }
.bundle-fulfillment-item strong { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.bundle-fulfillment-item small { overflow: hidden; color: var(--muted); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.bundle-fulfillment-row label { display: grid; gap: 3px; min-width: 0; }
.bundle-fulfillment-row label > span { color: var(--muted); font-size: 8px; font-weight: 650; }
.bundle-fulfillment-row input { min-width: 0; height: 34px; padding: 5px 7px; }
.bundle-fulfillment-row input[readonly] { background: #e8eae9; color: #858a8d; cursor: not-allowed; }
.bundle-fulfillment-row .badge { align-self: center; justify-self: start; }
.bundle-fulfillment-service { display: grid; grid-template-columns: minmax(180px, 1.5fr) minmax(210px, 1fr); gap: 12px; align-items: center; min-height: 52px; padding: 8px 48px 8px 32px; border-bottom: 1px solid var(--border); }
.bundle-fulfillment-service:last-child { border-bottom: 0; }
.bundle-fulfillment-service > span:last-child { display: grid; grid-template-columns: 22px minmax(0, 1fr); grid-template-rows: auto auto; gap: 0 7px; align-items: center; color: var(--muted); }
.bundle-fulfillment-service > span:last-child svg { grid-row: 1 / span 2; width: 16px; height: 16px; }
.bundle-fulfillment-service > span:last-child strong { color: var(--text); font-size: 9px; }
.bundle-fulfillment-service > span:last-child small { font-size: 8px; }
.delivery-billing-ready { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 12px; border-top: 1px solid #e0bf65; background: #fff6d8; }
.delivery-billing-ready > span { display: grid; grid-template-columns: 18px minmax(0, 1fr); align-items: center; column-gap: 7px; }
.delivery-billing-ready svg { grid-row: 1 / span 2; width: 16px; height: 16px; color: #805500; }
.delivery-billing-ready strong { color: #704900; font-size: 11px; }
.delivery-billing-ready small { color: #765f25; font-size: 9px; }
.billing-pill.billing-invoiced { border-color: #66ab91; background: #d9f1e5; color: #0b5c3e; }

.contact-list { display: grid; }
.contact-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto auto; gap: 8px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.contact-row > span:nth-child(2) { display: grid; min-width: 0; }
.contact-row strong,
.contact-row small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-row strong { font-size: 11px; }
.contact-row small { color: var(--muted); font-size: 9px; }
.contact-quick-actions { display: flex; grid-column: 4; gap: 3px; align-items: center; }
.contact-quick-actions form { display: inline-flex; margin: 0; }
.customer-mobile-contact { display: none; }

progress { width: 130px; height: 8px; accent-color: var(--teal); }

@media (max-width: 1380px) {
    .customer-hero {
        align-items: stretch;
        flex-direction: column;
    }

    .hero-actions {
        justify-content: flex-start;
        width: 100%;
    }

    .operation-filter-form {
        grid-template-columns: minmax(210px, 1fr) repeat(3, minmax(120px, 0.65fr));
    }

    .operation-filter-form label:nth-of-type(5),
    .operation-filter-form label:nth-of-type(6) {
        grid-row: 2;
    }

    .operation-row {
        grid-template-columns: 52px 34px minmax(200px, 1fr) 100px auto auto 16px;
    }

    .operation-progress {
        display: none;
    }
}

@media (max-width: 1280px) {
    .stat-grid-six {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .stat-grid-six article:nth-child(3) {
        border-right: 0;
    }

    .stat-grid-six article:nth-child(-n + 3) {
        border-bottom: 1px solid var(--border);
    }

    .record-row {
        grid-template-columns: 38px minmax(210px, 1.5fr) repeat(2, minmax(110px, 0.8fr)) 28px 18px;
    }

    .record-row .record-metric:nth-of-type(4) {
        display: none;
    }

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

    .filter-form,
    .task-form,
    .recurrence-form,
    .draft-line-form,
    .item-form {
        grid-template-columns: repeat(3, minmax(130px, 1fr));
    }

    .sale-cart-form {
        grid-template-columns: minmax(250px, 2fr) repeat(2, 100px) minmax(150px, 1fr);
    }

    .sale-deposit-toggle,
    .sale-note {
        grid-row: 2;
    }
}

@media (max-width: 1050px) {
    :root {
        --sidebar-width: 214px;
    }

    .global-search {
        display: none;
    }

    .workspace-grid,
    .workspace-grid-two,
    .customer-work-grid,
    .draft-layout,
    .operation-detail-layout,
    .sales-workspace {
        grid-template-columns: 1fr;
    }

    .customer-data-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }

    .fulfillment-row {
        grid-template-columns: minmax(190px, 1.6fr) repeat(4, 72px) 88px;
    }

    .fulfillment-note {
        grid-column: 1 / -2;
    }

    .bundle-fulfillment-row {
        grid-template-columns: minmax(180px, 1.5fr) repeat(4, 70px) 90px 36px;
    }

    .bundle-component-note {
        grid-column: 1 / -3;
    }

    .direct-sale-create-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .draft-inspector,
    .operation-inspector {
        position: static;
    }

    .operation-create-form,
    .schedule-form,
    .operation-line-form,
    .inventory-movement-form,
    .deposit-movement-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .operation-row {
        grid-template-columns: 52px 34px minmax(180px, 1fr) auto auto 16px;
    }

    .operation-owner,
    .operation-progress {
        display: none;
    }

    .master-detail {
        grid-template-columns: minmax(250px, 300px) minmax(0, 1fr);
    }

    .form-section {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .metric-strip,
    .stat-grid,
    .summary-band {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .metric-strip > div:nth-child(2),
    .stat-grid article:nth-child(2),
    .summary-band > div:nth-child(2) {
        border-right: 0;
    }

    .metric-strip > div:nth-child(-n + 2),
    .stat-grid article:nth-child(-n + 2),
    .summary-band > div:nth-child(-n + 2) {
        border-bottom: 1px solid var(--border);
    }

    .record-row {
        grid-template-columns: 38px minmax(190px, 1fr) minmax(110px, 0.7fr) 28px 18px;
    }

    .record-row .record-metric:nth-of-type(3) {
        display: none;
    }
}

@media (max-width: 900px) {
    .invoice-lines-table {
        min-width: 760px;
    }

    .table-wrap.compact .drafts-table {
        min-width: 0;
    }

    .drafts-table thead {
        display: none;
    }

    .drafts-table tbody,
    .drafts-table tr,
    .drafts-table td {
        display: block;
    }

    .drafts-table tbody tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 5px 12px;
        padding: 12px 14px;
        border-bottom: 1px solid var(--border);
    }

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

    .drafts-table td {
        padding: 0;
        border: 0;
    }

    .drafts-table td:nth-child(2) {
        grid-column: 1;
        grid-row: 1;
    }

    .drafts-table td:nth-child(5) {
        grid-column: 2;
        grid-row: 1;
    }

    .drafts-table td:nth-child(3) {
        grid-column: 1;
        grid-row: 2;
    }

    .drafts-table td:nth-child(4) {
        grid-column: 2;
        grid-row: 2;
        text-align: right;
    }

    .drafts-table td:nth-child(1) {
        grid-column: 1;
        grid-row: 3;
        color: var(--muted);
        font-size: 10px;
    }

    .drafts-table td:nth-child(6) {
        grid-column: 2;
        grid-row: 3;
    }

    .drafts-table .record-actions {
        align-items: flex-end;
        flex-direction: row;
    }

    .sales-composer summary small {
        display: none;
    }

    .app-shell {
        display: block;
    }

    .sidebar {
        position: fixed;
        left: 0;
        transform: translateX(-102%);
        width: min(284px, 86vw);
        transition: transform 180ms ease;
    }

    .nav-open .sidebar {
        transform: translateX(0);
        box-shadow: 16px 0 50px rgba(20, 24, 28, 0.2);
    }

    .sidebar-scrim {
        position: fixed;
        inset: 0;
        z-index: 25;
        background: rgba(20, 24, 28, 0.35);
    }

    .nav-open .sidebar-scrim {
        display: block;
    }

    .sidebar-close.icon-button,
    .mobile-menu.icon-button {
        display: inline-flex;
    }

    .topbar {
        gap: 11px;
        min-height: 68px;
        padding: 10px 14px;
    }

    .page-intro {
        flex: 1;
    }

    .page-intro p {
        display: none;
    }

    .topbar-actions .quick-create summary span {
        display: none;
    }

    .topbar-actions .quick-create summary {
        width: 36px;
        padding: 0;
    }

    .page-content {
        padding: 18px 12px 36px;
    }

    .command-bar,
    .billing-run-header,
    .customer-hero,
    .document-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .direct-sale-create-form,
    .new-customer-fields,
    .sale-cart-form,
    .form-grid-wide,
    .settings-grid,
    .fulfillment-row {
        grid-template-columns: 1fr;
    }

    .form-grid-wide .span-2,
    .form-grid-wide .span-full,
    .fulfillment-note {
        grid-column: auto;
    }

    .document-type-tabs {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .document-type-tabs a:nth-child(2) { border-right: 0; }
    .document-type-tabs a:nth-child(-n + 2) { border-bottom: 1px solid var(--border); }

    .project-workspace-head,
    .project-billing-head,
    .document-flow {
        align-items: stretch;
        flex-direction: column;
    }

    .billing-metric-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .billing-metric:nth-child(2) { border-right: 0; }
    .billing-metric:nth-child(-n + 2) { border-bottom: 1px solid var(--border); }
    .delivery-billing-ready { align-items: stretch; flex-direction: column; }
    .logistics-flow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .logistics-flow > span:nth-child(2) { border-right: 0; }
    .logistics-flow > span:nth-child(-n + 2) { border-bottom: 1px solid var(--border); }
    .fulfillment-entry { overflow: visible; }
    .bundle-fulfillment-heading { align-items: flex-start; flex-direction: column; }
    .bundle-fulfillment-row { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 11px; }
    .bundle-fulfillment-service { grid-template-columns: 1fr; padding: 11px; }
    .bundle-fulfillment-item, .bundle-component-note { grid-column: 1 / -1; }
    .bundle-fulfillment-row .badge { align-self: center; }
    .bundle-fulfillment-row .icon-button { justify-self: end; }
    .project-billing-table { overflow: visible; }
    .project-billing-table table,
    .project-billing-table tbody { display: block; width: 100%; min-width: 0; }
    .table-wrap.compact.project-billing-table table { min-width: 0; }
    .project-billing-table thead { display: none; }
    .project-billing-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
    .project-billing-table td { display: block; min-width: 0; padding: 0; border: 0; white-space: normal; }
    .project-billing-table td:nth-child(1) { grid-column: 1; grid-row: 1; }
    .project-billing-table td:nth-child(2) { grid-column: 1; grid-row: 2 / span 2; }
    .project-billing-table td:nth-child(3) { grid-column: 2; grid-row: 1; text-align: right; }
    .project-billing-table td:nth-child(4) { grid-column: 2; grid-row: 2; text-align: right; }
    .project-billing-table td:nth-child(5) { grid-column: 2; grid-row: 3; justify-self: end; }

    .project-linked-records > .table-section:first-child {
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .project-workspace-actions .button {
        flex: 1 1 auto;
    }

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

    .direct-sale-create-form .span-2,
    .direct-sale-create-form .span-full,
    .new-customer-fields .section-kicker,
    .sale-deposit-toggle,
    .sale-note {
        grid-column: auto;
        grid-row: auto;
    }

    .document-actions {
        flex-wrap: wrap;
        width: 100%;
    }

    .search-field {
        width: 100%;
    }

    .command-actions {
        flex-wrap: wrap;
    }

    .item-view-switch {
        width: 100%;
    }

    .item-view-switch a {
        flex: 1;
        justify-content: center;
    }

    .item-grid-wrap {
        max-height: calc(100vh - 260px);
    }

    .item-grid-footer,
    .item-grid-save,
    .svg-upload-fields {
        align-items: stretch;
        grid-template-columns: 1fr;
        flex-direction: column;
    }

    .master-detail {
        display: block;
    }

    .master-pane {
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .master-list {
        display: flex;
        max-height: none;
        overflow-x: auto;
    }

    .master-row {
        flex: 0 0 250px;
        border-right: 1px solid var(--border);
    }

    .detail-header,
    .form-section,
    .form-actions {
        padding-right: 16px;
        padding-left: 16px;
    }

    .form-grid,
    .form-grid-4,
    .project-record-editor > .stack-form,
    .filter-form,
    .task-form,
    .recurrence-form,
    .draft-line-form,
    .item-form,
    .board-filter,
    .monthly-form,
    .split-grid {
        grid-template-columns: 1fr;
    }

    .operation-create-form,
    .schedule-form,
    .operation-line-form,
    .inventory-movement-form,
    .deposit-movement-form,
    .time-entry-form,
    .operation-filter-form,
    .operation-lower-grid {
        grid-template-columns: 1fr;
    }

    .operation-filter-form label:nth-of-type(5),
    .operation-filter-form label:nth-of-type(6) {
        grid-row: auto;
    }

    .span-2,
    .wide-field,
    .task-form .wide-field {
        grid-column: auto;
    }

    .metric-strip,
    .stat-grid,
    .summary-band,
    .stat-grid-six {
        grid-template-columns: 1fr;
    }

    .metric-strip > div,
    .stat-grid article,
    .summary-band > div {
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .metric-strip > div:last-child,
    .stat-grid article:last-child,
    .summary-band > div:last-child {
        border-bottom: 0;
    }

    .record-row {
        grid-template-columns: 36px minmax(0, 1fr) 18px;
        min-height: 62px;
        padding: 8px 12px;
    }

    .record-row .record-metric,
    .record-row .sync-mark {
        display: none;
    }

    .segmented-tabs {
        display: flex;
        width: 100%;
        overflow-x: auto;
    }

    .segmented-tabs a {
        flex: 1 0 auto;
    }

    .operation-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .operation-heading-meta {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
        padding: 10px;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        background: var(--paper);
    }

    .operation-row {
        grid-template-columns: 44px 32px minmax(0, 1fr) 16px;
        gap: 8px;
        padding: 9px 10px;
    }

    .operation-row > .badge,
    .operation-row > .billing-pill,
    .operation-owner,
    .operation-progress {
        display: none;
    }

    .schedule-row,
    .deposit-balance-row {
        grid-template-columns: 34px minmax(0, 1fr) auto;
        padding: 9px 10px;
    }

    .schedule-row .record-metric,
    .deposit-balance-row .record-metric {
        display: none;
    }

    .inline-plan-form {
        align-items: stretch;
        flex-direction: column;
    }

    .compact-operation-row {
        grid-template-columns: 32px 38px minmax(0, 1fr) auto;
        gap: 7px;
        padding: 8px 10px;
    }

    .compact-operation-row .billing-pill {
        display: none;
    }

    .quick-add-row {
        grid-template-columns: 92px minmax(0, 1fr) 30px;
    }

    .site-row {
        grid-template-columns: 32px minmax(0, 1fr);
    }

    .site-row > p,
    .site-row > small {
        grid-column: 2;
    }

    .billing-project-row {
        grid-template-columns: 34px minmax(0, 1fr) auto;
    }

    .billing-project-row .billing-state {
        grid-column: 2 / -1;
    }

    .document-total {
        text-align: left;
    }

    .document-command-bar {
        align-items: flex-start;
        gap: 10px;
        flex-direction: column;
    }

    .document-status {
        flex-wrap: wrap;
    }

    .record-actions,
    .compact-actions {
        align-items: stretch;
        flex-direction: column;
    }

.invoice-row-actions {
        align-items: center;
        flex-direction: row;
    }

    .inline-status-form {
        min-width: 0;
    }

    .quick-create-menu {
        position: fixed;
        top: 66px;
        right: 12px;
        left: 12px;
        width: auto;
    }

    .project-record-editor summary small {
        display: none;
    }
}

.document-list-create summary {
    list-style: none;
}

.document-list-create summary::-webkit-details-marker {
    display: none;
}

[hidden] {
    display: none !important;
}

/* Live item palette */
.item-combobox-field {
    position: relative;
    grid-column: span 2;
}

.item-combobox {
    position: relative;
    min-width: 0;
}

.item-search-control {
    position: relative;
    display: flex;
    align-items: center;
}

.item-search-control > svg,
.item-search-control > img {
    position: absolute;
    left: 10px;
    z-index: 1;
    width: 15px;
    height: 15px;
    color: var(--muted);
    pointer-events: none;
}

.item-search-control input {
    width: 100%;
    padding-right: 34px;
    padding-left: 32px;
}

.item-search-clear {
    position: absolute;
    right: 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 27px;
    height: 27px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.item-search-clear svg,
.item-search-clear img {
    width: 14px;
    height: 14px;
}

.item-search-results {
    position: absolute;
    top: calc(100% + 5px);
    right: 0;
    left: 0;
    z-index: 80;
    max-height: 330px;
    overflow-y: auto;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--paper);
    box-shadow: 0 16px 38px rgba(20, 24, 28, 0.18);
}

.item-search-results button {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    width: 100%;
    min-height: 54px;
    padding: 9px 11px;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: var(--paper);
    color: var(--text);
    text-align: left;
    cursor: pointer;
}

.item-search-results button:last-child {
    border-bottom: 0;
}

.item-search-results button:hover,
.item-search-results button.active {
    background: #fff9d9;
}

.item-search-results button > span,
.item-search-results button strong,
.item-search-results button small,
.item-search-results button b,
.item-search-results button em {
    display: block;
    min-width: 0;
}

.item-search-results button strong {
    overflow: hidden;
    color: var(--text-strong);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.item-search-results button small,
.item-search-results button em {
    margin-top: 2px;
    color: var(--muted);
    font-size: 10px;
    font-style: normal;
}

.item-search-results button > span:last-child {
    text-align: right;
}

.item-search-results button b {
    color: var(--text-strong);
    font-size: 12px;
}

.item-search-results .item-search-free {
    grid-template-columns: 1fr;
    min-height: 46px;
    background: var(--paper-soft);
}

.item-search-empty {
    display: block;
    padding: 16px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.45;
}

.item-selection-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 5px;
    padding: 7px 9px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--paper-soft);
}

.item-selection-preview > span,
.item-selection-preview strong,
.item-selection-preview small,
.item-selection-preview em {
    display: block;
    min-width: 0;
}

.item-selection-preview strong {
    overflow: hidden;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.item-selection-preview small,
.item-selection-preview em {
    color: var(--muted);
    font-size: 9px;
    font-style: normal;
}

.item-preview-side {
    flex: 0 0 auto;
    text-align: right;
}

.item-preview-side b {
    display: inline-block;
    margin-top: 2px;
    padding: 1px 5px;
    border: 1px solid #9fc6e7;
    border-radius: 3px;
    color: #176295;
    font-size: 8px;
}

/* Inline document lines */
.invoice-lines-table {
    min-width: 930px;
}

.invoice-lines-table th:nth-child(1) { width: 86px; }
.invoice-lines-table th:nth-child(2) { width: 170px; }
.invoice-lines-table th:nth-child(3) { width: auto; }
.invoice-lines-table th:nth-child(4) { width: 112px; }
.invoice-lines-table th:nth-child(5) { width: 86px; }
.invoice-lines-table th:nth-child(6) { width: 62px; }
.invoice-lines-table th:nth-child(7) { width: 86px; }
.invoice-lines-table th:nth-child(8) { width: 124px; }

.invoice-line-row td {
    padding: 6px 5px;
    transition: background 120ms ease;
}

.invoice-line-row.is-dirty td {
    background: #fffbed;
}

.invoice-line-row.is-saving td {
    background: #f4f8fc;
}

.invoice-line-row.has-save-error td {
    background: var(--red-soft);
}

.inline-line-control {
    width: 100%;
    min-width: 0;
    min-height: 31px;
    padding: 5px 6px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: var(--text);
    font: inherit;
    line-height: 1.25;
}

select.inline-line-control {
    padding-right: 22px;
}

.inline-line-control:hover {
    border-color: var(--border);
    background: var(--paper);
}

.inline-line-control:focus {
    outline: 0;
    border-color: #7fa7ca;
    background: var(--paper);
    box-shadow: 0 0 0 2px rgba(28, 105, 165, 0.12);
}

.inline-line-title {
    color: var(--text-strong);
    font-weight: 600;
}

.inline-line-description {
    display: block;
    max-height: 120px;
    resize: none;
}

.inline-quantity {
    display: grid;
    grid-template-columns: minmax(40px, .85fr) minmax(42px, 1.15fr);
    gap: 2px;
}

.inline-tax {
    display: flex;
    align-items: center;
}

.inline-tax span {
    margin-left: -3px;
    color: var(--muted);
    font-size: 10px;
}

.amount-input {
    text-align: right;
}

.inline-price-breakdown {
    display: grid;
    gap: 1px;
    margin: -1px 6px 0;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.2;
    text-align: right;
    white-space: nowrap;
}

.inline-price-breakdown span:last-child {
    color: var(--text-strong);
}

.price-display-note {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.inline-line-actions {
    gap: 2px;
    justify-content: flex-end;
    min-width: 0;
}

.inline-line-actions form {
    display: inline-flex;
    margin: 0;
}

.inline-line-actions .icon-button,
.inline-save-state {
    width: 27px;
    min-width: 27px;
    height: 27px;
}

.inline-save-state {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--teal);
}

.inline-save-state svg,
.inline-save-state img {
    width: 14px;
    height: 14px;
}

.inline-save-state[data-state="dirty"] { color: var(--amber); }
.inline-save-state[data-state="saving"] { color: var(--blue); opacity: .7; }
.inline-save-state[data-state="error"] { color: var(--red); }

.promote-line-button {
    color: #785f00;
}

/* Position to item dialog */
.line-to-item-dialog {
    width: min(720px, calc(100vw - 28px));
    max-height: calc(100vh - 42px);
    padding: 0;
    overflow: auto;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--paper);
    color: var(--text);
    box-shadow: 0 22px 70px rgba(14, 18, 22, 0.3);
}

.line-to-item-dialog::backdrop {
    background: rgba(17, 20, 24, 0.5);
    backdrop-filter: blur(2px);
}

.line-to-item-form > header {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) 34px;
    gap: 12px;
    align-items: start;
    padding: 17px 18px;
    border-bottom: 1px solid var(--border);
}

.line-to-item-form header h3,
.line-to-item-form header p {
    margin: 0;
}

.line-to-item-form header h3 {
    font-size: 17px;
}

.line-to-item-form header p {
    margin-top: 3px;
    color: var(--muted);
    font-size: 11px;
}

.line-to-item-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 18px;
}

.line-to-item-grid label {
    min-width: 0;
}

.line-to-item-grid .span-2 {
    grid-column: span 2;
}

.line-to-item-form > footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 13px 18px;
    border-top: 1px solid var(--border);
    background: var(--paper-soft);
}

/* Rich document text */
.rich-text-field {
    display: grid;
    gap: 5px;
    min-width: 0;
}

.rich-text-label {
    color: var(--muted-strong);
    font-size: 11px;
    font-weight: 600;
}

.rich-text-shell {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--paper);
}

.rich-text-toolbar.ql-toolbar.ql-snow {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 4px;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: var(--paper-soft);
}

.rich-text-toolbar.ql-toolbar.ql-snow .ql-formats {
    display: inline-flex;
    margin: 0 3px 0 0;
}

.rich-text-toolbar.ql-toolbar.ql-snow button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 27px;
    height: 27px;
    padding: 4px;
    border-radius: 3px;
}

.rich-text-toolbar button:hover,
.rich-text-toolbar button.ql-active {
    background: #fff3aa !important;
    color: var(--brand-ink) !important;
}

.rich-text-toolbar button svg,
.rich-text-toolbar button img {
    width: 15px;
    height: 15px;
}

.rich-text-surface.ql-container.ql-snow {
    min-height: 112px;
    max-height: 260px;
    overflow-y: auto;
    border: 0;
    font-family: inherit;
    font-size: 12px;
}

.rich-text-surface .ql-editor {
    min-height: 112px;
    padding: 10px 11px;
    line-height: 1.45;
}

.rich-text-shell.is-static,
.rich-text-shell[data-readonly="1"] {
    border-color: var(--border);
    background: var(--paper-soft);
}

.rich-text-shell[data-readonly="1"] .rich-text-surface {
    padding: 9px 10px;
    color: var(--muted-strong);
    font-size: 11px;
    line-height: 1.45;
}

.rich-text-shell textarea:not([hidden]) {
    width: 100%;
    min-height: 110px;
    border: 0;
    border-radius: 0;
}

@media (max-width: 1350px) {
    .draft-layout {
        grid-template-columns: 1fr;
    }

    .draft-inspector {
        position: static;
    }
}

@media (max-width: 680px) {
    .line-to-item-grid {
        grid-template-columns: 1fr;
    }

    .line-to-item-grid .span-2 {
        grid-column: auto;
    }

    .line-to-item-form > footer {
        align-items: stretch;
        flex-direction: column-reverse;
    }

    .line-to-item-form > footer .button {
        width: 100%;
    }
}

/* 2026 live document grid */
.position-grid-wrap {
    border-bottom: 1px solid var(--border);
}

.invoice-lines-table.is-live-grid {
    min-width: 1120px;
    table-layout: fixed;
}

.invoice-lines-table.is-live-grid th:nth-child(1) { width: 34px; }
.invoice-lines-table.is-live-grid th:nth-child(2) { width: 102px; }
.invoice-lines-table.is-live-grid th:nth-child(3) { width: 190px; }
.invoice-lines-table.is-live-grid th:nth-child(4) { width: auto; }
.invoice-lines-table.is-live-grid th:nth-child(5) { width: 126px; }
.invoice-lines-table.is-live-grid th:nth-child(6) { width: 88px; }
.invoice-lines-table.is-live-grid th:nth-child(7) { width: 64px; }
.invoice-lines-table.is-live-grid th:nth-child(8) { width: 92px; }
.invoice-lines-table.is-live-grid th:nth-child(9) { width: 92px; }

.line-drag-cell { text-align: center; }

.line-drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 3px;
    background: transparent;
    color: #8a8e92;
    cursor: grab;
}

.line-drag-handle:hover { background: #ecefee; color: #303438; }
.line-drag-handle:active { cursor: grabbing; }
.line-drag-handle svg, .line-drag-handle img { width: 16px; height: 16px; }
.line-sort-ghost td { background: #fff5b8 !important; opacity: .55; }
.line-sort-chosen td { box-shadow: inset 0 1px #d1aa00, inset 0 -1px #d1aa00; }
.line-sort-drag { box-shadow: 0 10px 28px rgba(17, 20, 24, .18); }
[data-sortable-lines].is-reordering { opacity: .72; }
[data-sortable-lines].is-reordered td { animation: line-saved-flash 650ms ease; }
@keyframes line-saved-flash { 0% { background: #ddf5e8; } 100% { background: transparent; } }

.invoice-line-row.is-section td { background: #f1f2f0; border-top: 2px solid #303438; }
.invoice-line-row.is-section .inline-line-title { font-weight: 750; text-transform: uppercase; }
.invoice-line-row.is-section .line-rich-text { opacity: .85; }
.invoice-line-row.is-text td { background: #f7f8f7; }
.invoice-line-row.is-text .inline-line-title { font-weight: 700; }
.invoice-line-row.is-spacer td { height: 34px; padding-top: 5px; padding-bottom: 5px; background: var(--spacer-color, #fff); }
.invoice-line-row.is-spacer td:nth-child(n+4):not(:last-child) { color: transparent; }
.spacer-editor-label { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 10px; font-weight: 650; white-space: nowrap; }
.spacer-editor-label svg, .spacer-editor-label img { width: 14px; height: 14px; }
.spacer-color-editor { display: flex; align-items: center; gap: 8px; }
.spacer-color-editor .hex-color-picker { grid-template-columns: 34px 88px; width: 128px; min-width: 128px; }
.spacer-color-editor .hex-color-picker input[type="color"] { width: 34px; min-width: 34px; height: 28px; padding: 2px; }
.spacer-color-editor .hex-color-picker .hex-color-value { height: 28px; padding-inline: 7px; font-size: 11px; }
.spacer-editor-rule { display: block; width: 100%; border-top: 1px dashed rgba(35, 31, 32, .28); }
.invoice-line-row [disabled] { opacity: .38; cursor: not-allowed; }

.line-rich-text {
    min-width: 210px;
    overflow: hidden;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
}

.line-rich-text:hover,
.line-rich-text:focus-within { border-color: var(--border); background: var(--paper); }

.line-rich-toolbar.ql-toolbar.ql-snow {
    display: none;
    align-items: center;
    gap: 2px;
    min-height: 29px;
    padding: 2px 3px;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: #f4f5f4;
}

.line-rich-text:focus-within .line-rich-toolbar.ql-toolbar.ql-snow { display: flex; }
.line-rich-toolbar.ql-toolbar.ql-snow .ql-formats { display: inline-flex; margin: 0 2px 0 0; }
.line-rich-toolbar.ql-toolbar.ql-snow button { display: inline-flex; align-items: center; justify-content: center; width: 25px; height: 24px; padding: 4px; border-radius: 3px; }
.line-rich-toolbar.ql-toolbar.ql-snow button:hover,
.line-rich-toolbar.ql-toolbar.ql-snow button.ql-active { background: #fff7a8; color: var(--brand-ink); }
.line-rich-toolbar button svg, .line-rich-toolbar button img { width: 14px; height: 14px; }
.line-rich-surface.ql-container.ql-snow { min-height: 38px; max-height: 150px; overflow-y: auto; border: 0; font-family: inherit; font-size: 11px; }
.line-rich-surface .ql-editor { min-height: 38px; padding: 7px 7px; line-height: 1.35; }
.line-rich-surface .ql-editor p { margin: 0; }
.line-rich-surface .ql-editor ul, .line-rich-surface .ql-editor ol { padding-left: 17px; }
.line-description-static { color: var(--muted-strong); font-size: 11px; line-height: 1.35; }
.line-description-static p { margin: 0 0 3px; }

.line-action-cell { position: relative; }
.line-options { position: relative; }
.line-options > summary { list-style: none; }
.line-options > summary::-webkit-details-marker { display: none; }
.line-options-panel {
    position: absolute;
    z-index: 35;
    top: 31px;
    right: 0;
    display: grid;
    gap: 10px;
    width: 230px;
    padding: 12px;
    border: 1px solid var(--border-strong);
    border-radius: 5px;
    background: var(--paper);
    box-shadow: 0 14px 34px rgba(16, 20, 24, .18);
}
.line-options-panel label { display: grid; gap: 4px; color: var(--muted); font-size: 10px; }
.line-options-panel .button { justify-content: flex-start; }

.position-quick-add {
    display: grid;
    grid-template-columns: 24px 92px minmax(180px, 1fr) 55px 68px 68px 54px 52px 30px;
    gap: 5px;
    align-items: end;
    padding: 9px 8px 10px;
    background: #f4f5f4;
    border-top: 2px solid #fff200;
}
.position-composer-zone {
    position: relative;
}

.position-sheet-header,
.position-sheet-scrim,
.mobile-document-dock,
.mobile-line-kind,
.mobile-line-expand,
.quick-type-rail,
.quick-description-mobile {
    display: none;
}

.position-quick-add .icon-button.primary > span {
    display: none;
}

.theme-toggle [data-theme-icon] {
    display: none;
}

html[data-theme="light"] .theme-toggle [data-theme-icon="light"],
html[data-theme="dark"] .theme-toggle [data-theme-icon="dark"] {
    display: inline-flex;
}
.position-quick-add > label { display: grid; gap: 3px; min-width: 0; color: var(--muted); font-size: 9px; }
.position-quick-add input,
.position-quick-add select { width: 100%; min-width: 0; height: 31px; padding: 5px 6px; font-size: 11px; }
.position-add-mark { display: inline-flex; align-items: center; justify-content: center; height: 31px; color: #756000; }
.position-add-mark svg, .position-add-mark img { width: 16px; height: 16px; }
.position-quick-add .item-search-control { min-height: 31px; }
.position-quick-add .item-selection-preview { display: none !important; }
.position-quick-add .quick-spacer-color { display: none; }
.position-quick-add .quick-deposit { display: flex; align-items: center; justify-content: center; gap: 4px; height: 31px; }
.position-quick-add .quick-deposit input { width: 14px; height: 14px; }
.position-quick-add .icon-button.primary { width: 31px; height: 31px; border-color: #d6ca00; background: #fff200; color: #231f20; }
.position-quick-add .icon-button.primary:hover { background: #f1ca00; }
.quick-add-state { grid-column: 3 / -1; min-height: 0; color: var(--teal); font-size: 10px; }
.position-quick-add.is-saving { opacity: .7; }
.position-quick-add.has-error .quick-add-state { color: var(--red); }
.position-quick-add.is-section .quick-deposit,
.position-quick-add.is-text .quick-deposit,
.position-quick-add.is-spacer .quick-deposit { opacity: .35; pointer-events: none; }
.position-quick-add.is-text,
.position-quick-add.is-section { background: #f7f8f7; }
.position-quick-add.is-spacer { background: var(--quick-spacer-color, #fff); }
.position-quick-add.is-spacer .quick-item { display: none; }
.position-quick-add.is-spacer .quick-spacer-color { display: grid; }

/* In-app A4 document preview */
.document-preview-dialog {
    width: min(1120px, calc(100vw - 30px));
    height: min(900px, calc(100vh - 30px));
    padding: 0;
    overflow: hidden;
    border: 1px solid #aeb2b5;
    border-radius: 6px;
    background: #e6e8ea;
    color: var(--text);
    box-shadow: 0 24px 72px rgba(12, 16, 20, .35);
}
.document-preview-dialog::backdrop { background: rgba(15, 18, 22, .58); backdrop-filter: blur(2px); }
.document-preview-dialog > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 58px; padding: 8px 12px 8px 16px; border-bottom: 1px solid var(--border); background: var(--paper); }
.document-preview-dialog > header > div:first-child { display: grid; gap: 2px; }
.document-preview-dialog > header strong { font-size: 13px; }
.document-preview-actions { display: flex; align-items: center; gap: 7px; }
.document-preview-canvas { height: calc(100% - 58px); padding: 14px; overflow: auto; }
.document-preview-canvas iframe { display: block; width: 100%; height: 100%; min-width: 840px; border: 0; background: #fff; box-shadow: 0 5px 20px rgba(20, 24, 28, .12); }

/* Reusable custom icon assets */
.icon-asset-mask {
    display: inline-block;
    width: 1em;
    height: 1em;
    background: currentColor;
    -webkit-mask: var(--icon-asset) center / contain no-repeat;
    mask: var(--icon-asset) center / contain no-repeat;
}
.icon-asset-image { display: block; width: 100%; height: 100%; object-fit: contain; }
.record-icon > .icon-asset-mask { width: 17px; height: 17px; }
.record-icon > .icon-asset-image { width: 74%; height: 74%; }

/* Live article workspace */
.item-command-bar {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) auto;
    align-items: end;
}

.item-command-bar .command-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
}

.item-live-search { margin: 0; }

.item-live-filters {
    display: flex;
    gap: 7px;
}

.item-live-filters label {
    display: grid;
    gap: 3px;
}

.item-live-filters label > span {
    color: var(--muted);
    font-size: 9px;
    font-weight: 650;
}

.item-live-filters select {
    min-width: 122px;
    height: 36px;
    padding-top: 0;
    padding-bottom: 0;
}

.item-group-strip {
    display: flex;
    align-items: stretch;
    gap: 3px;
    margin: 0 0 10px;
    padding: 0 2px 5px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
}

.item-group-filter,
.item-group-manage {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 7px;
    min-height: 39px;
    padding: 5px 9px;
    border: 1px solid transparent;
    border-bottom: 3px solid transparent;
    border-radius: 5px 5px 2px 2px;
    background: transparent;
    color: var(--muted-strong);
    font: inherit;
    font-size: 10px;
    font-weight: 650;
    cursor: pointer;
}

.item-group-filter:hover,
.item-group-manage:hover { border-color: var(--border); background: var(--paper-soft); color: var(--text); }
.item-group-filter.is-active {
    border-color: var(--border);
    border-bottom-color: var(--item-group-color, #25292d);
    background: var(--paper);
    color: var(--text);
}
.item-group-filter b {
    min-width: 19px;
    padding: 2px 5px;
    border-radius: 8px;
    background: var(--control);
    color: var(--muted);
    font-size: 8px;
    text-align: center;
}
.item-group-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 25px;
    height: 25px;
    border: 1px solid color-mix(in srgb, var(--item-group-color, #7b8185) 55%, var(--border));
    border-radius: 5px;
    background: color-mix(in srgb, var(--item-group-color, #7b8185) 13%, var(--paper));
    color: var(--item-group-color, #565d61);
}
.item-group-mark svg,
.item-group-mark .icon-asset-mask { width: 14px; height: 14px; }
.item-group-filter.is-ungrouped { --item-group-color: #7b8185; }
.item-group-manage { margin-left: auto; border-left-color: var(--border); }
.item-group-manage svg { width: 15px; height: 15px; }

.item-metrics { margin-bottom: 14px; }

.item-live-workspace {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--paper);
}

.item-live-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 48px;
    padding: 8px 12px 8px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--paper);
}

.item-live-meta > div { display: grid; gap: 2px; }
.item-live-meta strong { font-size: 12px; }
.item-live-meta span { color: var(--muted); font-size: 10px; }
.live-save-legend { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.live-save-legend i { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 3px rgba(0, 140, 114, .12); }

.item-live-table-wrap {
    max-height: calc(100vh - 276px);
    overflow: auto;
    overscroll-behavior: contain;
}

.item-live-table {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
}

.item-live-table th {
    position: sticky;
    top: 0;
    z-index: 8;
    height: 34px;
    padding: 0 7px;
    border-right: 1px solid #404448;
    border-bottom: 1px solid #404448;
    background: #25292d;
    color: #f6f7f6;
    font-size: 9px;
    font-weight: 700;
    text-align: left;
    white-space: nowrap;
}

.item-live-table td {
    height: 43px;
    padding: 0;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: var(--paper);
    vertical-align: middle;
}

.item-live-table th:nth-child(1), .item-live-table td:nth-child(1) { width: 48px; min-width: 48px; text-align: center; }
.item-live-table th:nth-child(2), .item-live-table td:nth-child(2) { width: 118px; min-width: 118px; }
.item-live-table th:nth-child(3), .item-live-table td:nth-child(3) { width: 260px; min-width: 260px; }
.item-live-table th:nth-child(4), .item-live-table td:nth-child(4) { width: 122px; min-width: 122px; }
.item-live-table th:nth-child(5), .item-live-table td:nth-child(5) { width: 160px; min-width: 160px; }
.item-live-table th:nth-child(6), .item-live-table td:nth-child(6) { width: 94px; min-width: 94px; }
.item-live-table th:nth-child(7), .item-live-table td:nth-child(7) { width: 76px; min-width: 76px; }
.item-live-table th:nth-child(8), .item-live-table td:nth-child(8) { width: 67px; min-width: 67px; }
.item-live-table th:nth-child(9), .item-live-table td:nth-child(9) { width: 92px; min-width: 92px; }
.item-live-table th:nth-child(10), .item-live-table td:nth-child(10) { width: 170px; min-width: 170px; }
.item-live-table th:nth-child(11), .item-live-table td:nth-child(11) { width: 82px; min-width: 82px; text-align: center; }
.item-live-table th:nth-child(12), .item-live-table td:nth-child(12) { width: 100px; min-width: 100px; }
.item-live-table th:nth-child(13), .item-live-table td:nth-child(13) { width: 72px; min-width: 72px; text-align: center; }

.item-live-table input:not([type="checkbox"]),
.item-live-table select {
    width: 100%;
    min-width: 0;
    height: 42px;
    padding: 0 7px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--text);
    font-size: 10px;
}

.item-live-table input:hover,
.item-live-table select:hover { background: var(--paper-soft); }

.item-live-table input:focus,
.item-live-table select:focus {
    position: relative;
    z-index: 3;
    outline: 2px solid #146ef5;
    outline-offset: -2px;
    background: var(--control);
}

.item-live-table .item-live-name { font-weight: 700; }
.item-live-row.is-inactive { opacity: .63; }
.item-live-row.is-dirty td { background: #fffdf0; }
.item-live-row.is-saving td { background: #f1f7ff; }
.item-live-row.has-save-error td { background: #fff1f1; }

.item-visual-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 43px;
    height: 42px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.item-visual-button:hover { background: #f1f2f1; }
.item-visual-button .record-icon { width: 31px; height: 31px; }
.item-visual-button .record-icon > .icon-asset-mask { width: 16px; height: 16px; }
.item-new-icon { width: 28px; height: 28px; border-style: dashed; background: #fff8c7; color: #665400; }

.item-stock-cell { padding: 0 7px !important; text-align: right; }
.item-stock-cell strong, .item-stock-cell small { display: block; }
.item-stock-cell strong { font-size: 11px; }
.item-stock-cell small, .item-stock-cell span { color: var(--muted); font-size: 8px; }
.item-stock-cell.is-low { background: #fff0d9 !important; color: #8d4300; }
.item-live-muted { padding: 0 7px !important; color: var(--muted); font-size: 9px; }
.item-sync-cell { padding: 0 7px !important; color: var(--muted); font-size: 9px; }
.item-sync-cell svg, .item-sync-cell img { width: 14px; height: 14px; margin-right: 4px; vertical-align: middle; }
.item-sync-cell.is-synced { color: #007761; }

.item-live-new-row td { position: sticky; top: 34px; z-index: 6; background: #fffbed; border-bottom-color: #d6b100; }
.item-live-new-row td:first-child { z-index: 7; }
.item-live-new-row .badge { background: #fff2a6; border-color: #d6b100; color: #5b4a00; }
.live-row-state { display: inline-block; width: 7px; height: 7px; margin-left: 4px; border-radius: 50%; background: #b7bbbe; vertical-align: middle; }
.live-row-state[data-state="saved"] { background: var(--teal); }
.live-row-state[data-state="dirty"] { background: #d6a800; }
.live-row-state[data-state="saving"] { background: #146ef5; animation: live-state-pulse .85s infinite alternate; }
.live-row-state[data-state="error"] { background: var(--red); }
@keyframes live-state-pulse { to { opacity: .25; } }

.item-live-detail-row > td { height: auto; background: #f4f5f4; }
.item-live-detail-shell { position: sticky; left: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0; width: min(1400px, calc(100vw - 322px)); border-top: 2px solid #fff200; }
.item-visual-inline-form, .item-inline-operations, .item-inline-sync { min-width: 0; padding: 16px; border-right: 1px solid var(--border); }
.item-detail-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.item-detail-heading > div { display: grid; gap: 2px; }
.item-detail-heading strong { font-size: 12px; }
.item-inline-visual-editor { grid-template-columns: 58px repeat(2, minmax(0, 1fr)); gap: 9px; }
.item-visual-inline-form > footer { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding-top: 12px; }
.item-inline-detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.item-inline-detail-grid > label { display: grid; gap: 4px; min-width: 0; }
.item-inline-detail-grid > label > span { color: var(--muted); font-size: 9px; font-weight: 650; }
.item-inline-detail-grid > .check-label { display: flex; align-items: center; gap: 7px; min-height: 36px; padding-top: 12px; }
.item-inline-detail-grid > .check-label > span { color: var(--text); font-size: 10px; }
.item-inline-detail-grid .span-2 { grid-column: span 2; }
.item-inline-detail-grid textarea { resize: vertical; }
.bundle-derived-field { display: grid; gap: 2px; padding: 9px 10px; border-left: 3px solid #d2b900; background: #fff9d6; }
.bundle-derived-field > span { color: #6a5b00; font-size: 8px; font-weight: 700; text-transform: uppercase; }
.bundle-derived-field strong { font-size: 10px; }
.bundle-derived-field small { color: #665f38; font-size: 8px; }
.bundle-derived-rule { display: grid; grid-column: span 2; grid-template-columns: 24px minmax(0, 1fr); gap: 8px; align-items: center; min-height: 44px; padding: 7px 9px; border: 1px solid var(--border); background: var(--paper-soft); }
.bundle-derived-rule > svg { width: 17px; height: 17px; color: #6a5b00; }
.bundle-derived-rule > span { display: grid; gap: 2px; }
.bundle-derived-rule strong { font-size: 9px; }
.bundle-derived-rule small { color: var(--muted); font-size: 8px; line-height: 1.35; }
.item-bundle-launch { display: grid; grid-template-columns: 34px minmax(0, 1fr) 18px; gap: 9px; align-items: center; width: 100%; margin: 0 0 12px; padding: 9px; border: 1px solid #afb4b7; border-radius: 5px; background: #f7f8f7; color: var(--text); text-align: left; cursor: pointer; }
.item-bundle-launch:hover { border-color: #6f777c; background: #eef0ef; }
.item-bundle-launch.is-bundle { border-color: #9a8700; background: #fff9cf; }
.item-bundle-launch .record-icon { width: 34px; height: 34px; }
.item-bundle-launch > span:nth-child(2) { display: grid; gap: 2px; min-width: 0; }
.item-bundle-launch strong { font-size: 10px; }
.item-bundle-launch small { color: var(--muted); font-size: 8px; line-height: 1.35; }
.item-bundle-launch > svg { width: 16px; height: 16px; color: var(--muted); }
.item-inline-sync { display: grid; grid-column: 1 / -1; grid-template-columns: 36px minmax(0, 1fr) auto; align-content: start; gap: 10px; border-top: 1px solid var(--border); border-right: 0; }
.item-inline-sync > div { display: grid; gap: 3px; }
.item-inline-sync strong { font-size: 11px; }
.item-inline-sync small { color: var(--muted); font-size: 9px; line-height: 1.45; }
.item-inline-sync form { align-self: center; }
.item-inline-sync.is-linked { background: #eef9f5; }
.item-live-empty { display: grid; justify-items: center; gap: 4px; padding: 36px; color: var(--muted); text-align: center; }
.item-live-empty svg { width: 20px; height: 20px; }

.item-create-dialog {
    width: min(620px, calc(100vw - 28px));
    max-height: min(760px, calc(100dvh - 28px));
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--border-strong);
    border-radius: 7px;
    background: var(--paper);
}
.item-create-dialog::backdrop { background: rgba(15, 18, 22, .58); backdrop-filter: blur(2px); }
.item-create-sheet-shell { display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; height: 100%; min-height: 0; }
.item-create-dialog .mobile-create-header { border-bottom: 1px solid var(--border); }
.item-create-dialog .mobile-create-header > div { display: grid; gap: 1px; min-width: 0; }
.item-create-dialog .mobile-create-header h2 { font-size: 18px; }
.item-create-dialog .mobile-create-header small { color: var(--muted); font-size: 10px; line-height: 1.35; }
.item-create-dialog-body { min-height: 0; padding: 16px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.item-create-dialog-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.item-create-dialog-fields label { align-content: start; }
.item-create-dialog-fields .check-label { display: flex; min-height: 44px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 5px; background: var(--paper-soft); }
.item-create-dialog-fields .check-label input { width: 20px; height: 20px; }
.item-create-sheet-shell.is-service .item-create-stock { opacity: .5; }
.item-create-dialog-footer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; min-height: 68px; padding: 10px 16px; border-top: 1px solid var(--border); background: var(--paper-soft); }
.item-create-dialog-state { color: var(--red); font-size: 11px; line-height: 1.35; }

.item-groups-dialog {
    width: min(1180px, calc(100vw - 28px));
    max-height: min(880px, calc(100dvh - 28px));
    padding: 0;
    overflow: hidden;
    border: 1px solid #969da1;
    border-radius: 6px;
    background: var(--paper);
}
.item-groups-dialog::backdrop { background: rgba(15, 18, 22, .58); backdrop-filter: blur(2px); }
.item-groups-dialog > header {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) 36px;
    gap: 10px;
    align-items: center;
    min-height: 70px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}
.item-groups-dialog > header > div { display: grid; gap: 1px; min-width: 0; }
.item-groups-dialog > header h3 { margin: 0; font-size: 15px; }
.item-groups-dialog > header p { margin: 0; color: var(--muted); font-size: 9px; line-height: 1.4; }
.item-groups-dialog-body { max-height: calc(100dvh - 165px); padding: 12px; overflow: auto; }
.item-group-create-form {
    display: grid;
    grid-template-columns: minmax(175px, 1fr) 165px 170px 88px minmax(220px, 1.4fr) auto;
    gap: 8px;
    align-items: end;
    margin-bottom: 14px;
    padding: 11px;
    border: 1px solid var(--border-strong);
    border-left: 3px solid #fff200;
    border-radius: 5px;
    background: var(--paper-soft);
}
.item-group-form-heading { display: none; }
.item-group-create-form > label,
.item-group-edit-form > label { display: grid; gap: 3px; min-width: 0; }
.item-group-create-form > label > span,
.item-group-edit-form > label > span { color: var(--muted); font-size: 8px; font-weight: 650; }
.item-group-create-form .span-2 { grid-column: auto; }
.item-group-list { display: grid; gap: 5px; }
.item-group-edit-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 36px;
    gap: 5px;
    align-items: end;
    padding: 7px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--item-group-color);
    border-radius: 4px;
    background: var(--paper);
}
.item-group-edit-form {
    display: grid;
    grid-template-columns: 38px minmax(145px, 1fr) 155px 165px 76px minmax(170px, 1.25fr) 68px 64px 36px;
    gap: 7px;
    align-items: end;
    min-width: 0;
}
.item-group-edit-visual {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid color-mix(in srgb, var(--item-group-color) 60%, var(--border));
    border-radius: 5px;
    background: color-mix(in srgb, var(--item-group-color) 14%, var(--paper));
    color: var(--item-group-color);
}
.item-group-edit-visual .icon-asset-mask,
.item-group-edit-visual svg { width: 17px; height: 17px; }
.item-group-edit-form input:not([type="checkbox"]),
.item-group-edit-form select,
.item-group-create-form input:not([type="checkbox"]),
.item-group-create-form select { width: 100%; min-width: 0; height: 36px; }
.item-group-edit-form .check-label { min-height: 36px; }
.item-group-use-count { align-self: center; color: var(--muted); font-size: 8px; text-align: right; white-space: nowrap; }
.item-group-edit-row > form:last-child { display: flex; align-items: flex-end; height: 36px; }
.item-groups-dialog > footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 54px;
    padding: 8px 12px;
    border-top: 1px solid var(--border);
    background: var(--paper-soft);
}
.item-groups-dialog > footer > span { color: var(--muted); font-size: 9px; }

.item-bundle-dialog { width: min(1040px, calc(100vw - 24px)); max-height: min(860px, calc(100dvh - 24px)); padding: 0; overflow: hidden; border: 1px solid #969da1; border-radius: 6px; background: var(--paper); }
.item-bundle-dialog::backdrop { background: rgba(15, 18, 22, .58); backdrop-filter: blur(2px); }
.item-bundle-dialog > form { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; max-height: min(860px, calc(100dvh - 24px)); }
.item-bundle-dialog header { display: grid; grid-template-columns: 38px minmax(0, 1fr) 36px; gap: 10px; align-items: center; min-height: 66px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.item-bundle-dialog header > div { display: grid; gap: 1px; min-width: 0; }
.item-bundle-dialog header h3 { margin: 0; overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.item-bundle-dialog header p { margin: 0; color: var(--muted); font-size: 9px; }
.item-bundle-body { overflow: auto; padding: 12px; }
.bundle-explainer { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 12px; border: 1px solid var(--border); border-radius: 5px; background: var(--paper-soft); }
.bundle-explainer > span { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 1px 7px; align-items: center; min-height: 60px; padding: 8px 10px; border-right: 1px solid var(--border); }
.bundle-explainer > span:last-child { border-right: 0; }
.bundle-explainer svg { grid-row: 1 / span 2; width: 18px; height: 18px; color: #343a3e; }
.bundle-explainer b { font-size: 9px; }
.bundle-explainer small { color: var(--muted); font-size: 8px; line-height: 1.35; }
.bundle-component-search { position: relative; display: grid; gap: 4px; margin-bottom: 10px; }
.bundle-component-search > span:first-child { color: var(--muted); font-size: 9px; font-weight: 650; }
.bundle-component-search .item-search-results { z-index: 20; top: calc(100% + 3px); right: 0; left: 0; }
.bundle-component-list { display: grid; gap: 6px; }
.bundle-component-row { display: grid; grid-template-columns: 32px minmax(150px, 1fr) 84px 145px 150px 110px 36px; gap: 8px; align-items: center; min-height: 58px; padding: 7px; border: 1px solid var(--border); border-radius: 5px; background: var(--paper); }
.bundle-component-row .record-icon { width: 32px; height: 32px; }
.bundle-component-copy { display: grid; min-width: 0; }
.bundle-component-copy strong, .bundle-component-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bundle-component-copy strong { font-size: 10px; }
.bundle-component-copy small, .bundle-component-stock { color: var(--muted); font-size: 8px; }
.bundle-component-row label { display: grid; gap: 2px; }
.bundle-component-row label span { color: var(--muted); font-size: 8px; }
.bundle-component-row input, .bundle-component-row select { width: 100%; height: 34px; min-width: 0; }
.bundle-component-stock { text-align: right; }
.bundle-component-empty { display: grid; justify-items: center; gap: 3px; padding: 28px 12px; border: 1px dashed #b9bec1; border-radius: 5px; color: var(--muted); text-align: center; }
.bundle-component-empty svg { width: 22px; height: 22px; }
.bundle-component-empty strong { color: var(--text); font-size: 10px; }
.bundle-component-empty span { font-size: 9px; }
.bundle-rule-note { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 8px; margin-top: 10px; padding: 9px 10px; border-left: 3px solid #d2b900; background: #fff9d6; }
.bundle-rule-note svg { width: 17px; height: 17px; color: #6c5c00; }
.bundle-rule-note span { display: grid; gap: 2px; }
.bundle-rule-note strong { font-size: 9px; }
.bundle-rule-note small { color: #665f38; font-size: 8px; line-height: 1.4; }
.item-bundle-dialog footer { display: flex; justify-content: flex-end; gap: 7px; padding: 10px 12px; border-top: 1px solid var(--border); background: var(--paper-soft); }

html[data-theme="dark"] .item-bundle-launch.is-bundle,
html[data-theme="dark"] .bundle-derived-field,
html[data-theme="dark"] .bundle-rule-note,
html[data-theme="dark"] .logistics-flow .is-open,
html[data-theme="dark"] .delivery-billing-ready {
    background: #37330d;
    color: var(--text-strong);
}
html[data-theme="dark"] .item-bundle-launch.is-bundle small,
html[data-theme="dark"] .bundle-derived-field > span,
html[data-theme="dark"] .bundle-derived-field small,
html[data-theme="dark"] .bundle-rule-note small {
    color: #d9ce78;
}
html[data-theme="dark"] .bundle-fulfillment { background: var(--paper-soft); }
html[data-theme="dark"] .bundle-badge { border-color: #687177; background: #30363a; color: var(--text); }
html[data-theme="dark"] .bundle-fulfillment-row input[readonly] { background: var(--control); color: var(--muted); }
html[data-theme="dark"] .logistics-flow .is-exception { background: #3c2022; }

.item-bulk-dialog { width: min(1500px, calc(100vw - 28px)); height: min(820px, calc(100vh - 28px)); padding: 0; overflow: hidden; border: 1px solid #aeb2b5; border-radius: 6px; background: var(--paper); }
.item-bulk-dialog::backdrop { background: rgba(15, 18, 22, .58); backdrop-filter: blur(2px); }
.item-bulk-dialog > header { display: flex; align-items: center; justify-content: space-between; height: 58px; padding: 9px 13px 9px 17px; border-bottom: 1px solid var(--border); }
.item-bulk-dialog > header > div { display: grid; gap: 2px; }
.item-bulk-dialog > header strong { font-size: 13px; }
.item-bulk-dialog > header span { color: var(--muted); font-size: 10px; }
.item-bulk-dialog-body { height: calc(100% - 58px); overflow: auto; }
.item-bulk-dialog .item-grid-section { border: 0; border-radius: 0; }
.item-bulk-dialog .item-grid-wrap { max-height: calc(100vh - 170px); }

/* The document picker must escape the table shell. */
.invoice-paper:has(.position-quick-add) { overflow: visible; }
.invoice-paper:has(.position-quick-add) .position-grid-wrap { overflow-x: auto; }
.position-quick-add { position: relative; z-index: 12; }
.position-quick-add:focus-within { z-index: 90; }
.position-quick-add .quick-item { position: relative; }
.position-quick-add .item-search-results { right: auto; left: 0; width: min(440px, calc(100vw - 44px)); max-height: 290px; }

@media (max-width: 1180px) {
    .item-inline-sync { grid-template-columns: 36px minmax(0, 1fr); }
    .item-inline-sync form { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
    .item-command-bar { grid-template-columns: 1fr; align-items: stretch; }
    .item-live-filters { display: grid; grid-template-columns: 1fr 1fr; }
    .item-live-filters select { width: 100%; }
    .item-command-bar .command-actions { grid-column: auto; justify-content: flex-start; overflow-x: auto; }
    .item-command-bar .command-actions .button span { display: none; }
    .item-group-strip { margin-right: -12px; margin-left: -12px; padding-right: 12px; padding-left: 12px; }
    .item-group-manage { margin-left: 0; }
    .item-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .item-live-table-wrap { max-height: calc(100vh - 330px); }
    .item-live-meta { align-items: flex-start; }
    .live-save-legend { display: none; }
    .item-live-detail-shell { grid-template-columns: 1fr; width: calc(100vw - 30px); }
    .item-visual-inline-form, .item-inline-operations, .item-inline-sync { border-right: 0; border-bottom: 1px solid var(--border); }
    .item-inline-visual-editor { grid-template-columns: 52px 1fr; }
    .item-inline-visual-editor .span-2 { grid-column: span 2; }
    .item-groups-dialog { width: 100vw; max-width: none; max-height: calc(100dvh - var(--safe-area-top)); margin: var(--safe-area-top) 0 0; border-right: 0; border-bottom: 0; border-left: 0; border-radius: 8px 8px 0 0; }
    .item-groups-dialog-body { max-height: calc(100dvh - var(--safe-area-top) - 124px); }
    .item-group-create-form { grid-template-columns: 1fr 1fr; }
    .item-group-form-heading { display: grid; grid-column: 1 / -1; grid-template-columns: 34px minmax(0, 1fr); gap: 8px; align-items: center; }
    .item-group-form-heading > div { display: grid; }
    .item-group-form-heading strong { font-size: 10px; }
    .item-group-form-heading small { color: var(--muted); font-size: 8px; }
    .item-group-create-form .span-2 { grid-column: 1 / -1; }
    .item-group-create-form > button { grid-column: 1 / -1; }
    .item-group-edit-row { grid-template-columns: minmax(0, 1fr) 36px; align-items: start; }
    .item-group-edit-form { grid-template-columns: 38px minmax(0, 1fr) 36px; }
    .item-group-edit-form > label { grid-column: span 3; }
    .item-group-edit-form > label:nth-of-type(1) { grid-column: 2 / 4; }
    .item-group-edit-form .check-label { grid-column: span 1; }
    .item-group-use-count { grid-column: 2; text-align: left; }
    .item-group-edit-form > .icon-button { grid-column: 3; }
    .item-bundle-dialog { width: 100vw; max-width: none; max-height: calc(100dvh - var(--safe-area-top)); margin: var(--safe-area-top) 0 0; border-right: 0; border-bottom: 0; border-left: 0; border-radius: 8px 8px 0 0; }
    .item-bundle-dialog > form { max-height: calc(100dvh - var(--safe-area-top)); }
    .bundle-explainer { grid-template-columns: 1fr; }
    .bundle-explainer > span { border-right: 0; border-bottom: 1px solid var(--border); }
    .bundle-explainer > span:last-child { border-bottom: 0; }
    .bundle-component-row { grid-template-columns: 32px minmax(0, 1fr) 36px; }
    .bundle-component-row label { grid-column: 2; }
    .bundle-component-stock { grid-column: 2; text-align: left; }
    .bundle-component-row .icon-button { grid-column: 3; grid-row: 1; }
    .position-quick-add .item-search-results { position: fixed; top: auto; right: 10px; bottom: 12px; left: 10px; width: auto; max-height: min(55vh, 360px); }
}

/* Icon library and live studio */
.icon-library-workspace { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(350px, .8fr); gap: 16px; align-items: start; }
.icon-library-panel, .icon-studio-panel { margin: 0; }
.icon-library-search { position: relative; display: block; margin: 0 0 12px; }
.icon-library-search svg, .icon-library-search img { position: absolute; z-index: 1; left: 10px; top: 10px; width: 15px; height: 15px; color: var(--muted); }
.icon-library-search input { width: 100%; padding-left: 33px; }
.icon-library-workspace .icon-preset-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.icon-preset { grid-template-columns: minmax(0, 1fr) auto; padding: 0; overflow: hidden; background: var(--paper); }
.icon-preset:hover { border-color: #969b9f; box-shadow: 0 2px 8px rgba(20, 24, 28, .07); }
.icon-preset-select { display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 9px; align-items: center; min-width: 0; padding: 9px; border: 0; background: transparent; color: inherit; text-align: left; cursor: pointer; }
.icon-preset-select > span:last-child { display: grid; min-width: 0; }
.icon-preset-actions { display: flex; align-items: center; gap: 2px; padding-right: 7px; }
.icon-preset-actions form { display: inline-flex; }
.icon-studio-panel { position: sticky; top: 12px; }
.icon-studio-form { display: grid; gap: 14px; }
.icon-studio-stage { display: grid; place-items: center; min-height: 210px; padding: 24px; border: 1px solid #bdc1c3; border-radius: 5px; background: linear-gradient(90deg, #eceeed 1px, transparent 1px), linear-gradient(#eceeed 1px, transparent 1px), #f9faf9; background-size: 16px 16px; }
.icon-studio-preview { display: inline-flex; align-items: center; justify-content: center; width: 108px; height: 108px; overflow: hidden; border: 3px solid var(--studio-border); background: var(--studio-bg); color: var(--studio-fg); }
.icon-studio-preview > .icon-asset-mask { width: 54px; height: 54px; }
.icon-studio-preview > .icon-asset-image { width: 76%; height: 76%; object-fit: contain; }
.icon-studio-caption { margin-top: 12px; max-width: 260px; color: #303438; font-size: 12px; font-weight: 700; text-align: center; }
.icon-studio-stage { grid-template-rows: 108px auto; }
.icon-studio-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.icon-studio-controls label { display: grid; gap: 4px; min-width: 0; }
.icon-studio-controls label > span { color: var(--muted-strong); font-size: 10px; font-weight: 650; }
.icon-studio-controls .span-2 { grid-column: span 2; }
.icon-file-drop { padding: 10px; border: 1px dashed #9da2a5; border-radius: 4px; background: #f5f6f5; }
.icon-file-drop input { width: 100%; }
.icon-file-drop strong { font-size: 11px; }
.icon-file-drop small { color: var(--muted); font-size: 9px; }
.icon-studio-actions { display: flex; justify-content: flex-end; gap: 7px; padding-top: 12px; border-top: 1px solid var(--border); }

@media (max-width: 1080px) {
    .position-quick-add { grid-template-columns: 28px 102px minmax(190px, 1fr) 60px 76px 76px 58px 32px; }
    .position-quick-add .quick-deposit { display: none; }
    .icon-library-workspace { grid-template-columns: 1fr; }
    .icon-studio-panel { position: static; }
}

@media (max-width: 680px) {
    .position-grid-wrap { overflow: visible !important; }
    .invoice-lines-table.is-live-grid { display: block; width: 100%; min-width: 0; table-layout: auto; }
    .invoice-lines-table.is-live-grid thead { display: none; }
    .invoice-lines-table.is-live-grid tbody { display: grid; gap: 8px; padding: 8px; }
    .invoice-lines-table.is-live-grid .invoice-line-row {
        display: grid;
        grid-template-columns: 28px minmax(0, 1fr) minmax(0, 1fr) 34px;
        gap: 8px;
        padding: 9px 7px;
        border: 1px solid var(--border);
        border-left: 3px solid #fff200;
        background: var(--paper);
    }
    .invoice-lines-table.is-live-grid .invoice-line-row > td {
        display: grid;
        min-width: 0;
        height: auto;
        padding: 0;
        border: 0;
        background: transparent;
        text-align: left;
        vertical-align: top;
    }
    .invoice-lines-table.is-live-grid .invoice-line-row > td::before {
        content: attr(data-label);
        margin-bottom: 3px;
        color: var(--muted);
        font-size: 8px;
        font-weight: 700;
        text-transform: uppercase;
    }
    .invoice-lines-table.is-live-grid .invoice-line-row > td:nth-child(1) { grid-column: 1; grid-row: 1 / span 2; align-content: center; }
    .invoice-lines-table.is-live-grid .invoice-line-row > td:nth-child(1)::before,
    .invoice-lines-table.is-live-grid .invoice-line-row > td:nth-child(9)::before { display: none; }
    .invoice-lines-table.is-live-grid .invoice-line-row > td:nth-child(2) { grid-column: 2; grid-row: 1; }
    .invoice-lines-table.is-live-grid .invoice-line-row > td:nth-child(3) { grid-column: 3; grid-row: 1; }
    .invoice-lines-table.is-live-grid .invoice-line-row > td:nth-child(4) { grid-column: 2 / 4; grid-row: 2; }
    .invoice-lines-table.is-live-grid .invoice-line-row > td:nth-child(5) { grid-column: 2; grid-row: 3; }
    .invoice-lines-table.is-live-grid .invoice-line-row > td:nth-child(6) { grid-column: 3; grid-row: 3; }
    .invoice-lines-table.is-live-grid .invoice-line-row > td:nth-child(7) { grid-column: 2; grid-row: 4; }
    .invoice-lines-table.is-live-grid .invoice-line-row > td:nth-child(8) { grid-column: 3; grid-row: 4; align-content: end; text-align: right; }
    .invoice-lines-table.is-live-grid .invoice-line-row > td:nth-child(9) { grid-column: 4; grid-row: 1 / span 4; align-content: start; }
    .invoice-lines-table.is-live-grid .invoice-line-row .line-rich-text { min-width: 0; }
    .invoice-lines-table.is-live-grid .invoice-line-row .inline-line-actions { align-items: center; flex-direction: column; }
    .invoice-lines-table.is-live-grid .invoice-line-row .line-options-panel { position: fixed; top: auto; right: 12px; bottom: 12px; left: 12px; width: auto; }
    .invoice-lines-table.is-live-grid .invoice-line-row.is-section,
    .invoice-lines-table.is-live-grid .invoice-line-row.is-text,
    .invoice-lines-table.is-live-grid .invoice-line-row.is-spacer { background: #f7f8f7; }
    .invoice-lines-table.is-live-grid .invoice-line-row.is-section > td:nth-child(n+5):nth-child(-n+8),
    .invoice-lines-table.is-live-grid .invoice-line-row.is-text > td:nth-child(n+5):nth-child(-n+8),
    .invoice-lines-table.is-live-grid .invoice-line-row.is-spacer > td:nth-child(n+5):nth-child(-n+8) { display: none; }
    .invoice-lines-table.is-live-grid [data-empty-lines] { display: block; }
    .invoice-lines-table.is-live-grid [data-empty-lines] td { display: block; }
    .position-quick-add { grid-template-columns: 90px minmax(180px, 1fr) 34px; overflow-x: auto; }
    .position-add-mark, .position-quick-add > label:not(.quick-type):not(.quick-item):not(.quick-spacer-color), .position-quick-add .quick-add-state { display: none; }
    .position-quick-add .quick-type { grid-column: 1; }
    .position-quick-add .quick-item { grid-column: 2; }
    .position-quick-add .quick-spacer-color { grid-column: 2; }
    .position-quick-add > button { grid-column: 3; }
    .document-preview-dialog > header .button span { display: none; }
    .document-preview-canvas { padding: 0; }
    .icon-library-workspace .icon-preset-grid { grid-template-columns: 1fr; }
    .icon-studio-controls { grid-template-columns: 1fr; }
    .icon-studio-controls .span-2 { grid-column: auto; }
}

/* Customer detail: keep the stats, data sheet and tasks compact and readable. */
@media (min-width: 1051px) {
    .customer-stats {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }

    .customer-stats article:nth-child(3) {
        border-right: 1px solid var(--border);
    }

    .customer-stats article:nth-child(-n + 3) {
        border-bottom: 0;
    }
}

@media (max-width: 680px) {
    .customer-data-summary {
        grid-template-columns: 34px minmax(0, 1fr) 18px;
    }

    .customer-data-summary-meta {
        display: none;
    }

    .customer-data-form {
        grid-template-columns: 1fr;
    }

    .customer-data-wide {
        grid-column: auto;
    }

    .customer-task-section .table-wrap {
        overflow: visible;
    }

    .task-table-customer,
    .task-table-customer tbody {
        display: block;
        width: 100%;
    }

    .task-table-customer thead {
        display: none;
    }

    .task-table-customer tr {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px 8px;
        padding: 10px;
        border-bottom: 1px solid var(--border);
    }

    .task-table-customer td {
        display: block;
        padding: 2px 0;
        border: 0;
    }

    .task-table-customer td:nth-child(1),
    .task-table-customer td:nth-child(6) {
        grid-column: 1 / -1;
    }

    .task-table-customer .record-actions {
        flex-direction: row;
    }
}

/* Unified documents and direct sales */
.direct-sales-table {
    min-width: 0;
    table-layout: fixed;
}

.direct-sales-table th:nth-child(1) { width: 84px; }
.direct-sales-table th:nth-child(2) { width: 150px; }
.direct-sales-table th:nth-child(3) { width: auto; }
.direct-sales-table th:nth-child(4) { width: 112px; }
.direct-sales-table th:nth-child(5) { width: 96px; }
.direct-sales-table th:nth-child(6) { width: 48px; }

.direct-sales-table td:last-child {
    text-align: right;
}

.direct-sales-journal {
    margin-top: 18px;
}

@media (max-width: 1050px) {
    .filter-form.documents-filter-form {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }

    .documents-filter-form > label:nth-of-type(1),
    .documents-filter-form > .live-customer-field {
        grid-column: span 3;
    }

    .documents-filter-form > label:not(:nth-of-type(1)):not(.live-customer-field),
    .documents-filter-form > .button {
        grid-column: span 2;
    }
}

@media (max-width: 680px) {
    .documents-type-tabs {
        display: flex;
        overflow-x: auto;
    }

    .documents-type-tabs a,
    .documents-type-tabs a:nth-child(2),
    .documents-type-tabs a:nth-child(-n + 2) {
        flex: 0 0 auto;
        min-width: 118px;
        border-right: 1px solid var(--border);
        border-bottom: 0;
    }

    .filter-form.documents-filter-form {
        grid-template-columns: 1fr;
    }

    .documents-filter-form > label:nth-of-type(1),
    .documents-filter-form > .live-customer-field,
    .documents-filter-form > label:not(:nth-of-type(1)):not(.live-customer-field),
    .documents-filter-form > .button {
        grid-column: auto;
    }

    .direct-sales-table,
    .direct-sales-table tbody {
        display: block;
        width: 100%;
    }

    .direct-sales-table thead {
        display: none;
    }

    .direct-sales-table tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 6px 10px;
        padding: 10px 12px;
        border-bottom: 1px solid var(--border);
    }

    .direct-sales-table td {
        display: block;
        padding: 0;
        border: 0;
    }

    .direct-sales-table td:nth-child(3) {
        grid-column: 1 / -1;
    }

    .direct-sales-table td:nth-child(6) {
        grid-column: 2;
        grid-row: 1;
    }
}

/* Cascade-critical modern overrides stay last. */
body,
.login-body,
.app-shell {
    min-height: 100dvh;
}

.sidebar {
    height: 100dvh;
}

:where(a, button, summary, input, select, textarea, [tabindex]):focus-visible {
    outline: 2px solid #146ef5 !important;
    outline-offset: 2px;
}

.item-bulk-dialog {
    height: min(820px, calc(100dvh - 28px));
}

.item-bulk-dialog .item-grid-wrap {
    max-height: calc(100dvh - 170px);
}

/* iPhone and installed web-app layer. */
:root {
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-right: env(safe-area-inset-right, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-left: env(safe-area-inset-left, 0px);
    --visual-viewport-height: 100dvh;
    --visual-viewport-offset-top: 0px;
    --mobile-tabbar-height: 0px;
}

html {
    max-width: 100%;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body,
.app-shell,
.workspace-main {
    max-width: 100%;
}

.is-standalone body {
    overscroll-behavior-y: none;
}

.mobile-tabbar {
    display: none;
}

.table-wrap,
.item-live-table-wrap,
.master-list,
.segmented-tabs,
.documents-type-tabs {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-inline: contain;
}

.has-horizontal-overflow:not(.is-scroll-end) {
    box-shadow: inset -4px 0 0 var(--accent);
}

.app-dialog {
    max-height: calc(var(--visual-viewport-height, 100dvh) - 24px);
}

.toast-region {
    right: max(18px, var(--safe-area-right));
    bottom: max(18px, var(--safe-area-bottom));
}

.document-preview-dialog {
    height: min(900px, calc(var(--visual-viewport-height, 100dvh) - 30px));
}

.document-preview-page {
    position: relative;
    flex: 0 0 auto;
    width: 794px;
    height: 1123px;
    margin: 0 auto;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 5px 20px rgba(20, 24, 28, .12);
}

.document-preview-canvas iframe,
.document-preview-page iframe {
    position: absolute;
    inset: 0 auto auto 0;
    display: block;
    width: 794px;
    height: 1123px;
    min-width: 0;
    border: 0;
    background: #fff;
    box-shadow: none;
    transform-origin: top left;
}

@media (max-width: 720px) {
    :root {
        --mobile-tabbar-height: calc(60px + var(--safe-area-bottom));
    }

    html {
        scroll-padding-top: calc(64px + var(--safe-area-top));
    }

    body {
        min-width: 0;
    }

    .topbar {
        min-height: calc(62px + var(--safe-area-top));
        padding: calc(8px + var(--safe-area-top)) max(10px, var(--safe-area-right)) 8px max(10px, var(--safe-area-left));
        background: var(--chrome);
        backdrop-filter: none;
    }

    .topbar .mobile-menu {
        display: none;
    }

    .page-intro {
        min-width: 0;
    }

    .page-intro h1 {
        overflow: hidden;
        font-size: 20px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .topbar-actions {
        flex: 0 0 auto;
        gap: 5px;
    }

    .topbar-actions .quick-create summary {
        width: 44px;
        height: 44px;
    }

    .user-menu {
        gap: 0;
        padding-left: 0;
        border-left: 0;
    }

    .user-menu > a {
        display: none;
    }

    .page-content {
        padding: 14px max(12px, var(--safe-area-right)) calc(34px + var(--mobile-tabbar-height)) max(12px, var(--safe-area-left));
    }

    .mobile-tabbar {
        position: fixed;
        z-index: 24;
        right: 0;
        bottom: 0;
        left: 0;
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        min-height: var(--mobile-tabbar-height);
        padding: 3px max(4px, var(--safe-area-right)) var(--safe-area-bottom) max(4px, var(--safe-area-left));
        border-top: 1px solid var(--border-strong);
        background: var(--chrome);
        box-shadow: 0 -8px 28px rgba(20, 24, 28, .08);
        backdrop-filter: blur(18px) saturate(1.2);
    }

    .is-standalone .mobile-tabbar {
        background: var(--chrome);
    }

    .mobile-tabbar a,
    .mobile-tabbar button {
        position: relative;
        display: grid;
        grid-template-rows: 27px 14px;
        place-items: center;
        align-content: center;
        min-width: 0;
        min-height: 56px;
        padding: 2px;
        border: 0;
        border-radius: 0;
        background: transparent;
        color: var(--muted-strong);
        cursor: pointer;
        font-family: inherit;
        font-size: 10px;
        font-weight: 650;
        line-height: 1;
        text-decoration: none;
        touch-action: manipulation;
    }

    .mobile-tabbar a::before,
    .mobile-tabbar button::before {
        position: absolute;
        top: -3px;
        right: 22%;
        left: 22%;
        height: 3px;
        background: transparent;
        content: "";
    }

    .mobile-tabbar a.active,
    .mobile-tabbar button.active {
        color: var(--brand-ink);
    }

    .mobile-tabbar a.active::before,
    .mobile-tabbar button.active::before {
        background: var(--accent);
    }

    .mobile-tabbar .app-icon {
        width: 22px;
        height: 22px;
    }

    .sidebar {
        top: 0;
        bottom: 0;
        width: min(326px, 88vw);
        height: var(--visual-viewport-height, 100dvh);
        padding: calc(14px + var(--safe-area-top)) 12px calc(12px + var(--safe-area-bottom)) max(12px, var(--safe-area-left));
    }

    .main-nav a {
        min-height: 44px;
    }

    .sidebar-close.icon-button {
        width: 44px;
        height: 44px;
    }

    .quick-create-menu {
        top: calc(58px + var(--safe-area-top));
        right: max(8px, var(--safe-area-right));
        bottom: calc(var(--mobile-tabbar-height) + 8px);
        left: max(8px, var(--safe-area-left));
        width: auto;
        max-height: none;
        overscroll-behavior: contain;
    }

    .quick-create-menu a {
        min-height: 52px;
    }

    .button,
    .icon-button,
    button,
    summary,
    .segmented-tabs a,
    .documents-type-tabs a {
        min-height: 44px;
    }

    .icon-button {
        width: 44px;
        height: 44px;
        padding: 0;
    }

    .item-grid-table th:nth-child(1),
    .item-grid-table td:nth-child(1),
    .item-grid-table th:nth-child(17),
    .item-grid-table td:nth-child(17) {
        width: 44px;
        min-width: 44px;
        max-width: 44px;
    }

    .item-grid-remove,
    .item-visual-button {
        width: 44px;
        min-width: 44px;
        height: 44px;
    }

    input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="color"]),
    select,
    textarea,
    .rich-text-surface .ql-editor,
    .line-rich-surface .ql-editor {
        max-width: 100%;
        min-height: 44px;
        font-size: 16px;
    }

    input[type="checkbox"],
    input[type="radio"] {
        width: 22px;
        height: 22px;
    }

    input[type="color"] {
        min-width: 44px;
        min-height: 44px;
    }

    .hex-color-picker {
        grid-template-columns: 44px minmax(0, 1fr);
        max-width: none;
    }

    .hex-color-picker input[type="color"] {
        width: 44px;
        min-width: 44px;
        height: 44px;
        min-height: 44px;
    }

    .hex-color-picker .hex-color-value {
        min-height: 44px;
        font-size: 16px;
    }

    .spacer-color-editor .hex-color-picker {
        grid-template-columns: 44px minmax(88px, 1fr);
        width: min(100%, 154px);
        min-width: 0;
    }

    .spacer-color-editor .hex-color-picker input[type="color"] {
        width: 44px;
        min-width: 44px;
        height: 44px;
        min-height: 44px;
    }

    .spacer-color-editor .hex-color-picker .hex-color-value {
        width: auto;
        height: 44px;
        min-height: 44px;
        font-size: 16px;
    }

    textarea {
        min-height: 88px;
    }

    .check-label {
        min-height: 44px;
    }

    .rich-text-toolbar,
    .line-rich-toolbar {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .rich-text-toolbar button,
    .line-rich-toolbar button {
        width: 44px;
        min-width: 44px;
        height: 44px;
    }

    .hero-actions {
        width: 100%;
        flex-wrap: nowrap;
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: 4px;
        scroll-snap-type: x proximity;
        -webkit-overflow-scrolling: touch;
    }

    .hero-actions .button,
    .hero-actions form {
        flex: 0 0 auto;
        scroll-snap-align: start;
    }

    .customer-mobile-contact {
        display: flex;
        gap: 6px;
        margin-top: 10px;
        overflow-x: auto;
    }

    .customer-mobile-contact a {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 7px;
        min-height: 44px;
        padding: 0 13px;
        border: 1px solid var(--border-strong);
        border-radius: var(--radius);
        background: var(--paper);
        color: var(--text-strong);
        font-size: 12px;
        font-weight: 650;
        text-decoration: none;
        white-space: nowrap;
    }

    .customer-mobile-contact a:active {
        background: var(--accent-soft);
    }

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

    .contact-row > .badge {
        display: none;
    }

    .contact-quick-actions {
        grid-column: 3;
        gap: 1px;
    }

    .metric-strip,
    .stat-grid,
    .summary-band,
    .stat-grid-six,
    .customer-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .metric-strip > div,
    .stat-grid article,
    .summary-band > div {
        min-width: 0;
        border-right: 1px solid var(--border);
        border-bottom: 1px solid var(--border);
    }

    .metric-strip > div:nth-child(2n),
    .stat-grid article:nth-child(2n),
    .summary-band > div:nth-child(2n) {
        border-right: 0;
    }

    .metric-strip > div:nth-last-child(-n + 2),
    .stat-grid article:nth-last-child(-n + 2),
    .summary-band > div:nth-last-child(-n + 2) {
        border-bottom: 0;
    }

    .table-wrap,
    .item-live-table-wrap {
        max-width: 100%;
        scrollbar-width: thin;
        touch-action: pan-x pan-y;
    }

    .item-live-table-wrap {
        max-height: calc(var(--visual-viewport-height, 100dvh) - var(--mobile-tabbar-height) - 250px);
    }

    .item-live-detail-shell {
        width: calc(100dvw - max(12px, var(--safe-area-left)) - max(12px, var(--safe-area-right)));
    }

    .invoice-lines-table.is-live-grid .invoice-line-row {
        grid-template-columns: 44px minmax(0, 1fr) minmax(0, 1fr) 44px;
    }

    .line-drag-handle {
        width: 44px;
        height: 44px;
        touch-action: none;
    }

    .line-order-actions {
        grid-template-columns: 44px 44px;
    }

    .position-quick-add {
        grid-template-columns: minmax(86px, .42fr) minmax(0, 1fr) 44px;
        gap: 7px;
        overflow: visible;
    }

    .position-quick-add .item-search-results {
        right: max(8px, var(--safe-area-right));
        bottom: max(8px, var(--safe-area-bottom));
        left: max(8px, var(--safe-area-left));
        max-height: min(55dvh, 420px);
        border-radius: 8px 8px 4px 4px;
        box-shadow: 0 -16px 44px rgba(20, 24, 28, .22);
    }

    .invoice-lines-table.is-live-grid .invoice-line-row .line-options-panel {
        right: max(8px, var(--safe-area-right));
        bottom: max(8px, var(--safe-area-bottom));
        left: max(8px, var(--safe-area-left));
        max-height: calc(var(--visual-viewport-height, 100dvh) - var(--safe-area-top) - var(--safe-area-bottom) - 16px);
        overflow-y: auto;
    }

    .app-dialog {
        max-width: calc(100vw - var(--safe-area-left) - var(--safe-area-right) - 16px);
        max-height: calc(var(--visual-viewport-height, 100dvh) - var(--safe-area-top) - var(--safe-area-bottom) - 16px);
    }

    .app-dialog:not(.confirm-dialog) {
        width: auto;
        inset: auto max(8px, var(--safe-area-right)) max(8px, var(--safe-area-bottom)) max(8px, var(--safe-area-left));
        margin: 0;
        border-radius: 8px 8px 4px 4px;
    }

    .confirm-dialog {
        width: calc(100vw - var(--safe-area-left) - var(--safe-area-right) - 24px);
    }

    .confirm-dialog-card {
        padding: 16px;
    }

    .confirm-dialog-card > footer {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .item-bulk-dialog,
    .document-preview-dialog {
        width: auto;
        height: calc(var(--visual-viewport-height, 100dvh) - var(--safe-area-top) - var(--safe-area-bottom) - 16px);
        max-height: none;
    }

    .document-preview-dialog > header {
        min-height: 58px;
        height: auto;
        padding-left: 12px;
    }

    .document-preview-dialog > header .eyebrow {
        display: none;
    }

    .document-preview-canvas {
        height: calc(100% - 58px);
        padding: 8px;
        overscroll-behavior: contain;
    }

    .toast-region {
        right: max(8px, var(--safe-area-right));
        bottom: calc(var(--mobile-tabbar-height) + 8px);
        left: max(8px, var(--safe-area-left));
        width: auto;
    }

    .app-toast {
        min-height: 52px;
        font-size: 13px;
    }

    .toast-close {
        width: 44px;
        height: 44px;
    }

    .login-body {
        padding: max(16px, var(--safe-area-top)) max(16px, var(--safe-area-right)) max(16px, var(--safe-area-bottom)) max(16px, var(--safe-area-left));
    }

    .login-panel {
        padding: 24px 18px;
    }

    .has-visual-keyboard .mobile-tabbar {
        display: none;
    }

    .has-visual-keyboard .page-content {
        padding-bottom: 34px;
    }

    .has-visual-keyboard .toast-region {
        bottom: max(8px, var(--safe-area-bottom));
    }
}

@media (max-width: 380px) {
    .mobile-tabbar a,
    .mobile-tabbar button {
        font-size: 9px;
    }

    .page-intro h1 {
        font-size: 18px;
    }

    .metric-strip,
    .stat-grid,
    .summary-band,
    .stat-grid-six,
    .customer-stats {
        grid-template-columns: 1fr 1fr;
    }
}
/* Mietpark und geführte Inventur */
.inventory-tabs {
    overflow-x: auto;
    scrollbar-width: thin;
}

.inventory-tabs a {
    min-width: max-content;
}

.rental-command-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.rental-scan-form {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
}

.rental-scan-form > .app-icon {
    color: var(--muted);
}

.rental-scan-form label,
.rental-scan-form input {
    width: 100%;
}

.rental-scan-form input {
    border: 0;
    box-shadow: none;
    background: transparent;
    font-size: 1rem;
}

.rental-scan-form input:focus {
    outline: 0;
}

.scan-hint {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    font-size: .78rem;
    white-space: nowrap;
}

.rental-metrics {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.date-range-filter,
.compact-filters {
    display: flex;
    align-items: end;
    gap: 8px;
    flex-wrap: wrap;
}

.date-range-filter label {
    display: grid;
    gap: 3px;
    color: var(--muted);
    font-size: .72rem;
}

.date-range-filter input,
.compact-filters input,
.compact-filters select {
    min-height: 38px;
}

.row-attention {
    background: color-mix(in srgb, #dc2626 6%, var(--surface));
}

.text-danger {
    color: #b42318;
}

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

.asset-register-form,
.asset-dialog-fields,
.inspection-fields,
.inventory-count-create {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.asset-register-form label,
.asset-dialog-fields label,
.inspection-fields label,
.inventory-count-create label {
    min-width: 0;
}

.asset-register-form .span-2,
.asset-dialog-fields .span-2,
.inspection-fields .span-2,
.inventory-count-create .span-2 {
    grid-column: span 2;
}

.asset-register-form > button,
.inventory-count-create > button {
    align-self: end;
}

.assignment-cell {
    display: grid;
    gap: 2px;
}

.assignment-cell small,
.table-subline {
    display: block;
    color: var(--muted);
    font-size: .75rem;
}

.selected-row {
    box-shadow: inset 3px 0 0 var(--accent);
    background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}

.badge.asset-available,
.badge.inspection-passed,
.badge.count-completed {
    border-color: #5dbb87;
    background: #dff7e8;
    color: #12633a;
}

.badge.asset-reserved,
.badge.asset-inspection,
.badge.inspection-conditional,
.badge.count-in_progress {
    border-color: #e5a93f;
    background: #fff1c8;
    color: #6f4800;
}

.badge.asset-checked_out {
    border-color: #58a6d8;
    background: #dff2ff;
    color: #075985;
}

.badge.asset-maintenance {
    border-color: #c18be1;
    background: #f3e5fb;
    color: #6b278f;
}

.badge.asset-damaged,
.badge.asset-lost,
.badge.inspection-failed {
    border-color: #df7772;
    background: #fee4e2;
    color: #9f231e;
}

.badge.asset-retired,
.badge.count-cancelled {
    border-color: #9ca3af;
    background: #eef0f2;
    color: #4b5563;
}

.asset-file {
    display: grid;
    gap: 0;
    border-block: 1px solid var(--border);
    background: var(--surface);
}

.asset-file-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    padding: 20px 0;
}

.asset-file-header h2,
.count-header h2 {
    margin: 2px 0 3px;
    font-size: 1.35rem;
    letter-spacing: 0;
}

.asset-file-header p,
.count-header p {
    margin: 0;
    color: var(--muted);
}

.asset-file-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: end;
}

.asset-facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
    border-block: 1px solid var(--border);
}

.rental-overdue-notice {
    display: flex;
    align-items: start;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid #e8b84e;
    background: #fff5d9;
    color: #6f4800;
}

.rental-overdue-notice div,
.rental-overdue-notice strong,
.rental-overdue-notice span {
    display: block;
}

.rental-overdue-notice span {
    margin-top: 2px;
    font-size: .8rem;
}

.asset-facts > div {
    display: grid;
    gap: 5px;
    min-width: 0;
    padding: 14px;
    border-right: 1px solid var(--border);
}

.asset-facts > div:last-child {
    border-right: 0;
}

.asset-facts span:first-child {
    color: var(--muted);
    font-size: .72rem;
}

.asset-facts strong {
    overflow-wrap: anywhere;
    font-size: .88rem;
}

.asset-history-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(300px, .85fr);
    gap: 0;
}

.asset-history-grid > section {
    min-width: 0;
    padding: 20px 0;
}

.asset-history-grid > section + section {
    padding-left: 24px;
    border-left: 1px solid var(--border);
}

.asset-history-grid > section:first-child {
    padding-right: 24px;
}

.asset-history-grid > section > header strong,
.asset-history-grid > section > header span {
    display: block;
}

.asset-history-grid > section > header span {
    margin-top: 3px;
    color: var(--muted);
    font-size: .76rem;
}

.timeline-list,
.inspection-list {
    display: grid;
    gap: 0;
    margin-top: 14px;
}

.timeline-list article {
    position: relative;
    display: grid;
    grid-template-columns: 16px minmax(0, 1fr);
    gap: 10px;
    padding: 0 0 18px;
}

.timeline-list article:not(:last-child)::before {
    content: "";
    position: absolute;
    top: 13px;
    bottom: 0;
    left: 5px;
    width: 1px;
    background: var(--border);
}

.timeline-marker {
    position: relative;
    z-index: 1;
    width: 11px;
    height: 11px;
    margin-top: 3px;
    border: 2px solid var(--surface);
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.timeline-list p,
.inspection-list p {
    margin: 3px 0;
    color: var(--text-soft);
    line-height: 1.45;
}

.timeline-list small,
.inspection-list small {
    color: var(--muted);
}

.inspection-list article {
    padding: 13px 0;
    border-bottom: 1px solid var(--border);
}

.inspection-list article > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.asset-dialog,
.inspection-dialog {
    width: min(760px, calc(100vw - 28px));
}

.asset-assignment {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--paper-soft);
}

.asset-assignment[hidden] {
    display: none;
}

.inventory-count-layout {
    display: grid;
    grid-template-columns: minmax(250px, 310px) minmax(0, 1fr);
    align-items: start;
    border-block: 1px solid var(--border);
}

.inventory-count-list {
    display: grid;
    align-content: start;
    border-right: 1px solid var(--border);
}

.inventory-count-list > header,
.inventory-count-workbench {
    padding: 16px;
}

.inventory-count-list > header strong,
.inventory-count-list > header span {
    display: block;
}

.inventory-count-list > header span {
    margin-top: 3px;
    color: var(--muted);
    font-size: .75rem;
}

.inventory-count-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 10px;
    align-items: center;
    min-height: 62px;
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    color: inherit;
    text-decoration: none;
}

.inventory-count-row:hover,
.inventory-count-row.active {
    background: var(--paper-soft);
}

.inventory-count-row.active {
    box-shadow: inset 3px 0 0 var(--accent);
}

.inventory-count-row small {
    display: block;
    margin-top: 2px;
    color: var(--muted);
}

.inventory-count-row .badge {
    grid-column: 1 / -1;
    justify-self: start;
}

.count-progress {
    font-variant-numeric: tabular-nums;
    color: var(--muted);
    font-size: .78rem;
}

.inventory-count-workbench {
    min-width: 0;
}

.count-header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.inventory-count-form .count-input {
    width: 82px;
    min-height: 36px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.count-difference-positive {
    color: #12633a;
}

.count-difference-negative {
    color: #b42318;
}

.count-actions,
.count-final-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 14px;
}

.count-actions span {
    color: var(--muted);
    font-size: .78rem;
}

.count-final-actions {
    justify-content: end;
    border-top: 1px solid var(--border);
}

.count-final-actions form {
    margin: 0;
}

@container workspace (max-width: 1050px) {
    .rental-metrics,
    .asset-facts {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .asset-facts > div:nth-child(3) {
        border-right: 0;
    }

    .asset-facts > div:nth-child(-n+3) {
        border-bottom: 1px solid var(--border);
    }

    .asset-register-form,
    .inventory-count-create {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 820px) {
    .rental-command-bar,
    .asset-file-header,
    .asset-history-grid,
    .inventory-count-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .scan-hint {
        display: none;
    }

    .asset-file-actions {
        justify-content: start;
    }

    .asset-history-grid > section + section {
        padding-left: 0;
        border-top: 1px solid var(--border);
        border-left: 0;
    }

    .asset-history-grid > section:first-child {
        padding-right: 0;
    }

    .inventory-count-list {
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }
}

@media (max-width: 620px) {
    .rental-scan-form {
        grid-template-columns: 22px minmax(0, 1fr);
    }

    .rental-scan-form .button {
        grid-column: 1 / -1;
        width: 100%;
    }

    .rental-metrics,
    .asset-facts,
    .asset-register-form,
    .asset-dialog-fields,
    .inspection-fields,
    .inventory-count-create,
    .asset-assignment {
        grid-template-columns: minmax(0, 1fr);
    }

    .asset-register-form .span-2,
    .asset-dialog-fields .span-2,
    .inspection-fields .span-2,
    .inventory-count-create .span-2 {
        grid-column: auto;
    }

    .asset-facts > div,
    .asset-facts > div:nth-child(3) {
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .date-range-filter,
    .compact-filters,
    .count-actions,
    .count-final-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .date-range-filter label,
    .date-range-filter input,
    .compact-filters input,
    .compact-filters select,
    .count-actions .button,
    .count-final-actions form,
    .count-final-actions .button {
        width: 100%;
    }
}

/* App-wide command layer */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.app-progress {
    position: fixed;
    z-index: 10000;
    top: 0;
    right: 0;
    left: 0;
    height: 3px;
    overflow: hidden;
    pointer-events: none;
}

.app-progress span {
    display: block;
    width: 0;
    height: 100%;
    background: #fff200;
    box-shadow: 0 0 0 1px rgba(35, 31, 32, .12);
    opacity: 0;
}

.app-progress.is-active span {
    width: 88%;
    opacity: 1;
    transition: width 7s cubic-bezier(.12, .68, .24, 1), opacity .12s ease;
}

.app-progress.is-complete span {
    width: 100%;
    opacity: 0;
    transition: width .12s ease, opacity .18s ease .06s;
}

button.global-search {
    min-height: 38px;
    padding: 0 14px 0 35px;
    border: 1px solid #c9cccf;
    border-radius: 5px;
    background: var(--control);
    color: var(--muted-strong);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

button.global-search:hover,
button.global-search:focus-visible {
    border-color: #73787d;
    color: var(--text-strong);
    box-shadow: 0 0 0 3px rgba(255, 242, 0, .24);
}

.command-center {
    width: min(720px, calc(100vw - 32px));
    max-width: none;
    height: min(720px, calc(100dvh - 72px));
    max-height: none;
    margin: 8vh auto auto;
    padding: 0;
    overflow: hidden;
    border: 1px solid #9da2a6;
    border-radius: 8px;
    background: var(--paper);
    box-shadow: 0 24px 70px rgba(19, 21, 23, .28);
}

.command-center::backdrop {
    background: rgba(22, 23, 24, .48);
    backdrop-filter: blur(3px);
}

.command-center-shell {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    height: 100%;
}

.command-center-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 38px;
    gap: 8px;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid var(--border);
}

.command-center-search {
    position: relative;
    display: flex;
    align-items: center;
}

.command-center-search > svg {
    position: absolute;
    left: 12px;
    width: 19px;
    height: 19px;
    color: #6c7277;
    pointer-events: none;
}

.command-center-search input {
    width: 100%;
    height: 44px;
    padding: 0 42px;
    border: 1px solid transparent;
    background: var(--paper-soft);
    color: var(--text-strong);
    font-size: 15px;
}

.command-center-search input:focus {
    border-color: #8d9296;
    background: var(--control);
    box-shadow: 0 0 0 3px rgba(255, 242, 0, .22);
}

.command-search-spinner {
    position: absolute;
    right: 13px;
    width: 15px;
    height: 15px;
    border: 2px solid #c7cacc;
    border-top-color: #231f20;
    border-radius: 50%;
    opacity: 0;
}

.command-search-spinner.is-active {
    opacity: 1;
    animation: command-spin .7s linear infinite;
}

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

.command-center-body {
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

.command-section {
    padding: 14px 16px;
}

.command-section + .command-section {
    border-top: 1px solid var(--border);
}

.command-section > header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
}

.command-action-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
}

.command-action-grid a {
    display: flex;
    gap: 7px;
    align-items: center;
    min-width: 0;
    min-height: 42px;
    padding: 8px 9px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--paper-raised);
    color: var(--text-strong);
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
}

.command-action-grid a:hover,
.command-action-grid a:focus-visible {
    border-color: #8d9296;
    background: #fffef0;
}

.command-action-grid svg {
    flex: 0 0 auto;
    width: 17px;
    height: 17px;
}

.command-area-list,
.command-list {
    display: grid;
    gap: 2px;
}

.command-area-list a,
.command-result {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) auto;
    gap: 9px;
    align-items: center;
    min-height: 48px;
    padding: 7px 9px;
    border: 1px solid transparent;
    border-radius: 5px;
    color: var(--text-strong);
    text-decoration: none;
}

.command-area-list a:hover,
.command-area-list a:focus-visible,
.command-result:hover,
.command-result:focus-visible,
.command-result.is-active {
    border-color: #ded48a;
    background: #fffde3;
}

.command-area-list > a > svg:first-child,
.command-result-icon {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 1px solid #b9bdc0;
    border-radius: 5px;
    background: var(--paper-raised);
    color: var(--text-strong);
}

.command-result-icon img {
    width: 17px;
    height: 17px;
}

.command-area-list > a > svg:first-child {
    padding: 7px;
}

.command-area-list > a > svg:last-child {
    width: 15px;
    color: var(--muted);
}

.command-area-list span,
.command-result > span:nth-child(2) {
    display: grid;
    min-width: 0;
}

.command-area-list strong,
.command-result strong {
    overflow: hidden;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.command-area-list small,
.command-result small {
    overflow: hidden;
    color: var(--muted);
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.command-result-kind {
    padding: 3px 6px;
    border: 1px solid #c7cbce;
    border-radius: 4px;
    background: var(--paper-raised);
    color: var(--muted-strong);
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
}

.command-empty {
    display: grid;
    justify-items: center;
    gap: 4px;
    padding: 58px 20px;
    color: var(--muted);
    text-align: center;
}

.command-empty[hidden] { display: none; }
.command-empty svg { width: 24px; height: 24px; margin-bottom: 4px; }
.command-empty strong { color: var(--text-strong); font-size: 13px; }
.command-empty span { font-size: 11px; }

.command-center-shell > footer {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    min-height: 34px;
    padding: 8px 16px;
    border-top: 1px solid var(--border);
    background: #f6f7f5;
    color: var(--muted);
    font-size: 10px;
}

form.is-submitting {
    pointer-events: none;
}

.button[aria-busy="true"]::after,
.icon-button[aria-busy="true"]::after {
    width: 13px;
    height: 13px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    content: '';
    animation: command-spin .7s linear infinite;
}

.item-live-row.is-command-target {
    background: #fffde3;
    box-shadow: inset 3px 0 #e2d600;
}

@media (max-width: 700px) {
    .command-center {
        width: 100vw;
        height: min(82dvh, 720px);
        margin: auto 0 0;
        border-width: 1px 0 0;
        border-radius: 8px 8px 0 0;
    }

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

    .command-center-shell > footer {
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }
}

@media (prefers-reduced-motion: reduce) {
    .app-progress.is-active span { transition-duration: .01ms; }
    .command-search-spinner.is-active,
    .button[aria-busy="true"]::after,
    .icon-button[aria-busy="true"]::after { animation-duration: 1.4s; }
}

/* PDF workspace: the app chrome remains available on every device. */
.pdf-viewer-workspace-main .page-content {
    max-width: none;
}

.pdf-viewer {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    height: max(600px, calc(var(--visual-viewport-height, 100dvh) - 156px));
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background: #dfe2e4;
    box-shadow: var(--shadow-soft);
}

.pdf-viewer-toolbar {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    min-height: 62px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    background: var(--paper);
}

.pdf-viewer-identity {
    display: grid;
    min-width: 0;
}

.pdf-viewer-identity > span {
    color: var(--muted);
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
}

.pdf-viewer-identity strong,
.pdf-viewer-identity small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pdf-viewer-identity strong { font-size: 13px; }
.pdf-viewer-identity small { color: var(--muted); font-size: 10px; }

.pdf-viewer-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.pdf-viewer-stage {
    position: relative;
    min-width: 0;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    background: #cfd3d6;
}

.pdf-viewer-pages {
    display: grid;
    align-content: start;
    align-items: start;
    justify-items: center;
    gap: 14px;
    width: 100%;
    min-width: 0;
    min-height: 100%;
    padding: 14px;
}

.pdf-viewer-page {
    position: relative;
    width: max-content;
    max-width: 100%;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 2px 10px rgba(19, 24, 27, .18);
}

.pdf-viewer-page canvas {
    display: block;
    max-width: 100%;
    height: auto;
    background: #fff;
}

.pdf-viewer-page > span {
    position: absolute;
    right: 7px;
    bottom: 7px;
    padding: 2px 5px;
    border-radius: 3px;
    background: rgba(22, 27, 30, .72);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    line-height: 1.4;
    pointer-events: none;
}

.pdf-viewer:not(.is-pdf-ready) .pdf-viewer-pages {
    visibility: hidden;
}

.pdf-viewer.is-pdf-ready .pdf-viewer-pages {
    visibility: visible;
}

.has-pdf-error .pdf-viewer-pages {
    display: none;
}

.pdf-viewer-page,
.pdf-viewer-page canvas {
    min-width: 0;
}

.pdf-viewer-loading {
    position: absolute;
    z-index: 1;
    inset: 0;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 9px;
    background: #eef0f1;
    color: var(--muted-strong);
    font-size: 11px;
    font-weight: 650;
}

.pdf-viewer-loading[hidden] { display: none; }
.pdf-viewer-loading svg { animation: pdf-viewer-spin .9s linear infinite; }
@keyframes pdf-viewer-spin { to { transform: rotate(360deg); } }

.pdf-viewer-fallback {
    position: absolute;
    z-index: 3;
    right: 12px;
    bottom: 12px;
    left: 12px;
    display: none;
    justify-content: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid #b48216;
    border-radius: 5px;
    background: #fff8dc;
    color: #5f4913;
    font-size: 11px;
}

.has-pdf-error .pdf-viewer-fallback { display: flex; }
.pdf-viewer-fallback a { color: inherit; font-weight: 750; }

@media (max-width: 720px) {
    .workspace-main,
    .page-content,
    .page-content > *,
    .document-heading,
    .document-command-bar,
    .document-flow,
    .table-meta,
    .draft-layout,
    .draft-main,
    .draft-inspector {
        min-width: 0;
        max-width: 100%;
    }

    .document-command-bar,
    .table-meta {
        align-items: stretch;
        flex-direction: column;
        gap: 9px;
    }

    .document-status {
        min-width: 0;
        flex-wrap: wrap;
    }

    .document-status > span:last-child {
        flex-basis: 100%;
        overflow-wrap: anywhere;
    }

    .document-actions,
    .document-flow-actions,
    .document-preview-actions {
        flex-wrap: nowrap;
        max-width: 100%;
        overflow-x: auto;
        overscroll-behavior-inline: contain;
        -webkit-overflow-scrolling: touch;
    }

    .document-actions > *,
    .document-flow-actions > *,
    .document-preview-actions > * {
        flex: 0 0 auto;
    }

    .pdf-viewer-workspace-main .page-content {
        padding: 8px max(8px, var(--safe-area-right)) calc(8px + var(--mobile-tabbar-height)) max(8px, var(--safe-area-left));
    }

    .pdf-viewer {
        height: calc(var(--visual-viewport-height, 100dvh) - var(--mobile-tabbar-height) - 78px);
        min-height: 360px;
        border-radius: 4px;
    }

    .pdf-viewer-toolbar {
        grid-template-columns: 44px minmax(0, 1fr) auto;
        gap: 7px;
        min-height: 58px;
        padding: 6px;
    }

    .pdf-viewer-back {
        width: 44px;
        min-width: 44px;
        padding: 0;
    }

    .pdf-viewer-back span,
    .pdf-viewer-actions .button span {
        display: none;
    }

    .pdf-viewer-actions .button {
        width: 44px;
        min-width: 44px;
        padding: 0;
    }

    .pdf-viewer-identity > span { display: none; }
    .pdf-viewer-identity strong { font-size: 12px; }

    .pdf-viewer-pages {
        gap: 8px;
        padding: 8px;
    }

    .pdf-viewer-fallback {
        align-items: center;
        flex-direction: column;
        text-align: center;
    }

    .documents-table-wrap {
        overflow: visible;
    }

    .documents-table,
    .documents-table tbody {
        display: block;
        width: 100%;
        min-width: 0;
    }

    .documents-table thead {
        display: none;
    }

    .documents-table tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 6px 12px;
        padding: 12px;
        border-bottom: 1px solid var(--border);
        background: var(--paper);
    }

    .documents-table tr:last-child {
        border-bottom: 0;
    }

    .documents-table td,
    .documents-table td:last-child {
        display: block;
        min-width: 0;
        width: auto;
        padding: 0;
        border: 0;
        background: transparent;
        text-align: left;
        white-space: normal;
    }

    .documents-table:not(.is-compact) td:nth-child(1) { grid-column: 1; grid-row: 1; }
    .documents-table:not(.is-compact) td:nth-child(2) { grid-column: 2; grid-row: 1; }
    .documents-table:not(.is-compact) td:nth-child(3) { grid-column: 2; grid-row: 2; color: var(--muted); font-size: 10px; text-align: right; white-space: nowrap; }
    .documents-table:not(.is-compact) td:nth-child(4) { grid-column: 1; grid-row: 2; }
    .documents-table:not(.is-compact) td:nth-child(5) { grid-column: 1 / -1; grid-row: 3; }
    .documents-table:not(.is-compact) td:nth-child(6) { grid-column: 1; grid-row: 4; align-self: center; }
    .documents-table:not(.is-compact) td:nth-child(7) { grid-column: 2; grid-row: 4; align-self: center; text-align: right; }
    .documents-table:not(.is-compact) td:nth-child(8) { grid-column: 1 / -1; grid-row: 5; justify-self: stretch; }

    .documents-table.is-compact td:nth-child(1) { grid-column: 1; grid-row: 1; }
    .documents-table.is-compact td:nth-child(2) { grid-column: 2; grid-row: 1; }
    .documents-table.is-compact td:nth-child(3) { grid-column: 1 / -1; grid-row: 2; }
    .documents-table.is-compact td:nth-child(4) { grid-column: 1; grid-row: 3; align-self: center; }
    .documents-table.is-compact td:nth-child(5) { grid-column: 2; grid-row: 3; align-self: center; text-align: right; }
    .documents-table.is-compact td:nth-child(6) { grid-column: 1 / -1; grid-row: 4; justify-self: stretch; }

    .documents-table .position {
        display: -webkit-box;
        overflow: hidden;
        color: var(--muted-strong);
        font-size: 11px;
        line-height: 1.35;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }

    .documents-table .invoice-list-actions {
        justify-content: flex-end;
        width: 100%;
    }

    .documents-table .invoice-list-actions .icon-button {
        width: 44px;
        min-width: 44px;
        height: 44px;
    }

    .button.compact {
        min-height: 44px;
    }
}

@media (max-width: 380px) {
    .pdf-viewer-identity small { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .pdf-viewer-loading svg { animation-duration: 1.8s; }
}

/* Project-wide mobile interaction layer. */
.page-content {
    animation: app-page-in 180ms ease both;
}

@keyframes app-page-in {
    from { opacity: .72; }
}

:where(input, select, textarea):user-invalid {
    border-color: #c63838;
    box-shadow: 0 0 0 3px rgba(198, 56, 56, .12);
}

:where(button, .button, .icon-button)[disabled],
:where(button, .button, .icon-button)[aria-disabled="true"] {
    cursor: not-allowed;
    opacity: .56;
}

.has-touch-feedback {
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

.touch-ripple {
    position: absolute;
    z-index: 20;
    border-radius: 50%;
    background: currentColor;
    opacity: 0;
    pointer-events: none;
    transform: scale(.12);
    animation: touch-ripple 440ms ease-out;
}

@keyframes touch-ripple {
    18% { opacity: .13; }
    to { opacity: 0; transform: scale(1); }
}

.is-activating {
    background-color: var(--accent-soft) !important;
}

.app-toast {
    animation: app-toast-enter 180ms ease-out both;
}

@keyframes app-toast-enter {
    from { opacity: 0; transform: translateY(8px) scale(.985); }
}

.mobile-create-sheet {
    width: min(680px, calc(100vw - 24px));
    max-width: none;
}

.mobile-create-sheet-shell {
    display: grid;
    grid-template-rows: auto auto auto minmax(0, 1fr);
    min-height: 0;
}

.mobile-sheet-grabber {
    display: none;
}

.mobile-create-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 14px 16px 10px;
}

.mobile-create-header h2,
.mobile-create-header .eyebrow {
    margin: 0;
}

.mobile-create-search {
    position: relative;
    display: flex;
    align-items: center;
    margin: 0 16px 10px;
}

.mobile-create-search > svg {
    position: absolute;
    left: 12px;
    z-index: 1;
    color: var(--muted);
    pointer-events: none;
}

.mobile-create-search input {
    width: 100%;
    min-height: 44px;
    padding: 0 12px 0 40px;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background: var(--canvas);
}

.mobile-create-content {
    min-height: 0;
    padding: 2px 16px 18px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.mobile-create-group + .mobile-create-group {
    margin-top: 16px;
}

.mobile-create-group > h3 {
    margin: 0 0 7px;
    color: var(--muted-strong);
    font-size: 10px;
    font-weight: 750;
    text-transform: uppercase;
}

.mobile-create-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
}

.mobile-create-list {
    display: grid;
    border-top: 1px solid var(--border);
}

.mobile-create-action {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) 16px;
    gap: 9px;
    align-items: center;
    min-width: 0;
    min-height: 56px;
    padding: 8px 2px;
    border-bottom: 1px solid var(--border);
    color: var(--text-strong);
    text-decoration: none;
    transition: background-color 120ms ease, transform 120ms ease;
}

.mobile-create-action.is-featured {
    grid-template-columns: 38px minmax(0, 1fr);
    align-content: start;
    min-height: 88px;
    padding: 10px;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background: var(--paper-raised);
}

.mobile-create-action.is-featured:nth-child(1) {
    border-color: #c8bc00;
    background: #fffde3;
}

.mobile-create-action > span:nth-child(2) {
    display: grid;
    min-width: 0;
}

.mobile-create-action strong {
    overflow-wrap: anywhere;
    font-size: 13px;
}

.mobile-create-action small {
    margin-top: 1px;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.25;
}

.mobile-create-action > svg:last-child {
    width: 15px;
    color: var(--muted);
}

.mobile-create-icon {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 1px solid #9a9da1;
    border-radius: 6px;
    background: var(--paper-raised);
    color: var(--text-strong);
}

.mobile-create-icon svg {
    width: 18px;
    height: 18px;
}

.mobile-create-empty {
    justify-items: center;
    gap: 6px;
    padding: 40px 12px;
    color: var(--muted);
    text-align: center;
}

.mobile-create-empty:not([hidden]) { display: grid; }
.mobile-create-empty svg { width: 24px; height: 24px; }

.swipe-back-indicator {
    display: none;
}

@media (max-width: 720px) {
    .topbar .mobile-menu {
        display: inline-flex;
    }

    .topbar-actions .global-create {
        display: none;
    }

    .topbar-actions .global-search {
        display: inline-grid;
    }

    button.global-search {
        place-items: center;
        width: 44px;
        min-width: 44px;
        height: 44px;
        padding: 0;
        border-radius: 6px;
    }

    button.global-search > svg {
        position: static;
        width: 19px;
        height: 19px;
    }

    button.global-search > span {
        display: none;
    }

    .mobile-tabbar {
        overflow: visible;
        contain: layout style;
    }

    .mobile-tabbar a,
    .mobile-tabbar button {
        transition: color 120ms ease, background-color 120ms ease, transform 120ms ease;
    }

    .mobile-tabbar .mobile-tab-create::before {
        display: none;
    }

    .mobile-tabbar .mobile-tab-create .app-icon {
        width: 42px;
        height: 42px;
        padding: 10px;
        border: 1px solid #231f20;
        border-radius: 8px;
        background: #fff200;
        box-shadow: 0 5px 14px rgba(35, 31, 32, .2);
        color: #231f20;
        transform: translateY(-8px);
        transition: transform 140ms ease, box-shadow 140ms ease;
    }

    .mobile-tabbar .mobile-tab-create > span {
        transform: translateY(-5px);
    }

    .mobile-tabbar .mobile-tab-create:active .app-icon,
    .mobile-tabbar .mobile-tab-create.is-touching .app-icon {
        box-shadow: 0 2px 7px rgba(35, 31, 32, .18);
        transform: translateY(-5px) scale(.95);
    }

    :where(.button, .icon-button, .mobile-tabbar a, .mobile-create-action, .customer-mobile-contact a):active,
    :where(.button, .icon-button, .mobile-tabbar a, .mobile-create-action, .customer-mobile-contact a).is-touching {
        filter: brightness(.97);
        transform: scale(.975);
    }

    .mobile-create-sheet,
    .app-dialog.mobile-create-sheet:not(.confirm-dialog) {
        --sheet-drag: 0px;
        width: 100%;
        max-width: none;
        height: min(84dvh, 720px);
        max-height: calc(var(--visual-viewport-height, 100dvh) - var(--safe-area-top) - 8px);
        inset: auto 0 0;
        margin: 0;
        overflow: hidden;
        border-width: 1px 0 0;
        border-radius: 8px 8px 0 0;
        transform: translateY(calc(12px + var(--sheet-drag))) scale(1);
    }

    .mobile-create-sheet[open],
    .app-dialog.mobile-create-sheet[open] {
        transform: translateY(var(--sheet-drag)) scale(1);
    }

    .mobile-create-sheet.is-sheet-dragging {
        transition: none;
    }

    .mobile-create-sheet::backdrop {
        background: rgba(15, 18, 22, .58);
    }

    .mobile-create-sheet-shell {
        height: 100%;
        padding-bottom: var(--safe-area-bottom);
    }

    .mobile-sheet-grabber {
        display: grid;
        place-items: center;
        width: 100%;
        height: 22px;
        min-height: 22px;
        padding: 0;
        border: 0;
        background: var(--paper);
        touch-action: none;
    }

    .mobile-sheet-grabber span {
        width: 38px;
        height: 4px;
        border-radius: 2px;
        background: #b5b9bc;
    }

    .mobile-create-header {
        padding-top: 4px;
    }

    .mobile-create-header h2 {
        font-size: 19px;
    }

    .mobile-create-search input {
        font-size: 16px;
    }

    .app-progress {
        top: var(--safe-area-top);
    }

    .swipe-back-indicator {
        position: fixed;
        z-index: 310;
        top: 48%;
        left: max(7px, var(--safe-area-left));
        display: grid;
        place-items: center;
        width: 42px;
        height: 42px;
        border: 1px solid #231f20;
        border-radius: 50%;
        background: #fff200;
        box-shadow: 0 5px 18px rgba(20, 24, 28, .22);
        color: #231f20;
        opacity: 0;
        pointer-events: none;
        transform: translate3d(calc(-34px + (var(--swipe-back-progress, 0) * 34px)), -50%, 0) scale(calc(.76 + (var(--swipe-back-progress, 0) * .24)));
    }

    .is-swipe-tracking .swipe-back-indicator,
    .is-swipe-committing .swipe-back-indicator {
        opacity: calc(.2 + (var(--swipe-back-progress, 0) * .8));
    }

    .is-swipe-tracking body,
    .is-swipe-committing body {
        overflow: hidden;
    }

    .is-swipe-tracking .workspace-main {
        border-radius: 8px 0 0 8px;
        box-shadow: -8px 0 24px rgba(20, 24, 28, .12);
        transform: translate3d(var(--swipe-back-offset, 0), 0, 0);
        will-change: transform;
    }

    .is-swipe-committing .workspace-main {
        transform: translate3d(100vw, 0, 0);
        transition: transform 180ms ease-out;
    }

    .is-navigating .mobile-tabbar .is-activating .app-icon {
        transform: scale(.9);
    }
}

@media (max-width: 380px) {
    .mobile-create-grid {
        grid-template-columns: 1fr 1fr;
    }

    .mobile-create-action.is-featured {
        min-height: 82px;
        padding: 8px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .page-content,
    .touch-ripple,
    .app-toast {
        animation-duration: .01ms;
    }

    .mobile-tabbar a,
    .mobile-tabbar button,
    .mobile-create-action,
    .workspace-main {
        transition-duration: .01ms !important;
    }
}

/* Keep the mobile document workspace last in the cascade. */
@media (max-width: 720px) {
    body:has(.mobile-document-dock) .page-content {
        padding-bottom: calc(var(--mobile-tabbar-height) + 104px);
    }

    .mobile-document-dock {
        display: grid;
    }

    .position-sheet-scrim {
        display: block;
    }

    .position-sheet-header {
        display: flex;
    }

    .mobile-line-kind {
        display: block;
    }

    .mobile-line-expand {
        display: inline-grid;
    }

    .mobile-create-sheet,
    .app-dialog.mobile-create-sheet:not(.confirm-dialog) {
        height: min(90dvh, 780px);
        border-radius: 18px 18px 0 0;
        background: var(--paper);
        box-shadow: 0 -18px 64px rgba(0, 0, 0, .28);
        transition: transform 320ms cubic-bezier(.22, 1, .36, 1), opacity 180ms ease, overlay 180ms allow-discrete, display 180ms allow-discrete;
    }

    .mobile-sheet-grabber {
        height: 28px;
        min-height: 28px;
        background: var(--paper);
    }

    .mobile-create-header {
        min-height: 60px;
        padding: 2px 18px 11px;
        touch-action: none;
    }

    .invoice-lines-table.is-live-grid .invoice-line-row,
    .invoice-lines-table.is-live-grid .invoice-line-row.is-section,
    .invoice-lines-table.is-live-grid .invoice-line-row.is-text,
    .invoice-lines-table.is-live-grid .invoice-line-row.is-spacer {
        grid-template-columns: 36px minmax(0, 1fr) auto 44px !important;
        min-height: 72px;
        gap: 7px;
        padding: 9px 6px;
        background: var(--paper);
    }

    .invoice-lines-table.is-live-grid .invoice-line-row > td:nth-child(1) {
        grid-column: 1;
        grid-row: 1;
        align-content: center;
    }

    .invoice-lines-table.is-live-grid .invoice-line-row > td:nth-child(2),
    .invoice-lines-table.is-live-grid .invoice-line-row > td:nth-child(4),
    .invoice-lines-table.is-live-grid .invoice-line-row > td:nth-child(5),
    .invoice-lines-table.is-live-grid .invoice-line-row > td:nth-child(6),
    .invoice-lines-table.is-live-grid .invoice-line-row > td:nth-child(7) {
        display: none;
    }

    .invoice-lines-table.is-live-grid .invoice-line-row > td:nth-child(3) {
        grid-column: 2;
        grid-row: 1;
        align-content: center;
    }

    .invoice-lines-table.is-live-grid .invoice-line-row > td:nth-child(8) {
        grid-column: 3;
        grid-row: 1;
        align-content: center;
        min-width: 68px;
        text-align: right;
    }

    .invoice-lines-table.is-live-grid .invoice-line-row > td:nth-child(9) {
        grid-column: 4;
        grid-row: 1;
        align-content: start;
    }

    .invoice-lines-table.is-live-grid .invoice-line-row > td:nth-child(3)::before,
    .invoice-lines-table.is-live-grid .invoice-line-row > td:nth-child(8)::before,
    .invoice-lines-table.is-live-grid .invoice-line-row > td:nth-child(9)::before {
        display: none;
    }

    .invoice-line-row .inline-line-actions {
        display: none;
    }

    .invoice-lines-table.is-live-grid .invoice-line-row.is-mobile-expanded {
        grid-template-columns: 36px minmax(0, 1fr) minmax(82px, .55fr) 44px !important;
        background: var(--paper-soft);
    }

    .invoice-lines-table.is-live-grid .invoice-line-row.is-mobile-expanded > td:nth-child(1) {
        grid-row: 1 / span 2;
    }

    .invoice-lines-table.is-live-grid .invoice-line-row.is-mobile-expanded > td:nth-child(2) {
        display: grid;
        grid-column: 2 / 4;
        grid-row: 2;
    }

    .invoice-lines-table.is-live-grid .invoice-line-row.is-mobile-expanded > td:nth-child(4) {
        display: grid;
        grid-column: 2 / 4;
        grid-row: 3;
    }

    .invoice-lines-table.is-live-grid .invoice-line-row.is-mobile-expanded > td:nth-child(5) {
        display: grid;
        grid-column: 2;
        grid-row: 4;
    }

    .invoice-lines-table.is-live-grid .invoice-line-row.is-mobile-expanded > td:nth-child(6) {
        display: grid;
        grid-column: 3;
        grid-row: 4;
    }

    .invoice-lines-table.is-live-grid .invoice-line-row.is-mobile-expanded > td:nth-child(7) {
        display: grid;
        grid-column: 2;
        grid-row: 5;
    }

    .invoice-lines-table.is-live-grid .invoice-line-row.is-mobile-expanded > td:nth-child(9) {
        grid-row: 1 / span 5;
    }

    .invoice-line-row.is-mobile-expanded .inline-line-actions {
        display: flex;
    }

    .invoice-lines-table.is-live-grid .invoice-line-row.is-section.is-mobile-expanded > td:nth-child(n + 5):nth-child(-n + 8),
    .invoice-lines-table.is-live-grid .invoice-line-row.is-text.is-mobile-expanded > td:nth-child(n + 5):nth-child(-n + 8),
    .invoice-lines-table.is-live-grid .invoice-line-row.is-spacer.is-mobile-expanded > td:nth-child(n + 5):nth-child(-n + 8) {
        display: none;
    }

    /* The create action stays inside the tabbar grid and never overlaps its label. */
    .mobile-tabbar .mobile-tab-create {
        grid-template-rows: 36px 14px;
        align-content: center;
        gap: 1px;
        height: 56px;
        overflow: hidden;
        padding-top: 2px;
        contain: size layout paint;
        transform: none !important;
    }

    .mobile-tabbar .mobile-tab-create .mobile-create-glyph {
        width: 40px;
        height: 34px;
        border: 1px solid #231f20;
        border-radius: 9px;
        background: #231f20;
        box-shadow: 0 2px 5px rgba(18, 20, 22, .18);
        color: #fff200;
        transform: none;
    }

    .mobile-tabbar .mobile-tab-create .mobile-create-glyph .app-icon {
        width: 19px;
        height: 19px;
        padding: 0;
        border: 0;
        background: transparent;
        box-shadow: none;
        color: inherit;
    }

    .mobile-tabbar .mobile-tab-create > span:last-child {
        position: relative;
        z-index: 1;
        line-height: 12px;
        transform: none;
    }

    .mobile-tabbar .mobile-tab-create:active .mobile-create-glyph,
    .mobile-tabbar .mobile-tab-create.is-touching .mobile-create-glyph {
        box-shadow: 0 1px 2px rgba(18, 20, 22, .18);
        background: #fff200;
        color: #231f20;
        transform: none;
    }

    .mobile-tabbar .mobile-tab-create[aria-expanded="true"] .mobile-create-glyph {
        background: #fff200;
        color: #231f20;
        transform: none;
    }

    .mobile-tabbar a:active,
    .mobile-tabbar a.is-touching,
    .mobile-tabbar button:active,
    .mobile-tabbar button.is-touching {
        filter: brightness(.94);
        transform: none !important;
    }

    .mobile-create-sheet,
    .app-dialog.mobile-create-sheet:not(.confirm-dialog) {
        --mobile-create-sheet-height: min(760px, calc(var(--visual-viewport-height, 100dvh) - max(52px, var(--safe-area-top))));
        --sheet-drag: 0px;
        position: fixed;
        top: calc(var(--visual-viewport-offset-top, 0px) + var(--visual-viewport-height, 100dvh) - var(--mobile-create-sheet-height));
        right: 0;
        bottom: auto;
        left: 0;
        width: 100%;
        height: var(--mobile-create-sheet-height);
        max-height: none;
        margin: 0;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -24px 72px rgba(0, 0, 0, .34);
        opacity: 0;
        transform: translateY(calc(100% + 18px)) scale(.985);
        transition: transform 420ms cubic-bezier(.2, .78, .2, 1), opacity 240ms ease, top 140ms linear, height 140ms linear, overlay 240ms allow-discrete, display 240ms allow-discrete;
        will-change: transform, opacity;
    }

    .app-dialog.mobile-create-sheet[open] {
        opacity: 0;
        transform: translateY(calc(100% + 18px)) scale(.985);
    }

    .app-dialog.mobile-create-sheet[open].is-sheet-visible {
        opacity: 1;
        transform: translateY(var(--sheet-drag)) scale(1);
    }

    .app-dialog.mobile-create-sheet[open].is-sheet-closing {
        opacity: 0;
        pointer-events: none;
        transform: translateY(calc(100% + 18px)) scale(.985);
    }

    .app-dialog.mobile-create-sheet.is-sheet-dragging {
        transition: none;
    }

    .app-dialog.mobile-create-sheet.is-sheet-closing::backdrop {
        opacity: 0;
    }

    .app-dialog.mobile-create-sheet::backdrop {
        background: rgba(15, 18, 22, calc(.58 - (var(--sheet-drag-progress, 0) * .3)));
    }

    html.has-visual-keyboard .app-dialog.mobile-create-sheet {
        border-radius: 16px 16px 0 0;
    }

    html.has-visual-keyboard .mobile-create-sheet-shell {
        padding-bottom: 0;
    }

    .mobile-sheet-grabber span {
        transition: width 160ms ease, background-color 160ms ease, transform 160ms ease;
    }

    .mobile-create-sheet.is-sheet-dragging .mobile-sheet-grabber span,
    .position-composer-zone.is-dragging .position-sheet-header::before {
        width: 54px;
    }

    .mobile-create-sheet.is-past-threshold .mobile-sheet-grabber span,
    .position-composer-zone.is-past-threshold .position-sheet-header::before {
        width: 66px;
        background: #fff200;
    }

    html.has-position-composer .mobile-tabbar {
        opacity: 0;
        pointer-events: none;
        transform: translateY(calc(100% + var(--safe-area-bottom)));
    }

    .position-sheet-scrim {
        z-index: 360;
        background: rgba(8, 10, 12, calc(.62 - (var(--composer-drag-progress, 0) * .32)));
    }

    .position-composer-zone .position-quick-add,
    .position-composer-zone .sale-cart-composer {
        z-index: 370;
        bottom: var(--visual-viewport-offset-bottom, 0px);
        max-height: min(92dvh, calc(var(--visual-viewport-height, 100dvh) - var(--safe-area-top) - 8px));
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -24px 72px rgba(0, 0, 0, .36);
    }

    .position-sheet-header {
        position: sticky;
        z-index: 8;
        top: 0;
        min-height: 82px;
        margin: 0 -14px;
        padding: 19px 16px 10px;
        background: color-mix(in srgb, var(--paper) 94%, transparent);
        backdrop-filter: blur(18px);
    }

    .position-sheet-header::before {
        transition: width 160ms ease, background-color 160ms ease;
    }

    .position-composer-zone .position-quick-add {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
        padding: 0 14px calc(18px + var(--safe-area-bottom));
        overscroll-behavior: contain;
    }

    .position-composer-zone .position-quick-add .quick-type {
        display: none !important;
    }

    .position-composer-zone .quick-type-rail {
        display: flex;
        grid-column: 1 / -1;
        gap: 7px;
        width: calc(100% + 28px);
        margin: -4px -14px 0;
        padding: 4px 14px 8px;
        overflow-x: auto;
        scroll-padding-inline: 14px;
        scrollbar-width: none;
        overscroll-behavior-inline: contain;
    }

    .position-composer-zone .quick-type-rail::-webkit-scrollbar {
        display: none;
    }

    .position-composer-zone .quick-type-rail button {
        display: inline-flex;
        flex: 0 0 auto;
        align-items: center;
        gap: 6px;
        min-height: 38px;
        padding: 0 11px;
        border: 1px solid var(--border-strong);
        border-radius: 7px;
        background: var(--paper);
        color: var(--muted-strong);
        font: inherit;
        font-size: 11px;
        font-weight: 700;
    }

    .position-composer-zone .quick-type-rail button svg,
    .position-composer-zone .quick-type-rail button img {
        width: 16px;
        height: 16px;
    }

    .position-composer-zone .quick-type-rail button[aria-pressed="true"] {
        border-color: #231f20;
        background: #231f20;
        box-shadow: inset 0 -3px #fff200;
        color: #fff;
    }

    .position-composer-zone .position-quick-add .quick-item {
        grid-column: 1 / -1;
    }

    .position-composer-zone .position-quick-add .quick-item .item-combobox {
        position: static;
    }

    .position-composer-zone .position-quick-add .quick-item .item-search-results {
        position: relative;
        top: auto;
        right: auto;
        bottom: auto;
        left: auto;
        width: 100%;
        max-height: min(32dvh, 270px);
        margin-top: 6px;
        border-radius: 6px;
        box-shadow: 0 10px 28px rgba(20, 24, 28, .16);
    }

    .position-composer-zone .position-quick-add .quick-description-mobile {
        display: grid !important;
    }

    .position-composer-zone .position-quick-add .quick-spacer-color {
        display: none !important;
    }

    .position-composer-zone .position-quick-add.is-spacer .quick-spacer-color {
        display: grid !important;
    }

    .position-composer-zone .position-quick-add.is-spacer .quick-item,
    #position-neu .position-quick-add.is-spacer > .quick-quantity,
    #position-neu .position-quick-add.is-spacer > .quick-unit,
    #position-neu .position-quick-add.is-spacer > .quick-price,
    #position-neu .position-quick-add.is-spacer > .quick-tax,
    .position-composer-zone .position-quick-add.is-spacer .quick-description-mobile,
    #position-neu .position-quick-add.is-spacer > .quick-deposit,
    #position-neu .position-quick-add.is-text > .quick-quantity,
    #position-neu .position-quick-add.is-text > .quick-unit,
    #position-neu .position-quick-add.is-text > .quick-price,
    #position-neu .position-quick-add.is-text > .quick-tax,
    #position-neu .position-quick-add.is-text > .quick-deposit,
    #position-neu .position-quick-add.is-section > .quick-quantity,
    #position-neu .position-quick-add.is-section > .quick-unit,
    #position-neu .position-quick-add.is-section > .quick-price,
    #position-neu .position-quick-add.is-section > .quick-tax,
    #position-neu .position-quick-add.is-section > .quick-deposit {
        display: none !important;
    }

    #position-neu .position-quick-add > label.quick-deposit {
        display: flex !important;
        flex-direction: row;
        align-items: center;
        grid-column: 1 / -1;
        justify-content: flex-start;
        gap: 9px;
        height: auto;
        min-height: 44px;
        padding: 4px;
        color: var(--text);
        font-size: 12px;
        font-weight: 650;
    }

    #position-neu .position-quick-add > label.quick-deposit input[type="checkbox"] {
        width: 22px;
        min-width: 22px;
        height: 22px;
        min-height: 22px;
        margin: 0;
        padding: 0;
    }

    #position-neu .position-quick-add > label.quick-deposit span {
        display: inline;
        color: inherit;
        font: inherit;
    }

    .position-composer-zone .quick-description-mobile .rich-text-field {
        gap: 4px;
    }

    .position-composer-zone .quick-description-mobile .rich-text-label {
        color: var(--muted-strong);
        font-size: 10px;
    }

    .position-composer-zone .quick-description-mobile .rich-text-toolbar {
        position: sticky;
        top: 82px;
        z-index: 6;
        background: var(--paper-soft);
    }

    .position-composer-zone .quick-description-mobile .ql-editor {
        min-height: 72px;
        font-size: 16px;
    }

    .position-composer-zone .position-quick-add > .icon-button.primary,
    .position-composer-zone .sale-cart-form > .button.primary {
        position: sticky;
        z-index: 7;
        bottom: 0;
        grid-column: 1 / -1;
        min-height: 50px;
        border-radius: 7px;
        box-shadow: 0 -8px 0 8px var(--paper), 0 8px 0 8px var(--paper);
    }

    .position-composer-zone .position-quick-add .quick-add-state,
    .position-composer-zone .sale-cart-form .quick-add-state {
        min-height: 0;
    }

    .position-composer-zone .sale-cart-form {
        padding-bottom: calc(18px + var(--safe-area-bottom));
        overscroll-behavior: contain;
    }

    html[data-theme="dark"] .mobile-tabbar .mobile-tab-create .mobile-create-glyph {
        border-color: #fff200;
        box-shadow: 0 2px 5px rgba(0, 0, 0, .45);
    }

html[data-theme="dark"] .position-composer-zone .quick-type-rail button[aria-pressed="true"] {
        border-color: #fff200;
        background: #fff200;
        box-shadow: none;
        color: #17191b;
    }

    .item-live-new-row {
        display: none;
    }

    .item-create-dialog .mobile-sheet-grabber {
        display: grid;
    }

    .item-create-dialog .mobile-create-header {
        min-height: 66px;
        padding: 0 16px 11px;
        touch-action: auto;
    }

    .item-create-dialog-body {
        padding: 12px 14px;
    }

    .item-create-dialog-fields {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .item-create-dialog-fields .span-2 {
        grid-column: auto;
    }

    .item-create-dialog-fields input,
    .item-create-dialog-fields select {
        width: 100%;
        min-height: 46px;
        font-size: 16px;
    }

    .item-create-dialog-footer {
        grid-template-columns: 1fr;
        gap: 6px;
        min-height: 76px;
        padding: 9px 14px calc(9px + var(--safe-area-bottom));
    }

    .item-create-dialog-footer .button {
        width: 100%;
        min-height: 48px;
    }

    .item-create-dialog-state:empty {
        display: none;
    }
}

/* Keep list-level create menus compact; the global create menu remains a mobile sheet. */
.document-list-create > summary > .app-icon:last-child {
    transition: transform 180ms cubic-bezier(.2, .75, .2, 1);
}

.document-list-create[open] > summary > .app-icon:last-child {
    transform: rotate(180deg);
}

.document-list-create[open] > .quick-create-menu {
    animation: document-create-menu-in 200ms cubic-bezier(.2, .75, .2, 1) both;
    transform-origin: top right;
}

@keyframes document-create-menu-in {
    from {
        opacity: 0;
        transform: translateY(-6px) scale(.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (max-width: 720px) {
    .invoice-list-actions .icon-button,
    .toast-close {
        width: 44px;
        min-width: 44px;
        height: 44px;
    }

    .position-composer-zone .quick-type-rail button {
        min-height: 44px;
    }

    .document-list-create {
        width: 100%;
        min-width: 0;
    }

    .document-list-create > summary {
        width: 100%;
        justify-content: center;
    }

    .document-list-create > .quick-create-menu {
        position: absolute;
        top: calc(100% + 8px);
        right: auto;
        bottom: auto;
        left: 0;
        width: calc(200% + 8px);
        max-width: calc(100vw - 48px);
        max-height: min(360px, calc(var(--visual-viewport-height, 100dvh) - 190px));
        padding: 6px;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        border-radius: 8px;
        box-shadow: 0 16px 42px rgba(0, 0, 0, .28);
        transform-origin: top left;
    }

    .document-list-create > .quick-create-menu a {
        min-height: 56px;
        padding: 9px 10px;
        align-items: center;
    }

    .document-list-create > .quick-create-menu a + a {
        border-top: 1px solid var(--border);
    }

    .invoice-line-row.is-mobile-expanded .line-options > summary.icon-button,
    .invoice-line-row.is-mobile-expanded .line-options-panel .icon-button {
        width: 44px;
        min-width: 44px;
        height: 44px;
    }

    .invoice-lines-table.is-live-grid .invoice-line-row .line-options-panel {
        bottom: calc(var(--mobile-tabbar-height) + 8px);
        max-height: calc(var(--visual-viewport-height, 100dvh) - var(--mobile-tabbar-height) - var(--safe-area-top) - 24px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .document-list-create[open] > .quick-create-menu {
        animation: none;
    }

    .document-list-create > summary > .app-icon:last-child {
        transition: none;
    }

    .combobox-results:not([hidden]) {
        animation: none;
    }
}

.transient-draft-notice {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
    padding: 11px 12px;
    border: 1px solid color-mix(in srgb, var(--accent) 58%, var(--border));
    border-left: 4px solid var(--accent);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--accent) 10%, var(--paper));
    transition: opacity 160ms ease, transform 160ms ease;
}

.transient-draft-notice > div:not(.transient-draft-actions) {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.transient-draft-notice strong {
    font-size: 13px;
}

.transient-draft-notice span {
    color: var(--muted-strong);
    font-size: 12px;
}

.transient-draft-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid color-mix(in srgb, var(--accent) 62%, var(--border));
    border-radius: var(--radius);
    background: var(--paper);
    color: var(--text);
}

.transient-draft-icon .app-icon {
    width: 19px;
    height: 19px;
}

.transient-draft-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.transient-draft-notice.is-resolved {
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
}

.transient-draft-dialog {
    width: min(520px, calc(100vw - 24px));
}

.transient-draft-dialog-card {
    display: grid;
    gap: 16px;
    padding: 20px;
}

.transient-draft-dialog-card > header {
    display: flex;
    gap: 12px;
    align-items: center;
}

.transient-draft-dialog-card > header > div {
    display: grid;
    gap: 2px;
}

.transient-draft-dialog-card h2,
.transient-draft-dialog-card p {
    margin: 0;
}

.transient-draft-dialog-card p {
    color: var(--muted-strong);
    font-size: 13px;
    line-height: 1.5;
}

.transient-draft-dialog-card > footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

@media (max-width: 720px) {
    .transient-draft-notice {
        grid-template-columns: 38px minmax(0, 1fr);
        align-items: start;
    }

    .transient-draft-actions {
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .transient-draft-actions .button {
        justify-content: center;
        min-height: 44px;
    }

    .transient-draft-dialog {
        width: calc(100vw - 20px);
        margin-bottom: max(10px, env(safe-area-inset-bottom));
    }

    .transient-draft-dialog-card > footer {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .transient-draft-dialog-card > footer .button {
        justify-content: center;
        min-height: 44px;
    }

    .transient-draft-dialog-card > footer [data-transient-exit-cancel] {
        grid-column: 1 / -1;
        grid-row: 2;
    }
}

/* Position workspace: operational overview plus full spreadsheet mode */
.position-overview-tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: var(--paper-soft);
}

.position-filter-rail {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.position-filter-rail::-webkit-scrollbar {
    display: none;
}

.position-filter-rail button,
.position-view-switch button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 32px;
    padding: 5px 9px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: var(--muted-strong);
    font: inherit;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
}

.position-filter-rail button:hover,
.position-view-switch button:hover {
    border-color: var(--border);
    background: var(--paper);
    color: var(--text-strong);
}

.position-filter-rail button[aria-pressed="true"],
.position-view-switch button[aria-pressed="true"] {
    border-color: var(--border-strong);
    background: var(--paper);
    color: var(--text-strong);
    box-shadow: inset 0 -2px var(--brand);
}

.position-filter-rail button[data-position-filter="rental"][aria-pressed="true"] {
    box-shadow: inset 0 -2px var(--blue);
}

.position-filter-rail button[data-position-filter="deposit"][aria-pressed="true"] {
    box-shadow: inset 0 -2px var(--teal);
}

.position-filter-rail button[data-position-filter="service"][aria-pressed="true"] {
    box-shadow: inset 0 -2px var(--amber);
}

.position-filter-rail button[data-position-filter="discount"][aria-pressed="true"] {
    box-shadow: inset 0 -2px var(--red);
}

.position-filter-rail button svg,
.position-filter-rail button img,
.position-view-switch button svg,
.position-view-switch button img {
    width: 14px;
    height: 14px;
}

.position-filter-rail button b {
    display: inline-grid;
    place-items: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    background: var(--paper-soft);
    color: var(--muted-strong);
    font-size: 9px;
}

.position-view-switch {
    display: inline-flex;
    flex: none;
    gap: 2px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--paper-soft);
}

.position-filter-empty {
    padding: 30px 16px;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}

.line-title-meta {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    margin-bottom: 1px;
}

.line-item-category {
    max-width: 190px;
    overflow: hidden;
    color: var(--muted);
    font-size: 9px;
    font-weight: 650;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (min-width: 721px) {
    .invoice-paper:has(.position-quick-add) .position-grid-wrap[data-position-view="overview"],
    .position-grid-wrap[data-position-view="overview"] {
        overflow-x: clip;
        overflow-y: visible;
    }

    .position-grid-wrap[data-position-view="overview"] .invoice-lines-table.is-live-grid {
        display: block;
        width: 100%;
        min-width: 0;
        table-layout: auto;
    }

    .position-grid-wrap[data-position-view="overview"] thead,
    .position-grid-wrap[data-position-view="overview"] tbody {
        display: block;
        width: 100%;
    }

    .position-grid-wrap[data-position-view="overview"] thead tr,
    .position-grid-wrap[data-position-view="overview"] .invoice-line-row {
        display: grid;
        grid-template-columns: 30px minmax(220px, 1fr) 132px 92px 108px 76px;
        column-gap: 8px;
        align-items: center;
        width: 100%;
    }

    .position-grid-wrap[data-position-view="overview"] thead tr {
        min-height: 32px;
        padding: 0 8px;
        background: var(--paper-soft);
    }

    .position-grid-wrap[data-position-view="overview"] thead th {
        display: none;
        width: auto;
        padding: 7px 4px;
        border: 0;
        background: transparent;
        color: var(--muted);
        font-size: 8px;
    }

    .position-grid-wrap[data-position-view="overview"] thead th:nth-child(1) { display: block; grid-column: 1; }
    .position-grid-wrap[data-position-view="overview"] thead th:nth-child(3) { display: block; grid-column: 2; }
    .position-grid-wrap[data-position-view="overview"] thead th:nth-child(5) { display: block; grid-column: 3; }
    .position-grid-wrap[data-position-view="overview"] thead th:nth-child(6) { display: block; grid-column: 4; text-align: right; }
    .position-grid-wrap[data-position-view="overview"] thead th:nth-child(8) { display: block; grid-column: 5; text-align: right; }
    .position-grid-wrap[data-position-view="overview"] thead th:nth-child(9) { display: block; grid-column: 6; }

    .position-grid-wrap[data-position-view="overview"] .invoice-line-row {
        min-height: 62px;
        padding: 8px;
        border-bottom: 1px solid var(--border);
        border-left: 3px solid transparent;
        background: var(--paper);
        transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
    }

    .position-grid-wrap[data-position-view="overview"] .invoice-line-row:hover {
        border-left-color: var(--brand);
        background: var(--paper-soft);
    }

    .position-grid-wrap[data-position-view="overview"] .invoice-line-row[hidden] {
        display: none !important;
    }

    .position-grid-wrap[data-position-view="overview"] .invoice-line-row > td {
        display: none;
        min-width: 0;
        width: auto;
        height: auto;
        padding: 0;
        border: 0;
        background: transparent;
        vertical-align: middle;
    }

    .position-grid-wrap[data-position-view="overview"] .invoice-line-row > td:nth-child(1) {
        display: block;
        grid-column: 1;
        grid-row: 1;
    }

    .position-grid-wrap[data-position-view="overview"] .invoice-line-row > td:nth-child(3) {
        display: block;
        grid-column: 2;
        grid-row: 1;
    }

    .position-grid-wrap[data-position-view="overview"] .invoice-line-row > td:nth-child(5) {
        display: block;
        grid-column: 3;
        grid-row: 1;
    }

    .position-grid-wrap[data-position-view="overview"] .invoice-line-row > td:nth-child(6) {
        display: block;
        grid-column: 4;
        grid-row: 1;
    }

    .position-grid-wrap[data-position-view="overview"] .invoice-line-row > td:nth-child(8) {
        display: block;
        grid-column: 5;
        grid-row: 1;
        text-align: right;
    }

    .position-grid-wrap[data-position-view="overview"] .invoice-line-row > td:nth-child(9) {
        display: flex;
        grid-column: 6;
        grid-row: 1;
        align-items: center;
        justify-content: flex-end;
        gap: 3px;
    }

    .position-grid-wrap[data-position-view="overview"] .mobile-line-kind {
        display: inline;
        margin: 0;
        color: var(--muted);
        font-size: 8px;
        font-weight: 750;
        text-transform: uppercase;
    }

    .position-grid-wrap[data-position-view="overview"] .mobile-line-expand {
        display: inline-grid;
        width: 32px;
        height: 32px;
        border-color: transparent;
        background: transparent;
    }

    .position-grid-wrap[data-position-view="overview"] .inline-line-actions {
        display: none;
    }

    .position-grid-wrap[data-position-view="overview"] .invoice-line-row.is-mobile-expanded {
        grid-template-rows: auto auto auto;
        row-gap: 8px;
        border-left-color: var(--brand);
        background: var(--paper-soft);
        box-shadow: inset 0 0 0 1px var(--border-strong);
    }

    .position-grid-wrap[data-position-view="overview"] .invoice-line-row.is-mobile-expanded > td:nth-child(2) {
        display: block;
        grid-column: 2;
        grid-row: 2;
    }

    .position-grid-wrap[data-position-view="overview"] .invoice-line-row.is-mobile-expanded > td:nth-child(4) {
        display: block;
        grid-column: 2 / 6;
        grid-row: 3;
    }

    .position-grid-wrap[data-position-view="overview"] .invoice-line-row.is-mobile-expanded > td:nth-child(7) {
        display: block;
        grid-column: 3;
        grid-row: 2;
    }

    .position-grid-wrap[data-position-view="overview"] .invoice-line-row.is-mobile-expanded > td:nth-child(2)::before,
    .position-grid-wrap[data-position-view="overview"] .invoice-line-row.is-mobile-expanded > td:nth-child(4)::before,
    .position-grid-wrap[data-position-view="overview"] .invoice-line-row.is-mobile-expanded > td:nth-child(7)::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 3px;
        color: var(--muted);
        font-size: 8px;
        font-weight: 750;
        text-transform: uppercase;
    }

    .position-grid-wrap[data-position-view="overview"] .invoice-line-row.is-mobile-expanded > td:nth-child(9) {
        grid-row: 1 / span 3;
        align-self: stretch;
        align-content: start;
        flex-direction: column;
    }

    .position-grid-wrap[data-position-view="overview"] .invoice-line-row.is-mobile-expanded .inline-line-actions {
        display: flex;
        align-items: center;
        flex-direction: column;
    }

    .position-grid-wrap[data-position-view="overview"] .invoice-line-row.is-mobile-expanded .mobile-line-expand svg,
    .position-grid-wrap[data-position-view="overview"] .invoice-line-row.is-mobile-expanded .mobile-line-expand img {
        transform: rotate(180deg);
    }

    .position-grid-wrap[data-position-view="overview"] .invoice-line-row.is-section,
    .position-grid-wrap[data-position-view="overview"] .invoice-line-row.is-text {
        min-height: 54px;
        border-left-color: var(--brand);
        background: var(--paper-soft);
    }

    .position-grid-wrap[data-position-view="overview"] .invoice-line-row.is-section > td:nth-child(3),
    .position-grid-wrap[data-position-view="overview"] .invoice-line-row.is-text > td:nth-child(3) {
        grid-column: 2 / 6;
    }

    .position-grid-wrap[data-position-view="overview"] .invoice-line-row.is-section > td:nth-child(5),
    .position-grid-wrap[data-position-view="overview"] .invoice-line-row.is-section > td:nth-child(6),
    .position-grid-wrap[data-position-view="overview"] .invoice-line-row.is-section > td:nth-child(8),
    .position-grid-wrap[data-position-view="overview"] .invoice-line-row.is-text > td:nth-child(5),
    .position-grid-wrap[data-position-view="overview"] .invoice-line-row.is-text > td:nth-child(6),
    .position-grid-wrap[data-position-view="overview"] .invoice-line-row.is-text > td:nth-child(8),
    .position-grid-wrap[data-position-view="overview"] .invoice-line-row.is-spacer > td:nth-child(5),
    .position-grid-wrap[data-position-view="overview"] .invoice-line-row.is-spacer > td:nth-child(6),
    .position-grid-wrap[data-position-view="overview"] .invoice-line-row.is-spacer > td:nth-child(8) {
        display: none;
    }

    .position-grid-wrap[data-position-view="overview"] .invoice-line-row.is-spacer {
        min-height: 38px;
    }

    .position-grid-wrap[data-position-view="overview"] .inline-line-title {
        min-height: 30px;
        padding: 3px 5px;
        font-size: 13px;
    }

    .position-grid-wrap[data-position-view="overview"] .line-rich-text {
        min-width: 0;
        background: var(--paper);
    }
}

@media (max-width: 720px) {
    .position-overview-tools {
        position: sticky;
        z-index: 12;
        top: 0;
        align-items: stretch;
        padding: 7px 8px;
        background: var(--paper);
    }

    .position-view-switch {
        display: none;
    }

    .position-filter-rail {
        width: 100%;
    }

    .position-filter-rail button {
        min-height: 38px;
        padding-inline: 10px;
    }

    .line-title-meta {
        display: grid;
        gap: 1px;
    }

    .line-item-category {
        max-width: min(58vw, 240px);
    }
}
