/* ============================================
   LABELS MODAL — Thumbnail Sidebar Layout
   ============================================ */

:root {
    --thumb-label-width: clamp(110px, calc((90dvh - 205px) * 148 / 210 / 3), 165px);
    --label-preview-width: min(480px, calc((90dvh - 220px) * 148 / 210), 100%);
}

/* ===== Modal Panel ===== */
.labels-modal-panel {
    width: min(1200px, 95vw);
    height: min(900px, 90dvh);
    min-height: 620px;
    max-height: 90dvh;
    overflow: hidden;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    display: grid;
    grid-template-rows: auto 1fr;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

/* ===== Toolbar ===== */
.labels-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    z-index: 2;
}

.toolbar-title {
    display: grid;
    gap: 0.2rem;
}

.toolbar-title h2 {
    font-family: 'Space Grotesk', sans-serif;
    margin: 0;
    font-size: 1rem;
    line-height: 1.2;
}

.labels-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ===== Layout Switch (Detailed / Simple) ===== */
.label-layout-switch {
    display: inline-flex;
    padding: 3px;
    gap: 2px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
}

.label-layout-switch .layout-btn {
    padding: 4px 12px;
    border: 0;
    border-radius: calc(var(--radius-sm) - 2px);
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-size: 0.78rem;
    cursor: pointer;
    line-height: 1.4;
}

.label-layout-switch .layout-btn:hover {
    color: var(--text-primary);
}

.label-layout-switch .layout-btn.active {
    background: var(--accent-orange);
    color: #ffffff;
    font-weight: 600;
}

/* ===== Warning Banner ===== */
.label-warning {
    margin: 0;
    padding: 0.65rem 1rem;
    border-bottom: 1px solid rgba(220, 38, 38, 0.35);
    background: rgba(220, 38, 38, 0.08);
    color: #fca5a5;
    font-size: 0.72rem;
    line-height: 1.4;
}

/* ===== Workspace (viewer + sidebar) ===== */
.labels-workspace {
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 250px;
}

/* ===== Left: Label Viewer ===== */
.label-viewer {
    min-width: 0;
    min-height: 0;
    display: grid;
    grid-template-rows: auto 1fr auto;
    background: var(--bg-primary);
}

.viewer-status {
    min-height: 48px;
    padding: 10px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 12px;
}

.viewer-status strong {
    color: var(--text-primary);
    font-size: 13px;
}

/* Page indicator + prev/next buttons grouped together on the right of the
   status bar, so the pager sits right after "Page X of Y". */
.viewer-pagenav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.viewer-stage {
    min-height: 0;
    padding: 18px;
    overflow: hidden;
    display: grid;
    place-items: center;
}

/* ===== Selected Label (large preview) ===== */
.selected-label {
    width: var(--label-preview-width);
    aspect-ratio: 148 / 210;
    background: #ffffff;
    color: #0d0f12;
    border: 1px solid #4b5563;
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.38);
    display: grid;
    grid-template-rows: 1fr auto;
    overflow: hidden;
    transition: opacity 120ms ease, transform 120ms ease;
    container-type: inline-size;
}

.selected-label.is-changing {
    opacity: 0.35;
    transform: translateY(4px);
}

.label-content {
    width: 86%;
    margin: 4cqi auto 0;
    display: grid;
    /* logo · reference · fields(1fr, expands) · importer footer (pinned bottom) */
    grid-template-rows: auto auto 1fr auto;
    row-gap: 3.5cqi;
}

.label-logo-area {
    height: 11cqi;
    border-bottom: 1px solid #9ca3af;
    display: grid;
    place-items: center;
    padding-bottom: 1.8cqi;
}

.label-logo-fallback {
    width: 68%;
    height: 7cqi;
    border: 1px dashed #8f98a6;
    color: #5d6674;
    display: grid;
    place-items: center;
    font-size: 2.6cqi;
    font-weight: 700;
    letter-spacing: 0.5cqi;
    /* Match the logo image's ~3% upward nudge (see .label-logo-img). */
    transform: translateY(-4.3cqi);
}

/* MYON logo image (replaces the text fallback) — kept small so it never
   touches the header divider above the reference. */
.label-logo-img {
    max-width: 58%;
    max-height: 70%;
    width: auto;
    height: auto;
    object-fit: contain;
    /* Nudge the logo ~3% of the label height upward (both layouts share this).
       Container is inline-size, so vertical units must be cqi (% of width):
       4.3cqi of 148mm ≈ 6.4mm ≈ 3% of the 210mm label height. */
    transform: translateY(-4.3cqi);
}

.label-reference {
    text-align: center;
    font-size: 12cqi;
    line-height: 0.95;
    font-weight: 800;
    word-break: keep-all;
    overflow-wrap: normal;
}

.label-details-grid {
    display: grid;
    /* Wider left column so the longer values (product, container, vessel) get
       more room — leaves the data sitting further right, more space on the left. */
    grid-template-columns: 1.3fr 1fr;
    gap: 3cqi 5cqi;
    align-content: start;
}

.label-line-full {
    grid-column: 1 / -1;
}

.label-key {
    font-size: 2.7cqi;
    line-height: 1;
    margin-bottom: 1.2cqi;
    color: #111827;
}

.label-value {
    font-size: 5.8cqi;
    line-height: 1.1;
    font-weight: 800;
    text-transform: uppercase;
    word-break: keep-all;
    overflow-wrap: normal;
}

/* ===== Simple Layout (fewer fields, bigger text) ===== */
.label-content-simple {
    row-gap: 2.4cqi;
}

/* File reference stays at the top (under the logo/divider) with no extra gap.
   The content section (variety/quantity…) gets a ~5% margin BELOW the file
   reference. Container is inline-size, so the vertical margin uses cqi (% of width). */
.label-content-simple .label-simple-grid {
    margin-top: 5cqi;
}

/* Two independent flex columns (wider left for Variety/Brand/Product) so a
   wrapping value in one column never adds dead space beside the other. */
.label-simple-grid {
    display: flex;
    align-items: flex-start;
    gap: 4cqi;
}
.label-simple-col {
    display: flex;
    flex-direction: column;
    gap: 2.2cqi;
    min-width: 0;
}
.label-simple-col:nth-child(1) { flex: 1.3; }
.label-simple-col:nth-child(2) { flex: 1; }

.label-simple-line {
    display: grid;
    gap: 0.6cqi;
    min-width: 0;
}

.label-key-lg {
    font-size: 3cqi;
    line-height: 1;
    font-weight: 600;
    letter-spacing: 0.3cqi;
    text-transform: uppercase;
    color: #4b5563;
}

/* Bigger than the detailed layout's values for easy reading; the wider
   left column keeps a single variety/brand/product word on one line. */
.label-value-lg {
    font-size: 7.4cqi;
    line-height: 1.05;
    font-weight: 800;
    text-transform: uppercase;
    word-break: keep-all;
    overflow-wrap: normal;
    color: #0d0f12;
}

/* ===== Importer footer (pinned just above the barcode divider) ===== */
.label-importer {
    margin-bottom: 1.2cqi;
}

.label-importer-key {
    font-size: 2.7cqi;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.3cqi;
    color: #4b5563;
    margin-bottom: 0.8cqi;
}

.label-importer-value {
    font-size: 4.6cqi;
    line-height: 1.05;
    font-weight: 800;
    text-transform: uppercase;
    /* Importer name always on a single row, even when long — shrink to fit
       rather than wrap. */
    white-space: nowrap;
    color: #0d0f12;
}

/* ===== Barcode Area ===== */
.barcode-wrap {
    width: 94%;
    margin: 0 auto 3.5cqi;
    position: relative;
}

.label-divider {
    border-top: 2px solid #9ca3af;
    margin-bottom: 2cqi;
}

.barcode-box {
    text-align: center;
}

.barcode-svg {
    width: 100%;
    height: 8cqi;
}

.barcode-fallback {
    border: 1px dashed #111827;
    padding: 1cqi;
    font-size: 2.8cqi;
    text-align: center;
    margin: 0 auto;
}

.barcode-value-text {
    margin-top: 0.6cqi;
    text-align: right;
    font-size: 2.8cqi;
    line-height: 1;
    font-weight: 600;
    letter-spacing: 0.2cqi;
    color: #374151;
}

.barcode-pallet-nr {
    margin-top: 1cqi;
    text-align: center;
    font-size: 8cqi;
    line-height: 1;
    font-weight: 800;
}

.external-no {
    position: absolute;
    right: 0;
    bottom: 0.8cqi;
    font-size: 2.5cqi;
    font-weight: 700;
}

/* ===== Viewer Footer / Pager ===== */
.viewer-footer {
    min-height: 44px;
    padding: 8px 18px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    color: var(--text-muted);
    font-size: 12px;
}

.pager-buttons {
    display: flex;
    gap: 8px;
}

.pager-btn {
    min-width: 34px;
    height: 30px;
    padding: 0 11px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    /* Action buttons are orange on the dark theme, header-blue on light
       (overridden below) — matches the rest of the app's button accents. */
    background: var(--accent-orange, #f97316);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    font: inherit;
}

.pager-btn:hover:not(:disabled) {
    background: var(--accent-orange-dim, #c2410c);
}

.pager-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Light theme: action buttons use the top-header / brand blue. */
[data-theme="light"] .pager-btn,
[data-theme="light"] #labelsModal .btn-primary {
    background: #0a5989 !important;
    border-color: #0a5989 !important;
    color: #fff !important;
}
[data-theme="light"] .pager-btn:hover:not(:disabled),
[data-theme="light"] #labelsModal .btn-primary:hover {
    background: #0d6ea6 !important;
    border-color: #0d6ea6 !important;
}

/* ===== Right: Thumbnail Rail ===== */
.thumbnail-rail {
    min-height: 0;
    width: 250px;
    background: var(--bg-tertiary);
    border-left: 1px solid var(--border-color);
    display: grid;
    grid-template-rows: auto 1fr;
}

.thumbnail-header {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.thumbnail-header h2 {
    margin: 0;
    font-size: 13px;
    line-height: 1.2;
}

.thumbnail-count {
    color: var(--text-muted);
    font-size: 12px;
}

.thumbnail-list {
    min-height: 0;
    overflow-y: auto;
    padding: 8px 0 10px;
    display: grid;
    justify-items: center;
    gap: 6px;
}

/* ===== Thumbnail Items ===== */
.thumb-item {
    width: calc(var(--thumb-label-width) + 28px);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    padding: 5px;
    background: transparent;
    color: inherit;
    cursor: pointer;
    display: grid;
    justify-items: center;
    gap: 4px;
    font: inherit;
}

.thumb-item:hover {
    background: var(--bg-hover);
    border-color: var(--border-highlight);
}

.thumb-item.active {
    background: rgba(249, 115, 22, 0.14);
    border-color: var(--accent-orange);
}

.thumb-label {
    width: var(--thumb-label-width);
    aspect-ratio: 148 / 210;
    background: #ffffff;
    color: #111827;
    border: 1px solid #6b7280;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.25);
    display: grid;
    grid-template-rows: 1fr auto;
    overflow: hidden;
}

.thumb-content {
    width: 86%;
    margin: 7% auto 0;
    display: grid;
    grid-template-rows: auto auto 1fr;
    row-gap: clamp(4px, 0.9dvh, 8px);
}

.thumb-logo {
    height: clamp(16px, 2.8dvh, 24px);
    border-bottom: 1px solid #d1d5db;
    display: grid;
    place-items: center;
    font-size: 5px;
    letter-spacing: 1px;
    font-weight: 700;
    color: #6b7280;
}

.thumb-logo-img {
    max-width: 80%;
    max-height: 80%;
    width: auto;
    height: auto;
    object-fit: contain;
}

.thumb-reference {
    text-align: center;
    font-size: clamp(18px, 3dvh, 24px);
    line-height: 1;
    font-weight: 800;
}

.thumb-lines {
    display: grid;
    gap: clamp(4px, 0.8dvh, 7px);
    align-content: start;
}

.thumb-line {
    height: clamp(5px, 0.9dvh, 8px);
    background: #111827;
}

.thumb-line.short { width: 70%; }
.thumb-line.medium { width: 86%; }

.thumb-barcode-wrap {
    width: 88%;
    margin: 0 auto clamp(5px, 1dvh, 8px);
}

.thumb-divider {
    border-top: 1px solid #d1d5db;
    margin-bottom: 5px;
}

.thumb-barcode {
    height: clamp(17px, 2.7dvh, 24px);
    display: flex;
    justify-content: center;
    gap: 1px;
    overflow: hidden;
}

.thumb-barcode span {
    width: var(--w);
    background: #111827;
}

.thumb-number {
    margin-top: 3px;
    text-align: center;
    font-size: 11px;
    line-height: 1;
    font-weight: 800;
}

.thumb-caption {
    width: var(--thumb-label-width);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--text-muted);
    font-size: 10px;
    line-height: 1;
}

.thumb-item.active .thumb-caption {
    color: var(--text-primary);
}

.page-chip {
    padding: 2px 7px;
    border-radius: var(--radius-sm);
    background: var(--accent-orange);
    color: #ffffff;
    font-size: 10px;
    font-weight: 700;
}

/* ===== Empty State ===== */
.label-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    padding: 2rem;
    color: #dc2626 !important;
    font-size: 1.15rem;
    font-weight: 700;
    text-align: center;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #ffffff !important;
    margin: 1rem 1.5rem 1.5rem;
}

/* LIGHT THEME — themes.css has a broad `[data-theme="light"] div { background-color:inherit;
   color:inherit }` rule that out-specifies the labels-modal classes, so the panel + its
   inner divs inherit the dark overlay backdrop → a black modal. Force the real surfaces
   with !important (per the theme-compliance standard). */
[data-theme="light"] .labels-modal-panel,
[data-theme="light"] .labels-workspace,
[data-theme="light"] .label-viewer,
[data-theme="light"] .viewer-stage,
[data-theme="light"] .thumbnail-rail { background: #ffffff !important; }
[data-theme="light"] .labels-toolbar { background: #f6f9fc !important; }
[data-theme="light"] .selected-label,
[data-theme="light"] .thumb-label { background: #ffffff !important; }
[data-theme="light"] .label-empty { background: #ffffff !important; color: #dc2626 !important; }

/* ===== Print staging container =====
   Built by printAll(): holds one .print-label-page per label. Kept OFF-SCREEN
   (not display:none) and sized at the true print geometry — 148mm wide with
   `container-type: inline-size` — so fitLabelText() measures each value at the
   size it will actually print (cqi font-fit is otherwise computed against the
   wrong width) AND the giant label pages never flash at the bottom of the page.
   The @media print block below resets it back on-page. */
#labelsPrintContainer {
    position: fixed;
    left: -10000px;
    top: 0;
    width: 148mm;
    z-index: -1;
    pointer-events: none;
}
#labelsPrintContainer .print-label-page {
    width: 148mm;
    height: 210mm;
    background: #fff;
    color: #0b0f14;
    display: grid;
    grid-template-rows: 1fr auto;
    overflow: hidden;
    container-type: inline-size;
}

/* ===== Print Styles ===== */
body.printing-labels .top-nav,
body.printing-labels .page-header,
body.printing-labels .stats-summary,
body.printing-labels .filters-bar,
body.printing-labels .positions-table-container,
body.printing-labels #positionModal,
body.printing-labels .theme-toggle,
body.printing-labels #toast {
    display: none !important;
}

@media print {
    @page {
        size: 148mm 210mm;
        margin: 0;
    }

    body.printing-labels {
        background: #fff !important;
    }

    /* Undo the off-screen staging offset so the pages print on-page. */
    body.printing-labels #labelsPrintContainer {
        position: static !important;
        left: auto !important;
        top: auto !important;
        width: auto !important;
        z-index: auto !important;
    }

    body.printing-labels #labelsModal {
        position: static !important;
        display: block !important;
        background: #fff !important;
        inset: auto !important;
        padding: 0 !important;
    }

    body.printing-labels .labels-modal-panel {
        border: none !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        overflow: visible !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        display: block !important;
    }

    body.printing-labels .labels-toolbar,
    body.printing-labels .label-warning,
    body.printing-labels .thumbnail-rail,
    body.printing-labels .viewer-status,
    body.printing-labels .viewer-footer {
        display: none !important;
    }

    /* Print ONLY the generated #labelsPrintContainer pages. Hide the on-screen
       viewer/preview (the currently-selected label) — otherwise it printed a
       SECOND time on top of its own print page ("same label twice"). */
    body.printing-labels .labels-workspace,
    body.printing-labels .label-viewer,
    body.printing-labels .viewer-stage,
    body.printing-labels .selected-label {
        display: none !important;
    }

    /* Hide all labels except the one being printed */
    body.printing-labels .print-label-page {
        width: 148mm;
        height: 210mm;
        background: #fff;
        color: #0b0f14;
        margin: 0 auto;
        border: none;
        page-break-after: always;
        break-after: page;
        display: grid;
        grid-template-rows: 1fr auto;
        overflow: hidden;
        container-type: inline-size;
    }

    body.printing-labels .print-label-page:last-child {
        page-break-after: auto;
        break-after: auto;
    }
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .labels-modal-panel {
        width: calc(100vw - 24px);
        height: calc(100dvh - 24px);
        min-height: 0;
        max-height: calc(100dvh - 24px);
    }

    .labels-workspace {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 1fr) 210px;
    }

    .thumbnail-rail {
        width: auto;
        border-left: 0;
        border-top: 1px solid var(--border-color);
        grid-template-rows: auto 1fr;
    }

    .thumbnail-list {
        padding: 12px;
        display: flex;
        overflow-x: auto;
        overflow-y: hidden;
        justify-content: flex-start;
    }

    .thumb-item {
        flex: 0 0 auto;
    }

    .thumbnail-header {
        padding: 10px 12px;
    }

    .viewer-stage {
        padding: 16px;
    }

    .toolbar-actions .btn {
        padding: 0 10px;
    }
}

@media (max-width: 640px) {
    .labels-toolbar,
    .viewer-status,
    .viewer-footer {
        align-items: flex-start;
        flex-direction: column;
    }

    .toolbar-actions,
    .pager-buttons {
        width: 100%;
    }

    .toolbar-actions .btn,
    .pager-buttons .pager-btn {
        flex: 1;
    }

    .selected-label {
        width: min(390px, calc((100dvh - 270px) * 148 / 210), 100%);
    }
}

/* ============================================
   GENERAL CARGO (SHIP SUPPLY) LABEL — 4x6 in
   Ported 2026-09-27 from the Schiphol WMS 4x6 template, including its
   2026-09-24 FOOTER LOCK: the DETAILS row is minmax(0, 1fr) (a plain 1fr is
   minmax(auto, 1fr) and grew past the free space, pushing the logo divider and
   the 01/02 sequence off the sticker); every other row is fixed and clips; the
   details text is scaled by --ss-fit (set by fitSsLabels() in the preview AND
   in the print tab); the footer is a FLEX column with a 4cqi bottom safety
   margin (Chrome's print/PDF pipeline dropped the logo image from a GRID footer
   that combined align-content:end with bottom padding).
   Used ONLY when the position's active packing list is 'general' — the fresh
   A5 layouts above are untouched. Selectors are scoped under .ss-label-root so
   themes.css's broad [data-theme="light"] div { color: inherit } cannot win.
   ============================================ */

/* On-screen preview: a true 4:6 frame (the class is set by setActive()). */
.selected-label.is-ss-4x6 {
    aspect-ratio: 4 / 6;
    grid-template-rows: 1fr;
    width: auto;
    height: min(100%, 720px);   /* 720 = 480 x 6/4: once the width cap bites the height follows the aspect */
    max-width: min(480px, 100%);
}
.thumb-label.thumb-label-ss { aspect-ratio: 4 / 6; }
.thumb-label-ss .thumb-reference { font-size: 0.62rem; overflow-wrap: anywhere; }
.thumb-label-ss .thumb-barcode { margin: 6% 0; }
[data-theme="light"] .thumb-label-ss .thumb-line { background: #111827 !important; }   /* themes.css `div { background-color: inherit }` blanks them */

.ss-label-root {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-rows:
        16cqi           /* PO / REF */
        20cqi           /* BARCODE */
        22cqi           /* ADDITIONAL REFERENCES: File ref | Take-in, + Vessel */
        19.9cqi         /* SHIPPER | CUSTOMER */
        minmax(0, 1fr)  /* DETAILS + ORIGIN: never grows past the free space (footer lock) */
        24cqi;          /* FOOTER: logo + divider + 01/05 */
    color: #0d0f12;
    background: #ffffff;
    font-family: 'Space Grotesk', 'JetBrains Mono', system-ui, sans-serif;
    overflow: hidden;
    min-height: 0;
}
.ss-label-root > div { min-width: 0; min-height: 0; }

.ss-label-root .ss-label-file-section {
    display: grid;
    place-items: center;
    border-bottom: 1.5px solid #0d0f12;
    padding: 1cqi 3cqi;
    overflow: hidden;
}
.ss-label-root .ss-label-file-ref {
    font-size: 7.5cqi;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-align: center;
    overflow-wrap: anywhere;
    line-height: 1;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
}
.ss-label-root .ss-label-file-ref.is-long { font-size: 5.6cqi; }
.ss-label-root .ss-label-file-ref.is-xlong { font-size: 4.4cqi; }

.ss-label-root .ss-label-barcode-section {
    display: grid;
    place-items: center;
    border-bottom: 1.5px solid #0d0f12;
    padding: 1.5cqi 3cqi;
    text-align: center;
    overflow: hidden;
}
.ss-label-root .ss-label-barcode-section .barcode-svg {
    width: 90%;
    height: 11cqi;
    display: block;
    margin: 0 auto;
}
.ss-label-root .ss-label-barcode-section .barcode-fallback { font-size: 4cqi; }
.ss-label-root .ss-label-barcode-value {
    margin-top: 0.6cqi;
    font-size: 6cqi;
    font-weight: 800;
    letter-spacing: 0.08em;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    line-height: 1;
    white-space: nowrap;
}

.ss-label-root .ss-label-addrefs-section,
.ss-label-root .ss-label-details-section {
    padding: 1.6cqi 3cqi;
    border-bottom: 1.5px solid #0d0f12;
}
.ss-label-root .ss-label-addrefs-section { overflow: hidden; }
.ss-label-root .ss-label-section-title {
    font-size: 2.7cqi;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: #0d0f12;
    line-height: 1.1;
    text-transform: uppercase;
    margin-bottom: 0.4cqi;
}
.ss-label-root .ss-label-section-body {
    font-size: 3.4cqi;
    font-weight: 600;
    line-height: 1.25;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
}
.ss-label-root .ss-label-section-body > div { line-height: 1.25; }

.ss-label-root .ss-label-addrefs-body { padding-top: 0.4cqi; }
.ss-label-root .ss-label-ref-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 3cqi;
    align-items: start;
}
.ss-label-root .ss-label-ref-col {
    display: flex;
    flex-direction: column;
    gap: 0.4cqi;
    min-width: 0;
}
.ss-label-root .ss-label-ref-col + .ss-label-ref-col {
    border-left: 1px solid #cbd2da;
    padding-left: 3cqi;
}
.ss-label-root .ss-ref-k {
    font-family: 'Space Grotesk', system-ui, sans-serif;
    font-size: 2.4cqi;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #4b5563 !important;   /* beats themes.css [data-theme=light] span { color: inherit !important } */
    line-height: 1;
}
.ss-label-root .ss-ref-v {
    font-size: 3.6cqi;
    font-weight: 700;
    line-height: 1.1;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}
.ss-label-root .ss-ref-v.is-long { font-size: 3cqi; }
.ss-label-root .ss-ref-v.is-xlong { font-size: 2.6cqi; }
.ss-label-root .ss-label-vessel {
    margin-top: 1.4cqi;
    padding-top: 1cqi;
    border-top: 1px dashed #cbd2da;
    font-size: 3.4cqi;
    font-weight: 800;
    letter-spacing: 0.03em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ss-label-root .ss-label-vessel.is-long { font-size: 3cqi; }
.ss-label-root .ss-label-vessel.is-xlong { font-size: 2.6cqi; }

.ss-label-root .ss-label-parties-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-bottom: 1.5px solid #0d0f12;
    overflow: hidden;
}
.ss-label-root .ss-label-party {
    padding: 1.4cqi 2.6cqi;
    border-left: 1px solid #0d0f12;
    overflow: hidden;   /* fixed track: long names wrap max 2-3 lines and step down in size */
    min-width: 0;
}
.ss-label-root .ss-label-party:first-child { border-left: none; }
.ss-label-root .ss-label-party-name {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    overflow-wrap: anywhere;
}
.ss-label-root .ss-label-party-name.is-long { font-size: 2.9cqi; }
.ss-label-root .ss-label-party-name.is-xlong { font-size: 2.5cqi; letter-spacing: -0.01em; -webkit-line-clamp: 3; }

.ss-label-root .ss-label-details-section {
    border-bottom: none;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: calc(2cqi * var(--ss-fit, 1));
    overflow: hidden;   /* the only flexible row: it clips, --ss-fit shrinks its text */
    min-height: 0;
}
.ss-label-root .ss-label-details-section .ss-label-section-title { font-size: calc(2.7cqi * var(--ss-fit, 1)); }
.ss-label-root .ss-label-details-section .ss-label-section-body { font-size: calc(3.4cqi * var(--ss-fit, 1)); overflow-wrap: anywhere; }
.ss-label-root .ss-label-qty { font-weight: 800; }
.ss-label-root .ss-label-cargo { font-weight: 700; }

.ss-label-root .ss-label-footer-section {
    display: flex;               /* FLEX, not grid: see the header note */
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    text-align: center;
    padding: 0 0 4cqi;           /* ~4 mm safety margin: the sequence ends ~6 mm above the edge */
    overflow: hidden;
}
.ss-label-root .ss-label-footer-logo {
    width: 100%;
    height: 7.5cqi;
    display: grid;
    place-items: center;
    padding: 0.6cqi 0;
    margin-bottom: 2.5cqi;
}
.ss-label-root .ss-label-footer-logo-img {
    height: 6.25cqi;
    width: auto;
    max-width: 72%;
    object-fit: contain;
    display: block;
}
.ss-label-root .ss-label-footer-logo-fallback {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 4cqi;
    font-weight: 800;
    letter-spacing: 0.2em;
}
.ss-label-root .ss-label-footer-value {
    border-top: 1.5px solid #0d0f12;
    width: 100%;
    padding: 1cqi 0;
    font-size: 6cqi;
    font-weight: 800;
    letter-spacing: 0.05em;
    line-height: 1.1;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
}
