.modal-header {
    background-color: #f39c12;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    width: 100%;
    box-sizing: border-box;
    position: relative;
    padding: 12px 96px 12px 12px;
    overflow: visible;
}

.modal-header .btn-close {
    position: absolute;
    right: 80px;
    top: 50%;
    transform: translateY(-50%);
    margin: 0;
    z-index: 2002;
}

.modal-header .modal-title {
    margin-bottom: 0;
    flex-shrink: 0;
}

/* Show the menu trigger button inside the modal header */
.modal-header .app-sidebar-trigger-wrap {
    display: flex !important;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    margin: 0 !important;
    z-index: 2003;
}

.modal-header .app-sidebar-trigger {
    background: rgba(0, 0, 0, 0.15);
}

.modal-header .app-sidebar-trigger span {
    background: #fff;
}

.library-switcher {
    max-width: 161px;
    margin-left: auto;
    margin-right: 8px;
    flex-shrink: 0;
}

.module-hub-body {
    background: #ececec;
    min-height: calc(100vh - 120px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.module-hub-card {
    width: 100%;
    max-width: 520px;
    background: #fff;
    border: 1px solid #d0d0d0;
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.modal-footer {
    background-color: #7aa12b;
    flex-shrink: 0;
    width: 100%;
    box-sizing: border-box;
}

/* ===== UPPERCASE ALL MODAL FOOTER BUTTONS ===== */
.modal-footer .btn {
    text-transform: uppercase;
    font-weight: 600;
}

/* ===== ENSURE MODAL BODY MAINTAINS SIZE ===== */
.modal-body {
    width: 100%;
    box-sizing: border-box;
    overflow: auto;
}

/* ===== FIX MODAL DIALOG SIZING ===== */
.modal-dialog {
    box-sizing: border-box !important;
    pointer-events: auto;
}

.modal-dialog * {
    box-sizing: border-box;
}

.modal-dialog .modal-content {
    width: 100%;
}

/* Preserve Bootstrap size classes */
@media (min-width: 576px) {
    .modal-dialog:not(.modal-fullscreen):not(.modal-sm):not(.modal-lg):not(.modal-xl) {
        max-width: 560px;
        width: 100%;
    }

    .modal-dialog.modal-sm {
        max-width: 300px;
        width: 100%;
    }

    .modal-dialog.modal-lg,
    .modal-dialog.modal-xl {
        max-width: 800px;
        width: 100%;
    }
}

@media (min-width: 1200px) {
    .modal-dialog.modal-xl {
        max-width: 1140px;
    }
}

/* Centered dialogs: vertical center without forcing full viewport height on content */
.modal-dialog.modal-dialog-centered {
    display: flex;
    align-items: center;
    min-height: calc(100% - var(--bs-modal-margin, 1.75rem) * 2);
}

.modal-dialog.modal-dialog-centered .modal-content {
    height: auto;
    max-height: calc(100vh - 3.5rem);
}

.modal-content {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
    background-clip: padding-box;
}

/* Limit body height so large content scrolls inside modal */
.modal-dialog:not(.modal-fullscreen) .modal-body {
    max-height: 70vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Fullscreen library modals: fill viewport top to bottom */
.modal-fullscreen.modal.show .modal-dialog {
    width: 100vw !important;
    max-width: 100vw !important;
    min-width: 100vw !important;
    height: 100vh !important;
    min-height: 100vh !important;
    margin: 0 !important;
}

.modal-fullscreen .modal-content {
    width: 100vw !important;
    min-width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    min-height: 100vh !important;
    max-height: 100vh !important;
    display: flex !important;
    flex-direction: column !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

.modal-fullscreen .modal-body {
    flex: 1 1 auto !important;
    max-height: none !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

.modal-fullscreen .modal-footer {
    flex: 0 0 auto !important;
    margin-top: 0 !important;
}

.modal-fullscreen .library-grain-row {
    flex: 0 0 auto;
}

.modal-fullscreen .table-responsive {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow: auto !important;
}

.modal-fullscreen .dataTables_wrapper {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
}

.modal-fullscreen .dataTables_wrapper .dataTables_info,
.modal-fullscreen .dataTables_wrapper .dataTables_length,
.modal-fullscreen .dataTables_wrapper .dataTables_paginate {
    flex: 0 0 auto;
}

/* Footer and header keep natural sizing and do not collapse */
.modal-header,
.modal-footer {
    flex-shrink: 0;
}

/* Backdrop darkness */
.modal-backdrop.show {
    background-color: rgba(0,0,0,0.45);
}

/* ===== PREVENT SCROLLBAR SHIFT ===== */
html.modal-open {
    overflow-y: scroll;
}

/* ===== MODAL CONTENT STABILITY ===== */
.modal.show {
    pointer-events: auto;
}

/* body {
    font-family: "Figtree", sans-serif;
    background: #f3f4f6;
} */

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        Segoe UI,
        Roboto,
        Helvetica Neue,
        Arial,
        Noto Sans,
        sans-serif,
        Apple Color Emoji,
        Segoe UI Emoji,
        Segoe UI Symbol,
        Noto Color Emoji;
}

/* Default orange background for editable form fields */
input:not([type='hidden']):not([type='checkbox']):not([type='radio']):not([type='file']):not([type='submit']):not([type='button']):not([type='reset']):not([type='color']):not([readonly]):not(:disabled),
text,
textarea:not([readonly]):not(:disabled) {
    background-color: #f9a825 !important;
    transition: background-color 0.2s ease;
}

/* Switch to white after the user edits the field */
input:not([type='hidden']):not([type='checkbox']):not([type='radio']):not([type='file']):not([type='submit']):not([type='button']):not([type='reset']):not([type='color']):not([readonly]):not(:disabled).field-edited,
select:not(:disabled):not([disabled]).field-edited,
textarea:not([readonly]):not(:disabled).field-edited {
    background-color: #ffffff !important;
}

/* Keep paper name (and all record data) on a single line across every
   paper-records table in the app; let the responsive wrapper scroll. */
.table-responsive,
.table-scroll-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.paper-table tbody td,
.reel-stock-table tbody td,
.paper-stock-table tbody td {
    white-space: nowrap;
}

.modal.draggable .modal-header {
    cursor: move;
    user-select: none;
}

.modal.draggable .modal-header:active {
    cursor: grabbing;
}

.modal.dragging .modal-content {
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
}

.app-loading-panel {
    position: fixed;
    inset: 0;
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-loading-panel.app-loading-panel--hidden {
    display: none !important;
}

.app-loading-panel__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
}

.app-loading-panel__content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 180px;
    padding: 1.5rem 2rem;
    border-radius: 0.5rem;
    background: rgba(33, 37, 41, 0.92);
    color: #fff;
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.35);
}

.app-loading-panel__spinner {
    width: 2.5rem;
    height: 2.5rem;
    border: 0.3rem solid rgba(255, 255, 255, 0.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: app-loading-spin 0.75s linear infinite;
}

@keyframes app-loading-spin {
    to {
        transform: rotate(360deg);
    }
}

.app-loading-panel__text {
    font-size: 0.95rem;
    letter-spacing: 0.02em;
    margin-top: 1rem;
    margin-bottom: 0;
}

/* App sidebar */
.app-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    left: auto;
    width: 260px;
    height: 100vh;
    background: linear-gradient(180deg, #1f1f1f 0%, #111 100%);
    color: #fff;
    z-index: 1065;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 18px rgba(0, 0, 0, 0.35);
}

.app-sidebar.is-open {
    transform: translateX(0);
}

.app-sidebar__header {
    padding: 18px 16px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.app-sidebar__logo {
    width: 100%;
    max-width: 180px;
    display: block;
    margin: 0 auto;
}

.app-sidebar__nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

.app-sidebar__group {
    margin-top: 8px;
    padding-top: 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.app-sidebar__group-title {
    padding: 10px 18px 6px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #f39c12;
}

.app-sidebar__link--child {
    padding-left: 28px;
    font-size: 13px;
    font-weight: 500;
}

.app-sidebar__link {
    display: block;
    padding: 11px 18px;
    color: #f5f5f5;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    border-right: 3px solid transparent;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.app-sidebar__link:hover,
.app-sidebar__link:focus {
    background: rgba(243, 156, 18, 0.15);
    border-right-color: #f39c12;
    color: #fff;
}

.app-sidebar__logout {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin: 0;
}

.app-sidebar__logout-btn {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin: 0;
    cursor: pointer;
}

.app-sidebar__link--button {
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
    color: #f5f5f5;
}

/* Account modals must sit above fullscreen page modals (Paper Reels/Sheets etc.) */
#accountOptionsModal,
#changePasswordModal,
#profileDetailsModal {
    z-index: 20000 !important;
    background: rgba(0, 0, 0, 0.45);
}

#accountOptionsModal .modal-dialog,
#changePasswordModal .modal-dialog,
#profileDetailsModal .modal-dialog {
    z-index: 20001;
    position: relative;
}

/* ===== Account options / Change password / Profile ===== */
.account-options-body {
    background-color: #ececec;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 20px;
}

.account-option-btn {
    width: 100%;
    text-align: left;
    background: #fff;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    padding: 12px 16px;
    font-size: 15px;
    font-weight: 700;
    color: #111;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.account-option-btn:hover,
.account-option-btn:focus {
    background: #fff8eb;
    border-color: #f39c12;
    outline: none;
}

.change-password-body,
.profile-details-body {
    background-color: #ececec;
    padding: 20px;
}

.change-password-input {
    background-color: #fff !important;
    border: 1px solid #c8c8c8;
    border-radius: 2px;
    min-height: 38px;
}

.btn-change-password {
    background-color: #f39c12 !important;
    border-color: #f39c12 !important;
    color: #111 !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    padding: 8px 18px;
    border-radius: 6px;
}

.btn-change-password:hover,
.btn-change-password:focus {
    background-color: #e08e0b !important;
    border-color: #e08e0b !important;
    color: #111 !important;
}

#changePasswordModal .modal-footer {
    justify-content: flex-end;
}

.app-sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    z-index: 1060;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    pointer-events: none;
}

.app-sidebar-backdrop.is-visible {
    opacity: 1;
    visibility: visible;
}

.app-sidebar-trigger-wrap {
    margin-left: auto;
    display: flex;
    align-items: center;
    padding-left: 12px;
}

.app-sidebar-trigger-wrap--fixed {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 1064;
    margin-left: 0;
    padding-left: 0;
}

.app-sidebar-trigger {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.08);
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    padding: 0;
}

.app-sidebar-trigger span {
    display: block;
    width: 16px;
    height: 2px;
    background: #222;
    border-radius: 2px;
}

.app-sidebar-trigger--light {
    background: rgba(255, 255, 255, 0.12);
}

.app-sidebar-trigger--light span {
    background: #fff;
}

.modal-header.text-white .app-sidebar-trigger span,
.modal-header.custom-header .app-sidebar-trigger span {
    background: #fff;
}

body.modal-open .app-sidebar-trigger-wrap--fixed {
    display: none;
}

body.app-sidebar-open {
    overflow-x: hidden;
}

/* Sidebar overlays modals — never resize open dialogs */
body.app-sidebar-open .modal.show .modal-dialog {
    margin-left: auto !important;
    margin-right: auto !important;
}

body.app-sidebar-open .dashboard-container,
body.app-sidebar-open .main-content {
    margin-right: 260px;
    transition: margin-right 0.25s ease;
}

@media (max-width: 768px) {
    .app-sidebar {
        width: 220px;
    }

    body.app-sidebar-open .dashboard-container,
    body.app-sidebar-open .main-content {
        margin-right: 220px;
    }
}

/*
 * Readonly / disabled fields — grey background across the entire app.
 * Placed last so it wins over earlier linked stylesheets.
 * Page #id rules / jQuery .css() are handled in common.js.
 */
html body input[readonly],
html body textarea[readonly],
html body input:read-only:not([type='hidden']):not([type='checkbox']):not([type='radio']):not([type='file']):not([type='submit']):not([type='button']):not([type='reset']):not([type='color']):not([type='range']):not([type='image']),
html body textarea:read-only,
html body .form-control[readonly],
html body .form-control:read-only:not([type='checkbox']):not([type='radio']):not([type='hidden']),
html body .initial-orange[readonly],
html body select[disabled],
html body select:disabled,
html body .form-select[disabled],
html body .form-select:disabled,
html body .form-control[disabled],
html body .form-control:disabled,
html body .initial-orange:disabled {
    background-color: #80808052 !important;
    cursor: default !important;
}
