/* ============================================================
   FFM 669HN - Kin Kin Logistics Brand CSS
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;600;700&display=swap');

:root {
    --primary-color: #E31E24;
    --primary-hover: #C41A1F;
    --primary-soft: #FDEAEA;
    --bg-color: #F4F4F4;
    --card-bg: #FFFFFF;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-muted: #999999;
    --border-color: #DEE2E6;
    --border-light: #EEEEEE;
    --success-color: #28A745;
    --warning-color: #FFC107;
    --danger-color: #E31E24;
    --info-color: #0E7490;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; }

body {
    margin: 0; padding: 0;
    font-family: 'Roboto', 'Montserrat', Arial, sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-color);
    line-height: 1.5;
}

/* ============ LOGIN ============ */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-color);
}
.login-box {
    width: 100%;
    max-width: 400px;
    background: var(--card-bg);
    border-top: 4px solid var(--primary-color);
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    padding: 32px 28px;
    border-radius: 6px;
}
.login-logo {
    text-align: center;
    margin-bottom: 20px;
}
.login-logo img {
    max-width: 200px;
    height: auto;
}
.login-title {
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 24px;
}

/* ============ APP HEADER ============ */
.app-header {
    background: var(--card-bg);
    border-bottom: 2px solid var(--primary-color);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.app-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.app-header-left img {
    height: 36px;
}
.app-header-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}
.app-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
}
.app-header-right .user-name {
    font-weight: 600;
    color: var(--text-primary);
}

/* ============ MAIN CONTAINER ============ */
.app-container {
    display: flex;
    height: calc(100vh - 54px);
    gap: 8px;
    padding: 8px;
}

/* ============ OD SUB-TAB BAR (mobile only) ============ */
.od-tab-bar {
    display: none;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    position: sticky;
    top: 0;
    z-index: 50;
}
.od-tab {
    flex: 1;
    padding: 10px 8px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.od-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}
.od-tab-badge {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--primary-color);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
}

/* ============ PANEL TRÁI ============ */
.panel-left {
    flex: 0 0 33%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
    max-width: 440px;
}

/* ============ PANEL PHẢI ============ */
.panel-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
}

/* ============ CARDS ============ */
.card {
    background: var(--card-bg);
    border-radius: 6px;
    padding: 12px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-light);
}
.card.fill {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}
.card-title {
    font-weight: 700;
    font-size: 14px;
    color: var(--primary-color);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 6px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ============ FIELD ERROR ============ */
.field-error {
    margin-top: 4px;
    padding: 5px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    background: #f8d7da;
    color: #842029;
    border-left: 3px solid #E31E24;
    animation: shake 0.3s ease-in-out;
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* ============ FORM ============ */
.form-group { margin-bottom: 8px; }
.form-group label {
    display: block;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 3px;
    font-size: 12px;
}
.form-control {
    width: 100%;
    padding: 8px 10px;
    border: 1.5px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(227,30,36,0.15);
}
textarea.form-control {
    resize: none;
    min-height: 60px;
}
.input-group {
    display: flex;
    gap: 4px;
}
.input-group .form-control { flex: 1; }

/* ============ BUTTONS ============ */
.btn {
    padding: 8px 14px;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}
.btn-primary { background: var(--primary-color); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); box-shadow: 0 2px 6px rgba(227,30,36,0.3); }
.btn-success { background: var(--success-color); color: #fff; }
.btn-success:hover { background: #1e7e34; }
.btn-warning { background: #ef6c00; color: #fff; }
.btn-warning:hover { background: #c55600; }
.btn-secondary { background: #e9ecef; color: var(--text-primary); }
.btn-secondary:hover { background: #dde0e3; }
.btn-outline {
    background: transparent;
    color: var(--primary-color);
    border: 1.5px solid var(--primary-color);
}
.btn-outline:hover { background: var(--primary-soft); }
.btn-block { width: 100%; }
.btn-icon {
    background: transparent;
    color: var(--primary-color);
    padding: 4px 8px;
    font-size: 16px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}
.btn-icon:hover { background: var(--primary-soft); border-color: var(--primary-color); }
.btn-scan {
    background: var(--primary-soft);
    color: var(--primary-color);
    border: 1.5px solid var(--primary-color);
    font-size: 18px;
    padding: 6px 10px;
    border-radius: 4px;
    min-width: 42px;
    min-height: 42px;
}
.btn-scan:hover { background: var(--primary-color); color: #fff; }

.btn-clear-input {
    background: #fff;
    color: var(--text-muted);
    border: 1.5px solid var(--border-color);
    font-size: 16px;
    padding: 6px 10px;
    border-radius: 4px;
    min-width: 38px;
    min-height: 42px;
}
.btn-clear-input:hover { background: #dc3545; color: #fff; border-color: #dc3545; }

.btn-camera {
    background: #fff;
    color: #198754;
    border: 1.5px solid #198754;
    font-size: 18px;
    padding: 6px 10px;
    border-radius: 4px;
    min-width: 42px;
    min-height: 42px;
}
.btn-camera:hover { background: #198754; color: #fff; }

/* ============ STATUS ============ */
.status {
    margin-top: 6px;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    min-height: 16px;
}
.status.info { background: #e3f2fd; color: #0d47a1; }
.status.ok   { background: #d9ecd9; color: #1b5e20; }
.status.warn { background: #fff3cd; color: #7d5e0d; }
.status.err  { background: #f8d7da; color: #842029; }

/* ============ TABLES ============ */
.table-wrap {
    flex: 1;
    overflow: auto;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    min-height: 0;
}
table.main-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
table.main-table th {
    background: #f8f9fa;
    padding: 6px 5px;
    text-align: left;
    font-weight: 700;
    color: var(--text-primary);
    position: sticky;
    top: 0;
    z-index: 5;
    border-bottom: 2px solid var(--primary-color);
    white-space: nowrap;
    font-size: 11px;
}
table.main-table td {
    padding: 5px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}
table.main-table tr:hover td { background: #fef2f2; }
tr.checked td { background: #fff8e0 !important; }
tr.warned td { background: #fff3cd !important; }
tr.da-luu td { background: #d9ecd9 !important; }
tr.da-luu:hover td { background: #c5e0c5 !important; }

td.cell-check { text-align: center; width: 30px; }
td.cell-check input { width: 16px; height: 16px; cursor: pointer; }
td.cell-input input {
    width: 70px;
    padding: 3px 5px;
    border: 1.5px solid var(--warning-color);
    border-radius: 4px;
    background: #fffdf5;
    font-weight: 600;
    text-align: center;
    font-size: 12px;
}
td.cell-input input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(227,30,36,0.15);
}
td.cell-link a { color: var(--info-color); text-decoration: none; font-weight: 600; }
td.cell-link a:hover { text-decoration: underline; }

/* Mini table (panel trái) */
.kien-table-wrap {
    flex: 1;
    overflow: auto;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    background: #fff;
    min-height: 0;
}
.kien-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.kien-table th {
    background: #f8f9fa;
    padding: 5px 4px;
    text-align: left;
    font-weight: 700;
    color: var(--text-primary);
    position: sticky;
    top: 0;
    z-index: 5;
    border-bottom: 1.5px solid var(--primary-color);
    white-space: nowrap;
}
.kien-table td {
    padding: 4px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80px;
}
.kien-table tr:hover td { background: #fef2f2; }

/* Kiện hôm nay */
.kien-today {
    overflow: auto;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    background: #fafbfc;
    max-height: 120px;
}
.kien-item {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
}
.kien-item:hover { background: #fef2f2; }
.kien-item.doing { border-left: 4px solid #ef6c00; }
.kien-item.done  { border-left: 4px solid var(--success-color); opacity: 0.85; }
.kien-item-name { font-weight: 700; color: var(--text-primary); font-size: 13px; }
.kien-item-stat {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 8px;
    font-weight: 600;
}
.kien-item.doing .kien-item-stat { background: #fff3cd; color: #7d5e0d; }
.kien-item.done .kien-item-stat { background: #d9ecd9; color: #1b5e20; }

/* Badge */
.badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}
.badge-warn { background: #fff3cd; color: #7d5e0d; }
.badge-ok   { background: #d9ecd9; color: #1b5e20; }

/* Action row */
.action-row {
    display: flex;
    gap: 12px;
    align-items: stretch;
}
.action-note { flex: 1.2; display: flex; flex-direction: column; }
.action-note label {
    font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; font-size: 12px;
}
.action-buttons {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.action-buttons .btn {
    font-size: 12px;
    padding: 10px 8px;
    line-height: 1.3;
}

/* Section panels */
.section-result { flex: 1.2; }
.section-action { flex: 0 0 auto; }
.section-saved { flex: 1; }

.summary { font-size: 11px; color: var(--text-muted); }
.empty-state {
    padding: 30px 20px;
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    font-size: 13px;
}
.empty-mini {
    padding: 12px;
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    font-size: 12px;
}

/* Expand detail */
tr.saved-row { cursor: pointer; }
tr.saved-row.expanded td { background: #e3f2fd !important; }
tr.detail-row td {
    padding: 0 !important;
    background: #fafbfc;
    border-bottom: 2px solid var(--border-color);
}
.detail-content {
    padding: 10px 14px;
    font-size: 12px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px 16px;
}
.detail-content .field { display: flex; flex-direction: column; }
.detail-content .lbl { color: var(--text-muted); font-size: 10px; font-weight: 600; text-transform: uppercase; }
.detail-content .val { font-weight: 600; color: var(--text-primary); word-break: break-word; }

/* ============ SCAN WAIT BOX (chờ máy quét) ============ */
.scan-wait-box {
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: #0d1117;
    border-radius: 6px;
    color: #fff;
    text-align: center;
}
.scan-wait-icon {
    font-size: 40px;
    color: #00FF41;
    animation: scanBlink 1s ease-in-out infinite;
}
@keyframes scanBlink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}
.scan-wait-msg {
    font-size: 14px;
    font-weight: 600;
    color: #eee;
}
.scan-wait-sub {
    font-size: 12px;
    color: #aaa;
}
.scan-wait-sub span {
    font-weight: 700;
    color: #00FF41;
    font-size: 14px;
}
.scan-wait-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}
.scan-wait-actions .btn {
    font-size: 12px;
    padding: 6px 10px;
}

/* Canvas overlay khung xanh barcode */
#scan-canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 5;
}

/* Scanner container */
#scanner-container {
    width: 100%;
    overflow: hidden;
    border-radius: 6px;
    margin-top: 8px;
    display: none;
    position: relative;
    background: #000;
}
#scanner-container.active { display: block; }
#scanner-container video,
#scan-video,
#scanner-cam video {
    width: 100% !important;
    height: auto !important;
    max-height: 280px;
    object-fit: cover;
    display: block;
}
#scanner-cam {
    position: relative;
    overflow: hidden;
}
#scanner-cam canvas.drawingBuffer {
    position: absolute;
    top: 0; left: 0;
    width: 100% !important;
    height: 100% !important;
}
/* Đường ngắm scanner */
.scan-overlay {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    pointer-events: none;
    z-index: 10;
    box-shadow: 0 0 0 2000px rgba(0,0,0,0.4);
    animation: scanPulse 1.5s ease-in-out infinite;
}
.scan-overlay::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--primary-color);
    animation: scanLine 1.5s ease-in-out infinite;
}
@keyframes scanPulse {
    0%, 100% { border-color: var(--primary-color); }
    50% { border-color: #ff6b6b; }
}
@keyframes scanLine {
    0% { top: 0; }
    50% { top: calc(100% - 2px); }
    100% { top: 0; }
}
.scan-hint {
    position: absolute;
    bottom: 8px;
    left: 0; right: 0;
    text-align: center;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    z-index: 11;
}
.scan-close {
    position: absolute;
    top: 6px; right: 6px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 30px; height: 30px;
    font-size: 16px;
    cursor: pointer;
    z-index: 12;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============ KKF BADGE ============ */
td.cell-kkf { white-space: nowrap; }
.kkf-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.5px;
    background: #e8f4fd;
    color: #0e5a8a;
    border: 1px solid #b8d9f0;
}
.kkf-pending {
    font-size: 10px;
    color: var(--text-muted);
    font-style: italic;
}

/* ============ INPUT ERROR (validate bắt buộc) ============ */
input.input-error {
    border-color: var(--danger-color) !important;
    background: rgba(227, 30, 36, 0.06) !important;
    animation: shake 0.3s ease-in-out;
}

/* ============ HIGHLIGHT SCAN (scan SP → dòng bảng trái) ============ */
tr.highlight-scan td {
    background: rgba(227, 30, 36, 0.10) !important;
    outline: 2px solid var(--primary-color);
    outline-offset: -1px;
    animation: rowPulse 0.4s ease-out;
}
@keyframes rowPulse {
    0%   { background: rgba(227, 30, 36, 0.35) !important; }
    100% { background: rgba(227, 30, 36, 0.10) !important; }
}

/* ============ NAV TABS ============ */
.nav-tabs {
    display: flex;
    background: #fff;
    border-bottom: 2px solid var(--primary-color);
    padding: 0 16px;
}
.nav-tab {
    padding: 10px 20px;
    border: none;
    background: none;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}
.nav-tab:hover { color: var(--primary-color); }
.nav-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* ============ PAGE CONTENT ============ */
.page-content { display: none; }
.page-content.active { display: block; }

/* ============ KIỆN PAGE ============ */
.kien-page-container { padding: 12px 16px; }
.kien-full-table { width: 100%; font-size: 12px; table-layout: fixed; }
.kien-full-table th { background: #f8f9fa; position: sticky; top: 0; z-index: 2; }
.kien-full-table td, .kien-full-table th { padding: 6px 8px; }
.kien-full-table tr:hover td { background: #f0f7ff; }

/* Fixed widths + truncate để Size/Mã SP dài không đẩy cột khác ra ngoài */
.kien-full-table .kien-col-chk    { width: 32px;  text-align: center; white-space: nowrap; }
.kien-full-table .kien-col-date   { width: 110px; white-space: nowrap; }
.kien-full-table .kien-col-idkh   { width: 90px;  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kien-full-table .kien-col-tenkh  { width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kien-full-table .kien-col-loai   { width: 70px;  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kien-full-table .kien-col-od     { width: 100px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kien-full-table .kien-col-k      { width: 110px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kien-full-table .kien-col-sp     { width: 130px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kien-full-table .kien-col-mau    { width: 80px;  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kien-full-table .kien-col-size   { width: 90px;  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kien-full-table .kien-col-sl     { width: 60px;  text-align: right; white-space: nowrap; }
.kien-full-table .kien-col-status { width: 150px; white-space: nowrap; }
.kien-full-table .kien-col-act    { width: 80px;  white-space: nowrap; text-align: right; }
.status-badge { padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 600; }
.status-badge.chua { background: #ffe0e0; color: #c00; }
.status-badge.dang { background: #fff3cd; color: #856404; }
.status-badge.xong { background: #d4edda; color: #155724; }
.status-badge.canh { background: #ffe6cc; color: #b45f06; }

/* ============ DETAIL MODAL ============ */
.detail-modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 1000;
    display: flex; align-items: flex-start; justify-content: center;
    padding-top: 40px; overflow-y: auto;
}
.detail-modal {
    background: #fff; border-radius: 8px; width: 95%; max-width: 800px;
    max-height: 90vh; display: flex; flex-direction: column;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}
.detail-modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px; border-bottom: 2px solid var(--primary-color);
    font-weight: 700; font-size: 15px;
}
.detail-modal-body { padding: 16px; overflow-y: auto; flex: 1; }
.detail-section { margin-bottom: 16px; }
.detail-section-title {
    font-size: 13px; font-weight: 700; color: var(--primary-color);
    border-bottom: 1px solid #eee; padding-bottom: 4px; margin-bottom: 8px;
}
.detail-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.detail-field { display: flex; flex-direction: column; }
.detail-field .dlbl { font-size: 11px; color: var(--text-muted); }
.detail-field .dval { font-size: 13px; font-weight: 500; padding: 4px 0; }
.detail-field .dval {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.detail-field .dval.expanded {
    white-space: normal;
    word-break: break-all;
    max-width: none;
}
.detail-field .dval.editable {
    cursor: pointer; border-bottom: 1px dashed #ccc;
}
.detail-field .dval.editable:hover { background: #f0f7ff; }
.detail-field .dval.readonly { color: var(--text-muted); font-style: italic; }

/* ============ HISTORY TABLE ============ */
.history-table { width: 100%; font-size: 11px; }
.history-table th { background: #f8f9fa; font-weight: 600; }
.history-table td, .history-table th { padding: 4px 8px; }

/* ============ INLINE EDIT ============ */
.inline-input {
    border: 1px solid var(--primary-color);
    padding: 2px 6px; font-size: 13px; width: 100%;
    border-radius: 3px; outline: none;
}

/* ============ KIỆN K ROW ACTIVE ============ */
.kien-row-active td { background: #e8f5e9 !important; }
.kien-row-active td:first-child::before {
    content: '\2714';
    color: #28a745;
    font-weight: bold;
    margin-right: 2px;
}

/* ============ TEM MỚI (KKF layout) ============ */
.tem-top-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4px;
}
.tem-kkf-text {
    font-size: 16px;
    font-weight: 800;
    font-family: 'Courier New', monospace;
    letter-spacing: 1px;
}
.tem-od-ref {
    font-size: 11px;
    color: #888;
}

/* ============ AUTO-FILL HIGHLIGHT (vd: Kiện K tự gán sau khi search SP) ============ */
@keyframes autoFillPulse {
    0%   { box-shadow: 0 0 0 0   rgba(255,193,7,0.55); background: #fff9db; }
    50%  { box-shadow: 0 0 0 6px rgba(255,193,7,0.10); background: #fff3bf; }
    100% { box-shadow: 0 0 0 0   rgba(255,193,7,0);    background: #fff; }
}
.field-auto-filled {
    animation: autoFillPulse 1.6s ease-out;
    border-color: var(--warning-color) !important;
}

/* ============ TOAST NOTIFICATIONS ============ */
#toast-container {
    position: fixed;
    top: 60px;
    right: 16px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    min-width: 280px;
    max-width: 400px;
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 8px;
    animation: toastIn 0.3s ease-out;
    cursor: pointer;
}
.toast.toast-ok { background: #d4edda; color: #155724; border-left: 4px solid #28a745; }
.toast.toast-err { background: #f8d7da; color: #721c24; border-left: 4px solid #dc3545; }
.toast.toast-warn { background: #fff3cd; color: #856404; border-left: 4px solid #ffc107; }
.toast.toast-info { background: #d1ecf1; color: #0c5460; border-left: 4px solid #17a2b8; }
.toast.toast-out { animation: toastOut 0.3s ease-in forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(100px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(100px); } }

/* ============ CONFIRM MODAL ============ */
/* IMAGE POPUP (stack trên confirm modal) — z-index 2000 > 1500 */
.image-popup-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.85);
    z-index: 2000;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.image-popup-box {
    position: relative;
    max-width: 95vw; max-height: 95vh;
}
.image-popup-box img {
    display: block; max-width: 95vw; max-height: 85vh;
    object-fit: contain; background: #fff; border-radius: 4px;
}
#image-popup-caption {
    color: #fff; text-align: center; font-size: 12px;
    margin-top: 8px; word-break: break-all;
}
.image-popup-close {
    position: absolute; top: -14px; right: -14px;
    width: 36px; height: 36px; border-radius: 50%;
    background: #fff; border: 2px solid #dc3545;
    color: #dc3545; font-weight: 700; cursor: pointer; font-size: 16px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.image-popup-close:hover { background: #dc3545; color: #fff; }

.confirm-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1500;
    display: flex;
    align-items: center;
    justify-content: center;
}
.confirm-box {
    background: #fff;
    border-radius: 6px;
    width: 90%;
    max-width: 450px;
    padding: 20px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}
.confirm-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary-color);
}
.confirm-body {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    max-height: 300px;
    overflow-y: auto;
    white-space: pre-line;
}
.confirm-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ============ PRINT MODAL ============ */
.print-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.print-modal {
    background: #fff;
    border-radius: 6px;
    width: 95%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}
.print-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 2px solid var(--primary-color);
    font-weight: 700;
    font-size: 15px;
    color: var(--text-primary);
}
.print-modal-actions {
    display: flex;
    gap: 8px;
}
.print-modal-body {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}
/* Tem preview trong modal */
.tem-preview {
    border: 1px dashed #ccc;
    padding: 12px 16px;
    margin-bottom: 12px;
    text-align: center;
}
.tem-preview:last-child { margin-bottom: 0; }
.tem-preview .tem-od-text {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 1px;
    margin-bottom: 6px;
}
.tem-preview svg { display: block; margin: 6px auto; width: 100%; max-width: 280px; }
.tem-preview .tem-row { font-size: 13px; line-height: 1.4; }
.tem-preview .tem-lbl { color: #888; font-size: 12px; }
.tem-preview .tem-meta { font-size: 11px; color: #999; text-align: right; margin-top: 4px; }

/* Print styles — khi in chỉ hiện tem, khổ A6 shopee 100×150mm */
@media print {
    /* Ẩn header/footer browser */
    @page {
        size: 100mm 150mm;
        margin: 0;
    }

    /* Reset toàn bộ */
    html, body {
        margin: 0 !important;
        padding: 0 !important;
        width: 100mm !important;
        height: auto !important;
        background: #fff !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Ẩn mọi thứ ngoài print-modal */
    body > *:not(#print-modal) { display: none !important; }

    /* Force hiện print-modal chain */
    #print-modal,
    #print-modal.print-modal-overlay,
    .print-modal-overlay {
        display: block !important;
        position: static !important;
        background: none !important;
        overflow: visible !important;
        width: 100% !important;
        height: auto !important;
        max-width: none !important;
        max-height: none !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        z-index: auto !important;
    }
    .print-modal {
        box-shadow: none !important;
        max-width: none !important;
        max-height: none !important;
        width: 100% !important;
        border-radius: 0 !important;
        overflow: visible !important;
        display: block !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    .print-modal-header { display: none !important; }
    .print-modal-body,
    #print-modal-body {
        padding: 0 !important;
        margin: 0 !important;
        overflow: visible !important;
        display: block !important;
        width: 100% !important;
    }

    /* Tem label — full A6 page */
    .tem-preview {
        border: none !important;
        padding: 4mm 5mm !important;
        width: 90mm !important;
        min-height: 130mm !important;
        page-break-after: always;
        page-break-inside: avoid;
        display: flex !important;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        margin: 0 auto !important;
        background: #fff !important;
    }
    .tem-preview:last-child { page-break-after: auto; }

    .tem-preview .tem-top-row {
        display: flex !important;
        justify-content: space-between;
        align-items: baseline;
        width: 100%;
        margin-bottom: 3mm;
    }
    .tem-preview .tem-kkf-text {
        font-size: 18pt !important;
        font-weight: 900 !important;
        font-family: 'Courier New', monospace !important;
        letter-spacing: 1.5px;
    }
    .tem-preview .tem-od-ref {
        font-size: 10pt !important;
        color: #333 !important;
    }
    .tem-preview svg {
        display: block !important;
        max-width: none !important;
        height: 30mm !important;
        width: 85mm !important;
        margin: 4mm auto !important;
    }
    .tem-preview .tem-row {
        font-size: 14pt !important;
        line-height: 1.6 !important;
        width: 100%;
        text-align: center;
    }
    .tem-preview .tem-lbl { color: #333 !important; }
    .tem-preview .tem-meta {
        font-size: 10pt !important;
        color: #555 !important;
        margin-top: 3mm !important;
        width: 100%;
        text-align: center;
    }
}

/* ============ PHOTO MATCH — slot + loading spinner ============ */
.photo-slot {
    position: relative;
    width: 130px; height: 130px;
    border: 2px dashed #ccc; border-radius: 8px;
    background: #f8f9fa;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.photo-slot.filled { border-style: solid; border-color: #0d6efd; }
.photo-slot img { width: 100%; height: 100%; object-fit: cover; }
.photo-slot-remove {
    position: absolute; top: 3px; right: 3px;
    width: 22px; height: 22px; border-radius: 50%;
    background: rgba(220,53,69,0.9); color: #fff; border: none;
    font-size: 12px; cursor: pointer; line-height: 1;
    display: flex; align-items: center; justify-content: center;
}
.photo-slot-loading {
    position: absolute; inset: 0;
    background: rgba(255,255,255,0.72);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 6px;
}
.photo-spinner {
    width: 30px; height: 30px;
    border: 3px solid #d0d7e2; border-top-color: #0d6efd;
    border-radius: 50%;
    animation: photo-spin 0.8s linear infinite;
}
@keyframes photo-spin { to { transform: rotate(360deg); } }

/* ============ TABLET RESPONSIVE (768-1023px) ============ */
@media (min-width: 768px) and (max-width: 1023px) {
    .app-container {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .panel-left {
        flex: 0 0 38%;
        max-width: 38%;
    }
    .panel-right {
        flex: 0 0 62%;
        max-width: 62%;
    }
    .main-table th, .main-table td { font-size: 11px; padding: 4px 6px; }
    .main-table .cell-input input { font-size: 12px; padding: 3px 4px; }
    .cell-link { display: none; }
    .action-buttons { grid-template-columns: 1fr 1fr; }
}

/* ============ MOBILE RESPONSIVE (<768px) ============ */
@media (max-width: 767px) {
    .od-tab-bar { display: flex; }
    .app-container {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 90px);
    }
    .panel-left {
        flex: none;
        max-width: 100%;
    }
    .panel-right {
        flex: none;
    }
    /* Tab switching: chỉ panel khớp data-active-tab hiển thị */
    .app-container[data-active-tab="search"] .panel-right { display: none; }
    .app-container[data-active-tab="result"] .panel-left { display: none; }
    .table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .action-row {
        flex-direction: column;
    }
    .action-buttons {
        grid-template-columns: 1fr 1fr;
    }
    .detail-content {
        grid-template-columns: 1fr 1fr;
    }
    .form-control {
        font-size: 16px; /* Prevent iOS zoom */
    }
    .btn-scan, .btn-camera {
        min-width: 48px;
        min-height: 48px;
        font-size: 20px;
    }
    .app-header-title {
        font-size: 14px;
    }
    /* Scanner fullwidth trên mobile */
    #scanner-container {
        margin: 8px -8px 0;
        border-radius: 0;
        min-height: 200px;
    }
    #scanner-container.active {
        min-height: 220px;
    }
}

@media (max-width: 600px) {
    .app-header {
        padding: 6px 10px;
    }
    .app-container {
        padding: 4px;
        gap: 4px;
    }
    .card {
        padding: 8px;
    }
    .detail-content {
        grid-template-columns: 1fr;
    }
}

/* Toggle switch (tab Cấu hình) */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc; transition: 0.2s; border-radius: 24px;
}
.switch .slider:before {
    position: absolute; content: ""; height: 18px; width: 18px;
    left: 3px; bottom: 3px; background-color: white;
    transition: 0.2s; border-radius: 50%;
}
.switch input:checked + .slider { background-color: #28a745; }
.switch input:checked + .slider:before { transform: translateX(20px); }

/* Voice recording pulse animation */
.voice-recording {
    animation: voice-pulse 1.2s ease-in-out infinite;
}
@keyframes voice-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.6); }
    50% { box-shadow: 0 0 0 8px rgba(220, 53, 69, 0); }
}

/* PGH form responsive: 2-col grid → 1-col on mobile */
@media (max-width: 768px) {
    .pgh-form-grid { grid-template-columns: 1fr !important; }
    .pgh-form-grid > div > div[style*="grid-template-columns:1fr 1fr"] { grid-template-columns: 1fr !important; }
}

/* PGH custom dropdown — đẹp, có search + add new inline */
.pgh-dropdown { position: relative; }
.pgh-dropdown-display {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.pgh-dropdown-display:hover { border-color: #adb5bd; }
.pgh-dropdown-display:focus { outline: none; border-color: #0d6efd; box-shadow: 0 0 0 2px rgba(13,110,253,0.15); }
.pgh-dropdown-placeholder { color: #adb5bd; }
.pgh-dropdown-caret { color: #888; font-size: 12px; transition: transform 0.2s; }
.pgh-dropdown[data-open="1"] .pgh-dropdown-caret { transform: rotate(180deg); color: #0d6efd; }
.pgh-dropdown[data-open="1"] .pgh-dropdown-display { border-color: #0d6efd; box-shadow: 0 0 0 2px rgba(13,110,253,0.15); }
.pgh-dropdown-panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
    z-index: 1000;
    max-height: 300px;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: pghDropdownIn 0.15s ease-out;
}
.pgh-dropdown[data-open="1"] .pgh-dropdown-panel { display: flex; }
@keyframes pghDropdownIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.pgh-dropdown-search-wrap {
    position: relative;
    padding: 8px;
    border-bottom: 1px solid #f0f0f0;
    background: #fafbfc;
}
.pgh-dropdown-search-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: #888;
    font-size: 13px;
    pointer-events: none;
}
.pgh-dropdown-search-input {
    width: 100%;
    padding: 6px 10px 6px 30px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 13px;
    background: #fff;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.pgh-dropdown-search-input:focus { border-color: #0d6efd; box-shadow: 0 0 0 2px rgba(13,110,253,0.15); }
.pgh-dropdown-list { flex: 1; overflow-y: auto; max-height: 220px; padding: 4px 0; }
.pgh-dropdown-list::-webkit-scrollbar { width: 6px; }
.pgh-dropdown-list::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
.pgh-dropdown-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #333;
    transition: background 0.1s;
}
.pgh-dropdown-item:hover { background: #f0f7ff; }
.pgh-dropdown-item.selected {
    background: #e7f1ff;
    font-weight: 600;
    color: #0d6efd;
}
.pgh-dropdown-item .pgh-item-icon { width: 14px; display: inline-flex; justify-content: center; color: #0d6efd; font-size: 13px; }
.pgh-dropdown-item.add-new {
    color: #0d6efd;
    font-weight: 500;
    background: #fafbfc;
    border-top: 1px dashed #e0e0e0;
    margin-top: 4px;
    padding-top: 10px;
    padding-bottom: 10px;
}
.pgh-dropdown-item.add-new:hover { background: #e7f1ff; }
.pgh-dropdown-empty {
    padding: 16px;
    text-align: center;
    color: #999;
    font-size: 12px;
}

/* PGH form — ép tất cả field cao đều 38px cho thẩm mỹ */
#pgh-form-view .form-control {
    height: 38px;
    box-sizing: border-box;
}
#pgh-form-view textarea.form-control {
    height: auto;
    min-height: 60px;
}
#pgh-form-view .btn-scan,
#pgh-form-view .pgh-form-grid .btn-primary,
#pgh-form-view .pgh-form-grid .btn-secondary {
    height: 38px;
    min-height: 38px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
#pgh-form-view .pgh-dropdown-display {
    height: 38px;
    box-sizing: border-box;
}
#pgh-form-view label {
    display: block;
    min-height: 18px;
    margin-bottom: 4px;
    line-height: 18px;
}

/* ============================================================
   QUẢN LÝ VẬT TƯ — sidebar layout (extensible cho nhiều loại)
   ============================================================ */
.vat-tu-layout {
    display: flex;
    gap: 16px;
    padding: 12px;
    height: 100%;
    min-height: calc(100vh - 120px);
}
.vat-tu-sidebar {
    width: 220px;
    flex-shrink: 0;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-self: flex-start;
    position: sticky;
    top: 12px;
}
.vat-tu-sidebar-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 6px 8px;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #eee;
    margin-bottom: 4px;
}
.vat-tu-nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: none;
    background: transparent;
    border-radius: 5px;
    cursor: pointer;
    font-size: 13px;
    color: #333;
    text-align: left;
    width: 100%;
    transition: background 0.12s, color 0.12s;
}
.vat-tu-nav-item:hover:not(.disabled) { background: #f0f7ff; }
.vat-tu-nav-item.active {
    background: #e7f1ff;
    color: #0d6efd;
    font-weight: 600;
}
.vat-tu-nav-item.disabled {
    color: #adb5bd;
    cursor: not-allowed;
}
.vat-tu-nav-item .bi { font-size: 16px; width: 18px; }
.vat-tu-nav-label { flex: 1; }
.vat-tu-nav-count {
    font-size: 11px;
    background: #0d6efd;
    color: #fff;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 22px;
    text-align: center;
    font-weight: 600;
}
.vat-tu-nav-item.disabled .vat-tu-nav-count,
.vat-tu-nav-soon {
    background: #e9ecef;
    color: #6c757d;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 500;
    text-transform: lowercase;
}
.vat-tu-sidebar-hint {
    font-size: 11px;
    color: var(--text-muted);
    padding: 8px;
    margin-top: 8px;
    border-top: 1px solid #eee;
    line-height: 1.4;
    font-style: italic;
}
.vat-tu-nav-add {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 6px;
    padding: 9px 12px;
    background: #f0f7ff;
    color: var(--primary, #0d6efd);
    border: 1px dashed var(--primary, #0d6efd);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.vat-tu-nav-add:hover { background: #e1efff; }
.vt-col-row .form-control { font-size: 13px; }
.vat-tu-content {
    flex: 1;
    min-width: 0;
}
.vat-tu-subpage { animation: vatTuFade 0.2s ease-out; }
@keyframes vatTuFade {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Stock badge — số lượng trong bảng bao bì */
.bb-stock-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
}
.bb-stock-ok   { background: #d4edda; color: #155724; }
.bb-stock-warn { background: #fff3cd; color: #856404; }
.bb-stock-out  { background: #f8d7da; color: #721c24; }

/* Responsive: sidebar collapse trên mobile */
@media (max-width: 900px) {
    .vat-tu-layout { flex-direction: column; }
    .vat-tu-sidebar {
        width: 100%;
        flex-direction: row;
        overflow-x: auto;
        position: static;
    }
    .vat-tu-sidebar-title { display: none; }
    .vat-tu-sidebar-hint { display: none; }
    .vat-tu-nav-item { white-space: nowrap; flex-shrink: 0; }
}

/* ============================================================
   PGH list — toolbar + filter bar (UI/UX redesign)
   ============================================================ */
.pgh-toolbar {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.pgh-toolbar-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    gap: 16px;
    flex-wrap: wrap;
}
.pgh-toolbar-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    color: #1a1a1a;
    display: flex;
    align-items: center;
    gap: 8px;
}
.pgh-toolbar-title i { color: #0d6efd; }
.pgh-stats {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    align-items: center;
}
.pgh-stats .pgh-stat-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.pgh-stats .pgh-stat-dot {
    width: 8px; height: 8px; border-radius: 50%; display: inline-block;
}
.pgh-stats .pgh-stat-num { font-weight: 700; color: #1a1a1a; }

/* Filter bar */
.pgh-filter-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    padding: 10px;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #e2e8f0;
    border-radius: 6px;
}
.pgh-filter-search {
    position: relative;
    flex: 1;
    min-width: 220px;
    max-width: 320px;
}
.pgh-filter-search i {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 14px;
    pointer-events: none;
}
.pgh-filter-search input {
    width: 100%;
    padding: 8px 12px 8px 34px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    height: 36px;
    box-sizing: border-box;
}
.pgh-filter-search input:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 3px rgba(13,110,253,0.12);
}
.pgh-filter-select {
    padding: 8px 30px 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
    min-width: 160px;
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    height: 36px;
    box-sizing: border-box;
    color: #1a1a1a;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s, color 0.15s;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='%2364748b' d='M4.427 6.427 8 10l3.573-3.573z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 14px;
}
.pgh-filter-select:hover { border-color: #94a3b8; }
.pgh-filter-select:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 3px rgba(13,110,253,0.12);
}
.pgh-filter-select.active {
    background-color: #e7f1ff;
    border-color: #0d6efd;
    color: #0d6efd;
    font-weight: 600;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='%230d6efd' d='M4.427 6.427 8 10l3.573-3.573z'/%3e%3c/svg%3e");
}
.pgh-filter-reset {
    padding: 8px 12px;
    border: 1px solid #fecaca;
    border-radius: 6px;
    background: #fef2f2;
    color: #dc2626;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 36px;
    box-sizing: border-box;
    transition: background 0.15s, border-color 0.15s;
}
.pgh-filter-reset:hover {
    background: #fee2e2;
    border-color: #dc2626;
}

/* Responsive */
@media (max-width: 768px) {
    .pgh-filter-bar { gap: 6px; }
    .pgh-filter-search,
    .pgh-filter-select { width: 100%; max-width: 100%; min-width: 0; }
    .pgh-filter-reset { width: 100%; justify-content: center; }
}

/* PGH status change popover */
.pgh-status-popover {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
    min-width: 180px;
    padding: 6px 0;
    animation: pghPopoverIn 0.15s ease-out;
}
@keyframes pghPopoverIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.pgh-status-popover-title {
    padding: 4px 12px 6px 12px;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 4px;
}
.pgh-status-popover-item {
    padding: 7px 12px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.12s;
}
.pgh-status-popover-item:hover { background: #f0f7ff; }
.pgh-status-popover-item.current { background: #f8f9fa; cursor: default; color: #0d6efd; font-weight: 600; }
.pgh-status-popover-dot {
    width: 10px; height: 10px; border-radius: 50%; display: inline-block;
}

/* ============================================================
   PGH MODULE — UI OVERHAUL (typography + design system)
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

#pgh-list-view, #pgh-form-view,
#kkf-picker-modal, #bao-bi-picker-modal,
#bao-bi-detail-modal, #bao-bi-form-modal,
#pgh-form-modal {
    --pgh-bg: #f8fafc;
    --pgh-surface: #ffffff;
    --pgh-border: #e5e7eb;
    --pgh-border-strong: #d1d5db;
    --pgh-text: #111827;
    --pgh-text-muted: #6b7280;
    --pgh-text-light: #9ca3af;
    --pgh-primary: #2563eb;
    --pgh-primary-hover: #1d4ed8;
    --pgh-primary-soft: #eff6ff;
    --pgh-primary-border: #93c5fd;
    --pgh-radius: 10px;
    --pgh-radius-sm: 6px;
    --pgh-shadow-sm: 0 1px 3px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
    --pgh-shadow-lg: 0 12px 32px rgba(15,23,42,0.12);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color: var(--pgh-text);
}

#pgh-list-view .pgh-toolbar {
    background: var(--pgh-surface);
    border: 1px solid var(--pgh-border);
    border-radius: var(--pgh-radius);
    padding: 18px 20px;
    margin-bottom: 12px;
    box-shadow: var(--pgh-shadow-sm);
}
#pgh-list-view .pgh-toolbar-title {
    font-size: 20px; font-weight: 700; margin: 0;
    color: var(--pgh-text); letter-spacing: -0.025em;
    display: flex; align-items: center; gap: 10px;
}
#pgh-list-view .pgh-toolbar-title i {
    color: var(--pgh-primary); font-size: 22px;
    background: var(--pgh-primary-soft); padding: 8px; border-radius: var(--pgh-radius-sm);
}
#pgh-list-view .pgh-stats {
    font-size: 13px; color: var(--pgh-text-muted);
    margin-top: 8px; display: flex; gap: 18px; flex-wrap: wrap; align-items: center;
}
#pgh-list-view .pgh-stat-num { font-weight: 700; color: var(--pgh-text); }

#pgh-list-view .pgh-filter-bar {
    background: var(--pgh-bg);
    border: 1px solid var(--pgh-border);
    border-radius: var(--pgh-radius-sm);
    padding: 12px;
    gap: 10px;
}
#pgh-list-view .pgh-filter-search input,
#pgh-list-view .pgh-filter-select {
    height: 38px;
    border: 1px solid var(--pgh-border-strong);
    background: #fff;
    font-size: 13px;
    font-family: inherit;
    color: var(--pgh-text);
    transition: all 0.15s;
}
#pgh-list-view .pgh-filter-search input:hover,
#pgh-list-view .pgh-filter-select:hover { border-color: var(--pgh-primary-border); }
#pgh-list-view .pgh-filter-search input:focus,
#pgh-list-view .pgh-filter-select:focus {
    border-color: var(--pgh-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
    outline: none;
}
#pgh-list-view .pgh-filter-select.active {
    background-color: var(--pgh-primary-soft);
    border-color: var(--pgh-primary);
    color: var(--pgh-primary);
    font-weight: 600;
}

#pgh-list-view .btn, #pgh-form-view .btn,
#kkf-picker-modal .btn, #bao-bi-picker-modal .btn,
#bao-bi-detail-modal .btn, #bao-bi-form-modal .btn,
#pgh-form-modal .btn {
    font-family: inherit;
    font-weight: 500;
    border-radius: var(--pgh-radius-sm);
    transition: all 0.15s ease;
    border: 1px solid transparent;
    font-size: 13px;
    padding: 8px 14px;
    display: inline-flex; align-items: center; gap: 6px;
    line-height: 1; cursor: pointer; white-space: nowrap;
}
#pgh-list-view .btn-primary, #pgh-form-view .btn-primary,
#kkf-picker-modal .btn-primary, #bao-bi-picker-modal .btn-primary,
#bao-bi-form-modal .btn-primary, #pgh-form-modal .btn-primary {
    background: var(--pgh-primary); color: #fff; border-color: var(--pgh-primary);
    box-shadow: 0 1px 2px rgba(37,99,235,0.25);
}
#pgh-list-view .btn-primary:hover:not(:disabled),
#pgh-form-view .btn-primary:hover:not(:disabled),
#kkf-picker-modal .btn-primary:hover:not(:disabled),
#bao-bi-picker-modal .btn-primary:hover:not(:disabled),
#bao-bi-form-modal .btn-primary:hover:not(:disabled),
#pgh-form-modal .btn-primary:hover:not(:disabled) {
    background: var(--pgh-primary-hover); border-color: var(--pgh-primary-hover);
    transform: translateY(-1px); box-shadow: 0 4px 8px rgba(37,99,235,0.25);
}
#pgh-list-view .btn-secondary, #pgh-form-view .btn-secondary,
#kkf-picker-modal .btn-secondary, #bao-bi-picker-modal .btn-secondary,
#bao-bi-detail-modal .btn-secondary, #bao-bi-form-modal .btn-secondary,
#pgh-form-modal .btn-secondary {
    background: #fff; color: var(--pgh-text); border-color: var(--pgh-border-strong);
}
#pgh-list-view .btn-secondary:hover:not(:disabled),
#pgh-form-view .btn-secondary:hover:not(:disabled),
#kkf-picker-modal .btn-secondary:hover:not(:disabled),
#bao-bi-picker-modal .btn-secondary:hover:not(:disabled),
#bao-bi-form-modal .btn-secondary:hover:not(:disabled),
#pgh-form-modal .btn-secondary:hover:not(:disabled) {
    background: var(--pgh-bg); border-color: var(--pgh-primary-border);
    color: var(--pgh-primary);
}
#pgh-list-view .btn-scan, #pgh-form-view .btn-scan {
    background: var(--pgh-primary-soft); color: var(--pgh-primary);
    border-color: var(--pgh-primary-border);
    min-height: 38px; padding: 0 12px; font-size: 18px;
}
#pgh-list-view .btn-scan:hover, #pgh-form-view .btn-scan:hover {
    background: var(--pgh-primary); color: #fff;
}

#pgh-list-view .main-table,
#pgh-form-view .main-table,
#kkf-picker-modal .main-table,
#bao-bi-picker-modal .main-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
    font-family: inherit;
}
#pgh-list-view .main-table thead th,
#pgh-form-view .main-table thead th,
#kkf-picker-modal .main-table thead th,
#bao-bi-picker-modal .main-table thead th {
    background: var(--pgh-bg);
    font-weight: 600;
    color: var(--pgh-text-muted);
    text-transform: uppercase;
    font-size: 10.5px;
    letter-spacing: 0.6px;
    padding: 11px 12px;
    border-bottom: 1px solid var(--pgh-border);
    text-align: left;
    white-space: nowrap;
}
#pgh-list-view .main-table tbody td,
#pgh-form-view .main-table tbody td,
#kkf-picker-modal .main-table tbody td,
#bao-bi-picker-modal .main-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid #f3f4f6;
    font-size: 13px;
    color: var(--pgh-text);
    vertical-align: top;
}
#pgh-list-view .main-table tbody tr,
#kkf-picker-modal .main-table tbody tr,
#bao-bi-picker-modal .main-table tbody tr {
    transition: background 0.12s;
}
#pgh-list-view .main-table tbody tr:hover,
#kkf-picker-modal .main-table tbody tr:hover,
#bao-bi-picker-modal .main-table tbody tr:hover {
    background: var(--pgh-bg);
}
#pgh-list-view .main-table tbody td a { color: var(--pgh-primary); font-weight: 600; text-decoration: none; }
#pgh-list-view .main-table tbody td a:hover { text-decoration: underline; }

#pgh-list-view .card, #pgh-form-view .card {
    background: var(--pgh-surface);
    border: 1px solid var(--pgh-border);
    border-radius: var(--pgh-radius);
    box-shadow: var(--pgh-shadow-sm);
    padding: 16px;
}
#pgh-form-view .card { padding: 20px; }
#pgh-list-view .card-title, #pgh-form-view .card-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--pgh-text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--pgh-border);
    display: flex; align-items: center; gap: 8px;
}
#pgh-list-view .card-title i, #pgh-form-view .card-title i {
    color: var(--pgh-primary); font-size: 15px;
}

#pgh-form-view label {
    display: block;
    font-weight: 600;
    font-size: 11px;
    color: var(--pgh-text-muted);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 5px;
    line-height: 1.4;
}
#pgh-form-view label small {
    font-weight: 400; text-transform: none; letter-spacing: 0;
    font-size: 11px; color: var(--pgh-text-light);
}
#pgh-form-view .form-control {
    height: 38px;
    border: 1px solid var(--pgh-border-strong);
    border-radius: var(--pgh-radius-sm);
    padding: 0 12px;
    font-size: 13px;
    font-family: inherit;
    color: var(--pgh-text);
    background: #fff;
    box-sizing: border-box;
    transition: all 0.15s;
    width: 100%;
}
#pgh-form-view textarea.form-control {
    height: auto; min-height: 64px; padding: 10px 12px;
    line-height: 1.5; resize: vertical;
}
#pgh-form-view select.form-control { appearance: none; -webkit-appearance: none; padding-right: 30px; cursor: pointer; }
#pgh-form-view .form-control:hover { border-color: var(--pgh-primary-border); }
#pgh-form-view .form-control:focus {
    border-color: var(--pgh-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
    outline: none;
}
#pgh-form-view .form-control[readonly] {
    background: var(--pgh-bg) !important;
    color: var(--pgh-text-muted) !important;
}
#pgh-form-view #pgh-info-ma {
    font-family: 'Share Tech Mono', monospace; font-size: 14px; color: var(--pgh-text);
}
#pgh-form-view #pgh-info-tong-kkf {
    color: var(--pgh-primary) !important; font-size: 28px !important;
    font-weight: 800 !important; line-height: 1;
}
#pgh-form-view .empty-state {
    color: var(--pgh-text-muted); padding: 40px 20px !important;
}

#pgh-form-view #pgh-bao-bi-chip:hover {
    background: #dbeafe !important;
    transform: translateY(-1px);
    box-shadow: var(--pgh-shadow-sm);
}

#kkf-picker-modal, #bao-bi-picker-modal,
#bao-bi-detail-modal, #bao-bi-form-modal {
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}
#kkf-picker-modal .detail-modal,
#bao-bi-picker-modal .detail-modal,
#bao-bi-detail-modal .detail-modal,
#bao-bi-form-modal .detail-modal {
    border-radius: var(--pgh-radius);
    box-shadow: var(--pgh-shadow-lg);
    border: 1px solid var(--pgh-border);
    animation: pghModalIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: 'Inter', -apple-system, system-ui, sans-serif;
}
@keyframes pghModalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
#kkf-picker-modal .detail-modal-header,
#bao-bi-picker-modal .detail-modal-header,
#bao-bi-detail-modal .detail-modal-header,
#bao-bi-form-modal .detail-modal-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--pgh-border);
    background: linear-gradient(180deg, #fff 0%, var(--pgh-bg) 100%);
    font-weight: 700;
    font-size: 15px;
    color: var(--pgh-text);
    border-radius: var(--pgh-radius) var(--pgh-radius) 0 0;
}
#kkf-picker-modal .detail-modal-header i,
#bao-bi-picker-modal .detail-modal-header i,
#bao-bi-detail-modal .detail-modal-header i,
#bao-bi-form-modal .detail-modal-header i {
    color: var(--pgh-primary);
}

#pgh-list-view .pgh-status-clickable { transition: all 0.15s; user-select: none; }
#pgh-list-view .pgh-status-clickable:hover {
    transform: translateY(-1px); box-shadow: var(--pgh-shadow-sm);
    filter: brightness(1.08);
}
.pgh-status-popover { font-family: 'Inter', system-ui, sans-serif; }

#pgh-list-view #pgh-pagination { font-size: 13px; color: var(--pgh-text-muted); }
#pgh-list-view #pgh-pagination input[type="number"] {
    height: 28px; width: 50px; padding: 0 6px;
    border: 1px solid var(--pgh-border-strong); border-radius: 4px;
    text-align: center; font-size: 12px; font-family: inherit;
}

@media (max-width: 768px) {
    #pgh-list-view .pgh-toolbar-title { font-size: 17px; }
    #pgh-list-view .pgh-toolbar-title i { font-size: 18px; padding: 6px; }
    #pgh-form-view .card { padding: 14px; }
}

/* ============================================================
   VẬT TƯ KHO — UI OVERHAUL (reuse design system PGH)
   ============================================================ */
#page-vat-tu {
    --pgh-bg: #f8fafc;
    --pgh-surface: #ffffff;
    --pgh-border: #e5e7eb;
    --pgh-border-strong: #d1d5db;
    --pgh-text: #111827;
    --pgh-text-muted: #6b7280;
    --pgh-text-light: #9ca3af;
    --pgh-primary: #2563eb;
    --pgh-primary-hover: #1d4ed8;
    --pgh-primary-soft: #eff6ff;
    --pgh-primary-border: #93c5fd;
    --pgh-radius: 10px;
    --pgh-radius-sm: 6px;
    --pgh-shadow-sm: 0 1px 3px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color: var(--pgh-text);
}

/* SIDEBAR */
#page-vat-tu .vat-tu-sidebar {
    background: linear-gradient(180deg, #fff 0%, #fbfcfd 100%);
    border: 1px solid var(--pgh-border);
    border-radius: var(--pgh-radius);
    padding: 12px;
    box-shadow: var(--pgh-shadow-sm);
    gap: 4px;
}
#page-vat-tu .vat-tu-sidebar-title {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--pgh-text-light);
    padding: 4px 12px 10px 12px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--pgh-border);
}
#page-vat-tu .vat-tu-nav-item {
    border-radius: var(--pgh-radius-sm);
    padding: 9px 12px;
    font-size: 13px;
    color: var(--pgh-text);
    font-weight: 500;
    transition: all 0.15s;
    border-left: 3px solid transparent;
    margin-left: 0;
}
#page-vat-tu .vat-tu-nav-item:hover:not(.disabled) {
    background: var(--pgh-primary-soft);
    color: var(--pgh-primary);
}
#page-vat-tu .vat-tu-nav-item.active {
    background: var(--pgh-primary-soft);
    color: var(--pgh-primary);
    font-weight: 600;
    border-left-color: var(--pgh-primary);
    padding-left: 9px;
}
#page-vat-tu .vat-tu-nav-item .bi {
    background: var(--pgh-bg);
    color: var(--pgh-text-muted);
    width: 26px; height: 26px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 5px;
    font-size: 14px;
    transition: all 0.15s;
}
#page-vat-tu .vat-tu-nav-item.active .bi {
    background: var(--pgh-primary);
    color: #fff;
}
#page-vat-tu .vat-tu-nav-item.disabled .bi {
    background: #f3f4f6;
    color: var(--pgh-text-light);
}
#page-vat-tu .vat-tu-nav-count {
    font-weight: 700;
    background: var(--pgh-primary);
    color: #fff;
    font-size: 11px;
    padding: 2px 9px;
    border-radius: 999px;
    box-shadow: 0 1px 2px rgba(37,99,235,0.25);
}
#page-vat-tu .vat-tu-nav-soon {
    font-size: 9.5px;
    background: #f3f4f6;
    color: var(--pgh-text-light);
    padding: 2px 7px;
    border-radius: 999px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
#page-vat-tu .vat-tu-sidebar-hint {
    font-size: 11px;
    color: var(--pgh-text-light);
    padding: 10px 12px 4px 12px;
    margin-top: 8px;
    border-top: 1px solid var(--pgh-border);
    line-height: 1.5;
    font-style: italic;
}

/* CONTENT CARD */
#page-vat-tu .card {
    background: var(--pgh-surface);
    border: 1px solid var(--pgh-border);
    border-radius: var(--pgh-radius);
    box-shadow: var(--pgh-shadow-sm);
    padding: 18px;
}
#page-vat-tu .card-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--pgh-text);
    letter-spacing: -0.01em;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--pgh-border);
    margin-bottom: 14px;
}
#page-vat-tu .card-title > span:first-child { display: flex; align-items: center; gap: 8px; }
#page-vat-tu .card-title i { color: var(--pgh-primary); font-size: 18px; }
#page-vat-tu .card-title small { color: var(--pgh-text-muted); font-weight: 400; }

/* STAT SUMMARY — cards row */
#page-vat-tu #bao-bi-stat-summary {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)) !important;
    gap: 12px !important;
    padding: 4px 0 16px 0 !important;
    margin: 0 !important;
}
#page-vat-tu .bb-stat {
    background: #fff;
    border: 1px solid var(--pgh-border);
    border-radius: var(--pgh-radius-sm);
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.15s;
    box-shadow: var(--pgh-shadow-sm);
}
#page-vat-tu .bb-stat:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(15,23,42,0.08);
}
#page-vat-tu .bb-stat-icon {
    width: 40px; height: 40px;
    border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
#page-vat-tu .bb-stat-value {
    font-size: 22px;
    font-weight: 800;
    color: var(--pgh-text);
    line-height: 1;
    letter-spacing: -0.02em;
}
#page-vat-tu .bb-stat-label {
    font-size: 11px;
    color: var(--pgh-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-top: 4px;
}
#page-vat-tu .bb-stat-total .bb-stat-icon { background: #eff6ff; color: #2563eb; }
#page-vat-tu .bb-stat-stock .bb-stat-icon { background: #f0fdf4; color: #16a34a; }
#page-vat-tu .bb-stat-low   .bb-stat-icon { background: #fffbeb; color: #d97706; }
#page-vat-tu .bb-stat-out   .bb-stat-icon { background: #fef2f2; color: #dc2626; }
#page-vat-tu .bb-stat-total .bb-stat-value { color: #2563eb; }
#page-vat-tu .bb-stat-stock .bb-stat-value { color: #16a34a; }
#page-vat-tu .bb-stat-low   .bb-stat-value { color: #d97706; }
#page-vat-tu .bb-stat-out   .bb-stat-value { color: #dc2626; }

/* BUTTONS */
#page-vat-tu .btn {
    font-family: inherit;
    font-weight: 500;
    border-radius: var(--pgh-radius-sm);
    transition: all 0.15s ease;
    border: 1px solid transparent;
    font-size: 13px;
    padding: 8px 14px;
    display: inline-flex; align-items: center; gap: 6px;
    line-height: 1; cursor: pointer; white-space: nowrap;
}
#page-vat-tu .btn-primary {
    background: var(--pgh-primary); color: #fff; border-color: var(--pgh-primary);
    box-shadow: 0 1px 2px rgba(37,99,235,0.25);
}
#page-vat-tu .btn-primary:hover:not(:disabled) {
    background: var(--pgh-primary-hover); border-color: var(--pgh-primary-hover);
    transform: translateY(-1px); box-shadow: 0 4px 8px rgba(37,99,235,0.25);
}
#page-vat-tu .btn-secondary {
    background: #fff; color: var(--pgh-text); border-color: var(--pgh-border-strong);
}
#page-vat-tu .btn-secondary:hover:not(:disabled) {
    background: var(--pgh-bg); border-color: var(--pgh-primary-border);
    color: var(--pgh-primary);
}

/* SEARCH INPUT */
#page-vat-tu #bao-bi-search {
    height: 38px;
    border: 1px solid var(--pgh-border-strong);
    border-radius: var(--pgh-radius-sm);
    padding: 0 12px;
    font-size: 13px;
    font-family: inherit;
    transition: all 0.15s;
}
#page-vat-tu #bao-bi-search:focus {
    border-color: var(--pgh-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
    outline: none;
}

/* TABLE */
#page-vat-tu .main-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
    font-family: inherit;
}
#page-vat-tu .main-table thead th {
    background: var(--pgh-bg);
    font-weight: 600;
    color: var(--pgh-text-muted);
    text-transform: uppercase;
    font-size: 10.5px;
    letter-spacing: 0.6px;
    padding: 11px 12px;
    border-bottom: 1px solid var(--pgh-border);
    text-align: left;
    white-space: nowrap;
}
#page-vat-tu .main-table tbody td {
    padding: 11px 12px;
    border-bottom: 1px solid #f3f4f6;
    font-size: 13px;
    color: var(--pgh-text);
    vertical-align: middle;
}
#page-vat-tu .main-table tbody tr { transition: background 0.12s; }
#page-vat-tu .main-table tbody tr:hover { background: var(--pgh-bg); }
#page-vat-tu .main-table tbody tr:last-child td { border-bottom: none; }

/* STOCK BADGE polish */
#page-vat-tu .bb-stock-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.2px;
}
#page-vat-tu .bb-stock-ok   { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }
#page-vat-tu .bb-stock-warn { background: #fffbeb; color: #d97706; border: 1px solid #fde68a; }
#page-vat-tu .bb-stock-out  { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }

/* Empty state */
#page-vat-tu .empty-state {
    padding: 60px 20px !important;
    text-align: center !important;
    color: var(--pgh-text-muted) !important;
    font-size: 14px !important;
}

/* Form modal đã được PGH overhaul cover #bao-bi-form-modal */

/* Responsive */
@media (max-width: 900px) {
    #page-vat-tu .vat-tu-sidebar { padding: 6px; }
    #page-vat-tu .vat-tu-nav-item { padding: 8px 10px; }
}
@media (max-width: 600px) {
    #page-vat-tu #bao-bi-stat-summary { grid-template-columns: repeat(2, 1fr) !important; }
    #page-vat-tu .bb-stat { padding: 12px; }
    #page-vat-tu .bb-stat-icon { width: 36px; height: 36px; font-size: 18px; }
    #page-vat-tu .bb-stat-value { font-size: 18px; }
}

/* ============================================================
   ĐÓNG KIỆN — UI OVERHAUL (reuse design system PGH)
   ============================================================ */
#dk-list-view, #dk-form-view,
#dk-kkf-picker-modal, #dk-import-modal,
#pgh-dk-picker-modal {
    --pgh-bg: #f8fafc;
    --pgh-surface: #ffffff;
    --pgh-border: #e5e7eb;
    --pgh-border-strong: #d1d5db;
    --pgh-text: #111827;
    --pgh-text-muted: #6b7280;
    --pgh-text-light: #9ca3af;
    --pgh-primary: #2563eb;
    --pgh-primary-hover: #1d4ed8;
    --pgh-primary-soft: #eff6ff;
    --pgh-primary-border: #93c5fd;
    --pgh-radius: 10px;
    --pgh-radius-sm: 6px;
    --pgh-shadow-sm: 0 1px 3px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
    --pgh-shadow-lg: 0 12px 32px rgba(15,23,42,0.12);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color: var(--pgh-text);
}

/* DK toolbar (reuse pgh-toolbar class) — đã có style PGH, override icon DK */
#dk-list-view .pgh-toolbar { border-radius: var(--pgh-radius); }
#dk-list-view .pgh-toolbar-title i {
    color: #ea580c; background: #fff7ed; padding: 8px; border-radius: var(--pgh-radius-sm);
}
#dk-list-view .pgh-filter-search input:focus,
#dk-list-view .pgh-filter-select:focus {
    border-color: var(--pgh-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

/* DK buttons */
#dk-list-view .btn, #dk-form-view .btn,
#dk-kkf-picker-modal .btn, #dk-import-modal .btn {
    font-family: inherit; font-weight: 500;
    border-radius: var(--pgh-radius-sm);
    transition: all 0.15s ease;
    border: 1px solid transparent;
    font-size: 13px;
    padding: 8px 14px;
    display: inline-flex; align-items: center; gap: 6px;
    line-height: 1; cursor: pointer; white-space: nowrap;
}
#dk-list-view .btn-primary, #dk-form-view .btn-primary,
#dk-kkf-picker-modal .btn-primary, #dk-import-modal .btn-primary {
    background: var(--pgh-primary); color: #fff; border-color: var(--pgh-primary);
    box-shadow: 0 1px 2px rgba(37,99,235,0.25);
}
#dk-list-view .btn-primary:hover:not(:disabled),
#dk-form-view .btn-primary:hover:not(:disabled),
#dk-kkf-picker-modal .btn-primary:hover:not(:disabled),
#dk-import-modal .btn-primary:hover:not(:disabled) {
    background: var(--pgh-primary-hover); border-color: var(--pgh-primary-hover);
    transform: translateY(-1px); box-shadow: 0 4px 8px rgba(37,99,235,0.25);
}
#dk-list-view .btn-secondary, #dk-form-view .btn-secondary,
#dk-kkf-picker-modal .btn-secondary, #dk-import-modal .btn-secondary {
    background: #fff; color: var(--pgh-text); border-color: var(--pgh-border-strong);
}
#dk-list-view .btn-secondary:hover:not(:disabled),
#dk-form-view .btn-secondary:hover:not(:disabled),
#dk-kkf-picker-modal .btn-secondary:hover:not(:disabled),
#dk-import-modal .btn-secondary:hover:not(:disabled) {
    background: var(--pgh-bg); border-color: var(--pgh-primary-border);
    color: var(--pgh-primary);
}
#dk-form-view .btn-scan {
    background: var(--pgh-primary-soft); color: var(--pgh-primary);
    border-color: var(--pgh-primary-border);
    min-height: 38px; padding: 0 12px; font-size: 18px;
}
#dk-form-view .btn-scan:hover { background: var(--pgh-primary); color: #fff; }

/* DK tables */
#dk-list-view .main-table,
#dk-form-view .main-table,
#dk-kkf-picker-modal .main-table,
#dk-import-modal .main-table {
    width: 100%; border-collapse: separate; border-spacing: 0;
    font-size: 13px; font-family: inherit;
}
#dk-list-view .main-table thead th,
#dk-form-view .main-table thead th,
#dk-kkf-picker-modal .main-table thead th,
#dk-import-modal .main-table thead th {
    background: var(--pgh-bg); font-weight: 600;
    color: var(--pgh-text-muted); text-transform: uppercase;
    font-size: 10.5px; letter-spacing: 0.6px;
    padding: 11px 12px; border-bottom: 1px solid var(--pgh-border);
    text-align: left; white-space: nowrap;
}
#dk-list-view .main-table tbody td,
#dk-form-view .main-table tbody td,
#dk-kkf-picker-modal .main-table tbody td,
#dk-import-modal .main-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid #f3f4f6;
    font-size: 13px; color: var(--pgh-text);
    vertical-align: middle;
}
#dk-list-view .main-table tbody tr,
#dk-kkf-picker-modal .main-table tbody tr,
#dk-import-modal .main-table tbody tr {
    transition: background 0.12s;
}
#dk-list-view .main-table tbody tr:hover,
#dk-kkf-picker-modal .main-table tbody tr:hover {
    background: var(--pgh-bg);
}
#dk-list-view .main-table tbody td a {
    color: var(--pgh-primary); font-weight: 600; text-decoration: none;
}
#dk-list-view .main-table tbody td a:hover { text-decoration: underline; }

/* DK cards */
#dk-list-view .card, #dk-form-view .card {
    background: var(--pgh-surface);
    border: 1px solid var(--pgh-border);
    border-radius: var(--pgh-radius);
    box-shadow: var(--pgh-shadow-sm);
    padding: 16px;
}
#dk-form-view .card { padding: 20px; }
#dk-list-view .card-title, #dk-form-view .card-title {
    font-size: 13px; font-weight: 700; color: var(--pgh-text);
    text-transform: uppercase; letter-spacing: 0.5px;
    margin-bottom: 12px; padding-bottom: 10px;
    border-bottom: 1px solid var(--pgh-border);
    display: flex; align-items: center; gap: 8px;
}
#dk-list-view .card-title i, #dk-form-view .card-title i {
    color: var(--pgh-primary); font-size: 15px;
}

/* DK form labels + inputs */
#dk-form-view label {
    display: block; font-weight: 600;
    font-size: 11px; color: var(--pgh-text-muted);
    letter-spacing: 0.5px; text-transform: uppercase;
    margin-bottom: 5px; line-height: 1.4;
}
#dk-form-view label small {
    font-weight: 400; text-transform: none; letter-spacing: 0;
    font-size: 11px; color: var(--pgh-text-light);
}
#dk-form-view .form-control {
    height: 38px;
    border: 1px solid var(--pgh-border-strong);
    border-radius: var(--pgh-radius-sm);
    padding: 0 12px;
    font-size: 13px; font-family: inherit;
    color: var(--pgh-text); background: #fff;
    box-sizing: border-box; transition: all 0.15s;
    width: 100%;
}
#dk-form-view textarea.form-control {
    height: auto; min-height: 64px; padding: 10px 12px;
    line-height: 1.5; resize: vertical;
}
#dk-form-view .form-control:hover { border-color: var(--pgh-primary-border); }
#dk-form-view .form-control:focus {
    border-color: var(--pgh-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
    outline: none;
}
#dk-form-view .form-control[readonly] {
    background: var(--pgh-bg) !important;
    color: var(--pgh-text-muted) !important;
}
#dk-form-view #dk-info-ma {
    font-family: 'Share Tech Mono', monospace; font-size: 14px; color: var(--pgh-text);
}
#dk-form-view #dk-info-sl-kkf {
    color: var(--pgh-primary) !important; font-size: 28px !important;
    font-weight: 800 !important; line-height: 1;
}
#dk-form-view #dk-info-can-kien {
    color: var(--pgh-primary) !important; font-size: 20px !important;
    font-weight: 700 !important; line-height: 1;
}
#dk-form-view .empty-state {
    color: var(--pgh-text-muted); padding: 40px 20px !important;
}

/* DK modals */
#dk-kkf-picker-modal, #dk-import-modal, #dk-check-modal, #pgh-dk-picker-modal {
    backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}
#dk-kkf-picker-modal .detail-modal,
#dk-import-modal .detail-modal,
#dk-check-modal .detail-modal,
#pgh-dk-picker-modal .detail-modal {
    border-radius: var(--pgh-radius);
    box-shadow: var(--pgh-shadow-lg);
    border: 1px solid var(--pgh-border);
    animation: pghModalIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: 'Inter', -apple-system, system-ui, sans-serif;
}
#dk-kkf-picker-modal .detail-modal-header,
#dk-import-modal .detail-modal-header,
#dk-check-modal .detail-modal-header,
#pgh-dk-picker-modal .detail-modal-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--pgh-border);
    background: linear-gradient(180deg, #fff 0%, var(--pgh-bg) 100%);
    font-weight: 700; font-size: 15px; color: var(--pgh-text);
    border-radius: var(--pgh-radius) var(--pgh-radius) 0 0;
}
#dk-kkf-picker-modal .detail-modal-header i,
#dk-import-modal .detail-modal-header i,
#dk-check-modal .detail-modal-header i,
#pgh-dk-picker-modal .detail-modal-header i {
    color: var(--pgh-primary);
}
#dk-check-modal .btn, #dk-check-modal .form-control {
    font-family: inherit;
}
#dk-check-modal .form-control {
    height: 40px;
    border: 1px solid var(--pgh-border-strong);
    border-radius: var(--pgh-radius-sm);
    padding: 0 12px;
    font-size: 14px;
    box-sizing: border-box;
    transition: all 0.15s;
}
#dk-check-modal .form-control:focus {
    border-color: var(--pgh-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
    outline: none;
}
#dk-check-modal .btn-scan {
    background: var(--pgh-primary-soft); color: var(--pgh-primary);
    border-color: var(--pgh-primary-border);
    min-height: 40px; padding: 0 12px; font-size: 18px;
}
#dk-check-modal .main-table thead th {
    background: var(--pgh-bg); font-weight: 600;
    color: var(--pgh-text-muted); text-transform: uppercase;
    font-size: 10.5px; letter-spacing: 0.6px;
    padding: 10px 12px; border-bottom: 1px solid var(--pgh-border);
    position: sticky; top: 0; z-index: 1;
}
#dk-check-modal .main-table tbody td {
    padding: 9px 12px; border-bottom: 1px solid #f3f4f6;
    font-size: 13px;
}

@keyframes dkCheckShake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

/* DK check modal tabs */
#dk-check-modal .dk-check-tabs {
    flex-shrink: 0;
}
#dk-check-modal .dk-check-tab-btn {
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 12px 18px;
    font-size: 13px;
    font-weight: 600;
    color: var(--pgh-text-muted);
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
}
#dk-check-modal .dk-check-tab-btn:hover {
    color: var(--pgh-primary);
    background: rgba(37,99,235,0.04);
}
#dk-check-modal .dk-check-tab-btn.active {
    color: var(--pgh-primary);
    border-bottom-color: var(--pgh-primary);
    background: #fff;
}

/* DK bulk check — mismatch cell highlight */
#dk-check-bulk-result .main-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 12px;
}
#dk-check-bulk-result .main-table thead th {
    background: var(--pgh-bg);
    font-weight: 600; color: var(--pgh-text-muted);
    text-transform: uppercase; font-size: 10px; letter-spacing: 0.5px;
    padding: 9px 10px; border-bottom: 1px solid var(--pgh-border);
    position: sticky; top: 0; z-index: 1;
    text-align: left; white-space: nowrap;
}
#dk-check-bulk-result .main-table tbody td {
    padding: 9px 10px;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: top;
}
#dk-check-bulk-result .cell-ok { color: var(--pgh-text); }
#dk-check-bulk-result .cell-mismatch {
    background: #fef2f2 !important;
    color: #dc2626 !important;
    font-weight: 600;
    border-right: 2px solid #ef4444;
}
#dk-check-bulk-result .cell-mismatch .cell-expected {
    display: block;
    font-size: 10px;
    font-weight: 500;
    color: #991b1b;
    margin-top: 2px;
    padding-top: 2px;
    border-top: 1px dashed #fecaca;
}
#dk-check-bulk-result .cell-empty {
    color: #cbd5e1;
    font-style: italic;
}
#dk-check-bulk-result .row-notfound td {
    background: #fef9f9;
}

/* DK pagination */
#dk-list-view #dk-pagination { font-size: 13px; color: var(--pgh-text-muted); }
#dk-list-view #dk-pagination input[type="number"] {
    height: 28px; width: 50px; padding: 0 6px;
    border: 1px solid var(--pgh-border-strong); border-radius: 4px;
    text-align: center; font-size: 12px; font-family: inherit;
}

@media (max-width: 768px) {
    #dk-list-view .pgh-toolbar-title { font-size: 17px; }
    #dk-form-view .card { padding: 14px; }
}
