:root {
  --blue: #1d4ed8;
  --blue-dark: #1e3a8a;
  --bg: #f4f6fb;
  --card: #ffffff;
  --border: #e2e6ef;
  --text: #1f2430;
  --text-muted: #6b7280;
  --red: #dc2626;
  --green: #16a34a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  background: var(--blue-dark);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 60px;
  flex-wrap: wrap;
}

.brand {
  font-size: 18px;
  font-weight: bold;
  letter-spacing: 0.5px;
}
.brand span {
  font-weight: normal;
  font-size: 13px;
  opacity: 0.8;
  margin-left: 8px;
}

.tabs {
  display: flex;
  gap: 4px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: white;
  opacity: 0.75;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
  border-radius: 6px 6px 0 0;
}
.tab-btn:hover { opacity: 1; background: rgba(255,255,255,0.08); }
.tab-btn.active {
  opacity: 1;
  background: var(--bg);
  color: var(--blue-dark);
  font-weight: bold;
}

.user-box { display: flex; align-items: center; gap: 10px; font-size: 13px; white-space: nowrap; }
.user-box .btn { padding: 6px 12px; font-size: 13px; }

body.role-nhan-vien .cost-only,
body.role-nhan-vien .giam-doc-only,
body.role-nhan-vien .report-access,
body.role-nhan-vien .write-access {
  display: none !important;
}

body.role-ke-toan .giam-doc-only {
  display: none !important;
}

main { padding: 24px; max-width: 1200px; margin: 0 auto; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.subtabs {
  display: flex;
  gap: 6px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 14px;
}
.subtab-btn {
  background: transparent;
  border: none;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}
.subtab-btn:hover { color: var(--text); }
.subtab-btn.active { color: var(--blue); font-weight: bold; border-bottom-color: var(--blue); }
.subtab-panel { display: none; }
.subtab-panel.active { display: block; }

.add-category-row {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.add-category-row input {
  flex: 1;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
}
.add-category-row .btn { padding: 6px 10px; font-size: 13px; }

#rc_outstanding_table, #pm_outstanding_table { margin: 10px 0; }
#rc_outstanding_table input, #pm_outstanding_table input {
  width: 100px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.panel-head h2 { margin: 0; font-size: 20px; }
.panel-head-actions { display: flex; gap: 10px; }

.hint {
  font-size: 13px;
  color: var(--text-muted);
  background: #eef2fb;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  margin: 10px 0;
}

.hint-small {
  font-size: 11px;
  color: var(--text-muted);
}

.mapping-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin: 14px 0;
}
.mapping-grid label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.mapping-grid select { width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: 6px; }

.btn {
  padding: 9px 16px;
  border: 1px solid var(--border);
  background: white;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}
.btn:hover { background: #f0f2f7; }
.btn-primary {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}
.btn-primary:hover { background: var(--blue-dark); }
.btn-danger { color: var(--red); }
.btn:disabled { opacity: 0.4; cursor: default; }

.pagination-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 14px 0;
  font-size: 14px;
  color: var(--text-muted);
}

.search-box {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}
.filter-row .search-box { flex: 1; margin-bottom: 0; }
.checkbox-label {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-badge {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 10px;
  background: #e6f4ea;
  color: var(--green);
}
.status-badge.inactive {
  background: #fdeaea;
  color: var(--red);
}

.sortable { cursor: pointer; user-select: none; }
.sortable:hover { color: var(--blue); }
.sortable .sort-arrow { font-size: 11px; margin-left: 4px; opacity: 0.6; }

.product-picker { position: relative; }
.product-picker input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
}
.product-picker-list {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  width: max-content;
  min-width: 100%;
  max-width: min(640px, 90vw);
  max-height: 320px;
  overflow-y: auto;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.15);
  z-index: 60;
}
.product-picker-list.open { display: block; }

.product-picker-header {
  display: grid;
  grid-template-columns: 100px minmax(220px,1fr) 60px 90px;
  gap: 12px;
  padding: 8px 14px;
  background: #eef1f8;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  position: sticky;
  top: 0;
}
.product-picker-header.with-price { grid-template-columns: 100px minmax(220px,1fr) 60px 90px 100px; }
.product-picker-header span:nth-child(3),
.product-picker-header span:nth-child(4),
.product-picker-header span:nth-child(5) { text-align: right; }

.product-picker-item {
  display: grid;
  grid-template-columns: 100px minmax(220px,1fr) 60px 90px;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.product-picker-item.with-price { grid-template-columns: 100px minmax(220px,1fr) 60px 90px 100px; }
.product-picker-item.simple { display: block; }
.product-picker-item:last-child { border-bottom: none; }
.product-picker-item:hover, .product-picker-item.highlighted { background: #eef2fb; }
.product-picker-item .sku { color: var(--text-muted); font-size: 13px; }
.product-picker-item .ppi-num { text-align: right; font-variant-numeric: tabular-nums; }
.product-picker-empty { padding: 10px 14px; font-size: 13px; color: var(--text-muted); }

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.data-table th, .data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 14px;
}
.data-table th {
  background: #eef1f8;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
}
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table tbody tr:hover { background: #f7f9fd; }

.row-link { color: var(--blue); cursor: pointer; margin-right: 10px; font-size: 13px; }
.row-link.danger { color: var(--red); }

.low-stock { color: var(--red); font-weight: bold; }

.summary-cards {
  display: flex;
  gap: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.summary-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 18px;
  min-width: 180px;
}
.summary-card .label { font-size: 13px; color: var(--text-muted); }
.summary-card .value { font-size: 22px; font-weight: bold; margin-top: 4px; }

.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.45);
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal-backdrop.active { display: flex; }

.modal {
  background: white;
  border-radius: 10px;
  padding: 24px;
  width: 420px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-wide { width: 640px; }

.modal h3 { margin-top: 0; }

.modal label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin: 12px 0 4px;
}
.modal input, .modal select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  align-items: end;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.po-total {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  font-size: 15px;
}

#poItemsTable, #invoiceItemsTable, #draftItemsTable { margin: 14px 0; overflow: visible; }
#poItemsTable select, #poItemsTable input,
#invoiceItemsTable select, #invoiceItemsTable input,
#draftItemsTable select, #draftItemsTable input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
}

/* ---- Hoa don xem / in ---- */
.invoice-print {
  font-family: Arial, sans-serif;
  color: #111;
  padding: 10px;
}
.invoice-print h2 { margin: 0 0 4px; font-size: 20px; text-align: center; }
.invoice-print .company-info { text-align: center; font-size: 13px; color: var(--text-muted); margin-bottom: 14px; }
.invoice-print .meta-row { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 4px; }
.invoice-print table { width: 100%; border-collapse: collapse; margin: 14px 0; }
.invoice-print th, .invoice-print td { border: 1px solid #999; padding: 6px 8px; font-size: 13px; }
.invoice-print th { background: #f0f2f7; }
.invoice-print td.num, .invoice-print th.num { text-align: right; }
.invoice-print .totals { text-align: right; font-size: 14px; margin-top: 10px; }
.invoice-print .totals strong { font-size: 16px; }
.invoice-print .discount-col { display: none; }
.invoice-print.has-discount .discount-col { display: table-cell; }
.invoice-print .company-header {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid #999;
}
.invoice-print .company-header strong { font-size: 15px; color: #111; }
.invoice-print .invoice-footer {
  margin-top: 22px;
  text-align: center;
  font-size: 13px;
  font-style: italic;
  color: var(--text-muted);
  line-height: 1.6;
}

@media print {
  body * { visibility: hidden; }
  .invoice-print, .invoice-print * { visibility: visible; }
  .invoice-print { position: absolute; top: 0; left: 0; width: 100%; }
  .no-print { display: none !important; }
}

/* ---- DASHBOARD ---- */
.period-presets { display: flex; gap: 4px; }
.preset-btn {
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: white;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
}
.preset-btn:hover { background: #f0f2f7; }
.preset-btn.active { background: var(--blue); color: white; border-color: var(--blue); font-weight: bold; }

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin: 18px 0;
}
.kpi-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
}
.kpi-tile .kpi-label { font-size: 13px; color: var(--text-muted); }
.kpi-tile .kpi-value { font-size: 24px; font-weight: bold; margin-top: 6px; }
.kpi-tile .kpi-change { font-size: 13px; margin-top: 6px; }
.kpi-change.up { color: var(--green); }
.kpi-change.down { color: var(--red); }
.kpi-change.flat { color: var(--text-muted); }

.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.dash-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
}
.dash-card h3 { margin: 0 0 14px; font-size: 15px; }

.qr-settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.qr-settings-grid h4 { margin: 0 0 8px; font-size: 14px; }
.qr-settings-grid label { display: block; margin: 8px 0 4px; font-size: 13px; color: var(--text-muted); }
.qr-settings-grid select, .qr-settings-grid input { width: 100%; }
@media (max-width: 720px) {
  .qr-settings-grid { grid-template-columns: 1fr; }
}

.invoice-qr-row {
  display: flex;
  gap: 24px;
  justify-content: center;
  margin: 14px 0;
  flex-wrap: wrap;
}
.invoice-qr-block {
  text-align: center;
  font-size: 12px;
}
.invoice-qr-block img {
  width: 150px;
  height: 150px;
  display: block;
  margin: 0 auto 4px;
}

.pnl-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.pnl-table td { padding: 8px 4px; border-bottom: 1px solid var(--border); }
.pnl-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.pnl-table tr.pnl-subtotal td { font-weight: bold; border-top: 2px solid var(--text); }
.pnl-table tr.pnl-total td { font-weight: bold; color: var(--blue-dark); font-size: 16px; border-top: 2px solid var(--blue); }
.pnl-table tr.pnl-indent td:first-child { padding-left: 16px; color: var(--text-muted); }

.mini-kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.mini-kpi { background: var(--bg); border-radius: 8px; padding: 12px 14px; }
.mini-kpi .label { font-size: 12px; color: var(--text-muted); }
.mini-kpi .value { font-size: 18px; font-weight: bold; margin-top: 4px; }

.chart-legend { display: flex; gap: 16px; margin-bottom: 10px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); }
.legend-swatch { width: 12px; height: 12px; border-radius: 2px; display: inline-block; }
.swatch-thu { background: var(--blue); }
.swatch-chi { background: var(--red); }

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 200px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 2px;
  overflow-x: auto;
}
.bar-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 28px;
  flex: 1;
  height: 100%;
  justify-content: flex-end;
}
.bar-pair {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  width: 100%;
  height: 100%;
  justify-content: center;
}
.bar-seg {
  width: 10px;
  border-radius: 2px 2px 0 0;
  min-height: 1px;
}
.bar-seg.bar-thu { background: var(--blue); }
.bar-seg.bar-chi { background: var(--red); }
.bar-day-label { font-size: 10px; color: var(--text-muted); margin-top: 4px; white-space: nowrap; }

@media (max-width: 900px) {
  .dash-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .row-2 { grid-template-columns: 1fr; }
  .row-3 { grid-template-columns: 1fr; }
  .modal-wide { width: 95vw; }
  main { padding: 14px; }
}

/* ---- Kiem tra suc khoe so lieu ---- */
.health-item { border-bottom: 1px solid var(--border); padding: 8px 0; }
.health-item summary { cursor: pointer; }
.health-item ul { margin: 4px 0 0 18px; padding: 0; }

/* ---- Thanh tab: nhieu tab thi tu xuong dong tren may tinh (khong bi tran khoi thanh 60px) ---- */
.topbar { height: auto; min-height: 60px; }
.tabs { flex-wrap: wrap; }

/* ================= GIAO DIEN DIEN THOAI (man hinh hep) ================= */
@media (max-width: 900px) {
  .topbar { padding: 8px 12px; gap: 6px; }
  /* Tab vuot ngang bang ngon tay thay vi xuong nhieu dong chiem het man hinh */
  .tabs { order: 3; width: 100%; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab-btn { white-space: nowrap; flex: 0 0 auto; padding: 10px 12px; border-radius: 6px; }
}

@media (max-width: 720px) {
  body { font-size: 15px; }
  .brand span { display: none; }
  .user-box { gap: 6px; }
  .panel-head { flex-wrap: wrap; gap: 10px; }
  .panel-head h2 { font-size: 18px; }
  .panel-head-actions { flex-wrap: wrap; gap: 6px; }
  .filter-row { flex-wrap: wrap; gap: 8px; }
  .filter-row .search-box { flex: 1 1 100%; }
  .checkbox-label { white-space: normal; }
  .period-presets { flex-wrap: wrap; }

  /* Bang danh sach: cuon ngang trong khung, khong lam vo ca trang */
  .data-table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  .data-table th, .data-table td { padding: 8px 10px; font-size: 13px; }
  .row-link { display: inline-block; padding: 4px 0; }

  .summary-cards { gap: 8px; }
  .summary-card { min-width: calc(50% - 4px); flex: 1 1 calc(50% - 4px); padding: 10px 12px; }
  .summary-card .value { font-size: 17px; }
  .kpi-row { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi-tile .kpi-value { font-size: 18px; }
  .mini-kpi-grid { grid-template-columns: 1fr; }
  .dash-card { padding: 12px; }

  /* Hop thoai: chiem tron man hinh, cuon doc */
  .modal-backdrop { align-items: stretch; }
  .modal, .modal-wide { width: 100vw; max-height: 100vh; border-radius: 0; padding: 16px; }
  .modal-actions { position: sticky; bottom: -16px; background: white; padding: 10px 0; margin-bottom: -16px; }
  /* Chu >= 16px trong o nhap de iPhone khong tu phong to man hinh khi bam vao */
  .modal input, .modal select, .search-box, .modal textarea { font-size: 16px; }

  /* Dong hang trong Hoa don / Don nhap / Phieu nhap: xep doc dang the thay vi bang ngang */
  #invoiceItemsTable, #draftItemsTable, #poItemsTable { display: block; white-space: normal; overflow: visible; }
  #invoiceItemsTable thead, #draftItemsTable thead, #poItemsTable thead { display: none; }
  #invoiceItemsTable tbody, #draftItemsTable tbody, #poItemsTable tbody { display: block; }
  #invoiceItemsTable tr, #draftItemsTable tr, #poItemsTable tr {
    display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; padding: 10px 0; border-bottom: 1px solid var(--border);
  }
  #invoiceItemsTable td, #draftItemsTable td, #poItemsTable td { border: none; padding: 0; }
  #invoiceItemsTable td:first-child, #draftItemsTable td:first-child, #poItemsTable td:first-child { grid-column: 1 / -1; }
  #invoiceItemsTable td::before, #draftItemsTable td::before, #poItemsTable td::before {
    display: block; font-size: 11px; color: var(--text-muted);
  }
  #invoiceItemsTable td:nth-child(2)::before, #draftItemsTable td:nth-child(2)::before, #poItemsTable td:nth-child(2)::before { content: "Số lượng"; }
  #invoiceItemsTable td:nth-child(3)::before, #draftItemsTable td:nth-child(3)::before { content: "Giá bán"; }
  #invoiceItemsTable td:nth-child(4)::before, #draftItemsTable td:nth-child(4)::before { content: "Chiết khấu %"; }
  #invoiceItemsTable td:nth-child(5)::before, #draftItemsTable td:nth-child(5)::before { content: "Thành tiền"; }
  #poItemsTable td:nth-child(3)::before { content: "Giá vốn"; }
  #poItemsTable td:nth-child(4)::before { content: "Thành tiền"; }

  /* O go-tim san pham: cot gon lai cho vua man hinh */
  .product-picker-list { max-width: 94vw; }
  .product-picker-header, .product-picker-item { grid-template-columns: 70px minmax(120px,1fr) 44px 56px; gap: 6px; padding: 8px 10px; font-size: 13px; }
  .product-picker-header.with-price, .product-picker-item.with-price { grid-template-columns: 70px minmax(120px,1fr) 44px 56px 72px; }

  .invoice-print .meta-row { flex-direction: column; }
  .po-total { justify-content: flex-start; }
}

/* ================= LEN DON TREN DIEN THOAI (Hoa don / Don nhap / Phieu nhap) - 2026-11-09 =================
   Nut/goi y "mobile-only" an tren may tinh; tren man hinh <= 720px moi hien. Xem mobileEnhanceItemRow() trong app.js. */
body .mobile-only { display: none; }
.qty-stepper { display: flex; align-items: center; gap: 6px; }
.qty-stepper input { flex: 1; min-width: 0; }
.paid-row { display: flex; gap: 8px; align-items: center; }
.paid-row input { flex: 1; min-width: 0; }
/* O tich trong hop thoai khong bi keo rong 100% (lam o tich lech khoi dong chu) */
.modal .checkbox-label input[type="checkbox"] { width: auto; flex: 0 0 auto; margin: 0; }

@media (max-width: 720px) {
  body button.mobile-only { display: inline-flex; align-items: center; justify-content: center; }
  body div.mobile-only { display: block; }
  body span.mobile-only { display: inline; }

  /* --- 1. Danh sach chon hang dang the: ten to, duoi la ma . DVT . ton . gia; khong cuon ngang --- */
  .product-picker input { padding: 10px 12px; }
  .product-picker-list { width: 100%; min-width: 0; max-width: none; max-height: 55vh; overflow-x: hidden; }
  .product-picker-header { display: none; }
  .product-picker-item:not(.simple), .product-picker-item.with-price:not(.simple) {
    grid-template-columns: auto auto 1fr auto;
    grid-template-areas: "name name name name" "sku unit stock price";
    gap: 3px 10px; padding: 11px 12px; font-size: 13px;
  }
  .product-picker-item:not(.simple) > span:nth-child(1) { grid-area: sku; }
  .product-picker-item:not(.simple) > span:nth-child(2) { grid-area: name; font-size: 15px; font-weight: 600; color: var(--text); white-space: normal; }
  .product-picker-item:not(.simple) > span:nth-child(3) { grid-area: unit; color: var(--text-muted); }
  .product-picker-item:not(.simple) > span:nth-child(4) { grid-area: stock; text-align: left; color: var(--text-muted); }
  .product-picker-item:not(.simple) > span:nth-child(4)::before { content: "Tồn "; font-weight: normal; }
  .product-picker-item:not(.simple) > span:nth-child(4).low-stock { color: var(--red); }
  .product-picker-item:not(.simple) > span:nth-child(5) { grid-area: price; font-weight: 700; color: var(--blue-dark); }
  .product-picker-item:not(.simple) > span:nth-child(5)::after { content: " đ"; font-weight: normal; }
  .product-picker-item.simple { padding: 11px 12px; }

  /* --- Dong hang dang the: nut X o goc, o san pham chua cho cho nut X --- */
  #invoiceItemsTable tr, #draftItemsTable tr, #poItemsTable tr { position: relative; padding: 12px 0; }
  #invoiceItemsTable td:first-child, #draftItemsTable td:first-child, #poItemsTable td:first-child { padding-right: 50px; }
  #invoiceItemsTable td:last-child, #draftItemsTable td:last-child, #poItemsTable td:last-child { position: absolute; top: 12px; right: 0; }
  #invoiceItemsTable td:last-child .row-link.danger, #draftItemsTable td:last-child .row-link.danger, #poItemsTable td:last-child .row-link.danger {
    font-size: 0; margin: 0; padding: 0; width: 42px; height: 42px; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid #f1c4c4; border-radius: 8px; background: #fff5f5;
  }
  #invoiceItemsTable td:last-child .row-link.danger::after, #draftItemsTable td:last-child .row-link.danger::after, #poItemsTable td:last-child .row-link.danger::after {
    content: "✕"; font-size: 18px; color: var(--red);
  }
  /* Thanh tien moi dong: chu to, de doc */
  #invoiceItemsTable td:nth-child(5), #draftItemsTable td:nth-child(5), #poItemsTable td:nth-child(4) { font-size: 16px; font-weight: 700; align-self: end; }

  /* --- 2. Nut - / + quanh o so luong --- */
  .qty-btn { flex: 0 0 44px; width: 44px; height: 44px; padding: 0; font-size: 22px; line-height: 1; border: 1px solid var(--border); border-radius: 8px; background: #f3f5fa; color: var(--text); }
  .qty-btn:active { background: #dfe5f3; }
  .qty-stepper input { text-align: center; }

  /* --- 4. Goi y so tien co dau cham: "= 420.000 đ" --- */
  .money-hint { font-size: 12px; color: var(--text-muted); margin-top: 3px; min-height: 15px; }

  /* --- 5. Chiet khau an sau nut "+ Chiet khau" (dong nao da co chiet khau thi tu hien) --- */
  #invoiceItemsTable tr:not(.ck-open) .inv-item-discount, #draftItemsTable tr:not(.ck-open) .draft-item-discount { display: none; }
  #invoiceItemsTable tr:not(.ck-open) td:nth-child(4)::before, #draftItemsTable tr:not(.ck-open) td:nth-child(4)::before { display: none; }
  .ck-toggle { background: none; border: none; color: var(--blue); font-size: 14px; padding: 10px 0; cursor: pointer; }
  body tr.ck-open .ck-toggle { display: none; }

  /* --- Nut them dong hang: to, de bam --- */
  #btnAddInvoiceItem, #btnAddDraftItem, #btnAddPoItem { width: 100%; padding: 12px; margin: 8px 0 4px; border-style: dashed; color: var(--blue); font-weight: 600; }

  /* --- 6. Thanh day co dinh: Tong tien + nut Luu --- */
  .modal-actions { align-items: center; box-shadow: 0 -6px 12px -8px rgba(0,0,0,0.25); z-index: 5; }
  .mobile-total { margin-right: auto; font-size: 13px; color: var(--text-muted); white-space: nowrap; }
  .mobile-total strong { font-size: 19px; color: var(--blue-dark); }

  /* --- 7. Nut "Khach tra du" --- */
  #btnInvPayFull { white-space: nowrap; padding: 10px 12px; }

  /* --- 8. Gom phan it dung vao "Them thong tin": dua xuong duoi bang order, an khi chua mo --- */
  #invoiceForm { display: flex; flex-direction: column; }
  #invoiceForm > .extra-toggle { order: 1; margin: 12px 0 4px; padding: 12px; justify-content: flex-start; text-align: left; color: var(--blue); font-weight: 600; background: #f3f6fd; border-color: #d5def3; }
  #invoiceForm > .mobile-extra { order: 2; }
  #invoiceForm:not(.show-extra) > .mobile-extra { display: none; }
  #invoiceForm > .note-label, #invoiceForm > .note-input { order: 3; }
  #invoiceForm > .modal-actions { order: 4; }

  /* --- 9. O tich "Khach da tra tien ship": nam canh dong chu --- */
  .modal .checkbox-label { white-space: normal; align-items: flex-start; gap: 10px; margin: 10px 0; font-size: 14px; }
  .modal .checkbox-label input[type="checkbox"] { width: 22px; height: 22px; margin-top: 1px; }
}
