/* index.css */
/* Visual Style and Premium Theme for SORABH KITCHEN WORLD */

/* CORE DESIGN TOKENS */
:root {
    --bg-main: #f8fafc; /* Very light slate */
    --bg-gradient: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    --bg-card: rgba(255, 255, 255, 0.95); /* Glass panel */
    --bg-card-header: #f1f5f9;
    --bg-input: #ffffff;
    --bg-input-focus: #f1f5f9;
    
    --primary: #3b82f6; /* Modern blue */
    --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;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: rgba(0, 0, 0, 0.1); /* Thin border */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 30px -10px rgba(0, 0, 0, 0.15);
    --transition-fast: 0.15s ease;
}

/* GENERAL RESET */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Remove default number input spinner buttons (up/down arrows) */
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;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    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.95);
    border-bottom: 1px solid var(--border);
    min-height: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 clamp(0.75rem, 1.5vw, 1.5rem);
    position: -webkit-sticky;
    position: sticky;
    top: -1px; /* Helps with some browser bugs */
    z-index: 1040;
    gap: 0.5rem;
}

.header-logo-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    white-space: nowrap;
}

.header-logo i {
    font-size: clamp(1.3rem, 1.5vw, 1.6rem);
    color: var(--primary);
    flex-shrink: 0;
}

.header-logo span {
    font-size: clamp(0.95rem, 1.1vw, 1.15rem);
    font-weight: 800;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #0f172a, #334155);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap !important;
    flex-shrink: 0;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: clamp(0.15rem, 0.3vw, 0.35rem);
    height: 100%;
    flex-shrink: 1;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
}

.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: clamp(0.78rem, 0.82vw, 0.88rem);
    font-weight: 600;
    padding: 0.45rem clamp(0.45rem, 0.6vw, 0.85rem);
    border-radius: 0.35rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: var(--transition-fast);
    white-space: nowrap !important;
    flex-shrink: 0;
}

.nav-tab:hover {
    color: var(--text);
    background-color: rgba(0, 0, 0, 0.02);
}

.nav-tab.active {
    color: var(--primary);
    background-color: rgba(0, 210, 255, 0.08);
    border: 1px solid rgba(0, 210, 255, 0.2);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: clamp(0.2rem, 0.35vw, 0.4rem);
    flex-shrink: 0;
}

.header-actions .btn {
    white-space: nowrap !important;
    flex-shrink: 0;
    font-size: clamp(0.72rem, 0.78vw, 0.82rem);
    padding: 0.35rem clamp(0.45rem, 0.6vw, 0.7rem);
}

/* APP CONTAINER */
.app-container {
    flex-grow: 1;
    padding: 0.75rem 0.75rem 1.8rem 0.75rem;
    display: flex;
    flex-direction: column;
}

.tab-content {
    display: none;
    flex-grow: 1;
    animation: fadeIn 0.2s ease-out;
}

.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.25rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.page-card {
    flex-grow: 1;
    min-height: calc(100vh - 130px);
}

/* PAGE HEADERS */
.page-title-area {
    margin-bottom: 1.25rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: var(--text);
}

.page-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.section-title {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text);
}

/* FORMS AND INPUTS */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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.35rem;
    padding: 0.6rem 0.85rem;
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition-fast);
}

select {
    cursor: pointer;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    background-color: var(--bg-input-focus);
    box-shadow: 0 0 0 2px rgba(0, 210, 255, 0.1);
}

/* Readonly fields styling in Navy ERP */
input[readonly] {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--text-muted);
    border-color: rgba(0, 0, 0, 0.03);
    cursor: not-allowed;
}

#normal_unit_name,
.mix-unit-name-input {
    font-size: 0.75rem !important;
    padding-left: 0.3rem !important;
    padding-right: 0.3rem !important;
    text-align: center;
}

.required {
    color: var(--danger);
    font-weight: bold;
}

.grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.grid-item-unit {
    display: grid;
    grid-template-columns: 3fr 1fr;
    gap: 0.75rem;
}

.form-section-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
    margin-top: 1rem;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid rgba(0, 210, 255, 0.15);
    padding-bottom: 0.25rem;
}

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 700;
    padding: 0.6rem 1.2rem;
    border-radius: 0.35rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition-fast);
    outline: none;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-primary {
    background-color: var(--primary);
    color: #ffffff;
    font-weight: 500;
}
.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-success {
    background-color: var(--success);
    color: white;
}
.btn-success:hover {
    background-color: var(--success-hover);
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}
.btn-danger:hover {
    background-color: var(--danger-hover);
}

.btn-secondary {
    background-color: var(--bg-input);
    border-color: var(--border);
    color: var(--text);
}
.btn-secondary:hover {
    background-color: var(--bg-input-focus);
}

.btn-outline-primary {
    background: transparent;
    border-color: var(--primary);
    color: var(--primary);
}
.btn-outline-primary:hover {
    background-color: rgba(0, 210, 255, 0.08);
}

.btn-outline-secondary {
    background: transparent;
    border-color: var(--border);
    color: var(--text-muted);
}
.btn-outline-secondary:hover {
    background-color: rgba(0, 0, 0, 0.02);
    color: var(--text);
}

.btn-outline-danger {
    background: transparent;
    border-color: var(--danger);
    color: var(--danger);
}
.btn-outline-danger:hover {
    background-color: rgba(239, 68, 68, 0.08);
}

.btn-outline-warning {
    background: transparent;
    border-color: var(--warning);
    color: var(--warning);
}
.btn-outline-warning:hover {
    background-color: rgba(245, 158, 11, 0.08);
}

.btn-warning {
    background-color: var(--warning);
    color: #ffffff;
}
.btn-warning:hover {
    background-color: var(--warning-hover);
}

.btn-seed {
    background-color: var(--warning);
    border: none;
    color: #ffffff;
    font-weight: 600;
    padding: 0.4rem 0.85rem;
    border-radius: 0.35rem;
    font-size: 0.8rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    transition: var(--transition-fast);
}
.btn-seed:hover {
    background-color: var(--warning-hover);
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
}

.w-100 {
    width: 100%;
}

.mb-3 { margin-bottom: 0.75rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1.25rem; }
.mr-2 { margin-right: 0.5rem; }

/* TABLES WITH THIN BORDERS */
.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background-color: var(--bg-card);
}

.flex-grow {
    flex-grow: 1;
}

table.thin-borders {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.85rem;
}

table.thin-borders th {
    background: #1e293b !important;
    color: #f1f5f9 !important;
    font-weight: 700;
    padding: 0.75rem 0.85rem;
    border: 1px solid #334155 !important;
    text-align: left;
    white-space: nowrap;
}

table.thin-borders th .th-content,
table.thin-borders th .th-title-sort {
    color: #f1f5f9 !important;
    font-weight: 700 !important;
}

#matrixItemsTable thead th,
.matrix-table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #1e293b !important;
    color: #f1f5f9 !important;
    border: 1px solid #334155 !important;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

#matrixItemsTable thead th .th-content,
#matrixItemsTable thead th .th-title-sort,
.matrix-table thead th .th-content,
.matrix-table thead th .th-title-sort {
    color: #f1f5f9 !important;
    font-weight: 700 !important;
}


table.thin-borders td {
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border); /* Thin grid border */
    color: var(--text);
    text-align: left;
    vertical-align: middle;
    white-space: nowrap;
}

table.thin-borders th.details-header,
table.thin-borders td.details-cell {
    text-align: left !important;
    min-width: clamp(220px, 22vw, 420px);
}

#reportMainTable {
    min-width: 1200px !important;
    width: 100%;
}

#reportMainTable th.details-header,
#reportMainTable td.details-cell {
    min-width: clamp(280px, 26vw, 500px) !important;
    white-space: normal !important;
    word-break: normal;
    overflow-wrap: break-word;
}

/* Allow text to wrap in content-heavy columns */
table.thin-borders td.details-cell,
table.thin-borders td.text-wrap {
    white-space: normal;
}

table.thin-borders tr:hover td {
    background-color: rgba(0, 0, 0, 0.01);
}

/* BADGES */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-info {
    background-color: rgba(0, 210, 255, 0.1);
    color: var(--primary);
    border: 1px solid rgba(0, 210, 255, 0.2);
}

.badge-success {
    background-color: rgba(34, 197, 94, 0.1);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.badge-warning {
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-danger {
    background-color: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-purple {
    background-color: rgba(167, 139, 250, 0.1);
    color: var(--purple);
    border: 1px solid rgba(167, 139, 250, 0.2);
}

.badge-orange {
    background-color: rgba(249, 115, 22, 0.1);
    color: #fb923c;
    border: 1px solid rgba(249, 115, 22, 0.2);
}

.badge-teal {
    background-color: rgba(20, 184, 166, 0.1);
    color: #2dd4bf;
    border: 1px solid rgba(20, 184, 166, 0.2);
}

.badge-muted {
    background-color: rgba(148, 163, 184, 0.08);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.custom-status-dropdown-wrapper {
    position: relative;
    display: inline-block;
}

.status-trigger-btn {
    outline: none !important;
    cursor: pointer !important;
    font-family: var(--font-sans);
    transition: var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.status-trigger-btn:hover {
    filter: brightness(0.92);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.status-dropdown-menu {
    position: absolute;
    top: 105%;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.35rem;
    z-index: 1000;
    box-shadow: var(--shadow-xl);
    display: none;
    min-width: 120px;
    padding: 0.25rem;
    backdrop-filter: blur(10px);
}

.status-dropdown-menu.show {
    display: block;
}

.status-dropdown-item {
    padding: 0.35rem 0.5rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: var(--transition-fast);
    border-radius: 0.25rem;
}

.status-dropdown-item:hover {
    background-color: rgba(0, 210, 255, 0.06);
}

.status-dropdown-item .badge {
    width: 100%;
    justify-content: center;
    cursor: pointer;
}

/* 1. PARTY ORDER ENTRY GRID */
.order-entry-layout {
    display: grid;
    grid-template-columns: 640px 1fr;
    gap: 1.25rem;
    align-items: stretch;
    height: calc(100vh - 135px);
    min-height: 550px;
}

.order-entry-layout .left-panel {
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.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.75rem;
}

/* RADIO TOGGLE GROUP */
.radio-toggle-group {
    display: flex;
    background-color: var(--bg-input);
    padding: 0.2rem;
    border-radius: 0.35rem;
    border: 1px solid var(--border);
}

.radio-toggle {
    flex: 1;
    text-align: center;
    cursor: pointer;
}

.radio-toggle input {
    display: none;
}

.radio-toggle span {
    display: block;
    padding: 0.4rem 0.75rem;
    border-radius: 0.25rem;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    transition: var(--transition-fast);
}

.radio-toggle input:checked + span {
    background-color: var(--bg-input-focus);
    color: var(--primary);
}

/* UNIT SELECTOR */
.unit-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.2rem;
    margin-bottom: 0.4rem;
}

.unit-btn {
    flex-grow: 1;
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.4rem 0.5rem;
    border-radius: 0.25rem;
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition-fast);
    text-align: center;
    min-width: 45px;
}

.unit-btn:hover {
    color: var(--text);
    border-color: rgba(0, 0, 0, 0.15);
}

.unit-btn.active {
    background-color: rgba(0, 210, 255, 0.12) !important;
    border-color: var(--primary) !important;
    color: var(--primary) !important;
}

.helper-text {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

/* CUSTOM SEARCHABLE SELECT */
.custom-select-wrapper {
    position: relative;
}
.custom-select-wrapper::after {
    content: '';
    position: absolute;
    right: 14px;
    top: 50%;
    width: 5px;
    height: 5px;
    border-right: 1.5px solid var(--text-muted);
    border-bottom: 1.5px solid var(--text-muted);
    transform: translateY(-50%) rotate(45deg);
    pointer-events: none;
    transition: transform var(--transition-fast);
}

.custom-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.35rem;
    max-height: 180px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    box-shadow: var(--shadow-xl);
}

.custom-options.show {
    display: block;
}

.custom-option {
    padding: 0.5rem 0.85rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: var(--transition-fast);
    white-space: normal;
    word-break: break-word;
    line-height: 1.4;
}

.custom-option:hover {
    background-color: rgba(0, 210, 255, 0.08); /* Light sky hover */
    color: var(--text);
}

.custom-option.selected {
    background-color: rgba(0, 210, 255, 0.1);
    color: var(--primary);
    font-weight: 700;
}

/* SIZES INPUT GRID */
.sizes-container {
    background-color: rgba(0, 0, 0, 0.03);
    border: 1px solid var(--border);
    border-radius: 0.35rem;
    padding: 0.75rem;
    margin-bottom: 1rem;
}

.sizes-header {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    letter-spacing: 0.5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.all-size-btn {
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.68rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1.2;
    white-space: nowrap;
    text-transform: uppercase;
}
.all-size-btn:hover {
    background: #2563eb;
    color: #ffffff;
    border-color: #2563eb;
}

.all-size-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s ease;
}
.all-size-badge:hover {
    background: #bfdbfe;
    color: #1e3a8a;
}

.all-size-breakdown {
    margin-top: 4px;
    padding: 6px 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.75rem;
}

.sizes-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem;
}

.size-input-row {
    display: flex;
    align-items: center;
    justify-content: space-between !important;
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    padding: 2px 4px !important;
    height: 32px !important;
}

.size-input-row label {
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem !important;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    flex: 1 1 0 !important;
    min-width: 0 !important;
    max-width: 100% !important;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    padding-right: 4px !important;
}

.size-input-row input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--primary);
    cursor: pointer;
}

.size-input-row input[type="number"] {
    flex: 0 0 54px !important;
    width: 54px !important;
    border: 1px solid var(--border) !important;
    background-color: var(--bg-input) !important;
    color: var(--text) !important;
    padding: 0 3px !important;
    font-size: 0.9rem !important;
    text-align: center !important;
    height: 24px !important;
    min-width: 30px !important;
    border-radius: 4px !important;
    outline: none !important;
    line-height: normal !important;
    transition: var(--transition-fast);
}

.size-input-row input[type="number"]:focus:not(:disabled) {
    border-color: var(--primary);
    background-color: var(--bg-input-focus);
}

.size-input-row input[type="number"]:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background-color: transparent;
    border-color: transparent;
}

.size-unit-lbl {
    font-size: 0.75rem !important;
    font-weight: 700;
    color: var(--text-muted);
    margin-left: 0.2rem;
    white-space: nowrap;
    flex: 0 0 auto;
    width: auto;
    min-width: 28px;
    text-align: left;
}

.sizes-footer-badges {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.sizes-footer-badges .badge {
    position: relative !important;
    display: inline-flex !important;
    margin: 0 !important;
    white-space: nowrap;
}

#orderForm {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.order-form-body {
    flex: 1;
    overflow-y: auto;
    padding-right: 6px;
    padding-bottom: 140px;
    margin-bottom: 0.5rem;
    display: flex;
    flex-direction: column;
}

.order-form-body::-webkit-scrollbar {
    width: 5px;
}

.order-form-body::-webkit-scrollbar-thumb {
    background-color: rgba(150, 150, 150, 0.25);
    border-radius: 4px;
}

#normalItemSection,
#mixBundleSection {
    padding-bottom: 0.5rem;
}

/* STICKY ACTIONS BAR (LEFT PANEL FOOTER) */
.sticky-action-bar {
    position: relative;
    margin-top: auto;
    padding-top: 0.85rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    background-color: var(--bg-card);
    border-top: 1px solid var(--border);
    z-index: 10;
    flex-shrink: 0;
}

.sticky-action-bar button {
    flex: 1;
    height: 42px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.order-grid-actions-row {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 0.75rem;
    margin-bottom: 1rem;
}

.order-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

.stat-card {
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.6rem 0.85rem;
}

.stat-title {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 0.15rem;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* STACKED FRACTION DISPLAY FORMAT (MANDATORY ERP STYLE) */
.fraction-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.fraction-box {
    width: 58px;
    text-align: center;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.05;
}

.fraction-box-done {
    position: relative;
    opacity: 0.55 !important;
}

.fraction-box-done::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom right, transparent calc(50% - 1px), #64748b calc(50% - 1px), #64748b calc(50% + 1px), transparent calc(50% + 1px));
    pointer-events: none;
}

.fraction-size {
    color: #0284c7;
    font-weight: 700;
    font-size: 14px;
}

.fraction-line {
    width: 44px;
    height: 1px;
    background: var(--text);
    margin: 3px 0 3px 0;
}

.fraction-qty {
    color: var(--text);
    font-weight: 700;
    font-size: 13px;
    white-space: nowrap;
}

.plus {
    color: var(--text);
    font-weight: 700;
    margin-top: -2px;
}

.mix-detail {
    margin-bottom: 8px;
}

.mix-item-title {
    font-weight: 700;
    font-size: 13px;
    margin-bottom: 4px;
    text-align: left;
}

.mix-item-details-block {
    border-left: 2px solid rgba(0, 210, 255, 0.25);
    padding-left: 0.5rem;
    margin-bottom: 0.35rem;
}

.mix-item-details-block:last-child {
    margin-bottom: 0;
}

.text-center { text-align: center; }
.py-5 { padding-top: 2.5rem; padding-bottom: 2.5rem; }

/* 2. ORDER VIEW FILTERS */
.filters-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    background-color: rgba(0, 0, 0, 0.03);
    padding: 0.85rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
}

/* FROZEN / STICKY ORDER VIEW LAYOUT */
#tab-order-view {
    height: calc(100vh - 90px);
    overflow: hidden;
}

#tab-order-view .page-card {
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: unset;
    padding: 0.5rem 1rem;
}

#tab-order-view .page-title-area {
    flex-shrink: 0;
    margin-bottom: 0.4rem;
}

#tab-order-view .page-title {
    font-size: 1.1rem; /* compact title */
    margin-bottom: 0;
}

#tab-order-view .page-subtitle {
    font-size: 0.75rem;
    margin-top: 0.1rem;
}

#tab-order-view .filters-row {
    flex-shrink: 0;
    margin-bottom: 0.6rem;
    padding: 0.6rem 0.85rem; /* tighter padding */
}

#tab-order-view .table-wrapper {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    background: var(--bg-card);
}

#tab-order-view .table-footer-summary {
    flex-shrink: 0;
    border-top: 1px solid var(--border);
}

/* ========================================== */
/* MODERN ENTERPRISE ORDER VIEW STYLING       */
/* ========================================== */
.order-view-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.order-view-title-group {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.order-count-pill {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 20px;
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary);
    border: 1px solid rgba(37, 99, 235, 0.2);
}

.order-status-pills {
    height: 32px;
    padding: 2px;
    gap: 2px;
}

.order-status-pills .toggle-btn {
    padding: 0 0.65rem;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border-radius: 4px;
}

.pill-count {
    font-size: 0.68rem;
    padding: 1px 5px;
    border-radius: 10px;
    background: rgba(0,0,0,0.06);
    font-weight: 800;
}

.toggle-btn.active .pill-count {
    background: rgba(255,255,255,0.25);
    color: #fff;
}

.order-view-top-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.order-view-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: nowrap;
    margin-bottom: 0.5rem;
    background: var(--bg-card);
    padding: 0.35rem 0.6rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    height: 42px;
    box-sizing: border-box;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 180px;
    height: 32px;
}

.search-input-wrapper .search-icon {
    position: absolute;
    left: 0.6rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    pointer-events: none;
}

.search-input-wrapper input {
    width: 100%;
    height: 32px;
    padding: 0 1.8rem 0 1.8rem;
    font-size: 0.8rem;
    border-radius: 0.35rem;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
    box-sizing: border-box;
}

.search-clear-btn {
    position: absolute;
    right: 0.5rem;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
}

.search-clear-btn:hover {
    color: var(--danger);
}

.toolbar-item {
    display: flex;
    align-items: center;
    height: 32px;
    flex-shrink: 0;
}

.category-select-wrap select {
    height: 32px;
    padding: 0 0.6rem;
    font-size: 0.78rem;
    border-radius: 0.35rem;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
    cursor: pointer;
    max-width: 150px;
}

.date-range-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 0.35rem;
    padding: 0 0.45rem;
    height: 32px;
    box-sizing: border-box;
}

.date-range-wrap input[type="date"] {
    border: none;
    background: transparent;
    padding: 0;
    font-size: 0.75rem;
    color: var(--text);
    height: 28px;
    outline: none;
}

.date-sep {
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.actions-wrap button {
    height: 32px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    padding: 0 0.65rem;
    border-radius: 0.35rem;
}

.clean-data-table {
    width: 100%;
    border-collapse: collapse;
}

#orderViewTable thead th,
.clean-data-table thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: #1e293b !important;
    color: #f1f5f9 !important;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.6rem 0.65rem;
    border-bottom: 2px solid #0f172a !important;
    border-top: none;
    user-select: none;
    white-space: nowrap !important;
}

#orderViewTable thead th .th-content,
.clean-data-table thead th .th-content {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #f1f5f9;
}

#orderViewTable thead th .sort-icon,
.clean-data-table thead th .sort-icon {
    font-size: 0.75rem;
    color: #94a3b8;
    opacity: 0.7;
    transition: opacity 0.2s, color 0.2s;
}

#orderViewTable thead th:hover .sort-icon,
.clean-data-table thead th:hover .sort-icon {
    opacity: 1;
    color: #38bdf8;
}

#orderViewTable thead th .sort-icon.active,
.clean-data-table thead th .sort-icon.active {
    opacity: 1;
    color: #38bdf8;
}

/* TH Content and Filter Buttons */
.clean-data-table thead th .th-title-sort {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    flex: 1;
    min-width: 0;
}

.th-filter-btn {
    background: transparent;
    border: none;
    padding: 2px 4px;
    border-radius: 4px;
    color: #94a3b8;
    cursor: pointer;
    font-size: 0.76rem;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 1;
}

.th-filter-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.15);
}

.th-filter-btn.active {
    color: #38bdf8 !important;
    background: rgba(56, 189, 248, 0.2) !important;
    font-weight: 700;
    box-shadow: 0 0 6px rgba(56, 189, 248, 0.4);
}

/* Active Filters Chips Bar */
.active-filters-chips-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0.4rem 0.85rem;
    background: rgba(56, 189, 248, 0.06);
    border: 1px dashed rgba(56, 189, 248, 0.35);
    border-radius: 0.4rem;
    margin-bottom: 0.5rem;
}

.active-filters-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 4px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.active-chips-list {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.active-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.active-filter-chip .chip-col-name {
    color: var(--text-muted);
    font-weight: 500;
}

.active-filter-chip .chip-remove-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    padding: 0 1px;
    transition: color 0.15s;
    line-height: 1;
}

.active-filter-chip .chip-remove-btn:hover {
    color: var(--danger);
}

.btn-clear-all-chips {
    margin-left: auto;
    background: transparent;
    border: none;
    color: var(--danger);
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.15s;
}

.btn-clear-all-chips:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Excel-Style Floating Filter Dropdown */
.excel-filter-dropdown {
    position: fixed;
    z-index: 100000;
    width: 290px;
    background: var(--bg-card, #ffffff);
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 0.6rem;
    box-shadow: 0 12px 28px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.15);
    font-family: var(--font-sans);
    color: var(--text, #1e293b);
    animation: filterDropdownIn 0.15s ease-out;
    overflow: hidden;
}

@keyframes filterDropdownIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.efd-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 0.75rem;
    background: var(--bg-card-header, #f8fafc);
    border-bottom: 1px solid var(--border, #e2e8f0);
}

.efd-title {
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--text, #0f172a);
    display: flex;
    align-items: center;
    gap: 4px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.efd-clear-link {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--primary, #3b82f6);
    cursor: pointer;
    background: transparent;
    border: none;
    padding: 0;
}

.efd-clear-link:hover {
    text-decoration: underline;
}

/* Sort Section in Popover */
.efd-sort-section {
    padding: 0.4rem 0.65rem;
    border-bottom: 1px solid var(--border, #e2e8f0);
    background: rgba(0,0,0,0.02);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.efd-sort-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    height: 28px;
    padding: 0 0.5rem;
    border-radius: 0.3rem;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text, #334155);
    font-size: 0.74rem;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: all 0.12s ease;
}

.efd-sort-btn:hover {
    background: rgba(59, 130, 246, 0.12);
    color: var(--primary, #3b82f6);
}

.efd-sort-btn.active {
    background: var(--primary, #3b82f6);
    color: #ffffff;
    font-weight: 700;
}

.efd-search-box {
    padding: 0.5rem 0.65rem;
    border-bottom: 1px solid var(--border, #f1f5f9);
    position: relative;
    display: flex;
    align-items: center;
}

.efd-search-input {
    width: 100%;
    height: 30px;
    padding: 0 0.65rem 0 32px !important;
    font-size: 0.75rem;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 0.35rem;
    background: var(--bg-body, #f8fafc);
    color: var(--text, #0f172a);
    outline: none;
    box-sizing: border-box;
}

.efd-search-input:focus {
    border-color: var(--primary);
    background: var(--bg-card, #ffffff);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.efd-search-icon {
    position: absolute;
    left: 19px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.85rem;
    color: var(--text-muted, #94a3b8);
    pointer-events: none;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
}

.efd-actions-row {
    display: flex;
    justify-content: space-between;
    padding: 0.35rem 0.65rem;
    border-bottom: 1px solid var(--border, #f1f5f9);
    background: var(--bg-card, #ffffff);
}

.efd-quick-btn {
    font-size: 0.68rem;
    color: var(--text-muted, #64748b);
    background: transparent;
    border: none;
    cursor: pointer;
    font-weight: 600;
    padding: 1px 4px;
    border-radius: 3px;
}

.efd-quick-btn:hover {
    color: var(--primary);
    background: var(--bg-body, #f1f5f9);
}

.efd-list {
    max-height: 190px;
    overflow-y: auto;
    padding: 0.35rem 0;
}

.efd-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.35rem 0.65rem;
    cursor: pointer;
    user-select: none;
    font-size: 0.74rem;
    color: var(--text, #334155);
    transition: background 0.1s;
}

.efd-item:hover {
    background: var(--bg-body, #f1f5f9);
}

.efd-item-left {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.efd-item-left span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.efd-checkbox {
    width: 14px;
    height: 14px;
    accent-color: var(--primary);
    cursor: pointer;
}

.efd-count {
    font-size: 0.68rem;
    color: var(--text-muted, #94a3b8);
    font-weight: 600;
    padding-left: 4px;
}

.efd-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    padding: 0.45rem 0.65rem;
    background: var(--bg-card-header, #f8fafc);
    border-top: 1px solid var(--border, #e2e8f0);
}

.efd-btn {
    height: 26px;
    padding: 0 0.65rem;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 0.3rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.efd-btn-apply {
    background: var(--primary);
    color: #ffffff;
    border: none;
}

.efd-btn-apply:hover {
    background: var(--primary-hover);
}

.efd-btn-cancel {
    background: var(--bg-card, #ffffff);
    color: var(--text-muted, #64748b);
    border: 1px solid var(--border, #cbd5e1);
}

.efd-btn-cancel:hover {
    background: var(--bg-body, #f1f5f9);
    color: var(--text, #0f172a);
}

.efd-empty {
    padding: 1rem;
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-muted, #94a3b8);
}

.efd-date-presets {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0.5rem 0.65rem;
}

.efd-preset-btn {
    text-align: left;
    background: var(--bg-body, #f8fafc);
    border: 1px solid var(--border, #e2e8f0);
    padding: 0.35rem 0.5rem;
    border-radius: 0.3rem;
    font-size: 0.72rem;
    color: var(--text, #334155);
    cursor: pointer;
    font-weight: 500;
}

.efd-preset-btn:hover, .efd-preset-btn.active {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 700;
}

.efd-date-custom {
    padding: 0.55rem 0.65rem;
    border-top: 1px solid var(--border, #f1f5f9);
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--bg-card, #ffffff);
}

.efd-date-custom-title {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 2px;
}

.efd-date-field-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.efd-date-field-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted, #475569);
    width: 36px;
    flex-shrink: 0;
}

.efd-date-input {
    height: 28px;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 0.3rem;
    padding: 0 0.45rem;
    font-size: 0.74rem;
    color: var(--text, #0f172a);
    outline: none;
    width: 100%;
    box-sizing: border-box;
    background: var(--bg-body, #f8fafc);
}

.efd-date-input:focus {
    border-color: var(--primary);
    background: var(--bg-card, #ffffff);
}

/* Numeric Condition Section in Popover */
.efd-num-section {
    padding: 0.6rem 0.65rem;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.efd-num-select {
    width: 100%;
    height: 30px;
    border-radius: 0.35rem;
    border: 1px solid var(--border, #cbd5e1);
    background: var(--bg-body, #f8fafc);
    color: var(--text, #0f172a);
    font-size: 0.75rem;
    padding: 0 0.5rem;
    outline: none;
    font-weight: 500;
}

.efd-num-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.efd-num-input {
    width: 100%;
    height: 28px;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 0.3rem;
    padding: 0 0.45rem;
    font-size: 0.74rem;
    color: var(--text, #0f172a);
    background: var(--bg-body, #f8fafc);
    outline: none;
    box-sizing: border-box;
}

.efd-num-input:focus {
    border-color: var(--primary);
    background: var(--bg-card, #ffffff);
}

.efd-qty-custom {
    padding: 0.65rem;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.efd-qty-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.efd-qty-input {
    width: 100%;
    height: 28px;
    border: 1px solid #cbd5e1;
    border-radius: 0.3rem;
    padding: 0 0.4rem;
    font-size: 0.74rem;
    color: #0f172a;
    outline: none;
    box-sizing: border-box;
}

.clean-data-table tbody tr {
    transition: background-color 0.15s ease;
    height: 48px;
}

.clean-data-table tbody tr:hover {
    background-color: rgba(37, 99, 235, 0.035);
}

.clean-data-table tbody td {
    padding: 0.45rem 0.65rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
    font-size: 0.82rem;
}

/* Order View, Order Items Grid & Dispatch Table compact size chips & details */
#orderViewTable th,
#orderViewTable td,
#orderItemsTable th,
#orderItemsTable td,
#dispatchTable th,
#dispatchTable td {
    text-align: left;
}

#orderViewTable .th-content,
#orderItemsTable .th-content,
#dispatchTable .th-content {
    justify-content: flex-start !important;
}

#orderViewTable .row-actions-group,
#orderItemsTable .row-actions-group,
#dispatchTable .row-actions-group {
    justify-content: flex-start !important;
}

#orderViewTable .details-cell,
#orderItemsTable .details-cell,
#dispatchTable .details-cell,
#reportMainTable .details-cell,
.details-cell {
    text-align: left !important;
    padding: 0.35rem 0.5rem;
    vertical-align: middle;
}

#orderViewTable .fraction-row,
#orderItemsTable .fraction-row,
#dispatchTable .fraction-row,
#reportMainTable .fraction-row,
.fraction-row {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    flex-wrap: wrap;
    text-align: left;
    margin: 0;
}

#orderViewTable .fraction-box,
#orderItemsTable .fraction-box,
#dispatchTable .fraction-box,
#reportMainTable .fraction-box {
    width: auto;
    min-width: unset;
    padding: 2.5px 7px;
    border-radius: 4px;
    background: #f0f7ff;
    border: 1px solid #bfdbfe;
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 3px;
    line-height: 1.1;
    flex-shrink: 0;
    margin: 1.5px 1px;
}

#orderViewTable .fraction-box-done,
#orderItemsTable .fraction-box-done,
#dispatchTable .fraction-box-done,
#reportMainTable .fraction-box-done {
    position: relative;
    background: #f1f5f9 !important;
    border-color: #cbd5e1 !important;
    color: #94a3b8 !important;
    text-decoration: line-through;
}

#orderViewTable .fraction-size,
#orderItemsTable .fraction-size,
#dispatchTable .fraction-size,
#reportMainTable .fraction-size {
    color: #0369a1;
    font-weight: 700;
    font-size: 11px;
}

#orderViewTable .fraction-line,
#orderItemsTable .fraction-line,
#dispatchTable .fraction-line,
#reportMainTable .fraction-line {
    width: 1px;
    height: 9px;
    background: rgba(100, 116, 139, 0.4);
    margin: 0 1px;
}

#orderViewTable .fraction-qty,
#orderItemsTable .fraction-qty,
#dispatchTable .fraction-qty,
#reportMainTable .fraction-qty {
    color: var(--text);
    font-weight: 700;
    font-size: 10.5px;
    white-space: nowrap;
}

#orderViewTable .mix-chips-grid,
#orderItemsTable .mix-chips-grid,
#dispatchTable .mix-chips-grid,
#reportMainTable .mix-chips-grid {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

#orderViewTable .mix-sub-row,
#orderItemsTable .mix-sub-row,
#dispatchTable .mix-sub-row,
#reportMainTable .mix-sub-row {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

#orderViewTable .mix-sub-label,
#orderItemsTable .mix-sub-label,
#dispatchTable .mix-sub-label,
#reportMainTable .mix-sub-label {
    font-size: 10.5px;
    font-weight: 700;
    color: #b45309;
    white-space: nowrap;
}

#dispatchTable .btn-sm {
    padding: 4px 10px;
    font-size: 0.76rem;
    font-weight: 600;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.party-primary-name {
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    line-height: 1.25;
    transition: color 0.15s;
}

.party-primary-name:hover {
    color: var(--primary);
    text-decoration: underline;
}

.party-sub-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 2px;
}

.party-station {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.item-primary-name {
    font-weight: 700;
    color: var(--primary);
    line-height: 1.25;
}

.item-remark-sub {
    font-size: 0.72rem;
    color: #dc2626;
    display: flex;
    align-items: center;
    gap: 3px;
    margin-top: 2px;
}

.badge-category-tag {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    background: rgba(100, 116, 139, 0.08);
    color: var(--text-muted);
    border: 1px solid rgba(100, 116, 139, 0.18);
    white-space: nowrap;
}

.qty-cell-val {
    display: flex;
    align-items: baseline;
    justify-content: flex-start !important;
    gap: 4px;
    text-align: left !important;
}

.qty-num {
    font-weight: 800;
    font-size: 0.92rem;
    color: var(--text);
}

.qty-unit-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 700;
}

/* Status Trigger Badges */
.status-trigger-btn {
    border-radius: 20px;
    padding: 3px 8px;
    font-size: 0.72rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    border: none;
    transition: transform 0.15s, box-shadow 0.15s;
}

.status-trigger-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.status-badge-submitted {
    background: rgba(16, 185, 129, 0.12);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.3) !important;
}

.status-badge-submitted .status-dot {
    background: #10b981;
}

.status-badge-draft {
    background: rgba(100, 116, 139, 0.12);
    color: #64748b;
    border: 1px solid rgba(100, 116, 139, 0.3) !important;
}

.status-badge-draft .status-dot {
    background: #94a3b8;
}

.status-badge-hold {
    background: rgba(245, 158, 11, 0.12);
    color: #d97706;
    border: 1px solid rgba(245, 158, 11, 0.3) !important;
}

.status-badge-hold .status-dot {
    background: #f59e0b;
}

.status-badge-cancelled {
    background: rgba(239, 68, 68, 0.12);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.3) !important;
}

.status-badge-cancelled .status-dot {
    background: #ef4444;
}

.status-arrow {
    font-size: 0.65rem;
    opacity: 0.6;
}

/* Action Group */
.row-actions-group {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
}

.row-action-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-body);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.15s ease;
}

.row-action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.action-print:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.08);
}

.action-edit:hover {
    color: var(--warning);
    border-color: var(--warning);
    background: rgba(245, 158, 11, 0.08);
}

.action-delete:hover {
    color: var(--danger);
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.08);
}

/* Modern Summary Footer */
.modern-summary-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem 0.85rem;
    background: var(--bg-card-header);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 0.5rem 0.5rem;
}

.summary-left {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 600;
}

.summary-left strong {
    color: var(--text);
    font-weight: 800;
}

.summary-chips {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.metric-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.74rem;
    font-weight: 600;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.metric-chip strong {
    color: var(--text);
    font-weight: 800;
}

.metric-chip.chip-total {
    background: rgba(37, 99, 235, 0.08);
    border-color: rgba(37, 99, 235, 0.25);
    color: var(--primary);
}

.metric-chip.chip-total strong {
    color: var(--primary);
}

/* Sticky table header inside masters and others */
#partiesMasterTable thead th,
#itemsMasterTable thead th,
#bundleWeightMasterTable thead th,
#transportMasterTableActual thead th,
#transportsMasterTable thead th,
#unitsMasterTable thead th,
#proformaListTable thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: #1e293b !important;
    color: #f1f5f9 !important;
    font-weight: 700 !important;
    border-bottom: 2px solid #0f172a !important;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.filter-group label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group input,
.filter-group select {
    padding: 0.5rem 0.65rem;
    font-size: 0.8rem;
}

.search-filter {
    position: relative;
    min-width: 240px;
}

.search-filter input {
    padding-left: 2rem !important;
}

.filter-icon {
    position: absolute;
    left: 0.65rem;
    top: 55%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.85rem;
}

.toggle-tabs {
    display: flex;
    background-color: var(--bg-input);
    padding: 0.2rem;
    border-radius: 0.35rem;
    border: 1px solid var(--border);
    height: 34px;
}

.toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0 0.85rem;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.toggle-btn:hover {
    color: var(--text);
}

.toggle-btn.active {
    background-color: var(--primary);
    color: #ffffff;
    font-weight: 500;
}

.table-footer-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-card-header);
    border: 1px solid var(--border);
    border-top: none;
    padding: 0.65rem 1rem;
    border-bottom-left-radius: 0.5rem;
    border-bottom-right-radius: 0.5rem;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
}

.table-footer-summary span span {
    color: var(--primary);
}

/* 3. DISPATCH LAYOUT */
.dispatch-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
    height: calc(100vh - 105px);
    position: relative;
    overflow: hidden;
}

.dispatch-layout.drawer-open,
#tab-dispatch.drawer-open .dispatch-layout {
    grid-template-columns: 1fr 450px;
}


.dispatch-layout .left-panel {
    height: 100%;
    overflow: hidden;
}

.dispatch-layout .right-sidebar {
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border);
    animation: slideInRight 0.2s ease-out;
}

.drawer-body {
    flex-grow: 1;
    overflow-y: auto;
    padding-bottom: 1rem;
}

.drawer-footer {
    flex-shrink: 0;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    background: var(--bg-card);
}

/* UNIFIED DISPATCH FILTER BAR */
.dispatch-unified-filters {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    flex-wrap: wrap;
    background-color: rgba(0, 0, 0, 0.03);
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    margin-bottom: 0.4rem;
    flex-shrink: 0;
    padding: 0.4rem 0.75rem;
}

.dispatch-unified-filters .filter-group {
    margin-bottom: 0;
}

.dispatch-unified-filters .toggle-tabs {
    height: 38px;
    align-self: flex-end;
}

/* FROZEN DISPATCH LAYOUT */
#tab-dispatch {
    height: calc(100vh - 90px);
    overflow: hidden;
}

#tab-dispatch .left-panel {
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 0.5rem 1rem;
}

#tab-dispatch .section-title {
    flex-shrink: 0;
    font-size: 1.1rem;
    margin-bottom: 0.4rem;
}

#tab-dispatch .table-wrapper {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
}

#tab-dispatch .table-footer-summary {
    flex-shrink: 0;
}

/* Sticky table header inside Dispatch */
#dispatchTable thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background-color: var(--bg-card-header);
}

/* DISPATCH DRAWER */
.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.65rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.75rem;
}

.drawer-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

.btn-close-drawer {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.35rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    transition: var(--transition-fast);
}

.btn-close-drawer:hover {
    background-color: rgba(255,255,255,0.03);
    color: var(--text);
}

.drawer-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
    background-color: var(--bg-input);
    padding: 0.65rem 0.85rem;
    border-radius: 0.35rem;
    font-size: 0.75rem;
    border: 1px solid var(--border);
    margin-bottom: 0.75rem;
}

.drawer-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary);
    margin-top: 1rem;
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ordered-details-box {
    background-color: rgba(0, 0, 0, 0.01);
    border: 1px solid var(--border);
    padding: 0.65rem 0.85rem;
    border-radius: 0.35rem;
    font-size: 0.8rem;
}

.dispatch-sizes-grid-wrapper {
    background-color: rgba(0, 0, 0, 0.03);
    border: 1px solid var(--border);
    border-radius: 0.35rem;
    padding: 0.65rem;
    margin-bottom: 0.65rem;
}

.dispatch-sizes-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
}

.dispatch-qty-rows {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
}

.dispatch-qty-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    padding: 0.35rem 0.65rem;
    border-radius: 0.25rem;
    box-sizing: border-box;
}

.dispatch-qty-row .size-name {
    font-weight: 700;
    font-size: 0.8rem;
    width: 35px;
    flex: 0 0 35px;
    white-space: nowrap;
}

.dispatch-qty-row input[type="number"] {
    flex: 0 0 80px;
    width: 80px;
    border: 1px solid var(--border);
    background-color: var(--bg-input);
    color: var(--text);
    padding: 0.25rem 0.4rem;
    text-align: center;
    font-size: 0.8rem;
    border-radius: 4px;
    outline: none;
    transition: var(--transition-fast);
}
.dispatch-qty-row input[type="number"]:focus {
    border-color: var(--primary);
    background-color: var(--bg-input-focus);
}

.dispatch-qty-row .unit-lbl {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 700;
    white-space: nowrap !important;
    flex: 1;
    text-align: right;
    padding-right: 4px;
}

.dispatch-qty-row-simple {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: rgba(0, 0, 0, 0.03);
    border: 1px solid var(--border);
    padding: 0.6rem 0.85rem;
    border-radius: 0.35rem;
    box-sizing: border-box;
}

.dispatch-qty-row-simple .item-name-label {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--primary);
    text-transform: uppercase;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 80px;
}

.dispatch-qty-row-simple input[type="number"] {
    flex: 0 0 100px;
    width: 100px;
    border: 1px solid var(--border);
    background-color: var(--bg-input);
    color: var(--text);
    padding: 0.35rem 0.5rem;
    text-align: center;
    font-size: 0.9rem;
    border-radius: 4px;
    outline: none;
    transition: var(--transition-fast);
}

.dispatch-qty-row-simple input[type="number"]:focus {
    border-color: var(--primary);
    background-color: var(--bg-input-focus);
}

.dispatch-qty-row-simple .unit-lbl {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 700;
    white-space: nowrap;
    flex: 0 0 auto;
}


/* SUBSTITUTE SECTION */
.substitute-section {
    border: 1px dashed rgba(0, 0, 0, 0.12);
    border-radius: 0.35rem;
    padding: 0.65rem;
    margin-top: 0.85rem;
}

.substitute-header {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.substitute-form-row {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.4rem;
}

.substitute-form-row select,
.substitute-form-row input {
    padding: 0.35rem 0.5rem;
    font-size: 0.75rem;
    height: 32px;
}

.substitute-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.sub-item-pill {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: rgba(0, 210, 255, 0.05);
    border: 1px solid rgba(0, 210, 255, 0.15);
    padding: 0.3rem 0.65rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
}

.btn-delete-sub {
    background: transparent;
    border: none;
    color: var(--danger);
    cursor: pointer;
}

.dispatch-type-radios {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background-color: var(--bg-card);
    padding: 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.4rem 0.5rem;
    border-radius: 0.35rem;
    transition: var(--transition-fast);
}

.radio-label:hover {
    background-color: rgba(0, 210, 255, 0.05);
    color: var(--text);
}

.radio-label input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

.radio-label input:checked + span {
    color: var(--primary);
    font-weight: 700;
}

.drawer-footer {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border);
}

.drawer-footer button {
    flex: 1;
}

.pagination-row {
    display: flex;
    gap: 0.2rem;
}

.page-num-btn {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: bold;
    border-radius: 0.2rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.page-num-btn:hover {
    color: var(--text);
    border-color: rgba(255,255,255,0.1);
}

.page-num-btn.active {
    background-color: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

/* MIX BUNDLE EDITOR ELEMENTS */
.mix-item-editor-card {
    background-color: rgba(0, 0, 0, 0.01);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.85rem;
    margin-bottom: 0.85rem;
}

/* 4. MASTER DATA SUBTABS */
.master-subtabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.25rem;
    gap: 0.75rem;
}

.subtab {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 700;
    padding: 0.5rem 0.4rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.subtab:hover {
    color: var(--text);
}

.subtab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.subtab-content {
    display: none;
    animation: fadeIn 0.15s ease-out;
}

.subtab-content.active {
    display: block;
}

.master-split-layout {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 1.25rem;
    align-items: start;
}

.master-form-card {
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1rem;
    position: sticky;
    top: 1rem;
    z-index: 10;
}

.master-list-card {
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1rem;
    overflow: hidden;
}

.master-list-card .table-wrapper {
    max-height: calc(100vh - 275px);
    overflow-y: auto;
}

.form-title, .list-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.master-form-card .form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.25rem;
}

.master-form-card .form-actions button {
    flex: 1;
    padding: 0.5rem;
    font-size: 0.8rem;
}

/* SIZE MAPPING BUILDER */
.size-mapping-builder {
    border: 1px dashed var(--border);
    padding: 0.65rem;
    border-radius: 0.35rem;
    margin-bottom: 0.85rem;
}

.size-mapping-builder label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
}

.mapping-rows {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-height: 130px;
    overflow-y: auto;
}

.mapping-row {
    display: flex;
    gap: 0.35rem;
}

.mapping-row input,
.mapping-row select {
    padding: 0.3rem 0.5rem;
    font-size: 0.75rem;
    height: 30px;
}

.btn-icon-del {
    background: transparent;
    border: none;
    color: var(--danger);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 0.25rem;
    transition: var(--transition-fast);
}

.btn-icon-del:hover {
    background-color: rgba(239, 68, 68, 0.08);
}

/* CHECKBOX GROUP */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.6rem;
    margin-top: 0.2rem;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
}

.checkbox-label input {
    accent-color: var(--primary);
    width: 14px;
    height: 14px;
}

/* 5. REPORTS LAYOUT */
.report-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 1.25rem;
    height: calc(100vh - 160px);
    min-height: 500px;
}

.report-layout .left-panel {
    height: 100%;
    overflow-y: auto;
    padding: 0.5rem 1rem;
}

.report-layout .right-panel {
    height: 100%;
    overflow: hidden;
    padding: 0.5rem 1rem;
}

#tab-report .table-wrapper {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
}

#reportMainTable thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: #1e293b !important;
    color: #f1f5f9 !important;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.6rem 0.65rem;
    border-bottom: 2px solid #0f172a !important;
    border-top: none;
    text-align: left !important;
}

.report-header-tabs {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.25rem;
}

.report-summary-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.6rem;
}

.summary-card {
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.summary-icon {
    width: 38px;
    height: 38px;
    border-radius: 0.35rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.text-blue .summary-icon {
    background-color: rgba(0, 210, 255, 0.08);
    color: var(--primary);
}
.text-green .summary-icon {
    background-color: rgba(34, 197, 94, 0.08);
    color: var(--success);
}
.text-orange .summary-icon {
    background-color: rgba(245, 158, 11, 0.08);
    color: var(--warning);
}
.text-purple .summary-icon {
    background-color: rgba(167, 139, 250, 0.08);
    color: var(--purple);
}

.summary-num {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text);
}

.summary-lbl {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 700;
}

.report-table-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.3rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.download-buttons-row {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.4rem;
}

/* Make the download section sticky at the bottom of the report left panel */
.download-section {
    position: sticky;
    bottom: 0;
    background-color: var(--bg-card);
    padding-top: 0.75rem;
    padding-bottom: 0.5rem;
    margin-top: 1.25rem;
    border-top: 1px solid var(--border);
    z-index: 10;
}

.btn-excel {
    background-color: rgba(16, 124, 65, 0.1);
    color: #22c55e;
    border: 1px solid rgba(16, 124, 65, 0.25);
}
.btn-excel:hover {
    background-color: rgba(16, 124, 65, 0.2);
}

.btn-pdf {
    background-color: rgba(220, 53, 69, 0.1);
    color: #ef4444;
    border: 1px solid rgba(220, 53, 69, 0.25);
}
.btn-pdf:hover {
    background-color: rgba(220, 53, 69, 0.2);
}

/* NESTED HEADER TABLE FOR REPORTS */
.nested-header-table th,
.nested-header-table td,
#reportMainTable th,
#reportMainTable td {
    text-align: left !important;
    white-space: nowrap;
}

#reportMainTable th[data-col-idx="12"],
#reportMainTable td[data-col-idx="12"] {
    min-width: 180px;
    width: 200px;
    max-width: 240px;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
}

#reportMainTable thead th {
    text-align: left !important;
}

.nested-header-table tr.total-row td {
    background-color: var(--bg-card-header);
    font-weight: 700;
    color: var(--text);
    border-top: 2px solid var(--primary);
}

/* MODAL OVERLAYS */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    width: 550px;
    max-width: 90%;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.25rem;
    background-color: var(--bg-card-header);
    border-bottom: 1px solid var(--border);
}

.btn-close-modal {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.35rem;
    cursor: pointer;
    transition: var(--transition-fast);
}
.btn-close-modal:hover {
    color: var(--text);
}

.modal-body {
    padding: 1.25rem;
}

.modal-body p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.85rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 0.85rem 1.25rem;
    background-color: rgba(0, 0, 0, 0.01);
    border-top: 1px solid var(--border);
}

.seed-instructions {
    background-color: rgba(245, 158, 11, 0.04);
    border: 1px dashed rgba(245, 158, 11, 0.15);
    border-radius: 0.35rem;
    padding: 0.65rem 0.85rem;
    margin-top: 0.85rem;
}

.seed-instructions strong {
    font-size: 0.8rem;
    color: var(--warning);
    display: block;
    margin-bottom: 0.2rem;
}

.seed-instructions p {
    font-size: 0.75rem;
    margin-bottom: 0.4rem;
}

/* ANIMATIONS */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

/* STACKED FRACTION DISPLAY STYLES */
.fraction-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-start;
}

.fraction-box {
    width: 58px;
    text-align: center;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.05;
}

.fraction-size {
    color: #0284c7;
    font-weight: 700;
    font-size: 14px;
}

.rep-fraction-line {
    width: 32px;
    height: 1px;
    background: var(--text);
    margin: 2px 0;
}

.rep-fraction-qty {
    color: var(--text);
    font-weight: 700;
    font-size: 11px;
}

.rep-plus {
    color: var(--text);
    font-weight: 700;
    margin-top: -1px;
}

/* CUSTOM MULTISELECT STYLES */
.custom-multiselect {
    position: relative;
    user-select: none;
}
.multiselect-trigger {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
    transition: var(--transition-fast);
    min-height: 38px;
    box-sizing: border-box;
}
.multiselect-trigger:hover {
    border-color: var(--primary);
    background-color: var(--bg-input-focus);
}
.multiselect-trigger::after {
    content: '';
    width: 5px;
    height: 5px;
    border-right: 1.5px solid var(--text-muted);
    border-bottom: 1.5px solid var(--text-muted);
    transform: translateY(-2px) rotate(45deg);
    margin-left: 0.5rem;
    transition: transform var(--transition-fast);
}
.multiselect-trigger i {
    display: none; /* Hide old icon */
}
.multiselect-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--bg-input-focus);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    margin-top: 4px;
    z-index: 1000;
    max-height: 220px;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    padding: 6px 0;
}
.multiselect-dropdown.show {
    display: block;
}
.multiselect-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: var(--transition-fast);
    margin-bottom: 0 !important;
    font-weight: normal !important;
}
.multiselect-option:hover {
    background-color: rgba(0, 210, 255, 0.08); /* Light sky hover */
    color: var(--text);
}
.multiselect-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
    margin: 0;
}
.multiselect-dropdown .divider {
    height: 1px;
    background-color: var(--border);
    margin: 6px 0;
}


/* GENERIC CUSTOM SELECT STYLES */
.custom-select-ui-wrapper {
    position: relative;
    width: 100%;
    user-select: none;
}
.custom-select-ui-trigger {
    width: 100%;
    box-sizing: border-box;
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 0.35rem;
    padding: 0.6rem 2rem 0.6rem 0.85rem;
    color: var(--text);
    font-size: 0.9rem;
    cursor: text;
    min-height: 38px;
    transition: var(--transition-fast);
}
.custom-select-ui-trigger[readonly] {
    cursor: pointer !important;
}
.custom-select-ui-trigger[readonly]:hover {
    border-color: var(--primary);
    background-color: rgba(255, 255, 255, 0.02);
}
.custom-select-ui-wrapper::after {
    content: '';
    position: absolute;
    right: 14px;
    top: 50%;
    width: 5px;
    height: 5px;
    border-right: 1.5px solid var(--text-muted);
    border-bottom: 1.5px solid var(--text-muted);
    transform: translateY(-50%) rotate(45deg);
    pointer-events: none;
    transition: transform var(--transition-fast);
}
.custom-select-ui-trigger:hover, .custom-select-ui-trigger:focus {
    border-color: var(--primary);
    outline: none;
}
.custom-select-ui-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.35rem;
    margin-top: 4px;
    z-index: 1000;
    max-height: 220px;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    padding: 4px 0;
}
.custom-select-ui-dropdown.show {
    display: block;
}
.custom-select-ui-option {
    padding: 0.5rem 0.85rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: background-color 0.15s ease, color 0.15s ease;
}
.custom-select-ui-option:hover {
    background-color: rgba(0, 210, 255, 0.08); /* Light sky hover */
    color: var(--text);
}
.custom-select-ui-option.selected {
    background-color: rgba(0, 210, 255, 0.15); /* Slightly darker sky for selected */
    color: var(--primary);
    font-weight: 600;
}

/* ==========================================
   MOBILE RESPONSIVENESS AND TABLET BREAKPOINTS
   ========================================== */
@media (max-width: 1024px) {
    /* General resets */
    body {
        overflow-x: hidden;
    }
    .app-container {
        padding: 0.5rem !important;
    }
    
    /* Stack forms columns on mobile/tablet */
    .grid-2col, 
    .grid-item-unit {
        grid-template-columns: 1fr !important;
        gap: 0.5rem;
    }
    
    /* Header Responsive Layout (Premium Mobile/Tablet Design) */
    .app-header {
        height: auto !important;
        min-height: unset !important;
        flex-direction: column !important;
        padding: 0.5rem 1rem !important;
        gap: 0.4rem !important;
        align-items: stretch !important;
    }
    
    .header-logo-wrapper {
        width: 100% !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
    }
    
    .mobile-menu-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }
    
    /* Slide-in Mobile Drawer Navigation */
    .header-nav {
        position: fixed !important;
        top: 0 !important;
        right: -280px !important;
        width: 260px !important;
        height: 100vh !important;
        background-color: var(--bg-main) !important;
        flex-direction: column !important;
        justify-content: flex-start !important;
        padding: 80px 1rem 1rem 1rem !important;
        gap: 0.5rem !important;
        box-shadow: -2px 0 12px rgba(0,0,0,0.15) !important;
        transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        z-index: 1050 !important;
        display: flex !important;
        border-top: none !important;
        overflow-y: auto !important;
        white-space: nowrap !important;
    }
    
    .header-nav.show {
        right: 0 !important;
    }
    
    .header-nav::-webkit-scrollbar {
        display: none !important;
    }
    
    .nav-tab {
        flex: 0 0 auto !important;
        padding: 0.55rem 1rem !important;
        font-size: 0.85rem !important;
        white-space: nowrap !important;
        width: 100% !important;
        justify-content: flex-start !important;
    }

    /* Action Buttons (Always visible below header row, small, horizontal scroll) */
    .header-actions {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        justify-content: flex-start !important;
        width: 100% !important;
        gap: 0.4rem !important;
        padding: 0.35rem 0 0.25rem 0 !important;
        border-top: none !important;
        margin-top: 0 !important;
        position: static !important;
        order: 3 !important;
        scrollbar-width: none !important;
    }
    
    .header-actions::-webkit-scrollbar {
        display: none !important;
    }
    
    .header-actions .btn {
        width: auto !important;
        flex: 0 0 auto !important;
        justify-content: center !important;
        padding: 0.28rem 0.55rem !important;
        font-size: 0.72rem !important;
        white-space: nowrap !important;
    }
    
    .order-bottom-sticky {
        position: -webkit-sticky !important;
        position: sticky !important;
        bottom: 0;
        background-color: var(--bg-card);
        z-index: 1000;
        padding: 10px 0;
        border-top: 1px solid var(--border);
        margin: 0 -1rem -1.25rem -1rem;
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .header-actions .btn {
        width: auto !important;
        flex: 0 0 auto !important;
        justify-content: center !important;
        padding: 0.25rem 0.45rem !important;
        font-size: 0.7rem !important;
        white-space: nowrap !important;
    }

    /* Stack panels vertically (Order Entry Tab) */
    .order-entry-layout {
        grid-template-columns: 1fr !important;
        height: auto !important;
        overflow: visible !important;
        gap: 1rem;
    }
    
    .order-entry-layout .left-panel,
    .order-entry-layout .right-panel {
        max-height: unset !important;
        height: auto !important;
        overflow: visible !important;
    }

    .order-form-body {
        max-height: unset !important;
        height: auto !important;
        overflow: visible !important;
    }
    
    .sticky-action-bar {
        position: static !important;
        margin: 1rem 0 0 0 !important;
        padding: 0 !important;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .sticky-action-bar button {
        width: 100% !important;
    }

    /* Stack Master Data Tabs split layouts */
    .master-split-layout {
        grid-template-columns: 1fr !important;
        height: auto !important;
    }
    
    .master-form-card {
        position: static !important; /* Disable sticky sidebar on mobile */
        width: 100% !important;
        margin-bottom: 1rem !important;
    }
    
    .master-list-card {
        width: 100% !important;
        margin-top: 0 !important;
    }

    /* Stack Reports layout */
    .report-layout {
        grid-template-columns: 1fr !important;
        height: auto !important;
        gap: 1rem;
    }
    
    .report-layout .left-panel,
    .report-layout .right-panel {
        height: auto !important;
        max-height: unset !important;
        overflow: visible !important;
        width: 100% !important;
    }
    
    .download-section {
        position: static !important;
        margin-top: 1rem !important;
    }

    /* Grid columns stack/wrap */
    .order-stats-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 0.25rem !important;
    }
    
    .report-summary-cards {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem;
    }
    
    .stat-card {
        padding: 0.4rem 0.25rem !important;
    }
    .stat-title {
        font-size: 0.55rem !important;
        white-space: nowrap;
    }
    .stat-value {
        font-size: 0.8rem !important;
    }
    
    /* Filters Bar alignment */
    .dispatch-unified-filters, 
    .filters-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .dispatch-unified-filters .filter-group, 
    .filters-row .filter-group {
        width: 100% !important;
    }
    
    .toggle-tabs {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        justify-content: flex-start !important;
        width: 100% !important;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    
    .toggle-tabs::-webkit-scrollbar {
        display: none;
    }
    
    .toggle-btn {
        flex: 0 0 auto !important;
        white-space: nowrap !important;
    }
    
    .filter-actions-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        width: 100%;
    }
    
    .filter-actions-grid .btn {
        width: 100%;
        margin: 0 !important;
        padding: 0.6rem 0.5rem !important;
        font-size: 0.8rem !important;
        justify-content: center;
    }
    /* The filter action buttons are in grid, so this broad rule is no longer strictly needed, but let's constrain it anyway */
    .dispatch-unified-filters > button.btn, 
    .filters-row > button.btn {
        width: 100%;
    }

    /* Full-screen Dispatch Drawer Overlay */
    .dispatch-layout.drawer-open,
    #tab-dispatch.drawer-open .dispatch-layout {
        grid-template-columns: 1fr !important;
    }
    
    .dispatch-layout .right-sidebar {
        position: fixed !important;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100% !important;
        height: 100% !important;
        z-index: 1050;
        background-color: var(--bg-card) !important;
        border-left: none;
        box-shadow: none;
    }

    /* Modal scaling */
    .modal-card {
        width: 95% !important;
        max-width: 100% !important;
        margin: 10px !important;
        padding: 1rem !important;
        max-height: 85vh !important;
    }
    
    .about-card {
        flex-direction: column !important;
        width: 95% !important;
        padding: 1.5rem !important;
        align-items: center;
    }
    
    .about-content {
        padding: 1rem 0 !important;
        order: 2;
        text-align: center;
    }
    
    .about-image-container {
        flex: 0 0 auto !important;
        width: 100px !important;
        height: 100px !important;
        padding: 0 !important;
        margin: 0 auto !important;
        order: 1;
    }
    
    .about-image {
        border-radius: 50% !important;
        width: 100% !important;
        height: 100% !important;
    }
    
    .about-name {
        font-size: 1.8rem !important;
    }
    
    .about-role {
        margin-bottom: 0.75rem !important;
    }
    
    .about-desc {
        font-size: 0.85rem !important;
        margin-bottom: 0.75rem !important;
    }
    
    .about-content button {
        margin: 0.5rem auto 0 auto;
        display: block;
    }

    /* Scrollable pages on mobile */
    #tab-dashboard, #tab-order, #tab-order-view, #tab-dispatch, #tab-report, #tab-master-data {
        height: auto !important;
        overflow: visible !important;
    }
    
    #tab-order-view .page-card, 
    #tab-dispatch .left-panel,
    .report-layout .left-panel,
    .report-layout .right-panel {
        height: auto !important;
        overflow: visible !important;
    }
    
    #tab-order-view .table-wrapper,
    #tab-dispatch .table-wrapper,
    #orderItemsTable .table-wrapper,
    .report-layout .table-wrapper,
    #tab-master-data .table-wrapper {
        overflow-x: auto !important;
        overflow-y: auto !important;
        max-height: 450px !important;
    }

    /* Reduce Button Sizes on Mobile */
    .btn, .btn-import {
        padding: 0.4rem 0.8rem !important;
        font-size: 0.75rem !important;
    }
    .btn-icon-del {
        padding: 0.25rem 0.4rem !important;
        font-size: 0.9rem !important;
    }

    /* Reduce Form Inputs/Selects */
    .form-group input, 
    .form-group select,
    .form-group textarea,
    input[type="text"],
    input[type="number"],
    input[type="date"] {
        padding: 0.45rem 0.6rem !important;
        font-size: 0.85rem !important;
    }
    
    .search-filter input[type="text"],
    input[id*="earch"],
    input[placeholder*="Search"] {
        padding-left: 2.2rem !important;
    }
    

    
    #addCustomColBtn {
        width: auto !important;
        flex: 0 0 auto !important;
        padding: 0 14px !important;
    }
    
    .form-group label,
    .filter-group label {
        font-size: 0.75rem !important;
        margin-bottom: 0.2rem !important;
    }

    /* Compact Tables on Mobile */
    .table th, .table td {
        padding: 0.35rem 0.4rem !important;
        font-size: 0.75rem !important;
    }
    
    .table th {
        font-size: 0.7rem !important;
        white-space: nowrap !important;
    }
    
    .table-footer-summary {
        font-size: 0.75rem !important;
        padding: 0.4rem 0.5rem !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.25rem !important;
    }

    /* Header text */
    .page-title {
        font-size: 1.1rem !important;
    }
    h2 { font-size: 1.25rem !important; }
    h3 { font-size: 1.1rem !important; }
    h4 { font-size: 1rem !important; }
    
    .master-subtabs {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        scrollbar-width: none;
    }
    .master-subtabs::-webkit-scrollbar {
        display: none !important;
    }
    .subtab {
        white-space: nowrap !important;
        font-size: 0.75rem !important;
        padding: 0.4rem 0.6rem !important;
    }
    
    .master-import-actions {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        width: 100%;
    }
    
    .master-import-actions .btn {
        width: 100% !important;
        margin: 0 !important;
        padding: 0.6rem 0.5rem !important;
        font-size: 0.8rem !important;
        justify-content: center !important;
    }
}

@media (max-width: 480px) {
    /* Columns stack for narrower devices */
    .grid-2col, 
    .grid-item-unit {
        grid-template-columns: 1fr !important;
        gap: 0.5rem;
    }
    .report-summary-cards {
        grid-template-columns: 1fr !important;
    }
    .sizes-grid {
        grid-template-columns: 1fr !important;
    }
    .size-input-row {
        padding: 0.35rem 0.5rem;
    }
    .dispatch-type-radios {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ==========================================
   EXCEL IMPORT / EXPORT STYLES
   ========================================== */

.master-list-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.85rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.master-import-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn-import {
    background: linear-gradient(135deg, #16a34a, #15803d);
    color: #ffffff !important;
    border: none !important;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.35rem 0.85rem;
    border-radius: 0.35rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: filter 0.15s ease, transform 0.1s ease;
    user-select: none;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(22, 163, 74, 0.35);
}
.btn-import:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.45);
}
.btn-import:active {
    transform: translateY(0);
}

#downloadPartyFormatBtn,
#downloadItemFormatBtn,
#downloadTransportFormatBtn {
    color: #0891b2 !important;
    border-color: #0891b2 !important;
    font-size: 0.75rem;
    white-space: nowrap;
}
#downloadPartyFormatBtn:hover,
#downloadItemFormatBtn:hover,
#downloadTransportFormatBtn:hover {
    background-color: rgba(8, 145, 178, 0.08) !important;
}

.import-stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem 0.5rem;
    border-radius: 0.65rem;
    border: 1px solid transparent;
    gap: 0.25rem;
}
.import-stat-card .import-stat-icon { font-size: 1.6rem; line-height: 1; }
.import-stat-card .import-stat-num  { font-size: 2rem; font-weight: 800; line-height: 1.1; }
.import-stat-card .import-stat-label {
    font-size: 0.7rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.5px; text-align: center;
}

.import-stat-success { background: rgba(34,197,94,0.08); border-color: rgba(34,197,94,0.25); color: #16a34a; }
.import-stat-skip    { background: rgba(245,158,11,0.08); border-color: rgba(245,158,11,0.25); color: #d97706; }
.import-stat-error   { background: rgba(239,68,68,0.08);  border-color: rgba(239,68,68,0.25);  color: #dc2626; }

.import-log-success { color: #22c55e; }
.import-log-skip    { color: #f59e0b; }
.import-log-error   { color: #f87171; }
.import-log-info    { color: #94a3b8; }

.footer-credit {
    position: fixed;
    bottom: 5px;
    right: 16px;
    font-size: 0.65rem;
    font-family: var(--font-sans);
    color: var(--text-muted);
    opacity: 0.5;
    pointer-events: none;
    z-index: 9999;
    letter-spacing: 0.5px;
}

/* =============================================
   REPORT COLUMN VISIBILITY TOGGLES
   ============================================= */

.col-visibility-section {
    border-top: 1px solid var(--border);
    padding-top: 0.85rem;
}

.col-vis-title {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.68rem;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 0.6rem;
}

.col-vis-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.3rem 0.5rem;
}

.col-vis-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.5rem;
    border-radius: 0.3rem;
    border: 1px solid var(--border);
    background: var(--bg-input);
    cursor: pointer;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: all 0.15s ease;
    user-select: none;
}

.col-vis-item:hover {
    border-color: rgba(59,130,246,0.3);
    color: var(--text);
    background: rgba(59,130,246,0.04);
}

/* When checkbox is checked — item looks "active" */
.col-vis-item:has(input:checked) {
    border-color: rgba(59,130,246,0.35);
    background: rgba(59,130,246,0.07);
    color: var(--primary);
}

.col-vis-item input[type="checkbox"] {
    width: 13px;
    height: 13px;
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
}



/* =============================================
   DISPATCH HISTORY PANEL (Inside Drawer)
   ============================================= */

.dispatch-history-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 1rem;
    max-height: 320px;
    overflow-y: auto;
}

.dispatch-history-item {
    background: linear-gradient(135deg, rgba(59,130,246,0.05) 0%, rgba(124,58,237,0.04) 100%);
    border: 1px solid rgba(59,130,246,0.15);
    border-radius: 0.5rem;
    padding: 0.65rem 0.75rem;
    position: relative;
    transition: border-color 0.15s ease;
}

.dispatch-history-item:hover {
    border-color: rgba(59,130,246,0.3);
}

.dispatch-history-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.35rem;
}

.dispatch-history-item-num {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dispatch-history-item-date {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
}

.dispatch-history-item-actions {
    display: flex;
    gap: 0.3rem;
}

.btn-hist-edit,
.btn-hist-delete {
    background: none;
    border: 1px solid transparent;
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 0.75rem;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    font-family: var(--font-sans);
}

.btn-hist-edit {
    color: var(--primary);
    border-color: rgba(59,130,246,0.2);
}
.btn-hist-edit:hover {
    background: rgba(59,130,246,0.1);
    border-color: var(--primary);
}

.btn-hist-delete {
    color: var(--danger);
    border-color: rgba(220,38,38,0.2);
}
.btn-hist-delete:hover {
    background: rgba(220,38,38,0.08);
    border-color: var(--danger);
}

.dispatch-history-item-body {
    font-size: 0.78rem;
    color: var(--text);
    line-height: 1.5;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.dispatch-history-item-body .hist-qty-row {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.18rem 0.65rem 0.18rem 0.5rem;
    font-size: 0.75rem;
    transition: border-color 0.15s ease;
}

.dispatch-history-item-body .hist-qty-row:hover {
    border-color: rgba(59,130,246,0.35);
}

.dispatch-history-item-body .hist-qty-row .hist-size {
    font-weight: 700;
    color: var(--text-muted);
    font-size: 0.72rem;
    background: rgba(59,130,246,0.08);
    border-radius: 999px;
    padding: 0.05rem 0.45rem;
    border: 1px solid rgba(59,130,246,0.15);
}

.dispatch-history-item-body .hist-qty-row .hist-amount {
    font-weight: 800;
    color: var(--text);
    font-size: 0.78rem;
}

.dispatch-history-item-body .hist-qty-row .hist-amount small {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-left: 0.15rem;
}

.dispatch-history-item-footer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.4rem;
    flex-wrap: wrap;
}

.hist-type-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 0.2rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.hist-type-close {
    background: rgba(34,197,94,0.1);
    color: #16a34a;
    border: 1px solid rgba(34,197,94,0.25);
}

.hist-type-partial {
    background: rgba(124,58,237,0.1);
    color: var(--purple);
    border: 1px solid rgba(124,58,237,0.2);
}

.hist-type-substitute {
    background: rgba(245,158,11,0.1);
    color: var(--warning);
    border: 1px solid rgba(245,158,11,0.2);
}

.hist-remarks {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Inline edit form for a history dispatch entry */
.dispatch-history-edit-form {
    background: rgba(255,255,255,0.9);
    border: 1px solid var(--primary);
    border-radius: 0.4rem;
    padding: 0.65rem 0.75rem;
    margin-top: 0.5rem;
}

.dispatch-history-edit-form .hist-edit-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.45rem;
    flex-wrap: wrap;
}

.dispatch-history-edit-form .hist-edit-row label {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-muted);
    min-width: 60px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 0;
}

.dispatch-history-edit-form .hist-edit-row input[type="number"] {
    height: 28px;
    font-size: 0.78rem;
    padding: 0.2rem 0.5rem;
    width: 75px;
    text-align: center;
}

.dispatch-history-edit-form .hist-edit-row input[type="text"] {
    height: 28px;
    font-size: 0.78rem;
    padding: 0.2rem 0.5rem;
    flex: 1;
}

.dispatch-history-edit-form .hist-edit-actions {
    display: flex;
    gap: 0.4rem;
    justify-content: flex-end;
    margin-top: 0.4rem;
}

/* Separator between history and new dispatch */
.dispatch-new-separator {
    border: none;
    border-top: 2px dashed rgba(59,130,246,0.2);
    margin: 0.75rem 0 0.5rem 0;
}

/* View-only footer (dispatched fully) */
#dispatchDrawerFooter.view-mode #confirmDispatchBtn {
    display: none;
}

/* =============================================
   DASHBOARD VISUAL STYLES
   ============================================= */
.db-metrics-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.db-metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.db-metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.db-metric-icon {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.db-metric-details {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.db-metric-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.db-metric-value {
    font-size: 1.75rem;
    font-weight: 800;
    margin: 0;
    color: var(--text);
    line-height: 1.1;
}

/* Charts Grid */
.db-charts-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.db-card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 1.25rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.02);
}

.db-card-header {
    padding: 0 0 1rem 0;
    border-bottom: none;
    background: transparent;
}

.db-card-header h4 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: #0f172a;
}

.db-chart-container {
    padding: 1.25rem;
    height: 250px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.db-chart-container-large {
    padding: 1.25rem;
    height: 320px;
    position: relative;
}

/* Bottom layout */
.db-bottom-row {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.flex-2 { flex: 2 1 350px; }
.flex-3 { flex: 3 1 450px; }

.db-table-container {
    padding: 0.75rem;
    overflow-x: auto;
    flex: 1;
}

.db-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.db-table th, 
.db-table td {
    padding: 0.65rem 0.85rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.db-table th {
    font-weight: 700;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    background: transparent;
}

.db-table tbody tr:last-child td {
    border-bottom: none;
}

.db-table tbody tr:hover {
    background: rgba(255,255,255,0.01);
}

#fulfillmentChart, #statusChart, #dispatchTypeChart, #monthWiseChart {
    width: 100% !important;
    height: 100% !important;
}

/* Boxed Fraction Styling */
.fraction-row {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin: 4px 0;
}

.fraction-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f0f7ff; 
    border: 1px solid #dbeafe;
    border-radius: 6px;
    padding: 4px 8px;
    min-width: 48px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.fraction-size {
    font-size: 13px;
    font-weight: 700;
    color: #2563eb; 
    text-align: center;
    margin-bottom: 2px;
}

.fraction-line {
    width: 100%;
    height: 1px;
    background-color: #bfdbfe; 
    margin-bottom: 2px;
}

.fraction-qty {
    font-size: 12px;
    font-weight: 700;
    color: #1e293b; 
    text-align: center;
    white-space: nowrap;
}

.fraction-row .plus {
    font-size: 15px;
    font-weight: 800;
    color: #1e293b;
    margin: 0 2px;
}

/* =========================================================
   EXTRA COMPONENT STYLES
   ========================================================= */



/* Enhanced Dispatch Type Radios */
.dispatch-type-radios {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.dispatch-type-radios .radio-label {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--bg-card);
    cursor: pointer;
    transition: all 0.2s ease;
}
.dispatch-type-radios .radio-label:hover {
    border-color: var(--primary);
    background: var(--bg-body);
}
.dispatch-type-radios .radio-label input[type="radio"] {
    margin-right: 0.75rem;
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--primary);
}
.dispatch-type-radios .radio-label span {
    font-weight: 500;
    color: var(--text);
    font-size: 0.9rem;
}
.dispatch-type-radios .radio-label:has(input[type="radio"]:checked) {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.05);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}
.dispatch-type-radios .radio-label:has(input[type="radio"]:checked) span {
    color: var(--primary);
    font-weight: 600;
}

.drawer-footer {
    position: sticky;
    bottom: 0;
    background-color: var(--bg-card);
    z-index: 100;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* FRACTION BOX DESIGN FOR ORDER DETAILS */
.fraction-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
}
.fraction-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #f0f7ff;
    border: 1px solid #dbeafe;
    border-radius: 4px;
    padding: 3px 6px;
    min-width: 32px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.fraction-size {
    font-weight: 700;
    font-size: 0.75rem;
    color: #2563eb;
    line-height: 1;
    margin-bottom: 2px;
}
.fraction-line {
    width: 100%;
    height: 1px;
    background: #bfdbfe;
    margin: 1px 0;
}
.fraction-qty {
    font-weight: 700;
    font-size: 0.65rem;
    color: #1e293b;
    line-height: 1;
    margin-top: 2px;
    white-space: nowrap;
}
.plus {
    font-weight: 700;
    font-size: 0.8rem;
    color: #64748b;
    margin: 0 1px;
}



/* ========================================================= */
/* RESPONSIVE BASE & MEDIA QUERIES                           */
/* ========================================================= */

* {
  box-sizing: border-box;
}

html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

img, video {
  max-width: 100%;
  height: auto;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: auto;
  padding: 0 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

.table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  min-width: 0;
}

.table-wrapper table {
  min-width: 600px;
}

.table-wrapper th, .table-wrapper td {
  white-space: nowrap;
}

@media (max-width: 600px) {
  .container {
    padding: 0 12px;
  }
  
  .app-container {
    padding: 0.5rem;
  }
  
  .card {
    padding: 1rem;
  }

  .grid,
  .row,
  .two-column,
  .form-row,
  .order-entry-layout,
  .grid-2col,
  .grid-item-unit,
  .db-metrics-row {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px;
  }

  .dispatch-unified-filters {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
  }

  .quick-action-grid {
    grid-template-columns: 1fr !important;
  }



  .app-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 6px !important;
    height: auto !important;
    min-height: unset !important;
    padding: 0.5rem 0.75rem !important;
    position: -webkit-sticky;
    position: sticky;
    top: -1px;
    z-index: 1040;
    background-color: var(--bg-card); /* To ensure solid background when sticky */
  }
  
  .header-logo-wrapper {
    width: 100% !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    position: relative;
    z-index: 1060;
  }

  .mobile-menu-toggle {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
  }

  .header-actions {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    justify-content: flex-start !important;
    width: 100% !important;
    margin-top: 0px !important;
    gap: 4px !important;
    padding-bottom: 2px !important;
    scrollbar-width: none !important;
  }
  
  .header-actions::-webkit-scrollbar {
    display: none !important;
  }
  
  .header-actions .btn {
    width: auto !important;
    flex: 0 0 auto !important;
    padding: 0.28rem 0.5rem !important;
    font-size: 0.7rem !important;
    white-space: nowrap !important;
  }

  /* Slide-in logic handled by 1024px media query */
  
  .header-nav .nav-tab {
    width: 100%;
    text-align: left;
    justify-content: flex-start;
    padding-left: 1rem;
    height: 44px;
  }

  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea,
  button:not(.btn-icon-del):not(.btn-icon-edit):not(.nav-tab):not(.unit-btn):not(.btn-close-modal):not(.btn-close-drawer):not(.btn-close-about) {
    width: 100%;
  }

  .card {
    width: 100%;
  }

  h1 {
    font-size: 28px;
    line-height: 1.2;
  }

  h2 {
    font-size: 22px;
  }

  p {
    font-size: 15px;
  }

  .sticky-action-bar,
  .order-grid-actions-row {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }
  
  .sticky-action-bar .btn,
  .order-grid-actions-row .btn {
    width: 100%;
    margin: 0;
    justify-content: center;
    padding: 0.6rem 0.5rem;
    font-size: 0.8rem;
  }
  
  .order-grid-actions-row #submitOrderBtn {
    grid-column: span 2;
  }

  /* Override complex desktop grid layouts */
  .dispatch-layout,
  .dispatch-layout.drawer-open,
  #tab-dispatch.drawer-open .dispatch-layout,
  .master-split-layout,
  .report-layout {
    display: flex !important;
    flex-direction: column !important;
  }
  
  /* Make horizontal tab containers scrollable */
  .master-subtabs,
  .toggle-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    justify-content: flex-start;
    padding-bottom: 5px;
  }
  
  /* Stack dispatch filters */
  .dispatch-unified-filters {
    flex-direction: column;
    align-items: stretch;
  }
  
  .dispatch-unified-filters .filter-group,
  .dispatch-unified-filters .toggle-tabs {
    width: 100%;
  }
  
  .dispatch-unified-filters .toggle-tabs {
    align-self: auto;
    height: auto;
    min-height: 38px;
  }

  /* Stack modal and drawer footers */
  .modal-footer, .drawer-footer {
    flex-direction: column;
    gap: 10px;
  }
  
  .panel-header-row,
  .form-section-title {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
  
  .panel-header-row h2.section-title {
    font-size: 1.1rem !important;
  }
  
  .btn-seed, .btn-voice-mic {
    flex: 1 1 100% !important;
    justify-content: center !important;
  }
}

@media (min-width: 601px) and (max-width: 1024px) {
  .grid,
  .order-entry-layout {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .two-column,
  .grid-2col {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
  }
  
  .dispatch-unified-filters {
    flex-wrap: wrap;
  }
}

/* MINI TOGGLE TABS FOR DASHBOARD CARD */
.toggle-tabs-mini {
    display: flex;
    background-color: var(--bg-input);
    padding: 0.15rem;
    border-radius: 0.25rem;
    border: 1px solid var(--border);
    height: 28px;
}
.btn-toggle-mini {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0 0.65rem;
    border-radius: 0.2rem;
    cursor: pointer;
    transition: var(--transition-fast);
    white-space: nowrap;
}
.btn-toggle-mini:hover {
    color: var(--text);
}
.btn-toggle-mini.active {
    background-color: var(--primary);
    color: #ffffff;
    font-weight: 500;
}

/* ORDER TRACKING TIMELINE STYLING */
.clickable-party {
    cursor: pointer;
    transition: var(--transition-fast);
}
.clickable-party:hover {
    color: var(--primary-hover) !important;
    text-decoration: underline;
}
.timeline-wrapper {
    position: relative;
    padding-left: 24px;
    margin: 1.25rem 0 0.5rem 0;
}
.timeline-wrapper::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 4px;
    bottom: 4px;
    width: 2px;
    background-color: var(--border);
}
.timeline-item {
    position: relative;
    margin-bottom: 1.5rem;
}
.timeline-item:last-child {
    margin-bottom: 0;
}
.timeline-dot {
    position: absolute;
    left: -22px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--bg-card);
    border: 3px solid var(--border);
    z-index: 2;
}
.timeline-item.completed .timeline-dot {
    border-color: #10b981;
    background-color: #10b981;
}
.timeline-item.active .timeline-dot {
    border-color: var(--primary);
    background-color: var(--primary);
}
.timeline-item.cancelled .timeline-dot {
    border-color: #ef4444;
    background-color: #ef4444;
}
.timeline-content {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding-left: 4px;
}
.timeline-title {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text);
    line-height: 1.2;
}
.timeline-date {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}
.timeline-desc {
    font-size: 0.8rem;
    color: var(--text);
    background-color: rgba(0, 0, 0, 0.02);
    padding: 6px 10px;
    border-radius: 0.35rem;
    margin-top: 2px;
    border: 1px solid var(--border);
    line-height: 1.4;
}

/* AI SLIP SCANNER STYLES */
.spinner-dual {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(37, 99, 235, 0.15);
    border-radius: 50%;
    border-top-color: var(--primary);
    border-bottom-color: var(--primary);
    animation: spin 1s linear infinite;
}

@keyframes scannerMove {
    0% { top: 6px; }
    50% { top: calc(100% - 38px); }
    100% { top: 6px; }
}

#slipDragDropZone.dragover {
    background: rgba(37, 99, 235, 0.05) !important;
    border-color: var(--primary) !important;
}

/* INTERACTIVE DARK MODE & PREMIUM UI THEME */
.theme-toggle-btn:hover {
    background-color: var(--border);
    color: var(--primary) !important;
}

[data-theme="dark"] {
    --bg-main: #0f172a; /* Slate 900 */
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%); /* Dark slate gradient */
    --bg-card: rgba(30, 41, 59, 0.7); /* Translucent dark slate */
    --bg-card-header: #1e293b; /* Slate 800 */
    --bg-input: #1e293b;
    --bg-input-focus: #334155;
    
    --primary: #60a5fa; /* Lighter blue for dark mode */
    --primary-hover: #3b82f6;
    
    --success: #34d399;
    --success-hover: #10b981;
    
    --warning: #fbbf24;
    --warning-hover: #f59e0b;
    
    --danger: #f87171;
    --danger-hover: #ef4444;
    
    --purple: #a78bfa;
    --text: #f8fafc; /* Lighter text */
    --text-muted: #94a3b8; /* Lighter muted text */
    --border: rgba(255, 255, 255, 0.1); /* Light border for dark contrast */
}

/* Dark mode native form elements adjustment */
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    color-scheme: dark;
}

/* Lighter scrollbar for dark mode */
[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #475569;
}
[data-theme="dark"] ::-webkit-scrollbar-track {
    background: #0f172a;
}

/* VOICE Command PULSE OVERLAY STYLING */
.voice-status-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 10005;
    display: flex;
    align-items: center;
    justify-content: center;
}
.voice-status-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}
.voice-mic-wave {
    position: relative;
    width: 64px;
    height: 64px;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
}
.voice-mic-wave::before,
.voice-mic-wave::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    border: 2px solid #ef4444;
    animation: micPulse 1.8s infinite ease-in-out;
    opacity: 0;
}
.voice-mic-wave::after {
    animation-delay: 0.9s;
}
@keyframes micPulse {
    0% { transform: scale(1); opacity: 0.5; }
    100% { transform: scale(1.6); opacity: 0; }
}
.voice-status-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
}
.voice-status-transcript {
    font-style: italic;
    font-size: 0.85rem;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.02);
    padding: 8px 12px;
    border-radius: 6px;
    max-height: 80px;
    overflow-y: auto;
    width: 100%;
}
.voice-status-actions {
    margin-top: 4px;
}

#matrixGridContainer {
    max-height: 65vh;
    overflow-y: auto;
    overflow-x: auto;
    position: relative;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
}

#matrixGridContainer table thead th,
.matrix-table th {
    position: sticky !important;
    top: 0 !important;
    z-index: 10 !important;
    background: #1e293b !important;
    color: #f1f5f9 !important;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.65rem 0.75rem;
    border-bottom: 2px solid #0f172a !important;
    border-top: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    white-space: nowrap;
}
.matrix-table th.matrix-item-header {
    text-align: left;
    min-width: 140px;
    position: sticky;
    left: 0;
    z-index: 3;
    background: linear-gradient(135deg, #4c1d95, #6d28d9);
}
.matrix-table td {
    border: 1px solid var(--border);
    padding: 3px;
    vertical-align: middle;
}
.matrix-table td.matrix-item-name {
    padding: 5px 10px;
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--text);
    background: var(--bg-card-header);
    min-width: 140px;
    white-space: nowrap;
    position: sticky;
    left: 0;
    z-index: 1;
    border-right: 2px solid var(--border);
}
.matrix-table td.matrix-item-name.is-size-based {
    color: var(--purple);
}
.matrix-table td.matrix-total-cell {
    padding: 4px 8px;
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--primary);
    background: rgba(59, 130, 246, 0.05);
    text-align: center;
    min-width: 60px;
}
.matrix-qty-input {
    width: 58px;
    height: 28px;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 600;
    background: var(--bg-input);
    color: var(--text);
    display: block;
    margin: auto;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.matrix-qty-input:focus {
    outline: none;
    border-color: var(--purple);
    box-shadow: 0 0 0 2px rgba(109, 40, 217, 0.15);
    background: var(--bg-input-focus);
}
.matrix-qty-input.has-value {
    background: rgba(109, 40, 217, 0.06);
    border-color: var(--purple);
    color: var(--purple);
}
.matrix-qty-input.na-cell {
    background: rgba(0,0,0,0.02);
    color: var(--text-muted);
    pointer-events: none;
    opacity: 0.4;
    cursor: not-allowed;
}
.matrix-table tbody tr:hover td:not(.matrix-item-name) {
    background: rgba(109, 40, 217, 0.03);
}
.matrix-table tbody tr:hover td.matrix-item-name {
    background: var(--bg-card-header);
}



/* Excel-like Header Filters */
.header-filter-select {
    display: block;
    width: 100%;
    margin-top: 4px;
    font-size: 0.75rem;
    padding: 2px 4px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-input);
    color: var(--text);
    cursor: pointer;
}
.header-filter-select:focus {
    outline: none;
    border-color: var(--primary);
}

/* =============================================
   SETTINGS RIGHT-SIDE SLIDE-OVER DRAWER
   ============================================= */
.settings-drawer-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 999990;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.settings-drawer-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.settings-side-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    max-width: 90vw;
    height: 100vh;
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    box-shadow: -10px 0 35px rgba(0, 0, 0, 0.45);
    z-index: 999995;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

.settings-side-drawer.active {
    transform: translateX(0);
}

.settings-drawer-header {
    padding: 1.25rem 1.4rem;
    background: var(--bg-card-header, var(--bg-card));
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.settings-drawer-title-box {
    display: flex;
    align-items: center;
    gap: 10px;
}

.settings-drawer-icon-wrap {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(99, 102, 241, 0.2));
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
}

.settings-drawer-title-box h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
}

.settings-drawer-title-box p {
    margin: 2px 0 0 0;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.settings-drawer-close-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-body);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s ease;
}

.settings-drawer-close-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
}

.settings-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem 1.4rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.settings-section-heading {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.settings-section-card {
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.settings-action-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0.85rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--text);
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
    text-decoration: none;
}

.settings-action-btn:hover {
    background: var(--bg-hover, rgba(59, 130, 246, 0.06));
    border-color: var(--primary);
    transform: translateY(-1px);
}

.settings-action-btn-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.settings-action-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}

.settings-action-info {
    display: flex;
    flex-direction: column;
}

.settings-action-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
}

.settings-action-desc {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 1px;
}

.settings-action-arrow {
    color: var(--text-muted);
    font-size: 1.1rem;
    transition: transform 0.2s ease;
}

.settings-action-btn:hover .settings-action-arrow {
    color: var(--primary);
    transform: translateX(3px);
}

.settings-drawer-footer {
    padding: 1rem 1.4rem;
    border-top: 1px solid var(--border);
    background: var(--bg-card-header, var(--bg-card));
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
}

