:root {
    color-scheme: light;
    font-family: "Segoe UI", Roboto, sans-serif;
    background: linear-gradient(135deg, #f2f5f9 0%, #e3eef7 100%);
}

/* Blazor Error UI */
#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 5px rgba(0, 0, 0, 0.35);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

#blazor-error-ui .reload {
    color: #0000EE;
    text-decoration: underline;
}

/* Error Boundary Styles */
.error-boundary {
    background-color: #fff5f5;
    border: 2px solid #dc3545;
    border-radius: 8px;
    padding: 2rem;
    margin: 2rem;
    max-width: 800px;
}

.error-boundary h2 {
    color: #dc3545;
    margin-top: 0;
}

.error-boundary pre {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 1rem;
    overflow-x: auto;
    font-size: 0.875rem;
    max-height: 400px;
}

.error-boundary button {
    background-color: #146c94;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
}

.error-boundary button:hover {
    background-color: #0f5470;
}


html,
body {
    height: 100%;
    margin: 0;
    background-color: inherit;
}

body {
    display: flex;
    flex-direction: column;
}

/* Light Theme (default) */
.theme-light {
    background-color: #f2f5f9;
    color: #1a1a1a;
}

.theme-light .app-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 4px solid #c32026;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.theme-light .app-title {
    color: #0e1426;
}

.theme-light .app-subtitle {
    color: #555555;
}

.theme-light .form-pane {
    background: linear-gradient(135deg, #ffffff 0%, #f8fbff 100%);
    border: 1px solid rgba(20, 108, 148, 0.1);
}

.theme-light .text-input,
.theme-light .number-input,
.theme-light input[type="text"],
.theme-light input[type="number"] {
    background-color: #ffffff;
    border-color: #e0e0e0;
    color: #1a1a1a;
}

/* Dark Theme */
.theme-dark {
    background-color: #1e1529;
    color: #f8f7fb;
}

.theme-dark .app-header {
    background: #0e1426;
    border-bottom: 4px solid #c32026;
}

.theme-dark .app-subtitle {
    color: rgba(255, 255, 255, 0.8);
}

.theme-dark .form-pane {
    background: linear-gradient(135deg, #2a1f3d 0%, #3d2f5a 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.theme-dark .text-input,
.theme-dark .number-input,
.theme-dark input[type="text"],
.theme-dark input[type="number"] {
    background: linear-gradient(135deg, #3d2f5a 0%, #4a3768 100%);
    border-color: #5a4577;
    color: #f8f7fb;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.theme-dark .text-input::placeholder,
.theme-dark .number-input::placeholder,
.theme-dark input[type="text"]::placeholder,
.theme-dark input[type="number"]::placeholder {
    color: #9b8bb8;
}

.theme-dark .text-input:hover,
.theme-dark .number-input:hover,
.theme-dark input[type="text"]:hover,
.theme-dark input[type="number"]:hover {
    border-color: #7e6ca0;
    background: #4a3768;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.theme-dark .text-input:focus,
.theme-dark .number-input:focus,
.theme-dark input[type="text"]:focus,
.theme-dark input[type="number"]:focus {
    border-color: #9c85c9;
    background: #4a3768;
    box-shadow: 0 0 0 4px rgba(156, 133, 201, 0.2), 0 4px 12px rgba(0, 0, 0, 0.4);
}

.theme-dark .form-field label {
    color: #c5b3e6;
}

.theme-dark .form-field label::before {
    background: linear-gradient(to bottom, #9c85c9, #c5b3e6);
}

.theme-dark .section-title {
    color: #c5b3e6;
    border-left-color: #c5b3e6;
}

.theme-dark .label-preview {
    background-color: #2a1f3d;
}

.theme-dark .validation-summary {
    background: linear-gradient(135deg, #4a2c3d 0%, #5a3a4d 100%);
}

/* Backwards compatibility for old DevExpress theme names */
body[data-dx-theme="blazing-berry"] {
    background-color: #1e1529;
    color: #f8f7fb;
}

body[data-dx-theme="blazing-berry"] .app-header {
    background: #0e1426;
    border-bottom: 4px solid #c32026;
}

body[data-dx-theme="blazing-berry"] .app-subtitle {
    color: rgba(255, 255, 255, 0.8);
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    gap: 1rem;
    background: #0e1426;
    border-bottom: 4px solid #c32026;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.header-left {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.language-toggle {
    font-size: 1.2rem;
    padding: 0.5rem 1rem;
    min-width: auto;
}

.theme-toggle {
    padding: 0.5rem 1rem;
}

.app-title {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: #ffffff;
    text-transform: uppercase;
    text-shadow: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    outline: none;
    border: none;
}

.app-title:focus {
    outline: none;
}

/* ========================================
   Modern Toolbar Header
   ======================================== */

.app-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1.5rem;
    background: #0e1426;
    border-bottom: 3px solid #c32026;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    flex-shrink: 0;
    gap: 1rem;
    min-height: 56px;
}

.toolbar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.toolbar-logo {
    height: 2.25rem;
    width: auto;
    filter: invert(1) drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.3));
}

.toolbar-titles {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.toolbar-title {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #ffffff;
    text-transform: uppercase;
    line-height: 1.2;
}

.toolbar-subtitle {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: rgba(255, 255, 255, 0.75);
    text-transform: uppercase;
    line-height: 1.2;
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    justify-content: center;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.toolbar-separator {
    width: 1px;
    height: 28px;
    background: rgba(255, 255, 255, 0.2);
    margin: 0 0.5rem;
}

.toolbar-end {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.toolbar-settings {
    margin-left: 0.5rem;
}

.pending-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #dc3545 0%, #e55353 100%);
    color: white;
    padding: 0.35rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
    animation: pulse-pending 1.5s ease-in-out infinite;
}

.cloud-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: linear-gradient(135deg, #0d6efd 0%, #3d8bfd 100%);
    color: white;
    padding: 0.35rem 0.65rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

.cloud-badge .oi {
    font-size: 0.9rem;
}

.cloud-badge-text {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Ribbon Save Status Indicator */
.ribbon-save-status {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.65rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.ribbon-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.ribbon-status-text {
    font-weight: 600;
}

.ribbon-status-time {
    font-size: 0.7rem;
    opacity: 0.8;
    margin-left: 0.25rem;
}

/* Unsaved - Muted red */
.ribbon-save-status.status-unsaved {
    background: rgba(220, 53, 69, 0.2);
    color: rgba(255, 255, 255, 0.9);
}

.ribbon-save-status.status-unsaved .ribbon-status-dot {
    background: #dc3545;
    animation: pulse-ribbon-status 1.5s ease-in-out infinite;
}

/* Local Only - Amber */
.ribbon-save-status.status-local {
    background: rgba(255, 193, 7, 0.25);
    color: rgba(255, 255, 255, 0.95);
}

.ribbon-save-status.status-local .ribbon-status-dot {
    background: #ffc107;
}

/* Cloud Saved - Green */
.ribbon-save-status.status-cloud {
    background: rgba(40, 167, 69, 0.25);
    color: rgba(255, 255, 255, 0.95);
}

.ribbon-save-status.status-cloud .ribbon-status-dot {
    background: #28a745;
}

/* Save Failed - Red with pulse */
.ribbon-save-status.status-failed {
    background: rgba(220, 53, 69, 0.3);
    color: rgba(255, 255, 255, 0.95);
}

.ribbon-save-status.status-failed .ribbon-status-dot {
    background: #dc3545;
    animation: pulse-ribbon-status 0.8s ease-in-out infinite;
}

@keyframes pulse-ribbon-status {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.85); }
}

/* Export/Import actions in ribbon */
.ribbon-export-actions {
    margin-left: 0.5rem;
}

.user-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
    padding: 0.35rem 0.65rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

.user-badge .oi {
    font-size: 0.9rem;
}

.user-badge .user-role {
    font-size: 0.7rem;
    opacity: 0.75;
    font-weight: 400;
}

.login-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    padding: 0.35rem 0.65rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.login-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    text-decoration: none;
}

.login-link .oi {
    font-size: 0.9rem;
}

/* Login button - prominent style for unauthenticated users */
.login-button {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: linear-gradient(135deg, #146c94 0%, #1e88c7 100%);
    color: #ffffff;
    text-decoration: none;
    padding: 0.45rem 0.85rem;
    border-radius: 5px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(20, 108, 148, 0.3);
}

.login-button:hover {
    background: linear-gradient(135deg, #1e88c7 0%, #42a5f5 100%);
    color: #ffffff;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(20, 108, 148, 0.4);
}

.login-button .oi {
    font-size: 0.95rem;
}

/* Logout button */
.logout-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    padding: 0.3rem;
    border-radius: 4px;
    margin-left: 0.3rem;
    transition: all 0.2s ease;
}

.logout-button:hover {
    color: #ff6b6b;
    background: rgba(255, 107, 107, 0.15);
    text-decoration: none;
}

.logout-button .oi {
    font-size: 0.9rem;
}

/* Offline badge for localhost */
.login-badge-offline {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(108, 117, 125, 0.3);
    color: rgba(255, 255, 255, 0.7);
    padding: 0.35rem 0.65rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px dashed rgba(255, 255, 255, 0.3);
}

.login-badge-offline .oi {
    font-size: 0.85rem;
    opacity: 0.8;
}

/* Auth info banner in form pane */
.auth-banner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border: 1px solid #90caf9;
    border-left: 4px solid #1976d2;
    border-radius: 6px;
    color: #1565c0;
    font-size: 0.9rem;
    font-weight: 500;
}

.auth-banner .oi {
    font-size: 1rem;
    flex-shrink: 0;
}

.auth-banner-link {
    margin-left: auto;
    padding: 0.35rem 0.75rem;
    background: #1976d2;
    color: #ffffff;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.auth-banner-link:hover {
    background: #1565c0;
    color: #ffffff;
    text-decoration: none;
}

/* Dark theme support for auth banner */
.theme-dark .auth-banner {
    background: linear-gradient(135deg, #1a237e 0%, #283593 100%);
    border-color: #3949ab;
    border-left-color: #5c6bc0;
    color: #c5cae9;
}

.theme-dark .auth-banner-link {
    background: #5c6bc0;
}

.theme-dark .auth-banner-link:hover {
    background: #7986cb;
}

.lang-button {
    min-width: 40px;
    font-weight: 700;
    letter-spacing: 0.05em;
}

/* Navigation tabs below toolbar */
.app-navigation {
    display: flex;
    align-items: center;
    gap: 0;
    background: #1a2233;
    padding: 0 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.nav-tab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
}

.nav-tab:hover {
    color: rgba(255, 255, 255, 0.95);
    background: rgba(255, 255, 255, 0.05);
}

.nav-tab.active {
    color: #ffffff;
    border-bottom-color: #c32026;
    background: rgba(195, 32, 38, 0.1);
}

.nav-tab .oi {
    font-size: 0.85rem;
}

/* Responsive navigation */
@media (max-width: 640px) {
    .app-navigation {
        padding: 0 0.5rem;
    }

    .nav-tab {
        padding: 0.6rem 0.75rem;
        font-size: 0.8rem;
    }

    .nav-tab span:not(.oi) {
        display: none;
    }
}

/* Toolbar button styling overrides */
.app-toolbar .dxbl-btn {
    font-size: 0.85rem;
    padding: 0.4rem 0.75rem;
}

.app-toolbar .dxbl-btn.dxbl-btn-light {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.9);
}

.app-toolbar .dxbl-btn.dxbl-btn-light:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

.app-toolbar .dxbl-btn.dxbl-btn-light:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.app-toolbar .dxbl-btn.dxbl-btn-primary {
    background: linear-gradient(135deg, #146c94 0%, #1e88c7 100%);
    border: none;
    color: #ffffff;
}

.app-toolbar .dxbl-btn.dxbl-btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #1e88c7 0%, #42a5f5 100%);
}

.app-toolbar .dxbl-btn.dxbl-btn-danger {
    background: linear-gradient(135deg, #dc3545 0%, #e55353 100%);
    border: none;
    color: #ffffff;
    animation: pulse-pending 1.5s ease-in-out infinite;
}

.app-toolbar .dxbl-btn.dxbl-btn-danger:hover:not(:disabled) {
    background: linear-gradient(135deg, #e55353 0%, #f06868 100%);
}

/* Responsive toolbar */
@media (max-width: 1024px) {
    .app-toolbar {
        flex-wrap: wrap;
        padding: 0.5rem 1rem;
        gap: 0.5rem;
    }

    .toolbar-actions {
        order: 3;
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        padding-top: 0.5rem;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    .toolbar-separator {
        display: none;
    }
}

@media (max-width: 640px) {
    .app-toolbar {
        padding: 0.5rem 0.75rem;
    }

    .toolbar-titles {
        display: none;
    }

    .toolbar-logo {
        height: 2rem;
    }

    .app-toolbar .dxbl-btn {
        font-size: 0.8rem;
        padding: 0.35rem 0.5rem;
    }

    .app-toolbar .dxbl-btn .dxbl-btn-text {
        display: none;
    }

    .user-badge span:not(.oi) {
        display: none;
    }
}

.app-logo {
    height: 2.5rem;
    width: auto;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.2));
    transition: filter 0.3s ease;
}

/* Invert logo colors in dark mode since logo is dark */
.theme-dark .app-logo {
    filter: invert(1) drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.2));
}

body[data-dx-theme="blazing-berry"] .app-logo {
    filter: invert(1) drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.2));
}

.app-subtitle {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.app-main {
    flex: 1;
    padding: 2rem 2rem 2rem; /* Added top padding for spacing */
}

/* ========================================
   Ribbon-based Application Layout
   ======================================== */

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Ribbon styling */
.app-ribbon {
    flex-shrink: 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.theme-dark .app-ribbon {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

/* Ribbon pending indicator */
.ribbon-pending-indicator {
    position: absolute;
    top: 0.5rem;
    right: 10rem;
    background: linear-gradient(135deg, #dc3545 0%, #e55353 100%);
    color: white;
    padding: 0.35rem 0.75rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    animation: pulse-pending 1.5s ease-in-out infinite;
    z-index: 100;
}

@keyframes pulse-pending {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Ribbon user info */
.ribbon-user-info {
    position: absolute;
    top: 0.5rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.1);
    color: inherit;
    padding: 0.35rem 0.75rem;
    border-radius: 4px;
    font-size: 0.75rem;
    z-index: 100;
}

.theme-dark .ribbon-user-info {
    background: rgba(255, 255, 255, 0.1);
}

/* Ribbon item pending state */
.ribbon-item-pending {
    animation: pulse-pending 1.5s ease-in-out infinite;
}

/* Splitter container - fills remaining space after toolbar */
.splitter-container {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Main splitter layout */
.main-splitter {
    flex: 1;
    min-height: 0; /* Important for flex child overflow */
    padding: 0.5rem 0.75rem;
}

.main-splitter.dxbl-splitter {
    height: 100% !important;
    flex: 1 !important;
}

.main-splitter .dxbl-splitter-panel {
    overflow: hidden;
}

/* Form pane wrapper inside splitter */
.form-pane-wrapper {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.form-pane-wrapper .form-pane {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-width: 0;
}

/* Preview pane wrapper inside splitter */
.preview-pane-wrapper {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.preview-pane-wrapper .preview-pane {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Splitter separator styling */
.main-splitter .dxbl-splitter-separator {
    background-color: #e0e0e0;
    transition: background-color 0.2s ease;
}

.main-splitter .dxbl-splitter-separator:hover {
    background-color: #146c94;
}

.main-splitter .dxbl-splitter-separator-handle {
    background-color: #999;
    border-radius: 2px;
}

.main-splitter .dxbl-splitter-separator:hover .dxbl-splitter-separator-handle {
    background-color: #ffffff;
}

/* Dark theme support for splitter */
.theme-dark .main-splitter .dxbl-splitter-separator {
    background-color: #3d2f5a;
}

.theme-dark .main-splitter .dxbl-splitter-separator:hover {
    background-color: #9c85c9;
}

.theme-dark .main-splitter .dxbl-splitter-separator-handle {
    background-color: #7e6ca0;
}

.theme-dark .main-splitter .dxbl-splitter-separator:hover .dxbl-splitter-separator-handle {
    background-color: #ffffff;
}

/* Cloud message styling */
.cloud-message {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-weight: 500;
    text-align: center;
}

.cloud-message.text-success {
    background: rgba(40, 167, 69, 0.1);
    border: 1px solid rgba(40, 167, 69, 0.3);
}

.cloud-message.text-danger {
    background: rgba(220, 53, 69, 0.1);
    border: 1px solid rgba(220, 53, 69, 0.3);
}

/* Responsive adjustments for ribbon layout */
@media (max-width: 1024px) {
    .app-container {
        height: auto;
        min-height: 100vh;
        overflow: auto;
    }

    .splitter-container {
        flex: none;
        height: auto;
        overflow: visible;
    }

    /* Stack splitter panes vertically on mobile */
    .main-splitter {
        flex-direction: column !important;
        overflow: visible;
        height: auto;
        flex: none;
    }

    .main-splitter .dxbl-splitter-panel {
        width: 100% !important;
        height: auto !important;
        min-width: 0 !important;
        max-width: none !important;
        flex: none !important;
    }

    /* Hide the splitter separator on mobile */
    .main-splitter .dxbl-splitter-separator {
        display: none !important;
    }

    .form-pane-wrapper,
    .preview-pane-wrapper {
        overflow: visible;
        height: auto;
    }

    .form-pane-wrapper .form-pane {
        overflow: visible;
        max-height: none;
    }

    .preview-pane-wrapper {
        order: -1; /* Preview above form on mobile */
    }

    .preview-pane-wrapper .preview-pane {
        min-height: auto;
        overflow: visible;
    }

    .wz-preview {
        overflow-x: auto;
        overflow-y: visible;
        max-height: none;
    }

    .ribbon-pending-indicator,
    .ribbon-user-info {
        position: static;
        display: inline-block;
        margin: 0.25rem;
    }
}

.page-grid {
    display: grid;
    grid-template-columns: minmax(320px, 440px) minmax(0, 1fr);
    gap: 2rem;
    max-width: 1240px;
    margin: 0 auto;
    align-items: stretch; /* Both panes same height for elegant alignment */
}

.form-pane {
    background: linear-gradient(135deg, #ffffff 0%, #f8fbff 100%);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    box-shadow: 0 10px 30px -15px rgba(18, 43, 70, 0.4);
    border: 1px solid rgba(20, 108, 148, 0.1);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-sizing: border-box; /* Include padding in width calculation */
}

.form-pane::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(to right, #146c94, #1e88c7, #42a5f5);
}

/* Product Grid Container - standalone grid without card wrapper */
.product-grid-container {
    margin-top: 0.75rem;
    border-radius: 6px;
    overflow: hidden;
}

.product-grid-container .dxbl-grid {
    border-radius: 6px;
}

/* Invoice Line Items Grid - Full Width */
.invoice-grid-fullwidth {
    width: 100%;
    overflow: visible;
}

.invoice-grid-fullwidth h4 {
    margin-bottom: 0.5rem;
}

.invoice-line-items-grid {
    width: 100% !important;
    min-height: 200px;
}

.invoice-line-items-grid .dxbl-grid-empty-data-area {
    min-height: 150px;
}

.invoice-line-items-grid .dxbl-grid-wrapper {
    width: 100%;
}

.invoice-line-items-grid .dxbl-grid-table {
    width: 100%;
}

/* Make the grid scroll horizontally when needed */
.invoice-line-items-grid .dxbl-scroll-viewer-content {
    min-width: fit-content;
}

/* Ensure grid header row takes full width */
.invoice-line-items-grid .dxbl-grid-header-row,
.invoice-line-items-grid .dxbl-grid-data-row {
    width: 100%;
}

.preview-pane {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.form-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid rgba(20, 108, 148, 0.1);
}

.form-section:first-of-type {
    margin-top: 2rem;
}

.section-title {
    margin: 0 0 1rem 0;
    font-size: 0.95rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #146c94;
    padding-left: 0.5rem;
    border-left: 4px solid #146c94;
}

/* Form Fields - Elegant Styling */
.form-fields {
    display: flex;
    flex-direction: column;
    gap: 1rem; /* Reduced spacing between data input fields */
    width: 100%; /* Fit within container */
    box-sizing: border-box;
}

.form-field {
    display: flex;
    flex-direction: row; /* Label on the left of input */
    justify-content: flex-start; /* Align like a table */
    align-items: center;
    gap: 0.5rem; /* Reduced gap between label and textbox */
    position: relative;
    width: 100%; /* Ensure full width usage */
}

.form-field label {
    font-size: 0.8rem;
    font-weight: 700;
    color: #146c94;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding-left: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap; /* Prevent label wrapping */
    flex-shrink: 0; /* Prevent label from shrinking */
    width: 150px; /* Fixed width for table-like alignment */
    min-width: 150px;
}

.form-field label::before {
    content: '';
    width: 3px;
    height: 14px;
    background: linear-gradient(to bottom, #146c94, #1e88c7);
    border-radius: 2px;
}

/* Elegant Input Styling */
.text-input,
.number-input,
input[type="text"],
input[type="number"] {
    flex: 1; /* Take remaining space */
    max-width: 100%; /* Fit within container */
    min-width: 0; /* Allow shrinking if needed */
    padding: 0.85rem 1rem;
    font-size: 1rem;
    font-weight: 500;
    border: 2px solid #d6e4ec;
    border-radius: 8px;
    background: linear-gradient(135deg, #ffffff 0%, #f9fcfe 100%);
    box-shadow: 0 2px 4px rgba(20, 108, 148, 0.05);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    color: #2c3e50;
}

.text-input::placeholder,
.number-input::placeholder,
input[type="text"]::placeholder,
input[type="number"]::placeholder {
    color: #95a5a6;
    font-weight: 400;
}

.text-input:hover,
.number-input:hover,
input[type="text"]:hover,
input[type="number"]:hover {
    border-color: #146c94;
    background: #ffffff;
    box-shadow: 0 3px 8px rgba(20, 108, 148, 0.12);
    transform: translateY(-1px);
}

.text-input:focus,
.number-input:focus,
input[type="text"]:focus,
input[type="number"]:focus {
    outline: none;
    border-color: #1e88c7;
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(20, 108, 148, 0.15), 0 4px 12px rgba(20, 108, 148, 0.2);
    transform: translateY(-1px);
}

.text-input:invalid,
.number-input:invalid,
input[type="text"]:invalid,
input[type="number"]:invalid {
    border-color: #dc3545;
}

/* Remove spinner buttons from number inputs for cleaner look */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:not(:disabled):active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, #146c94 0%, #1e88c7 100%);
    color: #ffffff;
}

.btn-primary:not(:disabled):hover {
    background: linear-gradient(135deg, #0f5470 0%, #1570a8 100%);
    box-shadow: 0 4px 12px rgba(20, 108, 148, 0.3);
}

.btn-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #868e96 100%);
    color: #ffffff;
}

.btn-secondary:not(:disabled):hover {
    background: linear-gradient(135deg, #5a6268 0%, #6c757d 100%);
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.3);
}

.btn-success {
    background: linear-gradient(135deg, #28a745 0%, #34ce57 100%);
    color: #ffffff;
}

.btn-success:not(:disabled):hover {
    background: linear-gradient(135deg, #218838 0%, #28a745 100%);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.btn-info {
    background: linear-gradient(135deg, #17a2b8 0%, #20c9e0 100%);
    color: #ffffff;
}

.btn-info:not(:disabled):hover {
    background: linear-gradient(135deg, #138496 0%, #17a2b8 100%);
    box-shadow: 0 4px 12px rgba(23, 162, 184, 0.3);
}

.form-actions-group {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.action-button {
    min-width: 160px;
    font-weight: 600;
    letter-spacing: 0.02em;
    transition: all 0.2s ease;
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem;
}

.print-action-button {
    grid-column: 1 / -1;
    min-width: 200px;
    font-size: 1.05rem;
    font-weight: 700;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.action-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(20, 108, 148, 0.3);
}

.action-button:active {
    transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
    .action-button:hover {
        transform: none;
    }
}

.validation-summary {
    margin-bottom: 1.5rem;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, #fff5f5 0%, #ffe5e5 100%);
    border-left: 5px solid #dc3545;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(220, 53, 69, 0.15);
    font-size: 0.9rem;
    color: #721c24;
    font-weight: 500;
}

.validation-summary ul {
    margin: 0.5rem 0 0;
    padding-left: 1.25rem;
    list-style-type: disc;
}

.validation-summary li {
    margin-bottom: 0.35rem;
}

.label-preview {
    background-color: #ffffff;
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 20px 60px -20px rgba(15, 32, 51, 0.25);
    width: 100%;
    max-width: 650px; /* Adjusted for better 21×10cm proportions */
}

.label-document-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 3mm; /* Match print padding */
    border-bottom: 4px solid #146c94;
    margin-bottom: 3mm; /* Match print margin */
    position: relative;
    z-index: 1;
}

.company-info {
    text-align: center;
    width: 100%;
}

.company-name {
    margin: 0;
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: 0.15em;
    color: #146c94;
    text-transform: uppercase;
    text-shadow: 2px 2px 4px rgba(20, 108, 148, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.company-logo {
    height: 2.5rem;
    width: auto;
    filter: drop-shadow(2px 2px 4px rgba(20, 108, 148, 0.15));
}

.document-type {
    margin: 0.5rem 0 0;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: #555;
    text-transform: uppercase;
}

.header-decoration {
    width: 60%;
    height: 3px;
    background: linear-gradient(to right, transparent, #1e88c7, #146c94, #1e88c7, transparent);
    margin-top: 0.75rem;
    border-radius: 2px;
}

.label-header {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #ffffff;
    background: linear-gradient(135deg, #146c94 0%, #1e88c7 100%);
    padding: 0.75rem 1.5rem;
    border-radius: 12px 12px 0 0;
    margin: -1.5rem -1.5rem 1rem -1.5rem; /* Extend to edges */
    text-align: center;
    box-shadow: 0 4px 12px rgba(20, 108, 148, 0.3);
    position: relative;
    overflow: hidden;
}

.label-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(to right, #42a5f5, #1e88c7, #146c94, #1e88c7, #42a5f5);
}

.label-body {
    background-color: #ffffff;
    border: 3px solid #146c94;
    border-radius: 12px;
    padding: 8mm; /* Closer to print padding of 3mm */
    width: 100%;
    max-width: 630px; /* Max width to maintain 21×10cm proportions */
    aspect-ratio: 210 / 100; /* 21x10cm aspect ratio */
    margin: 0 auto; /* Center the label */
    position: relative;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 5mm; /* Closer to print gap of 4mm */
    box-shadow: inset 0 0 0 1px rgba(20, 108, 148, 0.2);
}

/* Corner indicators removed per user request */

.label-section {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
    position: relative;
    z-index: 1;
    padding-bottom: 3mm; /* Closer to print padding */
    border-bottom: 2px solid #e3f2fd;
}

.label-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.label-section.barcode-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}

.label-section.text-line {
    flex-direction: row;
    align-items: baseline;
    justify-content: flex-start;
    gap: 0.75rem;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.label-section.wide {
    border-bottom: 3px solid #146c94;
    padding-bottom: 4mm; /* Closer to print padding */
}

.label-caption {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #146c94;
    position: relative;
    padding-left: 8px;
}

.label-caption::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 80%;
    background: linear-gradient(to bottom, #146c94, #1e88c7);
    border-radius: 2px;
}

.text-inline {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.4rem;
    width: 45%;
    background: linear-gradient(135deg, #e3f2fd 0%, #ffffff 100%);
    padding: 0.75rem 1rem;
    border-radius: 6px;
    border-left: 4px solid #146c94;
    box-shadow: 0 2px 6px rgba(20, 108, 148, 0.06);
}

.ltg-item-display {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
    width: 45%;
}

.ltg-descriptor {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    padding: 4px 12px;
    border-radius: 4px;
    border-left: 4px solid #146c94;
}

.ltg-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #146c94;
    letter-spacing: 0.03em;
}

.descriptor {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #146c94;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    padding: 4px 12px;
    border-radius: 4px;
    border-left: 4px solid #146c94;
}

.value {
    font-size: 1.4rem;
    font-weight: 700;
    color: #1a1a1a;
    letter-spacing: 0.03em;
}

.barcode-label-text {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #146c94;
    text-align: center;
    margin-bottom: 0.5rem;
    padding: 0.3rem 0;
    border-bottom: 2px solid #146c94;
}

.barcode {
    width: 100%;
    max-width: 100%;
    height: auto;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.08));
}

.barcode-wide {
    height: 72px;
}

.barcode-medium {
    width: 55%;
    height: 66px;
}

.barcode-medium-wide {
    height: 70px;
}

.barcode-block {
    background: #ffffff;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid rgba(20, 108, 148, 0.1);
    box-shadow: 0 2px 8px rgba(20, 108, 148, 0.08);
}

.print-view {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem;
    background-color: #f4f6fb;
    min-height: 100vh;
    box-sizing: border-box;
}

.print-only {
    box-shadow: none;
    padding: 0;
}

/* Accessibility: Enhanced focus states */
.dxbl-text-edit .dxbl-text-edit-input:focus-visible,
.dxbl-btn:focus-visible,
.action-button:focus-visible {
    outline: 3px solid var(--dxbl-primary, #146c94);
    outline-offset: 3px;
    border-radius: 4px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .dxbl-text-edit .dxbl-text-edit-input:focus-visible,
    .dxbl-btn:focus-visible,
    .action-button:focus-visible {
        outline-width: 4px;
    }
}

/* Skip to main content link (for screen readers) */
.skip-to-main {
    position: absolute;
    top: -40px;
    left: 0;
    background: #146c94;
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 100;
}

.skip-to-main:focus {
    top: 0;
}

.dxbl-validation-message,
.validation-message {
    font-size: 0.85rem;
}

.invalid .dxbl-text-edit,
.dxbl-text-edit.invalid {
    border-color: var(--dxbl-text-edit-validation-invalid-color, #d9534f);
}

.invalid .dxbl-text-edit .dxbl-text-edit-input,
.dxbl-text-edit.invalid .dxbl-text-edit-input {
    border-color: var(--dxbl-text-edit-validation-invalid-color, #d9534f);
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Subtle animation for visual appeal */
@keyframes gentlePulse {
    0%, 100% {
        opacity: 0.8;
    }
    50% {
        opacity: 1;
    }
}

.header-decoration {
    animation: gentlePulse 3s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
    .header-decoration {
        animation: none;
    }
}

/* Responsive design */
@media (max-width: 1024px) {
    .page-grid {
        grid-template-columns: 1fr;
    }

    .preview-pane {
        order: -1;
    }

    .label-body {
        aspect-ratio: auto;
        min-height: 720px;
    }
}

@media (max-width: 640px) {
    .app-header {
        padding: 1rem;
    }

    .app-main {
        padding: 1.5rem 1rem 1rem; /* Added top padding to prevent label preview from covering header */
    }

    .form-pane {
        padding: 1rem;
    }

    .label-preview {
        padding: 0.5rem;
        margin-top: 0.5rem; /* Extra margin for better spacing in mobile */
        margin-bottom: 1.5rem; /* Space between preview and form section */
        max-width: 100%;
        box-sizing: border-box;
    }

    .label-body {
        max-width: 100%;
        width: 100%;
        padding: 4mm;
        aspect-ratio: auto; /* Let height adjust naturally on mobile */
        min-height: auto; /* Remove min-height constraint */
        gap: 3mm; /* Tighter gap for mobile */
    }

    .label-document-header {
        padding-bottom: 2mm;
        margin-bottom: 2mm;
    }

    .company-name {
        font-size: 1.5rem;
        gap: 0.5rem;
    }

    .company-logo {
        height: 2rem;
    }

    .label-section {
        gap: 0.2rem;
        padding-bottom: 2mm;
    }

    .label-section.wide {
        padding-bottom: 3mm;
    }

    .label-caption {
        font-size: 0.9rem;
    }

    .barcode-wide {
        height: 50px;
    }

    .barcode-medium {
        height: 45px;
    }

    .barcode-medium-wide {
        height: 48px;
    }

    .text-inline {
        padding: 0.5rem 0.75rem;
    }

    .ltg-value {
        font-size: 1.2rem;
    }

    .descriptor {
        font-size: 0.9rem;
        padding: 3px 10px;
    }

    .value {
        font-size: 1.1rem;
    }

    .barcode-label-text {
        font-size: 1rem;
        margin-bottom: 0.3rem;
    }

    .form-actions-group {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .section-title {
        font-size: 0.85rem;
    }

    .action-button {
        min-width: 140px;
        font-size: 0.9rem;
        padding: 0.5rem 1rem;
    }

    .print-action-button {
        min-width: 100%;
        font-size: 1rem;
        padding: 0.7rem 1.2rem;
    }

    .app-title {
        font-size: 1.5rem;
    }
}

/* ========================================
   Document Mode Banner
   ======================================== */

.document-mode-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    margin-bottom: 0.75rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.document-mode-banner .oi {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.document-mode-banner-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.document-mode-banner-title {
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.document-mode-banner-desc {
    font-size: 0.75rem;
    font-weight: 500;
    opacity: 0.85;
}

.document-mode-banner-wz {
    font-family: "Consolas", "Monaco", monospace;
    background: rgba(0, 0, 0, 0.1);
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    margin-left: 0.35rem;
}

/* New Document Mode - Green */
.document-mode-banner.mode-new {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border: 1px solid #28a745;
    border-left: 4px solid #28a745;
    color: #155724;
}

.document-mode-banner.mode-new .oi {
    color: #28a745;
}

/* Editing Mode - Orange/Amber */
.document-mode-banner.mode-editing {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeeba 100%);
    border: 1px solid #ffc107;
    border-left: 4px solid #e67700;
    color: #856404;
}

.document-mode-banner.mode-editing .oi {
    color: #e67700;
}

/* Dark theme support */
.theme-dark .document-mode-banner.mode-new {
    background: linear-gradient(135deg, #1b4332 0%, #2d6a4f 100%);
    border-color: #40916c;
    color: #95d5b2;
}

.theme-dark .document-mode-banner.mode-new .oi {
    color: #52b788;
}

.theme-dark .document-mode-banner.mode-editing {
    background: linear-gradient(135deg, #5c4a16 0%, #7a6420 100%);
    border-color: #d4a04e;
    color: #f5d87f;
}

.theme-dark .document-mode-banner.mode-editing .oi {
    color: #f5c842;
}

/* ========================================
   WZ Number Locked Field Styling
   ======================================== */

.wz-number-field-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

.wz-number-field-wrapper .dxbl-text-edit {
    flex: 1;
}

.wz-number-locked {
    position: relative;
}

.wz-number-locked .dxbl-text-edit {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%) !important;
    border-style: dashed !important;
}

.wz-number-locked .dxbl-text-edit-input {
    color: #495057 !important;
    font-weight: 600 !important;
}

.lock-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.6rem;
    background: rgba(108, 117, 125, 0.15);
    border-radius: 4px;
    font-size: 0.75rem;
    color: #6c757d;
    white-space: nowrap;
}

.lock-indicator .oi {
    font-size: 0.8rem;
}

.theme-dark .wz-number-locked .dxbl-text-edit {
    background: linear-gradient(135deg, #3d2f5a 0%, #4a3768 100%) !important;
}

.theme-dark .wz-number-locked .dxbl-text-edit-input {
    color: #c5b3e6 !important;
}

.theme-dark .lock-indicator {
    background: rgba(255, 255, 255, 0.1);
    color: #adb5bd;
}

/* ========================================
   Save Status Indicator
   ======================================== */

.save-status-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    margin-top: 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
}

.save-status-indicator {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.save-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.save-status-text {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.save-status-label {
    font-weight: 600;
    font-size: 0.8rem;
}

.save-status-desc {
    font-size: 0.7rem;
    opacity: 0.8;
}

.save-status-timestamp {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-left: auto;
}

.save-status-actions {
    display: flex;
    gap: 0.4rem;
    margin-left: auto;
}

/* Unsaved - Red */
.save-status-bar.status-unsaved {
    background: linear-gradient(135deg, #fff5f5 0%, #ffe0e0 100%);
    border: 1px solid rgba(220, 53, 69, 0.3);
    border-left: 4px solid #dc3545;
    color: #721c24;
}

.save-status-bar.status-unsaved .save-status-dot {
    background: #dc3545;
    animation: pulse-status 1.5s ease-in-out infinite;
}

/* Local Only - Yellow/Amber */
.save-status-bar.status-local {
    background: linear-gradient(135deg, #fff9e6 0%, #fff3cd 100%);
    border: 1px solid rgba(255, 193, 7, 0.4);
    border-left: 4px solid #ffc107;
    color: #856404;
}

.save-status-bar.status-local .save-status-dot {
    background: #ffc107;
}

/* Cloud Saved - Green */
.save-status-bar.status-cloud {
    background: linear-gradient(135deg, #f0fff4 0%, #d4edda 100%);
    border: 1px solid rgba(40, 167, 69, 0.3);
    border-left: 4px solid #28a745;
    color: #155724;
}

.save-status-bar.status-cloud .save-status-dot {
    background: #28a745;
}

/* Save Failed - Red with pulse */
.save-status-bar.status-failed {
    background: linear-gradient(135deg, #fff5f5 0%, #ffe0e0 100%);
    border: 1px solid rgba(220, 53, 69, 0.4);
    border-left: 4px solid #dc3545;
    color: #721c24;
}

.save-status-bar.status-failed .save-status-dot {
    background: #dc3545;
    animation: pulse-status 0.8s ease-in-out infinite;
}

@keyframes pulse-status {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.9); }
}

/* Dark theme save status */
.theme-dark .save-status-bar.status-unsaved {
    background: linear-gradient(135deg, #4a2c3d 0%, #5a3a4d 100%);
    border-color: #dc3545;
    color: #f8d7da;
}

.theme-dark .save-status-bar.status-local {
    background: linear-gradient(135deg, #5c4a16 0%, #6a5518 100%);
    border-color: #ffc107;
    color: #fff3cd;
}

.theme-dark .save-status-bar.status-cloud {
    background: linear-gradient(135deg, #1b4332 0%, #2d6a4f 100%);
    border-color: #40916c;
    color: #d8f3dc;
}

.theme-dark .save-status-bar.status-failed {
    background: linear-gradient(135deg, #4a2c3d 0%, #5a3a4d 100%);
    border-color: #dc3545;
    color: #f8d7da;
}

/* ========================================
   Unlock Choice Dialog Styling
   ======================================== */

.unlock-choice-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

.unlock-choice-option {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #ffffff;
}

.unlock-choice-option:hover {
    border-color: #146c94;
    background: #f8fbff;
    transform: translateX(4px);
}

.unlock-choice-option .oi {
    font-size: 1.25rem;
    color: #146c94;
    margin-top: 0.1rem;
    flex-shrink: 0;
}

.unlock-choice-option-text {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.unlock-choice-option-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: #1a1a1a;
}

.unlock-choice-option-desc {
    font-size: 0.8rem;
    color: #6c757d;
}

.theme-dark .unlock-choice-option {
    background: #2a1f3d;
    border-color: #5a4577;
}

.theme-dark .unlock-choice-option:hover {
    border-color: #9c85c9;
    background: #3d2f5a;
}

.theme-dark .unlock-choice-option .oi {
    color: #9c85c9;
}

.theme-dark .unlock-choice-option-title {
    color: #f8f7fb;
}

.theme-dark .unlock-choice-option-desc {
    color: #9b8bb8;
}

/* Print styles - 21x10cm (210x100mm) label in portrait mode with 3mm margins */
@media print {
    @page {
        size: 210mm 100mm portrait;
        margin: 3mm;
    }

    body {
        background-color: #ffffff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .app-header,
    .form-pane,
    .form-actions,
    .page-grid > .form-pane,
    .page-grid > .form-pane *,
    .action-button,
    .label-header {
        display: none !important;
    }

    .app-main,
    .page-grid,
    .preview-pane,
    .label-preview {
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        border: none !important;
        width: auto !important;
        max-width: none !important;
        background: #ffffff !important;
    }

    .label-body {
        border: 3px solid #146c94 !important;
        width: 100% !important;
        height: 100% !important;
        aspect-ratio: auto !important;
        min-height: auto !important;
        padding: 3mm !important;
        gap: 4mm !important;
        background: #ffffff !important;
        page-break-inside: avoid;
        box-shadow: inset 0 0 0 1px rgba(20, 108, 148, 0.2) !important;
        box-sizing: border-box !important;
        font-size: 0.9em !important;
    }

    /* Corner indicators removed per user request */

    .label-document-header {
        padding-bottom: 3mm !important;
        margin-bottom: 3mm !important;
        border-bottom: 4px solid #146c94 !important;
    }

    .company-name {
        color: #146c94 !important;
        font-size: 1.6rem !important;
        gap: 0.5rem !important;
    }

    .company-logo {
        height: 2rem !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .label-section {
        padding-bottom: 2.5mm !important;
        border-bottom: 2px solid #e3f2fd !important;
        gap: 0.3rem !important;
    }

    .label-section:last-child {
        border-bottom: none !important;
        padding-bottom: 0 !important;
    }

    .label-section.wide {
        border-bottom: 3px solid #146c94 !important;
        padding-bottom: 3.5mm !important;
    }

    .barcode-block {
        background: #ffffff !important;
        border: 1px solid rgba(20, 108, 148, 0.1) !important;
        box-shadow: 0 1px 4px rgba(20, 108, 148, 0.08) !important;
        padding: 0.6rem !important;
    }

    .text-inline {
        background: linear-gradient(135deg, #e3f2fd 0%, #ffffff 100%) !important;
        border-left: 4px solid #146c94 !important;
        box-shadow: 0 1px 3px rgba(20, 108, 148, 0.06) !important;
        padding: 0.5rem 0.75rem !important;
    }

    .ltg-item-display {
        gap: 0.3rem !important;
    }

    .ltg-value {
        font-size: 1.25rem !important;
    }

    .label-caption {
        color: #146c94 !important;
        font-size: 0.95rem !important;
    }

    .label-caption::before {
        width: 3px !important;
    }

    .descriptor {
        color: #146c94 !important;
        background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%) !important;
        border-left: 4px solid #146c94 !important;
        font-size: 0.9rem !important;
        padding: 3px 10px !important;
    }

    .value {
        font-size: 1.15rem !important;
    }

    .header-decoration {
        background: linear-gradient(to right, transparent, #1e88c7, #146c94, #1e88c7, transparent) !important;
        height: 2.5px !important;
    }

    .print-view {
        background-color: #ffffff !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Ensure barcodes print clearly */
    .barcode {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }

    .barcode-wide {
        height: 55px !important;
    }

    .barcode-medium {
        height: 52px !important;
    }

    .barcode-medium-wide {
        height: 54px !important;
    }

    /* Barcode label text print styles */
    .barcode-label-text {
        color: #146c94 !important;
        font-size: 1rem !important;
        border-bottom: 2px solid #146c94 !important;
        margin-bottom: 0.4rem !important;
    }

    /* Ensure text is crisp */
    .label-caption,
    .descriptor,
    .value,
    .barcode-label-text {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* Dark mode print override */
@media print and (prefers-color-scheme: dark) {
    body {
        background-color: #ffffff !important;
    }
}

/* Specific styling for 21x10cm (1/3 A4) labels when using print-one-third-a4 class */
@media print {
    body.print-one-third-a4 {
        /* Ensure 21x10cm page size for PDF generation */
        @page {
            size: 210mm 100mm portrait;
            margin: 3mm;
        }
    }
}

/* =====================================================
   WZ DOCUMENT STYLES - A4 Layout
   ===================================================== */

/* =====================================================
   TABBED INTERFACE STYLES
   ===================================================== */

.wz-tabbed-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
}

.wz-tabs {
    background: transparent;
}

/* Tab header styling */
.wz-tabs .dxbl-tabs-tab-list-wrapper {
    border-bottom: none !important;
}

.wz-tabs .dxbl-tabs-tab-list {
    background: transparent;
    border: none;
    gap: 0.5rem;
    padding: 0;
    margin-bottom: -1px;
}

.wz-tabs .dxbl-tab {
    font-weight: 600;
    letter-spacing: 0.03em;
    padding: 0.85rem 2.5rem;
    transition: all 0.2s ease;
    border: 1px solid rgba(20, 108, 148, 0.2);
    border-bottom: none;
    border-radius: 10px 10px 0 0;
    background: linear-gradient(135deg, #e8f0f5 0%, #f0f4f8 100%);
    color: #146c94;
    margin-bottom: 0;
}

.wz-tabs .dxbl-tab:hover:not(.dxbl-active) {
    background: linear-gradient(135deg, #d0e4f0 0%, #e0eaf2 100%);
    transform: translateY(-2px);
}

.wz-tabs .dxbl-tab.dxbl-active {
    background: linear-gradient(135deg, #ffffff 0%, #f8fbff 100%);
    color: #146c94;
    border-color: rgba(20, 108, 148, 0.2);
    border-bottom: 1px solid #ffffff;
    font-weight: 700;
    position: relative;
    z-index: 1;
}

.wz-tabs .dxbl-tab.dxbl-active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(135deg, #146c94 0%, #1e88c7 100%);
    border-radius: 10px 10px 0 0;
}

/* Tab content panel */
.wz-tabs .dxbl-tabs-panel {
    background: linear-gradient(135deg, #ffffff 0%, #f8fbff 100%);
    border-radius: 0 12px 12px 12px;
    box-shadow: 0 10px 30px -15px rgba(18, 43, 70, 0.4);
    border: 1px solid rgba(20, 108, 148, 0.2);
}

.wz-tab-page {
    /* Styles inherited from panel */
}

/* Data Tab Content */
.wz-data-tab-content {
    padding: 2rem;
    max-width: 1000px;
    margin: 0 auto;
}

.wz-data-tab-content .wz-form-layout {
    width: 100%;
}

/* Preview Tab Content */
.wz-preview-tab-content {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Export Actions Bar */
.wz-export-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
    padding: 1rem;
    background: linear-gradient(135deg, #f0f4f8 0%, #e8f0f5 100%);
    border-radius: 8px;
    border: 1px solid rgba(20, 108, 148, 0.1);
}

/* Full-width Preview */
.wz-preview-full {
    background-color: #5a5a5a;
    border-radius: 12px;
    padding: 1rem;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.3);
    min-height: 600px;
}

.report-viewer-container-full {
    background: #ffffff;
    border-radius: 8px;
    overflow: hidden;
    min-height: 550px;
    max-height: calc(100vh - 250px);
}

.report-viewer-container-full .dxbl-report-viewer {
    height: 100%;
    min-height: 550px;
}

/* Dark theme support for tabs */
.theme-dark .wz-tabs .dxbl-tab {
    background: linear-gradient(135deg, #3d2f5a 0%, #4a3768 100%);
    border-color: rgba(255, 255, 255, 0.15);
    color: #c5b3e6;
}

.theme-dark .wz-tabs .dxbl-tab:hover:not(.dxbl-active) {
    background: linear-gradient(135deg, #4a3768 0%, #5a4577 100%);
}

.theme-dark .wz-tabs .dxbl-tab.dxbl-active {
    background: linear-gradient(135deg, #2a1f3d 0%, #3d2f5a 100%);
    color: #f8f7fb;
    border-bottom-color: #2a1f3d;
}

.theme-dark .wz-tabs .dxbl-tab.dxbl-active::before {
    background: linear-gradient(135deg, #9c85c9 0%, #c5b3e6 100%);
}

.theme-dark .wz-tabs .dxbl-tabs-panel {
    background: linear-gradient(135deg, #2a1f3d 0%, #3d2f5a 100%);
    border-color: rgba(255, 255, 255, 0.15);
}

.theme-dark .wz-export-actions {
    background: linear-gradient(135deg, #3d2f5a 0%, #4a3768 100%);
    border-color: rgba(255, 255, 255, 0.1);
}

.theme-dark .wz-data-tab-content {
    color: #f8f7fb;
}

body[data-dx-theme="blazing-berry"] .wz-tabs .dxbl-tab {
    background: linear-gradient(135deg, #3d2f5a 0%, #4a3768 100%);
    border-color: rgba(255, 255, 255, 0.15);
    color: #c5b3e6;
}

body[data-dx-theme="blazing-berry"] .wz-tabs .dxbl-tab:hover:not(.dxbl-active) {
    background: linear-gradient(135deg, #4a3768 0%, #5a4577 100%);
}

body[data-dx-theme="blazing-berry"] .wz-tabs .dxbl-tab.dxbl-active {
    background: linear-gradient(135deg, #2a1f3d 0%, #3d2f5a 100%);
    color: #f8f7fb;
    border-bottom-color: #2a1f3d;
}

body[data-dx-theme="blazing-berry"] .wz-tabs .dxbl-tab.dxbl-active::before {
    background: linear-gradient(135deg, #9c85c9 0%, #c5b3e6 100%);
}

body[data-dx-theme="blazing-berry"] .wz-tabs .dxbl-tabs-panel {
    background: linear-gradient(135deg, #2a1f3d 0%, #3d2f5a 100%);
    border-color: rgba(255, 255, 255, 0.15);
}

body[data-dx-theme="blazing-berry"] .wz-export-actions {
    background: linear-gradient(135deg, #3d2f5a 0%, #4a3768 100%);
    border-color: rgba(255, 255, 255, 0.1);
}

/* =====================================================
   LEGACY TWO-PANE LAYOUT (kept for reference)
   ===================================================== */

/* WZ Form Layout */
.wz-page-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 1rem;
    align-items: stretch; /* Both panes same height */
}

/* Form pane */
.wz-page-grid .form-pane {
    min-width: 0;
}

/* Preview pane - match form height */
.wz-page-grid .preview-pane {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* Fix DevExpress Grid taking full width */
.wz-page-grid .form-pane .dxbl-grid {
    width: 100%;
}

.wz-page-grid .form-pane .dxbl-fl-ctrl {
    width: 100%;
}

/* WZ Form Pane - Fix grid visibility (same as invoice-form-pane) */
.wz-form-pane {
    padding: 1rem;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Fix WZ grid visibility - override parent overflow:hidden */
.wz-form-pane.form-pane {
    overflow: visible;
    overflow-y: auto;
}

/* Allow grid container to handle its own scrolling */
.wz-form-pane .product-grid-container {
    overflow: visible !important;
    min-height: 200px;
}

/* WZ Line Items Grid */
.wz-line-items-grid {
    width: 100% !important;
    min-height: 200px;
}

.wz-line-items-grid .dxbl-grid-empty-data-area {
    min-height: 150px;
}

/* Ensure grid body/content area is visible */
.wz-form-pane .dxbl-grid-content,
.wz-form-pane .dxbl-grid-table-container {
    min-height: 150px !important;
}

/* Force the scroll viewer to show content */
.wz-form-pane .dxbl-scroll-viewer,
.wz-form-pane .dxbl-scroll-viewer-content {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
}

/* Ensure the grid wrapper doesn't collapse */
.wz-form-pane .dxbl-grid-wrapper {
    min-height: 180px;
    height: auto !important;
}

/* Grid data rows container */
.wz-form-pane .dxbl-grid-table-content {
    display: table-row-group !important;
}

/* A4 Preview Container - grey background simulating desk */
.wz-preview {
    background-color: #5a5a5a;
    border-radius: 8px;
    padding: 0.5rem;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.3);
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Page navigation for multi-page preview */
.wz-page-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.wz-page-nav .page-info {
    font-weight: 600;
    color: #333;
    font-size: 0.9rem;
    min-width: 80px;
    text-align: center;
}

.wz-page-nav .dxbl-btn {
    min-width: auto;
    padding: 0.4rem 0.8rem;
}

/* A4 page container - white paper on grey desk */
.wz-a4-page {
    background: #ffffff;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.2);
    aspect-ratio: 210 / 297; /* A4 proportions */
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    overflow: hidden;
    position: relative;
}

.wz-preview-header {
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.9);
    padding: 0.5rem 1rem;
    margin-bottom: 1rem;
    text-align: center;
}

/* Update Document Container - Centered */
.wz-update-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem 0;
    margin-top: 0.5rem;
}

/* Update Button - Large and prominent */
.btn-update-large {
    padding: 0.75rem 2rem !important;
    font-size: 1.1rem !important;
    font-weight: 600 !important;
    min-width: 180px;
}

/* Update Button - Glowing when changes pending */
.btn-update-pending {
    animation: pulse-attention 1.5s ease-in-out infinite;
    box-shadow: 0 0 0 4px rgba(195, 32, 38, 0.4), 0 0 20px rgba(195, 32, 38, 0.3) !important;
    font-weight: 700 !important;
}

@keyframes pulse-attention {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 4px rgba(195, 32, 38, 0.4), 0 0 20px rgba(195, 32, 38, 0.3);
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 0 0 6px rgba(195, 32, 38, 0.3), 0 0 30px rgba(195, 32, 38, 0.4);
    }
}

/* Grid Action Buttons - slightly bigger icons */
.dxbl-grid .d-flex.gap-1 .dxbl-btn {
    padding: 0.4rem 0.5rem !important;
    min-width: 32px;
    min-height: 32px;
}

.dxbl-grid .d-flex.gap-1 .dxbl-btn .oi {
    font-size: 1rem;
}

/* Empty Grid Template */
.empty-grid-template {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    gap: 1.5rem;
}

.empty-grid-icon {
    font-size: 3rem;
    color: #28a745;
    opacity: 0.7;
}

.empty-grid-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
}

.empty-grid-text {
    margin: 0;
    color: #6c757d;
    font-size: 1rem;
}

/* Report Viewer Container */
.report-viewer-container {
    background: #ffffff;
    border-radius: 6px;
    overflow: hidden;
    flex: 1;
    min-height: 300px;
}

.report-viewer-container .dxbl-report-viewer {
    height: 100%;
}

/* Dark mode fixes for DevExpress Report Viewer */
.theme-dark .report-viewer-container {
    background: #2d2d2d;
}

.theme-dark .dxbl-report-viewer,
.theme-dark .dxbl-report-viewer .dxbl-toolbar,
.theme-dark .dxbl-report-viewer .dxbl-btn-toolbar {
    background-color: #2d2d2d !important;
    color: #e0e0e0 !important;
}

.theme-dark .dxbl-report-viewer .dxbl-toolbar-btn,
.theme-dark .dxbl-report-viewer .dxbl-btn {
    color: #e0e0e0 !important;
}

.theme-dark .dxbl-report-viewer .dxbl-toolbar-btn:hover,
.theme-dark .dxbl-report-viewer .dxbl-btn:hover {
    background-color: #3d3d3d !important;
}

.theme-dark .dxbl-report-viewer .dxbl-dropdown-menu,
.theme-dark .dxbl-report-viewer .dxbl-popup,
.theme-dark .dxbl-report-viewer .dxbl-menu {
    background-color: #2d2d2d !important;
    color: #e0e0e0 !important;
    border-color: #444 !important;
}

.theme-dark .dxbl-report-viewer .dxbl-dropdown-item,
.theme-dark .dxbl-report-viewer .dxbl-menu-item {
    color: #e0e0e0 !important;
}

.theme-dark .dxbl-report-viewer .dxbl-dropdown-item:hover,
.theme-dark .dxbl-report-viewer .dxbl-menu-item:hover {
    background-color: #3d3d3d !important;
}

.theme-dark .dxbl-report-viewer .dxbl-text-edit,
.theme-dark .dxbl-report-viewer .dxbl-spin-edit,
.theme-dark .dxbl-report-viewer input {
    background-color: #3d3d3d !important;
    color: #e0e0e0 !important;
    border-color: #555 !important;
}

.theme-dark .dxbl-report-viewer .dxbl-toolbar-separator {
    background-color: #555 !important;
}

/* Dark mode for report viewer panel/sidebar */
.theme-dark .dxbl-report-viewer .dxbl-side-panel,
.theme-dark .dxbl-report-viewer .dxbl-params-panel,
.theme-dark .dxbl-report-viewer .dxbl-export-options {
    background-color: #2d2d2d !important;
    color: #e0e0e0 !important;
}

.theme-dark .dxbl-report-viewer label,
.theme-dark .dxbl-report-viewer .dxbl-form-label {
    color: #e0e0e0 !important;
}

/* Loading Indicator */
.loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    gap: 1rem;
    color: rgba(255, 255, 255, 0.9);
}

.loading-indicator .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Preview Placeholder */
.wz-preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    min-height: 300px;
}

.wz-preview-placeholder p {
    margin: 0;
    font-size: 1rem;
}

/* WZ Document - scales content to fit A4 preview */
.wz-document {
    background: #ffffff;
    width: 100%;
    height: 100%;
    padding: 6%;
    box-sizing: border-box;
    font-size: 0.55rem;
    line-height: 1.3;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    overflow: hidden;
}

/* WZ Header - Logo and Document Info */
.wz-doc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #146c94;
}

.wz-logo-section {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.wz-logo {
    height: 1.8em;
    width: auto;
}

.wz-company-name {
    font-size: 1.4em;
    font-weight: 700;
    color: #146c94;
    letter-spacing: 0.08em;
}

.wz-doc-meta {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    text-align: right;
    font-size: 0.9em;
}

.wz-meta-row {
    display: flex;
    justify-content: flex-end;
    gap: 0.3rem;
}

.wz-meta-label {
    color: #666;
}

.wz-meta-value {
    font-weight: 600;
    color: #c00;
}

/* WZ Parties - Supplier and Recipient */
.wz-parties {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid #ddd;
}

.wz-party {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.wz-party-label {
    font-size: 0.85em;
    font-weight: 700;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding-bottom: 0.15rem;
    border-bottom: 1px solid #ccc;
}

.wz-party-value {
    font-size: 0.9em;
    color: #c00;
    white-space: pre-line;
    line-height: 1.25;
}

/* WZ Document Title and Info */
.wz-title-section {
    text-align: center;
    padding: 0.3rem 0;
}

.wz-title {
    font-size: 1.3em;
    font-weight: 700;
    letter-spacing: 0.04em;
    margin: 0;
}

.wz-title .wz-date {
    color: #c00;
}

.wz-barcode-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    padding: 0.2rem 0;
}

.wz-barcode-section .wz-barcode {
    max-width: 60%;
    height: auto;
}

.wz-tracking-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    font-size: 0.85em;
    padding: 0.2rem 0;
}

.wz-tracking {
    font-weight: 600;
}

.wz-comment {
    color: #c00;
    font-weight: 600;
}

/* WZ Product Table */
.wz-product-table {
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

.wz-product-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85em;
}

.wz-product-table th,
.wz-product-table td {
    border: 1px solid #bbb;
    padding: 0.2rem 0.3rem;
    text-align: left;
    vertical-align: middle;
}

.wz-product-table th {
    background: #f0f0f0;
    font-weight: 700;
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.wz-product-table .col-lp {
    width: 6%;
    text-align: center;
}

.wz-product-table .col-barcode {
    width: 22%;
}

.wz-product-table .col-name {
    width: 16%;
}

.wz-product-table .col-qty {
    width: 8%;
    text-align: right;
}

.wz-product-table .col-unit {
    width: 8%;
    text-align: center;
}

.wz-product-table .col-pack {
    width: 12%;
    text-align: center;
}

.wz-product-table .grid-barcode {
    width: 100%;
    max-width: 100%;
    height: 2.2em;
}

/* WZ Footer / Signatures */
.wz-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    padding-top: 0.5rem;
    border-top: 1px solid #ccc;
    margin-top: auto;
}

.wz-signature-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
}

.wz-signature-name {
    font-size: 0.9em;
    font-weight: 600;
    color: #c00;
    min-height: 1em;
}

.wz-signature-line {
    width: 100%;
    height: 1px;
    background: #333;
    margin-top: 1.5rem;
}

.wz-signature-label {
    font-size: 0.75em;
    color: #666;
    text-align: center;
    margin-top: 0.15rem;
}

/* =====================================================
   WZ FORM STYLES
   ===================================================== */

.wz-form-section {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 2px solid rgba(20, 108, 148, 0.1);
}

.wz-form-section:first-of-type {
    margin-top: 1rem;
    padding-top: 0;
    border-top: none;
}

.wz-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.wz-form-row.single {
    grid-template-columns: 1fr;
}

.wz-textarea {
    width: 100%;
    min-height: 60px;
    padding: 0.6rem 0.8rem;
    font-size: 0.9rem;
    font-family: inherit;
    border: 2px solid #d6e4ec;
    border-radius: 6px;
    resize: vertical;
    background: linear-gradient(135deg, #ffffff 0%, #f9fcfe 100%);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.wz-textarea:hover {
    border-color: #146c94;
    background: #ffffff;
}

.wz-textarea:focus {
    outline: none;
    border-color: #1e88c7;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(20, 108, 148, 0.15);
}

/* Dark theme support for WZ textarea */
.theme-dark .wz-textarea {
    background: linear-gradient(135deg, #3d2f5a 0%, #4a3768 100%);
    border-color: #5a4577;
    color: #f8f7fb;
}

.theme-dark .wz-textarea:hover {
    border-color: #7e6ca0;
    background: #4a3768;
}

.theme-dark .wz-textarea:focus {
    border-color: #9c85c9;
    background: #4a3768;
    box-shadow: 0 0 0 3px rgba(156, 133, 201, 0.2);
}

/* Product Grid Add Button */
.wz-add-product-btn {
    margin-bottom: 0.75rem;
}

/* =====================================================
   A4 PRINT STYLES
   ===================================================== */

@media print {
    body.print-a4 {
        background: #ffffff !important;
    }

    body.print-a4 .app-header,
    body.print-a4 .form-pane,
    body.print-a4 .wz-preview-header,
    body.print-a4 .wz-page-nav,
    body.print-a4 .form-actions,
    body.print-a4 .action-button {
        display: none !important;
    }

    body.print-a4 .app-main,
    body.print-a4 .wz-page-grid,
    body.print-a4 .preview-pane,
    body.print-a4 .wz-preview,
    body.print-a4 .wz-a4-page {
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        border: none !important;
        width: 100% !important;
        max-width: none !important;
        background: #ffffff !important;
        aspect-ratio: auto !important;
    }

    body.print-a4 .wz-document {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: auto !important;
        border: none !important;
        padding: 10mm !important;
        box-shadow: none !important;
        font-size: 10pt !important;
        gap: 3mm !important;
    }

    body.print-a4 .wz-doc-header {
        padding-bottom: 3mm !important;
        border-bottom-width: 2px !important;
    }

    body.print-a4 .wz-logo {
        height: 2rem !important;
    }

    body.print-a4 .wz-company-name {
        font-size: 1.4rem !important;
    }

    body.print-a4 .wz-doc-meta {
        font-size: 9pt !important;
    }

    body.print-a4 .wz-parties {
        padding: 3mm 0 !important;
        gap: 10mm !important;
    }

    body.print-a4 .wz-party-label {
        font-size: 9pt !important;
    }

    body.print-a4 .wz-party-value {
        font-size: 10pt !important;
    }

    body.print-a4 .wz-title {
        font-size: 14pt !important;
    }

    body.print-a4 .wz-barcode-section .wz-barcode {
        max-width: 50% !important;
        height: 50px !important;
    }

    body.print-a4 .wz-tracking-info {
        font-size: 9pt !important;
    }

    body.print-a4 .wz-product-table table {
        font-size: 9pt !important;
    }

    body.print-a4 .wz-product-table th {
        font-size: 8pt !important;
        padding: 2mm !important;
    }

    body.print-a4 .wz-product-table td {
        padding: 1.5mm 2mm !important;
    }

    body.print-a4 .wz-product-table .grid-barcode {
        height: 30px !important;
    }

    body.print-a4 .wz-product-table .barcode-text {
        font-size: 9pt !important;
    }

    body.print-a4 .wz-product-table {
        page-break-inside: avoid;
    }

    body.print-a4 .wz-footer {
        page-break-inside: avoid;
        padding-top: 5mm !important;
        gap: 20mm !important;
    }

    body.print-a4 .wz-signature-name {
        font-size: 10pt !important;
    }

    body.print-a4 .wz-signature-line {
        margin-top: 15mm !important;
    }

    body.print-a4 .wz-signature-label {
        font-size: 8pt !important;
    }

    body.print-a4 .wz-page-continuation {
        font-size: 11pt !important;
        padding: 3mm 0 !important;
    }

    /* Ensure barcodes print clearly */
    body.print-a4 .wz-barcode,
    body.print-a4 .grid-barcode,
    body.print-a4 svg {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        image-rendering: crisp-edges;
    }
}

/* A4 page size for print-a4 class */
@page {
    body.print-a4 {
        size: A4 portrait;
        margin: 10mm;
    }
}

/* =====================================================
   WZ RESPONSIVE STYLES
   ===================================================== */

/* Continuation page indicator */
.wz-page-continuation {
    text-align: center;
    padding: 0.4rem 0;
    font-size: 1em;
    font-weight: 600;
    color: #666;
    border-bottom: 1px solid #ddd;
    margin-bottom: 0.3rem;
}

.wz-page-continuation .page-num {
    color: #146c94;
    font-weight: 700;
}

/* Product table for continuation pages - more rows fit */
.wz-document.continuation-page .wz-product-table {
    flex: 1;
}

.wz-document.continuation-page {
    gap: 0.3rem;
}

@media (max-width: 1200px) {
    .wz-page-grid {
        grid-template-columns: 1fr;
        max-width: 800px;
        overflow-y: auto;
    }

    .wz-page-grid .preview-pane {
        order: -1; /* Preview above form on mobile */
        overflow: visible;
    }

    .wz-page-grid .form-pane {
        overflow: visible;
    }

    .wz-preview {
        min-height: auto;
        overflow-x: auto;
    }

    .report-viewer-container {
        min-height: 450px;
    }
}

@media (max-width: 640px) {
    .wz-page-grid {
        padding: 0 0.5rem;
    }

    .wz-form-row {
        grid-template-columns: 1fr;
    }

    .wz-preview {
        padding: 1rem;
        max-width: 100%;
    }

    .wz-document {
        font-size: 0.5rem;
        padding: 4%;
    }

    .wz-parties {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .wz-footer {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* Tabbed interface mobile styles */
    .wz-tabbed-container {
        padding: 0 0.5rem;
    }

    .wz-tabs .dxbl-tab {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }

    .wz-data-tab-content {
        padding: 1rem;
    }

    .wz-preview-tab-content {
        padding: 1rem;
    }

    .wz-export-actions {
        flex-direction: column;
        gap: 0.5rem;
    }

    .wz-export-actions .dxbl-btn {
        width: 100%;
    }

    .wz-preview-full {
        min-height: 400px;
        padding: 0.5rem;
    }

    .report-viewer-container-full {
        min-height: 350px;
    }
}



/* Document Picker Styles */
.document-picker-popup .dxbl-popup-body {
    padding: 0;
}

.document-picker {
    padding: 1rem;
}

.document-picker-grid {
    height: 350px;
}

.document-picker-grid .dxbl-grid-table {
    font-size: 0.9rem;
}

/* Dark mode support for document picker */
[data-bs-theme="dark"] .document-picker-popup {
    background: var(--bs-body-bg);
}


.document-picker-searchbox {
    width: 250px;
    min-width: 150px;
    max-width: 300px;
}

/* ============================================
   INVOICE STYLES
   ============================================ */

/* Invoice Form */
.invoice-form-pane {
    padding: 1rem;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Fix invoice grid visibility - override parent overflow:hidden */
.invoice-form-pane.form-pane {
    overflow: visible;
    overflow-y: auto;
}

/* Allow grid container to handle its own scrolling */
.invoice-form-pane .invoice-grid-fullwidth {
    overflow: visible;
    margin-left: -0.5rem;
    margin-right: -0.5rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

/* Ensure invoice grid has proper height and scrolling */
.invoice-form-pane .product-grid-container {
    overflow: visible !important;
    min-height: 200px;
}

.product-grid-container.invoice-grid-fullwidth {
    overflow: visible !important;
}

.invoice-form-pane .invoice-line-items-grid {
    min-height: 200px;
}

/* Ensure grid body/content area is visible */
.invoice-form-pane .dxbl-grid-content,
.invoice-form-pane .dxbl-grid-table-container {
    min-height: 150px !important;
}

/* Force the scroll viewer to show content */
.invoice-form-pane .dxbl-scroll-viewer,
.invoice-form-pane .dxbl-scroll-viewer-content {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
}

/* Ensure the grid wrapper doesn't collapse */
.invoice-form-pane .dxbl-grid-wrapper {
    min-height: 180px;
    height: auto !important;
}

/* Grid data rows container */
.invoice-form-pane .dxbl-grid-table-content {
    display: table-row-group !important;
}

.invoice-form-layout {
    margin-bottom: 1rem;
}

/* Invoice Totals */
.invoice-totals {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
}

.totals-row {
    display: flex;
    justify-content: space-between;
    padding: 0.35rem 0;
    border-bottom: 1px solid #e9ecef;
}

.totals-row:last-child {
    border-bottom: none;
}

.totals-row .amount {
    font-weight: 600;
    font-family: "Consolas", monospace;
}

.totals-row.total-gross {
    font-size: 1.2rem;
    font-weight: 700;
    color: #146c94;
    border-top: 2px solid #146c94;
    margin-top: 0.5rem;
    padding-top: 0.75rem;
}

.totals-row.amount-words {
    font-size: 0.85rem;
    color: #666;
    font-style: italic;
}

.totals-row.amount-words .words {
    text-transform: lowercase;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* Access Denied */
.access-denied-container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: calc(100vh - 120px);
    padding: 2rem;
}

.access-denied-card {
    text-align: center;
    background: #fff;
    padding: 3rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    max-width: 400px;
}

.access-denied-card .oi {
    font-size: 4rem;
    color: #dc3545;
    margin-bottom: 1rem;
}

.access-denied-card h2 {
    margin: 0 0 0.5rem;
    color: #333;
}

.access-denied-card p {
    color: #666;
    margin-bottom: 1.5rem;
}

/* Invoice Preview */
.invoice-preview-container {
    display: flex;
    justify-content: center;
    padding: 1rem;
    overflow: auto;
    height: calc(100% - 60px);
}

.invoice-document {
    background: #fff;
    width: 210mm;
    min-height: 297mm;
    padding: 15mm;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    font-family: "Segoe UI", Arial, sans-serif;
    font-size: 10pt;
    color: #333;
}

/* Invoice Header */
.invoice-header {
    text-align: center;
    margin-bottom: 15mm;
    padding-bottom: 5mm;
    border-bottom: 2px solid #333;
}

.invoice-title {
    font-size: 18pt;
    font-weight: 700;
    letter-spacing: 0.1em;
    margin-bottom: 3mm;
}

.invoice-number {
    font-size: 14pt;
    font-weight: 600;
}

.invoice-original {
    font-size: 10pt;
    font-style: italic;
    color: #666;
}

/* Invoice Dates */
.invoice-dates {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10mm;
    font-size: 9pt;
}

/* Invoice Parties */
.invoice-parties {
    display: flex;
    gap: 10mm;
    margin-bottom: 10mm;
}

.invoice-parties .party {
    flex: 1;
    padding: 5mm;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.party-label {
    font-size: 8pt;
    font-weight: 700;
    text-transform: uppercase;
    color: #666;
    margin-bottom: 2mm;
}

.party-name {
    font-weight: 600;
    font-size: 11pt;
    margin-bottom: 2mm;
}

/* Invoice Table */
.invoice-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 10mm;
    font-size: 9pt;
}

.invoice-table th,
.invoice-table td {
    border: 1px solid #999;
    padding: 2mm 3mm;
    text-align: left;
}

.invoice-table th {
    background: #f0f0f0;
    font-weight: 600;
    font-size: 8pt;
}

.invoice-table td.number {
    text-align: right;
    font-family: "Consolas", monospace;
}

/* VAT Summary */
.vat-summary {
    background: #f8f8f8;
    padding: 5mm;
    margin-bottom: 10mm;
    border-radius: 4px;
}

.vat-summary-title {
    font-weight: 700;
    font-size: 9pt;
    margin-bottom: 3mm;
}

.vat-row {
    display: flex;
    gap: 10mm;
    font-size: 9pt;
    padding: 1mm 0;
}

/* Invoice Total */
.invoice-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14pt;
    font-weight: 700;
    padding: 5mm;
    background: #e8f4f8;
    border-radius: 4px;
    margin-bottom: 5mm;
}

.amount-in-words {
    font-size: 10pt;
    font-style: italic;
    margin-bottom: 10mm;
}

/* Payment Info */
.payment-info {
    margin-bottom: 10mm;
    font-size: 9pt;
}

/* KSeF Placeholder */
.ksef-placeholder {
    display: flex;
    align-items: center;
    gap: 5mm;
    margin-bottom: 10mm;
    padding: 5mm;
    border: 1px dashed #ccc;
    border-radius: 4px;
    background: #fafafa;
}

.qr-placeholder {
    width: 25mm;
    height: 25mm;
    border: 1px solid #ccc;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ksef-text {
    font-size: 8pt;
    color: #999;
    text-align: center;
}

/* Invoice Signatures */
.invoice-signatures {
    display: flex;
    justify-content: space-between;
    margin-top: 15mm;
    padding-top: 5mm;
}

.signature {
    width: 40%;
    text-align: center;
}

.signature-line {
    border-top: 1px solid #333;
    margin-bottom: 2mm;
}

.signature-label {
    font-size: 8pt;
    color: #666;
}

/* Dark mode invoice styles */
.theme-dark .invoice-totals {
    background: #2a2a2a;
}

.theme-dark .totals-row {
    border-bottom-color: #444;
}

.theme-dark .access-denied-card {
    background: #2a2a2a;
}

.theme-dark .access-denied-card h2 {
    color: #fff;
}

.theme-dark .access-denied-card p {
    color: #aaa;
}

/* ============================================
   ADMIN PAGE STYLES
   ============================================ */

.admin-container {
    padding: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
}

.admin-container h2 {
    margin-bottom: 1.5rem;
    color: #333;
}

.admin-tab-content {
    padding: 1rem 0;
    min-height: 400px;
}

.admin-grid {
    border-radius: 8px;
    overflow: hidden;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    color: #666;
}

.empty-state .oi {
    font-size: 4rem;
    opacity: 0.3;
    margin-bottom: 1rem;
}

.empty-state p {
    font-size: 1.1rem;
    margin: 0;
}

/* Dark mode admin styles */
.theme-dark .admin-container h2 {
    color: #fff;
}

.theme-dark .empty-state {
    color: #aaa;
}

/* ============================================
   KSeF Debug Panel Styles
   ============================================ */

.ksef-debug-panel {
    background: #1e1e1e;
    border-top: 3px solid #4a90d9;
    transition: max-height 0.3s ease-out;
    overflow: hidden;
}

.ksef-debug-panel.collapsed {
    max-height: 44px;
}

.ksef-debug-panel.expanded {
    max-height: 600px;
}

.ksef-debug-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: #2d2d2d;
    cursor: pointer;
    user-select: none;
    color: #e0e0e0;
    font-weight: 600;
    font-size: 0.95rem;
}

.ksef-debug-header:hover {
    background: #3d3d3d;
}

.ksef-debug-header .oi {
    font-size: 0.75rem;
    color: #4a90d9;
}

.ksef-debug-header .badge {
    margin-left: auto;
    font-size: 0.75rem;
}

.ksef-debug-header .badge:first-of-type {
    margin-left: auto;
}

.ksef-debug-header .badge + .badge {
    margin-left: 0.5rem;
}

.ksef-debug-content {
    padding: 1rem;
    color: #e0e0e0;
}

/* KSeF Environment Selector */
.ksef-environment-selector {
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.ksef-env-combo {
    min-width: 200px;
    max-width: 250px;
}

.ksef-environment-selector .text-muted {
    font-family: monospace;
}

.ksef-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #3d3d3d;
}

.ksef-tab-content {
    background: #252526;
    border-radius: 4px;
    padding: 1rem;
    max-height: 400px;
    overflow-y: auto;
}

.ksef-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: #666;
    text-align: center;
}

.ksef-placeholder .oi {
    font-size: 3rem;
    opacity: 0.3;
    margin-bottom: 1rem;
}

.ksef-validation-status {
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: #1e1e1e;
    border-radius: 4px;
}

.ksef-validation-status .validation-errors {
    margin: 0.5rem 0 0 0;
    padding-left: 1.5rem;
    color: #f48771;
    font-size: 0.875rem;
}

.xml-preview {
    background: #1e1e1e;
    border: 1px solid #3d3d3d;
    border-radius: 4px;
    padding: 1rem;
    overflow-x: auto;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.8rem;
    line-height: 1.4;
    color: #9cdcfe;
    max-height: 300px;
    margin: 0;
}

.xml-preview code {
    white-space: pre;
}

/* KSeF Log Styles */
.ksef-log {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ksef-log-entry {
    background: #1e1e1e;
    border: 1px solid #3d3d3d;
    border-radius: 4px;
    padding: 0.75rem;
}

.ksef-log-entry .log-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.ksef-log-entry .log-time {
    color: #6a9955;
    font-family: monospace;
    font-size: 0.8rem;
}

.ksef-log-entry .log-operation {
    color: #dcdcaa;
    font-weight: 600;
}

.ksef-log-entry .log-invoice {
    color: #9cdcfe;
    font-size: 0.85rem;
}

.ksef-log-entry .log-details {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: #252526;
    border-radius: 4px;
    font-size: 0.85rem;
    color: #b5cea8;
}

.ksef-log-entry .log-data {
    margin-top: 0.5rem;
}

.ksef-log-entry .log-data summary {
    cursor: pointer;
    color: #569cd6;
    font-size: 0.8rem;
    padding: 0.25rem 0;
}

.ksef-log-entry .log-data pre {
    background: #1e1e1e;
    border: 1px solid #3d3d3d;
    border-radius: 4px;
    padding: 0.5rem;
    margin: 0.5rem 0 0 0;
    font-size: 0.75rem;
    max-height: 150px;
    overflow-y: auto;
    color: #9cdcfe;
}

/* KSeF Status Info */
.ksef-status-info {
    background: #1e1e1e;
    border-radius: 4px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.ksef-status-info .status-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #3d3d3d;
}

.ksef-status-info .status-row:last-child {
    border-bottom: none;
}

.ksef-status-info .status-row .label {
    color: #888;
}

.ksef-status-info .status-row .value {
    font-weight: 600;
}

.ksef-status-info .status-row.error .value {
    color: #f48771;
}

.ksef-environment-info {
    background: #252526;
    border-radius: 4px;
    padding: 1rem;
}

.ksef-environment-info h5 {
    margin: 0 0 0.5rem 0;
    color: #4a90d9;
}

.ksef-environment-info p {
    margin: 0.25rem 0;
    font-size: 0.9rem;
}

/* Light theme overrides for KSeF panel */
.theme-light .ksef-debug-panel {
    background: #f8f9fa;
    border-top-color: #146c94;
}

.theme-light .ksef-debug-header {
    background: #e9ecef;
    color: #1a1a1a;
}

.theme-light .ksef-debug-header:hover {
    background: #dee2e6;
}

.theme-light .ksef-debug-header .oi {
    color: #146c94;
}

.theme-light .ksef-debug-content {
    color: #1a1a1a;
}

.theme-light .ksef-tab-content {
    background: #fff;
    border: 1px solid #dee2e6;
}

.theme-light .ksef-placeholder {
    color: #999;
}

.theme-light .ksef-validation-status {
    background: #f8f9fa;
}

.theme-light .xml-preview {
    background: #f8f9fa;
    border-color: #dee2e6;
    color: #0550ae;
}

.theme-light .ksef-log-entry {
    background: #fff;
    border-color: #dee2e6;
}

.theme-light .ksef-log-entry .log-details {
    background: #f8f9fa;
    color: #1a1a1a;
}

.theme-light .ksef-log-entry .log-data pre {
    background: #f8f9fa;
    border-color: #dee2e6;
    color: #0550ae;
}

.theme-light .ksef-status-info {
    background: #fff;
    border: 1px solid #dee2e6;
}

.theme-light .ksef-status-info .status-row {
    border-color: #dee2e6;
}

.theme-light .ksef-environment-info {
    background: #f8f9fa;
}

.theme-light .ksef-environment-selector {
    border-color: rgba(0, 0, 0, 0.1);
}

.theme-light .ksef-actions {
    border-bottom-color: #dee2e6;
}

/* Recent comment dropdown item */
.recent-comment-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 4px 0;
}

.recent-comment-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recent-comment-delete {
    flex-shrink: 0;
    margin-left: 8px;
    padding: 2px 8px;
    border: none;
    background: transparent;
    color: #999;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    border-radius: 4px;
}

.recent-comment-delete:hover {
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

/* =====================================================
   OCR Page Styles
   ===================================================== */

.ocr-page {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0;
}

.ocr-page .access-denied {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 2rem;
    text-align: center;
    color: #666;
}

.ocr-page .access-denied .oi {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.ocr-page .access-denied h3 {
    margin: 0 0 0.5rem 0;
    color: #333;
}

.ocr-page .access-denied .btn-login {
    margin-top: 1rem;
    padding: 0.75rem 1.5rem;
    background: #146c94;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.ocr-page .access-denied .btn-login:hover {
    background: #0f5470;
}

.ocr-container {
    display: grid;
    grid-template-columns: 1fr 280px 1fr;
    gap: 1rem;
    padding: 1rem;
    height: calc(100vh - 140px);
    overflow: hidden;
}

.ocr-upload-section {
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.ocr-upload-section h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 0.5rem 0;
    font-size: 1.25rem;
    color: #146c94;
}

.ocr-description {
    color: #666;
    margin: 0 0 1rem 0;
    font-size: 0.9rem;
}

.upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    border: 2px dashed #ccc;
    border-radius: 8px;
    background: #f8f9fa;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.upload-area:hover {
    border-color: #146c94;
    background: #f0f7fa;
}

.upload-area.dragging {
    border-color: #146c94;
    background: #e3f2fd;
}

.upload-area .oi {
    font-size: 3rem;
    color: #999;
    margin-bottom: 1rem;
}

.upload-area:hover .oi {
    color: #146c94;
}

.upload-text {
    font-size: 1.1rem;
    color: #333;
    margin-bottom: 0.5rem;
}

.upload-hint {
    font-size: 0.85rem;
    color: #888;
}

.upload-progress {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #146c94;
}

.upload-error {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: #fff5f5;
    border: 1px solid #dc3545;
    border-radius: 6px;
    color: #dc3545;
    font-size: 0.9rem;
}

/* Jobs List Section */
.ocr-jobs-section {
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.jobs-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid #eee;
}

.jobs-header h3 {
    margin: 0;
    font-size: 1rem;
    color: #333;
}

.jobs-loading,
.jobs-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: #888;
    text-align: center;
}

.jobs-empty .oi,
.jobs-loading .oi {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.jobs-list {
    flex: 1;
    overflow-y: auto;
}

.job-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.15s ease;
}

.job-item:hover {
    background: #f8f9fa;
}

.job-item.selected {
    background: #e3f2fd;
}

.job-icon {
    font-size: 1.25rem;
    color: #666;
    width: 28px;
    text-align: center;
}

.job-info {
    flex: 1;
    min-width: 0;
}

.job-name {
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.job-meta {
    display: flex;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: #888;
    margin-top: 2px;
}

.job-status {
    width: 24px;
    text-align: center;
}

.job-item.status-processing .job-status {
    color: #146c94;
}

.job-item.status-completed .job-status {
    color: #28a745;
}

.job-item.status-failed .job-status {
    color: #dc3545;
}

.job-item.status-pending .job-status {
    color: #ffc107;
}

.job-actions .btn-delete {
    padding: 4px 8px;
    background: transparent;
    border: none;
    color: #999;
    cursor: pointer;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.job-item:hover .job-actions .btn-delete {
    opacity: 1;
}

.job-actions .btn-delete:hover {
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

/* Results Section */
.ocr-results-section {
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid #eee;
}

.results-header h3 {
    margin: 0;
    font-size: 1rem;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.results-actions {
    flex-shrink: 0;
}

.results-meta {
    display: flex;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    font-size: 0.85rem;
    color: #666;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.results-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 2rem;
    color: #888;
    text-align: center;
}

.results-placeholder .oi {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.results-processing,
.results-error,
.results-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem;
    text-align: center;
}

.results-processing {
    color: #146c94;
}

.results-error {
    color: #dc3545;
    background: #fff5f5;
}

.results-empty {
    color: #666;
}

.results-text {
    flex: 1;
    overflow: auto;
    padding: 1rem;
}

.results-text pre {
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: "Consolas", "Monaco", monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #333;
}

/* Markdown content in OCR results */
.results-markdown {
    flex: 1;
    overflow: auto;
    padding: 1rem;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #333;
}

.results-markdown h1,
.results-markdown h2,
.results-markdown h3 {
    margin: 1em 0 0.5em 0;
    font-weight: 600;
    color: #222;
}

.results-markdown h1 { font-size: 1.4rem; }
.results-markdown h2 { font-size: 1.2rem; }
.results-markdown h3 { font-size: 1.1rem; }

.results-markdown p {
    margin: 0.5em 0;
}

.results-markdown table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
    font-size: 0.85rem;
}

.results-markdown th,
.results-markdown td {
    border: 1px solid #ddd;
    padding: 0.5rem 0.75rem;
    text-align: left;
    vertical-align: top;
}

.results-markdown th {
    background: #f5f5f5;
    font-weight: 600;
    white-space: nowrap;
}

.results-markdown tr:nth-child(even) {
    background: #fafafa;
}

.results-markdown tr:hover {
    background: #f0f0f0;
}

.results-markdown code {
    font-family: "Consolas", "Monaco", monospace;
    background: #f5f5f5;
    padding: 0.1em 0.3em;
    border-radius: 3px;
    font-size: 0.9em;
}

.results-markdown pre {
    background: #f5f5f5;
    padding: 1em;
    border-radius: 4px;
    overflow-x: auto;
    margin: 1em 0;
}

.results-markdown pre code {
    background: none;
    padding: 0;
}

.results-markdown ul,
.results-markdown ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.results-markdown hr {
    border: none;
    border-top: 1px solid #ddd;
    margin: 1.5em 0;
}

/* Spinning animation */
.spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Dark theme support for OCR page */
.theme-dark .ocr-upload-section,
.theme-dark .ocr-jobs-section,
.theme-dark .ocr-results-section {
    background: #2a1f3d;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.theme-dark .ocr-upload-section h2 {
    color: #c5b3e6;
}

.theme-dark .ocr-description {
    color: #9b8bb8;
}

.theme-dark .upload-area {
    background: #3d2f5a;
    border-color: #5a4577;
}

.theme-dark .upload-area:hover {
    border-color: #9c85c9;
    background: #4a3768;
}

.theme-dark .upload-area.dragging {
    border-color: #c5b3e6;
    background: #4a3768;
}

.theme-dark .upload-text,
.theme-dark .job-name {
    color: #f8f7fb;
}

.theme-dark .upload-hint,
.theme-dark .job-meta {
    color: #9b8bb8;
}

.theme-dark .jobs-header,
.theme-dark .results-header {
    border-bottom-color: #4a3768;
}

.theme-dark .jobs-header h3,
.theme-dark .results-header h3 {
    color: #f8f7fb;
}

.theme-dark .job-item {
    border-bottom-color: #3d2f5a;
}

.theme-dark .job-item:hover {
    background: #3d2f5a;
}

.theme-dark .job-item.selected {
    background: #4a3768;
}

.theme-dark .results-meta {
    background: #3d2f5a;
    border-bottom-color: #4a3768;
    color: #9b8bb8;
}

.theme-dark .results-text pre {
    color: #f8f7fb;
}

.theme-dark .results-markdown {
    color: #f8f7fb;
}

.theme-dark .results-markdown h1,
.theme-dark .results-markdown h2,
.theme-dark .results-markdown h3 {
    color: #c5b3e6;
}

.theme-dark .results-markdown th,
.theme-dark .results-markdown td {
    border-color: #4a3768;
}

.theme-dark .results-markdown th {
    background: #3d2f5a;
}

.theme-dark .results-markdown tr:nth-child(even) {
    background: rgba(74, 55, 104, 0.3);
}

.theme-dark .results-markdown tr:hover {
    background: rgba(74, 55, 104, 0.5);
}

.theme-dark .results-markdown code {
    background: #3d2f5a;
}

.theme-dark .results-markdown pre {
    background: #3d2f5a;
}

.theme-dark .results-markdown hr {
    border-top-color: #4a3768;
}

.theme-dark .upload-error {
    background: rgba(220, 53, 69, 0.15);
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .ocr-container {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto 1fr;
    }

    .ocr-upload-section {
        grid-column: 1 / -1;
    }
}

@media (max-width: 768px) {
    .ocr-container {
        grid-template-columns: 1fr;
        height: auto;
        overflow: visible;
    }

    .ocr-jobs-section,
    .ocr-results-section {
        min-height: 300px;
    }
}

