:root {
    --kv-blue-main: #1a56b6; --kv-blue-hover: #12408d;
    --kv-green-btn: #4bac4d; --kv-green-hover: #3d8b3e;
    --kv-bg-body: #f4f6f9; --border-color: #e2e5e9;
    --text-main: #2c3e50; --text-muted: #7f8c8d;
}
* { box-sizing: border-box; }
body { background: var(--kv-bg-body); color: var(--text-main); font-family: 'Roboto', Arial, sans-serif; font-size: 13px; display: flex; flex-direction: column; height: 100vh; overflow: hidden; margin: 0; padding: 0; }

/* LOGIN */
#login-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(135deg, rgba(26,86,182,0.9) 0%, rgba(0,210,255,0.9) 100%), url('https://images.unsplash.com/photo-1586528116311-ad8ed7c83a7f?q=80&w=2000&auto=format&fit=crop') center/cover; display: flex; justify-content: center; align-items: center; z-index: 99999; }
.login-card { background: #fff; width: 400px; padding: 40px 30px; border-radius: 12px; box-shadow: 0 15px 35px rgba(0,0,0,0.2); text-align: center; }
.login-logo { font-size: 28px; color: var(--kv-blue-main); font-weight: 700; margin-bottom: 5px; }
.login-logo i { color: #00d2ff; }
.login-subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 30px; }
.login-input { width: 100%; padding: 12px 15px; margin-bottom: 15px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; outline: none; transition: 0.3s; }
.login-input:focus { border-color: var(--kv-blue-main); box-shadow: 0 0 0 3px rgba(26,86,182,0.1); }
.btn-login { width: 100%; padding: 12px; background: var(--kv-blue-main); color: #fff; border: none; border-radius: 6px; font-size: 15px; font-weight: bold; cursor: pointer; transition: 0.3s; }
.btn-login:hover { background: var(--kv-blue-hover); transform: translateY(-2px); }

/* TOPBAR */
.kv-topbar-white { background: #fff; height: 40px; display: flex; justify-content: space-between; align-items: center; padding: 0 25px; border-bottom: 1px solid #e0e0e0; z-index: 10; }
.kv-logo-area { display: flex; align-items: center; font-size: 17px; font-weight: 700; color: var(--kv-blue-main); letter-spacing: 0.5px; }
.kv-logo-area i { font-size: 22px; margin-right: 8px; color: #00d2ff; }
.kv-topbar-right { display: flex; align-items: center; gap: 15px; font-size: 13px; }

/* APP LAYOUT & SIDEBAR */
.app-body-layout { display: flex; height: calc(100vh - 40px); overflow: hidden; }
.sidebar-left-nav { 
    background: var(--kv-blue-main); 
    width: 230px; 
    display: flex; 
    flex-direction: column; 
    flex-shrink: 0; 
    box-shadow: 2px 0 5px rgba(0,0,0,0.1); 
    z-index: 9; 
    overflow-y: auto;
    transition: width 0.3s ease; 
    overflow-x: hidden;          
    white-space: nowrap;         
}
.sidebar-left-nav.collapsed { width: 60px; }
.sidebar-left-nav .kv-nav-item { color: rgba(255,255,255,0.75); padding: 16px 20px; cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.2s; border-left: 4px solid transparent; display: flex; align-items: center; }
.sidebar-left-nav .kv-nav-item i { margin-right: 12px; font-size: 16px; width: 20px; text-align: center; }
.sidebar-left-nav .kv-nav-item:hover { background: var(--kv-blue-hover); color: #fff; }
.sidebar-left-nav .kv-nav-item.active { background: var(--kv-blue-hover); color: #fff; border-left-color: #00d2ff; }

.role-admin, .role-staff, .role-client { display: none; }
.main-wrapper { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* BARS & BUTTONS */
.kv-action-bar { background: #fff; height: 55px; display: flex; justify-content: space-between; align-items: center; padding: 0 20px; border-bottom: 1px solid var(--border-color); box-shadow: 0 1px 3px rgba(0,0,0,0.03); flex-shrink: 0; }
.kv-page-title { font-size: 18px; font-weight: 700; margin: 0; color: var(--text-main); text-transform: uppercase; }
.btn-kv-green { background: var(--kv-green-btn); color: #fff; border: none; border-radius: 4px; padding: 7px 16px; font-weight: 600; font-size: 13px; cursor: pointer; }
.btn-kv-green:hover { background: var(--kv-green-hover); }
.btn-kv-outline { background: #fff; border: 1px solid #ced4da; color: var(--text-main); border-radius: 4px; padding: 7px 14px; font-size: 13px; font-weight: 500; cursor: pointer; }
.btn-kv-outline:hover { background: #f8f9fa; border-color: #adb5bd; }

/* SPLIT LAYOUT */
.kv-layout-split { display: flex; height: 100%; overflow: hidden; padding: 15px; gap: 15px; }
.kv-sidebar-left { width: 280px; background: #fff; border: 1px solid var(--border-color); border-radius: 6px; display: flex; flex-direction: column; overflow-y: auto; flex-shrink: 0; box-shadow: 0 2px 8px rgba(0,0,0,0.03); }
.kv-filter-header { background: #f8f9fa; padding: 12px 15px; font-weight: 700; border-bottom: 1px solid var(--border-color); font-size: 14px; color: var(--kv-blue-main); }
.kv-filter-body { padding: 15px; }
.kv-content-right { flex: 1; background: #fff; border: 1px solid var(--border-color); border-radius: 6px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.03); }

/* FORMS */
.kv-input-group { margin-bottom: 15px; }
.kv-label { display: block; font-weight: 600; margin-bottom: 6px; color: #34495e; font-size: 12px; }
.kv-input { width: 100%; border: 1px solid #ced4da; padding: 8px 12px; border-radius: 4px; font-size: 13px; outline: none; transition: all 0.2s; }
.kv-input:focus { border-color: var(--kv-blue-main); box-shadow: 0 0 0 3px rgba(26, 86, 182, 0.1); }
.kv-input[readonly] { background: #f8f9fa; color: var(--text-muted); cursor: not-allowed; }
select.kv-input { appearance: auto; }

/* TABLES */
.kv-table-wrap { flex: 1; overflow: auto; }
.kv-table { width: 100%; border-collapse: collapse; text-align: left; }
.kv-table th { position: sticky; top: 0; background: #f4f6f9; padding: 12px 10px; font-weight: 700; border-bottom: 2px solid #e2e5e9; color: #2c3e50; white-space: nowrap; z-index: 10; font-size: 12px; text-transform: uppercase; }
.kv-table td { padding: 10px; border-bottom: 1px solid #edf2f7; vertical-align: middle; font-size: 13px; }
.kv-table tr:hover td { background-color: #f8faff !important; }

/* KPIs & CHARTS */
.kpi-wrapper { display: flex; gap: 15px; margin-bottom: 15px; }
.kpi-box { flex: 1; background: #fff; border: 1px solid var(--border-color); border-radius: 6px; padding: 20px; display: flex; align-items: center; gap: 15px; box-shadow: 0 2px 8px rgba(0,0,0,0.03); transition: transform 0.2s; }
.kpi-box:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.05); }
.kpi-icon { width: 48px; height: 48px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 20px; flex-shrink: 0; }
.kpi-box h3 { margin: 0; font-size: 24px; font-weight: 700; }
.kpi-box span { font-size: 13px; color: var(--text-muted); display: block; margin-bottom: 5px; font-weight: 500; }
.chart-box { background: #fff; border: 1px solid var(--border-color); padding: 20px; border-radius: 6px; box-shadow: 0 2px 8px rgba(0,0,0,0.03); }

/* VIEWS & MISC */
.view-section { display: none; height: 100%; flex-direction: column; }
.view-section.active { display: flex; animation: fadeIn 0.2s ease-in-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
#toast-msg { display: none; position: fixed; top: 90px; right: 20px; z-index: 9999; padding: 12px 24px; border-radius: 4px; color: #fff; font-weight: bold; font-size: 13px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.barcode-wrap svg { width: 100%; height: 50px; object-fit: contain; }
.scan-focus { border: 2px solid var(--kv-green-btn) !important; background: #e8f5e9 !important; color: var(--kv-green-btn) !important; font-size: 16px !important; font-weight: bold; }
.gmap-section { display: none; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border-color); }
.gmap-section.active { display: block; }
.staff-mode-pane { display: none; }
.staff-mode-pane.active { display: block; }

/* SKU AUTOCOMPLETE */
.sku-autocomplete-wrap { position: relative; }
.sku-autocomplete-list { position: absolute; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--border-color); border-top: none; border-radius: 0 0 4px 4px; z-index: 9999; max-height: 260px; overflow-y: auto; box-shadow: 0 6px 18px rgba(0,0,0,0.12); display: none; }
.sku-item { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid #f0f0f0; }
.sku-item:hover { background: #f0f4ff; }
.sku-item-code { font-weight: 700; color: #1a56b6; font-size: 13px; }
.sku-item-name { font-size: 12px; color: #666; margin-top: 2px; }

/* ACCOUNT MANAGEMENT */
.acc-role-badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.acc-role-ADMIN { background: #fff3cd; color: #856404; border: 1px solid #ffc107; }
.acc-role-STAFF { background: #d1ecf1; color: #0c5460; border: 1px solid #17a2b8; }
.acc-role-CLIENT { background: #d4edda; color: #155724; border: 1px solid #28a745; }
.acc-status-active { color: #28a745; font-weight: bold; }
.acc-status-inactive { color: #dc3545; font-weight: bold; }

/* TRACKASIA */
.ta-autocomplete-wrap { position: relative; }
.ta-autocomplete-list { position: absolute; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--border-color); border-top: none; border-radius: 0 0 4px 4px; z-index: 9999; max-height: 280px; overflow-y: auto; box-shadow: 0 6px 18px rgba(0,0,0,0.12); display: none; }
.ta-item { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid #f0f0f0; transition: background 0.12s; }
.ta-item:last-child { border-bottom: none; }
.ta-item:hover { background: #f0f4ff; }
.ta-item-main { font-weight: 600; color: #2064ce; font-size: 13px; }
.ta-item-sub { font-size: 11.5px; color: #666; margin-top: 1px; }
.ta-loading, .ta-no-result { padding: 10px 12px; color: #999; font-size: 12px; text-align: center; }

/* IN ẤN */
#print-area, #print-barcode-area, #print-audit-area { display: none; }
@media print {
    body * { visibility: hidden !important; } .no-print { display: none !important; }
    body.print-mode-trans #print-area, body.print-mode-trans #print-area * { visibility: visible !important; }
    body.print-mode-trans #print-area { display: block !important; position: absolute; left: 0; top: 0; width: 100%; }
    body.print-mode-audit #print-audit-area, body.print-mode-audit #print-audit-area * { visibility: visible !important; }
    body.print-mode-audit #print-audit-area { display: block !important; position: absolute; top: 0; left: 0; width: 100%; }
    body.print-mode-barcode #print-barcode-area, body.print-mode-barcode #print-barcode-area * { visibility: visible !important; }
    body.print-mode-barcode #print-barcode-area { display: flex !important; position: absolute; left: 0; top: 0; width: 100%; justify-content: flex-start; align-items: flex-start; background: #fff; }
    .print-label-box { width: 50mm; height: 30mm; border: 1px dashed #ccc !important; padding: 2mm; box-sizing: border-box; display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; text-align: center; page-break-inside: avoid; }
    .print-label-box h3 { font-size: 10px !important; margin: 0 0 2px 0; font-family: Arial, sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; color: #000; }
    .print-label-box h2 { font-size: 12px !important; margin: 2px 0 0 0; font-family: monospace; font-weight: bold; letter-spacing: 0.5px; color: #000; }
    .print-label-box svg { max-width: 100%; max-height: 14mm !important; }
    @page { size: auto; margin: 0mm; }
}
/* FIX BUG 2: Sidebar collapse - ẩn label text */
.sidebar-left-nav.collapsed .nav-label {
    display: none;
}
.sidebar-left-nav.collapsed .kv-nav-item {
    justify-content: center;
    padding: 16px 0;
    border-left: 4px solid transparent;
}
.sidebar-left-nav.collapsed .kv-nav-item i {
    margin-right: 0;
}
.sidebar-left-nav.collapsed .kv-nav-item.active {
    border-left-color: #00d2ff;
}
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 3px; }