/* 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: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, 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;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* 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);
    height: 65px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.header-logo i {
    font-size: 1.6rem;
    color: var(--primary);
}

.header-logo span {
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #0f172a, #334155);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    height: 100%;
}

.nav-tab {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.5rem 1.2rem;
    border-radius: 0.35rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition-fast);
}

.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: 0.5rem;
}

/* 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);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.25rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
}

.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;
}

.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-color: var(--bg-card-header);
    color: var(--text-muted);
    font-weight: 700;
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--border); /* Thin grid border */
    text-align: left;
    white-space: nowrap;
}

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: center !important;
    min-width: 220px;
}

/* 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: 550px 1fr;
    gap: 1.25rem;
    align-items: stretch;
    height: calc(100vh - 105px);
}

.order-entry-layout .left-panel {
    overflow-y: auto;
    max-height: 100%;
}

.order-entry-layout .right-panel {
    height: 100%;
    overflow: hidden;
}

.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: 10;
    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;
}

.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.85rem !important;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 42px !important;
    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-grow: 1;
}

/* STICKY ACTIONS BAR (LEFT PANEL) */
.sticky-action-bar {
    position: sticky;
    bottom: -1.25rem;
    margin-top: auto;
    margin-left: -1.25rem;
    margin-right: -1.25rem;
    margin-bottom: -1.25rem;
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    background-color: var(--bg-card);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    border-radius: 0 0 0.75rem 0.75rem;
    z-index: 50;
}

.sticky-action-bar button {
    flex: 1;
}

.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, #tab-performa {
    height: calc(100vh - 90px);
    overflow: hidden;
}

#tab-order-view .page-card,
#tab-performa .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,
#tab-performa .table-wrapper {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    border-radius: 0.5rem;
}

#tab-order-view .table-footer-summary {
    flex-shrink: 0;
    border-top: 1px solid var(--border);
}

/* Sticky table header inside Order View */
#orderViewTable thead th,
#partiesMasterTable thead th,
#itemsMasterTable thead th,
#transportMasterTableActual thead th,
#transportsMasterTable thead th,
#unitsMasterTable thead th,
#proformaListTable thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background-color: var(--bg-card-header);
}

.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: 300px 1fr;
    gap: 0.75rem;
    height: calc(100vh - 105px);
}

.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-color: var(--bg-card-header);
}

.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 {
    text-align: center;
    white-space: nowrap;
}

.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: 768px) {
    /* 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 Design) */
    .app-header {
        height: auto !important;
        flex-direction: column !important;
        padding: 0.5rem 1rem !important;
        gap: 0.5rem !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;
    }
    
    /* Scrollable Horizontal View Tabs (Quick access, no overlap!) */
    .header-nav {
        width: 100% !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
        display: flex !important;
        justify-content: flex-start !important;
        padding-bottom: 0.5rem !important;
        gap: 0.35rem !important;
        scrollbar-width: none !important;
        border-top: none !important;
        order: 2 !important;
    }
    
    .header-nav::-webkit-scrollbar {
        display: none !important;
    }
    
    .nav-tab {
        flex: 0 0 auto !important;
        padding: 0.45rem 0.85rem !important;
        font-size: 0.8rem !important;
    }

    /* Actions Drawer Overlay (Hidden by default, slides down on hamburger click) */
    .header-actions {
        display: none !important;
        width: 100% !important;
        flex-direction: column !important;
        gap: 0.5rem !important;
        padding: 0.75rem 0 !important;
        border-top: 1px solid var(--border) !important;
        margin-top: 0.25rem !important;
        position: static !important;
        order: 3 !important;
    }
    
    .header-actions.show {
        display: flex !important;
    }
    
    .header-actions .btn {
        width: 100% !important;
        justify-content: flex-start !important;
        padding: 0.6rem 1rem !important;
        font-size: 0.85rem !important;
    }

    /* Stack panels vertically (Order Entry Tab & Proforma Builder) */
    .order-entry-layout,
    .proforma-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,
    .proforma-entry-layout .left-panel,
    .proforma-entry-layout .right-panel {
        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, 
    .report-summary-cards {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem;
    }
    
    /* 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;
    }
    
    .dispatch-unified-filters .toggle-tabs {
        align-self: stretch;
        justify-content: center;
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        height: auto !important;
    }
    
    .dispatch-unified-filters button, 
    .filters-row button {
        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, #tab-performa, #performaBuilderView {
        height: auto !important;
        overflow: visible !important;
    }
    
    #tab-order-view .page-card, 
    #tab-performa .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;
    }
}

@media (max-width: 480px) {
    /* Columns stack for narrower devices */
    .grid-2col, 
    .grid-item-unit {
        grid-template-columns: 1fr !important;
        gap: 0.5rem;
    }
    .order-stats-grid, 
    .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: 'Outfit', sans-serif;
    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);
}

.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;
}

/* =========================================================
   PROFORMA INVOICE STYLES
   ========================================================= */

.pi-header-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #0A1B54 0%, #06113A 100%);
    padding: 1.25rem 1.5rem;
    border-radius: 12px;
    color: white;
    box-shadow: 0 10px 25px -5px rgba(10, 27, 84, 0.4);
    margin-bottom: 1rem;
}

.pi-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.pi-header-icon {
    font-size: 2.5rem;
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.15);
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.pi-header-title {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    margin: 0 0 0.25rem 0;
}

.pi-header-sub {
    font-size: 0.85rem;
    color: #94a3b8;
    margin: 0;
}

.pi-header-right {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.pi-header-block {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.pi-header-block label {
    font-size: 0.65rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.pi-header-block input {
    background: transparent;
    border: none;
    color: white;
    padding: 0;
    font-size: 1.35rem;
    font-weight: 700;
    width: 110px;
    font-family: inherit;
}

.pi-header-block input[type="date"] {
    font-size: 0.95rem;
    font-weight: 600;
    margin-top: 0.3rem;
    width: 155px;
    color: white;
    color-scheme: dark;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 4px;
    padding: 2px 6px;
}

.pi-header-block input:focus {
    outline: none;
}

.pi-dark-container {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 0.5rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.pi-header-divider {
    width: 1px;
    height: 35px;
    background: rgba(255, 255, 255, 0.15);
}

.pi-status-badge {
    padding: 0.6rem 1.5rem;
    background: #fef08a;
    color: #854d0e;
    font-weight: 800;
    font-size: 0.85rem;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 6px -1px rgba(254, 240, 138, 0.3);
}

.pi-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.pi-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    height: auto;
    flex-shrink: 0;
}

.pi-amount-words,
.pi-summary-card {
    flex-shrink: 0;
}

.pi-card-header {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 1rem 1.25rem;
    font-weight: 700;
    font-size: 1.05rem;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pi-card-body {
    padding: 1.25rem;
}

.pi-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 600;
    border-radius: 6px;
    transition: all 0.2s;
    font-size: 0.85rem;
}

.pi-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.pi-btn-outline-blue {
    background: #eff6ff;
    color: #3b82f6;
    border: 1px solid #bfdbfe;
}
.pi-btn-outline-purple {
    background: #f5f3ff;
    color: #8b5cf6;
    border: 1px solid #ddd6fe;
}
.pi-btn-outline-red {
    background: #fef2f2;
    color: #ef4444;
    border: 1px solid #fecaca;
}
.pi-btn-outline-green {
    background: #f0fdf4;
    color: #22c55e;
    border: 1px solid #bbf7d0;
}

/* 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;
}

/* Split Layout for Proforma Entry */
.proforma-entry-layout {
    display: grid;
    grid-template-columns: 550px 1fr;
    gap: 1.25rem;
    align-items: stretch;
    flex-grow: 1;
    height: 0;
    overflow: hidden;
}

.proforma-entry-layout .left-panel {
    overflow-y: auto;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 0.25rem 0.5rem 2rem 0.5rem;
}

.proforma-entry-layout .right-panel {
    overflow-y: auto;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 0.25rem 0.5rem 2rem 0.5rem;
}

/* Proforma Quick Actions and Bottom Bar */
.quick-action-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}
.quick-action-grid .btn {
    height: 38px;
}

.pi-bottom-bar {
    padding: 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}
.pi-bottom-actions {
    display: flex;
    gap: 1rem;
}
.pi-bottom-bar .btn {
    height: 46px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
#saveProformaDraftBtnBottom {
    padding: 0 1.5rem;
}
#saveProformaSubmitBtnBottom {
    background: #16a34a;
    border: 1px solid #15803d;
    color: white;
    box-shadow: 0 4px 10px rgba(22,163,74,0.3);
    padding: 0 2rem;
}

/* ========================================================= */
/* RESPONSIVE BASE & MEDIA QUERIES                           */
/* ========================================================= */

* {
  box-sizing: border-box;
}

html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

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;
}

.table-wrapper table {
  min-width: 600px;
}

.table-wrapper th, .table-wrapper td {
  white-space: nowrap;
}

@media (max-width: 600px) {
  .container {
    padding: 0 12px;
  }

  .grid,
  .row,
  .two-column,
  .form-row,
  .order-entry-layout,
  .proforma-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;
  }

  .pi-bottom-bar,
  .pi-bottom-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .app-header {
    flex-direction: column;
    align-items: center;
    gap: 10px;
    height: auto;
    padding: 15px 10px;
  }
  
  .header-logo-wrapper {
    width: 100%;
  }

  .mobile-menu-toggle {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
  }

  .header-actions {
    display: none;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    margin-top: 5px;
  }
  
  .header-actions.show {
    display: flex;
  }
  
  .header-actions .btn {
    width: auto !important;
    flex: 1 1 auto;
  }

  .header-nav {
    display: none;
    flex-direction: column;
    width: 100%;
    margin-top: 10px;
    gap: 8px;
  }
  
  .header-nav.show {
    display: flex;
  }
  
  .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: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
  }
  
  .sticky-action-bar .btn,
  .order-grid-actions-row .btn {
    width: 100%;
    margin: 0;
    justify-content: center;
  }

  /* 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;
  }
}

@media (min-width: 601px) and (max-width: 1024px) {
  .grid,
  .order-entry-layout,
  .proforma-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);
}
.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;
}

/* MATRIX ORDER ENTRY STYLES */
.matrix-table {
    border-collapse: collapse;
    font-size: 0.78rem;
    font-family: var(--font-sans);
    width: max-content;
    min-width: 100%;
}
.matrix-table th {
    background: linear-gradient(135deg, #4c1d95, #6d28d9);
    color: white;
    padding: 6px 10px;
    text-align: center;
    font-weight: 700;
    font-size: 0.72rem;
    letter-spacing: 0.5px;
    border: 1px solid rgba(255,255,255,0.2);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 2;
}
.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);
}

