/* ============================================
   ERP DESIGN SYSTEM — Nature Foods
   Single source of truth for all pages.
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    /* Surfaces */
    --erp-bg:           #f4f5f7;
    --erp-surface:      #ffffff;
    --erp-surface-alt:  #f9fafb;

    /* Borders */
    --erp-border:       #e5e7eb;
    --erp-border-strong:#d1d5db;

    /* Text */
    --erp-text:         #1f2937;
    --erp-text-muted:   #6b7280;
    --erp-text-faint:   #9ca3af;

    /* Accents */
    --erp-focus:        #3b82f6;
    --erp-positive:     #059669;
    --erp-negative:     #dc2626;
    --erp-warning:      #d97706;

    /* Sizing */
    --erp-input-h:  28px;
    --erp-radius:   4px;
}

/* ============================================
   BASE
   ============================================ */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--erp-bg);
    color: var(--erp-text);
    font-size: 13px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ============================================
   FORM PRIMITIVES
   ============================================ */

/* --- Labels --- */
.erp-label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--erp-text-muted);
    margin-bottom: 2px;
    white-space: nowrap;
}

/* --- Inputs --- */
.erp-input {
    width: 100%;
    height: var(--erp-input-h);
    background: var(--erp-surface);
    border: 1px solid var(--erp-border-strong);
    color: var(--erp-text);
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--erp-radius);
    padding: 0 6px;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
    font-family: inherit;
}
.erp-input:focus {
    outline: none;
    border-color: var(--erp-focus);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.12);
}
.erp-input::placeholder {
    color: var(--erp-text-faint);
    font-weight: 400;
}

/* Borderless input (for table cells) */
.erp-input-inline {
    width: 100%;
    height: 26px;
    background: transparent;
    border: none;
    border-bottom: 1.5px solid transparent;
    color: var(--erp-text);
    font-size: 13px;
    font-weight: 600;
    text-align: right;
    padding: 0 2px;
    border-radius: 0;
    transition: border-color 0.15s;
    box-sizing: border-box;
    font-family: inherit;
}
.erp-input-inline:focus {
    outline: none;
    border-bottom-color: var(--erp-focus);
}
.erp-input-inline::placeholder {
    color: var(--erp-text-faint);
    font-weight: 400;
}

/* --- Panels --- */
.erp-panel {
    background: var(--erp-surface);
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-radius);
    padding: 10px 12px;
}

/* --- Financial Rows --- */
.fin-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0;
    font-size: 12px;
}
.fin-row-label { color: var(--erp-text-muted); font-weight: 500; font-size: 14px; }
.fin-row-value { font-weight: 700; color: var(--erp-text); font-size: 13px; font-variant-numeric: tabular-nums; }
.fin-row-total {
    border-top: 2px solid #374151;
    padding-top: 6px;
    margin-top: 6px;
}
.fin-row-total .fin-row-label,
.fin-row-total .fin-row-value {
    font-weight: 800;
}
.fin-footer {
    display: grid;
    grid-template-columns: 1fr 1fr 1.2fr;
    gap: 0;
}
.fin-col { padding: 10px 14px; }
.fin-col + .fin-col { border-left: 1px solid var(--erp-border); }


/* ============================================
   SHARED STICKY HEADER
   ============================================ */
.erp-header {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border-bottom: 1px solid #475569;
    position: sticky;
    top: 0;
    z-index: 50;
}
.erp-header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 100%;
    padding: 7px 14px;
    gap: 8px;
}
.erp-header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}
.erp-header-icon {
    width: 26px;
    height: 26px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: white;
    flex-shrink: 0;
}
.erp-header-title {
    font-size: 14px;
    font-weight: 700;
    color: #f1f5f9;
    letter-spacing: -0.01em;
    margin: 0;
    line-height: 1.2;
}
.erp-header-sub {
    font-size: 10px;
    color: #94a3b8;
    font-weight: 500;
    margin: 0;
}
.erp-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* ============================================
   LABELS
   ============================================ */
.erp-label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--erp-text-muted);
    margin-bottom: 2px;
    white-space: nowrap;
}

/* ============================================
   INPUTS
   ============================================ */
.erp-input {
    width: 100%;
    height: var(--erp-input-h);
    background: var(--erp-surface);
    border: 1px solid var(--erp-border-strong);
    color: var(--erp-text);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--erp-radius);
    padding: 0 7px;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
    appearance: none;
}
.erp-input:focus {
    outline: none;
    border-color: var(--erp-focus);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.12);
}
.erp-input::placeholder { color: var(--erp-text-faint); font-weight: 400; }
.erp-input:disabled { background: var(--erp-surface-alt); color: var(--erp-text-muted); cursor: not-allowed; }
.erp-input[readonly] { background: var(--erp-surface-alt); cursor: default; }

/* Borderless inline input (for table cells) */
.erp-input-inline {
    width: 100%;
    height: 26px;
    background: transparent;
    border: none;
    border-bottom: 1.5px solid transparent;
    color: var(--erp-text);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    text-align: right;
    padding: 0 2px;
    border-radius: 0;
    transition: border-color 0.15s;
    box-sizing: border-box;
}
.erp-input-inline:focus { outline: none; border-bottom-color: var(--erp-focus); }
.erp-input-inline::placeholder { color: var(--erp-text-faint); font-weight: 400; }

/* Legacy compat */
.input-field {
    width: 100%;
    height: 30px;
    background: var(--erp-surface);
    border: 1px solid var(--erp-border-strong);
    color: var(--erp-text);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--erp-radius);
    padding: 0 8px;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
}
.input-field:focus {
    outline: none;
    border-color: var(--erp-focus);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.12);
}
.input-group-label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--erp-text-muted);
    margin-bottom: 2px;
}
.input-field-compact {
    width: 100%;
    height: 24px;
    background: transparent;
    border: none;
    border-bottom: 1px solid transparent;
    color: var(--erp-text);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    text-align: right;
    padding: 0 2px;
    border-radius: 0;
    transition: border-color 0.15s;
}
.input-field-compact:focus {
    outline: none;
    border-bottom-color: var(--erp-focus);
}

/* ============================================
   PANELS / CARDS
   ============================================ */
.erp-panel {
    background: var(--erp-surface);
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-radius);
    padding: 10px 12px;
}

/* ============================================
   SECTION TITLES
   ============================================ */
.erp-section-title {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--erp-text);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--erp-border);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn-save {
    background: var(--erp-positive);
    color: white;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    padding: 5px 14px;
    border-radius: var(--erp-radius);
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: background 0.15s;
    white-space: nowrap;
    text-decoration: none;
}
.btn-save:hover { background: #047857; }

.btn-delete {
    background: var(--erp-negative);
    color: white;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    padding: 5px 14px;
    border-radius: var(--erp-radius);
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: background 0.15s;
    white-space: nowrap;
}
.btn-delete:hover { background: #b91c1c; }

.btn-ghost {
    font-size: 14px;
    color: #94a3b8;
    background: none;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: color 0.15s;
    font-family: inherit;
    text-decoration: none;
    white-space: nowrap;
}
.btn-ghost:hover { color: #e2e8f0; }

.btn-header {
    font-size: 14px;
    color: white;
    background: rgba(255,255,255,0.12);
    padding: 5px 12px;
    border-radius: var(--erp-radius);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid rgba(255,255,255,0.15);
    cursor: pointer;
    transition: background 0.15s;
    font-family: inherit;
    white-space: nowrap;
}
.btn-header:hover { background: rgba(255,255,255,0.2); }

/* Legacy compat */
.btn-primary   { background: var(--erp-positive); color: white; font-size: 14px; font-weight: 700; font-family: inherit; padding: 5px 12px; border-radius: var(--erp-radius); border: none; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.btn-secondary { background: var(--erp-surface); color: var(--erp-focus); border: 1px solid #bfdbfe; font-size: 14px; font-weight: 600; font-family: inherit; padding: 5px 10px; border-radius: var(--erp-radius); cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }

.btn-save {
    background: var(--erp-positive); color: white; font-size: 14px; font-weight: 700;
    padding: 5px 14px; border-radius: var(--erp-radius); border: none; cursor: pointer;
    display: inline-flex; align-items: center; gap: 5px; transition: background 0.15s;
    font-family: inherit; white-space: nowrap;
}
.btn-save:hover { background: #047857; }

.btn-delete {
    background: var(--erp-negative); color: white; font-size: 14px; font-weight: 700;
    padding: 5px 14px; border-radius: var(--erp-radius); border: none; cursor: pointer;
    display: inline-flex; align-items: center; gap: 5px; transition: background 0.15s;
    font-family: inherit; white-space: nowrap;
}
.btn-delete:hover { background: #b91c1c; }

/* ============================================
   FORM LAYOUT (Data Entry Pages)
   ============================================ */
.erp-section-title {
    font-size: 14px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--erp-text);
    margin-bottom: 8px; padding-bottom: 6px;
    border-bottom: 1px solid var(--erp-border);
}
.doc-header-grid {
    display: grid;
    grid-template-columns: 120px 1fr 1fr 140px 100px 100px;
    gap: 6px 10px;
    align-items: end;
}
.doc-header-row2 {
    display: grid;
    grid-template-columns: 200px 1fr auto 1fr;
    gap: 6px 10px;
    align-items: end;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #f3f4f6;
}
@media (max-width: 1024px) {
    .doc-header-grid { grid-template-columns: 1fr 1fr 1fr; }
    .doc-header-row2 { grid-template-columns: 1fr 1fr; }
}

/* ============================================
   TABLE
   ============================================ */
.erp-table {
    width: 100%;
    text-align: left;
    border-collapse: collapse;
}
.erp-table thead th,
.erp-table .deal-columns-header th {
    background: #f1f3f5;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #4b5563;
    padding: 8px 8px;
    border-bottom: 2px solid var(--erp-border);
    border-right: 1px solid #d1d5db;
    white-space: nowrap;
    vertical-align: bottom;
    position: sticky;
    top: 0;
    z-index: 2;
}
.erp-table thead th:last-child,
.erp-table .deal-columns-header th:last-child {
    border-right: none;
}
.erp-table tbody td {
    padding: 5px 8px;
    font-size: 13px;
    color: var(--erp-text);
    border-bottom: 1px solid #f0f1f3;
    border-right: 1px solid #e5e7eb;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    position: relative; /* For absolute positioning of focused datalists */
}
.erp-table tbody td:last-child {
    border-right: none;
}

/* Expand narrow inputs with datalists on focus so the browser dropdown isn't cut off */
.erp-table tbody td input[list]:focus {
    position: absolute;
    top: 5px; /* match td padding-top */
    left: 8px; /* match td padding-left */
    width: max-content !important;
    min-width: 200px !important;
    z-index: 50;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    background: #fff;
}

/* Prevent Tailwind helper classes from making text unreadably small on desktop */
.erp-table tbody td .text-\[10px\] { font-size: 11px !important; }
.erp-table tbody td .text-xs { font-size: 12.5px !important; }
/* Zebra striping — default fallback when no group-band class is set */
.erp-table tbody tr:nth-child(even) td { background: #fafbfc; }
.erp-table tbody tr:nth-child(odd) td  { background: #ffffff; }
/* Group-based alternating band (per report, not per row) — overrides nth-child */
.erp-table tbody tr.row-band-a td { background: #edf0f5 !important; }
.erp-table tbody tr.row-band-b td { background: #ffffff !important; }
/* Group-start override for multi-row records */
.erp-table tbody tr.group-start td { border-top: 2px solid var(--erp-border); }
.erp-table tbody tr:hover td { background: #eef2ff !important; }

/* Highlighted column (light blue tint for important data like Final Amount) */
.erp-table .col-highlight { background: #eff6ff !important; }
.erp-table thead .col-highlight { background: #dbeafe !important; color: #1e40af; }
/* Accent column (green tint for key totals) */
.erp-table .col-accent { background: #f0fdf4 !important; }
.erp-table thead .col-accent { background: #dcfce7 !important; color: #166534; }

.erp-table tfoot td {
    background: #f1f3f5;
    border-top: 2px solid var(--erp-border);
    font-weight: 800;
    font-size: 12px;
    color: var(--erp-text);
    padding: 8px 8px;
    font-variant-numeric: tabular-nums;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.erp-empty-state, .empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--erp-text-faint);
}
.erp-empty-state i, .empty-state i {
    font-size: 2rem;
    display: block;
    margin-bottom: 10px;
    opacity: 0.5;
}
.erp-empty-state p, .empty-state p {
    font-size: 13px;
    margin: 0;
}

/* ============================================
   FILTER CARD (Register pages)
   ============================================ */
.erp-filter-card {
    background: var(--erp-surface);
    border: 1px solid var(--erp-border);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    padding: 12px 16px;
    margin-bottom: 16px;
}
.erp-filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
.erp-filter-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--erp-text);
    margin-right: 4px;
    white-space: nowrap;
}
.erp-filter-divider {
    width: 1px;
    height: 20px;
    background: var(--erp-border);
    flex-shrink: 0;
}
.erp-filter-spacer { flex-grow: 1; }

/* Filter inputs */
.erp-filter-input {
    height: 30px;
    background: var(--erp-surface);
    border: 1px solid var(--erp-border-strong);
    color: var(--erp-text);
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    border-radius: var(--erp-radius);
    padding: 0 8px;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
}
.erp-filter-input:focus {
    outline: none;
    border-color: var(--erp-focus);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}
.erp-filter-input::placeholder { color: var(--erp-text-faint); }

/* Action buttons inside filter card */
.erp-filter-btn {
    height: 30px;
    padding: 0 14px;
    border-radius: var(--erp-radius);
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.15s;
    border: 1px solid transparent;
    white-space: nowrap;
    text-decoration: none;
}
.erp-filter-btn-primary  { background: var(--erp-positive); color: white; border-color: #047857; }
.erp-filter-btn-primary:hover  { background: #047857; }
.erp-filter-btn-secondary{ background: var(--erp-surface-alt); color: var(--erp-text-muted); border-color: var(--erp-border-strong); }
.erp-filter-btn-secondary:hover{ background: var(--erp-border); color: var(--erp-text); }
.erp-filter-btn-accent   { background: #2563eb; color: white; border-color: #1d4ed8; }
.erp-filter-btn-accent:hover   { background: #1d4ed8; }
.erp-filter-btn-indigo   { background: #4f46e5; color: white; border-color: #4338ca; }
.erp-filter-btn-indigo:hover   { background: #4338ca; }
.erp-filter-btn-emerald  { background: #059669; color: white; border-color: #047857; }
.erp-filter-btn-emerald:hover  { background: #047857; }

/* ============================================
   TAB BAR (purchase-reports etc.)
   ============================================ */
.erp-tab-bar {
    display: flex;
    align-items: center;
    border-bottom: 2px solid var(--erp-border);
    margin-bottom: 12px;
    gap: 0;
}
.erp-tab-btn {
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--erp-text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.erp-tab-btn:hover { color: var(--erp-text); background: var(--erp-surface-alt); }
.erp-tab-btn.active { border-bottom-color: var(--erp-focus); color: var(--erp-focus); }
.erp-tab-count {
    font-size: 10px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 10px;
    background: var(--erp-surface-alt);
    color: var(--erp-text-muted);
    border: 1px solid var(--erp-border);
    transition: all 0.2s;
}

/* ============================================
   LAYOUT HELPERS
   ============================================ */
.doc-header-grid {
    display: grid;
    grid-template-columns: 120px 1fr 1fr 140px 100px 100px;
    gap: 6px 10px;
    align-items: end;
}
.doc-header-row2 {
    display: grid;
    grid-template-columns: 200px 1fr auto 1fr;
    gap: 6px 10px;
    align-items: end;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #f3f4f6;
}

/* ============================================
   FINANCIAL FOOTER
   ============================================ */
.fin-footer {
    display: grid;
    grid-template-columns: 1fr 1fr 1.2fr;
    gap: 0;
}
.fin-col { padding: 10px 14px; }
.fin-col + .fin-col { border-left: 1px solid var(--erp-border); }
.fin-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0;
    font-size: 12px;
}
.fin-row-label  { color: var(--erp-text-muted); font-weight: 500; font-size: 14px; }
.fin-row-value  { font-weight: 700; color: var(--erp-text); font-size: 13px; font-variant-numeric: tabular-nums; }
.fin-row-total  { border-top: 2px solid #374151; padding-top: 6px; margin-top: 6px; }
.fin-row-total .fin-row-label,
.fin-row-total .fin-row-value { font-weight: 800; }

/* ============================================
   EXPENSE ITEMS
   ============================================ */
.expense-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px 0;
}
.expense-item label, .expense-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--erp-text-muted);
}
.expense-label {
    outline: none; cursor: text;
    border-bottom: 1px dashed transparent;
    transition: border-color 0.2s;
    padding: 0 1px; min-width: 40px;
}
.expense-label:hover { border-bottom-color: var(--erp-border-strong); }
.expense-label:focus { border-bottom-color: var(--erp-focus); }
.expense-input {
    width: 90px; height: 24px;
    background: transparent; border: none;
    border-bottom: 1px solid transparent;
    color: var(--erp-text); font-size: 13px; font-weight: 600; font-family: inherit;
    text-align: right; padding: 0 2px; border-radius: 0;
    transition: border-color 0.15s;
}
.expense-input:focus { outline: none; border-bottom-color: var(--erp-focus); }

/* ============================================
   TOGGLE SWITCH
   ============================================ */
.toggle-switch {
    position: relative; width: 36px; height: 20px;
    background: #d1d5db; border-radius: 20px; cursor: pointer;
    transition: background 0.2s; border: none; padding: 0; flex-shrink: 0;
}
.toggle-switch.active { background: var(--erp-positive); }
.toggle-switch::after {
    content: ''; position: absolute; top: 2px; left: 2px;
    width: 16px; height: 16px; background: white; border-radius: 50%;
    transition: transform 0.2s; box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.toggle-switch.active::after { transform: translateX(16px); }

/* ============================================
   DISABLED STATE
   ============================================ */
.card-disabled {
    opacity: 0.4; pointer-events: none; filter: grayscale(0.6);
    transition: opacity 0.3s, filter 0.3s;
}

/* ============================================
   DRAWER
   ============================================ */
.drawer-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 70; display: none;
    backdrop-filter: blur(4px);
}
.drawer {
    position: fixed; top: 0; right: 0;
    height: 100%; width: 380px;
    background: white;
    box-shadow: -8px 0 30px rgba(0,0,0,0.12);
    z-index: 80; transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex; flex-direction: column;
    border-left: 1px solid var(--erp-border);
}
.drawer.open { transform: translateX(0); }

/* ============================================
   TEXT / COLOUR UTILITIES
   ============================================ */
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.text-left    { text-align: left; }
.font-bold    { font-weight: 700; }
.font-medium  { font-weight: 500; }
.text-muted   { color: var(--erp-text-muted); }
.text-faint   { color: var(--erp-text-faint); }
.text-green,  .text-positive { color: var(--erp-positive); }
.text-red,    .text-negative { color: var(--erp-negative); }
.text-warning { color: var(--erp-warning); }
.text-blue    { color: var(--erp-focus); }
.text-xs      { font-size: 14px; }

/* ============================================
   LOADING STATE
   ============================================ */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--erp-text-muted);
    font-size: 12px;
}

/* ============================================
   HIDDEN UTILITY
   ============================================ */
.hidden { display: none !important; }

/* ============================================
   ACTION BUTTONS (register rows)
   ============================================ */
.act-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--erp-radius);
    font-size: 12px;
    transition: all 0.15s;
}
.act-edit { color: var(--erp-focus); }
.act-edit:hover { background: #eff6ff; }
.act-del  { color: var(--erp-text-faint); }
.act-del:hover  { background: #fef2f2; color: var(--erp-negative); }

/* ============================================
   NOTE BADGES (register rows)
   ============================================ */
.note-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: var(--erp-radius);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.note-urd { background: #f3f4f6; color: var(--erp-text-muted); }
.note-dn  { background: #fef2f2; color: var(--erp-negative); }
.note-cn  { background: #ecfdf5; color: var(--erp-positive); }

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ============================================
   ORDER FORM — UNIFIED SIZING
   All three form types (Sales, Purchase, Export)
   share the same compact-but-readable sizing.
   ============================================ */

/* === SHARED: Labels across ALL form areas === */
#orderForm .erp-label,
#exportFieldsSection .erp-label,
.deal-card label,
.export-container-card label {
    font-size: 10px !important;
    font-weight: 600 !important;
    letter-spacing: 0.04em !important;
    text-transform: uppercase;
    color: var(--erp-text-muted);
    margin-bottom: 1px !important;
}

/* === SHARED: Inputs across ALL form areas === */
#orderForm .erp-input,
#exportFieldsSection .erp-input {
    height: 26px;
    font-size: 13px !important;
    font-family: 'Inter', -apple-system, sans-serif !important;
    font-weight: 500;
    padding: 0 5px;
}
#orderForm .erp-input::placeholder,
#exportFieldsSection .erp-input::placeholder {
    font-size: 10px;
}

/* === SHARED: Section titles === */
#orderForm .erp-section-title {
    font-size: 10px !important;
    font-weight: 700 !important;
    margin-bottom: 4px;
    padding-bottom: 3px;
}

/* Master select "+" buttons in header */
#orderForm .master-select-group button {
    height: 24px;
    padding: 0 4px;
    font-size: 9px;
}

/* === SALES ITEMS TABLE === */
#orderForm .erp-table thead th,
#orderForm .erp-table .deal-columns-header th {
    padding: 4px 6px !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
#orderForm .erp-table tbody td {
    padding: 3px 4px !important;
    vertical-align: top;
    white-space: normal;
    font-size: 11px !important;
}
#orderForm .erp-table tfoot td {
    padding: 4px 6px !important;
    font-size: 10px !important;
    font-weight: 700 !important;
}

/* Inputs inside items table */
#orderForm .erp-table input[type="text"],
#orderForm .erp-table input[type="number"],
#orderForm .erp-table select {
    height: 26px !important;
    font-size: 13px !important;
    font-family: 'Inter', -apple-system, sans-serif !important;
    padding: 0 6px !important;
    border-radius: 4px !important;
    border: 1px solid var(--erp-border) !important;
    box-sizing: border-box;
}
#orderForm .erp-table input[type="text"]:focus,
#orderForm .erp-table input[type="number"]:focus,
#orderForm .erp-table select:focus {
    outline: none;
    border-color: var(--erp-focus) !important;
    box-shadow: 0 0 0 1.5px rgba(59, 130, 246, 0.1);
}

/* "+" and gear buttons inside item rows */
#orderForm .erp-table .master-select-group button {
    height: 22px !important;
    padding: 0 3px !important;
    font-size: 9px !important;
    border-radius: 3px !important;
}

/* Remark/attachment buttons */
#orderForm .erp-table button[id^="btnRemark_"],
#orderForm .erp-table button[id^="btnAttachment_"] {
    font-size: 9px !important;
    padding: 1px 4px !important;
}

/* Gaps between stacked fields */
#orderForm .erp-table .flex.flex-col.gap-2 { gap: 2px !important; }
#orderForm .erp-table .flex.gap-2 { gap: 3px !important; }
#orderForm .erp-table .flex.gap-1 { gap: 2px !important; }
#orderForm .erp-table .mt-2 { margin-top: 3px !important; }

/* === EXPORT FIELDS SECTION === */
#exportFieldsContent {
    gap: 3px 6px !important;
}

/* === DEAL CARDS (Purchase) & EXPORT CONTAINER CARDS === */

/* Card chrome */
.deal-card,
.export-container-card {
    border-radius: 6px !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* Card header bar */
.deal-card > div:first-child,
.export-container-card > div:first-child {
    padding: 4px 8px !important;
}
.deal-card > div:first-child h4,
.export-container-card > div:first-child h4 {
    font-size: 10px !important;
}

/* Card body */
.deal-card > .p-3,
.export-container-card > .p-3 {
    padding: 6px 8px !important;
}

/* Inner table headers */
.deal-card table th,
.export-container-card table th {
    font-size: 10px !important;
    padding: 3px 4px !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--erp-text-muted);
}
/* Inner table cells */
.deal-card table td,
.export-container-card table td {
    padding: 3px 4px !important;
}

/* Inner inputs — match sales table inputs */
.deal-card input[type="text"],
.deal-card input[type="number"],
.deal-card select,
.export-container-card input[type="text"],
.export-container-card input[type="number"],
.export-container-card select {
    height: 26px !important;
    font-size: 13px !important;
    font-family: 'Inter', -apple-system, sans-serif !important;
    padding: 0 6px !important;
    border-radius: 4px !important;
    box-sizing: border-box;
}

/* Grid gap inside deal cards */
.deal-card .mt-3 { margin-top: 5px !important; }
.deal-card .pt-3 { padding-top: 5px !important; }
.deal-card .mt-2,
.export-container-card .mt-2 { margin-top: 4px !important; }

/* Action buttons */
.deal-card button[onclick*="removeDealCard"],
.deal-card button[onclick*="removeDealProductRow"],
.deal-card button[onclick*="addDealProductRow"],
.export-container-card button[onclick*="removeExportContainerCard"],
.export-container-card button[onclick*="removeExportProductRow"],
.export-container-card button[onclick*="addExportProductRow"] {
    font-size: 10px !important;
}

/* Container tfoot */
.export-container-card tfoot td {
    font-size: 10px !important;
    padding: 3px 4px !important;
}

/* === FORM ACTION BAR (Add Item / Save) === */
#orderForm > div:last-child {
    margin-top: 8px;
    padding-top: 6px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    .doc-header-grid   { grid-template-columns: 1fr 1fr 1fr; }
    .doc-header-row2   { grid-template-columns: 1fr 1fr; }
    .fin-footer        { grid-template-columns: 1fr; }
    .fin-col + .fin-col{ border-left: none; border-top: 1px solid var(--erp-border); }
}
@media (max-width: 640px) {
    .erp-filter-divider{ display: none; }
}

/* ============================================
   MOBILE RESPONSIVE CLASSES (<= 768px)
   ============================================ */
@media (max-width: 768px) {
    /* 1. Frosted Glass Headers (Dark Slate to match icons) */
    .erp-mobile-glass-header {
        background: rgba(30, 41, 59, 0.85) !important;
        backdrop-filter: blur(12px) !important;
        -webkit-backdrop-filter: blur(12px) !important;
        border-bottom: 1px solid rgba(255,255,255,0.1) !important;
    }
    
    /* 2. Soft, Modern Inputs — Global .erp-input on mobile */
    .erp-input,
    select.erp-input {
        background: #f1f5f9 !important;
        border: 1px solid transparent !important;
        border-radius: 8px !important;
        min-height: 42px !important;
        font-size: 14px !important;
        font-weight: 600 !important;
        font-family: 'Inter', -apple-system, sans-serif !important;
        padding: 10px 12px !important;
        color: #1f2937 !important;
    }
    .erp-input:focus {
        background: #ffffff !important;
        border-color: #3b82f6 !important;
        box-shadow: 0 0 0 3px #dbeafe !important;
    }
    
    .erp-input::placeholder {
        font-size: 14px !important;
        font-weight: 400 !important;
        color: #9ca3af !important;
    }
    
    .erp-label {
        font-family: 'Inter', -apple-system, sans-serif !important;
        font-size: 10px !important;
        font-weight: 600 !important;
        color: var(--erp-text-muted) !important;
        text-transform: uppercase !important;
        letter-spacing: 0.5px !important;
    }
    
    /* Stack form inputs vertically on mobile and prevent grid-breaks */
    .responsive-form-grid {
        grid-template-columns: 1fr 1fr !important;
        grid-auto-flow: dense !important;
        gap: 12px !important;
    }
    .responsive-form-grid > div {
        grid-column: span 1 / span 1 !important;
    }
    .responsive-form-grid > .col-span-2-mobile {
        grid-column: span 2 / span 2 !important;
    }
    .responsive-form-grid-single {
        grid-template-columns: 1fr !important;
    }
    .responsive-form-grid-single > div {
        grid-column: span 1 / span 1 !important;
    }
    
    /* 3. Chunky Pill Buttons */
    .btn-save {
        border-radius: 9999px !important;
        min-height: 48px !important;
        font-size: 14px !important;
        justify-content: center;
    }

    /* Keep generic tables wide (Registers, Reports) */
    .erp-table {
        min-width: 1200px;
    }

    /* =========================================
       5. ORDER FORM TABLES TO VERTICAL CARDS 
       ========================================= */
    #domesticItemsSection .erp-table,
    #exportContainersSection .erp-table,
    #purchaseDealsSection .erp-table {
        min-width: 0 !important;
        width: 100% !important;
    }
    
    #domesticItemsSection table, #domesticItemsSection thead, #domesticItemsSection tbody, #domesticItemsSection th, #domesticItemsSection td, #domesticItemsSection tr,
    #exportContainersSection table, #exportContainersSection thead, #exportContainersSection tbody, #exportContainersSection th, #exportContainersSection td, #exportContainersSection tr,
    #purchaseDealsSection table, #purchaseDealsSection thead, #purchaseDealsSection tbody, #purchaseDealsSection th, #purchaseDealsSection td, #purchaseDealsSection tr {
        display: block;
    }
    
    /* Hide Table Headers */
    #domesticItemsSection thead tr,
    #exportContainersSection thead tr,
    #purchaseDealsSection .deal-columns-header {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    
    /* Product Row as a Card */
    #itemsTableBody tr,
    .ec-product-row,
    .dc-product-row {
        display: grid !important;
        grid-template-columns: repeat(12, 1fr) !important;
        gap: 8px !important;
        background: #ffffff;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        padding: 4px !important;
        margin-bottom: 12px !important;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05) !important;
        position: relative;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    
    /* Deal & Container Headers/Footers */
    .deal-card, .export-container-card {
        background: transparent !important;
        border: none !important;
        margin-bottom: 24px;
    }
    .deal-card > tr:first-child,
    .export-container-card > tr:first-child {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        background: #ffffff;
        border-radius: 12px 12px 0 0;
        padding: 12px 16px;
        border: 1px solid #e2e8f0;
        border-bottom: none;
        margin-bottom: 0;
        box-shadow: none;
    }
    .deal-card > tr:last-child,
    .export-container-card > tr:last-child {
        display: flex !important;
        flex-direction: column;
        justify-content: center;
        align-items: stretch;
        background: #ffffff;
        border-radius: 0 0 12px 12px;
        padding: 12px 16px;
        border: 1px solid #e2e8f0;
        border-top: none;
        margin-top: -16px;
        gap: 8px;
    }
    
    /* Reset TR styling for header/footer rows in deals/exports */
    .deal-card > tr:first-child td, .deal-card > tr:last-child td,
    .export-container-card > tr:first-child td, .export-container-card > tr:last-child td {
        padding: 0 !important;
        border: none !important;
        width: auto !important;
    }

    /* The TDs inside Product Rows become stacked fields */
    #domesticItemsSection td,
    .ec-product-row td,
    .dc-product-row td,
    #domesticItemsSection tr:hover td,
    .ec-product-row:hover td,
    .dc-product-row:hover td {
        display: flex !important;
        flex-direction: column;
        align-items: flex-start;
        padding: 0 !important;
        border: none !important;
        width: 100% !important;
        background: transparent !important;
    }
    
    /* Sales Order Row Layout (12-col Grid) */
    #itemsTableBody td:nth-child(1) { grid-column: span 12; }
    #itemsTableBody td:nth-child(2) { grid-column: span 4; }
    #itemsTableBody td:nth-child(3) { grid-column: span 5; }
    #itemsTableBody td:nth-child(4) { grid-column: span 3; }
    #itemsTableBody td:nth-child(5) { grid-column: span 4; }
    #itemsTableBody td:nth-child(6) { grid-column: span 4; }
    #itemsTableBody td:nth-child(7) { grid-column: span 4; }
    #itemsTableBody td:nth-child(8) { grid-column: span 4; }
    #itemsTableBody td:nth-child(9) { grid-column: span 5; }
    #itemsTableBody td:nth-child(9) .domestic-field { flex-direction: row !important; gap: 4px; }
    #itemsTableBody td:nth-child(9) .domestic-field select { width: 50% !important; flex: 1 !important; }
    #itemsTableBody td:nth-child(10) { grid-column: span 3; }
    #itemsTableBody td:nth-child(11) { grid-column: span 12; }
    
    /* Export Order Row Layout */
    .ec-product-row td:nth-child(1) { grid-column: span 12; }
    .ec-product-row td:nth-child(2) { grid-column: span 4; }
    .ec-product-row td:nth-child(3) { grid-column: span 8; }
    .ec-product-row td:nth-child(4) { grid-column: span 6; }
    .ec-product-row td:nth-child(5) { grid-column: span 6; }
    .ec-product-row td:nth-child(6) { grid-column: span 6; }
    .ec-product-row td:nth-child(7) { grid-column: span 6; }
    .ec-product-row td:nth-child(8) { grid-column: span 6; }
    .ec-product-row td:nth-child(9) { grid-column: span 12; }
    
    /* Purchase Deal Row Layout */
    .dc-product-row td:nth-child(1) { grid-column: span 12; }
    .dc-product-row td:nth-child(2) { grid-column: span 6; }
    .dc-product-row td:nth-child(3) { grid-column: span 6; }
    .dc-product-row td:nth-child(4) { grid-column: span 12; }
    .dc-product-row td:nth-child(6) { grid-column: span 12; }
    .dc-product-row td:nth-child(7) { grid-column: span 4; }
    .dc-product-row td:nth-child(8) { grid-column: span 4; }
    .dc-product-row td:nth-child(9) { grid-column: span 4; }
    .dc-product-row td:nth-child(10) { grid-column: span 12; }
    
    /* Force inputs to match erp-input style */
    #itemsTableBody td input, #itemsTableBody td select,
    .ec-product-row td input, .ec-product-row td select,
    .dc-product-row td input, .dc-product-row td select {
        width: 100% !important;
        background: #f1f5f9 !important;
        border: 1px solid transparent !important;
        border-radius: 8px !important;
        min-height: 42px !important;
        font-size: 14px !important;
        font-weight: 600 !important;
        font-family: 'Inter', -apple-system, sans-serif !important;
        padding: 10px 12px !important;
        text-align: left !important;
        color: #1f2937 !important;
        box-sizing: border-box !important;
    }
    
    /* Hard override for tailwind classes on mobile inside tables */
    #itemsTableBody .text-xs, #itemsTableBody .text-\[10px\], #itemsTableBody .text-sm,
    .ec-product-row .text-xs, .ec-product-row .text-\[10px\], .ec-product-row .text-sm,
    .dc-product-row .text-xs, .dc-product-row .text-\[10px\], .dc-product-row .text-sm {
        font-size: 14px !important;
    }
    
    #itemsTableBody td input::placeholder, 
    .ec-product-row td input::placeholder, 
    .dc-product-row td input::placeholder {
        font-size: 14px !important;
        font-weight: 400 !important;
        color: #9ca3af !important;
    }
    
    /* Labels styling */
    #itemsTableBody td::before,
    .ec-product-row td::before,
    .dc-product-row td::before {
        display: block;
        width: 100%;
        margin-bottom: 2px;
        font-family: 'Inter', -apple-system, sans-serif !important;
        font-size: 14px !important;
        font-weight: 700 !important;
        color: #4b5563 !important;
    }

    /* =========================================
       DOMESTIC ITEMS LABELS (12 cols)
       ========================================= */
    #itemsTableBody td:nth-child(1)::before { content: "Product"; }
    #itemsTableBody td:nth-child(2)::before { content: "Count"; }
    #itemsTableBody td:nth-child(3)::before { content: "Packing"; }
    #itemsTableBody td:nth-child(4)::before { content: "Wt/Pc"; }
    #itemsTableBody td:nth-child(5)::before { content: "QTY (KG)"; }
    #itemsTableBody td:nth-child(6)::before { content: "Pieces"; }
    #itemsTableBody td:nth-child(7)::before { content: "Actual Rate"; }
    #itemsTableBody td:nth-child(8)::before { content: "Bill Rate"; }
    #itemsTableBody td:nth-child(9)::before { content: "GST"; }
    #itemsTableBody td:nth-child(10)::before { content: "Ship Time"; }
    #itemsTableBody td:nth-child(11)::before { content: "Status"; }
    #itemsTableBody td:nth-child(12)::before { display: none; }
    
    #itemsTableBody td:nth-child(12) { 
        position: absolute;
        top: 8px;
        right: 8px;
        width: auto !important;
        grid-column: auto !important;
        border-top: none !important;
        margin-top: 0 !important;
        padding-top: 0 !important;
    }

    /* =========================================
       EXPORT ITEMS LABELS (10 cols)
       ========================================= */
    .ec-product-row td:nth-child(1)::before { content: "Product"; }
    .ec-product-row td:nth-child(2)::before { content: "Count"; }
    .ec-product-row td:nth-child(3)::before { content: "Packing"; }
    .ec-product-row td:nth-child(4)::before { content: "QTY (KG)"; }
    .ec-product-row td:nth-child(5)::before { content: "Pieces"; }
    .ec-product-row td:nth-child(6)::before { content: "Rate/MT"; }
    .ec-product-row td:nth-child(7)::before { content: "Currency"; }
    .ec-product-row td:nth-child(8)::before { content: "Ship Time"; }
    .ec-product-row td:nth-child(9)::before { content: "Status"; }
    .ec-product-row td:nth-child(10)::before { display: none; }
    
    .ec-product-row td:nth-child(10) { 
        position: absolute;
        top: 8px;
        right: 8px;
        width: auto !important;
        grid-column: auto !important;
        border-top: none !important;
        margin-top: 0 !important;
        padding-top: 0 !important;
    }

    /* =========================================
       PURCHASE DEALS LABELS 
       ========================================= */
    .dc-product-row td:nth-child(1)::before { content: "Product"; }
    .dc-product-row td:nth-child(2)::before { content: "Count"; }
    .dc-product-row td:nth-child(3)::before { content: "Rate (₹/KG)"; }
    .dc-product-row td:nth-child(4)::before { content: "Remark"; }
    .dc-product-row td:nth-child(5)::before { display: none; }
    .dc-product-row td:nth-child(6)::before { content: "Packing"; }
    .dc-product-row td:nth-child(7)::before { content: "QTY (KG)"; }
    .dc-product-row td:nth-child(8)::before { content: "Pieces"; }
    .dc-product-row td:nth-child(9)::before { content: "Wt/Pc"; }
    .dc-product-row td:nth-child(10)::before { content: "Status"; }
    .dc-product-row td:nth-child(11)::before { display: none; }
    .dc-product-row td:nth-child(5) { 
        position: absolute;
        top: 8px;
        right: 8px;
        width: auto !important;
        grid-column: auto !important;
        border-top: none !important;
        margin-top: 0 !important;
        padding-top: 0 !important;
    }

    .dc-product-row td:nth-child(11) {
        grid-column: span 12;
        display: flex;
        justify-content: flex-end;
    }
    /* Keep header items horizontal */
    .mobile-scroll-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: thin !important;
        flex-wrap: nowrap !important;
    }
    .mobile-scroll-container::-webkit-scrollbar { height: 6px !important; }
    .mobile-scroll-container::-webkit-scrollbar-thumb { background: #cbd5e1 !important; border-radius: 4px !important; }

    .mobile-header-wrap { flex-wrap: wrap !important; gap: 8px !important; }
    .mobile-header-wrap > div:last-child {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: thin !important;
        width: 100%;
        padding-bottom: 4px;
        flex-wrap: nowrap !important;
    }
    .mobile-header-wrap > div:last-child::-webkit-scrollbar { height: 4px !important; }
    .mobile-header-wrap > div:last-child::-webkit-scrollbar-thumb { background: #cbd5e1 !important; border-radius: 4px !important; }

    /* =========================================
       6. ENHANCED MOBILE LAYOUT FIXES
       ========================================= */
       
    /* Fix Master Select Groups (+) */
    .master-select-group {
        display: flex !important;
        flex-direction: row !important;
        width: 100% !important;
        gap: 0 !important;
    }
    .master-select-group input {
        flex: 1 !important;
        border-radius: 8px 0 0 8px !important;
    }
    .master-select-group button {
        border-radius: 0 6px 6px 0 !important;
        background: #f1f5f9 !important;
        border: 1px solid transparent !important;
        border-left: 1px solid #e5e7eb !important;
        padding: 0 12px !important;
        color: var(--erp-text-muted) !important;
        font-weight: 800 !important;
        font-size: 14px !important;
    }

    /* Move Actions to Top Right via Grid (no absolute positioning) */
    #itemsTableBody td:last-child::before,
    .ec-product-row td:last-child::before,
    .dc-product-row td:last-child::before {
        display: none !important;
    }
    #itemsTableBody td:last-child,
    .ec-product-row td:last-child,
    .dc-product-row td:last-child {
        grid-column: span 12 !important;
        grid-row: 1 !important;
        justify-self: end !important;
        width: auto !important;
        margin: 0 !important;
        padding: 4px 0 !important;
        border: none !important;
        background: transparent !important;
        z-index: 2 !important;
    }

    /* Footer Buttons Match GP */
    div:has(> #addItemOrContainerBtn) {
        flex-direction: column !important;
        gap: 16px !important;
        border-top: none !important;
    }
    div:has(> #addItemOrContainerBtn) > div {
        width: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 16px !important;
    }
    
    #addItemOrContainerBtn {
        width: 100% !important;
        background: transparent !important;
        color: #64748b !important;
        border: 1px dashed #cbd5e1 !important;
        padding: 14px !important;
        border-radius: 8px !important;
        font-weight: 700 !important;
        font-size: 14px !important;
        justify-content: center !important;
        margin-bottom: 0 !important;
    }
    .btn-save {
        width: 100% !important;
        background: #10b981 !important;
        color: white !important;
        border-radius: 9999px !important;
        min-height: 48px !important;
        font-size: 14px !important;
        justify-content: center !important;
        border: none !important;
        box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2) !important;
    }
    
    /* Mobile Totals Box */
    tfoot {
        display: flex !important;
        flex-direction: column !important;
        background: #f0fdf4 !important;
        border: 1px dashed #4ade80 !important;
        border-radius: 12px !important;
        padding: 16px !important;
        margin-bottom: 24px !important;
    }
    .erp-label {
        font-size: 10px !important;
        margin-bottom: 4px !important;
    }
    
    /* Make item grid full width by negating parent padding */
    #domesticItemsSection, #exportFieldsSection {
        margin-left: -12px !important;
        margin-right: -12px !important;
        width: calc(100% + 24px) !important;
    }
    tfoot tr {
        display: flex !important;
        justify-content: space-around !important;
        width: 100% !important;
    }
    tfoot td {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        font-size: 16px !important;
        font-weight: 800 !important;
        color: #166534 !important;
        padding: 0 !important;
        border: none !important;
    }
    /* Hide the empty/label TDs in tfoot */
    tfoot td[colspan] {
        display: none !important;
    }
    /* Inject Labels into the actual total value cells */
    #totalQtyKg::before, #exportTotalQtyKg::before, #purchaseDealTotalQty::before { 
        content: "TOTAL WEIGHT (KG)"; font-size: 10px; font-weight: 700; color: #22c55e; margin-bottom: 4px;
    }
    #totalPieces::before, #exportTotalPieces::before { 
        content: "TOTAL QTY"; font-size: 10px; font-weight: 700; color: #22c55e; margin-bottom: 4px;
    }
    .responsive-form-grid {
        grid-template-columns: 1fr 1fr !important;
        grid-auto-flow: dense !important;
        gap: 12px !important;
    }
    .col-span-2-mobile {
        grid-column: span 2 / span 2 !important;
    }
    .responsive-form-grid-single {
        grid-template-columns: 1fr !important;
    }
}

/* ============================================
   PRINT
   ============================================ */
@media print {
    .no-print    { display: none !important; }
    .erp-header  { display: none !important; }
    body         { background: white !important; }
    .erp-panel   { border: none !important; box-shadow: none !important; padding: 0 !important; background: white !important; }
}

/* Mobile input overrides — unified 14px */
@media (max-width: 768px) {
    #itemsTableBody input, #itemsTableBody select, 
    .ec-product-row input, .ec-product-row select,
    .dc-product-row input, .dc-product-row select {
        font-size: 14px !important;
        min-height: 42px !important;
        padding: 10px 12px !important;
        line-height: 1.5 !important;
    }
}

/* --- Register Tables Font Size Override --- */
#domesticRegisterTableWrapper table th,
#domesticRegisterTableWrapper table td,
#exportRegisterTableWrapper table th,
#exportRegisterTableWrapper table td {
    font-size: 13px !important;
}
