html,
body {
    min-height: 100%;
    margin: 0;
}

#blazor-error-ui {
    box-sizing: border-box;
    display: none;
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 0.6rem 1.25rem 0.7rem;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
}

h1,
h2,
p {
    margin: 0;
}

.stack {
    display: grid;
    gap: 1rem;
}

.stack-lg {
    gap: 1.25rem;
}

.form-field {
    display: grid;
    gap: 0.35rem;
}

.form-field > span,
.invoice-preview-label {
    font-size: 0.78rem;
    text-transform: uppercase;
}

.validation-message {
    font-size: 0.82rem;
}

.blazor-error-boundary {
    padding: 1rem;
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

.converter-page {
    width: 100%;
    min-height: calc(100vh - 112px);
}

.customer-page {
    width: 100%;
}

.customer-page-header {
    width: 100%;
}

.customer-filter-form {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
    gap: 0.8rem;
    align-items: end;
}

.invoice-filter-form {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.8rem;
    align-items: end;
}

.invoice-filter-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    grid-column: 1 / -1;
}

.customer-filter-actions,
.customer-form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    min-width: 0;
}

.customer-icon-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    min-width: 28px;
    height: 28px;
    padding: 0;
}

.customer-form {
    display: grid;
    gap: 1rem;
}

.invoice-form {
    display: grid;
    gap: 1rem;
}

.invoice-customer-picker {
    position: relative;
}

.invoice-customer-results {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    z-index: 20;
    max-height: 260px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #d9d9d9;
    border-radius: 2px;
    box-shadow: 0 3px 10px rgb(0 0 0 / 12%);
}

.invoice-customer-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.6rem 0.75rem;
    color: inherit;
    text-align: left;
    background: transparent;
    border: 0;
    cursor: pointer;
}

.invoice-customer-option:hover,
.invoice-customer-option:focus {
    background: #f5f5f5;
}

.invoice-customer-option span,
.invoice-customer-empty {
    color: #8c8c8c;
    font-size: 0.82rem;
}

.invoice-customer-empty {
    padding: 0.75rem;
}

.invoice-custom-tax {
    margin-top: 0.5rem;
}

.invoice-line-editor {
    margin-bottom: 0.8rem;
}

.invoice-line-editor .ant-table-tbody > tr > td {
    padding: 8px 12px;
    vertical-align: top;
}

.invoice-line-editor .ant-form-item {
    margin-bottom: 0;
}

.invoice-line-editor .ant-form-item-explain {
    min-height: 0;
}

.invoice-line-editor .ant-table-tbody > tr > td:last-child .ant-btn {
    margin-top: 0;
}

.customer-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.8rem 1rem;
}

.customer-form-grid .validation-message {
    margin-top: -0.45rem;
}

.customer-select {
    width: 100%;
    height: 32px;
    padding: 4px 11px;
    line-height: 1.5715;
}

.customer-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.customer-details {
    display: grid;
    gap: 0.85rem;
}

.customer-details > div {
    display: grid;
    gap: 0.2rem;
    min-width: 0;
}

.customer-details strong {
    overflow-wrap: anywhere;
}

.converter-control-panel,
.invoice-preview-panel {
    width: 100%;
}

.invoice-preview-panel {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    width: 100%;
    min-height: 420px;
}

.invoice-preview-card-body {
    min-height: 360px;
}

.upload-box {
    display: grid;
    gap: 0.5rem;
    justify-items: center;
    min-width: 0;
}

.upload-button {
    position: relative;
}

.file-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.actions-row,
.processing-row,
.log-entry,
.dialog-actions,
.login-tenant-row,
.remember-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.actions-row,
.login-tenant-row {
    justify-content: space-between;
}

.processing-row .ant-progress {
    width: 150px;
}

.empty-log {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-height: 84px;
    padding: 0.9rem 1rem;
}

.log-list {
    display: grid;
    gap: 0.6rem;
}

.logs-panel {
    width: 100%;
}

.logs-panel.is-collapsed > .ant-card-body {
    display: none;
}

.invoice-preview-empty {
    display: grid;
    min-height: 320px;
    place-items: center;
    gap: 0.75rem;
    padding: 1.25rem;
    text-align: center;
}

.invoice-preview-paper {
    display: grid;
    gap: 1.2rem;
    min-height: 0;
    padding: 1.75rem;
    background: #fff;
    border: 1px solid #d9d9d9;
    border-radius: 2px;
    box-shadow: 0 2px 8px rgb(0 0 0 / 6%);
}

.invoice-preview-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #262626;
}

.invoice-preview-header h2 {
    margin-top: 0.1rem;
    font-size: 1.65rem;
    line-height: 1.15;
}

.invoice-preview-total {
    text-align: right;
}

.invoice-preview-total strong {
    display: block;
    font-size: 1.25rem;
}

.invoice-preview-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    padding-bottom: 1.2rem;
    border-bottom: 1px solid #d9d9d9;
}

.invoice-preview-meta > div,
.invoice-preview-parties > div {
    display: grid;
    gap: 0.2rem;
    min-width: 0;
}

.invoice-preview-meta > div {
    padding-left: 0.75rem;
    border-left: 1px solid #e8e8e8;
}

.invoice-preview-meta-reference {
    grid-column: span 2;
}

.invoice-preview-parties {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid #d9d9d9;
}

.invoice-preview-parties > div + div {
    padding-left: 1rem;
    border-left: 1px solid #e8e8e8;
}

.invoice-preview-lines {
    overflow: hidden;
    border: 1px solid #d9d9d9;
    border-radius: 2px;
}

.invoice-preview-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 64px 112px 110px;
    gap: 0.75rem;
    align-items: start;
    padding: 0.7rem 0.8rem;
    border-bottom: 1px solid #f0f0f0;
}

.invoice-preview-line:last-child {
    border-bottom: 0;
}

.invoice-preview-line > span:last-child,
.invoice-preview-line > span:nth-child(2),
.invoice-preview-line > span:nth-child(3) {
    text-align: right;
}

.invoice-preview-line span:first-child {
    display: grid;
    min-width: 0;
    gap: 0.15rem;
}

.invoice-preview-line-head {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    background: #fafafa;
    border-bottom-color: #d9d9d9;
}

.invoice-preview-summary {
    display: grid;
    justify-self: end;
    width: min(280px, 100%);
    gap: 0.45rem;
    padding-top: 1rem;
    border-top: 1px solid #d9d9d9;
}

.invoice-preview-summary div {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.invoice-preview-grand-total {
    padding-top: 0.55rem;
    font-size: 1.05rem;
    border-top: 2px solid #262626;
}

.customer-endpoint-dialog-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: grid;
    place-items: center;
    padding: 1rem;
}

.customer-endpoint-dialog {
    width: min(480px, 100%);
}

.customer-endpoint-form,
.login-form {
    display: grid;
    gap: 0.8rem;
    width: 100%;
    min-width: 0;
}

.login-transport-form {
    display: none;
}

.dialog-actions {
    justify-content: flex-end;
    margin-top: 0.3rem;
}

.login-shell {
    display: grid;
    width: 100%;
    max-width: 440px;
}

.login-panel {
    width: 100%;
}

.auth-card.ant-card {
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

.login-submit {
    justify-self: start;
}

.login-tenant-summary {
    display: grid;
    gap: 0.15rem;
    min-width: 0;
}

.login-tenant-summary strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.login-tenant-input {
    width: 100%;
}

.login-remember-checkbox {
    width: 18px;
    height: 18px;
    margin: 0;
    flex: 0 0 auto;
}

.culture-selector {
    width: 132px;
    height: 32px;
    padding: 4px 11px;
    line-height: 1.5715;
}

.culture-selector option {
    color: #1f1f1f;
    background: #fff;
}

.header-title {
    color: #ffffff;
}

.ant-pro-global-header-logo a img {
    width: auto;
    max-width: 176px;
    height: 56px !important;
    object-fit: contain;
}

.header-user-name {
    color: #ffffff;
    font-weight: 600;
    line-height: 32px;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-logout-button {
    align-items: center;
    display: inline-flex;
    height: 32px;
    gap: 0;
}

/* Ant Design ProLayout renders outside component-scoped style boundaries.
   Keep these overrides anchored to the authenticated shell. */
.authenticated-layout .ant-pro-sider-logo,
.authenticated-layout .ant-layout-header,
.authenticated-layout .ant-pro-global-header {
    background: linear-gradient(180deg, #173f63 0%, #285a80 100%) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: none !important;
}

.authenticated-layout .ant-layout-header,
.authenticated-layout .ant-pro-global-header,
.authenticated-layout .ant-pro-sider-logo {
    display: none !important;
}

.authenticated-layout .ant-pro-sider-fixed {
    top: 80px !important;
    height: calc(100vh - 80px) !important;
}

.authenticated-layout .ant-layout-header {
    height: 80px !important;
    min-height: 80px !important;
    padding: 0 !important;
    line-height: 80px !important;
}

.authenticated-layout .ant-pro-global-header {
    min-height: 80px;
    padding: 0 24px;
}

.authenticated-layout .ant-pro-sider-logo {
    box-sizing: border-box;
    height: 80px;
    min-height: 80px;
    padding: 10px 20px;
}

.authenticated-layout .ant-pro-sider:not(.ant-layout-sider-collapsed) .ant-pro-sider-logo img {
    width: 190px;
    max-width: 100%;
    height: auto !important;
    max-height: 60px;
    object-fit: contain;
}

.authenticated-layout .ant-pro-sider.ant-layout-sider-collapsed .ant-pro-sider-logo {
    padding: 16px 8px;
}

.authenticated-layout .ant-pro-sider.ant-layout-sider-collapsed .ant-pro-sider-logo img {
    width: 32px;
    height: 32px !important;
    content: url('/brand/rechnelia-icon.png');
    object-fit: contain;
}

.authenticated-layout .app-header-left,
.authenticated-layout .ant-pro-global-header > * {
    height: 100%;
}

.authenticated-layout .app-header-left {
    display: flex;
    align-items: center;
    gap: 28px;
}

.authenticated-layout .app-header-nav {
    display: flex;
    align-items: center;
    gap: clamp(16px, 2vw, 30px);
    height: 100%;
}

.authenticated-layout .app-header-nav a {
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    line-height: 38px;
    text-decoration: none;
    text-transform: uppercase;
    white-space: nowrap;
}

.authenticated-layout .app-header-nav a:hover,
.authenticated-layout .app-header-nav a:focus-visible {
    color: #8fd5ff;
}

.authenticated-layout .app-header-menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    color: #fff;
    font-size: 18px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.55);
    cursor: pointer;
}

.authenticated-layout .app-header-menu-toggle:hover,
.authenticated-layout .app-header-menu-toggle:focus-visible {
    background: rgba(255, 255, 255, 0.12);
    border-color: #fff;
}

.authenticated-layout .culture-selector {
    height: 38px;
    color: #fff;
    background: transparent;
    border-color: rgba(255, 255, 255, 0.55);
}

.authenticated-layout .header-user-name {
    color: #fff;
    font-size: 13px;
    font-weight: 500;
}

.authenticated-layout .header-logout-button {
    height: 38px;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    background: transparent;
    border-color: rgba(255, 255, 255, 0.65);
}

.authenticated-layout .header-logout-button:hover,
.authenticated-layout .header-logout-button:focus {
    color: #fff;
    background: #f28c00;
    border-color: #f28c00;
}

@media (max-width: 1180px) {
    .authenticated-layout .app-header-nav { display: none; }
}

.authenticated-layout {
    position: relative;
}

.authenticated-layout::before {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 100;
    width: 208px;
    height: 48px;
    background: #fff;
    border-bottom: 1px solid #f0f0f0;
    pointer-events: none;
    content: "";
    transition: width 0.2s ease;
}

.authenticated-layout.sider-collapsed::before {
    width: 48px;
}

/* Retain a compact white sidebar toolbar, but remove ProLayout's duplicate
   dark logo block. The shared header owns the brand. */
.authenticated-layout .ant-pro-sider-logo {
    display: flex !important;
    height: 48px;
    min-height: 48px;
    padding: 0;
    background: #fff !important;
    border-bottom: 1px solid #f0f0f0;
}

.authenticated-layout .ant-pro-sider-logo > a {
    display: none !important;
}

.sider-menu-toggle {
    position: absolute;
    top: 5px;
    left: 165px;
    z-index: 101;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    color: #173f63;
    font-size: 18px;
    background: #fff;
    border: 1px solid #b7c7d6;
    cursor: pointer;
    transition: left 0.2s ease;
}

.sider-menu-toggle:hover,
.sider-menu-toggle:focus-visible {
    color: #0f3150;
    background: #eef6fc;
    border-color: #285a80;
}

.authenticated-layout.sider-collapsed .sider-menu-toggle {
    left: 5px;
}

@media (max-width: 900px) {
    .upload-box {
        justify-items: start;
        justify-content: start;
    }

    .invoice-preview-meta,
    .invoice-preview-parties,
    .customer-filter-form,
    .invoice-filter-form,
    .customer-form-grid,
    .customer-detail-grid {
        grid-template-columns: 1fr;
    }

    .invoice-preview-meta > div,
    .invoice-preview-parties > div + div {
        padding-top: 0.75rem;
        padding-left: 0;
        border-top: 1px solid #e8e8e8;
        border-left: 0;
    }


    .invoice-preview-meta-reference {
        grid-column: auto;
    }

    .customer-filter-actions,
    .invoice-filter-actions,
    .customer-form-actions {
        justify-content: flex-start;
    }
}

.public-tool-page {
    width: 100%;
    margin: 0 auto;
}

.public-tool-page .captcha-widget {
    width: 100%;
    max-width: 300px;
    margin-inline: auto;
}

.public-tools-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin: 0 0 1.5rem;
}

.public-tool-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 1rem;
}

.guest-converter-alert {
    margin: 1rem 0;
}

.guest-converter-complete {
    margin-top: 1rem;
}

.guest-converter-complete .ant-alert {
    width: 100%;
}

@media (max-width: 700px) {
    .public-tool-form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
    .culture-selector {
        width: 116px;
    }

    .login-tenant-row {
        align-items: stretch;
        flex-direction: column;
    }

    .invoice-preview-line {
        grid-template-columns: minmax(0, 1fr) 44px 78px 78px;
        gap: 0.5rem;
        padding: 0.65rem;
    }
}
/* Ant Design adds a sibling margin to consecutive checkbox wrappers. Legal
   document checkboxes are vertical rows and must share the same left edge. */
.legal-document-checkbox.ant-checkbox-wrapper + .legal-document-checkbox.ant-checkbox-wrapper {
    margin-inline-start: 0;
}
