/* ==========================================================================
   01. GLOBAL VARIABLES & DESIGN TOKENS
   ========================================================================== */
:root {
    /* Category Colors */
    --wine: #8e3a43;
    --beer: #edc551;
    --cider: #6f9000;
    --soft: #30658e;
    
    /* System Actions & Status Theme */
    --primary: #ffffff;
    --success: #145730;
    --warning: #f39c12;
    --info: #1e577d;
    --purple: #a855f7;
    --danger: #892727;
    --gray: #64748b;
    
    /* Core Layout Canvas Base */
    --bg: #0f172a;
}

/* ==========================================================================
   02. BASE HTML & APPS CONTAINER LAYOUT
   ========================================================================== */
body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    padding: 20px;
    color: #f1f5f9;
    margin: 0;
}

/* Controlled by showApp() logic -> switches display to block when logged in */
.container {
    max-width: 1450px;
    margin: 0 auto;
    display: none; 
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Standard reusable wrapper for form blocks, table wrap, or standalone blocks */
.card {
    background: #1e293b;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    margin-bottom: 20px;
    border: 1px solid #334155;
}

/* Reset number field arrows universally */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
}

/* ==========================================================================
   03. INTERACTIVE CATEGORIES & SYSTEM FILTER CHIPS
   ========================================================================== */
.category-selection,
.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

/* Base style for chip pills (Category switches, status selection headers) */
.btn-cat,
.btn-filter,
.btn-stock-toggle {
    padding: 0 18px;
    height: 36px;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: 0.2s;
    border: 1px solid #475569;
    background: #1e293b;
    color: #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-sizing: border-box;
}

.btn-cat:hover,
.btn-filter:hover,
.btn-stock-toggle:hover {
    background: #334155;
    color: #ffffff;
}

/* Active Category Highlights via JS interaction logic classes */
.btn-wine.active  { background: var(--wine);    color: #ffffff; border-color: var(--wine); }
.btn-beer.active  { background: var(--beer);    color: #222222; border-color: var(--beer); }
.btn-cider.active { background: var(--cider);   color: #ffffff; border-color: var(--cider); }
.btn-soft.active  { background: var(--soft);    color: #ffffff; border-color: var(--soft); }
.btn-all.active   { background: #9e6142;        color: #ffffff; border-color: #9e6142; }

/* Stock Filter Status Sub-Group */
.stock-toggle-group {
    display: flex;
    gap: 6px;
    align-items: center;
}
.btn-stock-toggle.active {
    background: #7682c4;
    color: #ffffff;
    border-color: #475569;
}

/* ==========================================================================
   04. APP SEARCH ENGINE STYLING
   ========================================================================== */
.search-container {
    position: relative;
    min-width: 260px;
    display: inline-block;
}

.search-container i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #64748b;
    font-size: 14px;
}

.search-input {
    width: 100%;
    height: 36px;
    padding: 0 12px 0 34px;
    border: 1px solid #475569;
    background: #0f172a;
    color: #f1f5f9;
    border-radius: 50px;
    font-size: 13px;
    outline: none;
    box-sizing: border-box;
    transition: 0.2s;
    line-height: 36px;
}

.search-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* ==========================================================================
   05. FORM INPUT SYSTEM & DYNAMIC STRUCTURAL EXTRACTIONS
   ========================================================================== */
.input-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 15px;
}

.field {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-width: 0;
}

.field.grid-span-2 {
    grid-column: span 2;
}

.field.full-width {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    width: 100%;
    box-sizing: border-box;
}

.field-label-spacing {
    margin-bottom: 6px;
}

label {
    font-size: 10px;
    font-weight: 700;
    color: #64748b;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input {
    height: 36px;
    padding: 0 12px;
    border: 1px solid #475569;
    background: #0f172a;
    color: #f1f5f9;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    box-sizing: border-box;
    line-height: 34px;
}

input:focus {
    border-color: #3b82f6;
}

/* Standalone row housing segmented internal layout choice variants */
.button-system-row {
    display: flex;
    gap: 4px;
    align-items: center;
    width: 100%;
    background: #0f172a; 
    border: 1px solid #475569; 
    border-radius: 6px;
    height: 38px; 
    box-sizing: border-box;
    padding: 0 6px; 
}

/* Standardized button bases */
.btn-wine-type,
.btn-sparkling-choice {
    background: #1e293b; 
    border: none;
    border-radius: 4px;
    color: #94a3b8;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    white-space: nowrap;
    box-sizing: border-box;
    flex: 1;
    height: 24px;
}

.btn-wine-type:hover,
.btn-sparkling-choice:hover {
    background: #334155;
    color: #f1f5f9;
}

/* Uniform Fallback Active State */
.btn-wine-type.active,
.btn-sparkling-choice.active {
    background: #475569;
    color: #ffffff;
}

/* Custom Theming Variant Color Overrides (Wine Types) */
.btn-wine-type.active[onclick*="White"] {
    background: var(--beer) !important;
    color: #0f172a !important;
    font-weight: 700;
}

.btn-wine-type.active[onclick*="Red"] {
    background: var(--wine) !important;
    color: #ffffff !important;
}

.btn-wine-type.active[onclick*="Rosé"] {
    background: #7682c4 !important;
    color: #ffffff !important;
}

.btn-wine-type.active[onclick*="Orange"] {
    background: #9e6142 !important;
    color: #ffffff !important;
}

/* Distinct Variant Colors Rules for Sparkling Varieties */
.btn-sparkling-choice.active[onclick*="Yes"] {
    background: var(--cider);
    color: #ffffff !important;

}
.btn-sparkling-choice.active[onclick*="Pet-Nat"] {
    background: var(--soft);
    color: #ffffff !important;
}
.btn-sparkling-choice.active[onclick*="No"] {
    background: var(--wine)!important;
    color: #ffffff !important;
}

/* Dynamic Textareas */
.dyn-textarea {
    background: #0f172a;
    color: #f8fafc;
    border: 1px solid #475569;
    border-radius: 6px;
    padding: 8px 12px;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.5;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-height: 52px;
    resize: vertical;
    overflow: auto;
}

/* ==========================================================================
   06. CORE DATA TABLES & NESTED PREVIEW CARDS
   ========================================================================== */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 10px;
}

th {
    padding: 12px;
    text-align: left;
    font-size: 11px;
    color: #94a3b8;
    text-transform: uppercase;
    border-bottom: 2px solid #334155;
    cursor: pointer;
}

td {
    padding: 15px 12px;
    vertical-align: top;
    border-bottom: 1px solid #334155;
    background: #1e293b;
    font-size: 13px;
    color: #e2e8f0;
}

.preview-card {
    background: #0f172a;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #334155;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    font-size: 12px;
}

.preview-item {
    display: flex;
    flex-direction: column;
}

.preview-label {
    font-size: 9px;
    font-weight: 800;
    color: #64748b;
    text-transform: uppercase;
}

.preview-value {
    color: #e2e8f0;
    font-weight: 500;
}

.table-item-thumb {
    width: auto;
    height: 120px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #334155;
    margin-top: 4px;
}

.table-item-thumb-fallback {
    width: 42px;
    height: 42px;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: #cbd5e1;
    margin-top: 4px;
}

.category-badge {
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 800;
    text-transform: uppercase;
}

.category-badge-wine  { background: var(--wine);  color: #ffffff; }
.category-badge-beer  { background: var(--beer);  color: #222222; }
.category-badge-cider { background: var(--cider); color: #ffffff; }
.category-badge-soft  { background: var(--soft);  color: #ffffff; }

.desktop-producer-text { font-size: 15px; }
.desktop-sub-text      { color: #64748b; }
.desktop-meta-text     { color: #94a3b8; }

.variant-lines-list { display: flex; flex-direction: column; gap: 4px; }
.variant-line { font-size: 13px; line-height: 1.3; }
.variant-row { display: flex; gap: 8px; align-items: center; }
.variant-row input { padding: 8px 10px; border: 1px solid #e2e8f0; border-radius: 6px; font-size: 14px; flex: 1; min-width: 0; }
.variant-remove-btn { flex: 0 0 auto; }
.price-text-bold       { font-size: 15px; color: var(--primary); }

.desktop-card-layout-wrapper {
    display: flex; 
    gap: 10px; 
    align-items: flex-start;
}

.status-badge-container {
    font-size: 11px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}

.status-in-stock-text  { color: #16a34a; }
.status-to-order-text  { color: #d97706; }

.status-badge-dot {
    font-size: 9px;
}

/* Select & Isolate toggle: desktop table column checkbox */
.cell-select {
    width: 44px;
    text-align: center;
    vertical-align: top;
    padding-top: 18px;
}

.workingset-checkbox {
    width: 20px;
    height: 20px;
    accent-color: var(--warning);
    cursor: pointer;
    margin: 0;
}

.col-select { width: 44px; text-align: center; }

/* Select toggle: inline checkbox shown in the mobile collapsed row header,
   given its own slot before the thumbnail rather than crowding into
   .m-price-side alongside publish/export, which is already tight. */
.m-select-toggle {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
}

.m-select-toggle .workingset-checkbox {
    width: 22px;
    height: 22px;
}

/* Publish toggle: desktop table column checkbox */
.cell-publish {
    width: 44px;
    text-align: center;
    vertical-align: top;
    padding-top: 18px;
}

.publish-checkbox {
    width: 20px;
    height: 20px;
    accent-color: var(--success);
    cursor: pointer;
    margin: 0;
}

/* Publish toggle: inline checkbox shown in the mobile collapsed row header */
.m-publish-toggle {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.m-publish-toggle .publish-checkbox {
    width: 22px;
    height: 22px;
}

/* ==========================================================================
   07. ACTIONS SYSTEMS & BUTTON MATRIX
   ========================================================================== */
.btn-main {
    height: 36px;
    padding: 0 24px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
    font-size: 13px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-tool {
    padding: 6px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    color: #ffffff;
    transition: 0.2s;
}

.btn-tool:hover {
    filter: brightness(1.1);
}

.actions-wrapper-layout {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.actions-wrapper-layout .btn-tool {
    width: 100%;
    box-sizing: border-box;
}

.btn-action-info    { background: var(--info); }
.btn-action-success { background: var(--success); }
.btn-action-danger  { background: var(--danger); }

/* ==========================================================================
   08. OVERLAYS, WRAPPERS & FIXED APP NODES
   ========================================================================== */
#loginOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0f172a;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

#toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #f1f5f9;
    color: #0f172a;
    padding: 10px 25px;
    border-radius: 50px;
    opacity: 0;
    transition: 0.3s;
    pointer-events: none;
    z-index: 3001;
    font-weight: 600;
}

#toast.show {
    opacity: 1;
}

/* ==========================================================================
   Image lightbox — click-to-zoom preview for product thumbnails
   ========================================================================== */
.image-lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.92);
    z-index: 4000;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
    padding: 40px;
    box-sizing: border-box;
}

.image-lightbox.show {
    display: flex;
}

.image-lightbox img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    cursor: default;
}

.lightbox-close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: transparent;
    border: none;
    color: #f1f5f9;
    font-size: 36px;
    line-height: 1;
    cursor: pointer;
    padding: 8px;
}

.lightbox-close:hover {
    color: #ffffff;
}

.table-item-thumb {
    cursor: zoom-in;
}

.m-thumb .table-item-thumb {
    cursor: zoom-in;
}

.image-upload-wrap {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.upload-trigger-btn {
    background: var(--info);
    color: #ffffff;
    padding: 0 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 36px;
    box-sizing: border-box;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
}

.mobile-summary-head {
    display: none;
}

/* ==========================================================================
   09. LOGIN OVERLAY CONTENT
   ========================================================================== */
.login-box {
    background: #1e293b;
    padding: 30px;
    border-radius: 12px;
    width: 300px;
    text-align: center;
}

.login-input {
    width: 100%;
    margin-bottom: 15px;
    box-sizing: border-box;
}

.btn-unlock {
    background: #64748b;
    color: #ffffff;
    width: 100%;
}

.login-switch {
    margin: 14px 0 0;
    font-size: 12.5px;
    color: #94a3b8;
}

.login-switch a {
    color: #60a5fa;
    text-decoration: none;
    font-weight: 600;
}

.login-switch a:hover {
    text-decoration: underline;
}

/* ==========================================================================
   10. APP HEADER
   ========================================================================== */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.app-title {
    margin: 0;
    color: var(--primary);
}

#status {
    font-size: 12px;
    margin-left: 10px;
}

.status-icon-ok   { color: var(--success); }
.status-icon-fail { color: var(--danger); }

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.role-badge {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--warning);
    border: 1px solid var(--warning);
    border-radius: 20px;
    padding: 4px 10px;
    white-space: nowrap;
    /* Grid items get "blockified" and stretched to the row height by
       default (this sits in a grid cell on mobile, next to a button that
       can be taller) — center the text within whatever height that ends
       up being, rather than leaving it pinned to the top of a tall box. */
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.role-badge:empty {
    display: none;
}

/* Elements marked admin-only get hidden for a staff session via a class
   on <body> (see applyRolePermissions() in inventory-auth.js) rather than
   inline styles, so this also catches table rows/cells that get rebuilt
   after every search, sort, add, or edit — not just what existed in the
   DOM at login time. */
body.role-staff .admin-only {
    display: none !important;
}

/* ==========================================================================
   11. BUTTON COLOR VARIANTS & SIZE MODIFIERS
   Reusable on top of .btn-main / .btn-tool so a button's color can be
   changed in one place instead of hunting through the markup.
   ========================================================================== */
.btn-color-purple  { background: var(--purple);  color: #ffffff; }
.btn-color-slate   { background: #34495e;        color: #ffffff; }
.btn-color-success { background: var(--success); color: #ffffff; }
.btn-color-warning { background: var(--warning); color: #ffffff; }
.btn-color-wine    { background: var(--wine);    color: #ffffff; }
.btn-color-gray    { background: var(--gray);    color: #ffffff; }
.btn-color-info    { background: var(--info);    color: #ffffff; }
.btn-color-danger  { background: var(--danger);  color: #ffffff; }

.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
}

.btn-hidden {
    display: none;
}

/* ==========================================================================
   12. INVENTORY FORM LAYOUT
   ========================================================================== */
.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.field-variants {
    margin-top: 10px;
}

.variants-container {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fields-divider-top {
    border-top: 0px solid #f1f5f9;
    padding-top: 15px;
}

.form-actions {
    margin-top: 15px;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.file-input-hidden {
    display: none;
}

#imagePreviewContainer {
    display: none;
    align-items: center;
    gap: 6px;
}

#imagePreview {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

.btn-image-remove {
    background: var(--danger);
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: bold;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
}

/* ==========================================================================
   13. TABLE HEADER COLUMN WIDTHS
   ========================================================================== */
.col-publish { width: 44px; text-align: center; }
.col-date    { width: 100px; }
.col-product { width: 180px; }
.col-price   { width: 120px; }
.col-actions { width: 100px; }

/* ==========================================================================
   14. PRODUCERS EDITOR VIEW
   ========================================================================== */
#publisherView {
    display: none;
}

#calcView {
    display: none;
}

#rawModePane {
    display: none;
}

.m-0 {
    margin: 0;
}

.mb-15 {
    margin-bottom: 15px;
}

.mt-10 {
    margin-top: 10px;
}

.mt-15 {
    margin-top: 15px;
}

.help-text {
    font-size: 12px;
    color: #64748b;
    margin: -2px 0 15px 0;
}

.help-text-tight {
    font-size: 12px;
    color: #64748b;
    margin: -2px 0 10px 0;
}

/* ==========================================================================
   15. MOBILE-ONLY RESPONSIVE OVERRIDES (PERFECT DESKTOP ISOLATION)
   ========================================================================== */
@media screen and (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .app-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .app-header h2 {
        text-align: center;
    }
    
    .header-actions {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        width: 100%;
    }
    
    .header-actions .btn-main:not(.btn-hidden) {
        width: 100%;
        padding: 12px 4px;
        font-size: 11px;
        display: flex;
        justify-content: center;
        align-items: center;
        margin: 0;
        height: 44px;
    }
    
    /* Explicit rather than relying on the grid row to stretch this to
       match its sibling button — matches .btn-main's mobile height above
       directly instead. */
    .header-actions .role-badge {
        height: 44px;
        width: 100%;
        box-sizing: border-box;
    }
    
    .category-selection {
        display: flex;
        flex-direction: column;
        flex-wrap: nowrap;
        overflow-x: visible;
        gap: 8px;
        width: 100%;
        padding-bottom: 0;
    }
    
    .category-selection .btn-cat {
        width: 100%;
        justify-content: center;
        height: 44px;
        box-sizing: border-box;
    }
    
    .filter-bar {
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }
    
    .btn-filter {
        width: 100%;
        justify-content: center;
        height: 44px;
        box-sizing: border-box;
    }
    
    .search-container {
        width: 100%;
        margin-top: 4px;
    }
    
    .search-input {
        height: 44px;
        font-size: 14px;
        line-height: 44px;
    }
    
    .input-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .input-grid input {
        height: 44px;
        font-size: 16px;
        line-height: 42px;
    }
    
    /* The base rule (line ~181) makes this span 2 of the desktop grid's
       auto-fit columns. On mobile the grid only defines ONE explicit
       column (immediately above), so that span request was forcing the
       browser to fabricate an implicit second column sized by content —
       and grid auto-placement was then also sliding OTHER single-column
       fields (Alcohol, Vintage, Sugar, Soil...) into that same phantom
       column, silently reverting the whole mobile layout back into an
       unintended, content-sized 2-column grid. That's what was causing
       the inconsistent button sizes and off-screen text throughout the
       add/edit item form on mobile. */
    .field.grid-span-2 {
        grid-column: auto;
    }
    
    /* Responsive adjustment for clean mobile scaling layout vectors */
    .button-system-row {
        height: 44px;
    }
    
    .btn-wine-type,
    .btn-sparkling-choice {
        height: 32px;
        font-size: 12px;
        min-width: 0;
    }
    
    .form-actions {
        display: flex;
        gap: 12px;
        align-items: center;
        flex-wrap: wrap;
        width: 100%;
    }
    
    #addBtn,
    #updateBtn,
    #cancelBtn {
        width: 100%;
        height: 46px;
        font-size: 14px;
    }
    
    /* Excludes .stock-toggle-group: this generic "any direct div child of
       .form-actions" selector (really meant for .image-upload-wrap) was
       ALSO matching the stock toggle's wrapper div, and — because of the
       extra div/button type selectors — winning over the more specific
       .stock-toggle-group/.btn-stock-toggle rules further down despite
       coming first in the file. That silently forced flex-direction back
       to column and collapsed both buttons to their minimum content
       height (~18px) instead of the intended full-height row, which is
       what made "In stock"/"To order" render thin and stacked. */
    .form-actions>div:not(.stock-toggle-group) {
        flex-direction: column;
        height: auto;
        width: 100%;
        gap: 12px;
        align-items: stretch;
    }
    
    .form-actions>div:not(.stock-toggle-group)>button {
        width: 100%;
        height: 44px;
        justify-content: center;
    }
    
    #imagePreviewContainer {
        width: 100%;
        justify-content: center;
    }
    
    .stock-toggle-group {
        width: 100%;
        display: flex;
        flex-direction: row;
        gap: 8px;
        height: 52px;
    }
    
    .btn-stock-toggle {
        flex: 1;
        height: 52px;
        justify-content: center;
        font-size: 14px;
    }
    
    table.card {
        display: block;
        background: transparent;
        box-shadow: none;
        border: none;
        padding: 0;
        width: 100%;
    }
    
    table.card thead {
        display: none; 
    }
    
    table.card tbody {
        display: flex;
        flex-direction: column;
        gap: 16px;
        width: 100%;
    }
    
    table.card tr.collapsible-row {
        display: flex;
        flex-direction: column;
        background: #1e293b;
        border-radius: 12px;
        overflow: hidden; 
        padding: 12px;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
        border: 1px solid #334155;
        box-sizing: border-box;
        width: 100%;
    }
    
    table.card td {
        display: block;
        padding: 0;
        border: none;
        white-space: normal;
        width: 100%;
        box-sizing: border-box;
        background: transparent;
    }
    
    .desktop-visible-content,
    table.card td.cell-date,
    table.card td.mobile-hideable {
        display: none;
    }
    
    .mobile-summary-head {
        display: flex;
        justify-content: space-between;
        align-items: center;
        cursor: pointer;
        padding: 4px 2px;
        gap: 10px;
    }
    
    .m-thumb {
        flex-shrink: 0;
        width: 40px;
        height: 40px;
    }
    
    .m-thumb .table-item-thumb {
        width: 40px;
        height: 40px;
        margin-top: 0;
    }
    
    .m-thumb .table-item-thumb-fallback {
        width: 40px;
        height: 40px;
        margin-top: 0;
    }
    
    .m-info {
        display: flex;
        flex-direction: column;
        gap: 2px;
        text-align: left;
        flex: 1;
        min-width: 0;
    }
    
    .m-title {
        font-size: 14px;
        color: #f1f5f9;
        line-height: 1.3;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .m-sub {
        font-size: 13px;
        color: #94a3b8;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .m-meta {
        font-size: 11px;
        color: #64748b;
        margin-top: 2px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .m-price-side {
        display: flex;
        align-items: center;
        gap: 12px;
        flex-shrink: 0;
    }
    
    .m-total-val {
        font-size: 14px;
        font-weight: 700;
        color: #3b82f6;
        white-space: nowrap;
    }
    
    .mobile-toggle-icon {
        transition: transform 0.2s ease;
        color: #64748b;
    }
    
    table.card tr.collapsible-row.expanded td.mobile-hideable {
        display: block;
    }
    
    table.card tr.collapsible-row.expanded td.cell-publish {
        margin-top: 12px;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    table.card tr.collapsible-row.expanded td.cell-publish::before {
        content: "PUBLISH TO SITE:";
        font-weight: 800;
        color: #64748b;
        font-size: 9px;
    }

    table.card tr.collapsible-row.expanded td.cell-select {
        margin-top: 12px;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    table.card tr.collapsible-row.expanded td.cell-select::before {
        content: "SELECTED FOR WORKING SET:";
        font-weight: 800;
        color: #64748b;
        font-size: 9px;
    }

    table.card tr.collapsible-row.expanded td.cell-preview {
        margin-top: 12px;
        border-top: 1px dashed #334155;
        padding-top: 12px;
    }
    
    table.card tr.collapsible-row.expanded td.cell-price {
        margin-top: 12px;
        background: #0f172a;
        padding: 10px 12px;
        border-radius: 8px;
    }
    
    table.card tr.collapsible-row.expanded td.cell-price::before {
        content: "PRICE TOTAL:";
        font-weight: 800;
        color: #64748b;
        font-size: 9px;
        display: block;
        margin-bottom: 4px;
    }
    
    table.card tr.collapsible-row.expanded td.cell-actions {
        margin-top: 14px;
        border-top: 1px solid #334155;
        padding-top: 12px;
    }
    
    table.card tr.collapsible-row.expanded .actions-wrapper-layout {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        width: 100%;
    }
    
    table.card tr.collapsible-row.expanded .actions-wrapper-layout button:nth-of-type(3) {
        grid-column: span 2;
    }
    
    table.card tr.collapsible-row.expanded .actions-wrapper-layout button {
        height: 42px;
        font-size: 13px;
        font-weight: 700;
        border-radius: 6px;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    
    tr.collapsible-row.expanded .mobile-toggle-icon {
        transform: rotate(180deg);
    }
    
    #loginOverlay div {
        width: 88%;
        padding: 24px 16px;
    }
    
    #loginOverlay input {
        height: 44px;
        font-size: 16px;
    }
}
/* ODS selection controls and column */
.ods-selection-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.workingset-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ods-selection-label {
    font-size: 12px;
    font-weight: 700;
    color: #94a3b8;
    margin-right: 2px;
    white-space: nowrap;
}

.ods-selection-count {
    font-size: 12px;
    font-weight: 700;
    color: #4ade80;
    white-space: nowrap;
}

.ods-selection-controls .btn-sm,
.workingset-controls .btn-sm {
    height: 32px;
    padding: 0 12px;
}

.btn-main.isolate-active {
    background: var(--success);
    box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.4);
}


.isolate-empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #94a3b8;
    font-size: 13px;
    line-height: 1.6;
}

.cell-ods {
    width: 44px;
    text-align: center;
    vertical-align: top;
    padding-top: 18px;
}

.ods-checkbox {
    width: 20px;
    height: 20px;
    accent-color: var(--info);
    cursor: pointer;
    margin: 0;
}

.col-ods {
    width: 44px;
    text-align: center;
}

.m-ods-toggle {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.m-ods-toggle .ods-checkbox {
    width: 22px;
    height: 22px;
}

@media (max-width: 900px) {
    .ods-selection-controls,
    .workingset-controls {
        width: 100%;
        margin-left: 0;
        justify-content: flex-start;
        flex-wrap: wrap;
        row-gap: 8px;
    }

    #workingSetIsolateBtn {
        width: 100%;
        justify-content: center;
    }

    table.card tr.collapsible-row.expanded td.cell-ods {
        margin-top: 8px;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    table.card tr.collapsible-row.expanded td.cell-ods::before {
        content: "INCLUDE IN EXPORT:";
        font-weight: 800;
        color: #64748b;
        font-size: 9px;
    }
}

/* ==========================================================================
   17. CALC TAB — LANDED PRICE CALCULATOR (admin-only)
   ========================================================================== */
.checkline {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.checkline input {
    width: 16px;
    height: 16px;
}

.checkline label {
    font-size: 12.5px;
    color: #cbd5e1;
    margin: 0;
    text-transform: none;
    letter-spacing: normal;
    font-weight: 500;
}

.calc-settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

.calc-settings-card {
    background: #0f172a;
    border: 1px solid #334155;
    border-top: 3px solid #3b82f6;
    border-radius: 8px;
    padding: 14px 14px 16px;
}

.calc-settings-card-title {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #94a3b8;
    margin-bottom: 12px;
}

.calc-settings-card .field {
    margin-bottom: 10px;
}

.calc-settings-card .field:last-child {
    margin-bottom: 0;
}

.calc-settings-card .field label {
    font-size: 11px;
    margin-bottom: 4px;
}

.save-note {
    font-size: 11px;
    color: #64748b;
    font-family: monospace;
}

.calc-table-scroll {
    overflow-x: auto;
    padding: 0;
}

table.calc-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1280px;
}

table.calc-table thead th {
    background: #0f172a;
    color: #cbd5e1;
    font-weight: 700;
    font-size: 10.5px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    text-align: left;
    padding: 10px;
    white-space: nowrap;
    border-bottom: 2px solid #3b82f6;
}

table.calc-table thead th.num {
    text-align: right;
}

table.calc-table tbody td {
    padding: 7px 10px;
    border-bottom: 1px solid #334155;
    font-size: 13px;
    vertical-align: middle;
    white-space: nowrap;
    color: #e2e8f0;
}

table.calc-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

table.calc-table tbody tr:hover {
    background: rgba(59, 130, 246, 0.08);
}

table.calc-table td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

table.calc-table td input,
table.calc-table td select {
    font-size: 12.5px;
    padding: 6px 8px;
    border: 1px solid #475569;
    border-radius: 4px;
    background: #0f172a;
    color: #f1f5f9;
    width: 100%;
    box-sizing: border-box;
}

table.calc-table td input:focus,
table.calc-table td select:focus {
    outline: none;
    border-color: #3b82f6;
}

.calc-narrow {
    width: 72px;
}

.calc-name-cell {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

td.calc-landed {
    background: rgba(59, 130, 246, 0.12);
    font-weight: 700;
    color: #93c5fd;
    border-left: 2px solid #3b82f6;
    border-right: 2px solid #3b82f6;
}

td.calc-sell {
    color: #4ade80;
    font-weight: 700;
}

/* Deliberately distinct from the purchase->landed->sell calculation
   chain — a plain reference value (the item's actual current price,
   already set via the Inventory tab) rather than something computed
   here, styled with a dashed left border to visually mark that break. */
td.calc-current-price {
    color: #94a3b8;
    font-style: italic;
    border-left: 1px dashed #475569;
}

th.calc-current-price-header {
    border-left: 1px dashed #475569;
}

.calc-tax-warn {
    color: var(--danger);
    font-weight: 700;
}

/* Simple / Advanced view toggle — hides the intermediate computed columns
   (Purchase SEK through +VAT) so the table isn't overwhelming by default;
   Advanced brings back the full breakdown for when it's actually needed. */
#calcView.calc-simple-mode .calc-advanced-only {
    display: none !important;
}

.calc-header-btns {
    display: flex;
    gap: 8px;
}

.calc-section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #94a3b8;
    margin: 0 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #334155;
}

.calc-reference details {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 10px;
}

.calc-reference details:last-child {
    margin-bottom: 0;
}

.calc-reference summary {
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #e2e8f0;
    padding: 4px 0;
    list-style: none;
}

.calc-reference summary::-webkit-details-marker {
    display: none;
}

.calc-reference summary::before {
    content: "▸";
    display: inline-block;
    width: 16px;
    color: #3b82f6;
}

.calc-reference details[open] summary::before {
    content: "▾";
}

table.calc-ref-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 12.5px;
}

table.calc-ref-table th {
    text-align: left;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    padding: 6px 8px;
    border-bottom: 1px solid #334155;
}

table.calc-ref-table td {
    padding: 6px 8px;
    border-bottom: 1px solid #1e293b;
    color: #cbd5e1;
    vertical-align: top;
}

table.calc-ref-table td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

td.calc-ref-cat {
    font-weight: 700;
    color: #93c5fd;
    white-space: nowrap;
}

@media screen and (max-width: 768px) {
    .calc-settings-grid {
        grid-template-columns: 1fr;
    }
}

/* Just the Assumptions & exchange rates settings collapse — the same
   small-row pattern as the Reference boxes below, not the whole
   calculator. Closed by default: these are set-once values you rarely
   touch day to day, unlike the product table itself, which stays visible
   as always. */
.calc-collapsible-group details {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 10px 14px;
}

.calc-collapsible-group summary {
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #e2e8f0;
    padding: 4px 0;
    list-style: none;
}

.calc-collapsible-group summary::-webkit-details-marker {
    display: none;
}

.calc-collapsible-group summary::before {
    content: "▸";
    display: inline-block;
    width: 16px;
    color: #3b82f6;
}

.calc-collapsible-group details[open] summary::before {
    content: "▾";
}

/* Exchange rate auto-sync status, shown right under the two rate fields */
.calc-sync-status {
    font-size: 11px;
    color: #64748b;
    margin: 8px 0 6px;
}

.calc-sync-status.calc-sync-error {
    color: var(--danger);
}

.calc-sync-btn {
    width: 100%;
    justify-content: center;
}

/* Select & Isolate bar — .workingset-controls already provides the flex
   layout (shared with the Inventory tab's own copy); this just adds the
   bordered/background "bar" treatment to match the rest of the Calc tab's
   visual language. */
.calc-workingset-bar {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 14px;
    flex-wrap: wrap;
    box-sizing: border-box;
}

.calc-select-check,
.calc-select-check-header {
    width: 44px;
    text-align: center;
}

.calc-select-check input {
    width: 18px;
    height: 18px;
    accent-color: #4ade80;
    cursor: pointer;
}

/* .table-actions had no margin at all, so it sat flush against Reference
   right below it — every other block on this tab gets its spacing from
   the .card class's margin-bottom, but this div isn't a .card. */
.table-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

/* Purchase Calc order summary — a running total that reflects EVERY item
   in the catalog with a quantity set, not just what's currently filtered
   or selected, so it always shows the real order total at a glance. */
.purchase-summary-bar {
    box-sizing: border-box;
}

.purchase-summary-main {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 28px;
}

.purchase-export-btn {
    margin-left: auto;
}

.purchase-summary-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.purchase-summary-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #94a3b8;
}

.purchase-summary-value {
    font-size: 20px;
    font-weight: 700;
    color: #e2e8f0;
}

.purchase-summary-value.purchase-summary-highlight {
    color: #4ade80;
}

.purchase-summary-breakdown {
    margin: 12px 0 0;
    font-size: 12px;
    color: #64748b;
}

#purchaseCalcSaveNote {
    display: block;
    margin-top: 6px;
}
