html, body {
    height: 100%;
}

:root {
    --pks-app-workspace-background: #F2F5FA;
    --pks-list-hover-background: #EFF6FF;
    --pks-list-selected-background: #EFF6FF;
}

app {
    display: block;
    height: 100%;
}

/* PKS shell and list standards. Header, ribbon, sidebar and content cards keep their own
   DevExpress surfaces; only the application workspace behind them uses the PKS background. */
.dxbl-theme-fluent .app,
.dxbl-theme-fluent .main-ribbon-template.app {
    background-color: var(--pks-app-workspace-background);
}

.dxbl-theme-fluent .main-ribbon-template.app .xaf-ribbon
    .dxbl-tabs-content-panel:not(:has(.dxbl-bar-item:not(.dxbl-toolbar-hidden-item))) {
    display: none;
}

/* Tabbed MDI already renders the active view caption in its tab strip. */
.dxbl-theme-fluent .main-ribbon-template.app .header .view-caption-root {
    display: none;
}

.dxbl-grid {
    --dxbl-grid-hover-bg: var(--pks-list-hover-background);
}

.dxbl-grid .dxbl-grid-table > tbody > tr:not(.dxbl-grid-group-row):not(.dxbl-grid-group-footer-row):not(.dxbl-grid-edit-row):not(.dxbl-grid-empty-row):not(.dxbl-grid-selected-row):not(.dxbl-grid-focused-row):hover > td {
    background-color: var(--pks-list-hover-background);
}

.dxbl-grid .dxbl-grid-table > tbody > tr:not(.dxbl-grid-group-row):not(.dxbl-grid-group-footer-row):not(.dxbl-grid-edit-row):not(.dxbl-grid-empty-row).dxbl-grid-selected-row > td,
.dxbl-grid .dxbl-grid-table > tbody > tr:not(.dxbl-grid-group-row):not(.dxbl-grid-group-footer-row):not(.dxbl-grid-edit-row):not(.dxbl-grid-empty-row).dxbl-grid-focused-row > td {
    background-color: var(--pks-list-selected-background) !important;
    color: var(--dxds-color-content-neutral-default-rest, #26364A) !important;
}

.grid-content td.xaf-double-click,
.pks-double-click-grid .dxbl-grid-table > tbody > tr:not(.dxbl-grid-group-row):not(.dxbl-grid-group-footer-row):not(.dxbl-grid-edit-row):not(.dxbl-grid-empty-row) > td {
    cursor: pointer;
}

/* The Ribbon template keeps its native navigation toggle. On pointer devices a collapsed
   sidebar opens as a lightweight flyout; the pin delegates persistent state changes back to
   XAF's own sidebar toggle. Touch devices retain the native click interaction. */
.main-ribbon-template.app > .xaf-flex-auto,
.main-ribbon-template.app .sidebar {
    position: relative;
}

@media (min-width: 576px) {
    .pks-navigation-filter-row {
        display: flex;
        width: 100%;
        align-items: stretch;
    }

    .pks-navigation-filter-row > .dxbl-navigation-filter {
        flex: 1 1 auto;
        width: auto;
        min-width: 0;
    }

    .pks-navigation-pin {
        display: inline-flex;
        box-sizing: border-box;
        flex: 0 0 auto;
        width: auto;
        min-width: 0;
        height: auto;
        min-height: 0;
        aspect-ratio: 1;
        align-self: stretch;
        align-items: center;
        justify-content: center;
        margin: var(--dxbl-treeview-navigation-filter-top-spacing)
            var(--dxbl-treeview-navigation-filter-x-spacing)
            var(--dxbl-treeview-navigation-filter-bottom-spacing)
            0;
        border: 1px solid var(--dxds-color-border-neutral-default-rest);
        border-radius: var(--dxds-border-radius-40, 0.375rem);
        padding: 0;
        background: var(--dxds-color-surface-neutral-default-rest);
        color: var(--dxds-color-content-neutral-default-rest, #53647A);
        box-shadow: none;
        transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
    }

    .pks-navigation-pin:hover,
    .pks-navigation-pin:focus-visible {
        border-color: var(--dxds-color-border-primary-default-rest);
        background: var(--pks-list-hover-background);
        color: var(--dxds-color-content-primary-default-rest, #4F6F9F);
    }

    .pks-navigation-pin[aria-pressed="true"] {
        border-color: var(--dxds-color-border-neutral-default-rest);
        background: var(--dxds-color-surface-neutral-default-rest);
        color: var(--dxds-color-content-neutral-default-rest, #53647A);
    }

    .pks-navigation-pin .pks-navigation-pin-icon {
        display: block;
        width: 1.125rem;
        height: 1.125rem;
        background-color: currentColor;
        mask-position: center;
        mask-repeat: no-repeat;
        mask-size: contain;
        -webkit-mask-position: center;
        -webkit-mask-repeat: no-repeat;
        -webkit-mask-size: contain;
    }

    .pks-navigation-pin .pks-navigation-pin-icon--pinned {
        mask-image: url("../images/icons/pin.svg");
        -webkit-mask-image: url("../images/icons/pin.svg");
    }

    .pks-navigation-pin .pks-navigation-pin-icon--unpinned {
        mask-image: url("../images/icons/pin-off.svg");
        -webkit-mask-image: url("../images/icons/pin-off.svg");
    }
}

@media (min-width: 576px) and (hover: hover) {
    .main-ribbon-template.app.collapse-toggle.pks-navigation-hover-open .sidebar {
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 1040;
        display: flex !important;
        width: 270px;
        min-width: 270px;
        background: var(--dxds-color-surface-neutral-default-rest);
        box-shadow: 0 2px 8px rgba(30, 50, 70, 0.06);
    }
}

@media (max-width: 575.98px) {
    .pks-navigation-pin {
        display: none;
    }
}

.header-logo {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    width: auto;
    min-width: 88px;
    height: 36px;
    color: #1f2f3b;
}

.header-logo::before {
    content: "";
    display: block;
    width: 40px;
    height: 32px;
    background: url('../images/branding/paulis-logo.png') center / contain no-repeat;
}

.header-logo::after {
    content: "PKS";
    margin-left: 10px;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0;
}

.pks-shell-brand-host {
    display: inline-flex !important;
    align-items: center !important;
}

.pks-shell-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #1f2f3b;
    font-weight: 700;
    line-height: 1;
}

.pks-shell-brand-logo {
    display: block;
    width: 58px;
    height: 30px;
    object-fit: contain;
}

.pks-shell-brand-text {
    font-size: 1rem;
    letter-spacing: 0;
}

.pks-splash-brand [style*="background"],
.pks-splash-brand [class*="splash"],
.pks-splash-brand [class*="Splash"],
.pks-splash-brand [class*="loading"],
.pks-splash-brand [class*="Loading"] {
    background: transparent !important;
    background-color: transparent !important;
}

.pks-splash-brand img {
    display: block;
    object-fit: contain;
}

.pks-logon-card {
    width: min(500px, calc(100vw - 32px)) !important;
    border: 1px solid #dbe3ed !important;
    border-radius: 10px !important;
    box-shadow: 0 18px 46px rgba(26, 43, 61, 0.12) !important;
    background: #fff !important;
    padding: 32px 42px 34px !important;
}

.pks-logon-card > div {
    border: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
}

.pks-logon-card input {
    background-color: #fff !important;
}

.pks-logon-template .logon-template-header {
    min-height: 48px;
}

.pks-logon-template .card-body {
    padding: 0 !important;
}

.pks-logon-branding {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 28px;
    width: 100%;
    margin: -4px 0 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e4ebf3;
}

.pks-logon-branding img {
    display: block;
    object-fit: contain;
}

.pks-logon-branding-paulis {
    width: 206px;
    max-width: 60%;
    height: auto;
    max-height: 92px;
}

.pks-logon-branding-optisoft {
    width: 150px;
    max-width: 34%;
    height: auto;
    max-height: 42px;
}

.pks-logon-title {
    margin-top: 0 !important;
    margin-bottom: 18px !important;
    font-size: 1.28rem !important;
    font-weight: 700 !important;
    color: #162130 !important;
}

.pks-logon-intro {
    margin: 0 0 14px;
}

.pks-native-logon-form {
    position: relative;
}

.pks-logon-submit-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 44px;
    margin-top: 18px;
    padding: 9px 18px;
    border: 1px solid #1976d2;
    border-radius: 4px;
    background: #1976d2;
    color: #fff;
    font: inherit;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}

.pks-logon-submit-button:hover {
    background: #1669bb;
    border-color: #1669bb;
}

.pks-logon-submit-button:focus {
    outline: 0;
    box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.2);
}

.pks-logon-submit-button:active {
    background: #125ba4;
    border-color: #125ba4;
}

.pks-native-logon-page {
    min-height: 100%;
    margin: 0;
    background: #fff;
    color: #162130;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.pks-native-logon-page-main {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
}

.pks-native-logon-card {
    box-sizing: border-box;
}

.pks-logon-field {
    margin-top: 12px;
}

.pks-logon-field label {
    display: block;
    margin-bottom: 4px;
}

.pks-logon-field input {
    box-sizing: border-box;
    width: 100%;
    min-height: 36px;
    padding: 6px 10px;
    border: 1px solid #b8c4d1;
    border-radius: 4px;
    color: #162130;
    font: inherit;
}

.pks-logon-field input:focus {
    border-color: #1976d2;
    box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.16);
    outline: 0;
}

.pks-password-input {
    position: relative;
}

.pks-logon-field .pks-password-input input {
    padding-inline-end: 44px;
}

.pks-password-visibility-button {
    position: absolute;
    top: 2px;
    inset-inline-end: 2px;
    display: inline-flex;
    width: 32px;
    height: 32px;
    padding: 6px;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 3px;
    background: transparent;
    color: #52677b;
    cursor: pointer;
}

.pks-password-visibility-button:hover {
    background: #edf3f8;
    color: #162130;
}

.pks-password-visibility-button:focus-visible {
    outline: 2px solid #1976d2;
    outline-offset: 1px;
}

.pks-password-visibility-icon {
    width: 20px;
    height: 20px;
    pointer-events: none;
}

.pks-logon-error {
    margin: 0 0 12px;
    padding: 8px 10px;
    border: 1px solid #f1b5b5;
    border-radius: 4px;
    background: #fff2f2;
    color: #9f1d1d;
}

.pks-change-password-dialog {
    width: min(720px, calc(100vw - 32px)) !important;
    max-width: calc(100vw - 32px) !important;
}

.pks-change-password-dialog .dxbl-popup-content,
.pks-change-password-dialog .dxbl-popup-body,
.pks-change-password-dialog .modal-body {
    overflow-x: hidden !important;
}

.pks-change-password-dialog .dxbl-fl,
.pks-change-password-dialog .dxbl-fl-cpt,
.pks-change-password-dialog .dxbl-text-edit {
    max-width: 100% !important;
}

.pks-change-password-visibility-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0 12px;
    font-size: 0.92rem;
    color: #1f2f3b;
    user-select: none;
}

.pks-change-password-visibility-toggle input {
    margin: 0;
}

@media (max-width: 640px) {
    .pks-logon-branding {
        flex-direction: column;
        align-items: center;
        gap: 10px;
        margin-bottom: 22px;
        padding-bottom: 18px;
    }

    .pks-logon-branding-paulis {
        width: 178px;
    }

    .pks-logon-branding-optisoft {
        width: 124px;
    }
}

#blazor-error-ui {
    background: inherit;
    bottom: 0;
    display: none;
    position: fixed;
    width: 100%;
    height: 100%;
    z-index: 100001;
}

.pks-grid-standard .dxbl-grid-table {
    min-width: 1400px;
}

.pks-rezepte-list-grid {
    min-height: 0;
}

/* QuickAccess renders the PKS Arbeitskontext and license status as XAF Actions. */
.combobox-xaf-action,
.combobox-xaf-action .dxbl-btn,
[data-xaf-action="PKS_Arbeitskontext"],
[data-xaf-action="PKS_Arbeitskontext"] .dxbl-btn,
[data-xaf-action="PKS_Lizenzstatus"],
button[data-xaf-action="PKS_Lizenzstatus"] {
    min-height: 44px !important;
    font-size: 1.08rem !important;
}

.combobox-xaf-action,
[data-xaf-action="PKS_Arbeitskontext"] {
    width: clamp(360px, 36vw, 520px) !important;
    max-width: calc(100vw - 360px);
    min-width: 320px;
}

.combobox-xaf-action .dxbl-btn-group,
.combobox-xaf-action .btn-group,
.combobox-xaf-action .dxbl-btn,
[data-xaf-action="PKS_Arbeitskontext"] .dxbl-btn {
    width: 100%;
    min-width: 0;
    justify-content: space-between;
}

.combobox-xaf-action .dxbl-btn:not(:last-child),
[data-xaf-action="PKS_Arbeitskontext"] .dxbl-btn:not(:last-child) {
    flex: 1 1 auto;
    overflow: hidden;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
}

[data-xaf-action="PKS_Lizenzstatus"],
button[data-xaf-action="PKS_Lizenzstatus"] {
    font-weight: 600;
    padding-right: 16px !important;
    padding-left: 16px !important;
}

@media (max-width: 900px) {
    .combobox-xaf-action,
    [data-xaf-action="PKS_Arbeitskontext"] {
        width: 320px !important;
        max-width: calc(100vw - 260px);
    }
}

/* DevExpress renders popups outside the component scope. Keep Mandant/Betrieb edit popups fixed;
   only the embedded parameter section may scroll. */
.pks-edit-popup,
.pks-edit-popup .dxbl-popup {
    display: flex !important;
    width: min(900px, calc(100vw - 32px)) !important;
    height: min(760px, calc(100vh - 32px)) !important;
    max-width: calc(100vw - 32px) !important;
    max-height: calc(100vh - 32px) !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

.pks-edit-popup .dxbl-popup-header {
    flex: 0 0 auto !important;
}

.pks-edit-popup .dxbl-popup-content,
.pks-edit-popup .dxbl-popup-body {
    display: flex !important;
    min-height: 0 !important;
    flex: 1 1 auto !important;
    flex-direction: column !important;
    overflow: hidden !important;
    overflow-y: hidden !important;
    max-height: none !important;
}

.pks-edit-popup .dxbl-popup-body > div,
.pks-edit-popup-content {
    display: flex !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    flex: 1 1 auto !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

.pks-edit-popup .pks-popup-section {
    flex: 0 0 auto !important;
}

.pks-edit-popup .pks-popup-form-actions {
    flex: 0 0 auto !important;
}

.pks-edit-popup .pks-popup-parameter-section {
    min-height: 0 !important;
    flex: 1 1 0 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
}

.pks-edit-popup .pks-popup-parameter-section .pks-parameter-editor {
    min-height: 0 !important;
    flex: 0 0 auto !important;
    overflow: visible !important;
}

.pks-copy-field {
    display: flex;
    width: 100%;
    align-items: stretch;
    gap: 6px;
}

.pks-copy-field-input {
    display: flex;
    min-width: 0;
    flex: 1 1 0;
}

.pks-copy-field-input .dxbl-text-edit {
    width: 100%;
    min-width: 0;
    flex: 1 1 auto;
}

.pks-copy-field .pks-copy-button {
    width: 32px !important;
    height: auto !important;
    min-height: 0;
    flex: 0 0 32px;
    align-self: stretch;
}

/* DxSpinEdit renders the actual input inside DevExpress-owned markup. This global rule
   intentionally targets only PKS parameter numeric editors. */
.pks-parameter-number-editor input,
.pks-parameter-number-editor .dxbl-text-edit-input,
.pks-parameter-number-input {
    text-align: right !important;
}

/* Shared PKS form conventions: stable dialog navigation and numeric alignment. */
.pks-dialog-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    width: 100%;
    min-width: 0;
    flex: 0 0 auto;
    margin-top: auto;
    border-top: 1px solid #e5e7eb;
    padding-top: 8px;
}

.pks-dialog-footer-left,
.pks-dialog-footer-right {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex-wrap: wrap;
}

.pks-dialog-footer-right {
    justify-content: flex-end;
    margin-left: auto;
}

.pks-numeric-cell {
    display: block;
    width: 100%;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.pks-numeric-editor input,
.pks-numeric-editor .dxbl-text-edit-input {
    text-align: right !important;
    font-variant-numeric: tabular-nums;
}

/* DxPopup renders its custom header outside the Razor CSS-isolation scope. */
.pks-eaternity-menu-plan-title,
.pks-eaternity-menu-plan-test-notice {
    display: flex;
    align-items: center;
    min-width: 0;
}

.pks-eaternity-menu-plan-title {
    gap: 14px;
    width: 100%;
    font-weight: 700;
}

.pks-eaternity-menu-plan-test-notice {
    gap: 8px;
    border-left: 3px solid var(--bs-warning, #b7791f);
    padding: 4px 8px;
    background: var(--bs-warning-bg-subtle, #fff4d6);
    color: var(--bs-body-color, #20262d);
    font-size: 12px;
    font-weight: 400;
}

.pks-eaternity-menu-plan-grid {
    flex: 1 1 0;
    width: 100%;
    min-width: 0;
    height: 100%;
    min-height: 0;
}

.pks-eaternity-menu-plan-grid .dxbl-scroll-viewer-content {
    overflow-x: scroll !important;
    scrollbar-gutter: stable;
}

@media (max-width: 520px) {
    .pks-dialog-footer {
        align-items: flex-end;
    }
}

.pks-control-admin-page {
    min-height: 100vh;
    margin: 0;
    background: var(--pks-app-workspace-background);
    color: #26364a;
    font-family: Arial, sans-serif;
}

.pks-control-admin-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 20px;
    border-bottom: 1px solid #d9e0e8;
    padding: 12px 28px;
    background: #fff;
}

.pks-control-admin-header .pks-logon-branding {
    margin: 0;
}

.pks-control-admin-title,
.pks-control-admin-card h2 {
    margin: 0;
    color: #1f2f43;
}

.pks-control-admin-title {
    font-size: 24px;
}

.pks-control-admin-subtitle {
    margin: 4px 0 0;
    color: #617085;
}

.pks-control-admin-main {
    width: min(1240px, calc(100% - 32px));
    margin: 24px auto;
}

.pks-control-admin-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.pks-control-admin-card {
    min-width: 0;
    border: 1px solid #d9e0e8;
    border-radius: 10px;
    padding: 20px;
    background: #fff;
}

.pks-control-admin-card h2 {
    margin-bottom: 16px;
    font-size: 18px;
}

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

.pks-control-admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.pks-control-admin-table th,
.pks-control-admin-table td {
    border-bottom: 1px solid #e5e9ef;
    padding: 8px 10px;
    text-align: left;
    white-space: nowrap;
}

.pks-control-admin-table th {
    background: #f6f8fb;
    font-weight: 600;
}

.pks-control-admin-table tbody tr:nth-child(even) {
    background: #fafbfd;
}

.pks-control-admin-table tbody tr:hover {
    background: var(--pks-list-hover-background);
}

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

.pks-control-admin-status {
    display: inline-flex;
    border-radius: 999px;
    padding: 3px 9px;
    background: #edf1f5;
    color: #526174;
    font-size: 12px;
}

.pks-control-admin-status-active {
    background: #e7f5ec;
    color: #23663c;
}

.pks-control-admin-status-error {
    background: #fdecec;
    color: #9b2c2c;
}

.pks-control-admin-form {
    display: grid;
    gap: 8px;
}

.pks-control-admin-form label {
    margin-top: 4px;
    font-size: 13px;
    font-weight: 600;
}

.pks-control-admin-form input:not([type="checkbox"]),
.pks-control-admin-form select {
    box-sizing: border-box;
    width: 100%;
    min-height: 32px;
    border: 1px solid #bdc7d3;
    border-radius: 4px;
    padding: 5px 8px;
    background: #fff;
    color: inherit;
}

.pks-control-admin-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pks-control-admin-button,
.pks-control-admin-link-button {
    border: 1px solid #2875bf;
    border-radius: 6px;
    background: #2875bf;
    color: #fff;
    cursor: pointer;
    font: inherit;
}

.pks-control-admin-button {
    min-height: 32px;
    margin-top: 8px;
    padding: 6px 14px;
}

.pks-control-admin-button-secondary {
    border-color: #aeb9c6;
    background: #fff;
    color: #26364a;
}

.pks-control-admin-link-button {
    border: 0;
    padding: 2px;
    background: transparent;
    color: #175f9f;
    text-decoration: underline;
}

.pks-control-admin-message,
.pks-control-admin-error:not(:empty) {
    margin-bottom: 16px;
    border-radius: 6px;
    padding: 10px 12px;
}

.pks-control-admin-message {
    border: 1px solid #a8d8b7;
    background: #eef9f1;
}

.pks-control-admin-error:not(:empty) {
    border: 1px solid #e3a8a8;
    background: #fff2f2;
    color: #8b2525;
}

@media (max-width: 900px) {
    .pks-control-admin-grid {
        grid-template-columns: 1fr;
    }

    .pks-control-admin-header {
        grid-template-columns: 1fr;
    }

    .pks-control-admin-logout {
        justify-self: start;
    }
}
