/* ==========================================================================
   CyclePower — Main Stylesheet
   Clean, professional, fast. Dark blue primary, green accent.
   ========================================================================== */

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

:root {
    --primary: #1a365d;
    --primary-light: #2a4a7f;
    --primary-dark: #0f2440;
    --accent: #38a169;
    --accent-hover: #2f855a;
    --bg: #f7f8fa;
    --bg-white: #ffffff;
    --text: #1a202c;
    --text-muted: #718096;
    --border: #e2e8f0;
    --danger: #e53e3e;
    --danger-hover: #c53030;
    --warning: #dd6b20;
    --info: #3182ce;
    --radius: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
    --transition: 0.15s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- App Layout ---------- */
.app-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.app-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ---------- Navbar ---------- */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--primary);
    color: #fff;
    padding: 0 20px;
    height: 50px;
    flex-shrink: 0;
}

.navbar-brand { display: flex; align-items: center; gap: 10px; }
.navbar-logo { font-size: 18px; font-weight: 700; letter-spacing: 0.5px; }
.navbar-powered-by {
    font-size: 12px;
    color: rgba(255,255,255,0.65);
    font-weight: 400;
    letter-spacing: 0;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.navbar-user { font-size: 13px; color: rgba(255,255,255,0.85); }
.navbar-link { font-size: 13px; color: rgba(255,255,255,0.85); }
.navbar-link:hover { color: #fff; text-decoration: none; }
.navbar-logout-form { display: inline; }

/* ---------- Sidebar ---------- */
.sidebar {
    width: 220px;
    background: var(--bg-white);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    flex-shrink: 0;
    padding: 16px 0;
}

.sidebar-section { margin-bottom: 16px; }

.sidebar-heading {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 4px 20px 6px;
}

.sidebar-link {
    display: block;
    padding: 7px 20px;
    font-size: 13px;
    color: var(--text);
    transition: background var(--transition);
}
.sidebar-link:hover { background: var(--bg); text-decoration: none; }
.sidebar-link.active {
    background: #ebf4ff;
    color: var(--primary);
    font-weight: 600;
    border-right: 3px solid var(--primary);
}
.sidebar-link.disabled {
    color: var(--text-muted);
    cursor: default;
    opacity: 0.5;
}
.sidebar-link.disabled:hover { background: none; }

/* ---------- Main Content ---------- */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px;
}

/* ---------- Auth Layout (login page) ---------- */
.auth-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}

.auth-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 40px;
    width: 380px;
    max-width: 95%;
}

.auth-card h1 {
    text-align: center;
    color: var(--primary);
    font-size: 24px;
    margin-bottom: 8px;
}

.auth-card .auth-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 28px;
}

/* ---------- Flash Messages ---------- */
.flash-container { margin-bottom: 16px; }

.flash {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-radius: var(--radius);
    margin-bottom: 8px;
    font-size: 13px;
    transition: opacity 0.3s ease;
}

.flash-success { background: #f0fff4; color: #22543d; border: 1px solid #c6f6d5; }
.flash-error   { background: #fff5f5; color: #742a2a; border: 1px solid #fed7d7; }
.flash-warning { background: #fffaf0; color: #7b341e; border: 1px solid #feebc8; }
.flash-info    { background: #ebf8ff; color: #2a4365; border: 1px solid #bee3f8; }

.flash-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: inherit;
    opacity: 0.6;
    padding: 0 4px;
}
.flash-close:hover { opacity: 1; }

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

.page-header h1 {
    font-size: 22px;
    font-weight: 600;
    color: var(--primary-dark);
}

/* ---------- Cards ---------- */
.card {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.card-body { padding: 20px; }

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.action-card {
    padding: 20px;
    border-radius: var(--radius);
    background: var(--bg-white);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    transition: box-shadow var(--transition), transform var(--transition);
}

.action-card:hover:not(.action-card-disabled) {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.action-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 4px; color: var(--primary); }
.action-card p { font-size: 13px; color: var(--text-muted); }

.action-card-disabled {
    opacity: 0.5;
    cursor: default;
}
.action-card-disabled h3 { color: var(--text-muted); }

.action-card a {
    display: block;
    color: inherit;
    text-decoration: none;
}

/* ---------- Tables ---------- */
.table-wrap {
    background: var(--bg-white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    text-align: left;
    padding: 10px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-muted);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

tbody td {
    padding: 10px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f7fafc; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    gap: 6px;
}

.btn:hover { text-decoration: none; }

.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-light); }

.btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-accent:hover { background: var(--accent-hover); }

.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-hover); }

.btn-outline {
    background: transparent;
    color: #fff;
    border-color: rgba(255,255,255,0.4);
}
.btn-outline:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.6); }

.btn-secondary {
    background: var(--bg-white);
    color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }

.btn-group { display: inline-flex; gap: 6px; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-white);
    color: var(--text);
    transition: border-color var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,54,93,0.1);
}

select.form-control { cursor: pointer; }

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.form-check label { margin-bottom: 0; cursor: pointer; }

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
}

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.badge-active { background: #f0fff4; color: #22543d; }
.badge-inactive { background: #fff5f5; color: #742a2a; }
.badge-admin { background: #ebf8ff; color: #2a4365; }
.badge-locked { background: #fffaf0; color: #7b341e; }

/* ---------- Error Pages ---------- */
.error-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
}

.error-page h1 {
    font-size: 72px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 8px;
}

.error-page p {
    font-size: 16px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

/* ---------- Coming Soon Cards ---------- */
.coming-soon {
    padding: 32px;
    text-align: center;
    color: var(--text-muted);
}
.coming-soon h2 { color: var(--primary); margin-bottom: 8px; }

/* ---------- Search / Filter Bar ---------- */
.filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.search-form {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-input {
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-white);
    color: var(--text);
    width: 320px;
    transition: border-color var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,54,93,0.1);
}

.filter-info {
    font-size: 13px;
    color: var(--text-muted);
}

/* ---------- Upload Card ---------- */
.upload-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}

.upload-card h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 8px;
}

.upload-card p {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.upload-card code {
    background: var(--bg);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 12px;
}

/* ---------- Inline Form Row ---------- */
.form-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.form-inline .form-control {
    width: auto;
}

.form-inline .form-control-sm {
    width: 140px;
}

/* ---------- Tag Badge ---------- */
.tag-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    color: #fff;
}

/* ---------- Pagination ---------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 20px;
}

.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--text);
    border: 1px solid var(--border);
    text-decoration: none;
    transition: all var(--transition);
}

.pagination a:hover { background: var(--bg); text-decoration: none; }
.pagination .active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.pagination .disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* ---------- Table Compact ---------- */
.table-compact td { padding: 8px 16px; }
.text-center { text-align: center; }
.text-nowrap { white-space: nowrap; }
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; }

/* ---------- Badge variants ---------- */
.badge-info { background: #ebf8ff; color: #2a4365; }
.badge-secondary { background: var(--bg); color: var(--text-muted); }

/* ---------- Section heading ---------- */
.section-heading {
    font-size: 15px;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 12px;
}

/* ---------- Utility ---------- */
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-right { text-align: right; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.inline-form { display: inline; }

/* ==========================================================================
   Packing Workspace (Module 4)
   ========================================================================== */

/* ---------- Packing Sidebar ---------- */
.packing-sidebar-batch { padding: 4px 20px 8px; }
.sidebar-batch-name { font-size: 14px; font-weight: 600; color: var(--primary-dark); padding: 4px 0; }

.packing-sidebar-progress { padding: 4px 20px 8px; }
.progress-bar-wrap {
    width: 100%;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 4px;
}
.progress-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.3s ease;
}
.progress-text { font-size: 11px; color: var(--text-muted); }

.pg-sidebar-name { font-size: 13px; }
.pg-sidebar-stats { font-size: 11px; color: var(--text-muted); }

.packing-complete-notice {
    background: #f0fff4;
    color: #22543d;
    border: 1px solid #c6f6d5;
    border-radius: var(--radius);
    padding: 10px;
    text-align: center;
    font-weight: 600;
    font-size: 13px;
    margin-top: 8px;
}

/* ---------- Packing Top Bar ---------- */
.packing-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.packing-scan-area {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.packing-scan-input {
    flex: 1;
    max-width: 500px;
    padding: 12px 16px;
    font-size: 16px;
    border: 2px solid var(--primary);
    border-radius: var(--radius);
    background: var(--bg-white);
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.packing-scan-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(56, 161, 105, 0.2);
}

.packing-actions { display: flex; gap: 8px; }

/* ---------- Packing Header ---------- */
.packing-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 16px;
}
.packing-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--primary-dark);
    margin: 0;
}

/* ---------- Scan Result Panel ---------- */
.scan-result-panel {
    background: var(--bg-white);
    border: 2px solid var(--primary);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    position: relative;
    box-shadow: var(--shadow-md);
}
.scan-result-panel.hidden { display: none; }

.scan-result-topbar {
    position: absolute;
    top: 8px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.scan-rate-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-white);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    padding: 0;
}
.scan-rate-btn:hover {
    border-color: #d69e2e;
    color: #d69e2e;
    background: #fffff0;
}
.close-scan-result {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-muted);
}
.close-scan-result:hover { color: var(--text); }

.scan-loading { color: var(--text-muted); font-style: italic; }
.scan-error { color: var(--danger); }

.scan-product {
    margin-bottom: 12px;
    display: flex;
    gap: 16px;
    align-items: flex-start;
    flex-wrap: wrap;
}
.scan-product:last-child { margin-bottom: 0; }

.scan-product-image {
    flex-shrink: 0;
    width: 100px;
    height: 100px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: #fafafa;
    display: flex;
    align-items: center;
    justify-content: center;
}
.scan-product-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.scan-product-info { flex: 1; min-width: 0; }

.scan-product-title { font-size: 15px; font-weight: 600; color: var(--primary-dark); margin-bottom: 4px; }
.scan-product-meta {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 4px;
    flex-wrap: wrap;
}
.scan-product-progress { font-size: 13px; margin-bottom: 8px; }

.badge-stickerless {
    background: #fef3c7;
    color: #92400e;
    padding: 5px 14px;
    border-radius: 14px;
    font-size: 17px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.scan-assign-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 8px 0 0;
    width: 100%;
}
.scan-assign-row label { font-size: 13px; font-weight: 500; }

.assign-qty {
    width: 60px !important;
    padding: 6px 8px;
    text-align: center;
}

.assign-box-select { width: 140px !important; padding: 6px 8px; }

.scan-divider-row { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 8px; }
.scan-row-divider {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
    margin-right: 4px;
}

.new-boxes-qty, .new-boxes-count,
.bulk-inline-qty, .bulk-inline-from, .bulk-inline-to { width: 55px !important; padding: 6px 8px; text-align: center; }

/* ---------- Compliance Summary ---------- */
.compliance-summary {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 13px;
}

.compliance-group {
    padding: 6px 0;
    border-top: 1px solid var(--border);
    margin-top: 6px;
}

.compliance-icon { margin-right: 6px; }
.compliance-compliant { color: #22543d; }
.compliance-warning { color: #7b341e; }
.compliance-too_few { color: #2a4365; }

/* ---------- Pack Group Items Panel ---------- */
.pack-group-items-panel {
    margin-bottom: 16px;
}
.pack-group-items-panel summary { outline: none; }

.row-complete { opacity: 0.5; }
.text-remaining { color: var(--accent); font-weight: 600; }

/* ---------- Pack Group Item Action Buttons ---------- */
.pg-item-actions-cell { white-space: nowrap; }

.pg-item-rate-btn,
.pg-item-print-btn,
.pg-item-pack-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-white);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    padding: 0;
    vertical-align: middle;
}
.pg-item-rate-btn:hover {
    border-color: #d69e2e;
    color: #d69e2e;
    background: #fffff0;
}
.pg-item-rate-btn.rated {
    color: #d69e2e;
    border-color: #d69e2e;
    background: #fffff0;
}
.pg-item-print-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #ebf4ff;
}
.pg-item-pack-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: #f0fff4;
}
.pg-item-rate-btn { margin-right: 2px; }
.pg-item-pack-btn { margin-left: 4px; }

/* ---------- Rating Popup ---------- */
.rating-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.rating-popup {
    background: var(--bg-white);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.18);
    padding: 24px 28px;
    min-width: 320px;
    max-width: 400px;
    text-align: center;
}
.rating-popup-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}
.rating-popup-msku {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
}
.rating-popup-scale {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-bottom: 16px;
}
.rating-popup-btn {
    width: 36px;
    height: 36px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    transition: all 0.12s ease;
}
.rating-popup-btn:hover {
    border-color: #d69e2e;
    background: #fffff0;
    transform: scale(1.1);
}
.rating-popup-btn.selected {
    border-color: #d69e2e;
    background: #d69e2e;
    color: #fff;
    transform: scale(1.12);
}
.rating-popup-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 14px;
    padding: 0 2px;
}
.rating-popup-info {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 12px;
}
.rating-popup-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
}
.rating-popup-actions .btn { min-width: 80px; }

/* ---------- Pack Group Item Filters ---------- */
.pg-item-filters {
    display: flex;
    gap: 0;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    width: fit-content;
}

.pg-filter-btn {
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    background: var(--bg);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    border-right: 1px solid var(--border);
}
.pg-filter-btn:last-child { border-right: none; }
.pg-filter-btn:hover { background: #e2e8f0; color: var(--text); }
.pg-filter-btn.active {
    background: var(--primary);
    color: #fff;
}

/* ---------- Pack Group Item Thumbnails ---------- */
.pg-item-img-cell { width: 40px; padding: 4px 8px !important; }
.pg-item-thumb {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 3px;
    border: 1px solid var(--border);
    background: #fafafa;
}

/* ---------- Sortable Column Headers ---------- */
.sortable { cursor: pointer; user-select: none; }
.sortable:hover { color: var(--primary); }

/* ---------- UPC Multi Dropdown ---------- */
.upc-multi {
    position: relative;
    cursor: pointer;
}

.upc-more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 1px 5px;
    margin-left: 4px;
}

.upc-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 100;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 6px 0;
    min-width: 140px;
    margin-top: 4px;
}

.upc-multi:focus .upc-dropdown,
.upc-multi:hover .upc-dropdown {
    display: flex;
    flex-direction: column;
}

.upc-dropdown-item {
    padding: 4px 12px;
    font-size: 13px;
    font-family: monospace;
    white-space: nowrap;
}
.upc-dropdown-item:hover { background: var(--bg); }

/* ---------- Box Grid ---------- */
.box-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 12px;
    padding-bottom: 80px;
}

.box-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: border-color var(--transition);
}

.box-card.box-compliant { border-color: #48bb78; border-width: 2px; background: #f0fff4; }
.box-card.box-compliant .box-header { background: #e6ffed; }
.box-card.box-warning { border-color: #ed8936; border-width: 2px; background: #fffaf0; }
.box-card.box-warning .box-header { background: #fff5e6; }
.box-card.box-too-few { border-color: #fc8181; border-width: 2px; background: #fff5f5; }
.box-card.box-too-few .box-header { background: #ffecec; }

.box-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.box-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

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

.badge-group {
    background: #ebf8ff;
    color: #2a4365;
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 600;
}

.box-actions { display: flex; gap: 4px; }

/* ---------- Box Dimensions (click-to-edit) ---------- */
.box-dims {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.dim-label { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.dim-display {
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    min-width: 24px;
    text-align: center;
    transition: background var(--transition);
}
.dim-display:hover { background: #edf2f7; }
.dim-sep { color: var(--text-muted); font-size: 11px; }
.dim-unit { font-size: 11px; color: var(--text-muted); }

.dim-edit {
    width: 50px;
    padding: 2px 4px;
    font-size: 13px;
    text-align: center;
    border: 1px solid var(--primary);
    border-radius: 3px;
}

/* ---------- Box Items ---------- */
.box-items-list { padding: 4px 0; }

.box-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 12px;
    font-size: 13px;
    border-bottom: 1px solid #f1f5f9;
}
.box-item-row:last-child { border-bottom: none; }

.box-item-info {
    display: flex;
    gap: 8px;
    align-items: baseline;
    overflow: hidden;
    flex: 1;
    min-width: 0;
}
.box-item-msku { font-weight: 600; white-space: nowrap; }
.box-item-title { color: var(--text-muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.box-item-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
/* .box-item-qty replaced by .box-item-qty-input (editable) */

.box-empty {
    padding: 16px 12px;
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    font-size: 13px;
}

.no-boxes-placeholder {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

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

.modal-content {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    width: 420px;
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-wide { width: 600px; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 600; color: var(--primary-dark); margin: 0; }

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0 4px;
}
.modal-close:hover { color: var(--text); }

.modal-body { padding: 20px; }
.modal-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.dim-inputs-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.dim-modal-input { width: 80px !important; text-align: center; }

/* ---------- Bulk Assign ---------- */
.bulk-info {
    display: flex;
    gap: 12px;
    align-items: baseline;
    margin-bottom: 12px;
    font-size: 14px;
}

.bulk-box-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.bulk-range-label { font-size: 12px; color: var(--text-muted); }
.bulk-range-start, .bulk-range-end { width: 50px !important; text-align: center; }

.bulk-box-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-height: 200px;
    overflow-y: auto;
    padding: 4px 0;
}

.bulk-box-option {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background var(--transition);
}
.bulk-box-option:hover { background: var(--bg); }
.bulk-box-option input[type="checkbox"] { width: 14px; height: 14px; }

.bulk-preview {
    padding: 8px 0;
    font-size: 13px;
    font-weight: 500;
}

/* ---------- Toast Notifications ---------- */
#toast-container {
    position: fixed;
    top: 60px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.packing-toast {
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    box-shadow: var(--shadow-md);
    transition: opacity 0.3s ease;
    max-width: 360px;
}

.packing-toast-success { background: #f0fff4; color: #22543d; border: 1px solid #c6f6d5; }
.packing-toast-error { background: #fff5f5; color: #742a2a; border: 1px solid #fed7d7; }
.packing-toast-info { background: #ebf8ff; color: #2a4365; border: 1px solid #bee3f8; }

/* ---------- Muted button (for secondary actions) ---------- */
.btn-muted {
    background: transparent;
    color: var(--text-muted);
    border-color: transparent;
    font-size: 10px;
    padding: 2px 6px;
    opacity: 0.6;
}
.btn-muted:hover { opacity: 1; background: var(--bg); border-color: var(--border); }

/* ---------- Tag Badge Large (prominent) ---------- */
.tag-badge-lg {
    display: inline-flex;
    align-items: center;
    padding: 5px 14px;
    border-radius: 14px;
    font-size: 17px;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

/* ---------- Scan Result Tags ---------- */
.scan-product-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.scan-product-title-link {
    color: var(--primary-dark);
    text-decoration: none;
}
.scan-product-title-link:hover { text-decoration: underline; color: var(--info); }

/* ---------- Scan row label (non-italic) ---------- */
.scan-row-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-right: 4px;
}

/* ---------- Box Item Editable Qty ---------- */
.box-item-qty-input {
    width: 48px;
    padding: 2px 4px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    color: var(--primary);
    border: 1px solid transparent;
    border-radius: 3px;
    background: transparent;
    transition: border-color var(--transition), background var(--transition);
    -moz-appearance: textfield;
}
.box-item-qty-input::-webkit-inner-spin-button,
.box-item-qty-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.box-item-qty-input:hover { border-color: var(--border); background: #f7fafc; }
.box-item-qty-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-white);
    box-shadow: 0 0 0 2px rgba(26,54,93,0.1);
}

/* ---------- Box Item Title Link ---------- */
a.box-item-title {
    color: var(--text-muted);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-decoration: none;
}
a.box-item-title:hover { text-decoration: underline; color: var(--info); }

/* ---------- Floating Action Buttons (FABs) ---------- */
.packing-fab-group {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 8px;
    z-index: 900;
}

.packing-fab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    border-radius: 24px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: all var(--transition);
}

.packing-fab-history {
    background: var(--primary);
    color: #fff;
}
.packing-fab-history:hover { background: var(--primary-light); box-shadow: 0 4px 12px rgba(0,0,0,0.2); }

.packing-fab-undo {
    background: var(--warning);
    color: #fff;
}
.packing-fab-undo:hover { background: #c05621; box-shadow: 0 4px 12px rgba(0,0,0,0.2); }

/* ---------- History Panel ---------- */
.history-panel {
    position: fixed;
    bottom: 70px;
    right: 20px;
    width: 380px;
    max-height: 400px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
    z-index: 950;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.history-panel.hidden { display: none; }

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    font-size: 14px;
}

.close-history {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0 4px;
}
.close-history:hover { color: var(--text); }

.history-list {
    overflow-y: auto;
    flex: 1;
    max-height: 340px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 13px;
    border-bottom: 1px solid #f1f5f9;
}
.history-item:last-child { border-bottom: none; }

.history-icon {
    width: 20px;
    text-align: center;
    font-weight: 700;
    flex-shrink: 0;
}

.history-desc { flex: 1; }

.history-time {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.history-loading, .history-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    font-size: 13px;
}

/* ==========================================================================
   v6c Design: Navbar Nav Links + Avatar
   ========================================================================== */

.navbar-logo-accent { color: #68d391; }
.navbar-logo-img { height: 70px; width: auto; display: block; }

.navbar-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.navbar-nav-link {
    color: rgba(255,255,255,.65);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: 20px;
    transition: all 0.15s;
}
.navbar-nav-link:hover { color: #fff; background: rgba(255,255,255,.1); text-decoration: none; }
.navbar-nav-link.active { color: #fff; background: rgba(255,255,255,.18); font-weight: 600; }

.navbar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    letter-spacing: .5px;
}

/* ==========================================================================
   v6c Design: Packing Page — Dark Sidebar
   ========================================================================== */

.packing-page .sidebar {
    background: #1a1f2e;
    border-right: none;
    width: 250px;
}

.packing-sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.packing-sidebar-brand {
    padding: 8px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.06);
    margin-bottom: 16px;
}
.packing-sidebar-logo-img { height: 44px; width: auto; display: block; }

.packing-sidebar-section { padding: 0 16px; margin-bottom: 18px; }
.packing-sidebar-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,.35);
    margin-bottom: 10px;
    font-weight: 700;
    padding: 0 4px;
}

/* Pack group cards */
.packing-pg-card {
    display: block;
    text-decoration: none;
    background: rgba(255,255,255,.04);
    border: 1px solid rgba(255,255,255,.06);
    border-radius: 8px;
    padding: 12px 14px 10px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all .15s;
}
.packing-pg-card:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.packing-pg-card.active { background: rgba(99,179,237,.08); border-color: rgba(99,179,237,.35); }

.packing-pg-card-name {
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.packing-pg-code {
    font-size: 10px;
    font-weight: 600;
    color: rgba(255,255,255,.4);
    background: rgba(255,255,255,.08);
    padding: 1px 6px;
    border-radius: 4px;
}
.packing-pg-card-stat { font-size: 11px; color: rgba(255,255,255,.5); margin-bottom: 6px; }
.packing-pg-progress-track { height: 8px; background: rgba(255,255,255,.08); border-radius: 4px; overflow: hidden; }
.packing-pg-progress-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, #3182ce, #48bb78); transition: width .4s ease; }

/* Batch info */
.packing-sidebar-batch-info { padding: 0 4px; }
.packing-sidebar-batch-name { font-size: 14px; font-weight: 700; color: #fff; margin-bottom: 6px; }
.packing-sidebar-detail { font-size: 12px; color: rgba(255,255,255,.45); margin-bottom: 3px; }
.packing-sidebar-detail strong { color: rgba(255,255,255,.7); font-weight: 600; }
.packing-sidebar-pill {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
}
.packing-sidebar-pill-high { background: rgba(245,101,101,.2); color: #fc8181; }
.packing-sidebar-pill-normal { background: rgba(160,174,192,.2); color: #a0aec0; }
.packing-sidebar-pill-packing { background: rgba(72,187,120,.2); color: #68d391; }

/* Sidebar action buttons */
.packing-sidebar-actions { margin-top: auto; padding: 0 16px 12px; }
.packing-sidebar-btn {
    display: block;
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all .15s;
    margin-bottom: 8px;
    text-decoration: none;
}
.packing-sidebar-btn:hover { text-decoration: none; }
.packing-sidebar-btn-primary { background: #38a169; color: #fff; }
.packing-sidebar-btn-primary:hover { background: #2f855a; color: #fff; }
.packing-sidebar-btn-ghost { background: transparent; color: rgba(255,255,255,.5); border: 1px solid rgba(255,255,255,.12); }
.packing-sidebar-btn-ghost:hover { background: rgba(255,255,255,.05); color: rgba(255,255,255,.7); }

/* Adjust main content for wider sidebar on packing page */
.packing-page .main-content { padding: 20px 28px; }

/* ==========================================================================
   v6c Design: Packing Page — Scan Bar Last Scan Indicator
   ========================================================================== */

.packing-last-scan {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    flex-shrink: 0;
}

.packing-last-scan-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #48bb78;
    flex-shrink: 0;
    animation: packing-pulse-dot 2s ease-in-out infinite;
}

@keyframes packing-pulse-dot {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(72,187,120,.5); }
    50% { opacity: .7; box-shadow: 0 0 0 4px rgba(72,187,120,0); }
}

.packing-last-scan-label { font-size: 12px; color: var(--text-muted); }
.packing-last-scan-msku { font-size: 13px; color: var(--text); }
.packing-last-scan-box { font-size: 12px; color: var(--text-muted); }
.packing-last-scan-time { font-size: 11px; color: #a0aec0; }

/* ==========================================================================
   v6c Design: Packing Page — Stat Cards
   ========================================================================== */

.packing-stat-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 12px;
}

.packing-stat-card {
    background: var(--bg-white);
    border-radius: 8px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 14px 16px 12px;
    position: relative;
    overflow: hidden;
}
.packing-stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}
.packing-stat-total::before { background: #3182ce; }
.packing-stat-group::before { background: #38a169; }
.packing-stat-ebr::before { background: #319795; }

.packing-stat-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .7px;
    color: #a0aec0;
    font-weight: 700;
    margin-bottom: 4px;
}

.packing-stat-value {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 6px;
}
.packing-stat-big { font-size: 28px; font-weight: 800; color: var(--primary); line-height: 1; }
.packing-stat-of { font-size: 13px; color: var(--text-muted); }
.packing-stat-pct { font-size: 12px; font-weight: 700; color: #4a5568; margin-left: auto; }

.packing-stat-bar-track { height: 6px; background: #edf2f7; border-radius: 3px; overflow: hidden; margin-bottom: 6px; }
.packing-stat-bar-fill { height: 100%; border-radius: 3px; }
.packing-stat-bar-blue { background: linear-gradient(90deg, #3182ce, #63b3ed); }
.packing-stat-bar-green { background: linear-gradient(90deg, #38a169, #68d391); }

.packing-stat-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    background: #fefcbf;
    color: #b7791f;
}

.packing-stat-ebr-status { margin-bottom: 6px; }
.packing-stat-ebr-pill {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 10px;
}
.packing-stat-ebr-pill.compliant { background: #c6f6d5; color: #276749; }
.packing-stat-ebr-pill.warning { background: #feebc8; color: #c05621; }
.packing-stat-ebr-pill.info { background: #bee3f8; color: #2b6cb0; }
.packing-stat-ebr-pill.none { background: #edf2f7; color: #a0aec0; }
.packing-stat-ebr-detail { font-size: 11px; color: var(--text-muted); line-height: 1.4; }

/* ==========================================================================
   v6c Design: Packing Page — EBR Detail Banner
   ========================================================================== */

.packing-ebr-banner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: #f0fff4;
    border: 1px solid #c6f6d5;
    border-left: 4px solid #38a169;
    border-radius: 6px;
    padding: 10px 16px;
    margin-bottom: 16px;
    font-size: 13px;
    color: #276749;
}

.packing-ebr-banner-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #38a169;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
}

.packing-ebr-banner strong { color: #22543d; }
