/* SPDX-License-Identifier: LicenseRef-PVIR-Proprietary */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
}

button {
    color: inherit;
}

@media screen {
    /* The viewport track is transparent over the same canvas as its screen. */
    html:has(>body>:is(.app-shell, .remote-login-gate)),
    html:has(>body.standalone-system-page) {
        background: var(--glass-canvas);
        background-color: var(--glass-login-opaque);
        background-attachment: fixed;
    }

    /* One scrollbar contract: transparent tracks and no WebKit arrow buttons. */
    :where(html, body,
        .remote-login-gate,
        :is(#app, #modalLayer, .remote-login-gate, .standalone-system-page) textarea,
        :is(#app, #modalLayer, .remote-login-gate, .standalone-system-page) [data-newsletter-editor],
        #app .sidebar .nav,
        :is(#app, #modalLayer) :is(.table-wrap, .product-results, .partner-results,
            .sr-picker-results, .selected-product-list),
        #modalLayer :is(.modal, .modal-body),
        #modalLayer .modal-backdrop:has(.document-editor-modal)) {
        scrollbar-width: thin;
        scrollbar-color: var(--glass-scrollbar-thumb) var(--glass-scrollbar-track);
    }

    :is(#app, #modalLayer, .remote-login-gate, .standalone-system-page) :is(input, select) {
        scrollbar-width: auto;
        scrollbar-color: initial;
    }

    @supports selector(::-webkit-scrollbar) {
        /* Chromium supports both APIs; auto keeps its WebKit geometry authoritative. */
        :where(html, body,
        .remote-login-gate,
        :is(#app, #modalLayer, .remote-login-gate, .standalone-system-page) textarea,
        :is(#app, #modalLayer, .remote-login-gate, .standalone-system-page) [data-newsletter-editor],
        #app .sidebar .nav,
        :is(#app, #modalLayer) :is(.table-wrap, .product-results, .partner-results,
            .sr-picker-results, .selected-product-list),
        #modalLayer :is(.modal, .modal-body),
        #modalLayer .modal-backdrop:has(.document-editor-modal)) {
            scrollbar-width: auto;
            scrollbar-color: initial;
        }

        :where(html, body,
        .remote-login-gate,
        :is(#app, #modalLayer, .remote-login-gate, .standalone-system-page) textarea,
        :is(#app, #modalLayer, .remote-login-gate, .standalone-system-page) [data-newsletter-editor],
        #app .sidebar .nav,
        :is(#app, #modalLayer) :is(.table-wrap, .product-results, .partner-results,
            .sr-picker-results, .selected-product-list),
        #modalLayer :is(.modal, .modal-body),
        #modalLayer .modal-backdrop:has(.document-editor-modal))::-webkit-scrollbar {
            width: var(--space-2);
            height: var(--space-2);
            background: var(--glass-scrollbar-track);
        }

        :where(html, body,
        .remote-login-gate,
        :is(#app, #modalLayer, .remote-login-gate, .standalone-system-page) textarea,
        :is(#app, #modalLayer, .remote-login-gate, .standalone-system-page) [data-newsletter-editor],
        #app .sidebar .nav,
        :is(#app, #modalLayer) :is(.table-wrap, .product-results, .partner-results,
            .sr-picker-results, .selected-product-list),
        #modalLayer :is(.modal, .modal-body),
        #modalLayer .modal-backdrop:has(.document-editor-modal))::-webkit-scrollbar-track,
        :where(html, body,
        .remote-login-gate,
        :is(#app, #modalLayer, .remote-login-gate, .standalone-system-page) textarea,
        :is(#app, #modalLayer, .remote-login-gate, .standalone-system-page) [data-newsletter-editor],
        #app .sidebar .nav,
        :is(#app, #modalLayer) :is(.table-wrap, .product-results, .partner-results,
            .sr-picker-results, .selected-product-list),
        #modalLayer :is(.modal, .modal-body),
        #modalLayer .modal-backdrop:has(.document-editor-modal))::-webkit-scrollbar-corner {
            background: var(--glass-scrollbar-track);
        }

        :where(html, body,
        .remote-login-gate,
        :is(#app, #modalLayer, .remote-login-gate, .standalone-system-page) textarea,
        :is(#app, #modalLayer, .remote-login-gate, .standalone-system-page) [data-newsletter-editor],
        #app .sidebar .nav,
        :is(#app, #modalLayer) :is(.table-wrap, .product-results, .partner-results,
            .sr-picker-results, .selected-product-list),
        #modalLayer :is(.modal, .modal-body),
        #modalLayer .modal-backdrop:has(.document-editor-modal))::-webkit-scrollbar-thumb {
            background-color: var(--glass-scrollbar-thumb);
            background-clip: padding-box;
            border: var(--border-strong-width) solid transparent;
            border-radius: var(--radius-pill);
        }

        :where(html, body,
        .remote-login-gate,
        :is(#app, #modalLayer, .remote-login-gate, .standalone-system-page) textarea,
        :is(#app, #modalLayer, .remote-login-gate, .standalone-system-page) [data-newsletter-editor],
        #app .sidebar .nav,
        :is(#app, #modalLayer) :is(.table-wrap, .product-results, .partner-results,
            .sr-picker-results, .selected-product-list),
        #modalLayer :is(.modal, .modal-body),
        #modalLayer .modal-backdrop:has(.document-editor-modal))::-webkit-scrollbar-button {
            display: none;
            width: 0;
            height: 0;
        }
    }

    .app-shell {
        display: grid;
        grid-template-columns: var(--sidebar-width) minmax(0,1fr);
        min-height: 100vh;
    }

    .sidebar {
        background: var(--graphite);
        color: var(--surface-pure);
        display: flex;
        flex-direction: column;
        min-height: 100vh;
        position: sticky;
        top: 0;
        height: 100vh;
        z-index: 40;
    }

    .brand-block {
        padding: var(--space-4) var(--space-4) var(--space-3);
        border-bottom: var(--border-width) solid var(--line-on-dark);
    }

    .brand-logo {
        display: block;
    }

    .brand-caption {
        text-transform: uppercase;
        letter-spacing: .16em;
        color: var(--text-on-dark-muted);
        margin-top: var(--space-1);
    }

    .nav {
        padding: var(--space-3) var(--space-2) var(--space-4);
        overflow: auto;
        flex: 1;
    }

    .nav-group {
        margin: 0 0 var(--space-3);
    }

    .nav-label {
        padding: var(--space-2) var(--space-3) var(--space-1);
        text-transform: uppercase;
        letter-spacing: .12em;
        color: var(--text-on-dark-subtle);
    }

    .nav-item {
        display: flex;
        align-items: center;
        gap: var(--space-2);
        width: 100%;
        text-align: left;
        cursor: pointer;
        margin: var(--space-1) 0;
    }

    .nav-icon {
        width: var(--nav-icon-width);
        text-align: center;
    }

    .account-button {
        display: flex;
        align-items: center;
        gap: var(--space-2);
        width: 100%;
        cursor: pointer;
        text-align: left;
    }

    .avatar {
        width: var(--avatar-size);
        height: var(--avatar-size);
        border-radius: var(--radius-circle);
        background: var(--yellow);
        display: grid;
        place-items: center;
        color: var(--ink-on-accent);
    }

    

    .account-copy b {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .workspace {
        min-width: 0;
    }

    .topbar {
        min-height: var(--topbar-height);
        height: auto;
        background: var(--surface-translucent);
        backdrop-filter: blur(var(--topbar-blur));
        border-bottom: var(--border-width) solid var(--line);
        display: flex;
        align-items: center;
        gap: var(--space-4);
        padding: var(--topbar-padding-block) var(--space-4);
        position: sticky;
        top: 0;
        z-index: 30;
    }

    .page-heading {
        min-width: var(--field-min-width);
        align-self: flex-start;
    }

    .page-heading #pageEyebrow {
        display: block;
        letter-spacing: .1em;
        text-transform: uppercase;
    }

    .page-heading h1 {
        margin: var(--space-1) 0 0;
    }

    .topbar-nav {
        display: flex;
        align-items: center;
        gap: var(--space-2);
        flex: 0 0 auto;
        min-width: 0;
    }

    .topbar-action {
        min-width: var(--control-height);
        justify-content: center;
        flex: 0 0 auto;
    }

    .topbar-icon {
        display: inline-grid;
        place-items: center;
        width: var(--nav-icon-width);
        height: var(--nav-icon-width);
        flex: 0 0 var(--nav-icon-width);
    }

    .topbar-icon svg {
        width: 100%;
        height: 100%;
    }

    .topbar-tools {
        margin-left: auto;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: var(--space-2);
        min-width: 0;
    }

    #globalCreateButton:not(.hidden) + #globalSearchButton {
        position: relative;
        margin-left: var(--space-4);
    }

    #globalCreateButton:not(.hidden) + #globalSearchButton::before {
        content: "";
        position: absolute;
        right: calc(100% + var(--space-3));
        height: var(--space-4);
        border-left: var(--border-width) solid var(--line);
        pointer-events: none;
    }

    .global-search {
        display: flex;
        align-items: center;
        gap: var(--space-2);
        min-width: 0;
        width: var(--search-min-width);
        flex: 0 1 var(--search-min-width);
    }

    .global-search input {
        width: 100%;
    }

    .content {
        padding: var(--space-4);
        max-width: var(--content-max-width);
        margin: 0 auto;
    }

    .mobile-only {
        display: none;
    }

    .panel-title {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .kpi-grid {
        display: grid;
        grid-template-columns: repeat(4,minmax(0,1fr));
        gap: var(--gap-panels);
        margin-bottom: var(--gap-panels);
    }

    .page-heading p {
        margin: var(--space-1) 0 0;
        color: var(--muted);
    }

    .kpi {
        padding: var(--space-3);
        background: var(--surface);
        border: var(--border-width) solid var(--line);
        border-radius: var(--radius);
    }

    .kpi span {
        display: block;
        text-transform: uppercase;
        letter-spacing: .08em;
    }

    .kpi strong {
        display: block;
        margin: var(--space-1) 0 var(--space-1);
        font-variant-numeric: tabular-nums;
    }

    .toolbar {
        display: flex;
        border-bottom: var(--border-width) solid var(--line);
        flex-wrap: wrap;
    }

    .toolbar .grow {
        flex: 1;
    }

    .search-input {
        position: relative;
        min-width: var(--field-min-width);
        flex: 1;
        max-width: var(--field-max-width);
    }

    .search-input input {
        width: 100%;
    }

    .table-wrap,
    [data-newsletter-editor] {
        overflow: auto;
    }

    .data-table {
        width: 100%;
        border-collapse: collapse;
        min-width: var(--table-min-width);
    }

    .data-table th {
        padding: var(--space-2);
        border-bottom: var(--border-width) solid var(--line);
        background: var(--surface-2);
        color: var(--muted);
        text-align: left;
        text-transform: uppercase;
        letter-spacing: .055em;
        white-space: normal;
    }

    .data-table td {
        padding: var(--space-2);
        border-bottom: var(--border-width) solid var(--line-soft);
        vertical-align: middle;
        overflow-wrap: anywhere;
    }

    .data-table tr:last-child td {
        border-bottom: 0;
    }

    

    .cell-sub {
        display: block;
        margin-top: var(--space-1);
    }

    .row-actions {
        justify-content: flex-end;
        white-space: nowrap;
    }

    .badge {
        display: inline-flex;
        align-items: center;
        border-radius: var(--radius-pill);
        padding: var(--space-1) var(--space-2);
        white-space: nowrap;
    }

    .badge.ok {
        background: var(--ok-bg);
        color: var(--ok);
    }

    .badge.warn {
        background: var(--warn-bg);
        color: var(--warn);
    }

    .badge.bad {
        background: var(--bad-bg);
        color: var(--bad);
    }

    .badge.info {
        background: var(--info-bg);
        color: var(--info);
    }

    .badge.muted {
        background: var(--surface-3);
        color: var(--text-subtle);
    }

    .empty {
        padding: var(--space-8);
        text-align: center;
    }

    .stack-list {
        display: flex;
        flex-direction: column;
    }

    .stack-row {
        display: flex;
        gap: var(--space-3);
        align-items: center;
        border-bottom: var(--border-width) solid var(--line);
    }

    .stack-row:last-child {
        border-bottom: 0;
    }

    .stack-row .grow {
        flex: 1;
    }

    .stack-row small {
        display: block;
        margin-top: var(--space-1);
    }

    .progress {
        height: var(--progress-height);
        border-radius: var(--radius-pill);
        background: var(--surface-3);
        overflow: hidden;
    }

    .progress>span {
        display: block;
        height: 100%;
        background: var(--yellow);
    }

    .modal-layer {
        position: fixed;
        inset: 0;
        z-index: 100;
        pointer-events: none;
    }

    .modal-layer.open {
        pointer-events: auto;
    }

    .modal-backdrop {
        position: absolute;
        inset: 0;
        display: grid;
        place-items: center;
    }

    .modal-head {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        position: sticky;
        top: 0;
        z-index: 3;
    }

    .modal-head :is(h3,div) {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .modal-foot {
        display: flex;
        justify-content: flex-end;
        position: sticky;
        bottom: 0;
        z-index: 3;
    }

    

    .type-card {
        cursor: pointer;
        text-align: left;
    }

    .type-card b {
        display: block;
        margin-bottom: var(--space-1);
    }

    .form-grid {
        display: grid;
        grid-template-columns: repeat(4,minmax(0,1fr));
    }

    .field.span-2,
    .form-grid>.span-2 {
        grid-column: span 2;
    }

    .field.span-3,
    .form-grid>.span-3 {
        grid-column: span 3;
    }

    .field.span-4,
    .form-grid>.span-4 {
        grid-column: 1/-1;
    }

    .field label {
        display: block;
    }

    .field input,
    .field select,
    .field textarea,
    .field [data-newsletter-editor] {
        width: 100%;
    }

    .editor-grid {
        display: grid;
        grid-template-columns: minmax(0,1fr) var(--document-summary-width);
        gap: var(--space-3);
    }

    .editor-main {
        min-width: 0;
        display: flex;
        flex-direction: column;
        gap: var(--space-3);
    }

    .editor-section {
        border: var(--border-width) solid var(--line);
        border-radius: var(--control-radius);
        padding: var(--space-3);
    }

    .editor-section-title {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: var(--space-3);
        margin-bottom: var(--gap-title);
    }

    .editor-section-title h4 {
        margin: 0;
    }

    .summary-card {
        position: sticky;
        top: calc(var(--topbar-height) + var(--border-width));
        align-self: start;
        border: var(--border-width) solid var(--line);
        background: var(--surface-2);
        border-radius: var(--control-radius);
        padding: var(--space-3);
    }

    .summary-line {
        display: flex;
        justify-content: space-between;
        gap: var(--space-2);
        padding: var(--space-2) 0;
    }

    .summary-line.total {
        border-top: var(--border-width) solid var(--line);
        margin-top: var(--space-1);
        padding-top: var(--space-3);
    }

    .product-results,
    .partner-results {
        position: fixed;
        z-index: 120;
        border: var(--border-width) solid var(--line);
        border-radius: var(--control-radius);
        background: var(--surface-pure);
        box-shadow: var(--shadow);
        max-height: var(--result-list-max-height);
        overflow: auto;
        margin: 0;
    }

    .result-button {
        width: 100%;
        display: flex;
        justify-content: space-between;
        text-align: left;
        cursor: pointer;
        overflow-wrap: anywhere;
    }

    .result-button small {
        display: block;
        text-align: left;
    }

    .toast-layer {
        position: fixed;
        right: var(--space-4);
        bottom: var(--space-4);
        z-index: 200;
        display: flex;
        flex-direction: column;
        gap: var(--space-2);
    }

    .toast {
        background: var(--surface-dark-2);
        color: var(--surface-pure);
        border-radius: var(--control-radius);
        padding: var(--space-2) var(--space-3);
        box-shadow: var(--shadow);
    }

    .toast.ok {
        border-left: var(--status-border-width) solid var(--yellow);
    }

    .toast.bad {
        border-left: var(--status-border-width) solid var(--bad);
    }

    

    .two-col {
        display: grid;
        grid-template-columns: minmax(0,1fr) minmax(var(--panel-side-min-width),.65fr);
        gap: var(--space-3);
    }

    .callout {
        border: var(--border-width) solid var(--accent-border);
        background: var(--accent-surface);
        border-radius: var(--control-radius);
        padding: var(--space-2) var(--space-3);
    }

    .danger-text {
        color: var(--bad);
    }

    .ok-text {
        color: var(--ok);
    }

    .muted {
        color: var(--muted);
    }

    .hidden {
        display: none !important;
    }

    @media(max-width:1100px) {
        .app-shell {
            grid-template-columns: var(--field-min-width) minmax(0,1fr);
        }

        .kpi-grid {
            grid-template-columns: repeat(2,1fr);
        }

        .two-col,
        .editor-grid {
            grid-template-columns: 1fr;
        }

        .summary-card {
            position: static;
        }

        .form-grid {
            grid-template-columns: repeat(2,1fr);
        }
    }

    @media(max-width:760px) {
        .editor-section-title {
            flex-wrap: wrap;
        }

        .editor-section-title>.actions {
            flex-basis: 100%;
            justify-content: flex-start;
        }

        .app-shell {
            display: block;
        }

        .sidebar {
            position: fixed;
            left: 0;
            top: 0;
            width: var(--sidebar-drawer-width);
            transform: translateX(-102%);
            transition: transform .18s ease;
            box-shadow: var(--sidebar-shadow);
        }

        .sidebar.open {
            transform: none;
        }

        .mobile-only {
            display: inline-grid;
            place-items: center;
        }

        .topbar {
            height: auto;
            min-height: var(--topbar-height);
            flex-wrap: wrap;
            padding: var(--topbar-padding-block) var(--space-3);
        }

        .page-heading {
            min-width: 0;
        }

        .topbar-tools {
            width: 100%;
            margin: 0;
        }

        .global-search {
            min-width: 0;
            flex: 1;
        }

        .content {
            padding: var(--space-3);
        }

        .page-head {
            flex-direction: column;
        }

        .kpi-grid {
            grid-template-columns: 1fr 1fr;
        }

        

        

        .form-grid {
            grid-template-columns: 1fr;
        }

        .field.span-2,
        .field.span-3,
        .field.span-4,
        .form-grid>.span-2,
        .form-grid>.span-3,
        .form-grid>.span-4 {
            grid-column: auto;
        }

        .modal-backdrop {
            align-items: end;
        }

        .modal-foot {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            grid-auto-rows: 1fr;
        }

    }

    @media(max-width:480px) {
        .global-search {
            display: none;
        }

        .topbar-tools {
            width: auto;
            margin-left: auto;
        }

        .kpi-grid {
            grid-template-columns: 1fr;
        }

        .content {
            padding: var(--space-2);
        }
    }

    .inline-input-action {
        display: flex;
        gap: var(--space-1);
        align-items: flex-start;
    }

    .inline-input-action input {
        flex: 1;
    }

    .field-hint {
        margin-top: var(--space-1);
    }

    .comment-template-row {
        display: flex;
        gap: var(--space-2);
        margin-bottom: var(--space-2);
    }

    .comment-template-row select {
        flex: 1;
    }

    .terms-editor {
        min-height: var(--textarea-long-min-height) !important;
    }

    

    body.modal-open {
        overflow: hidden;
        overscroll-behavior: none;
    }

    .modal-backdrop {
        overscroll-behavior: contain;
    }

    .modal {
        overscroll-behavior: contain;
        scrollbar-gutter: auto;
    }

    .modal-body,
    .editor-section {
        min-width: 0;
    }

    

    .doc-line {
        display: grid;
        border: var(--border-width) solid var(--line);
        border-radius: var(--control-radius);
        background: var(--surface-pure);
        transition: border-color .12s,box-shadow .12s,opacity .12s;
    }

    .doc-line:hover {
        border-color: var(--line-strong);
    }

    .doc-line.dragging {
        opacity: .55;
        box-shadow: var(--shadow);
    }

    .doc-line.drag-over {
        border-color: var(--yellow-dark);
        box-shadow: var(--focus-shadow);
    }

    .line-drag {
        align-self: stretch;
        display: grid;
        place-items: center;
        user-select: none;
    }

    .line-field {
        min-width: 0;
    }

    .line-field label {
        display: block;
        margin: 0 0 var(--space-1);
    }

    .line-field input,
    .line-field select,
    .line-field textarea {
        width: 100%;
    }

    .line-main textarea {
        resize: vertical;
        margin-top: var(--space-1);
    }

    .line-total {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        min-height: var(--control-height);
        height: var(--control-height);
        white-space: nowrap;
        padding: 0 var(--control-padding);
        border: var(--border-width) solid var(--line);
        border-radius: var(--control-radius);
        background: var(--surface-2);
        text-align: right;
    }

    .line-remove {
        align-self: center;
    }

    .line-product-meta {
        display: flex;
        gap: var(--space-1);
        flex-wrap: wrap;
        margin-bottom: var(--space-1);
    }

    .preview-layer {
        position: fixed;
        inset: 0;
        z-index: 180;
        display: grid;
        place-items: center;
    }

    .preview-shell {
        height: min(94vh,var(--preview-max-height));
        display: flex;
        flex-direction: column;
}

    .preview-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex: 0 0 auto;
    }

    .preview-head h3 {
        margin: 0;
    }

    .preview-actions {
        display: flex;
    }

    .preview-frame {
        border: 0;
        width: 100%;
        height: 100%;
        background: var(--line-strong);
        flex: 1;
    }

    @media(max-width:900px) {
        .preview-shell {
            height: 97vh;
        }
    }

    .modal.wide,
    .modal-body {
        overflow-x: hidden;
    }

    .doc-lines {
        min-width: 0;
    }

    .editor-section>.doc-lines {
        margin-top: var(--gap-fields);
    }

    .doc-line {
        min-width: 0;
        overflow: hidden;
    }

    .doc-line input,
    .doc-line select,
    .doc-line textarea {
        max-width: 100%;
    }

    .line-main {
        min-width: 0;
    }

    .line-main input,
    .line-main textarea {
        overflow-wrap: anywhere;
    }

    .line-product-meta {
        min-width: 0;
    }

    .layout-hint {
        margin: 0 0 var(--space-2);
    }

    .doc-line.offer-group-header {
        padding-left: calc(var(--space-3) + var(--border-width) - var(--status-border-width));
        border-color: var(--line-strong);
        border-left: var(--status-border-width) solid var(--yellow);
        background: var(--accent-gradient);
    }

    .doc-line.offer-group-header>.offer-group-title {
        align-self: end;
    }

    .preview-shell,
    .preview-frame {
        min-width: 0;
    }

    @media(max-width:900px) {
        .doc-line {
            overflow: visible;
        }

        .line-total {
            white-space: normal;
            overflow-wrap: anywhere;
        }
    }

    @media(max-width:600px) {
        .doc-line.offer-group-header {
            padding-left: calc(var(--space-2) + var(--border-width) - var(--status-border-width));
        }

        .preview-actions {
            flex-wrap: wrap;
            justify-content: flex-end;
        }

        .preview-head {
            align-items: flex-start;
        }
    }

    .line-note-toggle {
        display: inline-flex;
        align-items: center;
        margin-top: var(--space-1);
        cursor: pointer;
    }

    .line-note-toggle:hover {
        text-decoration: underline;
    }

    .comment-template-row {
        align-items: center;
        flex-wrap: wrap;
    }

    .offer-group-header+.doc-line {
        border-top-left-radius: var(--radius-sm);
        border-top-right-radius: var(--radius-sm);
    }

    @media(max-width:760px) {
        .page-head .actions {
            width: 100%;
            overflow: visible;
            flex-wrap: wrap;
        }

        .page-head .actions .button {
            flex: 0 1 auto;
            min-width: 0;
        }

        .preview-actions {
            min-width: 0;
        }
    }

    @media(max-width:760px) {
        .document-list-table td {
            border: 0 !important;
        }

        .document-list-table td[data-col="document"] {
            grid-column: 1;
            grid-row: 1;
        }

        .document-list-table td[data-col="status"] {
            grid-column: 2;
            grid-row: 1;
            justify-self: end;
        }

        .document-list-table td[data-col="partner"] {
            grid-column: 1/-1;
            grid-row: 2;
            padding-top: var(--space-1) !important;
            border-top: var(--border-width) solid var(--line-soft) !important;
        }

        .document-list-table td[data-col="date"] {
            grid-column: 1;
            grid-row: 3;
        }

        .document-list-table td[data-col="owner"] {
            grid-column: 2;
            grid-row: 3;
            text-align: right;
        }

        .document-list-table td[data-col="net"] {
            grid-column: 1;
            grid-row: 5;
            text-align: left !important;
            align-self: center;
        }

        .document-list-table td[data-col="actions"] {
            grid-column: 2;
            grid-row: 5;
            justify-self: end;
        }

        .document-list-table td[data-col="email"] {
            grid-column: 1/-1;
            grid-row: 4;
        }

        .document-list-table .row-actions {
            white-space: normal;
            flex-wrap: wrap;
            justify-content: flex-end;
        }

        .document-list-table .status-select {
            max-width: var(--status-control-compact-width);
        }
    }

    .remote-auth-hidden {
        display: none !important;
    }

    .remote-login-gate {
        position: fixed;
        inset: 0;
        z-index: 1000;
        display: grid;
        place-items: center;
        padding: var(--space-6);
        background: var(--login-gradient);
        overflow-y: auto;
        overflow-x: hidden;
    }

    .remote-login-card {
        width: min(var(--dialog-small),100%);
        background: var(--surface);
        border: var(--border-width) solid var(--line-on-dark);
        border-top: var(--status-border-width) solid var(--yellow);
        border-radius: var(--radius-lg);
        box-shadow: var(--login-shadow);
        padding: var(--space-6);
        display: flex;
        flex-direction: column;
        gap: var(--space-4);
    }

    .remote-login-logo {
        margin-bottom: var(--space-1);
    }

    .remote-login-copy span {
        display: block;
        letter-spacing: .12em;
    }

    .remote-login-copy h1 {
        margin: var(--space-1) 0 var(--space-2);
    }

    .remote-login-copy p {
        margin: 0;
    }

    .remote-login-field span {
        display: block;
        margin-bottom: var(--space-1);
    }

    .remote-login-field input {
        width: 100%;
    }

    .remote-login-submit {
        width: 100%;
        margin-top: var(--space-1);
    }

    @media(max-width:520px) {
        .remote-login-gate {
            padding: var(--space-4);
            overflow-y: auto;
            overflow-x: hidden;
        }

        .remote-login-card {
            padding: var(--space-6);
        }
    }

    .permission-group {
        border: var(--border-width) solid var(--line);
        border-radius: var(--radius);
        background: var(--surface-on-dark-soft);
    }

    .permission-group-title {
        display: flex;
        justify-content: space-between;
        gap: var(--space-3);
    }

    .permission-group-title small {
        color: var(--muted);
    }

    .permission-grid {
        display: grid;
        grid-template-columns: repeat(2,minmax(0,1fr));
    }

    .permission-item {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: var(--space-3);
        border: var(--border-width) solid var(--line-soft);
        border-radius: var(--control-radius);
        background: var(--surface-pure);
    }

    

    .permission-item small {
        white-space: normal;
    }

    

    @media (max-width:900px) {
        .permission-grid {
            grid-template-columns: 1fr;
        }

        .permission-group-title {
            display: block;
        }

        .permission-item {
            align-items: flex-start;
            flex-direction: column;
        }

        .permission-item select {
            max-width: none;
        }
    }

    .review-build-label {
        display: block;
        color: var(--line-strong);
        padding: var(--space-1) var(--space-3) var(--space-3);
    }

    .document-filter-row {
        display: grid;
        grid-template-columns: minmax(0,1fr) minmax(0,2fr) minmax(0,1fr) auto;
        padding: 0 var(--space-4) var(--space-4);
    }

    .document-filter-row input,
    .document-filter-row select {
        width: 100%;
    }

    @media screen and (min-width:901px) {
        .document-filter-row:has(>.split-grid):has(>.button:nth-child(3):last-child) {
            grid-template-columns: minmax(0,1fr) minmax(0,2fr) auto;
        }
    }

    @media screen and (max-width:900px) {
        .document-filter-row {
            grid-template-columns: repeat(2,minmax(0,1fr));
        }

        .document-filter-row>.button {
            grid-column: 1/-1;
            justify-self: start;
        }
    }

    @media screen and (max-width:600px) {
        .document-filter-row {
            grid-template-columns: minmax(0,1fr);
            padding: 0 var(--space-3) var(--space-4);
        }

        .document-filter-row>.button {
            width: 100%;
            justify-self: stretch;
        }
    }

    .line-source {
        flex-wrap: wrap;
    }

    .line-source small {
        display: block;
        margin-left: var(--source-label-offset);
    }

    @media(max-width:780px) {
        .line-source {
            display: block;
        }

        .line-source label,
        .line-source select,
        .line-source small {
            display: block;
            width: 100%;
            margin: var(--space-1) 0;
        }

        .line-source select {
            min-width: 0;
        }
    }

    .modal-backdrop:has(.document-editor-modal) {
        align-items: start;
        justify-items: center;
        overflow-y: auto;
        scrollbar-gutter: auto;
    }

    .document-editor-modal {
        height: min(94vh,var(--editor-max-height));
        max-height: min(94vh,var(--editor-max-height));
    }

    .document-editor-modal>.modal-body {
        overflow-x: hidden;
        scrollbar-gutter: auto;
    }

    .document-editor-modal .summary-card {
        top: 0;
    }

    @media(max-width:760px) {
        .modal-backdrop:has(.document-editor-modal) {
            align-items: end;
            overflow: hidden;
        }

        .document-editor-modal {
            height: 96vh;
            max-height: 96vh;
        }
    }

    .panel,
    .split-grid>* {
        min-width: 0;
    }

    .table-wrap {
        min-width: 0;
        max-width: 100%;
    }

    .link-button {
        display: inline-flex;
        cursor: pointer;
        text-decoration: underline;
        text-underline-offset: var(--focus-offset);
    }

    .table-wrap:has(> :is(.credit-table,.document-items,.report-detail-table)) {
        container-type: inline-size;
        container-name: table-view;
    }

    @media(max-width:760px) {
        .responsive-card-table {
            display: block;
            min-width: 0 !important;
            width: 100%;
        }

        .responsive-card-table thead {
            display: none;
        }

        .responsive-card-table colgroup {
            display: none;
        }

        .responsive-card-table tbody {
            display: grid;
            gap: var(--space-2);
        }

        

        .responsive-card-table tr {
            display: block;
            padding: var(--space-2) var(--space-3);
            border: var(--border-width) solid var(--line);
            border-radius: var(--control-radius);
            background: var(--glass-inner-surface);
            min-width: 0;
        }

        .responsive-card-table td {
            display: grid;
            grid-template-columns: minmax(var(--column-short-width),38%) minmax(0,1fr);
            gap: var(--space-2);
            padding: var(--space-2) 0 !important;
            border: 0 !important;
            border-bottom: var(--border-width) solid var(--line-soft) !important;
            min-width: 0;
            text-align: right !important;
            white-space: normal;
            overflow-wrap: anywhere;
        }

        .responsive-card-table td:last-child {
            border-bottom: 0 !important;
            padding-bottom: 0 !important;
        }

        .responsive-card-table td::before {
            letter-spacing: .045em;
            text-transform: uppercase;
            text-align: left;
        }

        .responsive-card-table td[data-label]::before {
            content: attr(data-label);
        }

        .responsive-card-table td>.primary-cell {
            align-items: flex-end;
            text-align: right;
            min-width: 0;
        }

        .responsive-card-table td>.row-actions {
            justify-content: flex-end;
            flex-wrap: wrap;
            min-width: 0;
            max-width: 100%;
        }

        .responsive-card-table td>.status-select {
            justify-self: end;
            max-width: 100%;
        }

        .responsive-card-table td>.badge,
        .responsive-card-table td>.button,
        .responsive-card-table td>.link-button {
            justify-self: end;
        }

        .responsive-card-table td:empty {
            display: none;
        }
    }

    @container table-view (max-width:760px) {
        .responsive-card-table {
            display: block;
            min-width: 0 !important;
            width: 100%;
        }

        .responsive-card-table thead {
            display: none;
        }

        .responsive-card-table colgroup {
            display: none;
        }

        .responsive-card-table tbody {
            display: grid;
            gap: var(--space-2);
        }

        

        .responsive-card-table tr {
            display: block;
            padding: var(--space-2) var(--space-3);
            border: var(--border-width) solid var(--line);
            border-radius: var(--control-radius);
            background: var(--glass-inner-surface);
            min-width: 0;
        }

        .responsive-card-table td {
            display: grid;
            grid-template-columns: minmax(var(--column-short-width),38%) minmax(0,1fr);
            gap: var(--space-2);
            padding: var(--space-2) 0 !important;
            border: 0 !important;
            border-bottom: var(--border-width) solid var(--line-soft) !important;
            min-width: 0;
            text-align: right !important;
            white-space: normal;
            overflow-wrap: anywhere;
        }

        .responsive-card-table td:last-child {
            border-bottom: 0 !important;
            padding-bottom: 0 !important;
        }

        .responsive-card-table td::before {
            letter-spacing: .045em;
            text-transform: uppercase;
            text-align: left;
        }

        .responsive-card-table td[data-label]::before {
            content: attr(data-label);
        }

        .responsive-card-table td>.primary-cell {
            align-items: flex-end;
            text-align: right;
            min-width: 0;
        }

        .responsive-card-table td>.row-actions {
            justify-content: flex-end;
            flex-wrap: wrap;
            min-width: 0;
            max-width: 100%;
        }

        .responsive-card-table td>.status-select {
            justify-self: end;
            max-width: 100%;
        }

        .responsive-card-table td>.badge,
        .responsive-card-table td>.button,
        .responsive-card-table td>.link-button {
            justify-self: end;
        }

        .responsive-card-table td:empty {
            display: none;
        }
    }

    .runtime-mode-banner {
        margin: 0 var(--space-4);
        padding: var(--space-3) var(--space-3);
        border: var(--border-width) solid var(--accent-border);
        border-radius: var(--control-radius);
        background: var(--accent-soft);
        color: var(--accent-strong);
        overflow-wrap: anywhere;
    }

    .runtime-mode-banner[hidden] {
        display: none;
    }

    @media(max-width:760px) {
        .runtime-mode-banner {
            margin: 0 var(--space-2);
        }
    }

    .toolbar {
        margin-top: var(--space-2);
        margin-bottom: var(--space-3);
    }

    .document-filter-row {
        margin-top: var(--space-3) !important;
        padding-top: var(--space-3) !important;
        border-top: var(--border-width) solid var(--line-soft);
    }

    .pager,
    .page-controls {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: var(--space-3);
        flex-wrap: wrap;
    }

    .pager .button,
    .pagination .button,
    .page-controls .button {
        margin: 0 !important;
    }

    .pager-info,
    .page-indicator {
        padding: 0 var(--space-2);
        white-space: nowrap;
    }

    .chart-grid {
        display: grid;
        grid-template-columns: repeat(2,minmax(0,1fr));
        margin: 0 0 var(--gap-panels);
    }

    .chart-card {
        min-width: 0;
        overflow: hidden;
        container-type: inline-size;
        container-name: chart-view;
    }

    /* The owner's dashboard reference uses two annual ring charts. */
    .donut-layout {
        display: grid;
        grid-template-columns: minmax(0,1fr) minmax(0,2fr);
        align-items: center;
        gap: var(--gap-panels);
        min-height: var(--chart-height);
    }

    .donut-ring {
        display: block;
        width: 100%;
        max-width: var(--chart-height);
        aspect-ratio: 1;
    }

    .donut-track {
        fill: var(--line);
    }

    .donut-tone-0 {
        fill: var(--ok);
    }

    .donut-tone-1 {
        fill: var(--accent);
    }

    .donut-tone-2 {
        fill: var(--bad);
    }

    .donut-tone-3 { fill: var(--info); }
    .donut-tone-4 { fill: var(--graphite); }
    .donut-tone-5 { fill: var(--accent-strong); }
    .donut-tone-6 { fill: var(--muted); }
    .donut-tone-7 { fill: var(--accent-border); }
    .donut-tone-8 { fill: var(--warn); }
    .donut-tone-9 { fill: var(--text-on-dark-subtle); }
    .donut-tone-10 { fill: var(--accent-hover); }
    .donut-tone-11 { fill: var(--line-strong); }

    .donut-summary {
        min-width: 0;
    }

    .donut-summary p {
        margin-block: var(--space-3);
    }

    .donut-legend {
        display: grid;
        gap: var(--gap-fields);
    }

    .donut-legend-row {
        display: grid;
        grid-template-columns: auto minmax(0,1fr) auto;
        align-items: center;
        gap: var(--gap-label);
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .donut-swatch {
        width: var(--space-4);
        height: var(--space-4);
        border-radius: var(--control-radius);
    }

    @container chart-view (max-width:560px) {
        .donut-layout {
            grid-template-columns: 1fr;
        }

        .donut-ring {
            margin-inline: auto;
            max-width: var(--chart-height-compact);
        }

        .donut-legend-row {
            grid-template-columns: auto minmax(0,1fr);
            align-items: start;
        }

        .donut-legend-row>b {
            grid-column: 2;
            white-space: normal;
            overflow-wrap: anywhere;
        }
    }

    .chart-svg {
        display: block;
        width: 100%;
        height: var(--chart-height);
        max-height: var(--chart-height);
        min-width: 0;
    }

    .chart-axis {
        stroke: var(--line);
        stroke-width: 1;
        stroke-dasharray: 3 5;
    }

    .chart-line {
        stroke: var(--graphite);
        stroke-width: 3;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .chart-dot {
        fill: var(--accent);
        stroke: var(--graphite);
        stroke-width: 1.5;
    }

    .chart-bar {
        fill: var(--accent);
    }

    .chart-label {
        fill: var(--muted);
    }

    .chart-value {
        fill: var(--ink);
    }

    .chart-empty {
        min-height: var(--chart-empty-min-height);
        display: grid;
        place-items: center;
    }

    @media(max-width:900px) {
        .chart-grid {
            grid-template-columns: 1fr;
        }
    }

    @media(max-width:560px) {
        .chart-svg {
            height: var(--chart-height-compact);
        }

        .chart-card {
            overflow: hidden;
        }
    }

    .empty.compact {
        padding: var(--space-3);
    }

    .comment-print-toggle {
        margin: 0 0 var(--space-2) !important;
        padding: var(--space-2) 0;
    }

    .chart-card .panel-title small {
        display: block;
        margin-top: var(--space-2);
    }

    .chart-data>summary {
        cursor: pointer;
        padding: var(--space-3) 0;
    }

    .document-link {
        color: var(--accent-strong);
        text-decoration: underline;
        text-underline-offset: var(--focus-offset);
        background: none;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        padding: 0;
        display: inline;
    }

    .document-link:hover {
        color: var(--ink-on-accent);
        text-decoration-thickness: var(--border-strong-width);
    }

    .document-link:focus-visible {
        outline: var(--focus-width) solid var(--accent-strong);
        outline-offset: var(--focus-offset);
    }

    .chart-data {
        margin-top: var(--space-2);
    }

    .chart-bar.is-negative {
        fill: var(--bad);
    }

    .badge:not(.ok):not(.warn):not(.bad):not(.info):not(.muted) {
        background: var(--accent-soft);
        color: var(--accent-strong);
    }

    .document-logo-placeholder {
        display: flex;
        flex-direction: column;
        gap: var(--space-1);
        padding: var(--space-1);
    }

    .document-logo-placeholder small {
        color: var(--muted);
    }

    .brand-logo {
        width: auto;
        max-width: 100%;
        height: var(--brand-logo-height);
        max-height: var(--brand-logo-height);
        object-fit: contain;
        object-position: left center;
    }

    .remote-login-logo {
        width: auto;
        max-width: var(--field-wide-min-width);
        height: var(--remote-logo-height);
        max-height: var(--remote-logo-height);
        object-fit: contain;
        object-position: left center;
    }

    .preview-actions {
        gap: var(--space-2);
    }

    .panel-pad {
        padding: var(--panel-padding);
    }

    .panel-title {
        margin-bottom: var(--space-3);
    }

    .stack-row {
        padding: var(--space-3) var(--space-3);
    }

    @media(max-width:760px) {
        .brand-logo {
            height: var(--brand-logo-height-compact);
            max-height: var(--brand-logo-height-compact);
        }
    }

    .link-button {
        align-items: center;
    }

    .permission-group {
        padding: var(--space-3) var(--space-3);
        margin-bottom: var(--space-2);
    }

    .permission-group-title {
        margin-bottom: var(--space-2);
    }

    .permission-grid {
        gap: var(--space-2);
    }

    .permission-item {
        min-height: calc(var(--control-height) + var(--space-2));
        padding: var(--space-2) var(--space-2);
    }

    .document-editor-modal>.modal-foot {
        min-height: calc(var(--control-height) + var(--space-4));
    }

    .remote-login-secret {
        word-break: break-all;
        margin-top: var(--space-2);
    }

    .doc-line {
        position: relative;
        grid-template-columns: var(--control-height) repeat(4,minmax(0,1fr));
        align-items: start;
        gap: var(--space-3) var(--space-3);
        padding: var(--space-3);
    }

    .doc-line>.line-drag {
        grid-column: 1;
        grid-row: 1;
        align-self: stretch;
    }

    .doc-line>.line-main {
        grid-column: 2/-1;
        grid-row: 1;
        display: grid;
        grid-template-columns: minmax(0,2fr) minmax(var(--field-min-width),1fr);
        gap: var(--space-1) var(--space-4);
        align-self: start;
        grid-template-rows: auto auto auto auto;
        row-gap: 0;
    }

    .line-main>.field {
        display: grid;
        grid-template-rows: subgrid;
        grid-row: 1 / span 4;
        row-gap: 0;
        align-content: start;
    }

    .line-main>.field>label {
        grid-row: 1;
        margin-bottom: var(--gap-label);
    }

    .line-main>.field>.line-product-meta {
        grid-row: 2;
    }

    .line-main>.field>:is(input, select, .badge) {
        grid-row: 3;
        align-self: start;
    }

    .line-main>.field>:is(.actions, details, .line-note, small) {
        grid-row: 4;
        margin-top: var(--gap-label);
    }

    .line-main>label,
    .line-main>.line-product-meta,
    .line-main>input {
        grid-column: 1;
    }

    .line-main>.line-source {
        grid-column: 2;
        grid-row: 1 / span 4;
        align-self: stretch;
        margin: 0;
        grid-template-columns: minmax(0,1fr);
        grid-template-rows: subgrid;
    }

    .line-main>.line-source small {
        grid-column: 1;
    }

    .line-main>.line-note,
    .line-main>.line-note-toggle,
    .line-main>small {
        grid-column: 1/-1;
    }

    .line-main>.line-note {
        margin-top: var(--space-1);
    }

    .line-main>.line-note-toggle {
        justify-self: start;
    }

    .doc-line>.line-quantity {
        grid-column: 2;
        grid-row: 2;
    }

    .doc-line>.line-unit {
        grid-column: 3;
        grid-row: 2;
    }

    .doc-line>.line-price {
        grid-column: 4;
        grid-row: 2;
    }

    .doc-line>.line-vat {
        grid-column: 5;
        grid-row: 2;
    }

    .doc-line>.line-secondary {
        grid-column: 2 / -1;
        grid-row: 3;
        display: grid;
        grid-template-columns: repeat(4,minmax(0,1fr));
        gap: var(--space-3);
        align-items: end;
    }

    .doc-line>.line-remove {
        grid-column: 1;
        grid-row: 3;
        align-self: end;
        justify-self: center;
    }

    .line-discount-controls {
        display: grid;
        grid-template-columns: minmax(0,1fr) minmax(var(--column-unit-width),.72fr);
        gap: var(--space-1);
        align-items: end;
    }

    .line-discount-controls>select,
    .line-discount-controls>input {
        min-width: 0;
        width: 100%;
    }

    .line-source {
        display: grid;
        grid-template-columns: var(--column-short-width) minmax(0,1fr);
        gap: var(--space-2) var(--space-2);
        align-items: center;
        margin-top: var(--space-2);
    }

    .line-source label {
        min-width: 0;
        margin: 0;
    }

    .line-source select {
        min-width: 0;
        width: 100%;
        max-width: none;
    }

    .line-source small {
        grid-column: 2;
        margin: 0;
        width: auto;
    }

    .toast-layer {
        max-width: min(var(--toast-max-width),calc(100vw - var(--space-6)));
    }

    .toast {
        max-width: 100%;
        overflow-wrap: anywhere;
    }

    @media(max-width:1250px) {
        .doc-line {
            grid-template-columns: var(--control-height) repeat(4,minmax(0,1fr));
        }
    }

    @media(max-width:900px) {
        .doc-line {
            grid-template-columns: var(--control-height) repeat(2,minmax(0,1fr));
            align-items: start;
        }

        .doc-line>.line-main {
            grid-column: 2/-1;
            grid-row: 1;
            grid-template-columns: minmax(0,1fr);
        }

        .line-main>.line-source {
            grid-column: 1;
            grid-row: auto;
            margin-top: var(--space-1);
            display: flex;
            flex-direction: column;
            gap: var(--gap-label);
        }

        .doc-line>.line-quantity,
        .doc-line>.line-price {
            grid-column: 2;
        }

        .doc-line>.line-unit,
        .doc-line>.line-vat {
            grid-column: 3;
        }

        .doc-line>.line-price,
        .doc-line>.line-vat {
            grid-row: 3;
        }

        .doc-line>.line-secondary {
            grid-column: 2/-1;
            grid-row: 4;
            grid-template-columns: repeat(2,minmax(0,1fr));
        }

        .doc-line>.line-remove {
            grid-column: 1;
            grid-row: 4;
            align-self: end;
        }

        .line-source {
            grid-template-columns: 1fr;
        }

        .line-source small {
            grid-column: 1;
        }
    }

    @media(max-width:600px) {
        .doc-line {
            grid-template-columns: var(--control-height) repeat(2,minmax(0,1fr));
            padding: var(--space-2);
            gap: var(--space-3) var(--space-2);
        }

        .doc-line>.line-main,
        .doc-line>.line-secondary {
            grid-column: 2/-1;
        }

        .doc-line>.line-quantity,
        .doc-line>.line-price {
            grid-column: 2;
        }

        .doc-line>.line-unit,
        .doc-line>.line-vat {
            grid-column: 3;
        }

        .doc-line>.line-secondary {
            grid-template-columns: 1fr;
        }

        .doc-line>.line-remove {
            grid-column: 3;
            grid-row: 5;
            justify-self: end;
        }

        .line-discount-controls {
            grid-template-columns: minmax(0,1fr) minmax(var(--column-unit-width),.72fr);
        }
    }

    .permission-item select {
        flex: 0 0 var(--field-compact-width);
        width: var(--field-compact-width);
    }

    .permission-group-title {
        align-items: flex-start;
    }

    .permission-group-title small {
        text-align: right;
    }

    @media (max-width: 1100px) {
        .permission-grid {
            grid-template-columns: 1fr;
        }
    }

    @media (max-width: 900px) {
        .permission-item select {
            flex: 0 0 auto;
            width: 100%;
        }

        .permission-group-title small {
            display: block;
            text-align: left;
            margin-top: var(--space-1);
        }
    }

    .sidebar-mobile-head,
    .sidebar-backdrop {
        display: none;
    }

    @media screen and (max-width: 1100px) {
        .app-shell {
            display: block;
        }

        .sidebar {
            position: fixed;
            inset: 0 auto 0 0;
            width: min(var(--sidebar-drawer-width), calc(100vw - var(--space-8)));
            min-height: 0;
            height: 100vh;
            height: 100dvh;
            transform: translateX(-105%);
            visibility: hidden;
            transition: transform .18s ease, visibility .18s;
            z-index: 90;
            padding-bottom: env(safe-area-inset-bottom, 0);
        }

        .sidebar.open {
            transform: none;
            visibility: visible;
        }

        .sidebar-mobile-head {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: max(var(--space-2), env(safe-area-inset-top, 0)) var(--space-3) var(--space-2);
            border-bottom: var(--border-width) solid var(--line-on-dark);
        }

        .sidebar-mobile-head .icon-button {
            flex: 0 0 var(--touch-target);
        }

        [data-action="toggle-sidebar"] {
            width: var(--touch-target);
            height: var(--touch-target);
            flex: 0 0 var(--touch-target);
        }

        .sidebar .nav {
            min-height: 0;
            overscroll-behavior: contain;
        }

        .sidebar .brand-block {
            padding: var(--space-2) var(--space-4);
        }

        .sidebar .brand-logo {
            max-height: var(--brand-logo-height-mobile);
        }

        .sidebar-backdrop:not([hidden]) {
            display: block;
            position: fixed;
            inset: 0;
            z-index: 89;
            border: 0;
            background: var(--overlay-soft);
        }

        body.sidebar-open {
            overflow: hidden;
        }

        .mobile-only {
            display: inline-grid;
            place-items: center;
        }

        .topbar {
            gap: var(--space-2);
        }

        .page-heading,
        .global-search {
            min-width: 0;
        }
    }

    @media screen and (max-width: 760px) {
        .preview-head {
            flex-wrap: wrap;
        }

        .preview-head h3 {
            margin: 0;
        }

        .preview-actions {
            display: flex;
            flex-wrap: wrap;
            gap: var(--space-2);
        }

        .preview-frame {
            min-height: 0;
            min-width: 0;
        }

        .preview-shell {
            height: 96vh;
            height: 96dvh;
        }
    }

    @media (prefers-reduced-motion: reduce) {
        .sidebar {
            transition: none;
        }
    }

    .sidebar-license-note {
        color: var(--text-on-dark-muted);
        margin: 0 var(--space-2) var(--space-2);
    }

    .chart-summary {
        display: flex;
        align-items: baseline;
        gap: var(--space-3);
        flex-wrap: wrap;
        margin: var(--space-3) 0 0;
    }

    .chart-summary strong,
    .chart-zero strong {
        letter-spacing: -.04em;
        font-variant-numeric: tabular-nums;
    }

    .chart-area {
        fill: var(--accent);
        opacity: .15;
    }

    .chart-bars {
        display: grid;
        gap: var(--space-6);
        padding: var(--space-6) 0 var(--space-4);
    }

    .chart-bar-row>div:first-child {
        display: flex;
        justify-content: space-between;
        gap: var(--space-3);
        margin-bottom: var(--space-2);
    }

    .chart-bar-row strong {
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
    }

    .chart-bar-track {
        height: var(--chart-bar-height);
        border-radius: var(--radius-sm);
        background: var(--surface-2);
        overflow: hidden;
    }

    .chart-bar-measure {
        display: block;
        width: 100%;
        height: 100%;
    }

    .chart-bar-fill {
        fill: var(--accent);
    }

    .chart-bar-fill.tone-1 {
        fill: var(--ok);
    }

    .chart-bar-fill.tone-2 {
        fill: var(--info);
    }

    .chart-bar-fill.is-negative {
        fill: var(--bad);
    }

    .chart-zero {
        min-height: var(--chart-zero-min-height);
        display: flex;
        flex-direction: column;
        gap: var(--space-3);
        align-items: center;
        justify-content: center;
        background: var(--surface-2);
        border-radius: var(--control-radius);
        margin-top: var(--space-4);
        text-align: center;
        padding: var(--space-6);
    }

    .readonly-note,
    [data-newsletter-editor] {
        white-space: pre-wrap;
        overflow-wrap: anywhere;
        margin: 0;
    }

    .editor-bottom-add {
        display: grid;
        gap: var(--space-3);
        margin-top: var(--space-4);
    }

    .editor-bottom-add>.button {
        justify-self: start;
    }

    .line-main>.line-product-results {
        grid-column: 1/-1;
        min-width: 0;
    }

    .global-search {
        position: relative;
    }

    .search-result-group {
        margin: 0 0 var(--space-4);
    }

    .search-result-group h4 {
        display: flex;
        gap: var(--space-2);
        align-items: center;
        margin: 0;
        padding: var(--space-2) var(--space-1);
        color: var(--muted);
    }

    .search-all-results {
        width: 100%;
    }

    .pagination {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: var(--space-3);
        padding: var(--space-4);
        flex-wrap: wrap;
    }

    @media(max-width:600px) {
        .topbar {
            flex-wrap: wrap;
        }

        .topbar-tools {
            width: 100%;
            margin-left: 0;
        }

        .global-search {
            display: flex;
            min-width: 0;
            flex: 1;
        }

        .global-search input {
            width: 100%;
            min-width: 0;
        }
    }

    #personalTasksPanel {
        padding: var(--space-6);
        margin-bottom: var(--space-4);
    }

    .preview-mobile-pdf .preview-head {
        flex-wrap: wrap;
    }

    .preview-mobile-pdf .preview-pdf-actions {
        display: flex;
        flex-wrap: wrap;
        gap: var(--space-2);
        min-width: 0;
    }

    .preview-mobile-pdf .preview-pdf-status {
        flex-basis: 100%;
        margin: 0;
    }

    @media (max-width:760px) {
        .preview-mobile-pdf .preview-actions {
            width: 100%;
            justify-content: flex-start;
        }

        .preview-mobile-pdf .preview-pdf-actions {
            flex: 1 1 var(--field-wide-min-width);
        }

        .preview-mobile-pdf .preview-actions>[data-preview-action="close"] {
            margin-left: auto;
        }
    }
}

/* Shared document lists use the space available inside each panel or dialog. */
@media screen {
    .table-wrap:has(> .document-list-table) {
        container-type: inline-size;
        container-name: document-list;
    }

    .table-wrap:has(> .document-list-table.receivable-summary-table) {
        container-name: document-summary;
    }

    .document-list-table td[data-label]::before {
        content: attr(data-label);
        display: none;
        margin-bottom: var(--space-1);
        color: var(--muted);
    }

    @container document-list (max-width:1180px) {
        .document-list-table td {
            border: 0 !important;
        }

        .document-list-table td[data-label]::before {
            display: block;
        }

        .document-list-table td[data-col="document"] {
            grid-column: 1;
            grid-row: 1;
        }

        .document-list-table td[data-col="status"] {
            grid-column: 2;
            grid-row: 1;
            justify-self: end;
        }

        .document-list-table td[data-col="partner"] {
            grid-column: 1/-1;
            grid-row: 2;
            padding-top: var(--space-1) !important;
            border-top: var(--border-width) solid var(--line-soft) !important;
        }

        .document-list-table td[data-col="date"] {
            grid-column: 1;
            grid-row: 3;
        }

        .document-list-table td[data-col="owner"] {
            grid-column: 2;
            grid-row: 3;
            text-align: right;
        }

        .document-list-table td[data-col="net"] {
            grid-column: 1;
            grid-row: 5;
            text-align: left !important;
            align-self: center;
        }

        .document-list-table td[data-col="actions"] {
            grid-column: 2;
            grid-row: 5;
            justify-self: end;
        }

        .document-list-table td[data-col="email"] {
            grid-column: 1/-1;
            grid-row: 4;
        }

        .document-list-table .row-actions {
            white-space: normal;
            flex-wrap: wrap;
            justify-content: flex-end;
        }

        .document-list-table .status-select {
            width: 100%;
            max-width: var(--status-control-compact-width);
        }
    }
    @container document-summary (max-width:760px) {
        .document-list-table td {
            border: 0 !important;
        }

        .document-list-table td[data-label]::before {
            display: block;
        }

        .document-list-table td[data-col="document"] {
            grid-column: 1;
            grid-row: 1;
        }

        .document-list-table td[data-col="status"] {
            grid-column: 2;
            grid-row: 1;
            justify-self: end;
        }

        .document-list-table td[data-col="partner"] {
            grid-column: 1/-1;
            grid-row: 2;
            padding-top: var(--space-1) !important;
            border-top: var(--border-width) solid var(--line-soft) !important;
        }

        .document-list-table td[data-col="date"] {
            grid-column: 1;
            grid-row: 3;
        }

        .document-list-table td[data-col="owner"] {
            grid-column: 2;
            grid-row: 3;
            text-align: right;
        }

        .document-list-table td[data-col="net"] {
            grid-column: 1;
            grid-row: 5;
            text-align: left !important;
            align-self: center;
        }

        .document-list-table td[data-col="actions"] {
            grid-column: 2;
            grid-row: 5;
            justify-self: end;
        }

        .document-list-table td[data-col="email"] {
            grid-column: 1/-1;
            grid-row: 4;
        }

        .document-list-table .row-actions {
            white-space: normal;
            flex-wrap: wrap;
            justify-content: flex-end;
        }

        .document-list-table .status-select {
            width: 100%;
            max-width: var(--status-control-compact-width);
        }
    }
}

/* Owner-requested header actions reuse the existing yellow account avatars. */
@media screen and (max-width: 1100px) {
    .topbar {
        display: flex;
        flex-wrap: wrap;
        gap: var(--space-2);
        padding: var(--space-3);
    }

    .topbar .page-heading {
        min-width: 0;
        flex: 1;
    }

    .topbar .topbar-tools {
        display: flex;
        order: 3;
        flex: 0 0 100%;
        width: 100%;
        margin: 0;
        flex-wrap: nowrap;
    }

    .topbar #globalCreateButton {
        margin-right: auto;
        flex: 0 0 auto;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .kpi {
        min-width: 0;
    }
}

@media screen and (min-width: 601px) and (max-width: 1100px) {
    .topbar #globalCreateButton {
        margin-left: auto;
        margin-right: 0;
    }
}

@media screen and (max-width: 600px) {
    .topbar .page-heading h1 {
        overflow-wrap: anywhere;
    }

    .topbar .topbar-nav {
        gap: var(--space-1);
    }

    .kpi-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media screen and (max-width: 360px) {
    .topbar .topbar-tools {
        display: grid;
        grid-template-columns: minmax(var(--touch-target), 1fr) repeat(3, var(--touch-target));
        justify-content: end;
        gap: var(--space-2);
    }

    .topbar #globalCreateButton {
        grid-column: 1/-1;
        justify-self: start;
        margin-right: 0;
    }

    .topbar #globalSearchButton {
        grid-column: 1;
        justify-self: end;
        margin-left: 0;
    }

    .topbar #globalSearchButton::before {
        display: none;
    }

    .topbar .topbar-nav {
        grid-column: 2/-1;
        gap: var(--space-2);
    }
}

/* Screen-only glass finish; approved layout, typography and control geometry stay unchanged. */
@media screen {
    .app-shell,
    .remote-login-gate {
        background: var(--glass-canvas);
    }

    #mainContent>.page-head,
    #mainContent>:is(.reports-view, .valuation-view)>.page-head,
    #mainContent>.empty,
    #mainContent>.reports-view>.report-section:not(.panel)>h3 {
        color: var(--glass-login-ink);
    }

    #mainContent>.page-head :is(p, .ui-description, .ui-meta),
    #mainContent>:is(.reports-view, .valuation-view)>.page-head :is(p, .ui-description, .ui-meta),
    #mainContent>.valuation-view>.report-context {
        color: var(--glass-login-muted);
    }

    #mainContent .field>label:not(:where(.panel, .surface-card, .kpi, .editor-section, .summary-card) *) {
        color: var(--glass-login-muted);
    }

    #mainNav>.nav-group>.nav-label {
        color: var(--accent);
    }

    .app-shell>.sidebar {
        background: var(--glass-graphite);
        background-attachment: fixed;
        box-shadow: var(--glass-graphite-shadow);
        -webkit-backdrop-filter: blur(calc(var(--topbar-blur) * 2)) saturate(1.15);
        backdrop-filter: blur(calc(var(--topbar-blur) * 2)) saturate(1.15);
    }

    .app-shell .topbar {
        background: var(--glass-chrome-surface);
        background-attachment: fixed;
        color: var(--glass-login-ink);
        border-bottom-color: var(--glass-edge);
        box-shadow: var(--glass-chrome-shadow);
        -webkit-backdrop-filter: blur(calc(var(--topbar-blur) * 2)) saturate(1.2);
        backdrop-filter: blur(calc(var(--topbar-blur) * 2)) saturate(1.2);
    }

    .app-shell .topbar .page-heading :is(#pageEyebrow, p) {
        color: var(--glass-login-muted);
    }

    #app .kpi {
        background: var(--glass-kpi-surface);
        border-radius: var(--radius-lg);
        border-color: var(--glass-edge);
        border-top-color: var(--glass-white-edge);
        border-left-color: var(--glass-white-edge);
        border-right-color: var(--glass-warm-edge);
        box-shadow: var(--glass-panel-shadow);
        -webkit-backdrop-filter: blur(var(--glass-surface-blur));
        backdrop-filter: blur(var(--glass-surface-blur));
    }

    #app .kpi:is(:hover, :focus-within) {
        box-shadow: var(--glass-panel-hover-shadow);
    }

    .remote-login-card {
        background: var(--glass-dialog-surface);
        border-color: var(--glass-white-edge);
        border-top-color: var(--accent);
        box-shadow: var(--glass-dialog-shadow);
        -webkit-backdrop-filter: blur(calc(var(--topbar-blur) * 3)) saturate(1.2);
        backdrop-filter: blur(calc(var(--topbar-blur) * 3)) saturate(1.2);
    }
}

/* The accepted login scenery is shared by all shell backgrounds without duplicating its arcs. */
@media screen {
    body:has(>.app-shell),
    .app-shell {
        background: var(--glass-canvas);
        background-attachment: fixed;
    }

    .remote-login-gate {
        background: var(--glass-login-canvas);
        color: var(--glass-login-ink);
    }

    .remote-login-gate::before {
        content: "";
        position: fixed;
        inset: 0;
        z-index: 0;
        background-image: var(--glass-login-arcs);
        pointer-events: none;
    }

    .remote-login-gate .remote-login-card {
        position: relative;
        z-index: 1;
        background: var(--glass-login-card);
        color: var(--glass-login-ink);
        border-color: var(--glass-login-border);
        border-top-color: var(--glass-login-top-edge);
        border-left-color: var(--glass-login-top-edge);
        border-right-color: var(--glass-warm-edge);
        box-shadow: var(--glass-login-shadow);
    }

    .remote-login-gate .remote-login-card:is(:hover, :focus-within) {
        box-shadow: var(--glass-login-hover-shadow);
    }

    .remote-login-card .remote-login-logo {
        align-self: flex-start;
    }

    .remote-login-copy span {
        color: var(--accent);
    }

    .remote-login-copy h1 {
        color: var(--glass-login-ink);
    }

    .remote-login-copy p,
    .remote-login-field span,
    .remote-login-card>p.ui-description {
        color: var(--glass-login-muted);
    }

    .remote-login-card .callout {
        color: var(--ink);
        background: var(--surface);
    }
}

@media screen and (prefers-reduced-motion: no-preference) {
    .app-shell .kpi,
    .remote-login-gate .remote-login-card {
        transition: box-shadow .18s ease, border-color .18s ease;
    }
}

/* Recovery reuses the accepted login material; auto margins keep a tall card scrollable from its top. */
@media screen {
    .remote-login-gate.password-reset-gate {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .password-reset-gate .password-reset-card {
        width: min(var(--password-reset-card-width), 100%);
        flex: 0 0 auto;
        margin-block: auto;
    }

    .password-reset-card .password-reset-form {
        display: flex;
        flex-direction: column;
        gap: var(--space-4);
        width: 100%;
    }

    .password-reset-card .ui-meta {
        color: var(--glass-login-muted);
    }
}

/* Installer and occupied-folder pages use the same screen materials as the application. */
@media screen {
    .standalone-system-page {
        min-height: 100vh;
        background: var(--glass-canvas);
        background-attachment: fixed;
        color: var(--glass-login-ink);
    }

    .standalone-system-page .installer-brand>.ui-label {
        color: var(--glass-login-ink);
    }

    .standalone-system-page .installer-brand .brand-caption,
    .standalone-system-page .installer-footer,
    .standalone-system-page .installer-steps li:not([aria-current="step"]) {
        color: var(--glass-login-muted);
    }

    .standalone-system-page .installer-steps li:not([aria-current="step"], .installer-step-complete) {
        border-bottom-color: var(--glass-edge);
    }

    .standalone-system-page .installer-section {
        position: relative;
        min-width: 0;
        overflow-wrap: anywhere;
        background: var(--glass-panel-surface);
        color: var(--ink);
        border-radius: var(--radius-lg);
        border-color: var(--glass-edge);
        border-top-color: var(--glass-white-edge);
        border-left-color: var(--glass-white-edge);
        border-right-color: var(--glass-warm-edge);
        box-shadow: var(--glass-panel-shadow);
        -webkit-backdrop-filter: blur(var(--glass-surface-blur));
        backdrop-filter: blur(var(--glass-surface-blur));
    }

    .standalone-system-page .installer-section:is(:hover, :focus-within) {
        box-shadow: var(--glass-panel-hover-shadow);
    }

    .standalone-system-page .installer-summary,
    .standalone-system-page .installer-choice,
    .standalone-system-page .installer-choice:has(input:checked) {
        background: var(--glass-inner-surface);
    }

    .standalone-system-page .installer-fields>:is(h2, h3, p) {
        margin: 0;
    }

    @supports ((mask-composite: exclude) or (-webkit-mask-composite: xor)) {
        .standalone-system-page .installer-section::after {
            content: "";
            position: absolute;
            z-index: 4;
            inset: calc(var(--border-width) * -1);
            padding: var(--border-strong-width);
            border-radius: var(--radius-lg);
            background: var(--glass-rim);
            -webkit-mask: var(--glass-rim-mask) content-box, var(--glass-rim-mask);
            mask: var(--glass-rim-mask) content-box, var(--glass-rim-mask);
            -webkit-mask-composite: xor;
            mask-composite: exclude;
            opacity: .72;
            pointer-events: none;
        }

        .standalone-system-page .installer-section:is(:hover, :focus-within)::after {
            opacity: 1;
        }
    }
}

@media screen and (prefers-reduced-motion: no-preference) {
    .standalone-system-page .installer-section {
        transition: box-shadow .18s ease, border-color .18s ease;
    }

    .standalone-system-page .installer-section::after {
        transition: opacity .18s ease;
    }
}

/* Inner rows reveal their parent material; highlighted offer-group headers retain their semantic fill. */
@media screen {
    :is(#app, #modalLayer) :is(.doc-line:not(.offer-group-header), .permission-item, .chart-zero) {
        background: var(--glass-inner-surface);
    }
}
