/* ============================================================
   ĐỢT 3 (10/2026): ĐĂNG NHẬP · ĐƠN HÀNG · CHỈ LỆNH · XUẤT THEO ĐƠN HÀNG · TÀI KHOẢN
   Dùng lại biến & class của ui-v2.css. Chỉ áp cho .v3-tab, .auth-* và thanh tab trên cùng.
   ============================================================ */

/* ---------- Chưa đăng nhập: ẩn thanh tab & nội dung ---------- */
html.auth-pending .nav-tabs,
html.auth-pending .kh-side,
html.auth-pending .main-container { visibility: hidden; }
.nav-tabs .tab-btn[hidden] { display: none; }

/* ---------- Màn hình đăng nhập / khởi tạo ---------- */
.auth-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  background: linear-gradient(160deg, #dcf4f7 0%, #f0f6f8 60%);
  font-family: "Be Vietnam Pro", "Segoe UI", Arial, sans-serif; color: #001c44; overflow-y: auto;
}
.auth-overlay[hidden] { display: none; }
.auth-overlay-soft { background: rgba(0, 28, 68, .45); }
.auth-card {
  width: 100%; max-width: 420px; background: #fff; border: 1px solid #d2dde5; border-radius: 14px;
  padding: 26px 26px 22px; box-shadow: 0 20px 60px rgba(0, 28, 68, .18); margin: auto;
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.auth-brand b { display: block; font-size: 16px; color: #0c5776; }
.auth-brand small { color: #4c6177; font-size: 12.5px; }
.auth-logo { width: 46px; height: 46px; border-radius: 12px; background: #0c5776; color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; font-size: 15px; flex: none; }
.auth-card h2 { font-size: 22px; margin-bottom: 14px; }
.auth-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 14px; font-weight: 600; }
.auth-field small { font-weight: 400; color: #8495a7; }
.auth-input { height: 48px; width: 100%; padding: 0 14px; border: 1px solid #b5c4d0; border-radius: 8px; font-size: 16px; font-family: inherit; color: #001c44; background: #fff; outline: none; }
.auth-input:focus { border-color: #2d99ae; box-shadow: 0 0 0 3px rgba(45, 153, 174, .18); }
.auth-pw { position: relative; display: block; }
.auth-pw .auth-input { padding-right: 52px; }
.auth-eye { position: absolute; right: 4px; top: 4px; width: 44px; height: 40px; border: 0; background: transparent; cursor: pointer; font-size: 18px; border-radius: 6px; }
.auth-eye:hover { background: #f0f6f8; }
.auth-submit { width: 100%; height: 50px; border: 0; border-radius: 9px; background: #0c5776; color: #fff; font-size: 16px; font-weight: 700; cursor: pointer; font-family: inherit; }
.auth-submit:hover { background: #001c44; }
.auth-submit:disabled { opacity: .6; cursor: wait; }
.auth-cancel { height: 50px; padding: 0 20px; border: 1px solid #b5c4d0; border-radius: 9px; background: #fff; font-size: 15px; font-weight: 600; cursor: pointer; font-family: inherit; }
.auth-row { display: flex; gap: 10px; }
.auth-row .auth-submit { flex: 1; }
.auth-msg { background: #f0f6f8; border-radius: 8px; padding: 10px 12px; font-size: 14px; margin-bottom: 14px; }
.auth-err { color: #b42318; font-size: 14px; font-weight: 600; min-height: 20px; margin: -4px 0 10px; }

/* ============================================================
   THANH ĐẦU TRANG (10/2026): logo · menu chữ · ô tìm phiếu · avatar – 1 hàng, không icon
   Bộ màu 001C44 · 0C5776 · 2D99AE · BCFEFE · F8DAD0. Menu thừa dồn vào "Thêm" (header.js)
   ============================================================ */
.app-header {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 20px;
  height: 64px; padding: 0 24px;
  background: #0c5776; box-shadow: 0 2px 10px rgba(0, 28, 68, .2);
  font-family: "Be Vietnam Pro", "Segoe UI", Arial, sans-serif;
}
.app-header .brand {
  flex: none; display: inline-flex; align-items: center; height: 40px; padding: 0 16px;
  border-radius: 12px; background: #f8dad0; color: #001c44;
  font-size: 17px; font-weight: 800; letter-spacing: .3px; white-space: nowrap; cursor: default;
}
/* Menu chữ */
/* Không cắt tràn (overflow) để menu "Thêm" thả ra ngoài được – header.js luôn dồn mục thừa trước khi vẽ */
.nav-tabs { flex: 1 1 auto; min-width: 0; height: 100%; display: flex; align-items: stretch; gap: 4px; }
.app-header .tab-btn, .nav-more-btn {
  flex: none; position: relative; display: inline-flex; align-items: center; gap: 4px;
  padding: 0 12px; border: 0; border-radius: 0; background: none;
  color: #fff; font: inherit; font-size: 15px; font-weight: 700; white-space: nowrap; cursor: pointer;
  transition: color .15s;
}
.app-header .tab-btn:hover, .nav-more-btn:hover { color: #bcfefe; }
/* Mục đang mở: chữ xanh nhạt + vạch dưới */
.nav-tabs > .tab-btn.active, .nav-more.active > .nav-more-btn { color: #bcfefe; }
.nav-tabs > .tab-btn.active::after, .nav-more.active > .nav-more-btn::after {
  content: ''; position: absolute; left: 12px; right: 12px; bottom: 10px; height: 3px; border-radius: 3px; background: #bcfefe;
}
.app-header .tab-btn:focus-visible, .nav-more-btn:focus-visible { outline: 2px solid #bcfefe; outline-offset: -6px; border-radius: 8px; }
.nav-more { position: relative; display: flex; }
.nav-more[hidden] { display: none; }
/* Ô tìm phiếu */
.hdr-search {
  flex: 0 1 260px; min-width: 150px; display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: 999px; background: #bcfefe; color: #0c5776; cursor: text;
}
.hdr-search[hidden] { display: none; }
.hdr-search svg { flex: none; }
.hdr-search input {
  flex: 1; min-width: 0; height: 100%; border: 0; background: none; outline: none;
  font: inherit; font-size: 15px; font-weight: 600; color: #001c44;
}
.hdr-search input::placeholder { color: #0c5776; opacity: .75; }
.hdr-search:focus-within { background: #fff; box-shadow: 0 0 0 3px #f8dad0; }
/* Avatar người dùng */
.hdr-user { position: relative; flex: none; }
.hdr-user[hidden] { display: none; }
.hdr-avatar {
  width: 40px; height: 40px; border-radius: 50%; border: 2px solid #bcfefe; background: #001c44; color: #bcfefe;
  font: inherit; font-size: 14px; font-weight: 800; cursor: pointer;
}
.hdr-avatar:hover, .hdr-avatar[aria-expanded="true"] { background: #bcfefe; color: #001c44; }
/* Menu thả xuống ("Thêm" và menu người dùng) */
.hdr-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 120; min-width: 220px; padding: 6px;
  background: #fff; border-radius: 12px; box-shadow: 0 12px 32px rgba(0, 28, 68, .22);
  display: flex; flex-direction: column;
}
.hdr-menu[hidden] { display: none; }
.nav-more .hdr-menu { top: calc(100% - 6px); left: 0; right: auto; }
.hdr-menu .tab-btn, .hdr-menu-item {
  display: block; width: 100%; height: 42px; padding: 0 14px; border: 0; border-radius: 8px; background: none;
  color: #001c44; font: inherit; font-size: 14.5px; font-weight: 600; text-align: left; cursor: pointer; white-space: nowrap;
}
.hdr-menu .tab-btn:hover, .hdr-menu-item:hover { background: #e8f7fa; color: #0c5776; }
.hdr-menu .tab-btn.active { background: #0c5776; color: #fff; }
.hdr-menu-item[hidden] { display: none; }
.hdr-menu-who { padding: 8px 14px 10px; margin-bottom: 4px; border-bottom: 1px solid #e3ebf0; display: flex; flex-direction: column; line-height: 1.35; }
.hdr-menu-who b { font-size: 15px; color: #001c44; }
.hdr-menu-who small { font-size: 12.5px; color: #4c6177; }
.hdr-menu-item[data-auth="logout"] { color: #b42318; }
@media (max-width: 1100px) {
  .app-header { gap: 12px; padding: 0 16px; }
  .app-header .tab-btn, .nav-more-btn { padding: 0 9px; font-size: 14.5px; }
  .nav-tabs > .tab-btn.active::after, .nav-more.active > .nav-more-btn::after { left: 9px; right: 9px; }
  .hdr-search { flex-basis: 210px; }
}
/* Máy tính bảng / điện thoại: hàng 1 logo · tìm · avatar; hàng 2 menu chữ */
@media (max-width: 900px) {
  .app-header { flex-wrap: wrap; height: auto; padding: 10px 16px 0; gap: 10px 12px; }
  .hdr-search { order: 2; flex: 1 1 0; min-width: 0; max-width: 420px; margin-left: auto; padding: 0 14px; }
  .hdr-user { order: 3; }
  .nav-tabs { order: 10; flex: 1 1 100%; height: 46px; margin: 0 -8px; }
  .app-header .tab-btn, .nav-more-btn { padding: 0 8px; font-size: 14.5px; }
  .nav-tabs > .tab-btn.active::after, .nav-more.active > .nav-more-btn::after { left: 8px; right: 8px; bottom: 6px; }
  .nav-more { position: static; } /* menu "Thêm" canh theo header */
  .nav-more .hdr-menu { left: auto; right: 16px; top: 100%; }
}
@media (max-width: 680px) {
  .app-header { position: relative; padding: 10px 12px 0; }
  .app-header .brand { padding: 0 14px; font-size: 15px; }
  .hdr-search { max-width: none; }
  .nav-more .hdr-menu { left: 12px; right: 12px; }
}

/* ============================================================
   CÁC TAB MỚI
   ============================================================ */
.v3-tab .ui-tab {
  height: 44px; padding: 0 18px; margin: 0; border-radius: 999px; border: 1px solid var(--ui-line-strong);
  background: var(--ui-paper); color: var(--ui-ink); font-size: 14.5px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.v3-tab .ui-tab:hover { border-color: var(--ui-brand); color: var(--ui-brand); }
.v3-tab .ui-tab.active { background: var(--ui-brand); border-color: var(--ui-brand); color: #fff; }

.v3-tab .v3-filter { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.v3-tab .v3-filter .ui-field { flex: 0 1 190px; }
.v3-tab .v3-filter .v3-grow { flex: 1 1 220px; }
.v3-tab .v3-filter-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.v3-tab .v3-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.v3-tab .v3-danger { color: var(--ui-danger); border-color: #e3b4ae; }
.v3-tab .v3-danger:hover { background: var(--ui-danger); color: #fff; border-color: var(--ui-danger); }
.v3-tab .v3-form { border-left: 4px solid var(--ui-brand); }
.v3-tab .v3-editing { margin-bottom: 14px; }
.v3-tab .ui-input.v3-err, .v3-tab .v3-err { border-color: var(--ui-danger) !important; box-shadow: 0 0 0 3px rgba(180, 35, 24, .15) !important; }
.v3-tab .v3-empty { text-align: center; padding: 30px 16px; color: var(--ui-muted); font-size: 15px; }
.v3-tab .v3-pad { padding: 10px 14px; }
.v3-tab .v3-mb { margin-bottom: 10px; }
.v3-tab .v3-neg { color: var(--ui-danger); font-weight: 700; }
.v3-tab .v3-ok { color: var(--ui-brand); }
.v3-tab .v3-textarea { width: 100%; margin-top: 8px; font-size: 14px; font-family: ui-monospace, Consolas, monospace; }
.v3-tab .v3-chip { display: inline-block; padding: 2px 9px; margin: 2px 2px 2px 0; border-radius: 999px; background: var(--ui-wash); border: 1px solid var(--ui-line); font-size: 13px; white-space: nowrap; }
.v3-tab .v3-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.v3-tab .v3-check { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 6px 12px; border: 1px solid var(--ui-line); border-radius: var(--ui-radius-sm); background: var(--ui-paper); cursor: pointer; font-size: 14.5px; }
.v3-tab .v3-check input { width: 20px; height: 20px; accent-color: var(--ui-brand); }
.v3-tab .v3-days { display: inline-flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.v3-tab .v3-sel-sm { height: 38px; min-width: 170px; font-size: 14px; padding: 0 8px; }

/* Bảng */
.v3-tab .v3-table-wrap { overflow: auto; max-height: 680px; }
.v3-tab .v3-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.v3-tab .v3-table th {
  position: sticky; top: 0; z-index: 1; background: var(--ui-wash); color: var(--ui-ink); font-size: 13.5px; font-weight: 700;
  text-align: left; padding: 10px; border-bottom: 2px solid var(--ui-line-strong); white-space: nowrap;
}
.v3-tab .v3-table td { padding: 9px 10px; border-bottom: 1px solid var(--ui-line); vertical-align: middle; }
.v3-tab .v3-table tbody tr:hover td { background: #f3f9fb; }
.v3-tab .v3-table tfoot td { background: var(--ui-wash); font-weight: 700; border-top: 2px solid var(--ui-ink); }
.v3-tab .v3-table .r { text-align: right; }
.v3-tab .v3-table .c { text-align: center; }
.v3-tab .v3-table .nowrap { white-space: nowrap; }
.v3-tab .v3-table .v3-sz { min-width: 46px; padding-left: 4px; padding-right: 4px; }
.v3-tab .v3-table-mini { font-size: 13.5px; }
.v3-tab .v3-table-mini th { position: static; padding: 7px 8px; }
.v3-tab .v3-table-mini td { padding: 7px 8px; }
.v3-tab .v3-group td { background: var(--ui-brand-soft) !important; border-top: 2px solid #a6d9e3; }
.v3-tab .v3-group .ui-btn-sm { height: 32px; margin-left: 10px; font-size: 13px; }
.v3-tab .v3-row-on td { background: var(--ui-amber-soft) !important; }
.v3-tab .v3-row-off td { color: var(--ui-faint); }
.v3-tab .v3-table-dh input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--ui-brand); }

/* Thanh chọn PO để thả chuyền */
.v3-tab .v3-selbar {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); width: min(920px, calc(100% - 32px)); z-index: 60;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; background: var(--ui-ink); color: #fff; border-radius: var(--ui-radius); box-shadow: 0 10px 30px rgba(0, 28, 68, .3);
}
.v3-tab .v3-selbar[hidden] { display: none; }
.v3-tab .v3-selbar .ui-btn-ghost { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .5); }

/* Ô size kiểu ô vuông to */
.v3-tab .v3-sizes-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.v3-tab .v3-total { margin-left: auto; font-size: 15px; }
.v3-tab .v3-total b { font-size: 20px; color: var(--ui-brand); }
.v3-tab .v3-sizes { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; margin-top: 10px; }
.v3-tab .v3-size { display: flex; flex-direction: column; gap: 3px; }
.v3-tab .v3-size span { text-align: center; font-size: 13.5px; font-weight: 700; color: var(--ui-brand); background: var(--ui-brand-soft); border-radius: 5px; padding: 2px 0; }
.v3-tab .v3-size-in, .v3-tab .v3-cell {
  height: 44px; width: 100%; text-align: center; font-size: 16px; font-weight: 600; font-family: inherit;
  border: 1px solid var(--ui-line-strong); border-radius: var(--ui-radius-sm); outline: none; color: var(--ui-ink); background: var(--ui-paper);
}
.v3-tab .v3-cell { min-width: 54px; height: 42px; }
.v3-tab .v3-size-in:focus, .v3-tab .v3-cell:focus { border-color: var(--ui-focus); box-shadow: 0 0 0 3px rgba(45, 153, 174, .18); }
.v3-tab .v3-cell:disabled { background: var(--ui-wash); color: var(--ui-faint); }

/* Đơn hàng: bảng nhập kiểu Excel (mỗi dòng 1 PO) */
.v3-tab .dd-wrap { max-height: 560px; margin-top: 8px; border: 1px solid var(--ui-line); border-radius: var(--ui-radius-sm); }
.v3-tab .dd-grid { font-size: 14px; }
.v3-tab .dd-grid th { padding: 7px 6px; }
.v3-tab .dd-grid td { padding: 2px 3px; border-bottom: 1px solid var(--ui-line); }
.v3-tab .dd-grid tbody tr:hover td { background: transparent; }
.v3-tab .dd-cell {
  width: 100%; height: 36px; padding: 0 7px; border: 1px solid transparent; border-radius: 5px; background: transparent;
  font: inherit; font-size: 14.5px; color: var(--ui-ink); outline: none;
}
.v3-tab .dd-cell:hover { border-color: var(--ui-line-strong); }
.v3-tab .dd-cell:focus { border-color: var(--ui-focus); background: var(--ui-paper); box-shadow: 0 0 0 2px rgba(45, 153, 174, .2); }
.v3-tab .dd-cell::placeholder { color: #a0aebb; font-style: italic; }
.v3-tab .dd-num { text-align: center; font-weight: 600; }
.v3-tab .dd-td-art { min-width: 130px; }
.v3-tab .dd-td-art .dd-cell, .v3-tab .dd-td-po .dd-cell { font-weight: 700; }
.v3-tab .dd-td-po { min-width: 120px; }
.v3-tab .dd-td-mau { min-width: 96px; }
.v3-tab .dd-td-don_gia { min-width: 84px; }
.v3-tab .dd-td-sz { min-width: 58px; }
.v3-tab .dd-grid tr.dd-err td { background: #fdecea !important; }
.v3-tab .dd-grid input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--ui-brand); }
.v3-tab .dd-del { height: 32px; padding: 0 8px; }
.v3-tab .dd-sum { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* Bảng tính kiểu Excel (sheet.js) */
.v3-tab .sheet-wrap { scroll-padding: 34px 0 0 46px; overflow: auto; max-height: 560px; margin-top: 8px; border: 1px solid #c2cdd7; border-radius: 6px; background: #fff; }
.sheet { border-collapse: separate; border-spacing: 0; font-size: 14px; font-family: inherit; user-select: none; }
.sheet th, .sheet td { border-right: 1px solid #dae3ea; border-bottom: 1px solid #dae3ea; padding: 0; height: 32px; background: #fff; }
.sheet thead th { position: sticky; top: 0; z-index: 3; background: #eff4f7; color: #22344f; font-weight: 700; font-size: 13px; padding: 0 8px; text-align: left; white-space: nowrap; border-bottom: 1px solid #c2cdd7; }
.sheet thead th.sheet-num { text-align: center; }
.sheet thead th.on { background: #d0eef3; color: #0c5776; }
.sheet .sheet-corner { left: 0; z-index: 4; min-width: 44px; cursor: pointer; }
.sheet .sheet-rh { position: sticky; left: 0; z-index: 2; background: #eff4f7; color: #5f7184; font-weight: 600; font-size: 12.5px; text-align: center; min-width: 44px; cursor: pointer; border-right: 1px solid #c2cdd7; }
.sheet .sheet-rh.on { background: #d0eef3; color: #0c5776; }
.sheet .sheet-td { position: relative; }
.sheet .sheet-in { display: block; width: 100%; height: 31px; padding: 0 8px; border: 0; outline: none; background: transparent; font: inherit; font-size: 14.5px; color: #001c44; cursor: cell; user-select: text; }
.sheet .sheet-num .sheet-in { text-align: center; font-weight: 600; }
.sheet .sheet-in::placeholder { color: #a0aebb; font-style: italic; }
.sheet td.sheet-sel { background: #dff5f8; }
.sheet td.sheet-act { box-shadow: inset 0 0 0 2px #2d99ae; z-index: 1; }
.sheet td.sheet-act .sheet-in { cursor: text; }
.sheet tr.sheet-err td, .sheet tr.sheet-err th.sheet-rh { background: #fdecea !important; }
.sheet td.sheet-x { padding: 0 8px; text-align: right; white-space: nowrap; color: #22344f; background: #f9fbfc; }
.sheet td.sheet-x.c { text-align: center; }
.sheet td.sheet-x input[type=checkbox] { width: 18px; height: 18px; accent-color: #0c5776; vertical-align: middle; }
.sheet-menu { position: fixed; z-index: 1000; min-width: 220px; padding: 6px; background: #fff; border: 1px solid #c2cdd7; border-radius: 8px; box-shadow: 0 10px 30px rgba(0, 28, 68, .2); display: flex; flex-direction: column; }
.sheet-menu[hidden] { display: none; }
.sheet-menu button { display: flex; justify-content: space-between; gap: 16px; padding: 8px 10px; border: 0; background: none; text-align: left; font: inherit; font-size: 14px; color: #001c44; cursor: pointer; border-radius: 5px; }
.sheet-menu button:hover { background: #dff5f8; }
.sheet-menu button.danger { color: #b42318; }
.sheet-menu kbd { font-family: inherit; font-size: 12px; color: #8495a7; }
.sheet-menu hr { border: 0; border-top: 1px solid #e0e8ee; margin: 4px 0; }
.v3-tab .sheet-help { font-size: 13px; color: var(--ui-muted); }
.v3-tab .sheet-help kbd { font-family: inherit; font-size: 12px; padding: 1px 5px; border: 1px solid var(--ui-line-strong); border-bottom-width: 2px; border-radius: 4px; background: var(--ui-paper); }

/* Chỉ lệnh */
.v3-tab .v3-cl-table td { border-bottom: 0; }
.v3-tab .v3-cl-info td { padding-top: 10px; padding-bottom: 2px; border-top: 1px solid var(--ui-line); color: var(--ui-muted); }
.v3-tab .v3-cl-row td { padding-top: 2px; padding-bottom: 10px; }
.v3-tab .v3-cl-row input[type=checkbox] { width: 24px; height: 24px; accent-color: var(--ui-brand); }
.v3-tab .v3-actionbar {
  position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--ui-paper); border: 1px solid var(--ui-line); border-radius: var(--ui-radius); padding: 12px 16px; box-shadow: 0 -4px 14px rgba(0, 28, 68, .08);
}
.v3-tab .v3-grand { font-size: 16px; }
.v3-tab .v3-grand b { font-size: 22px; color: var(--ui-brand); margin: 0 4px; }

/* Xuất theo đơn hàng */
.v3-tab .v3-td-card { padding: 14px 16px; }
.v3-tab .v3-td-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.v3-tab .v3-td-po { font-size: 17px; }
.v3-tab .v3-td-art { font-weight: 700; color: var(--ui-brand); margin-left: 6px; }
.v3-tab .v3-td-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.v3-tab .v3-td-table th:first-child, .v3-tab .v3-td-table tbody th { position: static; background: var(--ui-paper); text-align: left; font-weight: 600; border-bottom: 1px solid var(--ui-line); white-space: nowrap; }
.v3-tab .v3-muted-row td, .v3-tab .v3-muted-row th { color: var(--ui-muted); }
.v3-tab .v3-con-row td, .v3-tab .v3-con-row th { background: var(--ui-brand-soft) !important; font-weight: 700; font-size: 15px; }
.v3-tab .v3-adj { margin-top: 12px; padding: 14px; border: 1px dashed var(--ui-amber-line); background: var(--ui-amber-soft); border-radius: var(--ui-radius-sm); }
.v3-tab .v3-adj .v3-days { margin-bottom: 10px; }
.v3-tab .v3-td-detail { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--ui-line); }
.v3-tab .v3-td-detail h4 { font-size: 14.5px; margin: 10px 0 6px; }
.v3-tab .v3-alias { list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }

@media (max-width: 680px) {
  .v3-tab .v3-filter .ui-field, .v3-tab .v3-filter .v3-grow { flex: 1 1 100%; }
  .v3-tab .v3-filter-btns { width: 100%; }
  .v3-tab .v3-filter-btns .ui-btn { flex: 1; }
  .v3-tab .v3-subs { flex-wrap: nowrap; overflow-x: auto; }
  .v3-tab .v3-subs .ui-tab { flex: none; height: 40px; padding: 0 14px; font-size: 14px; }
  .v3-tab .v3-actionbar .ui-btn { flex: 1 1 auto; padding: 0 12px; }
  .v3-tab .v3-actionbar .ui-flex-fill { display: none; }
  .v3-tab .v3-sizes { grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); }
}

/* ============================================================
   THANH BÊN KHÁCH HÀNG (khsidebar.js) – mọi tab đi theo khách đang chọn
   ============================================================ */
.app-body { display: flex; align-items: flex-start; }
.app-body > .main-container { flex: 1 1 auto; min-width: 0; }
.kh-side {
  position: sticky; top: var(--kh-top, 12px); flex: none; width: 214px; margin: 16px 0 16px 16px;
  max-height: calc(100vh - var(--kh-top, 12px) - 12px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--ui-paper); border: 1px solid var(--ui-line); border-radius: 12px; padding: 10px 8px;
}
.kh-side:empty { display: none; }
.kh-side-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 8px 6px; font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ui-muted); }
.kh-side-mini { width: 30px; height: 30px; border: 1px solid var(--ui-line); border-radius: 7px; background: var(--ui-paper); color: var(--ui-muted); cursor: pointer; font-size: 16px; line-height: 1; }
.kh-side-mini:hover { border-color: var(--ui-brand); color: var(--ui-brand); }
.kh-side-list { display: flex; flex-direction: column; gap: 4px; }
.kh-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; min-height: 50px; padding: 7px 10px;
  border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--ui-ink); text-align: left; cursor: pointer;
}
.kh-item b { font-size: 15.5px; font-weight: 700; line-height: 1.25; }
.kh-item small { font-size: 12px; color: var(--ui-muted); line-height: 1.3; }
.kh-item i { display: none; font-style: normal; font-weight: 800; font-size: 13px; }
.kh-item:hover { background: var(--ui-wash); border-color: var(--ui-line); }
.kh-item.active { background: var(--ui-brand); border-color: var(--ui-brand); color: #fff; }
.kh-item.active small { color: rgba(255, 255, 255, .8); }
.kh-item-all { min-height: 42px; justify-content: center; border-bottom: 1px solid var(--ui-line); border-radius: 9px 9px 4px 4px; margin-bottom: 2px; }
.kh-item-all b { font-size: 14.5px; }
.kh-item-none { margin-top: 8px; border: 1px dashed var(--ui-amber-line); background: var(--ui-amber-soft); }
.kh-item-none b { color: var(--ui-amber); font-size: 14px; }
.kh-item-none.active { background: var(--ui-amber); border-color: var(--ui-amber); }
.kh-item-none.active b { color: #fff; }

/* Thu gọn: cột hẹp chỉ ghi chữ viết tắt */
body.kh-mini .kh-side { width: 66px; padding: 8px 6px; }
body.kh-mini .kh-side-head { justify-content: center; padding: 0 0 8px; }
body.kh-mini .kh-side-head span { display: none; }
body.kh-mini .kh-side-mini { transform: rotate(180deg); }
body.kh-mini .kh-item { align-items: center; justify-content: center; min-height: 44px; padding: 6px 2px; }
body.kh-mini .kh-item b, body.kh-mini .kh-item small { display: none; }
body.kh-mini .kh-item i { display: block; }
body.kh-mini .kh-item-all i { font-size: 11.5px; }

/* Dòng "Đang xem" ở đầu nội dung */
.kh-current {
  max-width: 1320px; margin: 0 auto 10px; padding: 8px 14px; border-radius: 9px; background: #dcf4f7; color: #001c44;
  font-family: "Be Vietnam Pro", "Segoe UI", Arial, sans-serif; font-size: 14px;
}
.kh-current:empty { display: none; }
.kh-current b { color: #0c5776; font-size: 15px; }
.kh-current span { color: #4c6177; }

/* Lập phiếu: khách theo thanh bên */
#tab-create .pxk-kh-current { cursor: default; }
#tab-create .pxk-kh-warn {
  grid-column: 1 / -1; padding: 12px 14px; border-radius: var(--ui-radius-sm); font-size: 14.5px;
  background: var(--ui-amber-soft); border: 1px solid var(--ui-amber-line); color: var(--ui-ink);
}
#tab-create .pxk-kh-warn b { color: var(--ui-amber); }
/* Đang xem Tất cả khách hàng: chỉ hiện bước chọn khách, ẩn phần nhập phiếu */
#tab-create.pxk-need-kh .ui-step ~ .ui-step, #tab-create.pxk-need-kh .ui-actionbar { display: none; }

/* Khách có bộ chi tiết: chọn xuất theo đôi / theo chi tiết */
#tab-create .pxk-kieu { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1 1 100%; }
#tab-create .pxk-kieu-lbl { font-weight: 700; font-size: 14px; color: #6b2f1a; margin-right: 4px; }
#tab-create .ui-bo-list[hidden] { display: none; }

/* Hộp gán khách hàng cho phiếu cũ */
.kh-assign { position: fixed; inset: 0; z-index: 900; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0, 28, 68, .45); }
.kh-assign-card { width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow-y: auto; background: var(--ui-paper); border-radius: 14px; padding: 20px; box-shadow: 0 20px 60px rgba(0, 28, 68, .25); }
.kh-assign-card h3 { font-size: 19px; margin-bottom: 6px; }
.kh-assign-card p { color: var(--ui-muted); margin-bottom: 14px; }
.kh-assign-card p b { color: var(--ui-ink); }
.kh-assign-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.kh-assign-btn { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 58px; padding: 9px 12px; border: 1px solid var(--ui-line-strong); border-radius: 9px; background: var(--ui-paper); cursor: pointer; text-align: left; color: var(--ui-ink); }
.kh-assign-btn b { font-size: 15.5px; }
.kh-assign-btn small { font-size: 12px; color: var(--ui-muted); line-height: 1.3; }
.kh-assign-btn:hover, .kh-assign-btn:focus-visible { border-color: var(--ui-brand); background: var(--ui-brand-soft); }
.kh-assign-btn:disabled { opacity: .6; cursor: wait; }
.kh-assign-foot { display: flex; justify-content: flex-end; margin-top: 14px; }

/* Tab Tài khoản không dùng thanh bên */
body.kh-off .kh-side, body.kh-off .kh-current { display: none; }

/* Chữ cố định thay cho ô chọn khách trong form */
.v3-tab .v3-fixed {
  display: flex; align-items: center; min-height: 46px; padding: 0 14px; border-radius: var(--ui-radius-sm);
  background: var(--ui-brand-soft); border: 1px solid #a6d9e3; color: var(--ui-brand); font-weight: 700; font-size: 15.5px;
}
.v3-tab .v3-need-kh { text-align: center; padding: 26px 16px; color: var(--ui-ink); font-size: 15.5px; }
.v3-tab .v3-need-kh b { color: var(--ui-brand); }

@media (max-width: 680px) {
  /* Điện thoại: thanh bên thành dải nút vuốt ngang dưới thanh tab */
  .app-body { display: block; }
  .kh-side { position: static; width: auto; max-height: none; margin: 8px 12px 0; padding: 6px; overflow: visible; }
  body.kh-mini .kh-side { width: auto; padding: 6px; }
  .kh-side-head { display: none; }
  .kh-side-list { flex-direction: row; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; gap: 6px; }
  .kh-side-list::-webkit-scrollbar { display: none; }
  .kh-item, body.kh-mini .kh-item { flex: none; width: auto; min-height: 42px; padding: 6px 14px; align-items: center; justify-content: center; border: 1px solid var(--ui-line); }
  .kh-item small, .kh-item i, body.kh-mini .kh-item small, body.kh-mini .kh-item i { display: none; }
  body.kh-mini .kh-item b { display: block; }
  .kh-item b { font-size: 14.5px; white-space: nowrap; }
  .kh-item-all { border-radius: 9px; margin-bottom: 0; }
  .kh-item-none { margin-top: 0; }
  .kh-current { display: none; }
}

/* ============================================================
   TAB ĐỐI CHIẾU GIAO HÀNG (doichieu.js): bảng kiểu Excel theo PO
   Đặt xám · Tổng xanh nhạt · Số thiếu vàng (âm đỏ) · nhãn PO vàng · OK đơn xanh lá
   Ô sửa: chữ xanh dương, góc trái số chênh (tăng xanh lá, giảm đỏ); viền cam = phiếu đã đổi sau khi sửa
   ============================================================ */
.v3-tab .dc-block { padding: 14px 16px; }
.v3-tab .dc-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 10px; font-size: 15px; }
.v3-tab .dc-head b { font-size: 16px; }
.v3-tab .dc-badge-fix { background: #e6f1fb; color: #1f5fbf; }
.v3-tab .dc-wrap { overflow-x: auto; }
.v3-tab .dc-table { border-collapse: collapse; min-width: 100%; font-size: 14px; font-variant-numeric: tabular-nums; }
.v3-tab .dc-table th, .v3-tab .dc-table td { border: 1px solid #b9c7d2; padding: 6px 8px; text-align: center; white-space: nowrap; }
.v3-tab .dc-table thead th { background: #e2efda; color: #001c44; font-weight: 700; }
.v3-tab .dc-table th.dc-sz { min-width: 64px; font-style: italic; }
.v3-tab .dc-table td.dc-fix { background: #fff; vertical-align: middle; }
.v3-tab .dc-table .dc-b { font-weight: 700; }
.v3-tab .dc-table .dc-lbl { text-align: left; font-weight: 700; }
.v3-tab .dc-table .dc-sp { text-align: left; }
.v3-tab .dc-dat td { background: #e3e6ea; font-weight: 700; }
.v3-tab .dc-tong td { background: #ddebf7; color: #1f4e79; font-weight: 700; }
.v3-tab .dc-thieu td { background: #fff59d; font-weight: 700; }
.v3-tab .dc-thieu .dc-lbl { color: #c00000; }
.v3-tab .dc-table .dc-neg { color: #c00000; }
.v3-tab .dc-table td.dc-po { vertical-align: top; }
.v3-tab .dc-po span { display: inline-block; background: #ffeb3b; color: #001c44; font-weight: 800; padding: 3px 10px; border-radius: 6px; }
.v3-tab .dc-ok { display: inline-block; background: #2e9e57; color: #fff; font-weight: 800; padding: 3px 10px; border-radius: 6px; font-size: 13px; }
/* Ô số của phiếu: sửa được như Excel */
.v3-tab .dc-table td.dc-ed { position: relative; min-width: 64px; height: 36px; cursor: cell; }
.v3-tab .dc-table td.dc-ed:hover { box-shadow: inset 0 0 0 2px #2d99ae; }
.v3-tab .dc-table td.dc-chg { color: #1f5fbf; font-weight: 800; }
.v3-tab .dc-d { position: absolute; left: 3px; top: 2px; font-size: 9px; line-height: 1; font-weight: 600; }
.v3-tab .dc-d.up, .v3-tab .dc-up { color: #1e8e3e; }
.v3-tab .dc-d.dn, .v3-tab .dc-dn { color: #c00000; }
.v3-tab .dc-table td.dc-lech { box-shadow: inset 0 0 0 2px #e08a1e; }
.v3-tab .dc-warn { color: #b35c00; }
.v3-tab .dc-table td.dc-editing { padding: 2px; box-shadow: inset 0 0 0 2px #0c5776; }
.v3-tab .dc-in { width: 100%; min-width: 56px; height: 30px; border: 0; outline: none; text-align: center; font: inherit; font-weight: 700; color: #1f5fbf; background: #fff; }
.v3-tab .dc-in-err { background: #fdecea; color: #c00000; }
/* Dòng ĐC: điều chỉnh không gắn phiếu (kiểu cũ) */
.v3-tab .dc-adj td { background: #fff4ec; font-style: italic; color: #6b4a2f; }
.v3-tab .dc-tag { display: inline-block; font-style: normal; font-size: 11px; font-weight: 700; background: #f8dad0; color: #8a2d12; padding: 1px 6px; border-radius: 5px; }
.v3-tab .dc-x { border: 0; background: none; color: #c00000; font-size: 17px; line-height: 1; cursor: pointer; padding: 0 4px; }
.v3-tab .dc-link { border: 0; background: none; padding: 0; color: #0c5776; font: inherit; font-weight: 600; cursor: pointer; text-decoration: underline dotted; }
@media (max-width: 680px) {
  .v3-tab .dc-block { padding: 12px 10px; }
  .v3-tab .dc-table { font-size: 13px; }
  .v3-tab .dc-table th.dc-sz, .v3-tab .dc-table td.dc-ed { min-width: 52px; }
}
