/* ---------- GENERAL PAGE THEME ---------- */
body {
    background-color: #f8f9fa;  /* soft white-grey background */
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #333;
    margin: 0;
    padding: 0;
}

header {
    background-color: #e5e7eb;  /* light grey header */
    color: #111;
    padding: 1rem 2rem;
    font-weight: 600;
    text-align: center;
    border-bottom: 2px solid #d1d5db;
}

/* ---------- LINKS ---------- */
a {
    color: #2563eb;  /* blue accent for links */
    text-decoration: none;
}
a:hover {
    color: #1e40af;
}

/* ---------- BUTTONS ---------- */
button, .btn {
    background-color: #4b5563;  /* neutral grey button */
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    border: none;
    cursor: pointer;
    transition: background-color 0.3s;
}
button:hover, .btn:hover {
    background-color: #374151;  /* darker grey on hover */
}

/* ---------- CARD STYLING ---------- */
.card {
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

/* ---------- PRINT FORMATS (from your existing setup) ---------- */

/* Global label variables and page setup for consistent printer alignment */
:root {
    --label-width: 62mm;   /* DK-11209 compatible width */
    --label-height: 29mm;  /* 29mm height */
    --offset-x: 0mm;       /* fine-tune horizontal offset if printer shifts */
    --offset-y: 0mm;       /* fine-tune vertical offset if printer shifts */

    /* Brother TZe tape defaults + fine offsets (can be adjusted in CSS) */
    --tze-length: 40mm;         /* default printable length per label */
    --tze-offset-x: 0mm;        /* horizontal offset for TZe labels */
    --tze-offset-y: 0mm;        /* vertical offset for TZe labels */
    /* common tape heights (aka tape width in mm). Users may switch via class */
    --tze-h-06: 6mm;
    --tze-h-09: 9mm;
    --tze-h-12: 12mm;
    --tze-h-18: 18mm;
    --tze-h-24: 24mm;
}

/* Named page used only when we add the PAGE class to the print container */
@page label29 {
    size: var(--label-width) var(--label-height);
    margin: 0;
}
@media print {
    body * { visibility: hidden; }
    .print-container.active, .print-container.active * { visibility: visible; }
    /* Center the active print label exactly in the middle of the page */
    .print-container.active {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        box-sizing: border-box;
        font-family: Arial, sans-serif;
        font-size: 19pt;
        background: #fff;
    }

    /* Precise page-box for 29mm labels: place at top-left, exact size, no scaling */
    .print-container.active.label-29mm-page {
        top: 0; left: 0; right: auto; bottom: auto;
        width: var(--label-width);
        height: var(--label-height);
        justify-content: center;
        align-items: center;
        transform: translate(var(--offset-x), var(--offset-y));
        page: label29;
    }
    /* Ensure the inner BID block is flex, QR beside text, centered */
    .bid-print-row {
        display: flex !important;
        flex-direction: row !important; /* QR beside text */
        align-items: center !important;
        justify-content: center !important; /* center the whole label block */
        gap: 4mm !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    .bid-print-row img {
        width: 50mm !important;
        height: auto !important;
        object-fit: contain !important;
        margin: 0 !important; /* spacing handled by gap */
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    .bid-print-row p {
        margin: 0 !important;
        font-size: 14pt !important;
        font-family: monospace !important;
        color: #111 !important;
        text-align: left !important; /* default left for inline text */
    }
    .bid-print-row .bid-print-text { display: flex !important; flex-direction: column !important; }
    .bid-print-row .bid-print-text p { text-align: left !important; }
    .no-print { display: none !important; }

    /* Precise label size overrides for 29mm roll */
    .bid-print-row.label-29mm {
        /* Constrain overall height to 29mm and keep content centered */
        height: var(--label-height) !important;
        padding: 0 !important;
        gap: 2mm !important; /* tighter spacing to fit more lines */
        align-items: center !important;
    }
    .bid-print-row.label-29mm img {
        width: var(--label-height) !important;
        height: var(--label-height) !important;
        margin: 0 !important; /* spacing handled by gap */
        object-fit: contain !important;
    }
    .bid-print-row.label-29mm .bid-print-text {
        /* Ensure text never exceeds label height */
        max-height: var(--label-height) !important;
        overflow: hidden !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important; /* center block vertically against QR */
    }
    .bid-print-row.label-29mm p {
        margin: 0 !important;
        font-size: 9pt !important;      /* compact font to fit all lines */
        line-height: 1.05 !important;   /* tight line height */
        white-space: nowrap !important; /* keep each field on a single line */
    }

    /* QR-only label: center QR with BID caption below */
    .bid-qr-only {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 2mm !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    .bid-qr-only img {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        object-fit: contain !important;
    }
    .bid-qr-only p {
        margin: 0 !important;
        font-size: 14pt !important;
        font-weight: bold !important;
        font-family: monospace !important;
        color: #111 !important;
        text-align: center !important;
        white-space: nowrap !important;
    }
    .bid-qr-only.label-29mm {
        height: var(--label-height) !important;
        width: var(--label-width) !important;
    }
    .bid-qr-only.label-29mm img {
        height: calc(var(--label-height) - 8mm) !important; /* leave room for caption */
        width: calc(var(--label-height) - 8mm) !important;  /* keep square QR */
    }

    /* Multiple 29mm labels in one print run */
    .labels-29mm-multi {
        page: label29;
        /* allow full page flow; do not constrain container to label size */
        width: auto !important;
        height: auto !important;
        transform: none !important;
        background: #fff !important;
    }
    .labels-29mm-multi .label-29mm-block {
        width: var(--label-width) !important;
        height: var(--label-height) !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        page-break-after: always !important;
        /* position the label content within page printable area using offsets */
        transform: translate(var(--offset-x), var(--offset-y));
    }
    .labels-29mm-multi .label-29mm-block:last-child {
        page-break-after: auto !important;
    }

    /* ===== UID per-page printing (center each UID on its own full page) ===== */
    .perpage-uid {
        page: auto;
        width: auto !important;
        height: auto !important;
        transform: none !important;
        background: #fff !important;
    }
    .perpage-uid .uid-page {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        min-height: 100vh !important;
        page-break-after: always !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    .perpage-uid .uid-page:last-child {
        page-break-after: auto !important;
    }
    .perpage-uid .uid-matrix-item,
    .perpage-uid .uid-matrix-item.text-center {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 8mm !important;
    }
    .perpage-uid .uid-matrix-item img {
        max-width: 70vw !important;
        max-height: 70vh !important;
        width: auto !important;
        height: auto !important;
        object-fit: contain !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    .perpage-uid .uid-text {
        font-family: monospace !important;
        font-size: 16pt !important;
        color: #111 !important;
        margin: 0 !important;
        text-align: center !important;
    }

    /* ===== Continuous Strip for TZe ===== */
    .continuous-tze.active {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 5mm !important;
        overflow: visible !important;
        width: max-content !important;
        height: 100% !important;
    }
    .continuous-tze.active .uid-matrix-item {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        width: auto !important;
    }
    .continuous-tze.active .uid-matrix-item img {
        height: 80% !important;
        width: auto !important;
    }
    .continuous-tze.active .uid-text {
        font-size: 10pt !important;
    }

}

/* Keep your QR, modal, and grid styling as before */
.print-container { display: none; }
.print-container.active { display: block; }
.hidden-qr { display: none; }

.qr-code-row {
    display: flex; justify-content: space-around; align-items: flex-start;
    gap: 2px;
}

.qr-code-item { display: flex; flex-direction: column; align-items: center; text-align: center; }
.qr-code-item img { width: 175px; height: 180px; }

.modal-backdrop {
    display: none; position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(4px); z-index: 50;
    justify-content: center; align-items: center;
}
.modal-backdrop.active { display: flex; }
.modal-content { background: white; padding: 2rem; border-radius: 0.5rem; position: relative; width: 400px; }
.modal-close { position: absolute; top: 0.5rem; right: 0.5rem; background: none; border: none; font-size: 1.5rem; cursor: pointer; }
.blur-content { filter: blur(4px); pointer-events: none; }



/* ---------- SUPPLY CHAIN ANIMATED BACKGROUND (SVG) ---------- */
:root {
    --scn-opacity: 0.55;
    --scn-opacity-dark: 0.35;
    --scn-opacity-subtle: 0.30;
}
.scn-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    /* subtle pattern behind content */
    opacity: var(--scn-opacity);
}
.scn-bg svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* ---------- TOAST NOTIFICATIONS ---------- */
.toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 1000002;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    background: white;
    color: #1f2937;
    padding: 1rem 1.25rem;
    border-radius: 0.75rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 300px;
    max-width: 400px;
    margin-bottom: 0.75rem;
    border-left: 4px solid #10b981;
    transform: translateX(120%);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
    opacity: 0;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast-icon {
    flex-shrink: 0;
    width: 1.5rem;
    height: 1.5rem;
    color: #10b981;
}

.toast-content {
    flex-grow: 1;
}

.toast-title {
    font-weight: 600;
    font-size: 0.875rem;
}

.toast-message {
    font-size: 0.8125rem;
    color: #4b5563;
}

.toast-close {
    flex-shrink: 0;
    color: #9ca3af;
    cursor: pointer;
    transition: color 0.2s;
}

.toast-close:hover {
    color: #4b5563;
}

@keyframes toastProgress {
    from { width: 100%; }
    to { width: 0%; }
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: #10b981;
    opacity: 0.3;
    animation: toastProgress linear forwards;
}

/* ---------- SCANNER OVERLAY (graphical) ---------- */
.scan-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 1rem;
}

.scan-box {
    position: relative;
    width: min(520px, 90vw);
    height: 200px;
    border-radius: 16px;
    background: rgba(17, 24, 39, 0.75); /* gray-900 @ 75% */
    box-shadow: 0 10px 30px rgba(0,0,0,0.35), inset 0 0 0 1px rgba(255,255,255,0.08);
    overflow: hidden;
}

.scan-grid {
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(255,255,255,0.06) 1px, transparent 1px),
                      linear-gradient(90deg, rgba(255,255,255,0.06) 1px, transparent 1px);
    background-size: 20px 20px, 20px 20px;
    filter: blur(0.2px);
}

.scan-bar {
    position: absolute;
    left: 0;
    right: 0;
    top: -20%;
    height: 28%;
    background: linear-gradient(to bottom, rgba(74,222,128,0) 0%, rgba(74,222,128,0.45) 40%, rgba(74,222,128,0.55) 60%, rgba(74,222,128,0) 100%);
    box-shadow: 0 0 25px 8px rgba(74,222,128,0.25);
    animation: scanSweep 1.9s linear infinite;
}

.scan-icon {
    position: absolute;
    width: 200px;
    height: 200px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.9;
    fill: rgba(255,255,255,0.85);
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.5));
}

.scan-text {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    text-align: center;
    padding: 16px 12px;
    background: linear-gradient(to top, rgba(0,0,0,0.45), rgba(0,0,0,0));
}

.scan-dots {
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 0.02em;
}
.scan-dots span { opacity: 0.2; animation: dots 1.4s infinite; }
.scan-dots span:nth-child(1) { animation-delay: 0s; }
.scan-dots span:nth-child(2) { animation-delay: 0.2s; }
.scan-dots span:nth-child(3) { animation-delay: 0.4s; }

.scan-sub {
    margin-top: 4px;
    font-size: 0.85rem;
    color: rgba(255,255,255,0.8);
}

@keyframes scanSweep {
    0% { top: -28%; }
    100% { top: 100%; }
}

@keyframes dots {
    0%, 20% { opacity: 0.2; }
    50% { opacity: 1; }
    100% { opacity: 0.2; }
}

/* Soft radial gradient wash for extra depth */
.scn-bg::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
      radial-gradient(1200px 800px at 20% 15%, rgba(37, 99, 235, 0.08), transparent 55%),
      radial-gradient(900px 700px at 85% 80%, rgba(16, 185, 129, 0.08), transparent 60%),
      radial-gradient(700px 500px at 60% 30%, rgba(245, 158, 11, 0.05), transparent 55%);
}

/* Per-page variants (apply on <body>) */
.bg-plain .scn-bg { display: none !important; }
.bg-subtle .scn-bg { opacity: var(--scn-opacity-subtle) !important; }

/* Animated dashed flow along routes */
.route {
    stroke-dasharray: 6 12;
    stroke-dashoffset: 0;
}
.anim-flow { animation: scn-flow 12s linear infinite; }
@keyframes scn-flow {
    from { stroke-dashoffset: 0; }
    to   { stroke-dashoffset: -400; }
}

/* Moving trucks horizontally */
.anim-truck-right { animation: scn-right 40s linear infinite; will-change: transform; }
.anim-truck-left  { animation: scn-left  46s linear infinite; will-change: transform; }
@keyframes scn-right {
    from { transform: translateX(0); }
    to   { transform: translateX(1800px); }
}
@keyframes scn-left {
    from { transform: translateX(0); }
    to   { transform: translateX(-1800px); }
}

/* Vertical movement for pallets/boxes */
.anim-box-up   { animation: scn-up   28s linear infinite; will-change: transform; }
.anim-box-down { animation: scn-down 32s linear infinite; will-change: transform; }
@keyframes scn-up   { from { transform: translateY(0); } to { transform: translateY(-1100px); } }
@keyframes scn-down { from { transform: translateY(0); } to { transform: translateY(1100px); } }

/* Parallax panning for route layers */
.layer-far  { animation: scn-pan1 120s linear infinite; will-change: transform; }
.layer-mid  { animation: scn-pan2  90s linear infinite; will-change: transform; }
.layer-near { /* keep static; only icons move for clarity */ }
@keyframes scn-pan1 { from { transform: translate3d(0,0,0); } to { transform: translate3d(-60px,-30px,0); } }
@keyframes scn-pan2 { from { transform: translate3d(0,0,0); } to { transform: translate3d(50px,-40px,0); } }

/* Silhouettes (plane/ship/warehouse) slow glide */
.silhouette { opacity: 0.12; animation: scn-glide 160s linear infinite; filter: blur(0.2px); }
@keyframes scn-glide { from { transform: translate3d(0,0,0); } to { transform: translate3d(-800px,-200px,0); } }

/* Accessibility: reduce motion when requested */
@media (prefers-reduced-motion: reduce) {
    .anim-flow,
    .anim-truck-right,
    .anim-truck-left,
    .anim-box-up,
    .anim-box-down,
    .layer-far,
    .layer-mid,
    .silhouette {
        animation: none !important;
    }
}

/* Small screens: keep it lighter */
@media (max-width: 640px) {
    .layer-far, .silhouette { display: none; }
    /* slightly slower near-layer actors */
    .anim-truck-right { animation-duration: 52s; }
    .anim-truck-left  { animation-duration: 58s; }
    .anim-box-up      { animation-duration: 34s; }
    .anim-box-down    { animation-duration: 38s; }
}

/* Dark mode tweaks */
@media (prefers-color-scheme: dark) {
    .scn-bg { opacity: var(--scn-opacity-dark); }
}

/* ---------- FORMS: INPUTS, SELECTS, ACCESSIBILITY ---------- */
/* Ensure selects and options are readable across browsers and themes */
select,
input,
textarea {
    color: #111827; /* gray-900 */
}

select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-color: #ffffff; /* solid background so text stays visible */
}

select:disabled,
input:disabled,
textarea:disabled {
    color: #6b7280; /* gray-500 */
}

/* Native dropdown options (best-effort, varies by browser) */
option {
    color: #111827; /* gray-900 */
    background: #ffffff;
}

/* Focus ring for accessibility (matches Tailwind focus styles) */
select:focus,
input:focus,
textarea:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.35); /* blue-500 ring */
    border-color: #3b82f6;
}

@media (prefers-color-scheme: dark) {
    /* Keep the site using the same light theme even when the OS is in dark mode */
    body { color: #333; }
    select,
    input,
    textarea {
        background-color: #ffffff; /* force light background */
        color: #111827; /* gray-900 text */
        border-color: #d1d5db; /* gray-300 border */
    }
    option {
        background: #ffffff; /* keep dropdown options light */
        color: #111827;
    }
}



/* ---------- UID LABELS & DATAMATRIX VIEW & PRINT (FINAL VERSION) ---------- */
.uid-scroll-container {
    position: relative;
    max-width: 100%;
    height: 160px;              /* slightly taller for text visibility */
    overflow-x: auto;           /* enable horizontal scroll */
    overflow-y: hidden;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #f9fafb;
    padding: 6mm;
    box-sizing: border-box;
    scroll-behavior: smooth;
}

/* Scrollbar styling */
.uid-scroll-container::-webkit-scrollbar {
    height: 8px;
}
.uid-scroll-container::-webkit-scrollbar-thumb {
    background: #9ca3af;
    border-radius: 3px;
}
.uid-scroll-container::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* ---------- SCREEN VIEW: Horizontal Layout with extra spacing ---------- */
.uid-matrix-row {
    display: flex !important;
    flex-direction: row !important;
    justify-content: flex-start;
    align-items: flex-start;
    flex-wrap: nowrap !important;
    gap: 35mm !important;       /* 🔹 extra spacing between UIDs */
    white-space: nowrap !important;
}

.uid-matrix-item {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    width: 45mm;                /* 🔹 more width for long UID text */
    text-align: center;
    vertical-align: top;
}

.uid-matrix-item img {
    width: 10mm !important;
    height: 10mm !important;
    object-fit: contain !important;
}


.uid-text {
    margin-top: 4mm;
    font-size: 10pt;
    font-family: monospace;
    color: #333;
    word-wrap: break-word;
    white-space: normal;        /* 🔹 allow wrapping */
    line-height: 1.2;
}

/* ---------- GLOBAL MOBILE RESPONSIVENESS ---------- */
img, video { max-width: 100%; height: auto; }

/* Small screens: make modals and long rows fit the viewport */
@media (max-width: 640px) {
  .modal-content {
    width: 92vw;
    max-width: 92vw;
    padding: 1rem;
  }

  /* Reduce height of UID scroll area and padding on small screens */
  .uid-scroll-container {
    height: 120px;
    padding: 3mm;
  }

  /* Allow QR rows to wrap nicely and reduce image sizes */
  .qr-code-row {
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
  }
  .qr-code-item img {
    width: 120px;
    height: 120px;
  }

  /* Make UID matrix spacing tighter and allow wrapping for narrow screens */
  .uid-matrix-row {
    gap: 8mm !important;
    flex-wrap: wrap !important;
  }
  .uid-matrix-item {
      width: auto;
      min-width: 10mm;
  }
}
/* Tables: use wrapper for horizontal scroll to keep header/body aligned */
/* Responsive table container: fixed height + scroll (GLOBAL) */
.table-responsive {
    /* Default max height for scrollable tables; can be overridden per instance */
    --table-max-h: 420px;
    --table-header-bg: #f3f4f6; /* gray-100 */
    --table-header-bg-2: #f8fafc; /* slate-50 */
    --table-header-text: #111827; /* gray-900 */
    --table-row-hover: #f1f5f9; /* slate-100 */
    --table-row-stripe: #fafafa; /* neutral-50 */
    --table-border: #e5e7eb; /* gray-200 */

    position: relative;
    max-height: var(--table-max-h);
    overflow-y: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;

    background: #ffffff;
    border: 1px solid var(--table-border);
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.table-responsive > table {
    width: 100%;
    min-width: 640px;
    border-collapse: separate; /* needed for sticky header with borders */
    border-spacing: 0;
}
/* Keep headers visible while scrolling */
.table-responsive thead th {
    position: sticky;
    top: 0;
    background: linear-gradient(var(--table-header-bg-2), var(--table-header-bg));
    color: var(--table-header-text);
    z-index: 10;
    font-weight: 600;
    letter-spacing: 0.02em;
    box-shadow: 0 1px 0 var(--table-border);
}
/* Sort indicators */
th.sort-asc::after,
th.sort-desc::after {
    content: '';
    display: inline-block;
    margin-left: 6px;
    opacity: 0.6;
    font-size: 10px;
}
th.sort-asc::after { content: '▲'; }
th.sort-desc::after { content: '▼'; }
/* Optional: maintain header bottom border when sticky */
.table-responsive thead th,
.table-responsive tbody td,
.table-responsive tbody th {
    border-bottom: 1px solid var(--table-border);
}
/* Rounded header corners inside the wrapper */
.table-responsive thead th:first-child { border-top-left-radius: 8px; }
.table-responsive thead th:last-child { border-top-right-radius: 8px; }

/* Ensure that all overlays are always on top of sticky table headers/columns.
   We use a high z-index and ensure no stacking context issues within .table-responsive. */
[id*="overlay"], [id*="modal"], [id*="loading"], .fixed.inset-0 {
    z-index: 1000000 !important;
}
/* Re-allow some specific lower z-indices if they were intended to be below other things but still above content */
#messenger-container { z-index: 9999 !important; }
#mobileOverlay { z-index: 9998 !important; }
#mobileDrawer { z-index: 9999 !important; }

/* Zebra striping & hover states for better readability */
.table-responsive tbody tr:nth-child(even) td { background: var(--table-row-stripe); }
.table-responsive tbody tr:hover td { background: var(--table-row-hover); }

/* Denser cell layout already set globally; keep consistent */
table th, table td { padding: 0.5rem 0.5rem !important; font-size: 12px !important; }

/* Subtle scroll edge hints (horizontal) */
.table-responsive::before,
.table-responsive::after {
    content: "";
    position: absolute;
    top: 0; bottom: 0;
    width: 18px;
    pointer-events: none;
    z-index: 1;
}
.table-responsive::before {
    left: 0;
    background: linear-gradient(90deg, rgba(255,255,255,0.9), rgba(255,255,255,0));
}
.table-responsive::after {
    right: 0;
    background: linear-gradient(270deg, rgba(255,255,255,0.9), rgba(255,255,255,0));
}

/* Scrollbar styling (WebKit) */
.table-responsive::-webkit-scrollbar { height: 10px; width: 10px; }
.table-responsive::-webkit-scrollbar-track { background: #f3f4f6; border-radius: 8px; }
.table-responsive::-webkit-scrollbar-thumb {
    background-color: #cbd5e1; /* slate-300 */
    border-radius: 8px;
    border: 2px solid #f3f4f6;
}
.table-responsive::-webkit-scrollbar-thumb:hover { background-color: #94a3b8; /* slate-400 */ }

/* On small screens, cap height to a portion of the viewport for better UX */
@media (max-width: 640px) {
  .table-responsive { max-height: min(60vh, var(--table-max-h)); }
}

/* Height utility modifiers for tables (override --table-max-h) */
.table-h-320 { --table-max-h: 320px; }
.table-h-420 { --table-max-h: 420px; }
.table-h-600 { --table-max-h: 600px; }

/* Cell helpers (mostly useful on tight layouts) */
.cell-break { word-break: break-word; white-space: normal; }
.cell-nowrap { white-space: nowrap; }

/* Narrow table modifier: allow tables to shrink below global 640px when needed */
.table-responsive.table-narrow > table {
    min-width: 0;
}

/* Tighten the first column (Item) and keep number columns compact */
.table-tight-item th:first-child,
.table-tight-item td:first-child {
    max-width: 14ch;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.table-tight-item th:nth-child(2),
.table-tight-item td:nth-child(2) {
    width: 6ch;
    white-space: nowrap;
}
.table-tight-item th:nth-child(3),
.table-tight-item td:nth-child(3) {
    width: 6ch;
    white-space: nowrap;
}

/* Realtime Activity table column sizing: keep width fixed, avoid horizontal scroll */
.table-activity th:nth-child(1),
.table-activity td:nth-child(1) {
    /* Time */
    width: 9ch;
    white-space: nowrap;
}
.table-activity th:nth-child(2),
.table-activity td:nth-child(2) {
    /* Event */
    width: 12ch;
    white-space: nowrap;
}
.table-activity th:nth-child(5),
.table-activity td:nth-child(5) {
    /* Qty */
    width: 6ch;
    white-space: nowrap;
    text-align: right;
}
.table-activity td:nth-child(3) {
    /* Details (item/link + id) */
    max-width: 26ch;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.table-activity td:nth-child(4) {
    /* Location */
    max-width: 18ch;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 640px) {
  .table-activity td:nth-child(3) { max-width: 18ch; }
  .table-activity td:nth-child(4) { max-width: 14ch; }
}

@media print {
  /* Hide interface elements */
  .no-print,
  header,
  form,
  button,
  .btn {
    display: none !important;
  }

  /* Show only the active print container */
  .print-container {
    display: none !important;
  }

  .print-container.active {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    flex-wrap: nowrap !important;
    justify-content: center !important;
    align-items: center !important;
    background: #fff !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    z-index: 9999 !important;
    page-break-inside: avoid !important;
  }

  /* Auto-fit UIDs on page */
  .uid-matrix-row {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 3mm !important;
    width: 100% !important;
  }

  .uid-matrix-item {
    flex: 0 1 10mm !important;       /* keep 10 mm width per UID */
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
  }

  .uid-matrix-item img {
    width: 10mm !important;
    height: 10mm !important;
    object-fit: contain !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Hide UID text when printing */
  .uid-text {
    display: none !important;
  }

  /* --- Overrides for per-page UID print mode --- */
  /* Allow the per-page UID container to flow across multiple pages instead of fixed centering */
  .print-container.active.perpage-uid {
    position: static !important;
    inset: auto !important;
    width: auto !important;
    height: auto !important;
    display: block !important;
    justify-content: normal !important;
    align-items: normal !important;
    background: #fff !important;
    overflow: visible !important;
    transform: none !important;
  }
  /* Each UID should occupy a full page and be centered */
  .perpage-uid .uid-page {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 100vh !important;
    page-break-after: always !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  .perpage-uid .uid-page:last-child { page-break-after: auto !important; }

  /* Ensure large, readable UID visuals in per-page mode (override global 10mm sizing) */
  .perpage-uid .uid-matrix-item,
  .perpage-uid .uid-matrix-item.text-center {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8mm !important;
  }
  .perpage-uid .uid-matrix-item img {
    max-width: 70vw !important;
    max-height: 70vh !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  /* Make UID text visible and larger in per-page mode */
  .perpage-uid .uid-text {
    display: block !important;
    font-family: monospace !important;
    font-size: 16pt !important;
    color: #111 !important;
    margin: 0 !important;
    text-align: center !important;
  }

  /* (Removed) TZe TAPE LABEL PRINTING — deprecated */

  @page {
    size: auto;   /* automatically adjusts to printer/page size */
    margin: 0;
  }

  html, body {
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
  }
}


/* Screen defaults (print overrides above will take precedence in print) */
.bid-print-row img { width: 200px; height: auto; }
.bid-print-row p { font-size: 14pt; font-family: monospace; color: #111; text-align: center; }

.sidebar {
    width: 300px;
    background-color: #f3f4f6;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

/* ---------- HOME TICKER ANIMATIONS ---------- */
@keyframes flashGreen {
  0%   { background-color: rgba(16,185,129,0.00); }
  20%  { background-color: rgba(16,185,129,0.18); }
  100% { background-color: rgba(16,185,129,0.00); }
}
@keyframes flashRed {
  0%   { background-color: rgba(239,68,68,0.00); }
  20%  { background-color: rgba(239,68,68,0.18); }
  100% { background-color: rgba(239,68,68,0.00); }
}
.flash-up {
  animation: flashGreen 1.2s ease-out;
}
.flash-down {
  animation: flashRed 1.2s ease-out;
}


/* ---------- BÜK MORPHING LOGO ---------- */
.buk-morph-container {
    position: relative;
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 1000px;
}

.buk-morph-base {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 16px;
    background: linear-gradient(135deg, #0d9488 0%, #0f766e 100%);
    box-shadow: 
        0 10px 15px -3px rgba(0, 0, 0, 0.1), 
        0 4px 6px -2px rgba(0, 0, 0, 0.05),
        inset 0 2px 4px rgba(255, 255, 255, 0.3),
        inset 0 -2px 4px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    animation: buk-morph-loop 2.4s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    transform-style: preserve-3d;
}

/* Glow effect behind the logo */
.buk-morph-container::before {
    content: '';
    position: absolute;
    width: 120%;
    height: 120%;
    background: radial-gradient(circle, rgba(13, 148, 136, 0.4) 0%, transparent 70%);
    border-radius: 50%;
    animation: buk-glow-pulse 1.2s ease-in-out infinite;
    z-index: -1;
}

@keyframes buk-glow-pulse {
    0%, 100% { transform: scale(0.8); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

.buk-morph-text {
    color: white;
    font-size: 24px;
    font-weight: 900;
    letter-spacing: -0.05em;
    user-select: none;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    animation: buk-text-fade 2.4s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.buk-morph-icon {
    position: absolute;
    width: 36px;
    height: 36px;
    color: white;
    opacity: 0;
    stroke: currentColor;
    stroke-width: 2.5;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.icon-scanner {
    animation: buk-scanner-fade 2.4s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.icon-barcode {
    animation: buk-barcode-fade 2.4s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes buk-morph-loop {
    0%, 30% { transform: scale(1) rotateX(0deg); border-radius: 16px; }
    33%, 63% { transform: scale(1.1) rotateX(10deg) rotateY(5deg); border-radius: 12px; }
    66%, 96% { transform: scale(1) rotateX(0deg) rotateZ(5deg); border-radius: 16px; }
    100% { transform: scale(1) rotateX(0deg); border-radius: 16px; }
}

@keyframes buk-text-fade {
    0%, 25% { opacity: 1; transform: scale(1) translateZ(10px); }
    30%, 100% { opacity: 0; transform: scale(0.5) translateZ(0); }
}

@keyframes buk-scanner-fade {
    0%, 30% { opacity: 0; transform: scale(0.5) translateY(10px) translateZ(0); }
    35%, 60% { opacity: 1; transform: scale(1) translateY(0) translateZ(15px); }
    65%, 100% { opacity: 0; transform: scale(0.5) translateY(-10px) translateZ(0); }
}

@keyframes buk-barcode-fade {
    0%, 63% { opacity: 0; transform: scale(0.5) rotate(-10deg) translateZ(0); }
    68%, 93% { opacity: 1; transform: scale(1) rotate(0deg) translateZ(15px); }
    98%, 100% { opacity: 0; transform: scale(0.5) rotate(10deg) translateZ(0); }
}

.buk-bounce-rotate {
    animation: buk-master-bounce 1.2s ease-in-out infinite;
}

@keyframes buk-master-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

/* ================= CUSTOM TEAL UTILITIES (FALLBACK FOR PRE-COMPILED TAILWIND) ================= */
.bg-teal-50 { background-color: #f0fdfa !important; }
.bg-teal-100 { background-color: #ccfbf1 !important; }
.bg-teal-200 { background-color: #99f6e4 !important; }
.bg-teal-500 { background-color: #14b8a6 !important; }
.bg-teal-600 { background-color: #0d9488 !important; }
.bg-teal-700 { background-color: #0f766e !important; }
.bg-teal-800 { background-color: #115e59 !important; }
.bg-teal-900 { background-color: #134e4a !important; }

.hover\:bg-teal-50:hover { background-color: #f0fdfa !important; }
.hover\:bg-teal-100:hover { background-color: #ccfbf1 !important; }
.hover\:bg-teal-600:hover { background-color: #0d9488 !important; }
.hover\:bg-teal-700:hover { background-color: #0f766e !important; }
.hover\:bg-teal-800:hover { background-color: #115e59 !important; }

.text-teal-400 { color: #2dd4bf !important; }
.text-teal-500 { color: #14b8a6 !important; }
.text-teal-600 { color: #0d9488 !important; }
.text-teal-700 { color: #0f766e !important; }
.text-teal-800 { color: #115e59 !important; }
.text-teal-900 { color: #134e4a !important; }

.hover\:text-teal-600:hover { color: #0d9488 !important; }
.hover\:text-teal-800:hover { color: #115e59 !important; }
.hover\:text-teal-900:hover { color: #134e4a !important; }

.border-teal-100 { border-color: #ccfbf1 !important; }
.border-teal-200 { border-color: #99f6e4 !important; }
.border-teal-300 { border-color: #5eead4 !important; }
.border-teal-400 { border-color: #2dd4bf !important; }
.border-teal-500 { border-color: #14b8a6 !important; }
.border-teal-600 { border-color: #0d9488 !important; }

.focus\:ring-teal-500:focus { --tw-ring-color: #14b8a6 !important; }
.focus\:border-teal-500:focus { border-color: #14b8a6 !important; }

/* Gradient stop variables for Tailwind compatibility */
.from-teal-600 {
    --tw-gradient-from: #0d9488 !important;
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, rgba(13, 148, 136, 0)) !important;
}
.via-teal-500 {
    --tw-gradient-stops: var(--tw-gradient-from), #14b8a6 !important, var(--tw-gradient-to, rgba(20, 184, 166, 0)) !important;
}
.to-teal-400 {
    --tw-gradient-to: #2dd4bf !important;
}
.to-teal-500 {
    --tw-gradient-to: #14b8a6 !important;
}
.to-teal-700 {
    --tw-gradient-to: #0f766e !important;
}

.from-teal-800 {
    --tw-gradient-from: #115e59 !important;
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, rgba(17, 94, 89, 0)) !important;
}
.via-teal-700 {
    --tw-gradient-stops: var(--tw-gradient-from), #0f766e !important, var(--tw-gradient-to, rgba(15, 118, 110, 0)) !important;
}
.to-teal-600 {
    --tw-gradient-to: #0d9488 !important;
}
.from-teal-900 {
    --tw-gradient-from: #134e4a !important;
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, rgba(19, 78, 74, 0)) !important;
}
.via-teal-800 {
    --tw-gradient-stops: var(--tw-gradient-from), #115e59 !important, var(--tw-gradient-to, rgba(17, 94, 89, 0)) !important;
}

.shadow-teal-200 {
    --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color) !important;
    --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(3px + var(--tw-ring-offset-width)) rgba(20, 184, 166, 0.3) !important;
    box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000) !important;
}

