/* ============================================================
   Storacle — Premium Production UI
   Design: Sharp, modern, data-density first.
   No noise. No decoration. Built for people working fast.
   ============================================================ */

:root {
    /* Dark, professional background system */
    --clr-canvas:    #f0f2f5;
    --clr-surface:   #ffffff;
    --clr-surface-2: #f8f9fa;
    --clr-border:    #e3e7ec;

    /* Sidebar — deep charcoal with green accent */
    --clr-sidebar:      #16202a;
    --clr-sidebar-2:    #1e2c38;
    --clr-sidebar-text: #b0bec5;
    --clr-sidebar-hi:   #eceff1;

    /* Brand / Primary — clean, saturated green */
    --clr-primary:       #1aab5e;
    --clr-primary-dark:  #148b4c;
    --clr-primary-faint: #e8f8f0;

    /* Accent colors (for status chips only, sparingly) */
    --clr-amber:  #f59e0b;
    --clr-red:    #ef4444;
    --clr-blue:   #3b82f6;
    --clr-purple: #8b5cf6;
    --clr-teal:   #06b6d4;

    /* Semantic */
    --clr-success: #1aab5e;
    --clr-danger:  #ef4444;
    --clr-warning: #f59e0b;

    /* Typography */
    --font:       'Outfit', system-ui, sans-serif;
    --text-hi:    #111827;  /* High-emphasis text */
    --text-med:   #374151;  /* Medium text */
    --text-lo:    #6b7280;  /* Low / muted */
    --text-faint: #9ca3af;  /* Very muted / labels */

    /* Geometry */
    --r-xs:  4px;
    --r-sm:  8px;
    --r-md:  12px;
    --r-lg:  16px;
    --r-xl:  24px;

    /* Shadows */
    --s-xs: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --s-sm: 0 4px 12px rgba(0,0,0,.06);
    --s-md: 0 8px 24px rgba(0,0,0,.08);

    /* Motion */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --dur:  160ms;
}

/* ---- Reset & base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-med);
    background: var(--clr-canvas);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ---- Top-level layout ---- */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    opacity: 1;
    transition: opacity 400ms var(--ease);
}
.app-container.layout-loading { opacity: 0; }

/* ================================================================
   SIDEBAR
   ================================================================ */
.sidebar {
    width: 256px;
    flex-shrink: 0;
    background: var(--clr-sidebar);
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255,255,255,.04);
    z-index: 20;
    transition: width 250ms var(--ease);
    overflow: hidden;
}

/* Collapsed sidebar — icons only */
.sidebar.collapsed {
    width: 64px;
}
.sidebar.collapsed .sidebar-header { padding: 16px 12px 12px; }
.sidebar.collapsed .brand h2,
.sidebar.collapsed .clock-display,
.sidebar.collapsed .nav-group h3,
.sidebar.collapsed .sidebar-footer #btn-feedback,
.sidebar.collapsed .sidebar-footer #btn-undo,
.sidebar.collapsed #sidebar-user-bar span,
.sidebar.collapsed #sidebar-user-bar .bi-chevron-right { display: none !important; }
.sidebar.collapsed .brand { justify-content: center; margin-bottom: 8px; }
.sidebar.collapsed .brand-logo { width: 28px; height: 28px; }
.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 10px 0;
    gap: 0;
}
.sidebar.collapsed .nav-link i { width: auto; font-size: 1.15rem; }
.sidebar.collapsed .nav-link span,
.sidebar.collapsed .nav-link:not(i) { font-size: 0; }
.sidebar.collapsed .sidebar-nav { padding: 12px 8px; }
.sidebar.collapsed .sidebar-footer { padding: 10px 8px; }
.sidebar.collapsed #sidebar-user-bar {
    justify-content: center !important;
    padding: 8px !important;
}

/* Collapse toggle button */
.sidebar-collapse-btn {
    position: absolute;
    top: 32px;
    right: 12px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.12);
    color: var(--clr-sidebar-text);
    font-size: 0.7rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 25;
    transition: background 150ms, transform 250ms var(--ease);
    padding: 0;
}
.sidebar-collapse-btn:hover {
    background: var(--clr-primary);
    color: #fff;
}
.sidebar.collapsed .sidebar-collapse-btn {
    top: 54px;
    right: 50%;
    transform: translateX(50%) rotate(180deg);
}

.sidebar-header {
    padding: 28px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,.05);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.brand i {
    font-size: 1.3rem;
    color: var(--clr-primary);
}

.brand h2 {
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: -.5px;
    color: #fff;
}

.brand-logo {
    width: 36px;
    height: 36px;
    object-fit: contain;
}

/* Delete row button — subtle red on hover */
.btn-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: var(--r-xs);
    background: transparent;
    color: var(--text-faint);
    font-size: 1rem;
    cursor: pointer;
    transition: background var(--dur), color var(--dur);
}
.btn-delete:hover {
    background: #fef2f2;
    color: var(--clr-danger);
}

/* Clock */
.clock-display {
    padding: 12px 14px;
    background: rgba(255,255,255,.04);
    border-radius: var(--r-sm);
    border: 1px solid rgba(255,255,255,.06);
}
.clock-display .date {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--clr-sidebar-hi);
    letter-spacing: .3px;
}
.clock-display .time {
    font-size: 0.75rem;
    color: var(--clr-sidebar-text);
    font-variant-numeric: tabular-nums;
    font-family: 'SF Mono', 'Fira Code', monospace;
    margin-top: 2px;
}
.clock-display .week-pill {
    display: inline-block;
    margin-top: 8px;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: .5px;
    text-transform: uppercase;
    background: var(--clr-primary);
    color: #fff;
}
.clock-display .season-name {
    display: block;
    margin-top: 8px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--clr-sidebar-text);
    letter-spacing: .3px;
}

/* Nav */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
    scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-group { margin-top: 28px; }
.nav-group:first-child { margin-top: 0; }

.nav-group h3 {
    padding: 0 10px 6px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: #4b6075;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--r-sm);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--clr-sidebar-text);
    text-decoration: none;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
    margin-bottom: 2px;
    user-select: none;
}
.nav-link i {
    font-size: 1rem;
    width: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    opacity: .7;
    transition: opacity var(--dur);
}
.nav-link:hover {
    background: rgba(255,255,255,.06);
    color: #fff;
}
.nav-link:hover i { opacity: 1; }

.nav-link.active {
    background: var(--clr-primary);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 10px rgba(26,171,94,.35);
}
.nav-link.active i { opacity: 1; }

/* Sidebar footer */
.sidebar-footer {
    padding: 14px 12px;
    border-top: 1px solid rgba(255,255,255,.05);
}

.btn-icon {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 14px;
    border-radius: var(--r-sm);
    border: 1px solid rgba(255,255,255,.08);
    background: transparent;
    color: var(--clr-sidebar-text);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--dur), color var(--dur);
}
.btn-icon:hover:not(:disabled) {
    background: rgba(255,255,255,.07);
    color: #fff;
}
.btn-icon:disabled { opacity: .3; cursor: not-allowed; }


/* ================================================================
   MAIN CONTENT
   ================================================================ */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 40px 48px;
}

/* Page */
.page {
    max-width: 1440px;
    margin: 0 auto;
    animation: slideIn var(--dur) var(--ease);
}

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

/* Page header */
.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 28px;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -.6px;
    color: var(--text-hi);
}

.page-subtitle {
    margin-top: 4px;
    font-size: 0.9rem;
    color: var(--text-lo);
}


/* ================================================================
   CARD
   ================================================================ */
.card {
    background: var(--clr-surface);
    border-radius: var(--r-lg);
    border: 1px solid var(--clr-border);
    box-shadow: var(--s-xs);
    padding: 28px;
    margin-bottom: 24px;
}


/* ================================================================
   BUTTONS
   ================================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 20px;
    border-radius: var(--r-sm);
    border: none;
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--dur), box-shadow var(--dur), transform var(--dur);
    white-space: nowrap;
    letter-spacing: -.1px;
}

.btn-primary {
    background: var(--clr-primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(26,171,94,.25);
}
.btn-primary:hover {
    background: var(--clr-primary-dark);
    box-shadow: 0 4px 16px rgba(26,171,94,.35);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--clr-surface);
    color: var(--text-med);
    border: 1px solid var(--clr-border);
    box-shadow: var(--s-xs);
}
.btn-secondary:hover {
    background: var(--clr-surface-2);
    color: var(--text-hi);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--text-lo);
    border: 1px solid var(--clr-border);
}
.btn-ghost:hover {
    background: var(--clr-surface-2);
    color: var(--text-med);
}


/* ================================================================
   DATA TABLE — the core component
   ================================================================ */
.data-table-container {
    background: var(--clr-surface);
    border-radius: var(--r-lg);
    border: 1px solid var(--clr-border);
    overflow: hidden;
    box-shadow: var(--s-xs);
}

/* Sticky scrolling for wide tables */
.data-table-scroll { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

/* Section header rows (group labels inside table) */
thead tr.thead-group th {
    padding: 10px 20px 8px;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    background: var(--clr-surface-2);
    color: var(--text-faint);
    border-bottom: 1px solid var(--clr-border);
}

thead tr:not(.thead-group) th {
    padding: 13px 20px;
    background: var(--clr-surface-2);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: .6px;
    text-transform: uppercase;
    color: var(--text-lo);
    border-bottom: 2px solid var(--clr-border);
    white-space: normal;
    text-align: center;
    vertical-align: middle;
}

/* Sticky headers — only inside scrollable table containers */
.table-scroll-sticky thead tr.thead-group th {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--clr-surface-2);
}
.table-scroll-sticky thead tr:not(.thead-group) th {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--clr-surface-2);
}
/* When a group header row exists, offset the column header row below it */
.table-scroll-sticky thead tr.thead-group ~ tr:not(.thead-group) th {
    top: 37px;
    z-index: 19;
}

/* ── Frozen first two columns (Lot ID + Product) ──────────────── */
table.freeze-cols th:nth-child(1),
table.freeze-cols td:nth-child(1) {
    position: sticky;
    left: 0;
    z-index: 10;
    background: var(--clr-surface);
}
table.freeze-cols th:nth-child(2),
table.freeze-cols td:nth-child(2) {
    position: sticky;
    left: var(--freeze-col1-w, 160px);
    z-index: 10;
    background: var(--clr-surface);
    box-shadow: 3px 0 6px -2px rgba(0,0,0,0.08);
}
/* Header cells need higher z-index (sticky row + sticky col intersection) */
table.freeze-cols thead th:nth-child(1),
table.freeze-cols thead th:nth-child(2) {
    z-index: 30;
    background: var(--clr-surface-2);
}
/* Hover row override so frozen cells match */
table.freeze-cols tbody tr:hover td:nth-child(1),
table.freeze-cols tbody tr:hover td:nth-child(2) {
    background: var(--clr-surface-2);
}
/* Deep storage rows — frozen cols inherit the blue tint */
table.freeze-cols tbody tr.row-deep td:nth-child(1),
table.freeze-cols tbody tr.row-deep td:nth-child(2) {
    background: #eff6ff;
}
table.freeze-cols tbody tr.row-deep:hover td:nth-child(1),
table.freeze-cols tbody tr.row-deep:hover td:nth-child(2) {
    background: var(--clr-surface-2);
}

td {
    padding: 15px 20px;
    border-bottom: 1px solid var(--clr-border);
    color: var(--text-med);
    vertical-align: middle;
    text-align: center;
}

td:first-child {
    text-align: left;
}

tr:last-child td { border-bottom: none; }

tbody tr {
    transition: background var(--dur);
}
tbody tr:hover td {
    background: var(--clr-surface-2);
}

/* Compact table — reduced horizontal padding for dense views */
.table-compact th { padding: 10px 8px; font-size: 0.68rem; }
.table-compact td { padding: 12px 8px; font-size: 0.82rem; }

/* Wash table — tighter horizontal spacing */
#wash-main-table th { padding: 10px 10px; }
#wash-main-table td { padding: 12px 10px; text-align: center; }

/* Collapsible Lot ID column */
.lot-id-col-header { white-space: nowrap; }
.lot-id-col-header:hover { background: rgba(0,0,0,.06) !important; }
.lot-id-col { transition: padding 200ms var(--ease), width 200ms var(--ease); text-align: center !important; }
td.lot-id-col:empty { padding: 0 4px; width: 0; min-width: 0; }


/* ================================================================
   LOT ID BADGE — prominent, monospace, pill
   ================================================================ */
.lot-id {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--r-xs);
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: .5px;
    white-space: nowrap;
}

.lot-id-prod {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.lot-id-harv {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.lot-id-wash {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.lot-id-crop {
    background: #f0fdfa;
    color: #0f766e;
    border: 1px solid #99f6e4;
}


/* ================================================================
   STATUS / CHIP
   ================================================================ */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: .4px;
    text-transform: uppercase;
    white-space: nowrap;
}

.chip-default { background: #f1f5f9; color: #475569; }
.chip-success { background: #22c55e; color: #fff; border: 1px solid #16a34a; }
.chip-warning { background: #fde047; color: #422006; border: 1px solid #facc15; }
.chip-danger  { background: #ef4444; color: #fff; border: 1px solid #ef4444; display: inline-block; padding: 4px 12px; }
.chip-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }


/* ================================================================
   FORM INPUTS (TABLE CONTEXT)
   ================================================================ */
.tbl-input {
    width: 100%;
    padding: 8px 12px;
    border-radius: var(--r-xs);
    border: 1px solid var(--clr-border);
    font-family: var(--font);
    font-size: 0.875rem;
    color: var(--text-hi);
    background: var(--clr-surface);
    transition: border-color var(--dur), box-shadow var(--dur);
    min-height: 36px;
}
.tbl-input::placeholder { color: var(--text-faint); }
.tbl-input:focus {
    outline: none;
    border-color: var(--clr-primary);
    box-shadow: 0 0 0 3px rgba(26,171,94,.15);
    background: #fff;
}

/* Keep select styled consistently */
select.tbl-input { background-image: none; cursor: pointer; }

/* Hide up/down arrows on number inputs */
input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button { 
  -webkit-appearance: none; 
  margin: 0; 
}
input[type=number] {
  -moz-appearance: textfield; /* Firefox */
}

/* narrow number inputs */
.tbl-input-sm { min-width: 80px; max-width: 110px; }

/* validation error highlight */
.tbl-input.error {
    border-color: #ef4444 !important;
    background-color: #fef2f2 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
}

/* Also keep old class working for backward compat */
.table-input { 
    width: 100%;
    padding: 8px 12px;
    border-radius: var(--r-xs);
    border: 1px solid var(--clr-border) !important;
    font-family: var(--font);
    font-size: 0.875rem;
    color: var(--text-hi);
    background: var(--clr-surface);
    transition: border-color var(--dur), box-shadow var(--dur);
    min-height: 36px;
}
.table-input:focus {
    outline: none;
    border-color: var(--clr-primary) !important;
    box-shadow: 0 0 0 3px rgba(26,171,94,.15);
}


/* ================================================================
   SECTION HEADER (within pages)
   ================================================================ */
.section-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: var(--clr-surface-2);
    border-bottom: 1px solid var(--clr-border);
    gap: 12px;
}

.section-bar-label {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: .5px;
    text-transform: uppercase;
    color: var(--text-lo);
}


/* ================================================================
   FULFILLMENT DAY BADGES
   ================================================================ */
.day-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: .3px;
}
.day-badge-ok   { background: var(--clr-primary); color: #fff; }
.day-badge-fail { background: var(--clr-danger);  color: #fff; }
.day-badge-na   { background: #e5e7eb; color: #9ca3af; }


/* ================================================================
   PROGRESS BAR
   ================================================================ */
.progress-bar-track {
    width: 100%;
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width .4s var(--ease);
}
.progress-fill-ok   { background: var(--clr-primary); }
.progress-fill-warn { background: var(--clr-warning); }


/* ================================================================
   UPLOAD DROP ZONE
   ================================================================ */
.drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 64px 32px;
    border: 2px dashed var(--clr-border);
    border-radius: var(--r-lg);
    background: var(--clr-surface);
    text-align: center;
    cursor: pointer;
    transition: border-color var(--dur), background var(--dur);
}
.drop-zone:hover {
    border-color: var(--clr-primary);
    background: var(--clr-primary-faint);
}
.drop-zone-icon {
    font-size: 2.5rem;
    color: var(--text-faint);
}
.drop-zone-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-hi);
}
.drop-zone-sub {
    font-size: 0.85rem;
    color: var(--text-lo);
}


/* ================================================================
   UTILITY CLASSES
   ================================================================ */
.text-hi    { color: var(--text-hi)   !important; }
.text-lo    { color: var(--text-lo)   !important; }
.text-faint { color: var(--text-faint)!important; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.mono   { font-family: 'SF Mono', 'Fira Code', monospace; font-size: .85em; }
.divider-col { border-right: 2px solid var(--clr-border) !important; }

/* ================================================================
   STORAGE LOCATION THEMES
   ================================================================ */
.theme-deep       { --th-bg: #1e3a8a; --th-tint: #eff6ff; --th-text: #ffffff; --th-label: #bfdbfe; }
.theme-cooler1    { --th-bg: #2563eb; --th-tint: #eff6ff; --th-text: #ffffff; --th-label: #dbeafe; }
.theme-cooler2    { --th-bg: #3b82f6; --th-tint: #f0f9ff; --th-text: #ffffff; --th-label: #dbeafe; }
.theme-cooler3    { --th-bg: #60a5fa; --th-tint: #f0f9ff; --th-text: #ffffff; --th-label: #eff6ff; }
.theme-cooler4    { --th-bg: #93c5fd; --th-tint: #f8fbff; --th-text: #1e3a8a; --th-label: #1e3a8a; }
.theme-greenhouse { --th-bg: #ef4444; --th-tint: #fef2f2; --th-text: #ffffff; --th-label: #fee2e2; }
.theme-dry        { --th-bg: #fca5a5; --th-tint: #fff5f5; --th-text: #7f1d1d; --th-label: #7f1d1d; }
.theme-trailer    { --th-bg: #9ca3af; --th-tint: #f9fafb; --th-text: #ffffff; --th-label: #f3f4f6; }
.theme-pending    { --th-bg: #22c55e; --th-tint: #f0fdf4; --th-text: #ffffff; --th-label: #dcfce7; }
.theme-old        { --th-bg: #facc15; --th-tint: #fefce8; --th-text: #422006; --th-label: #713f12; }
.theme-default    { --th-bg: #f8f9fa; --th-tint: #ffffff; --th-text: #6b7280; --th-label: #9ca3af; }

.data-table-container.theme-deep,
.data-table-container.theme-cooler1,
.data-table-container.theme-cooler2,
.data-table-container.theme-cooler3,
.data-table-container.theme-cooler4,
.data-table-container.theme-greenhouse,
.data-table-container.theme-dry,
.data-table-container.theme-trailer,
.data-table-container.theme-pending,
.data-table-container.theme-old,
.data-table-container.theme-default {
    background: var(--th-tint) !important;
}

.data-table-container.theme-deep .section-bar,
.data-table-container.theme-cooler1 .section-bar,
.data-table-container.theme-cooler2 .section-bar,
.data-table-container.theme-cooler3 .section-bar,
.data-table-container.theme-cooler4 .section-bar,
.data-table-container.theme-greenhouse .section-bar,
.data-table-container.theme-dry .section-bar,
.data-table-container.theme-trailer .section-bar,
.data-table-container.theme-pending .section-bar,
.data-table-container.theme-old .section-bar,
.data-table-container.theme-default .section-bar {
    background: var(--th-bg) !important;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.data-table-container.theme-deep .section-bar-label,
.data-table-container.theme-cooler1 .section-bar-label,
.data-table-container.theme-cooler2 .section-bar-label,
.data-table-container.theme-cooler3 .section-bar-label,
.data-table-container.theme-cooler4 .section-bar-label,
.data-table-container.theme-greenhouse .section-bar-label,
.data-table-container.theme-dry .section-bar-label,
.data-table-container.theme-trailer .section-bar-label,
.data-table-container.theme-pending .section-bar-label,
.data-table-container.theme-old .section-bar-label,
.data-table-container.theme-default .section-bar-label {
    color: var(--th-text) !important;
}

.data-table-container.theme-deep .chip-default,
.data-table-container.theme-cooler1 .chip-default,
.data-table-container.theme-cooler2 .chip-default,
.data-table-container.theme-cooler3 .chip-default,
.data-table-container.theme-cooler4 .chip-default,
.data-table-container.theme-greenhouse .chip-default,
.data-table-container.theme-dry .chip-default,
.data-table-container.theme-trailer .chip-default,
.data-table-container.theme-pending .chip-default,
.data-table-container.theme-old .chip-default,
.data-table-container.theme-default .chip-default {
    background: rgba(255,255,255,0.2) !important;
    color: var(--th-text) !important;
    border-color: rgba(255,255,255,0.1) !important;
}

/* ================================================================
   TABLE SORTING
   ================================================================ */
th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.1s ease;
    white-space: nowrap;
}
th.sortable:hover {
    background-color: rgba(0, 0, 0, 0.04);
}
th.sortable::after {
    content: " \2195"; /* Up/Down arrow */
    opacity: 0.2;
    font-size: 0.75em;
    margin-left: 2px;
}
th.sortable.sort-asc::after {
    content: " \25B2"; /* Up arrow */
    opacity: 1;
    color: var(--clr-primary);
}
th.sortable.sort-desc::after {
    content: " \25BC"; /* Down arrow */
    opacity: 1;
    color: var(--clr-primary);
}

/* --- Global Confirmation Modal --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.modal-card {
    background: #fff;
    border-radius: 12px;
    padding: 32px;
    max-width: 480px;
    width: 90%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    text-align: center;
    transform: scale(1);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.hidden .modal-card {
    transform: scale(0.95);
}

.modal-icon-container {
    width: 64px;
    height: 64px;
    background: #fef2f2;
    color: #ef4444;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto 16px;
}

#global-modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 8px;
}

#global-modal-message {
    font-size: 0.95rem;
    color: #475569;
    margin-bottom: 24px;
    line-height: 1.5;
    overflow-y: auto;
    max-height: 50vh;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.modal-actions .btn {
    flex: 1;
    justify-content: center;
    padding: 10px 16px;
    font-weight: 600;
}

/* ── Lot Timeline ── */
.lot-timeline {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.lot-timeline-sm { gap: 8px; }
.lot-timeline-sm .timeline-event { gap: 8px; }
.lot-timeline-sm .timeline-dot { width: 8px; height: 8px; min-width: 8px; }
.lot-timeline-sm .timeline-title { font-size: 0.8rem; }
.lot-timeline-sm .timeline-date { font-size: 0.7rem; }

.timeline-event {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    position: relative;
}
.timeline-event:not(:last-child)::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 14px;
    bottom: -12px;
    width: 2px;
    background: #e2e8f0;
}
.lot-timeline-sm .timeline-event:not(:last-child)::after {
    left: 3px;
    top: 10px;
    bottom: -8px;
}
.timeline-dot {
    width: 12px;
    height: 12px;
    min-width: 12px;
    border-radius: 50%;
    margin-top: 3px;
    z-index: 1;
}
.timeline-content {
    flex: 1;
    min-width: 0;
}
.timeline-title {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--clr-text);
}
.timeline-date {
    font-size: 0.72rem;
    color: #94a3b8;
    margin-top: 1px;
}
.timeline-details {
    margin-top: 4px;
    line-height: 1.5;
}

/* ── Sublot Rows ── */
.sublot-row:hover {
    background: rgba(37, 99, 235, 0.04);
}
.sublot-expanded {
    background: rgba(37, 99, 235, 0.06) !important;
}
.lot-history-panel td {
    background: #f8fafc;
}

/* ── Lot Index Row ── */
.lot-index-row:hover {
    background: rgba(37, 99, 235, 0.04);
}

/* ── Pack Page ── */
.pack-row-deficit {
    background: #fef2f2 !important;
}
.pack-row-deficit td {
    color: #991b1b;
}
.pack-sort-input {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: border-color 0.15s;
}
.pack-sort-input:focus {
    border-color: var(--clr-primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

/* ── Orders Page — Day Columns ── */
.orders-col-locked {
    background: #f3f4f6 !important;
}
.orders-col-current {
    background: #eff6ff !important;
    border-left: 2px solid var(--clr-primary) !important;
    border-right: 2px solid var(--clr-primary) !important;
}
thead .orders-col-current {
    border-top: 2px solid var(--clr-primary) !important;
}
tfoot .orders-col-current {
    border-bottom: 2px solid var(--clr-primary) !important;
}
.orders-col-future {
    background: #fefce8 !important;
}

/* ── Nav Badge (notification dot) ── */
.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: #ef4444;
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    border-radius: 50%;
    margin-left: auto;
    line-height: 1;
    animation: badge-pulse 2s ease-in-out infinite;
}
@keyframes badge-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* ============================================================
   Product Detail Popup
   ============================================================ */
.product-popup-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0);
    backdrop-filter: blur(0px);
    transition: background 0.25s ease, backdrop-filter 0.25s ease;
    padding: 24px;
}

.product-popup-overlay.popup-visible {
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(6px);
}

.product-popup {
    position: relative;
    width: 100%;
    max-width: 620px;
    max-height: 85vh;
    overflow-y: auto;
    background: var(--clr-surface);
    border-radius: 16px;
    padding: 28px 32px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.18), 0 4px 12px rgba(0, 0, 0, 0.08);
    opacity: 0;
    transform: translateY(20px) scale(0.97);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.popup-visible .product-popup {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.popup-close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-lo);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: background 0.15s ease, color 0.15s ease;
}

.popup-close-btn:hover {
    background: rgba(0, 0, 0, 0.12);
    color: var(--clr-danger);
}


/* Fulfillment row hover */
.fulfill-row:hover { background: rgba(37, 99, 235, 0.04); }
.fulfill-row[onclick]:hover { background: rgba(37, 99, 235, 0.06); }


/* Progress bar track/fill */
.progress-bar-track { height:6px; background:#e5e7eb; border-radius:3px; overflow:hidden; }
.progress-bar-fill { height:100%; border-radius:3px; transition:width 0.3s; }


/* 3-way layout toggle segment control */
.layout-toggle-group {
    display: inline-flex;
    border: 1px solid var(--clr-border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--clr-surface-2);
}
.layout-toggle-btn {
    background: none;
    border: none;
    padding: 6px 12px;
    cursor: pointer;
    color: var(--text-lo);
    font-size: 0.85rem;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 4px;
}
.layout-toggle-btn:hover {
    background: rgba(37, 99, 235, 0.08);
    color: var(--text-hi);
}
.layout-toggle-btn.active {
    background: var(--clr-primary);
    color: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.layout-toggle-btn + .layout-toggle-btn {
    border-left: 1px solid var(--clr-border);
}
.layout-toggle-btn.active + .layout-toggle-btn,
.layout-toggle-btn + .layout-toggle-btn.active {
    border-left-color: var(--clr-primary);
}

/* Icon/Card grid */
.harvest-icon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    padding: 4px;
}
.harvest-card {
    background: #fff;
    border: 1px solid var(--clr-border);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    transition: transform 0.15s, box-shadow 0.15s;
}
.harvest-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}
.harvest-card--done {
    border-color: #86efac;
    background: linear-gradient(135deg, #f0fdf4, #fff);
}
.harvest-card--deep {
    border-color: #93c5fd;
    background: linear-gradient(135deg, #eff6ff, #fff);
}
.harvest-card__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}
.harvest-card__title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-hi);
    margin-bottom: 6px;
    line-height: 1.3;
}
.harvest-card__meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-lo);
    margin-bottom: 10px;
}
.harvest-card__progress {
    margin-bottom: 12px;
}
.harvest-card__stats {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
}
.harvest-card__stat {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.harvest-card__stat-val {
    font-size: 0.85rem;
    font-weight: 700;
}
.harvest-card__stat-lbl {
    font-size: 0.65rem;
    color: var(--text-lo);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.harvest-card__btn {
    width: 100%;
    margin-top: auto;
    padding: 8px 16px;
    font-size: 0.85rem;
}

/* ─── Popup Animations ─── */
@keyframes popupFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes popupSlideUp {
    from { transform: translateY(24px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}


/* ================================================================
   READ-ONLY MODE — Crew users see data but can't mutate
   ================================================================ */
.read-only-mode .btn-primary,
.read-only-mode .btn-danger,
.read-only-mode .btn-close-pack,
.read-only-mode .btn-reopen-pack,
.read-only-mode .btn-delete,
.read-only-mode button[class*="btn-del"],
.read-only-mode .drop-zone,
.read-only-mode input[type="file"],
.read-only-mode .pack-sort-input,
.read-only-mode .btn-secondary:not(.view-mode-btn) {
    display: none !important;
}

/* Dim form inputs but keep them visible for reference */
.read-only-mode input:not([type="search"]):not([type="text"]):not(.search-input),
.read-only-mode select:not(.view-mode-select),
.read-only-mode textarea {
    pointer-events: none;
    opacity: 0.55;
}

/* Keep search/filter inputs fully interactive */
.read-only-mode input[type="text"],
.read-only-mode input[type="search"],
.read-only-mode .search-input {
    pointer-events: auto;
    opacity: 1;
}

/* View Only badge */
.read-only-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    border-radius: 20px;
    background: rgba(107, 114, 128, 0.1);
    color: #6b7280;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    white-space: nowrap;
}
.read-only-badge i {
    font-size: 0.8rem;
}
