:root {
    --font-main: 'Plus Jakarta Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --ddh-text-primary: #000000;
    --bs-body-color: var(--ddh-text-primary);
    --sidebar-deep-blue: #061a33;
    --sidebar-mid-blue: #0a2749;
    --sidebar-hover-blue: #12365f;
}

/* One type system for application and authentication screens. */
html,
body,
button,
input,
select,
textarea,
table,
.select2-container,
.flatpickr-calendar,
.swal2-popup,
.dropdown-menu,
.modal,
.popover,
.tooltip {
    font-family: var(--font-main) !important;
}

body {
    color: var(--ddh-text-primary);
    font-weight: 400;
    letter-spacing: -.006em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Header wording is normalized by column-header-case.js; prevent older page
   styles from forcing the normalized text back to full uppercase. */
#main-content table thead th {
    text-transform: none !important;
}

/* Shared filter/search layout. Help text may make one field taller, so filter
   columns align from their labels instead of aligning their uneven bottoms. */
#main-content .ddh-filter-row {
    align-items: flex-start !important;
    --bs-gutter-y: .45rem;
}

#main-content .ddh-filter-row > [class*="col-"] {
    min-width: 0;
}

#main-content .ddh-filter-row > .ddh-filter-actions {
    margin-top: calc(24px + .28rem);
    align-items: center !important;
    flex-wrap: wrap;
}

#main-content .ddh-filter-row .select2-container {
    max-width: 100%;
}

#main-content .ddh-filter-lock-toggle {
    white-space: nowrap;
}

#main-content .ddh-page-lock-stack {
    position: relative;
    z-index: 1;
}

#main-content.ddh-page-header-locked .ddh-page-lock-stack {
    position: sticky;
    top: var(--topbar-height, 60px);
    z-index: 1028;
    background: rgba(255, 255, 255, .98);
    box-shadow: 0 4px 12px rgba(15, 23, 42, .08);
}

#main-content.ddh-page-header-locked .ddh-filter-sticky {
    position: sticky !important;
    top: calc(var(--topbar-height, 60px) + var(--ddh-page-lock-stack-height, 0px) + 6px);
    z-index: 1026;
    background: rgba(255, 255, 255, .98);
    border-color: #93c5fd !important;
    box-shadow: 0 8px 22px rgba(15, 23, 42, .14) !important;
}

#main-content.ddh-page-header-locked form.ddh-filter-sticky {
    padding: .5rem .65rem;
    border: 1px solid #93c5fd;
    border-radius: 10px;
}

/* Compact shared page chrome. The title, actions, breadcrumb, navigation trail
   and filter controls remain readable while leaving more room for page data. */
#main-content .page-header {
    padding: .55rem 1rem .3rem;
}

#main-content .page-header h1 {
    font-size: 1.18rem;
    line-height: 1.25;
}

#main-content .page-header .breadcrumb {
    font-size: .74rem;
    line-height: 1.25;
}

#main-content .page-header .btn-sm,
#main-content .page-header .btn {
    padding: .2rem .5rem;
    font-size: .76rem;
}

#main-content #ss-process-trail {
    height: 28px;
    padding-inline: 1rem;
}

#main-content form.ddh-filter-row label.form-label:not(.form-check-label) {
    min-height: 24px;
    margin-bottom: .28rem;
    padding: .2rem .5rem .18rem;
    font-size: .72rem;
}

#main-content form.ddh-filter-row .form-control,
#main-content form.ddh-filter-row .form-select,
#main-content form.ddh-filter-row .select2-selection {
    min-height: 34px;
}

/* Small inline clipboard control for business references. */
#main-content .ddh-copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 21px;
    height: 21px;
    margin-left: .22rem;
    padding: 0;
    vertical-align: middle;
    color: #64748b;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .07);
    font-size: .7rem;
    line-height: 1;
}

#main-content .ddh-copy-btn:hover,
#main-content .ddh-copy-btn:focus-visible {
    color: #1d4ed8;
    border-color: #93c5fd;
    background: #eff6ff;
}

#main-content .ddh-copy-btn.is-copied {
    color: #047857;
    border-color: #6ee7b7;
    background: #ecfdf5;
}

@media (max-width: 767.98px) {
    #main-content .page-header { padding: .45rem .75rem .25rem; }
    #main-content #ss-process-trail { padding-inline: .75rem; }
}

/* Adaptive desktop sidebar. Locked is the user's normal preference; pages
   with horizontal overflow temporarily collapse it and expose an edge hover
   target. Unlocked mode keeps the same hover access on every page. */
#sidebar.ddh-adaptive-collapsed {
    transform: translateX(-100%);
}

#main-content.ddh-adaptive-collapsed {
    margin-left: 0;
}

#sidebar.ddh-adaptive-peek {
    transform: translateX(0);
    z-index: 1055;
    box-shadow: 12px 0 30px rgba(2, 12, 27, .3);
}

#ddh-sidebar-edge {
    position: fixed;
    inset: 0 auto 0 0;
    width: 12px;
    z-index: 1054;
    display: none;
}

body.ddh-sidebar-edge-active #ddh-sidebar-edge {
    display: block;
}

body.ddh-sidebar-edge-active #ddh-sidebar-edge::after {
    content: '';
    position: absolute;
    top: 38%;
    left: 2px;
    width: 4px;
    height: 54px;
    border-radius: 999px;
    background: rgba(59, 130, 246, .42);
    opacity: 0;
    transition: opacity .15s ease;
}

body.ddh-sidebar-edge-active #ddh-sidebar-edge:hover::after {
    opacity: 1;
}

#sidebar-toggle.ddh-menu-unlocked {
    color: #2563eb;
    background: #eff6ff;
    border-color: #bfdbfe;
}

@media (max-width: 767.98px) {
    #ddh-sidebar-edge { display: none !important; }
}

/* Optional table-heading lock. JavaScript calculates offsets for complete
   page headers, internal scroll panes, and multi-row table headings. Summary
   cards and card title bars remain in normal flow so they cannot consume the
   reading area when column headings are locked. */
#main-content.ddh-column-headers-locked table.ddh-lockable-columns > thead > tr > th {
    position: sticky !important;
    top: calc(var(--ddh-column-header-base, var(--topbar-height, 60px)) + var(--ddh-column-row-offset, 0px)) !important;
    z-index: 1023;
    box-shadow: inset 0 -1px 0 rgba(15, 23, 42, .18);
}

/* Bootstrap's horizontal responsive wrapper is also a vertical scroll
   containing block.  Release that containment only for page-scrolling tables
   while Column Lock is active, so headings can reach the viewport offset. */
#main-content.ddh-column-headers-locked .table-responsive.ddh-column-page-scroll-host {
    overflow: visible !important;
}

@media (max-width: 767.98px) {
    #main-content .ddh-filter-row > .ddh-filter-actions {
        margin-top: 0;
    }

    #main-content.ddh-page-header-locked .ddh-page-lock-stack {
        top: var(--topbar-height, 56px);
    }
}

/* Use one neutral ink colour across pages. Semantic, link, muted, disabled and
   validation colours retain their meaning through their own utility classes. */
#main-content,
#main-content .card,
#main-content .modal-content,
#main-content .dropdown-menu,
#main-content legend,
#main-content .form-label,
#main-content .form-check-label,
#main-content .form-control,
#main-content .form-select,
#main-content .input-group-text,
#main-content .select2-selection__rendered,
#main-content .select2-search__field {
    color: var(--ddh-text-primary);
}

#main-content .text-dark,
#main-content .text-body {
    color: var(--ddh-text-primary) !important;
}

#main-content .table {
    --bs-table-color: var(--ddh-text-primary);
    color: var(--ddh-text-primary);
}

#main-content .table > :not(caption) > * > *:not(.text-primary):not(.text-secondary):not(.text-success):not(.text-danger):not(.text-warning):not(.text-info):not(.text-light):not(.text-white):not(.text-muted) {
    color: var(--ddh-text-primary);
}

h1, h2, h3, h4, h5, h6,
.card-header,
.modal-title {
    letter-spacing: -.025em;
}

/* Deep-blue navigation surface, including the entire logo header. */
#sidebar {
    background: linear-gradient(180deg, var(--sidebar-deep-blue) 0%, var(--sidebar-mid-blue) 52%, #07182e 100%) !important;
    box-shadow: 8px 0 24px rgba(4, 20, 40, .16);
}

#sidebar .sidebar-brand {
    background: linear-gradient(180deg, #04152a 0%, var(--sidebar-deep-blue) 100%) !important;
    border-bottom-color: rgba(147, 197, 253, .16);
}

#sidebar .sidebar-brand .brand-icon {
    background: transparent !important;
}

#sidebar .sidebar-nav .nav-link:hover,
.sect-procurement + .sidebar-nav .nav-link:hover,
.sect-logistics + .sidebar-nav .nav-link:hover,
.sect-finance + .sidebar-nav .nav-link:hover,
.sect-returns + .sidebar-nav .nav-link:hover,
.sect-warehouse + .sidebar-nav .nav-link:hover,
.sect-staff + .sidebar-nav .nav-link:hover,
.sect-marketing + .sidebar-nav .nav-link:hover,
.sect-linnworks + .sidebar-nav .nav-link:hover,
.sect-tools + .sidebar-nav .nav-link:hover,
.sect-reports + .sidebar-nav .nav-link:hover,
.sect-admin + .sidebar-nav .nav-link:hover {
    background: var(--sidebar-hover-blue) !important;
}

#sidebar .sidebar-nav .nav-link.active {
    background: linear-gradient(90deg, rgba(37, 99, 235, .62), rgba(30, 64, 175, .35)) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), inset 0 -1px 0 rgba(0, 0, 0, .12);
}

#sidebar .sidebar-user {
    background: rgba(3, 16, 32, .28);
    border-top-color: rgba(147, 197, 253, .15);
}

/* Flat field labels match the compact Price Calculator visual language. */
#main-content label.form-label:not(.form-check-label) {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .25rem;
    max-width: 100%;
    min-height: auto;
    margin-bottom: .3rem;
    padding: 0;
    color: var(--ddh-text-primary);
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    font-size: .78rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: .005em;
    text-shadow: none;
    transform: none;
    transition: color .14s ease;
}

#main-content label.form-label:not(.form-check-label):hover {
    border-color: transparent;
    box-shadow: none;
    transform: none;
}

#main-content label.form-label .text-danger {
    color: #c0262d !important;
    text-shadow: none;
}

#main-content label.form-label small,
#main-content label.form-label .text-muted {
    color: #60738c !important;
    font-size: .7rem;
    font-weight: 500 !important;
    letter-spacing: 0;
}

@media (max-width: 767.98px) {
    #main-content label.form-label:not(.form-check-label) {
        min-height: auto;
        padding: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    #main-content label.form-label:not(.form-check-label) {
        transition: none;
    }
}
