﻿/* Reset and Base Styles */
:root {
    /* ── Layout heights ─────────────────────────────────────────────────────
       --cx-maintenance-banner-h is overridden to the banner height only while
       a maintenance notice is shown (see MaintenanceBanner.razor); otherwise it
       stays 0px. --cx-app-h is the usable viewport height below that banner and
       MUST be used instead of a raw 100vh for any full-height region, so the
       banner shrinks the app rather than pushing content off-screen. */
    --cx-maintenance-banner-h: 0px;
    --cx-app-h: calc(100vh - var(--cx-maintenance-banner-h));

    /* ── Warm Carpenter Palette ─────────────────────────────────────────── */
    --ink:        #1C1915;
    --ink-2:      #2A251F;
    --walnut:     #4A443C;
    --stone:      #8E8679;
    --sand:       #F0ECE4;
    --sand-2:     #E8E2D4;
    --paper:      #FAF7F2;
    --paper-2:    #F5F1E8;
    --copper:        #B8601F;
    --copper-dark:   #8A4514;
    --copper-light:  #E6A06B;
    --copper-50:     #FBEFE5;
    --copper-100:    #F6DEC6;

    /* ── Color aliases ──────────────────────────────────────────────────── */
    --primary:         var(--copper);
    --primary-dark:    var(--copper-dark);
    --secondary:       var(--ink);
    --secondary-2:     var(--ink-2);
    --light-gray:      var(--sand);
    --medium-gray:     var(--stone);
    --dark-gray:       var(--walnut);
    --hairline:        rgba(28,25,21,0.10);
    --hairline-soft:   rgba(28,25,21,0.05);
    --ink-on-dark:     rgba(255,255,255,0.72);
    --ink-on-dark-2:   rgba(255,255,255,0.50);
    --ai:              #5B4B8A;

    /* ── Semantic colors ────────────────────────────────────────────────── */
    --info-50:    #EEF3FB;
    --success-50: #EAF3EE;
    --warning-50: #FAF1DE;
    --danger-50:  #F7E7E5;
    --ai-50:      #EEEBF5;

    /* ── Radii ──────────────────────────────────────────────────────────── */
    --radius-xs:   2px;
    --radius-sm:   4px;
    --radius-md:   8px;
    --radius-lg:   10px;
    --radius-xl:   12px;
    --radius-2xl:  16px;
    --radius-pill: 999px;

    /* ── Shadows ────────────────────────────────────────────────────────── */
    --shadow-xs: 0 1px 2px rgba(28,25,21,.06);
    --shadow-sm: 0 2px 6px rgba(28,25,21,.08), 0 1px 2px rgba(28,25,21,.04);
    --shadow-md: 0 6px 14px rgba(28,25,21,.10), 0 2px 4px rgba(28,25,21,.06);
    --shadow-lg: 0 14px 28px rgba(28,25,21,.12), 0 6px 10px rgba(28,25,21,.08);
    --shadow-xl: 0 28px 56px rgba(28,25,21,.18), 0 10px 20px rgba(28,25,21,.10);
    --shadow-2xl: 0 44px 88px rgba(28,25,21,.22), 0 16px 32px rgba(28,25,21,.14);
    --shadow-inner: inset 0 1px 2px rgba(28,25,21,.08), inset 0 0 0 1px rgba(28,25,21,.04);
    --shadow-copper:    0 10px 24px rgba(184,96,31,.30), 0 4px 10px rgba(184,96,31,.18);
    --shadow-copper-lg: 0 16px 36px rgba(184,96,31,.32), 0 4px 10px rgba(184,96,31,.20);
    --shadow-blue:      0 10px 24px rgba(31,74,130,.28), 0 4px 10px rgba(31,74,130,.16);
    --shadow-dark-hover: 0 20px 40px rgba(28,25,21,.30);

    /* ── Motion ─────────────────────────────────────────────────────────── */
    --ease:       cubic-bezier(0.25, 0.1, 0.25, 1);
    --transition: 0.3s var(--ease);

    /* ── Typography ─────────────────────────────────────────────────────── */
    --font-display: 'Bricolage Grotesque', 'Archivo', -apple-system, system-ui, sans-serif;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --fs-hero:  clamp(2.75rem, 6vw, 4.5rem);
    --fs-h2:    clamp(2rem, 4.5vw, 3rem);
    --fs-h3:    clamp(1.5rem, 3vw, 2rem);
    --fs-h4:    1.125rem;
    --fs-lead:  clamp(1.125rem, 2.5vw, 1.375rem);
    --fs-body:  1.0625rem;
    --fs-small: 0.9375rem;
    --fs-xs:    0.8125rem;
    --fs-micro: 0.6875rem;

    --fw-light:    300;
    --fw-regular:  400;
    --fw-medium:   500;
    --fw-semibold: 600;
    --fw-bold:     700;
    --fw-xbold:    800;

    --lh-tight: 1.1;
    --lh-body:  1.6;
    --lh-lead:  1.5;

    --tracking-tight:   -0.025em;
    --tracking-tighter: -0.03em;
    --tracking-wide:     0.1em;

    /* ── Brand gradients ────────────────────────────────────────────────── */
    --gradient-brand:       linear-gradient(90deg,  #B8601F, #1F4A82);
    --gradient-brand-135:   linear-gradient(135deg, #B8601F, #1F4A82);
    --gradient-dark-panel:  linear-gradient(135deg, #1C1915 0%, #2A251F 100%);
    --gradient-dark-illust: linear-gradient(135deg, #1C1915, #2A251F);
    --gradient-hero-bg:     linear-gradient(180deg, #FAF7F2 0%, #F5F1E8 50%, #FAF7F2 100%);
    --gradient-success:     linear-gradient(135deg, #3F7D5B, #5DA07A);

    /* ── ERP Shell ──────────────────────────────────────────────────────── */
    --cx-sidebar-bg-2:          #2A251F;
    --cx-sidebar-active-fg:     #E6A06B;
    --cx-sidebar-hover:         rgba(255,255,255,0.06);
    --cx-sidebar-border:        rgba(255,255,255,0.08);
    --cx-sidebar-text:          rgba(255,255,255,0.72);
    --cx-sidebar-text-muted:    rgba(255,255,255,0.45);
    --cx-sidebar-text-hover:    rgba(255,255,255,0.95);
    --cx-card-border:           rgba(28,25,21,0.08);
    --cx-hairline:              rgba(28,25,21,0.10);
    --cx-hairline-soft:         rgba(28,25,21,0.05);
    --cx-primary-soft:          rgba(184,96,31,0.10);
    --cx-topbar-h:              60px;
    --cx-sidebar-w:             248px;
    --cx-sidebar-w-collapsed:   64px;
    --cx-row-h:                 40px;
    --cx-card-pad:              20px;

    /* ── Existing --cx-* tokens (repointed to warm palette) ────────────── */
    --cx-primary: #B8601F;
    --cx-primary-hover: #8A4514;
    --cx-primary-light: rgba(184,96,31,0.10);
    --cx-sidebar-bg: #1C1915;
    --cx-appbar-bg: #ffffff;
    --cx-content-bg: #FAF7F2;
    --cx-card-bg: #ffffff;
    --cx-text-primary: #1C1915;
    --cx-text-secondary: #4A443C;
    --cx-text-muted: #8E8679;
    --cx-text-on-dark: rgba(255,255,255,0.72);
    --cx-text-on-dark-hover: #ffffff;
    --cx-border-color: rgba(28,25,21,0.08);
    --cx-border: rgba(28,25,21,0.08);
    --cx-input-border: rgba(28,25,21,0.12);
    --cx-sidebar-active-bg: rgba(184,96,31,0.18);
    --cx-hover-bg: var(--sand);
    --cx-focus-ring: 0 0 0 3px rgba(184,96,31,0.25);
    --cx-border-radius: var(--radius-md);
    --cx-card-radius: var(--radius-xl);
    --cx-shadow-sm: var(--shadow-xs);
    --cx-shadow: var(--shadow-sm);
    --cx-shadow-md: var(--shadow-md);
    --cx-success: #3F7D5B;
    --cx-danger: #9A3B33;
    --cx-warning: #A97514;
    --cx-info: #1F4A82;

    /* Bootstrap variable bridge — every legacy component reads var(--bs-*).
       Without this remap, Bootstrap defaults to blue and bleeds through the
       warm palette wherever .text-primary, var(--bs-primary), etc. appear. */
    --bs-primary: var(--cx-primary);
    --bs-primary-rgb: 184, 96, 31;
    --bs-secondary: var(--cx-text-secondary);
    --bs-secondary-rgb: 74, 68, 60;
    --bs-success: var(--cx-success);
    --bs-success-rgb: 63, 125, 91;
    --bs-danger: var(--cx-danger);
    --bs-danger-rgb: 154, 59, 51;
    --bs-warning: var(--cx-warning);
    --bs-warning-rgb: 169, 117, 20;
    --bs-info: var(--cx-info);
    --bs-info-rgb: 31, 74, 130;
    --bs-link-color: var(--cx-primary);
    --bs-link-hover-color: var(--cx-primary-hover);
    --bs-light: var(--cx-content-bg-2, #f3efe7);
    --bs-border-color: var(--cx-border);
}

html, body {
    font-family: var(--font-sans);
    font-size: 14px;
    background: var(--cx-content-bg);
    color: var(--cx-text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: clip;
}

/* Reserve space for the maintenance banner by pushing all in-flow content down.
   Padding (unlike margin) never collapses, and position:fixed elements — the
   banner, reconnect modal, loading overlay — ignore it. Defaults to 0px, so the
   layout is untouched when no banner is shown. */
body {
    padding-top: var(--cx-maintenance-banner-h, 0px);
}

/* Textareas wrap, so they never need a horizontal scrollbar. Safari with
   "Show scroll bars: Always" (macOS default when a mouse is connected) draws
   one in empty textareas anyway. */
textarea {
    overflow-x: hidden;
}

a, .btn-link {
    color: var(--cx-primary);
    text-decoration: none;
    transition: color 0.15s ease-in-out;
}

    a:hover, .btn-link:hover {
        color: var(--cx-primary-hover);
        text-decoration: underline;
    }

/* Buttons */
.btn {
    padding: 0.5rem 1rem; /* Adjusted padding */
    border-radius: var(--cx-border-radius);
    font-size: 0.875rem; /* 14px */
    font-weight: 500;
    transition: background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    border: 1px solid transparent;
}

.btn-primary {
    color: #fff;
    background-color: var(--cx-primary);
    border-color: var(--cx-primary);
}

    .btn-primary:hover {
        color: #fff;
        background-color: var(--cx-primary-hover);
        border-color: var(--cx-primary-hover);
    }

.btn-secondary {
    color: var(--cx-text-primary);
    background-color: var(--cx-card-bg);
    border-color: var(--cx-input-border);
}

    .btn-secondary:hover {
        background-color: var(--cx-hover-bg);
        border-color: var(--cx-input-border);
    }

/* Focus Styles */
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus,
.form-control:focus, .form-select:focus, .form-check-input:focus {
    outline: 0;
    box-shadow: var(--cx-focus-ring);
}

/* Form Controls */
.form-control, .form-select {
    border-radius: var(--cx-border-radius);
    border: 1px solid var(--cx-input-border);
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    background-color: var(--cx-card-bg);
    color: var(--cx-text-primary);
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

    .form-control::placeholder {
        color: var(--cx-text-muted);
    }

.form-floating > .form-control-plaintext::placeholder,
.form-floating > .form-control::placeholder {
    color: var(--cx-text-muted);
    text-align: inherit; /* Remove text-align end */
}

.form-floating > .form-control-plaintext:focus::placeholder,
.form-floating > .form-control:focus::placeholder {
    text-align: inherit; /* Remove text-align start */
}

.form-label, label {
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    color: var(--cx-text-secondary);
}

/* Validation */
.valid.modified:not([type=checkbox]) {
    outline: none;
    border-color: var(--cx-success);
}

.invalid {
    outline: none;
    border-color: var(--cx-danger);
}

.validation-message {
    color: var(--cx-danger);
    font-size: 0.75rem; /* 12px */
    margin-top: 0.25rem;
}

/* Blazor Error Boundary */
.blazor-error-boundary {
    background: #fff0f0; /* Lighter red background */
    color: var(--cx-danger);
    padding: 1rem;
    border: 1px solid var(--cx-danger);
    border-radius: var(--cx-border-radius);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

    .blazor-error-boundary::before {
        content: "\F3E7"; /* Bootstrap Icons Exclamation Triangle Fill */
        font-family: 'bootstrap-icons';
        font-size: 1.5rem;
    }

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

/* Checkbox */
.darker-border-checkbox.form-check-input {
    border-color: var(--cx-input-border);
}

.form-check-input {
    border-color: var(--cx-input-border);
}

/* Content Padding */
.content {
    padding-top: 1rem; /* Adjusted padding */
}

h1:focus {
    outline: none;
}

/* == Start: Styles from site.css == */

/* Document tab styles */
.document-tab-container {
    position: relative;
    padding: 1rem;
}

.document-drag-area {
    position: relative;
    min-height: 300px;
    border: 2px dashed var(--cx-input-border); /* Use variable */
    border-radius: var(--cx-border-radius); /* Use variable */
    background-color: var(--cx-hover-bg); /* Lighter background */
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

    .document-drag-area:hover {
        border-color: var(--cx-primary);
        background-color: #eef2ff; /* Light blueish background on hover */
    }

.document-drop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.95);
    border: 3px dashed var(--cx-primary); /* Use variable */
    border-radius: var(--cx-border-radius); /* Use variable */
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

    .document-drop-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    .document-drop-overlay .drop-content {
        text-align: center;
    }

    .document-drop-overlay .oi,
    .document-drop-overlay .bi { /* Also support bootstrap icons */
        font-size: 3rem;
        color: var(--cx-primary); /* Use variable */
        margin-bottom: 1rem;
    }

    .document-drop-overlay p {
        font-size: 1.1rem; /* Slightly smaller */
        color: var(--cx-text-primary); /* Use variable */
    }

/* == End: Styles from site.css == */


/* == Start: Onboarding Styles (Kept separate for clarity) == */
.onboarding-container {
    max-width: 700px; /* Slightly narrower */
    margin: 2rem auto;
    padding: 2rem;
    background-color: var(--cx-card-bg);
    border-radius: var(--cx-border-radius);
    box-shadow: var(--cx-shadow);
    font-family: inherit; /* Use base font */
    color: var(--cx-text-primary);
}

.loading-spinner {
    text-align: center;
    font-size: 1rem;
    color: var(--cx-text-secondary);
    padding: 2rem;
}

.error-message {
    padding: 1rem;
    border: 1px solid var(--cx-danger);
    background-color: #fee2e2; /* Lighter red */
    color: #b91c1c; /* Darker red text */
    border-radius: var(--cx-border-radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

/* Step layout */
.step {
    display: flex;
    flex-direction: column;
    gap: 1.5rem; /* Increased gap */
    animation-duration: 0.3s;
    animation-fill-mode: both;
}

.fade-in {
    animation-name: fadeIn;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px); /* Increased effect */
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Basic form styling within onboarding */
.onboarding-container .form-group {
    margin-bottom: 1.25rem;
}

    .onboarding-container .form-group label {
        display: block;
        margin-bottom: 0.5rem;
        font-weight: 500;
        color: var(--cx-text-secondary);
    }

.onboarding-container .form-control {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--cx-input-border);
    border-radius: var(--cx-border-radius);
    background-color: var(--cx-card-bg);
}

/* Buttons within onboarding */
.onboarding-container .button-row {
    display: flex;
    justify-content: space-between;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--cx-border-color);
}

.onboarding-container .btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--cx-border-radius);
    cursor: pointer;
    font-size: 0.875rem;
}

.onboarding-container .btn-primary {
    background-color: var(--cx-primary);
    color: #fff;
}

    .onboarding-container .btn-primary:hover {
        background-color: var(--cx-primary-hover);
    }

.onboarding-container .btn-secondary {
    background-color: var(--cx-hover-bg);
    color: var(--cx-text-primary);
    border: 1px solid var(--cx-input-border);
}

    .onboarding-container .btn-secondary:hover {
        background-color: var(--cx-border-color); /* Slightly darker hover */
    }

/* Show a small red asterisk on required labels */
label.required::after {
    content: " *";
    color: var(--cx-danger);
    margin-left: 2px;
}

/* == End: Onboarding Styles == */

/* --- Page List Root --- */
/* Ensures no extra padding from the component root itself */
.customer-list-page,
.partner-list-page,
.supplier-list-page {
    padding: 0 !important; /* Use !important cautiously, but often needed for ::deep overrides */
}

/* --- Total Counter Badge --- */
.total-counter {
    display: inline-flex;
    align-items: center;
    background-color: #eef2ff; /* Light background, consider var(--cx-hover-bg) or a specific light primary */
    color: var(--cx-primary); /* Primary text color */
    padding: 0.4rem 0.8rem; /* Adjusted padding */
    border-radius: var(--cx-border-radius);
    font-weight: 500;
    font-size: 0.85rem; /* Slightly smaller */
}

    .total-counter .bi { /* Style icon inside */
        margin-right: 0.5rem;
        font-size: 1rem;
    }

/* --- Loading Container --- */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    min-height: 300px; /* Ensure it takes some space */
    text-align: center;
}

.loading-text {
    color: var(--cx-text-secondary);
    margin-top: 0.75rem;
    font-size: 0.9rem;
}
/* Optional: Style the spinner itself if needed */
.loading-container .e-spinner-pane .e-material-spinner {
    /* stroke: var(--cx-primary); */ /* Example: Change spinner color */
}


/* --- Empty Grid Template --- */
.empty-grid {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
    min-height: 300px; /* Ensure it takes some space */
}

    .empty-grid .empty-icon {
        font-size: 3rem;
        color: #cbd5e1;
        margin-bottom: 1rem;
    }

    .empty-grid h5 {
        font-size: 1.05rem; /* Slightly smaller heading */
        font-weight: 600;
        margin-bottom: 0.5rem;
        color: var(--cx-text-primary);
    }

    .empty-grid p {
        font-size: 0.9rem;
        color: var(--cx-text-secondary);
        max-width: 350px; /* Limit paragraph width */
    }

/* --- Grid Action Buttons (Common Style) --- */
.grid-actions {
    display: flex;
    justify-content: center; /* Or flex-start / flex-end as needed */
    align-items: center;
    gap: 4px; /* Reduced gap */
}

.grid-action-button {
    width: 30px; /* Slightly smaller */
    height: 30px;
    border-radius: var(--cx-border-radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0; /* Prevent shrinking */
    border: none;
    background-color: transparent;
    color: var(--cx-text-muted); /* Muted default color */
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
    padding: 0; /* Remove padding if icon is centered */
}

    .grid-action-button i,
    .grid-action-button span.bi { /* Target icon */
        font-size: 1rem; /* Adjust icon size */
        line-height: 1; /* Ensure icon is centered vertically */
    }

    .grid-action-button:hover {
        background-color: var(--cx-hover-bg);
        color: var(--cx-primary);
    }
    /* Specific hover for delete */
    .grid-action-button.delete:hover {
        background-color: #fee2e2; /* Light danger bg */
        color: var(--cx-danger);
    }
    /* You can add .view:hover, .edit:hover if you want different hover colors */
    .grid-action-button.view:hover,
    .grid-action-button.edit:hover {
        background-color: #eef2ff; /* Light primary bg */
        color: var(--cx-primary);
    }


/* --- Dialog Footer --- */
.dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding-top: 1rem; /* Add some space above */
}

/* --- General Link Styling in Grids --- */
.grid-cell-link {
    color: var(--cx-primary);
    text-decoration: none;
    font-weight: 500; /* Make links slightly bolder */
}

    .grid-cell-link:hover {
        text-decoration: underline;
        color: var(--cx-primary-hover);
    }

.grid-cell-muted {
    color: var(--cx-text-muted);
    font-style: italic;
}

/* --- Syncfusion grid styling --- */
/* Remove outer container borders but allow internal grid lines */
.e-grid {
    border: none !important;
    box-shadow: none !important;
}

.e-grid .e-gridheader {
    border: none !important;
    border-bottom: 1px solid #e5e7eb !important;
}

.e-grid .e-gridcontent {
    border: none !important;
}

.e-grid .e-gridpager {
    border: none !important;
}

.e-grid .e-pagercontainer {
    border-color: transparent !important;
}

/* Light grid lines for cells and header */
.e-grid .e-headercell,
.e-grid .e-rowcell {
    border-color: #f0f0f0 !important;
}

.e-grid .e-headercontent {
    border-color: #e5e7eb !important;
}

/* Keep light grid lines visible on hover */
.e-grid.e-gridhover tr.e-row:hover .e-rowcell {
    border-color: #f0f0f0 !important;
}

/* Apply these styles to specific grid containers if needed */
.modern-grid-container .e-grid,
.customer-list-page .e-grid,
.partner-list-page .e-grid,
.supplier-list-page .e-grid {
    border: none !important;
    border-radius: 0 !important;
}

/* Remove borders from grid toolbar and search containers */
.e-grid .e-toolbar,
.e-grid .e-toolbar-items,
.e-grid .e-toolbar-item,
.e-grid .e-tbar-btn,
.e-grid .e-searchbar {
    border: none !important;
    border-top: none !important;
    border-bottom: none !important;
}

/* Badge styles for ItemType column */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 0.375rem;
    color: #fff;
}

.badge-primary {
    background-color: var(--cx-primary);
}

.badge-warning {
    background-color: var(--cx-warning);
    color: #000;
}

.badge-success {
    background-color: var(--cx-success);
}

.badge-info {
    background-color: var(--cx-info);
}

.badge-secondary {
    background-color: var(--cx-text-secondary);
}

/* Fix main content overflow issue on invoice review page - only for pages with sidebar */
.main-content:not(.full-width) {
    max-width: calc(100vw - 240px);
    overflow-x: hidden;
}

.main-content.sidebar-collapsed:not(.full-width) {
    max-width: calc(100vw - 72px);
}

/* Ensure container-fluid doesn't exceed viewport */
.container-fluid {
    max-width: 100%;
    overflow-x: hidden;
}

/* Invoice Review Dialog improvements */
.dialog-form-actions .calculated-total-display {
    padding: 0.75rem 1rem;
    background-color: rgba(var(--cx-success), 0.1);
    border-radius: var(--cx-border-radius);
    border-left: 3px solid var(--cx-success);
}

.action-buttons .action-button {
    min-width: 120px;
    padding: 0.5rem 1.5rem;
    font-weight: 500;
}

/* Ensure lists display properly inside all RTE content areas */
.e-richtexteditor .e-rte-content .e-content ul {
    list-style-type: disc;
    padding-left: 1.5rem;
}
.e-richtexteditor .e-rte-content .e-content ol {
    list-style-type: decimal;
    padding-left: 1.5rem;
}
.e-richtexteditor .e-rte-content .e-content li {
    display: list-item;
}

/* Remove scrollbars from InvoiceDetailForm and improve layout */
.invoice-details-form,
.invoice-details-form .form-content,
.invoice-details-form .e-content {
    overflow-x: hidden !important;
    overflow-y: visible !important;
    max-height: none !important;
}

/* Improve form field spacing */
.invoice-details-form .mb-3 {
    margin-bottom: 1rem !important;
}

.invoice-details-form .form-label {
    margin-bottom: 0.25rem;
    font-weight: 500;
}

/* Remove horizontal scrollbars from line items grid */
.line-items-grid .e-grid,
.invoice-validation-grid .e-grid {
    max-width: 100%;
    box-sizing: border-box;
}

/* Description column should be flexible */
.line-items-grid .e-grid td[data-field="Description"],
.invoice-validation-grid .e-grid td[data-field="Description"] {
    max-width: 200px;
    word-wrap: break-word;
    white-space: normal !important;
}

/* Improve splitter pane layout to prevent overflow */
.invoice-validation-splitter .e-split-pane {
    overflow-x: hidden !important;
}

/* ContactSidebar Styles - Clean implementation using working .e-sidebar.contact-sidebar selector */
.e-sidebar.contact-sidebar {
    border-left: 3px solid var(--cx-primary);
    border-radius: 12px 0 0 12px;
    box-shadow: -10px 0 28px rgba(28,25,21,0.14);
    background: var(--cx-card-bg);
    overflow: hidden !important; /* No scrollbar on the sidebar itself */
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    position: relative !important; /* For absolute positioned footer */
}

/* Ensure Syncfusion's sidebar wrapper doesn't add scrollbars */
.e-sidebar-wrapper {
    overflow: hidden !important;
}

/* Hide all scrollbars in the sidebar */
.e-sidebar::-webkit-scrollbar,
.e-sidebar *::-webkit-scrollbar,
.contact-sidebar::-webkit-scrollbar,
.contact-sidebar *::-webkit-scrollbar {
    display: none !important;
}

/* Header styling - multiple selectors for reliability */
.e-sidebar.contact-sidebar .sidebar-header,
.contact-sidebar .sidebar-header {
    background: linear-gradient(135deg, var(--cx-primary) 0%, var(--cx-primary-hover) 100%) !important;
    color: white !important;
    padding: 18px 24px !important; /* Reduced from 24px to 18px for less height */
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    position: absolute !important; /* Changed to absolute */
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 10 !important;
    height: 60px !important; /* Fixed height to match content positioning */
}

.e-sidebar.contact-sidebar .sidebar-header h3,
.contact-sidebar .sidebar-header h3 {
    color: white !important;
    margin: 0 !important;
    font-weight: 700 !important;
    font-size: 1.375rem !important;
    letter-spacing: -0.025em !important;
}

.e-sidebar.contact-sidebar .sidebar-header .close-btn,
.contact-sidebar .sidebar-header .close-btn {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: white !important;
    font-size: 1.1rem !important;
    width: 36px !important;
    height: 36px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    backdrop-filter: blur(10px) !important;
}

.e-sidebar.contact-sidebar .sidebar-header .close-btn:hover,
.e-sidebar.contact-sidebar .sidebar-header .close-btn:focus,
.contact-sidebar .sidebar-header .close-btn:hover,
.contact-sidebar .sidebar-header .close-btn:focus {
    background: rgba(255, 255, 255, 0.2) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
    transform: scale(1.05) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

.e-sidebar.contact-sidebar .sidebar-content {
    position: absolute !important; /* Position absolute to control exact placement */
    top: 60px !important; /* Below header (adjust based on header height) */
    bottom: 76px !important; /* Above footer (adjust based on footer height) */
    left: 0 !important;
    right: 0 !important;
    padding: 24px !important; /* Using padding instead of margin as requested */
    overflow-y: auto !important;
    overflow-x: hidden !important; /* Disable horizontal scrollbar */
    scrollbar-width: none !important; /* Hide scrollbar for Firefox */
    -ms-overflow-style: none !important; /* Hide scrollbar for IE and Edge */
    background: var(--paper);
}


/* Additional padding selectors to ensure it applies */
.contact-sidebar .sidebar-content {
    position: absolute !important;
    top: 60px !important; /* Below header */
    bottom: 76px !important; /* Above footer */
    left: 0 !important;
    right: 0 !important;
    padding: 24px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important; /* Disable horizontal scrollbar */
    scrollbar-width: none !important; /* Hide scrollbar for Firefox */
    -ms-overflow-style: none !important; /* Hide scrollbar for IE and Edge */
}


/* Remove extra padding from form since .sidebar-content already has it */
.contact-sidebar form,
.e-sidebar.contact-sidebar form {
    padding: 0 !important; /* Remove double padding */
    overflow: visible !important; /* Let parent handle scrolling */
}

/* Ensure the entire sidebar doesn't have horizontal scroll */
.contact-sidebar,
.e-sidebar.contact-sidebar {
    overflow-x: hidden !important;
}


/* Footer styling - multiple selectors for reliability */
.e-sidebar.contact-sidebar .sidebar-footer,
.contact-sidebar .sidebar-footer {
    background: var(--paper-2) !important;
    border-top: 1px solid var(--cx-card-border) !important;
    padding: 20px 24px !important;
    display: flex !important;
    justify-content: flex-end !important;
    gap: 12px !important;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05) !important;
    position: absolute !important; /* Changed from sticky to absolute */
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 10 !important;
}

/* Force footer buttons into a row */
.e-sidebar.contact-sidebar .sidebar-footer,
.contact-sidebar .sidebar-footer {
    flex-direction: row !important;
}

.e-sidebar.contact-sidebar .sidebar-footer .e-btn,
.contact-sidebar .sidebar-footer .e-btn {
    width: auto !important;
    flex: 0 0 auto !important;
}

/* Essential Form Styling - ContactForm depends on these - More specific selectors */
.contact-sidebar .form-row,
.e-sidebar.contact-sidebar .form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 16px;
}

.contact-sidebar .form-group,
.e-sidebar.contact-sidebar .form-group {
    flex: 1;
    min-width: 200px;
    margin-bottom: 16px;
}

.contact-sidebar .form-group.wide,
.e-sidebar.contact-sidebar .form-group.wide {
    flex-basis: 100%;
}

.contact-sidebar label,
.e-sidebar.contact-sidebar label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--cx-text-secondary);
}

.contact-sidebar .form-control,
.e-sidebar.contact-sidebar .form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--cx-input-border);
    border-radius: var(--radius-md);
    font-size: 14px;
    transition: border-color 0.2s;
    background: var(--cx-card-bg);
    color: var(--cx-text-primary);
}

.contact-sidebar .form-control:focus,
.e-sidebar.contact-sidebar .form-control:focus {
    border-color: var(--cx-primary);
    outline: 0;
    box-shadow: var(--cx-focus-ring);
}

.contact-sidebar .input-validation-error,
.e-sidebar.contact-sidebar .input-validation-error {
    border-color: var(--cx-danger);
}

.contact-sidebar .validation-message,
.e-sidebar.contact-sidebar .validation-message {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--cx-danger);
}

/* Essential Tab Styling - ContactForm depends on these - More specific selectors */
.contact-sidebar .tabs,
.e-sidebar.contact-sidebar .tabs {
    margin-top: 24px;
}

.contact-sidebar .tab-header,
.e-sidebar.contact-sidebar .tab-header {
    display: flex;
    overflow-x: auto;
    border-bottom: 1px solid var(--cx-card-border);
    margin-bottom: 16px;
}

.contact-sidebar .tab-link,
.e-sidebar.contact-sidebar .tab-link {
    padding: 10px 16px;
    background: none;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    font-weight: 500;
    color: var(--cx-text-muted);
    transition: all 0.2s;
}

.contact-sidebar .tab-link:hover,
.e-sidebar.contact-sidebar .tab-link:hover {
    color: var(--cx-primary);
}

.contact-sidebar .tab-link.active,
.e-sidebar.contact-sidebar .tab-link.active {
    color: var(--cx-primary);
    border-bottom: 2px solid var(--cx-primary);
}

.contact-sidebar .tab-content,
.e-sidebar.contact-sidebar .tab-content {
    display: none !important;
    padding: 8px 0;
}

.contact-sidebar .tab-content.active,
.e-sidebar.contact-sidebar .tab-content.active {
    display: block !important;
}

/* Additional styling for ContactForm elements - More specific selectors */
.contact-sidebar .btn-link,
.e-sidebar.contact-sidebar .btn-link {
    background: none;
    border: none;
    color: var(--cx-primary);
    cursor: pointer;
    padding: 8px 0;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
}

.contact-sidebar .btn-link:hover,
.e-sidebar.contact-sidebar .btn-link:hover {
    color: var(--cx-primary-hover);
    text-decoration: underline;
}

.contact-sidebar .additional-addresses,
.contact-sidebar .contact-persons,
.e-sidebar .additional-addresses,
.e-sidebar.contact-sidebar .contact-persons {
    margin-top: 24px;
}

.contact-sidebar .address-card,
.contact-sidebar .contact-person-card,
.e-sidebar .address-card,
.e-sidebar.contact-sidebar .contact-person-card {
    border: 1px solid var(--cx-card-border);
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    overflow: hidden;
    transition: box-shadow 0.2s;
    background: var(--cx-card-bg);
}

.contact-sidebar .address-card:hover,
.contact-sidebar .contact-person-card:hover,
.e-sidebar .address-card:hover,
.e-sidebar.contact-sidebar .contact-person-card:hover {
    box-shadow: var(--shadow-sm);
}

.contact-sidebar .address-card-header,
.contact-sidebar .contact-person-header,
.e-sidebar .address-card-header,
.e-sidebar.contact-sidebar .contact-person-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background-color: var(--paper-2);
    border-bottom: 1px solid var(--cx-card-border);
}

.contact-sidebar .address-card-header h6,
.contact-sidebar .contact-person-header h6,
.e-sidebar .address-card-header h6,
.e-sidebar.contact-sidebar .contact-person-header h6 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--cx-text-secondary);
}

.contact-sidebar .address-card-body,
.contact-sidebar .contact-person-body,
.e-sidebar .address-card-body,
.e-sidebar .contact-person-body {
    padding: 16px;
}

.contact-sidebar .btn-delete,
.e-sidebar.contact-sidebar .btn-delete {
    background: none;
    border: none;
    color: var(--cx-danger);
    cursor: pointer;
    font-size: 16px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.contact-sidebar .btn-delete:hover,
.e-sidebar.contact-sidebar .btn-delete:hover {
    background-color: var(--danger-50);
}

.contact-sidebar input[readonly],
.e-sidebar.contact-sidebar input[readonly] {
    background-color: var(--paper-2);
    cursor: not-allowed;
}

.contact-sidebar input[readonly]::placeholder,
.e-sidebar.contact-sidebar input[readonly]::placeholder {
    color: var(--cx-text-muted);
    font-style: italic;
}

/* Contact Methods Tab */
.contact-sidebar .contact-method-card,
.e-sidebar.contact-sidebar .contact-method-card {
    border: 1px solid var(--cx-card-border);
    border-radius: var(--radius-lg);
    margin-bottom: 12px;
    padding: 12px 16px;
    background-color: var(--cx-card-bg);
    transition: box-shadow 0.2s;
}

.contact-sidebar .contact-method-card:hover,
.e-sidebar.contact-sidebar .contact-method-card:hover {
    box-shadow: var(--shadow-sm);
}

/* Typ | Wert | delete on one line, Bezeichnung below — three fields side by side overflow the sidebar. */
.contact-sidebar .contact-method-row,
.e-sidebar.contact-sidebar .contact-method-row {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr) 36px;
    grid-template-areas: "type value delete" "label label .";
    gap: 12px;
    align-items: end;
}

.contact-sidebar .contact-method-row .form-group,
.e-sidebar.contact-sidebar .contact-method-row .form-group {
    min-width: 0;
    margin-bottom: 0;
}

.contact-sidebar .contact-method-row .method-type,
.e-sidebar.contact-sidebar .contact-method-row .method-type {
    grid-area: type;
}

.contact-sidebar .contact-method-row .method-value,
.e-sidebar.contact-sidebar .contact-method-row .method-value {
    grid-area: value;
}

.contact-sidebar .contact-method-row .method-label,
.e-sidebar.contact-sidebar .contact-method-row .method-label {
    grid-area: label;
}

.contact-sidebar .contact-method-row .btn-delete-method,
.e-sidebar.contact-sidebar .contact-method-row .btn-delete-method {
    grid-area: delete;
}

.contact-sidebar .btn-delete-method,
.e-sidebar.contact-sidebar .btn-delete-method {
    background: none;
    border: none;
    color: var(--cx-danger);
    cursor: pointer;
    font-size: 16px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
    flex-shrink: 0;
    margin-bottom: 4px;
}

.contact-sidebar .btn-delete-method:hover,
.e-sidebar.contact-sidebar .btn-delete-method:hover {
    background-color: var(--danger-50);
}

/* Not scoped to the sidebar: ContactForm also renders in ContactDialog, where this button would fall back to native styling. */
.no-contact-methods {
    width: 100%;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-align: center;
    font: inherit;
    font-size: 13px;
    background-color: var(--paper-2);
    border-radius: var(--radius-lg);
    border: 1px dashed var(--cx-card-border);
    cursor: pointer;
    transition: border-color .15s, background-color .15s;
}

.no-contact-methods:hover {
    border-color: var(--cx-primary);
}

.no-contact-methods-title {
    font-size: 14px;
    font-weight: 550;
    color: var(--cx-primary);
}

.contact-sidebar .add-contact-method,
.e-sidebar.contact-sidebar .add-contact-method {
    text-align: left;
}

.contact-sidebar .tab-badge,
.e-sidebar.contact-sidebar .tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    margin-left: 6px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    background-color: var(--cx-text-muted);
    border-radius: 10px;
}

.contact-sidebar .tab-link.active .tab-badge,
.e-sidebar.contact-sidebar .tab-link.active .tab-badge {
    background-color: var(--cx-primary);
}

/* Entity type toggle — Firma / Privatperson */
.entity-type-toggle {
    display: flex;
    gap: 0;
    border: 1px solid var(--cx-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    width: fit-content;
}

.entity-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--cx-text-secondary);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.entity-btn:not(:last-child) {
    border-right: 1px solid var(--cx-border);
}

.entity-btn:hover {
    background: var(--cx-hover-bg);
    color: var(--cx-text-primary);
}

.entity-btn.active {
    background: var(--cx-primary);
    color: #fff;
}

/* Header variant — white styling on dark background */
.entity-type-toggle.header-variant {
    border-color: rgba(255, 255, 255, 0.35);
}

.entity-type-toggle.header-variant .entity-btn {
    color: rgba(255, 255, 255, 0.8);
}

.entity-type-toggle.header-variant .entity-btn:not(:last-child) {
    border-right-color: rgba(255, 255, 255, 0.35);
}

.entity-type-toggle.header-variant .entity-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.entity-type-toggle.header-variant .entity-btn.active {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

/* sidebar-header-extra sits between the title and close button */
.sidebar-header-extra {
    margin-left: auto;
    margin-right: 12px;
    display: flex;
    align-items: center;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .e-sidebar.contact-sidebar {
        width: 100vw !important;
        border-left: none;
        border-top: 3px solid var(--cx-primary);
        border-radius: 0;
    }

    .e-sidebar.contact-sidebar .form-group {
        flex-basis: 100%;
    }

    .e-sidebar.contact-sidebar .form-row {
        flex-direction: column;
        gap: 8px;
    }
}

/* ========================================
   Syncfusion Dropdown Button - Action Menu
   ======================================== */

/* Ensure dropdown popup renders above everything and stays within viewport */
.e-dropdown-popup.e-popup {
    z-index: 100000 !important;
    position: fixed !important;
}

/* Automatically position popup to the left if it would overflow right edge */
.e-dropdown-popup.e-popup.e-lib {
    border-radius: 8px !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15) !important;
    border: 1px solid #e2e8f0 !important;
    overflow: visible !important;
    min-width: 150px;
    max-width: calc(100vw - 20px);
}

/* Ensure popup doesn't overflow viewport */
.e-dropdown-popup.e-popup[style*="left"] {
    max-width: calc(100vw - 20px);
    right: auto;
}

.e-dropdown-popup .e-item {
    padding: 0.625rem 1rem !important;
    font-size: 0.875rem !important;
    color: #374151 !important;
    display: flex !important;
    align-items: center !important;
    gap: 0.5rem !important;
    transition: background-color 0.15s ease;
    white-space: nowrap;
}

.e-dropdown-popup .e-item:hover {
    background: #f3f4f6 !important;
}

.e-dropdown-popup .e-item .e-menu-icon {
    font-size: 0.875rem;
    color: #6b7280;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

.e-dropdown-popup .e-separator {
    margin: 0.25rem 0 !important;
    border-color: #e5e7eb !important;
}

/* Dropdown menu list styling */
.e-dropdown-popup .e-ul {
    padding: 0.375rem 0 !important;
    margin: 0 !important;
}

/* ========================================
   Syncfusion RTE Slash Menu
   Popup renders at <body> level — explicit colors needed
   to prevent Bootstrap/app CSS from hiding text
   ======================================== */
.e-rte-elements.e-rte-slashmenu {
    background: #fff;
    color: #242424;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.14);
}

.e-rte-elements.e-slash-menu .e-rte-slash-menu-item-text,
.e-rte-elements.e-slash-menu .e-rte-slash-menu-item-content-text {
    color: #242424;
    font-weight: 500;
}

.e-rte-elements.e-slash-menu .e-rte-slash-menu-item-description {
    color: #707070;
    font-size: 12px;
}

.e-rte-elements.e-slash-menu .e-slash-menu-icon {
    color: #616161;
}

.e-rte-elements.e-slash-menu .e-list-parent > li {
    color: #242424;
}

.e-rte-elements.e-slash-menu .e-list-parent > li:hover,
.e-rte-elements.e-slash-menu .e-list-parent > li.e-active {
    background: #f5f5f5;
    color: #242424;
}

.e-rte-elements.e-slash-menu .e-list-group-item {
    color: #616161;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* === Skeleton Loading Utilities === */
.skeleton {
    background: linear-gradient(90deg, #e5e7eb 25%, #d1d5db 50%, #e5e7eb 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: 6px;
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text { height: 14px; }
.skeleton-text-lg { height: 20px; }
.skeleton-text-xl { height: 28px; }
.skeleton-circle { border-radius: 50%; }
.skeleton-rounded { border-radius: 12px; }

/* ===========================================
   SHARED UX COMPONENTS
   =========================================== */

/* Info Tooltips (CSS-only, no JS) */
.info-tooltip {
    position: relative;
    display: inline-flex;
    margin-left: 0.5rem;
    color: var(--cx-text-muted, #9ca3af);
    cursor: help;
}

.info-tooltip:hover {
    color: var(--cx-text-secondary, #6b7280);
}

.info-tooltip .info-tooltip-text {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #1f2937;
    color: white;
    padding: 0.625rem 0.875rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 400;
    line-height: 1.5;
    width: max-content;
    max-width: 300px;
    z-index: 100;
    transition: opacity 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.info-tooltip .info-tooltip-text::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #1f2937;
}

.info-tooltip:hover .info-tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* ---- Underline Tab Buttons ---- */
.cx-tab-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    color: var(--cx-text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s;
}

.cx-tab-btn:hover {
    color: var(--cx-text-primary);
}

.cx-tab-btn:first-child {
    padding-left: 0;
}

.cx-tab-btn.active {
    color: var(--cx-primary);
    border-bottom-color: var(--cx-primary);
}

.cx-tab-btn i {
    font-size: 0.875rem;
}

.cx-tab-btn .tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    font-size: 0.6875rem;
    font-weight: 600;
    background: var(--paper-2);
    color: var(--cx-text-secondary);
}

.cx-tab-btn.active .tab-badge {
    background: var(--cx-primary-soft);
    color: var(--cx-primary);
}

.cx-tab-btn:not(.active) .tab-badge.tab-badge-warning {
    background: #fef3c7;
    color: #92400e;
}

/* Progressive Disclosure ("show more" button) */
.show-more-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem;
    margin-top: 0.5rem;
    background: #f3f4f6;
    border: 1px dashed #d1d5db;
    border-radius: 8px;
    color: #6b7280;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.show-more-btn:hover {
    background: #e5e7eb;
    color: #374151;
    border-color: #9ca3af;
}

/* Section Headers with Descriptions */
.section-header {
    margin-bottom: 1rem;
}

.section-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-description {
    font-size: 0.85rem;
    color: var(--cx-text-muted, #9ca3af);
    margin: 0.25rem 0 0;
}

/* Focus-visible states for keyboard accessibility */
.cx-tab-btn:focus-visible {
    outline: 2px solid var(--cx-primary);
    outline-offset: -2px;
    border-radius: 4px;
}

.show-more-btn:focus-visible {
    outline: 2px solid #6b7280;
    outline-offset: 2px;
}

/* ================================================================
   Shared Page Layout System (cx- prefix)
   Unified layout components for consistent page structure.
   Reference: /work-items (list pages), /templates (tabbed pages)
   ================================================================ */

/* ---- Page Header (CraftX shell) ---- */
.cx-page-header {
    background: transparent;
    padding: 1rem 2rem 0.75rem;
    border-bottom: 1px solid var(--cx-hairline-soft);
    flex-shrink: 0;
}

.cx-header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cx-header-left {
    display: flex;
    flex-direction: column;
}

.cx-header-left h1 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    color: var(--cx-text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cx-header-left h1 i {
    font-size: 1.1rem;
    color: var(--cx-text-secondary);
}

.cx-header-subtitle {
    margin: 0.125rem 0 0 0;
    font-size: 0.8rem;
    color: var(--cx-text-muted);
}

.cx-header-stats {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.375rem;
    font-size: 0.8rem;
    color: var(--cx-text-secondary);
}

.cx-header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.cx-header-actions .cx-header-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    background: var(--cx-primary);
    color: white;
    border: none;
    font-weight: 500;
    font-size: 0.8rem;
    padding: 0.5rem 1.125rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}

.cx-header-actions .cx-header-btn:hover {
    background: var(--cx-primary-hover);
}

/* SfButton override inside header actions — compact to match Variant D */
.cx-header-actions .e-btn,
.cx-header-actions .e-btn.e-primary {
    font-weight: 500 !important;
    font-size: 0.8rem !important;
    padding: 0.5rem 1.125rem !important;
    border-radius: 8px !important;
    line-height: 1 !important;
    height: auto !important;
    text-transform: none !important;
}

/* ---- Stats Section (Variant D: Compact cards) ---- */
.cx-stats-section {
    background: transparent;
    padding: 0.625rem 2rem;
    border-bottom: 1px solid var(--cx-hairline-soft);
    flex-shrink: 0;
}

.cx-stats-grid {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.cx-stat-card {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.75rem 0.5rem 0.875rem;
    border-radius: 8px;
    border: 1px solid var(--cx-card-border);
    background: var(--cx-card-bg);
    cursor: pointer;
    transition: all 0.15s;
    flex: 1;
    min-width: 120px;
    position: relative;
}

.cx-stat-card:hover {
    background: var(--paper-2);
    border-color: var(--cx-hairline);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.cx-stat-card.active {
    border-color: rgba(184,96,31,0.24);
    background: var(--cx-primary-soft);
}

/* Tone differentiation — 3px inset left bar per status. Cards stay white so a
   row of 4–6 cards reads as a clean dashboard, not a rainbow. The icon also
   gets a tone-tinted container. */
.cx-stat-card.warning { box-shadow: inset 3px 0 0 var(--cx-warning); }
.cx-stat-card.success { box-shadow: inset 3px 0 0 var(--cx-success); }
.cx-stat-card.info    { box-shadow: inset 3px 0 0 var(--cx-info); }
.cx-stat-card.danger  { box-shadow: inset 3px 0 0 var(--cx-danger); }
.cx-stat-card.primary { box-shadow: inset 3px 0 0 var(--cx-primary); }

.cx-stat-card.warning .cx-stat-icon { background: color-mix(in srgb, var(--cx-warning) 12%, white); }
.cx-stat-card.success .cx-stat-icon { background: color-mix(in srgb, var(--cx-success) 12%, white); }
.cx-stat-card.info    .cx-stat-icon { background: color-mix(in srgb, var(--cx-info)    12%, white); }
.cx-stat-card.danger  .cx-stat-icon { background: color-mix(in srgb, var(--cx-danger)  12%, white); }
.cx-stat-card.primary .cx-stat-icon { background: color-mix(in srgb, var(--cx-primary) 12%, white); }

.cx-stat-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.cx-stat-content {
    display: flex;
    flex-direction: column;
}

.cx-stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--cx-text-primary);
    line-height: 1.2;
}

.cx-stat-label {
    font-size: 0.7rem;
    color: var(--cx-text-muted);
}

/* ---- Toolbar Section ---- */
.cx-toolbar-section {
    background: transparent;
    padding: 0.875rem 3rem;
    border-bottom: 1px solid var(--cx-hairline-soft);
    flex-shrink: 0;
}

.cx-toolbar-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.cx-toolbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.cx-toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* ---- Search Box ---- */
.cx-search-box {
    position: relative;
    width: 280px;
}

.cx-search-box > i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--cx-text-muted);
    font-size: 0.8rem;
    pointer-events: none;
    z-index: 1;
}

.cx-search-input {
    width: 100%;
    height: 34px;
    padding: 0 2rem 0 30px;
    border: 1px solid var(--cx-card-border);
    border-radius: var(--radius-md);
    background: var(--paper-2);
    font-size: 0.8rem;
    color: var(--cx-text-primary);
    outline: none;
    transition: border-color 0.15s, background 0.15s;
}

.cx-search-input::placeholder {
    color: var(--cx-text-muted);
}

.cx-search-input:focus {
    border-color: var(--cx-primary);
    background: var(--cx-card-bg);
    box-shadow: var(--cx-focus-ring);
}

.cx-search-clear {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--light-gray);
    border-radius: 50%;
    color: var(--cx-text-secondary);
    cursor: pointer;
    font-size: 0.75rem;
    padding: 0;
}

.cx-search-clear:hover {
    background: var(--sand-2);
    color: var(--cx-text-primary);
}

/* ---- Filter Controls ---- */
.cx-filter-group {
    display: flex;
    gap: 0.5rem;
}

.cx-filter-select {
    height: 34px;
    padding: 0 1.75rem 0 0.625rem;
    border: 1px solid var(--cx-card-border);
    border-radius: var(--radius-md);
    background: var(--cx-card-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238E8679' d='M2.5 4.5L6 8l3.5-3.5'/%3E%3C/svg%3E") no-repeat right 8px center;
    background-size: 12px;
    font-size: 0.8rem;
    color: var(--cx-text-primary);
    cursor: pointer;
    outline: none;
    min-width: 130px;
    appearance: none;
    -webkit-appearance: none;
    transition: border-color 0.15s;
}

.cx-filter-select:focus {
    border-color: var(--cx-primary);
    box-shadow: var(--cx-focus-ring);
}

/* ---- Clear Filters Button ---- */
.cx-clear-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    border: 1px solid var(--cx-card-border);
    border-radius: var(--radius-md);
    background: var(--cx-card-bg);
    color: var(--cx-text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.cx-clear-btn:hover {
    background: var(--paper-2);
    border-color: var(--cx-hairline);
}

/* ---- View Toggle ---- */
.cx-view-toggle {
    display: flex;
    background: var(--paper-2);
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--cx-card-border);
}

.cx-view-btn {
    padding: 0.5rem 0.75rem;
    border: none;
    background: transparent;
    color: var(--cx-text-muted);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cx-view-btn:hover {
    background: rgba(28, 25, 21, 0.05);
}

.cx-view-btn.active {
    background: var(--ink);
    color: white;
}

/* ---- Content Section ---- */
.cx-content-section {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 1.25rem 2rem;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    box-sizing: border-box;
}

/* ---- Tabs Container (underline tab bar) ---- */
.cx-tabs-section {
    background: transparent;
    border-bottom: 1px solid var(--cx-hairline-soft);
    flex-shrink: 0;
}

.cx-tabs-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    gap: 0;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .cx-page-header,
    .cx-stats-section,
    .cx-toolbar-section,
    .cx-content-section {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .cx-tabs-container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .cx-header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .cx-toolbar-container {
        flex-direction: column;
        align-items: stretch;
    }

    .cx-toolbar-left {
        flex-direction: column;
    }

    .cx-search-box {
        width: 100%;
    }

    .cx-filter-group {
        width: 100%;
        flex-wrap: wrap;
    }

    .cx-filter-select {
        flex: 1;
        min-width: 0;
    }

    .cx-toolbar-right {
        justify-content: space-between;
    }

    .cx-stat-card {
        min-width: calc(50% - 0.5rem);
    }
}

/* ---- Focus / Accessibility ---- */
.cx-stat-card:focus-visible,
.cx-view-btn:focus-visible,
.cx-clear-btn:focus-visible,
.cx-header-btn:focus-visible {
    outline: 2px solid var(--cx-primary);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .cx-stat-card,
    .cx-view-btn,
    .cx-clear-btn,
    .cx-header-btn {
        transition: none;
    }
}
