*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #1a1a1a;
    background: #f5f5f5;
    min-height: 100vh;
}

a { color: #1a1a1a; text-decoration: none; font-weight: 600; }
a:hover { text-decoration: none; }

.layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 220px;
    background: #1c1c1c;
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
}

.sidebar-top {
    padding: 1.25rem 0;
}

.nav-brand {
    font-weight: 700;
    font-size: 1.1rem;
    padding: 0 1.25rem 1rem;
    border-bottom: 1px solid #2e2e2e;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.brand-icon {
    width: 22px;
    height: 22px;
}

.nav-links {
    display: flex;
    flex-direction: column;
}

.nav-create-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: #fff !important;
    background: #e93124;
    border-radius: 6px;
    margin: 0.5rem 1rem 0.25rem;
    padding: 0.4rem 0.75rem !important;
    font-size: 0.82rem !important;
    font-weight: 600;
    cursor: pointer;
    justify-content: center;
}
.nav-create-btn:hover { background: #c7271c !important; }
.nav-create-menu {
    display: none;
    position: absolute; left: 0.75rem; right: 0.75rem; top: 100%;
    background: #fff; border: 1px solid #ddd; border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15); z-index: 100;
    padding: 0.35rem 0;
}
.nav-create-menu.open { display: block; }
.nav-create-menu a {
    display: block; padding: 0.45rem 1rem; font-size: 0.82rem;
    color: #333 !important; text-decoration: none !important;
}
.nav-create-menu a:hover { background: #f5f5f5 !important; color: #e93124 !important; }

.nav-section-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #777;
    padding: 1rem 1.25rem 0.35rem;
}

.nav-section-label:first-child {
    padding-top: 0.25rem;
}

.nav-links a,
.nav-settings {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: #ccc;
    text-decoration: none !important;
    font-weight: normal;
    font-size: 0.9rem;
    padding: 0.5rem 1.25rem;
    transition: background 0.15s, color 0.15s;
}

.nav-links a:hover,
.nav-settings:hover {
    color: #fff;
    background: #2e2e2e;
}

.nav-links svg,
.nav-settings svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.7;
}

/* Sidebar bottom */
.sidebar-bottom {
    padding: 1rem 0;
    border-top: 1px solid #2e2e2e;
}


.nav-user {
    padding: 0.75rem 1.25rem 0;
    margin-top: 0.5rem;
    border-top: 1px solid #2e2e2e;
}

.nav-user-name {
    display: block;
    font-size: 0.85rem;
    color: #aaa;
    margin-bottom: 0.15rem;
}
.nav-user-company {
    display: block;
    font-size: 0.75rem;
    color: #777;
    margin-bottom: 0.25rem;
}

.nav-user a {
    color: #777;
    text-decoration: none;
    font-size: 0.8rem;
}

.nav-user a:hover {
    color: #fff;
}

/* Main content */
main {
    flex: 1;
    margin-left: 220px;
    padding: 2rem 2.5rem;
    min-width: 0;
    overflow-x: hidden;
}

/* Page header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 0;
}

.page-header h1 {
    font-size: 1.4rem;
    font-weight: 700;
}

.page-header-subtitle {
    width: 100%;
    font-size: 0.8rem;
    color: #888;
    margin-top: 0.1rem;
}

/* Help icon in page header */
.page-help-link {
    display: inline-flex;
    align-items: center;
    margin-left: 0.25rem;
    margin-right: auto;
    color: #bbb;
    text-decoration: none;
    transition: color 0.15s;
}
.page-help-link:hover { color: var(--color-primary, #e93124); }
.page-help-link svg { width: 18px; height: 18px; }

/* Help article content (rendered Markdown) */
.help-article-content {
    max-width: 720px;
    line-height: 1.7;
    font-size: 0.95rem;
    color: #333;
}
.help-article-content h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 1.75rem 0 0.75rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid #eee;
}
.help-article-content h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 1.25rem 0 0.5rem;
}
.help-article-content p { margin-bottom: 0.75rem; }
.help-article-content ul, .help-article-content ol {
    margin: 0.5rem 0 1rem 1.5rem;
}
.help-article-content li { margin-bottom: 0.3rem; }
.help-article-content code {
    background: #f5f5f5;
    padding: 0.15rem 0.35rem;
    border-radius: 3px;
    font-size: 0.85em;
}
.help-article-content pre {
    background: #f5f5f5;
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
    margin-bottom: 1rem;
}
.help-article-content pre code { background: none; padding: 0; }
.help-article-content table {
    border-collapse: collapse;
    width: 100%;
    margin-bottom: 1rem;
}
.help-article-content th, .help-article-content td {
    padding: 0.5rem 0.75rem;
    border: 1px solid #ddd;
    text-align: left;
    font-size: 0.85rem;
}
.help-article-content th { background: #fafafa; font-weight: 600; }
.help-article-content img {
    max-width: 100%;
    border-radius: 6px;
    margin: 0.5rem 0;
}

/* Help landing page filter */
.help-search-wrap { margin-bottom: 1.25rem; }
.help-filter-input {
    width: 100%;
    max-width: 400px;
    padding: 0.5rem 0.75rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.88rem;
    outline: none;
}
.help-filter-input:focus {
    border-color: var(--color-primary, #e93124);
    box-shadow: 0 0 0 2px rgba(233, 49, 36, 0.1);
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

/* Tabs */
.tab-bar {
    display: flex;
    gap: 0.25rem;
    border-bottom: 2px solid #ddd;
    margin-bottom: 1.5rem;
}

.tab {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: #666;
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}

.tab:hover {
    color: var(--color-primary, #e93124);
}

.tab.active {
    color: var(--color-primary, #e93124);
    font-weight: 600;
    border-bottom-color: var(--color-primary, #e93124);
}

.tab-bar-search {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.6rem;
    border: 1px solid #ccc;
    border-radius: 5px;
    background: #fff;
    margin-bottom: 4px;
    position: relative;
}

.tab-bar-search svg {
    width: 15px;
    height: 15px;
    color: #999;
    flex-shrink: 0;
}

.tab-bar-search-input {
    border: none;
    outline: none;
    font-size: 0.83rem;
    color: #1a1a1a;
    width: 180px;
    flex: 1;
    min-width: 0;
    background: transparent;
}

.tab-bar-search-input::placeholder {
    color: #aaa;
}
.search-clear {
    color: #999; text-decoration: none; font-size: 1.1rem; line-height: 1;
    padding: 0 0.25rem; margin-left: -0.25rem;
}
.search-clear:hover { color: #333; }

/* Data table */
.table-wrap {
    overflow-x: auto;
    padding-bottom: 4rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    table-layout: auto;
}

.data-table th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    font-weight: 600;
    font-size: 0.8rem;
    color: #666;
    border-bottom: 1px solid #ddd;
    white-space: nowrap;
}

.data-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid #eee;
    white-space: nowrap;
}

.data-table td.cell-subject {
    white-space: normal;
    min-width: 200px;
    max-width: 400px;
    word-break: break-word;
}

.data-table tbody tr:hover {
    background: #f5f5f5;
}

.data-table .text-right {
    text-align: right;
}

/* Sortable columns */
.data-table th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 1.4rem;
}

.data-table th.sortable:hover {
    color: #333;
}

.data-table th.sortable .sort-arrow {
    position: absolute;
    right: 0.3rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.65rem;
    color: #bbb;
    line-height: 1;
}

.data-table th.sortable.sort-asc .sort-arrow,
.data-table th.sortable.sort-desc .sort-arrow {
    color: #333;
}

.data-table td a,
.data-table .cell-order-num a,
.data-table .po-col-so a {
    color: #1a1a1a;
    font-weight: 600;
    text-decoration: none;
}

.data-table td a:hover,
.data-table .cell-order-num a:hover,
.data-table .po-col-so a:hover {
    text-decoration: underline;
}

.row-print-btn {
    display: inline-flex;
    align-items: center;
    margin-left: 0.25rem;
    vertical-align: middle;
    color: #999;
    opacity: 0;
    transition: opacity 0.15s;
}
.row-print-btn:hover { color: #1a1a1a; }
tr:hover .row-print-btn { opacity: 1; }

.note-icon-wrap {
    display: inline-flex;
    align-items: center;
    margin-left: 0.35rem;
    vertical-align: middle;
    cursor: default;
}
.note-icon {
    width: 14px;
    height: 14px;
    stroke: #888;
    flex-shrink: 0;
}
.note-icon-wrap:hover .note-icon {
    stroke: #333;
}
.note-tooltip {
    display: none;
    position: fixed;
    background: #1a1a1a;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 400;
    line-height: 1.4;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    white-space: pre-wrap;
    max-width: 280px;
    min-width: 120px;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    pointer-events: none;
}

.empty-state {
    text-align: center;
    padding: 2rem 0.75rem !important;
    color: #999;
}

/* Accounts table — truncation */
.acct-col-name,
.acct-col-contact,
.acct-col-email,
.acct-col-address {
    max-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.acct-col-name    { width: 30%; }
.acct-col-contact { width: 18%; }
.acct-col-email   { width: 22%; }
.acct-col-address { width: 22%; }

@media (max-width: 900px) {
    .acct-col-contact { display: none; }
    .po-col-so, .po-col-items, .po-col-creator { display: none; }
    .so-col-custpo, .so-col-items, .so-col-rep { display: none; }
    .est-col-items, .est-col-rep { display: none; }
    .inv-col-cat, .inv-col-loc { display: none; }
    .inv-col-name { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
    .recv-col-so, .recv-col-track, .recv-col-items { display: none; }
    .ship-col-city, .ship-col-zip, .ship-col-custpo { display: none; }
    .rinv-col-min, .rinv-col-cost, .rinv-col-age { display: none; }
    .rmsl-col-po, .rmsl-col-so { display: none; }
    .rpd-col-cost, .rpd-col-purpose { display: none; }
    .raud-col-ip { display: none; }
    .iv-col-lead { display: none; }
    .ii-col-notes { display: none; }
}

@media (max-width: 700px) {
    .acct-col-email { display: none; }
}

/* SO / Estimates / Shipping — constrain customer name column */
.so-col-customer,
.est-col-customer,
.ship-col-customer {
    max-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 20%;
}

/* Assembly image thumbnail */
.thumb {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    background: #f5f5f5;
    border: 1px solid #eee;
}

/* Assembly cards */
.asm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 0.75rem;
}
.asm-card {
    display: flex;
    gap: 0.85rem;
    padding: 0.85rem;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.asm-card-img {
    flex: 0 0 96px;
    width: 96px;
    height: 96px;
    border-radius: 4px;
    object-fit: cover;
    background: #fafafa;
    border: 1px solid #eee;
}
.asm-card-img-placeholder {
    flex: 0 0 96px;
    width: 96px;
    height: 96px;
    border-radius: 4px;
    background: #f5f5f5;
    border: 1px dashed #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #bbb;
}
.asm-card-img-placeholder svg { width: 36px; height: 36px; }
.asm-card-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.asm-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem; }
.asm-card-title { font-size: 0.95rem; font-weight: 600; color: #222; line-height: 1.2; }
.asm-card-subtitle { font-size: 0.78rem; color: #777; margin-top: 0.1rem; }
.asm-card-meta { font-size: 0.78rem; color: #555; display: flex; flex-wrap: wrap; gap: 0.4rem 0.8rem; }
.asm-card-meta strong { color: #333; font-weight: 600; }
.asm-card-notes { font-size: 0.78rem; color: #666; white-space: pre-wrap; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.asm-card-actions { display: flex; gap: 0.35rem; flex-shrink: 0; }
.asm-empty { padding: 2rem; text-align: center; color: #888; font-size: 0.9rem; border: 1px dashed #ddd; border-radius: 6px; }

/* Generic centered-overlay modal (shared across pages). */
.merge-modal-bg {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: 2000;
    display: flex; align-items: center; justify-content: center;
}
.merge-modal {
    background: #fff;
    border-radius: 8px;
    padding: 1.5rem;
    width: 480px; max-width: 90vw; max-height: 85vh;
    overflow: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

/* Assembly status chips */
.badge-asm-ordered    { background: #fff4cc; color: #8a6500; }
.badge-asm-shipped    { background: #e6f4ea; color: #1a7f37; }
.badge-asm-fast_track { background: #fce8e8; color: #c00; }

/* Status badges */
.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

/* Shipping status */
.badge-fulfilled            { background: #e6f4ea; color: #1a7f37; }
.badge-not-shipped,
.badge-unfulfilled          { background: #fce8e8; color: #c00; }
.badge-partially-fulfilled,
.badge-backlog              { background: #fff3e0; color: #b45309; }

/* Order status */
.badge-so-active            { background: #e6f4ea; color: #1a7f37; }
.badge-so-draft             { background: #eee; color: #666; }
.badge-so-voided            { background: #fce8e8; color: #c00; }
.badge-so-returned          { background: #ede9fe; color: #6d28d9; }
.badge-so-partially_returned { background: #fef3c7; color: #92400e; }

/* Estimate status */
.badge-est-draft             { background: #eee; color: #666; }
.badge-est-active            { background: #e0ecff; color: #1a56db; }
.badge-est-voided            { background: #fce8e8; color: #c00; }
.badge-est-converted         { background: #e6f4ea; color: #1a7f37; }
.badge-est-deleted           { background: #eee; color: #999; }
.badge-est-lost              { background: #fce8e8; color: #c00; }

/* Spam score badge */
.spam-score-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 1.5rem; padding: 0.1rem 0.4rem; border-radius: 10px;
    font-size: 0.7rem; font-weight: 700; flex-shrink: 0;
}
.spam-low    { background: #e6f4ea; color: #1a7f37; }
.spam-medium { background: #fff3e0; color: #b45309; }
.spam-high   { background: #fce8e8; color: #c00; }

.est-converted-banner {
    background: #e0ecff;
    color: #1a56db;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-weight: 500;
}
.est-converted-banner a {
    color: #1a56db;
    text-decoration: underline;
    font-weight: 600;
}

/* Invoice status */
.badge-inv-invoiced         { background: #e6f4ea; color: #1a7f37; }
.badge-inv-not-invoiced     { background: #fff3e0; color: #b45309; }

/* PO order status */
.badge-po-active            { background: #e6f4ea; color: #1a7f37; }
.badge-po-draft             { background: #eee; color: #666; }
.badge-po-received          { background: #e6f4ea; color: #1a7f37; }
.badge-po-awaiting-shipment { background: #fff3e0; color: #b45309; }
.badge-po-voided            { background: #fce8e8; color: #c00; }

/* Shipping status */
.badge-shipped              { background: #e6f4ea; color: #1a7f37; }

/* Receiving status */
.badge-recv-fully-received     { background: #e6f4ea; color: #1a7f37; }
.badge-recv-not-received       { background: #fce8e8; color: #c00; }
.badge-recv-partially-received { background: #fff3e0; color: #b45309; }

/* Purpose badges */
.badge-purpose-stock          { background: #e8f0fe; color: #1a56db; }
.badge-purpose-customer-order { background: #fff3e0; color: #b45309; }
.badge-purpose-shop-job       { background: #eee; color: #666; }

/* Ticket status badges */
.badge-ticket-open                    { background: #e8f0fe; color: #1a56db; }
.badge-ticket-pending                 { background: #fff3e0; color: #b45309; }
.badge-ticket-assigned                { background: #e6f4ea; color: #1a7f37; }
.badge-ticket-waiting_on_customer     { background: #fef3c7; color: #92400e; }
.badge-ticket-waiting_on_oem          { background: #fef3c7; color: #92400e; }
.badge-ticket-waiting_on_third_party  { background: #fef3c7; color: #92400e; }
.badge-ticket-resolved                { background: #e6f4ea; color: #1a7f37; }
.badge-ticket-closed                  { background: #eee; color: #666; }

/* Ticket priority badges */
.badge-priority-urgent  { background: #fce8e8; color: #c00; }
.badge-priority-high    { background: #fff3e0; color: #b45309; }
.badge-priority-medium  { background: #e8f0fe; color: #1a56db; }
.badge-priority-low     { background: #eee; color: #666; }

/* Mobile ticket cards & tab dropdown */
.mobile-tab-dropdown { display: none !important; }
.ticket-cards-mobile { display: none; }
.ticket-tab-mobile { display: none; }

/* Avatar color palette (by first letter) */
.tc-avatar-a,.tc-avatar-m { background: #fce4b8; color: #8a6d3b; }
.tc-avatar-b,.tc-avatar-n { background: #d4e6f1; color: #2e6da4; }
.tc-avatar-c,.tc-avatar-o { background: #d5f5e3; color: #1a7f37; }
.tc-avatar-d,.tc-avatar-p { background: #f5b7b1; color: #943126; }
.tc-avatar-e,.tc-avatar-q { background: #d2b4de; color: #6c3483; }
.tc-avatar-f,.tc-avatar-r { background: #a9dfbf; color: #1e8449; }
.tc-avatar-g,.tc-avatar-s { background: #aed6f1; color: #2471a3; }
.tc-avatar-h,.tc-avatar-t { background: #f9e79f; color: #7d6608; }
.tc-avatar-i,.tc-avatar-u { background: #fadbd8; color: #a93226; }
.tc-avatar-j,.tc-avatar-v { background: #d5dbdb; color: #566573; }
.tc-avatar-k,.tc-avatar-w { background: #abebc6; color: #1e8449; }
.tc-avatar-l,.tc-avatar-x { background: #f5cba7; color: #935116; }
.tc-avatar-y { background: #d6eaf8; color: #2874a6; }
.tc-avatar-z { background: #e8daef; color: #6c3483; }

/* Bulk action toolbar (tickets, tasks, etc.) */
.bulk-toolbar {
    display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.75rem;
    background: #f0f4ff; border: 1px solid #c5d5f0; border-radius: 6px; margin-bottom: 0.5rem;
    font-size: 0.82rem;
}
.bulk-count { font-weight: 600; color: #333; margin-right: 0.5rem; }
.bulk-btn {
    display: inline-flex; align-items: center; gap: 0.3rem;
    padding: 0.3rem 0.6rem; border: 1px solid #ccc; border-radius: 4px;
    background: #fff; color: #333; font-size: 0.78rem; cursor: pointer;
    transition: background 0.1s, border-color 0.1s;
}
.bulk-btn:disabled { opacity: 0.4; cursor: default; pointer-events: none; }
.bulk-btn:hover { background: #e8eef8; border-color: #aab; }
.bulk-btn-warn { color: #b45309; }
.bulk-btn-warn:hover { background: #fef3c7; border-color: #d97706; }
.bulk-btn-danger { color: var(--danger-color, #d44c3f); }
.bulk-btn-danger:hover { background: #fee; border-color: var(--danger-color, #d44c3f); }

/* Overflow menu pattern for mobile-compact toolbars */
.bulk-toolbar { position: relative; }
.bulk-overflow { display: contents; }
.bulk-more-btn { display: none; }

@media (max-width: 768px) {
    .bulk-overflow {
        display: none;
        position: absolute;
        top: 100%;
        right: 0.5rem;
        margin-top: 0.25rem;
        background: #fff;
        border: 1px solid #c5d5f0;
        border-radius: 6px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        z-index: 100;
        padding: 0.35rem;
        flex-direction: column;
        gap: 0.25rem;
        min-width: 180px;
        align-items: stretch;
    }
    .bulk-overflow.open { display: flex; }
    .bulk-overflow > .bulk-btn,
    .bulk-overflow > label {
        justify-content: flex-start;
        width: 100%;
        font-size: 0.85rem;
        padding: 0.45rem 0.6rem;
    }
    .bulk-more-btn { display: inline-flex; }
    .bulk-toolbar { flex-wrap: nowrap; }
}

@media (max-width: 768px) {
    .ticket-cards-mobile { display: flex; flex-direction: column; gap: 0.75rem; padding: 0.5rem; }
    .tickets-page .table-wrap, .tickets-page .bulk-toolbar { display: none !important; }
    .ticket-tab-bar-desktop { display: none !important; }
    .tickets-page .filter-bar { display: none !important; }
    .ticket-tab-mobile {
        display: block;
        padding: 0.5rem;
    }
    .ticket-tab-mobile select {
        width: 100%;
        padding: 0.5rem 0.75rem;
        font-size: 0.95rem;
        border: 1px solid #ccc;
        border-radius: 6px;
        background: #fff;
        color: #333;
    }
    .ticket-card {
        display: block;
        background: #fff;
        border: 1px solid #e5e7eb;
        border-radius: 10px;
        padding: 0.85rem 1rem;
        text-decoration: none;
        color: inherit;
        box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    }
    .ticket-card:active { background: #f8f9fa; }

    /* Row 1: Avatar + Contact name */
    .tc-row-top {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        margin-bottom: 0.3rem;
    }
    .tc-avatar {
        width: 30px; height: 30px;
        border-radius: 50%;
        display: flex; align-items: center; justify-content: center;
        font-size: 0.8rem; font-weight: 700;
        flex-shrink: 0;
    }
    .tc-contact {
        font-size: 1rem;
        font-weight: 600;
        color: #333;
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }

    /* Row 2: Status badge + age */
    .tc-row-meta {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        margin-bottom: 0.35rem;
        font-size: 0.75rem;
        color: #888;
    }

    /* Row 3: Subject + #ID */
    .tc-row-subject {
        display: flex;
        align-items: baseline;
        gap: 0.4rem;
        margin-bottom: 0.2rem;
    }
    .tc-subject {
        font-size: 1.05rem;
        font-weight: 600;
        color: #222;
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
        flex: 1; min-width: 0;
    }
    .tc-id {
        font-size: 0.95rem;
        font-weight: 600;
        color: #888;
        flex-shrink: 0;
    }

    /* Row 4: Email preview */
    .tc-row-preview {
        display: flex;
        align-items: center;
        gap: 0.35rem;
        font-size: 0.8rem;
        color: #999;
        margin-bottom: 0.5rem;
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .tc-row-preview svg { flex-shrink: 0; stroke: #bbb; }

    /* Row 5: Priority / Group-Agent / Status pills */
    .tc-row-bottom {
        display: flex;
        gap: 0.5rem;
        flex-wrap: wrap;
    }
    .tc-pill {
        display: inline-flex;
        align-items: center;
        gap: 0.25rem;
        font-size: 0.75rem;
        color: #666;
        background: #f3f4f6;
        border-radius: 4px;
        padding: 0.2rem 0.5rem;
        white-space: nowrap;
    }
    .tc-pill svg { stroke: #999; flex-shrink: 0; }
    .tc-dot {
        width: 8px; height: 8px;
        border-radius: 50%;
        display: inline-block;
        flex-shrink: 0;
    }
    .tc-priority-low .tc-dot     { background: #a3d977; }
    .tc-priority-medium .tc-dot  { background: #5b9bd5; }
    .tc-priority-high .tc-dot    { background: #f5a623; }
    .tc-priority-urgent .tc-dot  { background: #e74c3c; }

    /* Mobile card dropdowns */
    .tc-dd { position: relative; display: inline-block; }
    .tc-dd summary { list-style: none; cursor: pointer; }
    .tc-dd summary::-webkit-details-marker { display: none; }
    .tc-caret { width: 10px; height: 10px; flex-shrink: 0; opacity: 0.4; }
    .tc-dd[open] .tc-caret { transform: rotate(180deg); }
    .tc-dd-panel {
        position: absolute; bottom: calc(100% + 6px); left: 0; z-index: 50;
        background: #fff; border: 1px solid #ddd; border-radius: 8px;
        box-shadow: 0 4px 16px rgba(0,0,0,0.15); padding: 0.25rem 0;
        min-width: 160px; max-height: 260px; overflow-y: auto;
    }
    .tc-dd-opt {
        display: block; padding: 0.45rem 0.75rem; font-size: 0.85rem;
        color: #1a1a1a; text-decoration: none;
    }
    .tc-dd-opt:active { background: #f0f7ff; }
    .tc-dd-opt.active { font-weight: 600; color: var(--primary-color); }
    .tc-dd-section {
        padding: 0.3rem 0.75rem 0.15rem; font-size: 0.7rem;
        font-weight: 600; color: #999; text-transform: uppercase; letter-spacing: 0.03em;
        border-top: 1px solid #eee;
    }
    .tc-dd-section:first-child { border-top: none; }
}

/* Item status badges */
.badge-item-active            { background: #e6f4ea; color: #1a7f37; }
.badge-item-draft             { background: #eee; color: #666; }
.badge-item-archived          { background: #fff3e0; color: #b45309; }
.badge-kit                    { background: #ede9fe; color: #6d28d9; }
.badge-kit-shop               { background: #fef3c7; color: #92400e; }

/* Kit component rows in shipping */
.kit-header-row               { background: #faf5ff; }
.kit-component-row td:first-child { font-style: italic; }

/* Payment status badges */
.badge-pay-paid       { background: #e6f4ea; color: #1a7f37; }
.badge-pay-unpaid     { background: #fff3e0; color: #b45309; }
.badge-pay-net-terms  { background: #e6f4ea; color: #1a7f37; }

/* PIA warning banner */
.pia-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffc107;
    border-radius: 0.375rem;
    padding: 0.625rem 1rem;
    margin: 0 1.25rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
}

/* Item availability badges */
.badge-avail-fully-available      { background: #e6f4ea; color: #1a7f37; }
.badge-avail-partially-available  { background: #fff3e0; color: #b45309; }
.badge-avail-unavailable          { background: #fce8e8; color: #c00; }

/* Shipment status badges */
.badge-shipstatus-none                           { background: #f9fafb; color: #9ca3af; }
.badge-shipstatus-created                        { background: #f3f4f6; color: #6b7280; }
.badge-shipstatus-picked                         { background: #dbeafe; color: #1e40af; }
.badge-shipstatus-packed                         { background: #e0edff; color: #1a56db; }
.badge-shipstatus-ready_to_ship                  { background: #d1fae5; color: #065f46; }
.badge-shipstatus-shipped                        { background: #dcfce7; color: #15803d; }
.badge-shipstatus-pending_material_arrival       { background: #fef3c7; color: #92400e; }
.badge-shipstatus-pending_external_documentation { background: #fef3c7; color: #92400e; }
.badge-shipstatus-requires_shop_work             { background: #fee2e2; color: #991b1b; }
.badge-shipstatus-pending_arranged_pickup        { background: #e0e7ff; color: #3730a3; }
.badge-shipstatus-customer_arrangement_in_process { background: #ede9fe; color: #5b21b6; }
.badge-shipstatus-hold_psd                       { background: #e8eaed; color: #3c4043; border: 1px solid #c0c4cc; }

/* Invoice dropdown */
.cell-invoice {
    position: relative;
}

.invoice-dropdown {
    position: relative;
    display: inline-block;
}

.invoice-dropdown summary {
    cursor: pointer;
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.invoice-dropdown summary::-webkit-details-marker {
    display: none;
}

.invoice-dropdown .caret {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    opacity: 0.6;
    transition: transform 0.15s;
}

.invoice-dropdown[open] .caret {
    transform: rotate(180deg);
}

.invoice-panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 50;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    padding: 0.5rem 0;
    min-width: 190px;
    white-space: nowrap;
}

.invoice-info {
    padding: 0.35rem 0.75rem;
    font-size: 0.78rem;
    color: #666;
}

.invoice-link {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    color: #1a1a1a;
    text-decoration: none;
    transition: background 0.1s;
}

.invoice-link:hover {
    background: #f5f5f5;
}

.invoice-link svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
    opacity: 0.6;
}

/* Inline table dropdowns (tickets list) */
.cell-inline-dd { position: relative; }
.inline-dropdown { position: relative; display: inline-block; }
.inline-dropdown summary {
    cursor: pointer; list-style: none; display: inline-flex;
    align-items: center; gap: 0.25rem; font-size: 0.8rem;
}
.inline-dropdown summary::-webkit-details-marker { display: none; }
.inline-dropdown .caret {
    width: 10px; height: 10px; flex-shrink: 0; opacity: 0.4; transition: transform 0.15s;
}
.inline-dropdown[open] .caret { transform: rotate(180deg); }
.inline-panel {
    position: absolute; top: calc(100% + 4px); left: 0; z-index: 20;
    background: #fff; border: 1px solid #ddd; border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12); padding: 0.25rem 0;
    min-width: 170px; white-space: nowrap;
}
.inline-option {
    display: block; padding: 0.35rem 0.75rem; font-size: 0.8rem;
    color: #1a1a1a; text-decoration: none; transition: background 0.1s;
}
.inline-option:hover { background: #f0f7ff; }
.inline-option.active { font-weight: 600; color: var(--primary-color); }

/* Pagination */
.pagination {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.75rem 0; margin-top: 0.5rem; font-size: 0.82rem;
}
.pagination-info { color: #666; }
.pagination-controls { display: flex; align-items: center; gap: 0.25rem; }
.pagination-btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 32px; height: 32px; padding: 0 0.5rem;
    border: 1px solid #ddd; border-radius: 4px; background: #fff;
    color: #333; text-decoration: none; font-size: 0.82rem; cursor: pointer;
    transition: background 0.1s, border-color 0.1s;
}
.pagination-btn:hover:not(.disabled):not(.active) { background: #f0f7ff; border-color: #b0c4de; }
.pagination-btn.active { background: var(--danger-color, #d44c3f); color: #fff; border-color: var(--danger-color, #d44c3f); font-weight: 600; }
.pagination-btn.disabled { color: #ccc; cursor: default; background: #fafafa; }
.pagination-ellipsis { padding: 0 0.25rem; color: #999; }

/* Login page */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.login-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
}

.login-card h1 {
    color: #1a1a1a;
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.login-subtitle {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.login-error {
    background: #fee;
    color: #c00;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.login-field {
    margin-bottom: 1rem;
}

.login-field label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.35rem;
}

.login-field .form-input {
    width: 100%;
    box-sizing: border-box;
}

.btn-login {
    width: 100%;
    padding: 0.75rem;
    background: var(--color-primary, #e93124);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-login:hover {
    background: #c7281d;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}

.btn-primary {
    background: var(--color-primary, var(--color-primary, #e93124));
    color: #fff;
}

.btn-primary:hover {
    background: var(--color-primary-hover, #c7281d);
}

.btn-secondary {
    background: #e5e5e5;
    color: #333;
}

.btn-secondary:hover {
    background: #d5d5d5;
}

.btn-danger {
    background: var(--color-secondary, #dc3545);
    color: #fff;
}

.btn-danger:hover {
    background: var(--color-secondary-hover, #bb2d3b);
}

.btn-accent {
    background: #1DBA1D;
    color: #fff;
}
.btn-accent:hover {
    background: #18a018;
}

.btn-print {
    background: #BB1D76;
    color: #fff;
}
.btn-print:hover {
    background: #9a1862;
}

.btn-sm {
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
}

.btn-remove {
    background: none;
    border: none;
    color: #c00;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.btn-remove:hover {
    background: #fee;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    vertical-align: middle;
}

.btn-icon:hover {
    background: #e8f0fe;
    color: var(--primary);
}

.btn-icon + .btn-icon { margin-left: 0.25rem; }
.btn-icon:disabled { opacity: 0.3; cursor: default; }
.btn-icon:disabled:hover { background: none; color: var(--text-secondary); }
.btn-icon-danger { color: #c00; }
.btn-icon-danger:hover { background: #fee; color: #c00; }

/* Form layout */
.form-row {
    display: grid;
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row-4 { grid-template-columns: repeat(4, 1fr); }
.form-row-5 { grid-template-columns: repeat(5, 1fr); }
.form-row-6 { grid-template-columns: repeat(6, 1fr); }

.form-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.form-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.form-card-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #333;
    display: block;
    margin-bottom: 0.5rem;
}

.form-card-header .form-card-title {
    margin-bottom: 0;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.form-field-group {
    margin-top: 0.5rem;
}

.form-label {
    font-size: 0.78rem;
    font-weight: 500;
    color: #666;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.45rem 0.6rem;
    font-family: inherit;
    font-size: 0.85rem;
    border: 1px solid #ccc;
    border-radius: 5px;
    background: #fff;
    color: #1a1a1a;
    transition: border-color 0.15s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--color-primary, #e93124);
}

input[type="date"].form-input {
    font-family: inherit;
}

.form-input-sm {
    width: 100px;
    padding: 0.3rem 0.5rem;
}

.form-input-table {
    width: 100%;
    font-size: 0.82rem;
    padding: 0.35rem 0.5rem;
}

.form-textarea {
    resize: vertical;
    font-family: inherit;
}

.attachment-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0;
    font-size: 0.82rem;
}

.attachment-link {
    color: #1a73e8;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.attachment-link:hover {
    text-decoration: underline;
}

.attachment-size {
    color: #888;
    font-size: 0.75rem;
    white-space: nowrap;
}

.attachment-delete {
    background: none;
    border: none;
    color: #c00;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 0.2rem;
    line-height: 1;
}

.attachment-delete:hover {
    color: #e00;
}

.attachment-upload {
    margin-top: 0.4rem;
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem;
    color: #555;
    cursor: pointer;
}

.form-checkbox input[type="checkbox"] {
    accent-color: auto;
}

.address-select-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.address-select-row .form-select {
    flex: 1;
}

.address-display {
    font-size: 0.83rem;
    color: #666;
    white-space: pre-line;
    line-height: 1.5;
    min-height: 2rem;
    padding: 0.5rem;
    background: #fafafa;
    border-radius: 4px;
    border: 1px solid #eee;
}

/* Line items table */
.line-items-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.line-items-table th {
    text-align: left;
    vertical-align: bottom;
    padding: 0.5rem 0.5rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: #666;
    border-bottom: 1px solid #ddd;
}

.line-items-table td {
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid #eee;
    vertical-align: top;
}

.li-sku    { width: 18%; }
.li-item   { width: 32%; }
.li-qty    { width: 8%; }
.li-price  { width: 14%; }
.li-total,
.line-items-table th.li-total { width: 14%; text-align: right; }
.li-remove { width: 5%; text-align: center; }

.btn-remove {
    margin-top: 0.35rem;
}

.li-select {
    width: 100%;
}

.li-qty-input {
    width: 70px;
    max-width: 100%;
    text-align: center;
}

.li-price-input {
    width: 100px;
    max-width: 100%;
    text-align: right;
}

.li-cost-input {
    width: 100px;
    max-width: 100%;
    text-align: right;
}

.li-line-total {
    text-align: right;
    font-weight: 500;
    padding-top: 0.9rem;
}

.li-cost-display,
.li-margin-display {
    padding-top: 0.9rem;
}

/* Autocomplete dropdown */
.li-sku-cell {
    position: relative;
}

.li-item-name {
    font-size: 0.83rem;
    color: #555;
}

.li-desc-input {
    width: 100%;
    box-sizing: border-box;
}

.li-avail {
    font-size: 0.75rem;
    margin-top: 0.15rem;
}

.avail-in-stock {
    color: #16a34a;
}

.avail-out {
    color: #dc2626;
}

.ac-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 20;
    background: #fff;
    border: 1px solid #ccc;
    border-top: none;
    border-radius: 0 0 5px 5px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-height: 240px;
    overflow-y: auto;
}

.ac-option {
    padding: 0.45rem 0.6rem;
    font-size: 0.83rem;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ac-option:hover,
.ac-option.ac-active {
    background: #f5f5f5;
}

.ac-sku {
    font-weight: 600;
    color: #1a1a1a;
}

.ac-browse {
    color: #666;
    font-style: italic;
    border-top: 1px solid #eee;
}

/* Browse modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e0e0e0;
}

.modal-title {
    font-size: 1rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: #666;
    padding: 0 0.25rem;
}

.modal-close:hover {
    color: #1a1a1a;
}

.modal-body {
    padding: 1rem 1.25rem;
    overflow-y: auto;
}

.modal-body > .form-input {
    margin-bottom: 0.75rem;
}

.modal-body .form-field-group {
    margin-top: 0.75rem;
}

.modal-body .form-field-group:first-child {
    margin-top: 0;
}

.modal-body .form-row {
    margin-top: 0.75rem;
}

.modal-body .form-row .form-field-group {
    margin-top: 0;
}

.modal-body .form-field-group .form-label {
    display: block;
    margin-bottom: 0.25rem;
}

.browse-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.83rem;
}

.browse-table th {
    text-align: left;
    padding: 0.4rem 0.5rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: #666;
    border-bottom: 1px solid #ddd;
    white-space: nowrap;
}

.browse-table td {
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid #eee;
}

.browse-table tbody tr:hover {
    background: #f5f5f5;
}

.browse-sku {
    font-weight: 600;
    white-space: nowrap;
}

.browse-desc {
    color: #666;
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Payment summary */
.payment-summary {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.payment-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #555;
}

.payment-total {
    border-top: 2px solid #1a1a1a;
    padding-top: 0.5rem;
    margin-top: 0.25rem;
    font-weight: 700;
    color: #1a1a1a;
    font-size: 0.95rem;
}

.money-input {
    margin-left: auto;
}

/* Form footer */
.form-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #e0e0e0;
}

/* Item viewer card */
.item-viewer {
    display: flex;
    flex-direction: row;
    gap: 2rem;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}
.item-viewer-img {
    width: 250px;
    min-width: 250px;
    max-width: 250px;
    height: 250px;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fafafa;
}
.item-viewer-img img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.item-viewer-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #aaa;
    font-size: 0.9rem;
}
.item-viewer-details {
    flex: 1;
    padding-top: 0.5rem;
}
.item-viewer-field {
    margin-bottom: 0.6rem;
}
.item-viewer-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: #777;
    margin-bottom: 0.1rem;
}
.item-viewer-value {
    font-size: 0.9rem;
    color: #1a1a1a;
}
.item-viewer-field-row {
    display: flex;
    gap: 3rem;
}

/* Item sub-table tabs */
.item-tabs-section {
    margin-top: 2rem;
    border-top: 1px solid #e0e0e0;
    padding-top: 1rem;
}

.item-tabs-bar {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #e0e0e0;
    margin-bottom: 1rem;
}

.item-tab {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: #666;
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}

.item-tab:hover {
    color: var(--color-primary, #e93124);
}

.item-tab.active {
    color: var(--color-primary, #e93124);
    font-weight: 600;
    border-bottom-color: var(--color-primary, #e93124);
}

.item-tab-content {
    min-height: 100px;
}

.item-tab-content .data-table {
    margin-bottom: 0;
}

.add-row td {
    padding-top: 0.5rem;
    border-bottom: none;
}

.form-select-sm,
.form-input-sm {
    font-size: 0.82rem;
    padding: 0.35rem 0.5rem;
}

.btn-sm {
    font-size: 0.78rem;
    padding: 0.3rem 0.6rem;
}

/* Pictures grid */
.pictures-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

.picture-card {
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
    background: #fafafa;
}

.picture-card img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    display: block;
}

.picture-placeholder {
    width: 100%;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 0.8rem;
}

.picture-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0.5rem;
    font-size: 0.8rem;
}

.picture-url-link {
    color: #666;
    text-decoration: none;
}

.picture-url-link:hover {
    text-decoration: underline;
}

/* 4-column form row */
.form-row-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

/* Settings page */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.settings-card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
}

.settings-card-wide {
    grid-column: 1 / -1;
}

.settings-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #eee;
    background: #fafafa;
}

.settings-card-header svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: #555;
}

.settings-card-header h2 {
    font-size: 0.95rem;
    font-weight: 600;
}

.settings-card-body {
    padding: 0;
}

.settings-card-body .data-table {
    margin-bottom: 0;
    border: none;
}

.settings-card-body .data-table thead th {
    background: #fff;
}

.settings-card-body .data-table tfoot td {
    background: #fff;
}

/* Reports landing page */
.reports-subtitle {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 1.5rem;
}

.reports-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.report-card {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.25rem;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.report-card:hover {
    border-color: var(--color-primary, #e93124);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.report-card-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    background: #f5f5f5;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.report-card-icon svg {
    width: 20px;
    height: 20px;
    color: var(--color-primary, #e93124);
}

.report-card-text h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.report-card-text p {
    font-size: 0.8rem;
    color: #666;
    line-height: 1.4;
}

/* Low stock highlight */
.text-low-stock {
    color: #c00;
    font-weight: 600;
}

/* Pick modal */
.pick-progress-wrap {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.pick-progress-bar {
    flex: 1;
    height: 8px;
    background: #e5e5e5;
    border-radius: 4px;
    overflow: hidden;
}

.pick-progress-fill {
    height: 100%;
    background: #1a7f37;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.pick-progress-complete {
    background: #1a7f37;
}

.pick-progress-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #333;
    min-width: 3rem;
    text-align: right;
}

.pick-table {
    table-layout: fixed;
    width: 100%;
}
.pick-table th:first-child,
.pick-table td:first-child {
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.pick-table .pick-qty-input {
    width: 5rem;
    text-align: right;
}
.pick-table .pick-loc-select {
    width: 100%;
    font-size: 0.8rem;
    padding: 0.25rem 0.35rem;
}

.pick-left-col {
    color: #666;
}

.pick-item-sku {
    color: #999;
    font-size: 0.8rem;
}
.pick-item-locations {
    color: #888;
    font-size: 0.75rem;
    margin-top: 0.15rem;
}

/* Pack tab */
.pack-layout {
    display: grid;
    grid-template-columns: 1fr 200px;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.pack-of-col {
    color: #666;
    white-space: nowrap;
}

.pack-container-select {
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1.25rem;
}

.pack-container-title {
    font-size: 0.95rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 1rem;
}

.pack-container-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
    text-decoration: none;
    color: inherit;
    margin-bottom: 0.5rem;
    transition: border-color 0.15s;
}

.pack-container-card:hover {
    border-color: var(--color-primary, #e93124);
}

.pack-container-card.selected {
    border-color: var(--color-primary, #e93124);
    background: #fef5f5;
}

.pack-container-icon svg {
    width: 24px;
    height: 24px;
    color: #555;
}

.pack-container-card.selected .pack-container-icon svg {
    color: var(--color-primary, #e93124);
}

.pack-container-card strong {
    flex: 1;
    font-size: 0.9rem;
}

.pack-container-arrow {
    width: 16px;
    height: 16px;
    color: #ccc;
    flex-shrink: 0;
}

.pack-skip {
    text-align: center;
    padding: 1rem 0;
    border-top: 1px solid #e0e0e0;
    margin-top: 0.5rem;
}

.pack-skip p {
    font-size: 0.82rem;
    color: #888;
    margin-bottom: 0.75rem;
}

/* Ship tab */
.ship-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.ship-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #1a1a1a;
}

.ship-package-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
}

.ship-package-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
    border-radius: 8px;
    flex-shrink: 0;
}

.ship-package-icon svg {
    width: 22px;
    height: 22px;
    stroke: #555;
}

.ship-package-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.ship-package-info strong {
    font-size: 0.9rem;
}

.ship-package-meta {
    font-size: 0.8rem;
    color: #888;
}

/* Shipment cards in modal */
/* SO detail shipments timeline */
.so-shipments-timeline {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.5rem 0;
}
.so-shipment-card {
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 0.75rem 1rem;
    background: #fafafa;
}
.so-shipment-card .data-table th {
    font-size: 0.7rem;
    padding: 0.25rem 0.4rem;
}
.so-shipment-card .data-table td {
    padding: 0.25rem 0.4rem;
}

/* Shipping modal shipment cards */
.shipment-card {
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    transition: background 0.1s, border-color 0.1s;
}
.shipment-card:hover {
    background: #f8f9fb;
    border-color: #ccc;
}

/* ─── Shared Tab Toolbar (Filters, Columns, Save View) ─── */
.tab-bar-right { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; }
.tab-add {
    border: 1px dashed #bbb; color: #777; font-size: 0.78rem;
    background: transparent; cursor: pointer; padding: 0.35rem 0.6rem; border-radius: 4px;
}
.tab-add:hover { background: #f0f4ff; color: #333; border-color: #999; }
.toolbar-btn {
    display: inline-flex; align-items: center; gap: 0.3rem;
    padding: 0.35rem 0.6rem; border: 1px solid #ddd; border-radius: 4px;
    background: #fff; color: #555; font-size: 0.78rem; cursor: pointer;
}
.toolbar-btn:hover { background: #f5f5f5; border-color: #bbb; }
.filter-count {
    background: #4a90d9; color: #fff; border-radius: 8px;
    padding: 0 5px; font-size: 0.65rem; font-weight: 700;
}
.filter-bar {
    background: #f8f9fb; border: 1px solid #e2e5ea; border-radius: 6px;
    padding: 0.75rem; margin-bottom: 0.5rem; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.5rem;
}
.filter-rows { display: flex; flex-wrap: wrap; gap: 0.4rem; flex: 1; min-width: 0; }
.filter-row {
    display: inline-flex; align-items: center; gap: 0.3rem; background: #fff;
    border: 1px solid #ddd; border-radius: 4px; padding: 0.25rem 0.4rem; font-size: 0.78rem;
}
.filter-row select { border: none; background: transparent; font-size: 0.78rem; padding: 0.15rem; cursor: pointer; }
.filter-row select:focus { outline: none; }
.filter-value-wrap { display: inline-flex; flex-wrap: wrap; gap: 0.2rem; align-items: center; }
.filter-value-chip {
    display: inline-flex; align-items: center; gap: 0.2rem;
    background: #e8f0fe; color: #1a56db; border-radius: 3px; padding: 0.1rem 0.35rem; font-size: 0.72rem;
}
.filter-value-chip .chip-x { cursor: pointer; font-weight: 700; opacity: 0.6; }
.filter-value-chip .chip-x:hover { opacity: 1; }
.filter-remove { cursor: pointer; color: #999; font-size: 1rem; line-height: 1; padding: 0 0.2rem; }
.filter-remove:hover { color: #d44c3f; }
.filter-add-btn {
    border: 1px dashed #bbb; background: transparent; color: #666; font-size: 0.75rem;
    padding: 0.3rem 0.5rem; border-radius: 4px; cursor: pointer; white-space: nowrap;
}
.filter-add-btn:hover { background: #eee; }
.col-chooser-popup {
    position: absolute; right: 0; top: 100%; z-index: 100;
    background: #fff; border: 1px solid #ddd; border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    width: 220px; margin-top: 0.25rem;
}
.col-chooser-header { padding: 0.6rem 0.75rem; font-weight: 600; font-size: 0.82rem; border-bottom: 1px solid #eee; }
.col-chooser-list { padding: 0.4rem 0; max-height: 300px; overflow-y: auto; }
.col-chooser-item {
    display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0.75rem;
    font-size: 0.82rem; cursor: grab; user-select: none;
}
.col-chooser-item:hover { background: #f5f7fa; }
.col-chooser-item.dragging { opacity: 0.4; }
.col-chooser-item.drag-over { border-top: 2px solid #4a90d9; }
.col-chooser-grip { color: #bbb; font-size: 0.7rem; cursor: grab; }
.col-chooser-footer { padding: 0.5rem 0.75rem; border-top: 1px solid #eee; text-align: right; }
.search-clear {
    position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%);
    color: #999; text-decoration: none; font-size: 1.1rem; line-height: 1;
}
.search-clear:hover { color: #333; }

/* Tab context menu (right-click) */
.tab-context-menu {
    position: fixed;
    z-index: 2000;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 4px 0;
    min-width: 160px;
}
.tab-context-menu button {
    display: block;
    width: 100%;
    padding: 6px 14px;
    border: none;
    background: none;
    text-align: left;
    font-size: 0.82rem;
    cursor: pointer;
    color: #333;
}
.tab-context-menu button:hover {
    background: #f0f4f8;
}
.tab-context-menu button.ctx-danger { color: #d44c3f; }
.tab-context-menu button.ctx-danger:hover { background: #fef2f2; }

/* ─── Dashboard ─── */
.dash-period {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
}

.dash-period-btn {
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: #666;
    text-decoration: none;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.dash-period-btn:hover {
    border-color: var(--color-primary, #e93124);
    color: var(--color-primary, #e93124);
}

.dash-period-btn.active {
    background: var(--color-primary, #e93124);
    color: #fff;
    border-color: var(--color-primary, #e93124);
    font-weight: 600;
}

.dash-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.dash-card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 1.5rem;
    text-align: center;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

a.dash-card:hover {
    border-color: var(--color-primary, #e93124);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.dash-card-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 1rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dash-card-icon svg {
    width: 24px;
    height: 24px;
}

.dash-icon-estimates { background: #f3e8ff; color: #7c3aed; }
.dash-icon-est-value { background: #ede9fe; color: #6d28d9; }
.dash-icon-sales     { background: #e8f0fe; color: #1a56db; }
.dash-icon-revenue   { background: #e6f4ea; color: #1a7f37; }
.dash-icon-po        { background: #fff3e0; color: #b45309; }
.dash-icon-po-total  { background: #fce8e8; color: #c00; }
.dash-icon-shipped   { background: #e6f4ea; color: #1a7f37; }
.dash-icon-awaiting  { background: #fff3e0; color: #b45309; }
.dash-icon-sales-opp { background: #fef3c7; color: #d97706; }

.dash-card-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 0.25rem;
}

.dash-card-label {
    font-size: 0.85rem;
    color: #666;
    font-weight: 500;
}

.dash-card-split {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
}

/* ─── Dashboard Charts ─── */
.dash-charts {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-top: 1.5rem;
}

.dash-chart-card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 1.5rem;
}

.dash-chart-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 1rem;
}

/* ─── Hamburger button (hidden on desktop) ─── */
.hamburger {
    display: none;
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 210;
    background: #1c1c1c;
    border: none;
    border-radius: 6px;
    padding: 0.55rem 0.5rem;
    cursor: pointer;
    flex-direction: column;
    gap: 4px;
}

.hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: #fff;
    border-radius: 1px;
}

/* Mobile basket button (hidden on desktop) */
.mobile-basket {
    display: none;
    position: fixed;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 210;
    background: #1c1c1c;
    border: none;
    border-radius: 6px;
    padding: 0.5rem;
    color: #fff;
    text-decoration: none;
}

.mobile-basket svg {
    width: 20px;
    height: 20px;
}

.mobile-basket-badge {
    display: none;
    position: absolute;
    top: -4px;
    right: -4px;
    background: #e53e3e;
    color: #fff;
    border-radius: 10px;
    padding: 0 5px;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 16px;
    text-align: center;
    line-height: 16px;
}

/* Sidebar backdrop overlay (hidden on desktop) */
.sidebar-backdrop {
    display: none;
}

/* ─── Audit Report ─── */
.report-filters {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    padding: 1rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.report-filters .filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.report-filters .filter-group label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.report-filters .filter-group .form-input {
    width: auto;
    min-width: 140px;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 1rem 0;
}

.page-link {
    display: inline-block;
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.85rem;
    color: var(--text-primary);
    text-decoration: none;
    background: #fff;
}

.page-link:hover {
    background: var(--bg-hover);
}

.page-active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.page-ellipsis {
    border: none;
    background: none;
    cursor: default;
}

.badge-audit {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}

.badge-login { background: #e8f4fd; color: #1a73e8; }
.badge-create { background: #e6f4ea; color: #1e7e34; }
.badge-update { background: #fff3cd; color: #856404; }
.badge-delete { background: #fde8e8; color: #c62828; }
.badge-adjust { background: #f3e8fd; color: #6a1b9a; }
.badge-import { background: #e0f2f1; color: #00695c; }
.badge-export { background: #fce4ec; color: #ad1457; }

.changes-cell {
    font-size: 0.8rem;
    max-width: 300px;
    word-break: break-word;
    color: var(--text-secondary);
}

.changes-cell .change-key {
    font-weight: 600;
    color: var(--text-primary);
}

/* ─── Spinner ─── */
.btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(0,0,0,0.2);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: btn-spin 0.6s linear infinite;
    vertical-align: middle;
}
@keyframes btn-spin {
    to { transform: rotate(360deg); }
}

/* ─── Nav badge attention pulse ─── */
@keyframes nav-badge-pulse {
    0%   { transform: scale(1);   background: #e53e3e; box-shadow: 0 0 0 0 rgba(246,173,85,0); }
    30%  { transform: scale(1.35); background: #f6ad55; box-shadow: 0 0 0 6px rgba(246,173,85,0.35); }
    100% { transform: scale(1);   background: #e53e3e; box-shadow: 0 0 0 0 rgba(246,173,85,0); }
}
.nav-badge-pulse {
    animation: nav-badge-pulse 0.9s ease-out;
}

/* ─── Global Search ─── */
.global-search-wrap {
    position: relative;
    margin-bottom: 1.5rem;
}

.global-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.global-search:focus-within {
    border-color: var(--color-primary, #e93124);
    box-shadow: 0 0 0 3px rgba(233, 49, 36, 0.1);
}

.global-search svg {
    width: 16px;
    height: 16px;
    color: #999;
    flex-shrink: 0;
}

.global-search-input {
    border: none;
    outline: none;
    font-size: 0.88rem;
    color: #1a1a1a;
    width: 100%;
    background: transparent;
}

.global-search-input::placeholder {
    color: #aaa;
}

.global-search-kbd {
    font-size: 0.7rem;
    font-family: inherit;
    padding: 0.1rem 0.4rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    color: #999;
    background: #f5f5f5;
    line-height: 1.2;
}

.global-search-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 50;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    max-height: 420px;
    overflow-y: auto;
}

.gs-group-label {
    padding: 0.5rem 0.75rem 0.25rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #888;
    background: #fafafa;
    border-top: 1px solid #eee;
}

.gs-group-label:first-child {
    border-top: none;
}

.gs-option {
    padding: 0.45rem 0.75rem;
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #1a1a1a;
    text-decoration: none;
    display: block;
}

.gs-option:hover,
.gs-option.gs-active {
    background: #f0f0f0;
}

.gs-view-all {
    padding: 0.5rem 0.75rem;
    font-size: 0.82rem;
    color: var(--color-primary, #e93124);
    font-weight: 500;
    text-align: center;
    border-top: 1px solid #eee;
    cursor: pointer;
    text-decoration: none;
    display: block;
}

.gs-view-all:hover {
    background: #fef5f5;
}

.gs-empty {
    padding: 1rem 0.75rem;
    font-size: 0.85rem;
    color: #999;
    text-align: center;
}

/* Search results page */
.search-section {
    margin-bottom: 2rem;
}

.search-section-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--color-primary, #e93124);
    color: #1a1a1a;
}

/* ─── Mobile breakpoint ─── */
@media (max-width: 768px) {
    /* Show hamburger + mobile basket */
    .hamburger {
        display: flex;
    }

    .mobile-basket {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Sidebar: off-screen by default, slides in */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 200;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    /* Backdrop */
    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 190;
        background: rgba(0, 0, 0, 0.4);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
    }

    .sidebar-backdrop.open {
        opacity: 1;
        pointer-events: auto;
    }

    /* Main content: remove left margin, add top padding for hamburger */
    main {
        margin-left: 0;
        padding: 3.5rem 1rem 2rem;
    }

    /* Page header */
    .page-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .page-header h1 {
        font-size: 1.2rem;
    }

    /* Tab bar: wrap on mobile */
    .tab-bar {
        flex-wrap: wrap;
    }

    .tab-bar-search {
        margin-left: 0;
        width: 100%;
        order: -1;
        margin-bottom: 0.5rem;
    }

    .tab-bar-search-input {
        width: 100%;
    }

    /* Form grids: stack to single column */
    .form-row-2,
    .form-row-3,
    .form-row-4,
    .form-row-5,
    .form-row-6 {
        grid-template-columns: 1fr;
    }

    /* Settings grid: single column */
    .settings-grid {
        grid-template-columns: 1fr;
    }

    /* Pack layout: single column, container cards horizontal */
    .pack-layout {
        grid-template-columns: 1fr;
    }

    .pack-container-select {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.75rem;
    }

    .pack-container-title {
        flex: 0 0 100%;
        margin-bottom: 0.25rem;
    }

    .pack-container-card {
        flex: 1 1 0;
        margin-bottom: 0;
        justify-content: center;
    }

    .pack-container-arrow {
        display: none;
    }

    /* Data table: allow horizontal scroll, permit wrapping */
    .data-table td {
        white-space: normal;
    }

    /* --- Line items: card layout on mobile --- */
    .line-items-table,
    .line-items-table thead,
    .line-items-table tbody {
        display: block;
        width: 100%;
        min-width: 0;
    }

    /* Hide column headers, keep button row */
    .line-items-table thead tr:has(th) {
        display: none;
    }

    .line-items-table thead tr:first-child {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        align-items: center;
        padding: 0.25rem 0;
    }

    .line-items-table thead tr:first-child td {
        border: none;
        padding: 0.25rem 0;
    }

    .line-items-table thead tr:first-child td:empty {
        display: none;
    }

    /* Each line item = stacked card */
    .line-items-table tbody tr {
        display: flex;
        flex-wrap: wrap;
        align-items: flex-end;
        gap: 0.15rem 0.5rem;
        padding: 0.6rem 0.5rem;
    }

    .line-items-table tbody tr:nth-child(odd) {
        background: #f5f6f8;
        border-radius: 4px;
    }

    .line-items-table td {
        border-bottom: none;
        padding: 0.15rem 0;
        font-size: 0.82rem;
    }

    /* Full-width cells */
    .line-items-table .li-sku-cell,
    .line-items-table td.li-item-name {
        flex: 0 0 100%;
    }

    /* Numeric/date fields: wrap into rows */
    .line-items-table td:has(.li-qty-input),
    .line-items-table td:has(.li-price-input),
    .line-items-table td:has(.li-cost-input),
    .line-items-table td:has(.li-promise-date),
    .line-items-table td.li-line-total,
    .line-items-table td.li-cost-display,
    .line-items-table td.li-margin-display,
    .line-items-table td.li-fd-cell {
        flex: 1 1 70px;
    }

    /* Remove button */
    .line-items-table td:has(.btn-remove) {
        flex: 0 0 auto;
        align-self: flex-end;
    }

    /* Labels above each value */
    .line-items-table .li-sku-cell::before,
    .line-items-table td.li-item-name::before,
    .line-items-table td:has(.li-qty-input)::before,
    .line-items-table td:has(.li-price-input)::before,
    .line-items-table td:has(.li-cost-input)::before,
    .line-items-table td:has(.li-promise-date)::before,
    .line-items-table td.li-line-total::before,
    .line-items-table td.li-cost-display::before,
    .line-items-table td.li-margin-display::before,
    .line-items-table td.li-fd-cell::before {
        display: block;
        font-size: 0.65rem;
        font-weight: 600;
        color: #888;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        margin-bottom: 0.1rem;
    }

    .line-items-table .li-sku-cell::before { content: "SKU"; }
    .line-items-table td.li-item-name::before { content: "Item"; }
    .line-items-table td:has(.li-qty-input)::before { content: "Qty"; }
    .line-items-table td:has(.li-price-input)::before { content: "Unit Price"; }
    .line-items-table td:has(.li-cost-input)::before { content: "Unit Cost"; }
    .line-items-table td:has(.li-promise-date)::before { content: "Promise"; }
    .line-items-table td.li-line-total::before { content: "Total"; }
    .line-items-table td.li-cost-display::before { content: "Cost"; }
    .line-items-table td.li-margin-display::before { content: "Margin"; }
    .line-items-table td.li-fd-cell::before { content: "FD"; }

    /* Inputs: fill their cells */
    .line-items-table .li-qty-input,
    .line-items-table .li-price-input,
    .line-items-table .li-cost-input,
    .line-items-table .li-promise-date {
        width: 100% !important;
        box-sizing: border-box;
    }

    /* Modal: full-width on mobile */
    .modal {
        width: 95%;
        max-height: 90vh;
    }

    /* Reports grid */
    .reports-grid {
        grid-template-columns: 1fr;
    }

    /* Dashboard grid */
    .dash-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .dash-card-value {
        font-size: 1.5rem;
    }

    .dash-charts {
        grid-template-columns: 1fr;
    }

    /* --- Data table card layout on mobile --- */
    .card-table,
    .card-table thead,
    .card-table tbody {
        display: block;
        width: 100%;
    }

    .card-table thead {
        display: none;
    }

    .card-table tbody tr {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.15rem 0.5rem;
        padding: 0.85rem 1rem;
        background: #fff;
        border: 1px solid #e5e7eb;
        border-radius: 10px;
        margin-bottom: 0.5rem;
        box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    }

    .card-table tbody tr:nth-child(odd) {
        background: #fff;
    }

    .card-table td {
        border-bottom: none;
        padding: 0;
    }

    .card-table tbody tr:has(.empty-state) {
        display: block;
        text-align: center;
        box-shadow: none;
        border: none;
    }

    /* Hide desktop tab links, show mobile dropdown */
    .tab-bar > a.tab { display: none; }
    .mobile-tab-dropdown {
        display: block !important;
        margin-bottom: 0.5rem;
    }
    .mobile-tab-dropdown select {
        width: 100%;
        padding: 0.5rem 0.75rem;
        font-size: 0.95rem;
        border: 1px solid #ccc;
        border-radius: 6px;
        background: #fff;
        color: #333;
    }

    /* Card-table tfoot: stack add-row cells */
    .card-table tfoot {
        display: block;
    }

    .card-table tfoot tr.add-row {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.75rem 0.5rem;
        border-top: 2px solid #e0e0e0;
    }

    .card-table tfoot td {
        border: none;
        padding: 0;
        flex: 1 1 calc(50% - 0.5rem);
        min-width: 100px;
    }

    .card-table tfoot td:empty {
        display: none;
    }

    /* -- PO table columns -- */
    .po-col-num { flex: 1; font-size: 0.9rem; }
    .po-col-date { flex: 0 0 auto; color: #666; font-size: 0.8rem; }
    .po-col-vendor { flex: 0 0 100%; color: #444; font-size: 0.85rem; }
    .po-col-total { order: 4; flex: 0 0 auto; font-weight: 600; margin-right: auto; text-align: left; }
    .po-col-purpose { order: 5; flex: 0 0 auto; }
    .po-col-recv { order: 6; flex: 0 0 auto; }
    .po-col-status { order: 7; flex: 0 0 auto; }
    .po-col-so,
    .po-col-items,
    .po-col-creator { display: none; }

    /* -- SO table columns -- */
    .so-col-num { flex: 1; font-size: 0.9rem; }
    .so-col-date { flex: 0 0 auto; color: #666; font-size: 0.8rem; }
    .so-col-customer { flex: 0 0 100%; color: #444; font-size: 0.85rem; max-width: none; width: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .so-col-total { order: 4; flex: 0 0 auto; font-weight: 600; margin-right: auto; text-align: left; }
    .so-col-ship { order: 5; flex: 0 0 auto; }
    .so-col-status { order: 6; flex: 0 0 auto; }
    .so-col-invoice { order: 7; flex: 0 0 auto; }
    .so-col-custpo,
    .so-col-items,
    .so-col-rep { display: none; }

    /* -- Estimates table columns -- */
    .est-col-num { flex: 1; font-size: 0.9rem; }
    .est-col-date { flex: 0 0 auto; color: #666; font-size: 0.8rem; }
    .est-col-customer { flex: 0 0 100%; color: #444; font-size: 0.85rem; max-width: none; width: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .est-col-total { order: 4; flex: 0 0 auto; font-weight: 600; margin-right: auto; text-align: left; }
    .est-col-status { order: 5; flex: 0 0 auto; }
    .est-col-items,
    .est-col-rep { display: none; }

    /* -- Items (Inventory) table columns -- */
    .inv-col-sku { flex: 1; font-size: 0.9rem; }
    .inv-col-status { flex: 0 0 auto; }
    .inv-col-name { flex: 0 0 100%; color: #444; font-size: 0.85rem; }
    .inv-col-qty { order: 4; flex: 0 0 auto; font-weight: 600; margin-right: auto; text-align: left; }
    .inv-col-cost { order: 5; flex: 0 0 auto; text-align: left; }
    .inv-col-cat,
    .inv-col-loc { display: none; }

    /* -- Receiving table columns -- */
    .recv-col-num { flex: 1; font-size: 0.9rem; }
    .recv-col-date { flex: 0 0 auto; color: #666; font-size: 0.8rem; }
    .recv-col-vendor { flex: 0 0 100%; color: #444; font-size: 0.85rem; }
    .recv-col-total { order: 4; flex: 0 0 auto; font-weight: 600; margin-right: auto; text-align: left; }
    .recv-col-purpose { order: 5; flex: 0 0 auto; }
    .recv-col-recv { order: 6; flex: 0 0 auto; }
    .recv-col-status { order: 7; flex: 0 0 auto; }
    .recv-col-so,
    .recv-col-track,
    .recv-col-items { display: none; }

    /* -- Shipping table columns -- */
    .ship-col-num { flex: 1; font-size: 0.9rem; }
    .ship-col-date { flex: 0 0 auto; color: #666; font-size: 0.8rem; }
    .ship-col-customer { flex: 0 0 100%; color: #444; font-size: 0.85rem; max-width: none; width: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .ship-col-total { order: 4; flex: 0 0 auto; font-weight: 600; margin-right: auto; text-align: left; }
    .ship-col-ordstatus { order: 5; flex: 0 0 auto; }
    .ship-col-pay { order: 6; flex: 0 0 auto; }
    .ship-col-avail { order: 7; flex: 0 0 auto; }
    .ship-col-city,
    .ship-col-zip,
    .ship-col-custpo,
    .ship-col-shipterms,
    .ship-col-carrier,
    .ship-col-shipping { display: none; }

    /* -- Quotes table columns -- */
    .qt-col-num { flex: 1; font-size: 0.9rem; font-weight: 600; }
    .qt-col-date { flex: 0 0 auto; color: #666; font-size: 0.8rem; }
    .qt-col-customer { flex: 0 0 100%; color: #444; font-size: 0.85rem; }
    .qt-col-account { order: 4; flex: 0 0 auto; color: #666; font-size: 0.8rem; margin-right: auto; }
    .qt-col-status { order: 5; flex: 0 0 auto; }
    .qt-col-items { display: none; }

    /* -- Accounts (Customers) table columns -- */
    .acct-col-name,
    .acct-col-contact,
    .acct-col-email,
    .acct-col-address { max-width: none; width: auto; display: block; }
    .acct-col-name { flex: 1; font-size: 0.9rem; }
    .acct-col-contact { flex: 0 0 auto; color: #666; font-size: 0.8rem; }
    .acct-col-email { flex: 0 0 100%; color: #444; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .acct-col-address { order: 4; flex: 0 0 auto; color: #666; font-size: 0.8rem; margin-right: auto; }
    .acct-col-orders { order: 5; flex: 0 0 auto; font-weight: 600; font-size: 0.8rem; }

    /* -- Vendors table columns -- */
    .vnd-col-name { flex: 1; font-size: 0.9rem; }
    .vnd-col-contact { flex: 0 0 auto; color: #666; font-size: 0.8rem; }
    .vnd-col-email { flex: 0 0 100%; color: #444; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .vnd-col-city { order: 4; flex: 0 0 auto; color: #666; font-size: 0.8rem; }
    .vnd-col-state { order: 5; flex: 0 0 auto; color: #666; font-size: 0.8rem; }

    /* -- Contacts table columns -- */
    .ct-col-name { flex: 1; font-size: 0.9rem; }
    .ct-col-created { flex: 0 0 auto; color: #666; font-size: 0.8rem; }
    .ct-col-email { flex: 0 0 100%; color: #444; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .ct-col-account { order: 4; flex: 0 0 auto; color: #666; font-size: 0.8rem; margin-right: auto; }
    .ct-col-tickets { order: 5; flex: 0 0 auto; font-weight: 600; font-size: 0.8rem; }
    .ct-col-phone { display: none; }

    /* -- Inventory: hide price on mobile -- */
    .inv-col-price { display: none; }

    /* -- All Inventory report columns -- */
    .rinv-col-sku { flex: 1; font-size: 0.9rem; }
    .rinv-col-qty { flex: 0 0 auto; font-weight: 600; }
    .rinv-col-name { flex: 0 0 100%; color: #444; font-size: 0.85rem; }
    .rinv-col-value { order: 4; flex: 0 0 auto; font-weight: 600; margin-right: auto; text-align: left; }
    .rinv-col-loc { order: 5; flex: 0 0 auto; }
    .rinv-col-min,
    .rinv-col-cost,
    .rinv-col-age { display: none; }

    /* -- MSL report columns -- */
    .rmsl-col-sku { flex: 1; font-size: 0.9rem; }
    .rmsl-col-net { flex: 0 0 auto; font-weight: 600; }
    .rmsl-col-name { flex: 0 0 100%; color: #444; font-size: 0.85rem; }
    .rmsl-col-qty { order: 4; flex: 0 0 auto; margin-right: auto; text-align: left; }
    .rmsl-col-msl { order: 5; flex: 0 0 auto; }
    .rmsl-col-po,
    .rmsl-col-so { display: none; }

    /* -- PO Promise Date report columns -- */
    .rpd-col-po { flex: 1; font-size: 0.9rem; }
    .rpd-col-date { flex: 0 0 auto; color: #666; font-size: 0.8rem; }
    .rpd-col-vendor { flex: 0 0 100%; color: #444; font-size: 0.85rem; }
    .rpd-col-item { order: 4; flex: 0 0 100%; font-size: 0.85rem; }
    .rpd-col-qty { order: 5; flex: 0 0 auto; margin-right: auto; text-align: left; }
    .rpd-col-days { order: 6; flex: 0 0 auto; font-weight: 600; }
    .rpd-col-cost,
    .rpd-col-purpose { display: none; }

    /* -- Audit History report columns -- */
    .raud-col-date { flex: 0 0 auto; font-size: 0.8rem; color: #666; }
    .raud-col-action { flex: 0 0 auto; }
    .raud-col-user { order: 3; flex: 0 0 auto; font-size: 0.85rem; }
    .raud-col-table { order: 4; flex: 0 0 auto; font-size: 0.85rem; }
    .raud-col-record { order: 5; flex: 0 0 auto; margin-right: auto; }
    .raud-col-changes { order: 6; flex: 0 0 100%; font-size: 0.82rem; }
    .raud-col-ip { display: none; }

    /* -- Item Vendors sub-table columns -- */
    .iv-col-vendor { flex: 0 0 100%; font-size: 0.9rem; }
    .iv-col-sku { flex: 1; font-size: 0.85rem; color: #444; }
    .iv-col-cost { flex: 0 0 auto; font-weight: 600; }
    .iv-col-pref { flex: 0 0 auto; font-size: 0.85rem; }
    .iv-col-actions { flex: 0 0 auto; }
    .iv-col-lead { display: none; }

    /* -- Item Cross References sub-table columns -- */
    .xr-col-sku { flex: 0 0 auto; font-size: 0.9rem; font-weight: 600; }
    .xr-col-vendor { flex: 1; color: #444; font-size: 0.85rem; }
    .xr-col-name { flex: 0 0 100%; font-size: 0.85rem; color: #666; }
    .xr-col-actions { order: 3; flex: 0 0 auto; }

    /* -- Kit Components sub-table columns -- */
    .kc-col-sku { flex: 1; font-size: 0.9rem; }
    .kc-col-qty { flex: 0 0 auto; font-weight: 600; text-align: left; }
    .kc-col-name { flex: 0 0 100%; color: #444; font-size: 0.85rem; }
    .kc-col-actions { order: 3; flex: 0 0 auto; }

    /* -- Item Inventory sub-table columns -- */
    .ii-col-date { flex: 0 0 auto; font-size: 0.8rem; color: #666; }
    .ii-col-qty { flex: 0 0 auto; font-weight: 600; text-align: left; margin-left: auto; }
    .ii-col-vendor { flex: 0 0 100%; color: #444; font-size: 0.85rem; }
    .ii-col-loc { order: 4; flex: 0 0 auto; font-size: 0.85rem; }
    .ii-col-cost { order: 5; flex: 0 0 auto; text-align: left; }
    .ii-col-reason { order: 6; flex: 0 0 auto; font-size: 0.85rem; }
    .ii-col-actions { order: 7; flex: 0 0 auto; }
    .ii-col-notes { display: none; }

    /* Page header: full-width CTA button */
    .page-header > .btn {
        width: 100%;
        text-align: center;
    }

    /* Global search mobile */
    .global-search-kbd {
        display: none;
    }
    .global-search-wrap {
        margin-bottom: 1rem;
    }

    /* Login card */
    .login-card {
        margin: 1rem;
    }
}
