/* ==========================================================================
   SORABH KITCHEN WORLD (SKW) - STOCK MANAGEMENT ERP
   Design System & Layout Tokens
   ========================================================================== */

:root {
    --bg-main: #f8fafc;
    --bg-gradient: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    --bg-card: rgba(255, 255, 255, 0.98);
    --bg-card-header: #f1f5f9;
    --bg-input: #ffffff;
    --bg-input-focus: #f8fafc;
    --bg-table-header: #1e293b;
    
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-rgb: 59, 130, 246;
    
    --success: #16a34a;
    --success-hover: #15803d;
    
    --warning: #d97706;
    --warning-hover: #b45309;
    
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    
    --purple: #7c3aed;
    --purple-hover: #6d28d9;
    
    --text: #0f172a;
    --text-muted: #64748b;
    --border: rgba(0, 0, 0, 0.1);
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.08);
    --shadow-xl: 0 20px 30px -10px rgba(0, 0, 0, 0.12);
    --transition-fast: 0.15s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
}


body {
    background: var(--bg-gradient);
    color: var(--text);
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: clip;
}

/* CUSTOM SCROLLBARS */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* APP HEADER */
.app-header {
    background-color: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    min-height: 62px;
    height: 62px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 clamp(0.75rem, 1.5vw, 1.5rem);
    position: sticky;
    top: 0;
    z-index: 1040;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
}

.header-logo-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.3px;
}

.header-logo i {
    font-size: 1.5rem;
    color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
    padding: 6px;
    border-radius: 8px;
}

.header-logo .app-tag {
    font-size: 0.7rem;
    font-weight: 700;
    background: #eff6ff;
    color: var(--primary);
    border: 1px solid #bfdbfe;
    padding: 2px 7px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    margin-left: 4px;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    height: 100%;
    overflow-x: auto;
    scrollbar-width: none;
}
.header-nav::-webkit-scrollbar {
    display: none;
}

.nav-tab {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.86rem;
    font-weight: 600;
    padding: 0.45rem 0.85rem;
    border-radius: 0.45rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    transition: var(--transition-fast);
    white-space: nowrap;
}

.nav-tab:hover {
    color: var(--text);
    background-color: rgba(0, 0, 0, 0.04);
}

.nav-tab.active {
    color: var(--primary);
    background-color: #eff6ff;
    border: 1px solid #bfdbfe;
}

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

.user-badge {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 4px 10px;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary);
}

.db-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    border: 1px solid rgba(148, 163, 184, 0.3);
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-muted);
}
.db-status-pill:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.db-status-pill.online {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
    border-color: rgba(16, 185, 129, 0.3);
}
.db-status-pill.offline {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border-color: rgba(239, 68, 68, 0.3);
}
.db-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
    background-color: #94a3b8;
}
.db-status-pill.online .db-status-dot {
    background-color: #10b981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
}
.db-status-pill.offline .db-status-dot {
    background-color: #ef4444;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.25);
}

/* Dashboard Selected Items Floating / Sticky Dock */
.dash-selected-dock {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    background: #ffffff;
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.06);
    border-radius: 0 0 0.75rem 0.75rem;
    animation: slideUpDock 0.22s ease-out;
    gap: 12px;
    flex-wrap: wrap;
    position: sticky;
    bottom: 0;
    z-index: 20;
}
@keyframes slideUpDock {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.dash-selected-dock .dock-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
}
.dash-selected-dock .dock-badge {
    background: var(--primary);
    color: #fff;
    padding: 2px 9px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 700;
}
.dash-selected-dock .dock-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* APP CONTAINER */
.app-container {
    flex-grow: 1;
    padding: 0.85rem 1rem 1.5rem 1rem;
    display: flex;
    flex-direction: column;
}

.tab-content {
    display: none;
    flex-grow: 1;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

/* CARDS */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.15rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* REQUIREMENT PLANNING 2-COLUMN LAYOUT */
.order-entry-layout {
    display: grid;
    grid-template-columns: 410px minmax(0, 1fr);
    gap: 1.15rem;
    align-items: stretch;
    height: calc(100vh - 110px);
    min-height: 580px;
}

.order-entry-layout .left-panel {
    height: 100%;
    max-height: 100%;
    overflow-y: auto;
    overflow-x: hidden !important;
    width: 410px;
    max-width: 410px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-sizing: border-box;
}

/* Fix for Master Catalog sub-tabs height to prevent scrolling */
.mc-tab-content .order-entry-layout {
    height: calc(100vh - 175px);
}

.order-entry-layout .left-panel select,
.order-entry-layout .left-panel input,
.order-entry-layout .left-panel .form-group {
    max-width: 100% !important;
    box-sizing: border-box !important;
}

#req_bom_select {
    width: 100% !important;
    max-width: 100% !important;
    text-overflow: ellipsis !important;
    overflow: hidden !important;
    white-space: nowrap !important;
}

.order-entry-layout .right-panel {
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.panel-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.85rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.65rem;
}

.section-title {
    font-size: 1.12rem;
    font-weight: 800;
    letter-spacing: -0.2px;
    color: var(--text);
}

.form-section-title {
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--primary);
    margin-top: 0.5rem;
    margin-bottom: 0.65rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-group {
    margin-bottom: 0.8rem;
}

.form-group label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group label .required {
    color: var(--danger);
    font-size: 0.85rem;
}

.grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
}

input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 0.45rem;
    padding: 0.55rem 0.75rem;
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 0.88rem;
    outline: none;
    transition: var(--transition-fast);
}

input[type="date"] {
    cursor: pointer;
    font-weight: 600;
}

select {
    cursor: pointer;
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    background-color: var(--bg-input);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%233b82f6'%3E%3Cpath d='M11.9997 13.1714L16.9495 8.22168L18.3637 9.63589L11.9997 15.9999L5.63574 9.63589L7.04996 8.22168L11.9997 13.1714Z'%3E%3C/path%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 0.75rem center !important;
    background-size: 1.25rem 1.25rem !important;
    padding-right: 2.25rem !important;
}

select::-ms-expand {
    display: none;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    display: block !important;
    cursor: pointer;
    opacity: 0.75;
    font-size: 1.15rem;
    padding: 2px;
    margin-right: -2px;
    transition: opacity 0.2s ease;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    background-color: var(--bg-input-focus);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

/* UNIT SELECTOR BUTTON GROUP */
.unit-selector {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.35rem;
    margin-top: 0.2rem;
}

.unit-btn {
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.45rem 0.25rem;
    border-radius: 0.35rem;
    font-family: var(--font-sans);
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition-fast);
    text-align: center;
}

.unit-btn:hover {
    color: var(--text);
    border-color: #cbd5e1;
    background: #f1f5f9;
}

.unit-btn.active {
    background-color: #eff6ff !important;
    border-color: var(--primary) !important;
    color: var(--primary) !important;
    box-shadow: 0 0 0 1px var(--primary);
}

/* STICKY ACTION BAR FOR LEFT FORM */
.left-action-bar {
    display: flex;
    gap: 0.65rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border);
    margin-top: 0.5rem;
}

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: 0.82rem;
    letter-spacing: 0.3px;
    border-radius: 0.45rem;
    padding: 0.55rem 1rem;
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition-fast);
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
}
.btn-primary:hover {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
    background: #f1f5f9;
    color: var(--text-muted);
    border-color: var(--border);
}
.btn-secondary:hover {
    background: #e2e8f0;
    color: var(--text);
}

.btn-success {
    background: linear-gradient(135deg, #16a34a, #15803d);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(22, 163, 74, 0.3);
}
.btn-success:hover {
    background: linear-gradient(135deg, #15803d, #166534);
    box-shadow: 0 4px 10px rgba(22, 163, 74, 0.4);
}

.btn-purple {
    background: #ffffff;
    color: var(--purple);
    border: 1.5px solid var(--purple);
}
.btn-purple:hover {
    background: #f5f3ff;
}

.btn-outline-danger {
    background: #ffffff;
    color: var(--danger);
    border: 1px solid var(--danger);
}
.btn-outline-danger:hover {
    background: #fef2f2;
}

.btn-outline-primary {
    background: #ffffff;
    color: var(--primary);
    border: 1px solid var(--primary);
}
.btn-outline-primary:hover {
    background: #eff6ff;
}

.btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.76rem;
    border-radius: 0.35rem;
}

/* RIGHT PANEL TABLE */
.table-wrapper {
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: auto !important;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: #ffffff;
}

.clean-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
    text-align: left;
}

.clean-data-table th {
    background: #1e293b;
    color: #ffffff;
    font-weight: 700;
    padding: 0.65rem 0.85rem;
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    z-index: 10;
    white-space: nowrap !important;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.clean-data-table th:last-child {
    border-right: none;
}

.clean-data-table td {
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
    white-space: nowrap !important;
}

.clean-data-table td:last-child {
    border-right: none;
}

.clean-data-table tbody tr:hover {
    background-color: #f8fafc;
}

/* EMPTY STATE */
.empty-table-state {
    text-align: center;
    padding: 3.5rem 1rem;
    color: var(--text-muted);
}
.empty-table-state i {
    font-size: 2.5rem;
    color: #cbd5e1;
    display: block;
    margin-bottom: 0.6rem;
}

/* BADGES */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
}
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-purple { background: #f3e8ff; color: #6b21a8; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-red { background: #fee2e2; color: #991b1b; }

/* STICKY BOTTOM ACTIONS & STATS GRID */
.order-bottom-sticky {
    margin-top: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.order-grid-actions-row {
    display: flex;
    justify-content: flex-end;
    gap: 0.65rem;
}

.order-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.65rem;
}

.stat-card {
    background-color: #ffffff;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.6rem 0.85rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.stat-title {
    font-size: 0.68rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 0.2rem;
    letter-spacing: 0.4px;
}

.stat-value {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text);
}

/* MODAL STYLES */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex !important;
}

.modal-dialog {
    background: #ffffff;
    border-radius: 0.85rem;
    width: 90%;
    max-width: 650px;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
}

.modal-dialog.modal-xl {
    max-width: 1150px;
    width: 94%;
    max-height: 88vh;
}

/* RM DETAILS DEDICATED TABLE (SPACIOUS + WRAP FRIENDLY) */
.rm-details-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.96rem;
    text-align: left;
}

.rm-details-table th {
    background: #1e293b;
    color: #ffffff;
    font-weight: 700;
    padding: 0.85rem 1rem;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.rm-details-table td {
    padding: 0.95rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    white-space: nowrap !important;
    word-break: break-word;
    line-height: 1.5;
}

.rm-details-table tbody tr:hover {
    background-color: #f8fafc;
}


.modal-header {
    background: #f8fafc;
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text);
}

.modal-close-btn {
    background: transparent;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--text-muted);
}
.modal-close-btn:hover {
    color: var(--danger);
}

.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex-grow: 1;
}

.modal-footer {
    background: #f8fafc;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
}

/* TOAST NOTIFICATION */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
}

.toast {
    background: #1e293b;
    color: #ffffff;
    padding: 10px 18px;
    border-radius: 8px;
    margin-top: 8px;
    font-size: 0.84rem;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slideUp 0.25s ease-out;
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--primary); }

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* PLACEHOLDER MODULE CARD */
.module-placeholder-card {
    background: #ffffff;
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    margin-top: 1rem;
}
.module-placeholder-card i {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 0.75rem;
    display: inline-block;
}
.module-placeholder-card h3 {
    font-size: 1.3rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}
.module-placeholder-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    max-width: 500px;
    margin: 0 auto;
}

@media (max-width: 900px) {
    .order-entry-layout {
        grid-template-columns: 1fr;
        height: auto;
    }
    .order-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ── MASTER CATALOG FILTER BAR ───────────────────────────────── */
.mc-filter-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1rem;
    background: #f8fafc;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.mc-filter-search {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 7px;
    padding: 0 0.65rem;
    height: 34px;
    flex: 0 0 220px;
    transition: border-color 0.15s;
}
.mc-filter-search:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59,130,246,0.12);
}
.mc-filter-search i {
    color: var(--text-muted);
    font-size: 0.95rem;
    flex-shrink: 0;
}
.mc-filter-search input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 0.83rem;
    color: var(--text);
    width: 100%;
    height: 100%;
    padding: 0;
    font-family: var(--font-sans);
}

.mc-filter-selects {
    display: flex;
    gap: 0.45rem;
    align-items: center;
    flex-wrap: wrap;
}
.mc-filter-selects select {
    height: 34px;
    font-size: 0.82rem;
    padding: 0 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 7px;
    background: #fff;
    color: var(--text);
    font-family: var(--font-sans);
    cursor: pointer;
    min-width: 130px;
    transition: border-color 0.15s;
}
.mc-filter-selects select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59,130,246,0.12);
}

.mc-filter-reset {
    height: 34px;
    padding: 0 0.85rem;
    font-size: 0.82rem;
    border-radius: 7px;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    white-space: nowrap;
    margin-left: auto;
}

/* ── ADVANCED REPORTS FILTER GRID ─────────────────────────────── */
.report-filters-grid {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
    width: 100%;
}
.report-col-full:first-child {
    min-width: 240px;
}
.report-col-half {
    width: 140px;
}
.report-col-full:nth-of-type(4) {
    flex: 1;
    min-width: 200px;
}
.report-actions-group {
    display: flex;
    gap: 6px;
}
.mobile-filter-toggle-btn {
    display: none !important;
}
.mobile-swipe-hint {
    display: none;
}

/* ── COLUMN FILTER BUTTON (Excel-style) ────────────────────────── */
.col-filter-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 4px;
    color: rgba(255,255,255,0.8);
    cursor: pointer;
    padding: 1px 4px;
    margin-left: 4px;
    font-size: 0.72rem;
    line-height: 1;
    vertical-align: middle;
    transition: background 0.15s, color 0.15s;
}
.col-filter-btn:hover,
.col-filter-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 0 0 2px rgba(59,130,246,0.3);
}
.col-filter-btn.active {
    background: #f59e0b;
    border-color: #f59e0b;
}

/* ── COLUMN FILTER DROPDOWN POPUP ──────────────────────────────── */
.mc-col-filter-popup {
    position: fixed;
    z-index: 9999;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    min-width: 200px;
    max-width: 280px;
    padding: 0;
    overflow: hidden;
    animation: popupFadeIn 0.12s ease;
}
@keyframes popupFadeIn {
    from { opacity: 0; transform: translateY(-6px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.mc-col-filter-popup .cfp-header {
    background: #1e293b;
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 0.55rem 0.85rem;
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.mc-col-filter-popup .cfp-search {
    padding: 0.45rem 0.65rem;
    border-bottom: 1px solid #f1f5f9;
}
.mc-col-filter-popup .cfp-search input {
    width: 100%;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 0.28rem 0.55rem;
    font-size: 0.8rem;
    font-family: var(--font-sans);
    outline: none;
}
.mc-col-filter-popup .cfp-search input:focus {
    border-color: var(--primary);
}
.mc-col-filter-popup .cfp-list {
    max-height: 240px;
    overflow-y: auto;
    padding: 0.3rem 0;
}
.mc-col-filter-popup .cfp-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.38rem 0.85rem;
    font-size: 0.83rem;
    color: #1e293b;
    cursor: pointer;
    transition: background 0.1s;
    user-select: none;
}
.mc-col-filter-popup .cfp-item:hover {
    background: #f0f6ff;
    color: var(--primary);
}
.mc-col-filter-popup .cfp-item.selected {
    background: #eff6ff;
    color: var(--primary);
    font-weight: 600;
}
.mc-col-filter-popup .cfp-item input[type="checkbox"] {
    accent-color: var(--primary);
    width: 14px;
    height: 14px;
    cursor: pointer;
    flex-shrink: 0;
}
.mc-col-filter-popup .cfp-footer {
    padding: 0.45rem 0.65rem;
    border-top: 1px solid #f1f5f9;
    display: flex;
    gap: 0.4rem;
    justify-content: flex-end;
}
.mc-col-filter-popup .cfp-footer button {
    font-size: 0.78rem;
    padding: 0.28rem 0.75rem;
    border-radius: 5px;
    border: 1px solid #d1d5db;
    background: #f8fafc;
    cursor: pointer;
    font-family: var(--font-sans);
    font-weight: 600;
    transition: background 0.12s;
}
.mc-col-filter-popup .cfp-footer .cfp-apply {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.mc-col-filter-popup .cfp-footer .cfp-apply:hover {
    background: var(--primary-hover);
}
.mc-col-filter-popup .cfp-footer button:hover {
    background: #e2e8f0;
}

/* RIGHT-SIDE SLIDING RECIPE DRAWER (OFFCANVAS) */
.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 2500;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s;
}

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

.recipe-drawer {
    position: fixed;
    top: 0;
    right: -1000px;
    width: 950px;
    max-width: 96vw;
    height: 100vh;
    background: #ffffff;
    z-index: 2600;
    box-shadow: -10px 0 35px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    transition: right 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.recipe-drawer.active {
    right: 0;
}

.drawer-header {
    padding: 1.1rem 1.4rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
}

.drawer-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.drawer-close-btn {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 0.45rem;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.25rem;
    color: var(--text-muted);
    transition: all 0.15s ease;
}

.drawer-close-btn:hover {
    background: #fee2e2;
    color: var(--danger);
    border-color: #fca5a5;
    transform: rotate(90deg);
}

.drawer-toolbar {
    padding: 0.85rem 1.4rem;
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    background: #ffffff;
}

.recipe-drawer .clean-data-table {
    width: 100%;
    border-collapse: collapse;
}

.recipe-drawer .clean-data-table th,
.recipe-drawer .clean-data-table td {
    padding: 0.65rem 0.65rem;
}

.drawer-footer {
    padding: 1rem 1.4rem;
    background: #f8fafc;
    border-top: 1px solid var(--border);
}

.drawer-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
    padding: 0.85rem 1.2rem;
    border-radius: 0.6rem;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.modal-overlay.active {
    opacity: 1;
}
.modal-dialog {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    max-width: 600px;
    width: 100%;
    transform: translateY(20px);
    transition: transform 0.2s ease;
    overflow: hidden;
}
.modal-overlay.active .modal-dialog {
    transform: translateY(0);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
}
.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}
.modal-close-btn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
}
.modal-close-btn:hover {
    color: var(--danger);
}
.modal-body {
    padding: 1.5rem;
    max-height: 70vh;
    overflow-y: auto;
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    background: #f8fafc;
}

/* Col Filter Popup Styles */
.mc-col-filter-popup {
    position: fixed;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    width: 260px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    font-size: 0.85rem;
}
.cfp-header {
    padding: 0.75rem 1rem;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
    border-top-left-radius: 0.5rem;
    border-top-right-radius: 0.5rem;
}
.cfp-search {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
}
.cfp-search input {
    width: 100%;
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.35rem;
    font-size: 0.8rem;
    outline: none;
}
.cfp-list {
    max-height: 220px;
    overflow-y: auto;
    padding: 0.5rem 0;
}
.cfp-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 1rem;
    cursor: pointer;
    transition: background 0.1s;
}
.cfp-item:hover {
    background: #f1f5f9;
}
.cfp-item input[type="checkbox"] {
    cursor: pointer;
}
.cfp-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    background: #f8fafc;
    border-bottom-left-radius: 0.5rem;
    border-bottom-right-radius: 0.5rem;
}
.cfp-footer button {
    padding: 0.3rem 0.75rem;
    border-radius: 0.35rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border);
    background: #ffffff;
    color: var(--text);
}
.cfp-footer button:hover {
    background: #f1f5f9;
}
.cfp-footer button.cfp-apply {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}
.cfp-footer button.cfp-apply:hover {
    background: var(--primary-hover);
}

/* Force hide any database loading overlay */
#db-loading-overlay {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}




/* Keep labels and table cells clean without breaking words */
label, th, td, .nav-tab, .badge { white-space: nowrap; word-break: normal; }
.section-title, .form-section-title { white-space: normal; word-break: break-word; }
.left-panel .panel-header-row { flex-direction: column; align-items: flex-start; gap: 12px; }
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
body { white-space: normal; overflow-x: hidden; }
.header-logo-wrapper, .header-actions { flex-shrink: 0; }
.app-header { gap: 12px; }

.sync-status-bar {display:flex;justify-content:flex-end;align-items:center;gap:12px;padding:6px 20px;font-size:12px;color:#475569;background:#fff;}
.import-result {margin:8px 16px;padding:12px;border:1px solid #93c5fd;background:#eff6ff;white-space:pre;overflow:auto;max-height:180px;}
.report-toolbar {display:flex;gap:10px;align-items:center;margin:12px 0;overflow-x:auto;}
.report-toolbar input {width:auto;min-width:140px;}
#planningReportsPanel {scroll-margin-top:75px;}

.plan-menu{display:inline-block;white-space:nowrap}.plan-menu summary{list-style:none;cursor:pointer}.plan-menu>div{display:flex;gap:6px;margin-top:6px} #planningReportsPanel th,#planningReportsPanel td{white-space:nowrap}

.plan-buttons{display:flex;gap:8px;align-items:center;white-space:nowrap}#planningEditBanner:not([hidden]){display:flex;gap:16px;align-items:center;padding:12px 18px;background:#eff6ff;border:1px solid #bfdbfe;margin-bottom:12px}

#operationFeedback:not([hidden]){position:fixed;bottom:16px;left:16px;right:16px;z-index:12000;padding:14px 18px;background:#fff1f2;color:#9f1239;border:1px solid #fda4af;border-radius:8px;box-shadow:0 4px 16px #0002}

/* Excel-like Header Filters */
.filter-icon {
    color: #a0aec0;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 2px;
    border-radius: 4px;
    transition: all 0.2s;
}
.filter-icon:hover, .filter-icon.active {
    background: var(--bg-hover);
    color: var(--primary);
}

.header-filter-popup {
    position: fixed;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.18);
    width: 230px;
    z-index: 99999;
    display: none;
    flex-direction: column;
    font-weight: normal;
    text-align: left;
    color: var(--text);
    box-sizing: border-box;
}
.header-filter-popup.show {
    display: flex;
}
.header-filter-search {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border);
}
.header-filter-search input {
    width: 100%;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    font-size: 0.8rem;
    outline: none;
}
.header-filter-search input:focus {
    border-color: var(--primary);
}
.header-filter-list {
    max-height: 200px;
    overflow-y: auto;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.header-filter-item, .filter-item {
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
    gap: 0.5rem !important;
    padding: 0.3rem 0.4rem !important;
    font-size: 0.85rem !important;
    cursor: pointer !important;
    border-radius: 4px;
    box-sizing: border-box !important;
    user-select: none;
    margin: 0 !important;
}
.header-filter-item:hover, .filter-item:hover {
    background-color: #f1f5f9;
}
.header-filter-item input[type="checkbox"], .filter-item input[type="checkbox"] {
    cursor: pointer;
    width: 15px;
    height: 15px;
    margin: 0;
    flex-shrink: 0;
}
.header-filter-item span, .filter-item span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
    color: var(--text);
}
.header-filter-actions {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem;
    border-top: 1px solid var(--border);
    background: #f8fafc;
    border-radius: 0 0 0.5rem 0.5rem;
}
.header-filter-actions button {
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
    border-radius: 0.25rem;
}

/* ═════════════════════════════════════════════════════════════════
   MOBILE MENU TOGGLE & SLIDE-OUT DRAWER
   ═════════════════════════════════════════════════════════════════ */
.mobile-menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #f8fafc;
    color: var(--text);
    font-size: 1.3rem;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.mobile-menu-toggle:hover {
    background: #e2e8f0;
    color: var(--primary);
    border-color: #cbd5e1;
}

.mobile-menu-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(3px);
    z-index: 1050;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.mobile-menu-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.mobile-menu-drawer {
    position: fixed;
    top: 0;
    right: -310px;
    width: 290px;
    max-width: 85vw;
    height: 100vh;
    background: #ffffff;
    box-shadow: -6px 0 30px rgba(0, 0, 0, 0.18);
    z-index: 1060;
    display: flex;
    flex-direction: column;
    transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow-y: auto;
}
.mobile-menu-drawer.open {
    right: 0;
}

.mobile-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.15rem;
    border-bottom: 1px solid var(--border);
    background: #ffffff;
}
.mobile-drawer-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}
.mobile-drawer-logo i {
    font-size: 1.35rem;
    color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
    padding: 6px;
    border-radius: 8px;
}
.mobile-logo-title {
    font-size: 0.88rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.2;
}
.mobile-logo-subtitle {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--primary);
}
.mobile-drawer-close {
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    background: #f8fafc;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text);
    transition: all 0.15s ease;
}
.mobile-drawer-close:hover {
    background: #fee2e2;
    color: var(--danger);
    border-color: #fca5a5;
}

.mobile-drawer-user-info {
    padding: 0.85rem 1.15rem 0.5rem 1.15rem;
}
.mobile-user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.65rem 0.85rem;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
}
.mobile-user-card:hover {
    background: #eff6ff;
    border-color: #bfdbfe;
}
.mobile-user-card i#mobileUserRoleIcon {
    font-size: 1.25rem;
    color: var(--primary);
}

.mobile-nav-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0.75rem 1.15rem;
    flex-grow: 1;
}
.mobile-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 8px;
    background: transparent;
    border: none;
    color: var(--text);
    font-weight: 500;
    font-size: 0.88rem;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
    width: 100%;
}
.mobile-nav-item i {
    font-size: 1.15rem;
    color: var(--text-muted);
    transition: color 0.15s ease;
}
.mobile-nav-item:hover {
    background: #f1f5f9;
    color: var(--primary);
}
.mobile-nav-item:hover i {
    color: var(--primary);
}
.mobile-nav-item.active {
    background: #eff6ff;
    color: var(--primary);
    font-weight: 700;
}
.mobile-nav-item.active i {
    color: var(--primary);
}

.mobile-drawer-footer {
    padding: 1rem 1.15rem;
    border-top: 1px solid var(--border);
    background: #fafafa;
}

/* ═════════════════════════════════════════════════════════════════
   RESPONSIVE DESIGN (PC Small Screen, Laptop, Tablet, Mobile)
   ═════════════════════════════════════════════════════════════════ */

/* Laptops & Medium Screens (<= 1200px) */
@media (max-width: 1200px) {
    .header-logo {
        font-size: 1rem;
    }
    .header-logo i {
        font-size: 1.25rem;
        padding: 4px;
    }
    .header-nav {
        gap: 0.2rem;
    }
    .nav-tab {
        padding: 0.45rem 0.65rem;
        font-size: 0.78rem;
        gap: 4px;
    }
    .header-actions {
        gap: 8px;
    }
}

/* Specific enhancement for Laptops / Small PC screens (993px - 1200px) */
@media (min-width: 993px) and (max-width: 1200px) {
    .order-entry-layout {
        grid-template-columns: 350px minmax(0, 1fr) !important;
        gap: 0.85rem !important;
    }
    .order-entry-layout .left-panel {
        width: 350px !important;
        max-width: 350px !important;
    }
    .clean-data-table th,
    .clean-data-table td {
        padding: 6px 8px !important;
        font-size: 0.8rem !important;
    }
}

/* Tablet & Mobile Landscape / Portrait (<= 992px) */
@media (max-width: 992px) {
    html, body {
        white-space: normal !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        height: auto !important;
        min-height: 100% !important;
    }

    .app-header {
        height: auto;
        min-height: 58px;
        padding: 0.45rem 0.85rem;
        gap: 8px;
        overflow: visible !important;
    }

    /* Hide desktop nav tabs & desktop logout button on mobile */
    #headerNavMenu {
        display: none !important;
    }
    .header-actions .btn-secondary {
        display: none !important;
    }
    .mobile-menu-toggle {
        display: inline-flex !important;
    }

    .header-logo-wrapper {
        min-width: 0;
        flex: 1;
    }
    .header-logo {
        font-size: 0.95rem;
        gap: 6px;
    }
    .header-logo i {
        font-size: 1.25rem;
        padding: 4px;
    }
    .header-logo .app-tag {
        font-size: 0.65rem;
        padding: 1px 5px;
    }

    /* Container & Tab Content: Natural Block Scrolling, NO Viewport Trapping */
    .app-container {
        display: block !important;
        flex: none !important;
        height: auto !important;
        min-height: 0 !important;
        padding: 0.65rem 0.65rem 3rem 0.65rem !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
        overflow-y: visible !important;
    }

    .tab-content,
    .tab-content.active {
        display: none;
        height: auto !important;
        min-height: 0 !important;
        flex: none !important;
        overflow: visible !important;
    }

    .tab-content.active {
        display: block !important;
    }

    /* Stacking side-by-side grids vertically into 1 clean column */
    .order-entry-layout,
    .mc-tab-content .order-entry-layout {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: 1fr !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        gap: 1rem !important;
        overflow: visible !important;
    }

    .order-entry-layout .left-panel,
    .order-entry-layout .right-panel,
    .left-panel,
    .right-panel {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        overflow: visible !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: flex-start !important;
        flex: none !important;
    }

    .card {
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        border-radius: 0.65rem !important;
        padding: 0.85rem !important;
        overflow: visible !important;
    }

    .card > div:not(.table-wrapper) {
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        overflow: visible !important;
    }

    /* Panel header wrap so buttons/badges NEVER get truncated or clipped */
    .panel-header-row {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
        align-items: center !important;
        justify-content: space-between !important;
        margin-bottom: 0.75rem !important;
        padding-bottom: 0.5rem !important;
    }

    .panel-header-row > div {
        display: flex !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        gap: 6px !important;
    }

    .section-title {
        font-size: 1rem !important;
        line-height: 1.3 !important;
        white-space: normal !important;
    }

    .form-section-title {
        font-size: 0.8rem !important;
        margin-top: 0.85rem !important;
        margin-bottom: 0.5rem !important;
    }

    /* Form inputs full width & touch friendly */
    .grid-2col {
        grid-template-columns: 1fr !important;
        gap: 0.65rem !important;
    }

    .form-group {
        margin-bottom: 0.75rem !important;
    }

    .form-group label {
        font-size: 0.75rem !important;
        margin-bottom: 0.25rem !important;
    }

    input[type="text"],
    input[type="number"],
    input[type="date"],
    select,
    textarea {
        font-size: 0.9rem !important;
        height: 40px !important;
        padding: 0.5rem 0.65rem !important;
    }

    /* Action buttons: Reset and Add Item */
    .left-action-bar {
        display: flex !important;
        flex-direction: row !important;
        gap: 8px !important;
        margin-top: 1rem !important;
        width: 100% !important;
    }

    .left-action-bar .btn {
        flex: 1 !important;
        height: 42px !important;
        font-size: 0.88rem !important;
        font-weight: 600 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Bottom sticky bar becomes natural block on mobile */
    .order-bottom-sticky {
        position: static !important;
        margin-top: 1rem !important;
        padding: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
        width: 100% !important;
    }

    .order-grid-actions-row {
        display: flex !important;
        flex-direction: row !important;
        gap: 8px !important;
        width: 100% !important;
    }

    .order-grid-actions-row .btn {
        flex: 1 !important;
        height: 42px !important;
        font-size: 0.88rem !important;
        font-weight: 700 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Reports tab toolbar */
    .mobile-filter-toggle-btn {
        display: inline-flex !important;
        align-items: center;
        gap: 4px;
        padding: 4px 10px !important;
        font-size: 0.78rem !important;
        height: 32px !important;
        font-weight: 600;
        cursor: pointer;
    }
    .mc-filter-bar {
        padding: 0.65rem !important;
        margin-bottom: 0.75rem !important;
        background: #ffffff !important;
        border: 1px solid var(--border) !important;
        border-radius: 0.5rem !important;
        transition: all 0.25s ease;
    }
    .mc-filter-bar.filters-collapsed {
        display: none !important;
    }
    .report-filters-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 8px 10px !important;
        width: 100% !important;
    }
    .report-col-full {
        grid-column: 1 / -1 !important;
        width: 100% !important;
        margin: 0 !important;
    }
    .report-col-half {
        grid-column: span 1 !important;
        width: 100% !important;
        margin: 0 !important;
        min-width: 0 !important;
    }
    .report-col-half input[type="date"],
    .report-col-full select,
    .report-col-full input[type="text"] {
        width: 100% !important;
        height: 38px !important;
        font-size: 0.85rem !important;
    }
    .report-actions-group {
        display: grid !important;
        grid-template-columns: 1fr 0.8fr 1.2fr !important;
        gap: 6px !important;
        width: 100% !important;
        margin: 4px 0 0 0 !important;
    }
    .report-actions-group .btn {
        height: 38px !important;
        padding: 0 6px !important;
        font-size: 0.82rem !important;
        font-weight: 600 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        white-space: nowrap !important;
    }

    #tab-reports .table-wrapper {
        min-height: 280px !important;
        max-height: calc(100vh - 250px) !important;
        overflow-y: auto !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        border: 1px solid var(--border) !important;
        border-radius: 8px !important;
        background: #ffffff !important;
    }

    /* Universal Mobile Table Grids across all tabs */
    .mobile-swipe-hint {
        display: flex !important;
        align-items: center;
        gap: 6px;
        font-size: 0.72rem;
        font-weight: 600;
        color: #475569;
        background: #f1f5f9;
        padding: 3px 8px;
        border-radius: 5px;
        margin: 4px 0 6px 0;
        width: fit-content;
        border: 1px solid #e2e8f0;
    }
    .mobile-swipe-hint i {
        color: var(--primary);
        font-size: 0.85rem;
    }

    .table-wrapper {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: auto !important;
        overflow-y: auto !important;
        max-height: 440px !important;
        -webkit-overflow-scrolling: touch !important;
        display: block !important;
        margin: 0.4rem 0 !important;
        border: 1px solid var(--border) !important;
        border-radius: 8px !important;
        background: #ffffff !important;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) !important;
        flex: none !important;
        flex-grow: 0 !important;
        scrollbar-width: thin !important;
        scrollbar-color: #94a3b8 #f1f5f9 !important;
    }

    .table-wrapper::-webkit-scrollbar {
        height: 6px !important;
        width: 6px !important;
        display: block !important;
    }
    .table-wrapper::-webkit-scrollbar-track {
        background: #f1f5f9 !important;
        border-radius: 4px !important;
    }
    .table-wrapper::-webkit-scrollbar-thumb {
        background: #94a3b8 !important;
        border-radius: 4px !important;
    }

    .clean-data-table {
        min-width: max-content !important;
        width: 100% !important;
        border-collapse: separate !important;
        border-spacing: 0 !important;
    }

    .clean-data-table th {
        padding: 8px 10px !important;
        font-size: 0.72rem !important;
        font-weight: 700 !important;
        letter-spacing: 0.3px !important;
        background-color: var(--bg-table-header) !important;
        color: #ffffff !important;
        white-space: nowrap !important;
        position: sticky !important;
        top: 0 !important;
        z-index: 10 !important;
        border-bottom: 2px solid #0f172a !important;
        border-right: 1px solid rgba(255, 255, 255, 0.12) !important;
    }
    .clean-data-table th:last-child {
        border-right: none !important;
    }

    .clean-data-table td {
        padding: 8px 10px !important;
        font-size: 0.78rem !important;
        white-space: nowrap !important;
        border-bottom: 1px solid #e2e8f0 !important;
        border-right: 1px solid #f8fafc !important;
        vertical-align: middle !important;
    }
    .clean-data-table td:last-child {
        border-right: none !important;
    }

    .clean-data-table tbody tr:nth-child(even) {
        background-color: #f8fafc !important;
    }
    .clean-data-table tbody tr:hover,
    .clean-data-table tbody tr:active {
        background-color: #eff6ff !important;
    }

    .clean-data-table td .btn,
    .clean-data-table td button {
        padding: 2px 6px !important;
        font-size: 0.74rem !important;
        height: 28px !important;
        min-width: 28px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .empty-table-state {
        padding: 2.5rem 1rem !important;
    }
    .empty-table-state i {
        font-size: 2rem !important;
    }
    .empty-table-state div,
    .empty-table-state p {
        font-size: 0.8rem !important;
        margin-top: 0.5rem !important;
    }

    /* Header filter popup responsive placement */
    .header-filter-popup {
        right: 10px;
        max-width: 240px;
    }
}

/* Phones & Small Devices (<= 480px) */
@media (max-width: 480px) {
    .app-header {
        padding: 0.4rem 0.65rem;
    }
    .header-logo span:first-of-type {
        font-size: 0.82rem;
    }
    .header-logo i {
        font-size: 1.1rem;
        padding: 3px;
    }
    .header-logo .app-tag {
        display: none;
    }
    .user-badge {
        padding: 3px 6px;
        font-size: 0.7rem;
    }
    .app-container {
        padding: 0.45rem 0.45rem 3rem 0.45rem !important;
    }
    .card {
        padding: 0.75rem !important;
    }
    .section-title {
        font-size: 0.95rem !important;
    }
    .report-actions-group {
        grid-template-columns: 1fr 0.8fr 1.2fr !important;
        gap: 5px !important;
    }
    .report-actions-group .btn {
        height: 36px !important;
        font-size: 0.78rem !important;
        padding: 0 4px !important;
    }
    .order-grid-actions-row,
    .left-action-bar {
        flex-direction: row !important;
        display: flex !important;
        gap: 8px !important;
        width: 100% !important;
    }
    .order-grid-actions-row .btn,
    .left-action-bar .btn {
        flex: 1 !important;
        height: 40px !important;
        font-size: 0.82rem !important;
        font-weight: 700 !important;
    }
    .clean-data-table th, .clean-data-table td {
        padding: 7px 8px !important;
        font-size: 0.75rem !important;
    }
}

/* ----------------------------------------------------
   MOBILE RESPONSIVE CARDS MODE & TOGGLE SYSTEM
   ---------------------------------------------------- */
.mobile-grid-toggle {
    display: none !important;
}

@media (max-width: 768px) {
    .mobile-grid-toggle {
        display: inline-flex !important;
        align-items: center !important;
        gap: 5px !important;
        padding: 3px 8px !important;
        font-size: 0.75rem !important;
        font-weight: 600 !important;
        height: 30px !important;
        border-radius: 6px !important;
        cursor: pointer !important;
    }

    /* By default on mobile, convert tables to clean cards */
    .responsive-cards-wrapper:not(.force-table-mode) {
        overflow: visible !important;
        max-height: none !important;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
    }

    /* Hide the swipe hint when in cards mode */
    .responsive-cards-wrapper:not(.force-table-mode) ~ .mobile-swipe-hint,
    .right-panel:has(.responsive-cards-wrapper:not(.force-table-mode)) .mobile-swipe-hint {
        display: none !important;
    }

    .responsive-cards-wrapper:not(.force-table-mode) table,
    .responsive-cards-wrapper:not(.force-table-mode) tbody {
        display: block !important;
        width: 100% !important;
        min-width: 0 !important;
    }

    .responsive-cards-wrapper:not(.force-table-mode) thead {
        display: none !important;
    }

    .responsive-cards-wrapper:not(.force-table-mode) tr {
        display: block !important;
        width: 100% !important;
        background: #ffffff !important;
        border: 1px solid var(--border) !important;
        border-radius: 10px !important;
        padding: 10px 12px !important;
        margin-bottom: 10px !important;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05) !important;
        box-sizing: border-box !important;
        transition: transform 0.15s ease, box-shadow 0.15s ease !important;
    }

    .responsive-cards-wrapper:not(.force-table-mode) tr:hover {
        box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08) !important;
    }

    .responsive-cards-wrapper:not(.force-table-mode) td {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 5px 0 !important;
        border: none !important;
        border-bottom: 1px dashed #f1f5f9 !important;
        font-size: 0.85rem !important;
        white-space: normal !important;
        text-align: right !important;
        box-sizing: border-box !important;
    }

    .responsive-cards-wrapper:not(.force-table-mode) td:last-child {
        border-bottom: none !important;
        padding-top: 8px !important;
        margin-top: 4px !important;
        justify-content: flex-end !important;
    }

    .responsive-cards-wrapper:not(.force-table-mode) td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        font-size: 0.72rem;
        text-transform: uppercase;
        letter-spacing: 0.3px;
        text-align: left;
        margin-right: 10px;
        flex-shrink: 0;
    }

    .responsive-cards-wrapper:not(.force-table-mode) td[data-label="Action"]::before {
        display: none !important;
    }

    .responsive-cards-wrapper:not(.force-table-mode) td[data-label="Select"] {
        justify-content: flex-start !important;
        gap: 8px;
        border-bottom: 1px solid #e2e8f0 !important;
        padding-bottom: 6px !important;
        margin-bottom: 4px !important;
    }

    .responsive-cards-wrapper:not(.force-table-mode) td[data-label="Select"]::before {
        display: none !important;
    }

    .responsive-cards-wrapper:not(.force-table-mode) td[data-label="Item Name"],
    .responsive-cards-wrapper:not(.force-table-mode) td[data-label="Item"] {
        font-size: 0.94rem !important;
        font-weight: 700 !important;
        color: #0f172a !important;
    }

    .responsive-cards-wrapper:not(.force-table-mode) .empty-table-state {
        display: block !important;
        text-align: center !important;
        padding: 2.5rem 1rem !important;
    }

    .responsive-cards-wrapper:not(.force-table-mode) .empty-table-state::before {
        display: none !important;
    }

    /* Force Table Mode on Mobile */
    .responsive-cards-wrapper.force-table-mode {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: auto !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        display: block !important;
        border: 1px solid var(--border) !important;
        border-radius: 8px !important;
        background: #ffffff !important;
    }

    .responsive-cards-wrapper.force-table-mode table {
        min-width: 600px !important;
        display: table !important;
    }

    .responsive-cards-wrapper.force-table-mode thead {
        display: table-header-group !important;
    }

    .responsive-cards-wrapper.force-table-mode tbody {
        display: table-row-group !important;
    }

    .responsive-cards-wrapper.force-table-mode tr {
        display: table-row !important;
    }

    .responsive-cards-wrapper.force-table-mode th,
    .responsive-cards-wrapper.force-table-mode td {
        display: table-cell !important;
    }

    .responsive-cards-wrapper.force-table-mode td::before {
        display: none !important;
    }
}




