/* ==========================================================================
   HỆ THỐNG QUẢN LÝ HÓA ĐƠN & ĐƠN BÁO GIÁ NHÁP
   ========================================================================== */

:root {
  /* Brand & Theme Colors */
  --primary: #dc2626;
  --primary-hover: #b91c1c;
  --primary-gradient: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  --primary-light: #fef2f2;
  --primary-ring: rgba(220, 38, 38, 0.2);
  
  --secondary: #0f172a;
  --secondary-hover: #1e293b;
  --accent-blue: #2563eb;
  --accent-blue-light: #eff6ff;
  --accent-green: #059669;
  --accent-green-light: #ecfdf5;
  
  /* Neutral Palette */
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --text-main: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --border-ui: #e2e8f0;
  --border-subtle: #f1f5f9;
  
  /* Geometry & Elevation */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 28px -4px rgba(15, 23, 42, 0.1), 0 4px 12px -2px rgba(15, 23, 42, 0.05);
  --shadow-xl: 0 24px 48px -12px rgba(15, 23, 42, 0.22);
  --shadow-paper: 0 20px 45px -10px rgba(15, 23, 42, 0.12), 0 0 0 1px rgba(15, 23, 42, 0.05);
  
  /* Typography */
  --font-sans: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-invoice: 'Times New Roman', Times, 'Segoe UI', serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

/* ================= TOP NAVIGATION / GLASS HEADER (3-COLUMN BALANCED LAYOUT) ================= */
.app-header {
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 4px 18px -4px rgba(15, 23, 42, 0.06);
}

/* Cột 1 (Trái): Logo & Tên - Căn đều trên dưới tuyệt đối */
.header-left-zone {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex: 0 0 auto;
  min-width: 0;
}

/* Cột 2: hàng tiện ích căn đúng bề ngang tờ hóa đơn */
.header-center-slot {
  display: contents;
}

.header-center-stack {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  justify-content: center;
  flex: 0 1 auto;
  gap: 6px;
  min-width: 0;
}

.header-edit-stack {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 6px;
  min-width: 0;
  width: max-content;
  max-width: 100%;
}

.header-tool-box {
  display: inline-grid;
  grid-template-columns: max-content;
  justify-items: start;
  gap: 6px;
  max-width: 100%;
}

.header-manage-tools {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  box-sizing: border-box;
}

.header-manage-tools .btn {
  height: 30px !important;
  padding: 0 12px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  border-radius: 6px !important;
  white-space: nowrap !important;
  color: #475569 !important;
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  line-height: 1 !important;
}

.header-manage-tools .btn:hover {
  background: #f8fafc !important;
  color: #0f172a !important;
  border-color: #94a3b8 !important;
}

/* Cột 3 (Phải): Thông tin Người lập & Đăng xuất - Căn đều trên dưới tuyệt đối */
.header-right-zone {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 0 0 auto;
  gap: 6px;
  width: max-content;
  min-width: 0;
  max-width: 100%;
}

.header-settings-label {
  display: none;
}

.header-gear-btn {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 999px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #0f172a;
  cursor: pointer;
}

.header-center-stack .summary-toggles-wrapper {
  height: 30px;
  gap: 6px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
}

.header-center-stack .summary-toggles-wrapper .btn-toggle {
  height: 30px !important;
  padding: 0 12px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  border-radius: 6px !important;
  line-height: 1 !important;
}

@media (min-width: 701px) and (min-height: 501px) {
  .header-gear-btn {
    width: auto;
    height: 30px;
    flex: 0 0 auto;
    padding: 0 12px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #475569;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-sans);
    line-height: 1;
  }

  .header-gear-btn .header-gear-icon {
    display: none;
  }

  .header-settings-label {
    display: inline;
  }

  .header-gear-btn:hover {
    background: #f8fafc;
    color: #0f172a;
    border-color: #94a3b8;
  }

  .app-header .user-auth-pill {
    height: 30px;
    align-items: stretch;
    border-radius: 6px;
    max-width: 240px;
    padding: 0 0 0 10px;
    gap: 8px;
  }

  .app-header .auth-name {
    font-size: 12px;
    font-weight: 600;
    align-self: center;
  }

  .app-header .user-auth-pill .btn-user-action {
    height: auto;
    align-self: stretch;
    padding: 0 8px;
    font-size: 12px;
    font-weight: 600;
    border: none;
    border-left: 1px solid #e2e8f0;
    border-radius: 0;
    background: transparent;
  }

  .app-header .header-right-zone .btn-logout-action {
    border-radius: 0 5px 5px 0;
  }

  .header-center-stack {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: stretch;
    justify-content: center;
    gap: 6px;
    width: min(794px, 100%);
    max-width: 794px;
    margin: 0 auto;
    flex: 0 0 auto;
  }

  .header-right-zone {
    margin-left: auto;
  }

  .header-account-cluster {
    display: grid;
    grid-template-columns: repeat(3, max-content);
    gap: 6px;
    justify-items: stretch;
    align-items: center;
  }

  .header-account-cluster > .header-gear-btn {
    width: auto;
    min-width: max-content;
    justify-content: center;
    white-space: nowrap;
  }

  .header-account-cluster > .user-auth-pill {
    grid-column: 1 / -1;
    width: 100%;
    max-width: none;
    height: 30px;
    box-sizing: border-box;
    justify-content: space-between;
  }

  .header-account-cluster .auth-name {
    flex: 1 1 auto;
    max-width: none;
  }

  .header-edit-stack,
  .header-tool-box,
  .header-manage-tools,
  .header-tool-box .toolbar-edit-group,
  .toolbar-export-group,
  .header-center-stack .summary-toggles-wrapper {
    display: contents;
  }

  .header-center-stack .btn,
  .header-center-stack .btn-toggle {
    width: 100%;
    min-width: 0;
    height: 30px !important;
    margin: 0;
    justify-content: center;
    box-sizing: border-box;
  }
}

.header-util-menu {
  position: relative;
  flex: 0 0 auto;
  z-index: 30;
}

.app-header,
.header-center-stack,
.header-edit-stack,
.header-tool-box,
.header-manage-tools,
.quick-bar-actions-row {
  overflow: visible;
}

.header-util-pop {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 148px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
  z-index: 1100;
}

.header-util-pop[hidden] {
  display: none !important;
}

.header-util-item {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: #0f172a;
  cursor: pointer;
  font-family: inherit;
}

.header-util-item:hover {
  background: #f1f5f9;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.brand-badge img {
  height: 30px;
  width: auto;
  border-radius: var(--radius-sm);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.06));
}

.brand-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  justify-content: center;
  letter-spacing: -0.3px;
  line-height: 1.15;
}



.brand-title span:first-child {
  color: #000000;
  background: none;
  -webkit-text-fill-color: #000000;
}

.brand-subtitle {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 1px;
}

/* ================= MODERN BUTTONS ================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 15px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: var(--font-sans);
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--primary-gradient);
  color: #ffffff;
  border-color: rgba(220, 38, 38, 0.2);
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.25);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.35);
  transform: translateY(-1px);
}

.btn-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  border-color: rgba(5, 150, 105, 0.2);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}

.btn-success:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
  transform: translateY(-1px);
}

.btn-outline {
  background: #ffffff;
  color: #334155;
  border: 1px solid #cbd5e1;
  box-shadow: var(--shadow-sm);
}

.btn-outline:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #0f172a;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12.5px;
  border-radius: var(--radius-sm);
}

/* ================= USER AUTH (RIGHT ZONE) ================= */
.user-auth-pill {
  display: inline-flex;
  align-items: center;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-full);
  padding: 2px 3px 2px 8px;
  gap: 6px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  font-family: var(--font-sans);
  flex: 0 1 auto;
  width: auto;
  min-width: 0;
  max-width: 186px;
  overflow: hidden;
}

.auth-name {
  display: block;
  flex: 0 1 auto;
  width: auto;
  min-width: 0;
  max-width: 96px;
  font-size: 12px;
  font-weight: 700;
  color: #1e293b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-user-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  font-size: 10.5px;
  font-weight: 600;
  color: #475569;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--font-sans);
  line-height: 1.35;
  white-space: nowrap;
}

.btn-user-action:hover {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #94a3b8;
}

.btn-logout-action {
  flex-shrink: 0;
  color: #dc2626;
  border-color: #fecaca;
  background: #fff5f5;
}

.btn-logout-action:hover {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
}

/* ================= TẦNG 2: THANH TÍNH NĂNG DÙNG NHIỀU (SOẠN THẢO + XUẤT FILE) ================= */
.toolbar-edit-group,
.toolbar-export-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.header-tool-box .toolbar-edit-group {
  width: max-content;
  justify-content: flex-start;
}

.toolbar-export-group {
  margin-bottom: 0;
}

/* Chuẩn hóa nút bấm Tầng 2: rộng rãi, thoáng, chiều cao 30px, cực kỳ dễ bấm */
.toolbar-edit-group .btn,
.toolbar-export-group .btn,
.header-edit-stack > .btn-action-add-item {
  height: 30px !important;
  padding: 0 12px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  border-radius: 6px !important;
  white-space: nowrap !important;
  flex-shrink: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  line-height: 1 !important;
  box-sizing: border-box !important;
}

.toolbar-edit-group .btn span,
.toolbar-export-group .btn span,
.header-edit-stack > .btn-action-add-item span {
  white-space: nowrap !important;
  display: inline-block !important;
}

.btn-add-highlight {
  color: #2563eb !important;
  border-color: #bfdbfe !important;
  background: #eff6ff !important;
  font-weight: 700 !important;
  padding: 0 14px !important;
}

.btn-add-highlight:hover {
  background: #dbeafe !important;
  color: #1d4ed8 !important;
  border-color: #93c5fd !important;
}

/* Nhóm nút bật tắt Đặt cọc / Giảm giá */
.summary-toggles-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 2px 4px;
  height: 30px;
  box-sizing: border-box;
  flex-shrink: 0;
}

.summary-toggles-wrapper .btn-toggle {
  height: 24px !important;
  padding: 0 8px !important;
  font-size: 11.5px !important;
  font-weight: 600 !important;
  border-radius: 4px !important;
  line-height: 1 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  white-space: nowrap !important;
  flex-shrink: 0 !important;
  box-sizing: border-box !important;
}

/* ================= MAIN APP LAYOUT ================= */
.app-container {
  max-width: 1280px;
  margin: 12px auto 60px auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Trên desktop, ẩn quick-bar vì toàn bộ nút đã được đưa lên thanh Navbar cố định */
@media (min-width: 701px) and (min-height: 501px) {
  .quick-bar {
    display: none !important;
  }
}

/* ================= QUICK ACTION FLOATING BAR ================= */
.quick-bar {
  position: sticky;
  top: 66px;
  z-index: 800;
  width: 100%;
  max-width: 830px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: var(--radius-lg);
  padding: 8px 16px;
  margin: 0 auto 16px auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  box-shadow: 0 4px 16px -2px rgba(15, 23, 42, 0.08);
  transition: all 0.2s ease;
}

.quick-bar-left, .quick-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.quick-hint {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ================= SUMMARY ROW TOGGLE BUTTONS ================= */
.summary-toggles-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 2px 6px;
}

.toggle-hint-label {
  font-size: 11.5px;
  font-weight: 600;
  color: #64748b;
  margin-right: 2px;
}

.btn-toggle {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: #475569;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--font-sans);
  white-space: nowrap;
}

.btn-toggle:hover {
  background: #f8fafc;
  color: #0f172a;
  border-color: #94a3b8;
}

.btn-toggle.active {
  background: #dc2626;
  color: #ffffff;
  border-color: #dc2626;
  box-shadow: 0 1px 4px rgba(220, 38, 38, 0.25);
}

/* ================= INVOICE PAPER (CHUẨN A4 KHỔ DỌC: 794px x 1123px) ================= */
.invoice-wrapper {
  width: 100%;
  max-width: 100%;
  display: block;
  margin: 0 auto;
  padding: 8px 0 60px 0;
  background: transparent;
  box-shadow: none;
  border: none;
  border-radius: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.invoice-fit-container {
  display: block;
  width: auto;
  margin: 0 auto;
  position: relative;
}

.invoice-paper {
  display: block;
  width: 794px;
  min-width: 794px;
  max-width: 794px;
  min-height: 1123px;
  margin: 0 auto;
  background: #ffffff;
  padding: 28px 30px 36px 30px;
  position: relative;
  font-family: var(--font-invoice);
  color: #000000;
  box-sizing: border-box;
  box-shadow: var(--shadow-paper);
  border-radius: var(--radius-xs);
  display: flex;
  flex-direction: column;
}

.inv-main-content {
  width: 100%;
}

/* ================= TOP CONTAINER & ABSOLUTE BANK QR ================= */
.inv-top-container {
  position: relative;
  width: 100%;
  margin-bottom: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  grid-template-areas:
    "brand qr"
    "title title";
  column-gap: 16px;
  row-gap: 8px;
  align-items: start;
}

.inv-brand-row {
  position: relative;
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  max-width: none;
  margin-top: 20px;
}

.inv-shop-logo-box {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  margin-bottom: 0;
}

.inv-shop-logo-box .inv-logo-img {
  height: 56px;
  width: auto;
  max-width: 110px;
  object-fit: contain;
  cursor: pointer;
  transition: transform 0.2s;
  display: block;
}

.inv-shop-logo-box .inv-logo-img:hover {
  transform: scale(1.02);
}

.inv-company-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  font-size: 12px;
  line-height: 1.45;
  min-width: 0;
  flex: 1;
}

.inv-company-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
  color: #000;
  text-transform: uppercase;
  max-width: 100%;
  word-break: break-word;
  overflow-wrap: break-word;
}

.inv-company-sub {
  font-size: 11.5px;
  line-height: 1.45;
  max-width: 100%;
  word-break: break-word;
  overflow-wrap: break-word;
}

#shop-contact-line {
  white-space: nowrap;
}

/* ================= TIÊU ĐỀ ĐƠN BÁO GIÁ ================= */
.inv-center-header {
  position: relative;
  grid-area: title;
  text-align: center;
  z-index: 1;
  margin: 4px 0 0;
  padding: 0;
}

.inv-top-container:not(.qr-off) .inv-center-header {
  margin-top: -42px;
}

.inv-center-header .inv-title {
  font-size: 23px;
  font-weight: 800;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #000;
  white-space: nowrap;
}

/* ================= ẢNH STK VIETCOMBANK Ở GÓC PHẢI ================= */
.inv-bank-qr-fixed {
  position: relative;
  grid-area: qr;
  width: 142px;
  justify-self: end;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0;
  overflow: visible;
}

.qr-quick {
  position: absolute;
  left: 0;
  top: 100%;
  width: 142px;
  max-width: 142px;
  margin-top: 2px;
  display: flex;
  flex-direction: column;
  gap: 0;
  font-family: var(--font-sans);
  z-index: 8;
  box-sizing: border-box;
}

.qr-quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  width: 142px;
}

.qr-quick-actions:has(.qr-quick-btn-hide[hidden]) .qr-quick-btn-change {
  grid-column: 1 / -1;
}

.qr-quick-btn {
  min-width: 0;
  height: 18px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #1e293b;
  border-radius: 4px;
  padding: 0 3px;
  font-size: 8px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.qr-quick-btn:hover {
  border-color: #0f172a;
  background: #f8fafc;
}

.inv-bank-qr-fixed.is-empty .qr-quick-btn-change {
  min-height: 18px;
  border-style: dashed;
}

.inv-bank-qr-fixed.is-hidden .qr-quick {
  padding: 0;
  border: none;
  background: transparent;
}

.qr-quick-btn.is-off,
.btn-toggle.is-off {
  background: #111111;
  color: #ffffff;
  border-color: #111111;
}

.inv-bank-card-img {
  width: 142px;
  height: auto;
  max-height: 165px;
  object-fit: contain;
  cursor: pointer;
  transition: transform 0.2s;
  display: block;
  border-radius: 4px;
}

.inv-bank-card-img:hover {
  transform: scale(1.02);
}

/* ================= KHỐI THÔNG TIN KHÁCH HÀNG ================= */
.inv-customer-section {
  width: 100%;
  margin-bottom: 8px;
  font-size: 13px;
  line-height: 1.6;
}

.inv-cust-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.inv-cust-pair {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  column-gap: 32px;
  row-gap: 6px;
}

.inv-cust-pair .inv-cust-row {
  flex: 0 0 auto;
}

.inv-cust-pair .inv-cust-val {
  flex: 0 0 auto;
  min-width: 9em;
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
}

.inv-cust-address {
  width: 100%;
}

.inv-cust-row {
  display: flex;
  align-items: baseline;
  min-width: 0;
}

.inv-cust-label {
  font-weight: 700;
  white-space: nowrap;
  width: auto;
  flex: 0 0 auto;
  margin-right: 6px;
  color: #000;
}

.inv-cust-val {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  color: #000;
  word-break: break-word;
  overflow-wrap: anywhere;
  min-height: 20px;
}

.inv-cust-val:empty:before {
  content: attr(data-placeholder);
  color: #94a3b8;
  font-weight: normal;
  font-style: italic;
  font-size: 12px;
}

/* ================= SUMMARY ROW TOGGLES ================= */
.summary-toggles-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  border: 1px solid #cbd5e1;
  margin-left: 6px;
}

.toggle-hint-label {
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  margin-right: 2px;
}

.btn-toggle {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  padding: 3px 9px;
  font-size: 11.5px;
  font-weight: 700;
  border-radius: var(--radius-full);
  cursor: pointer;
  color: #475569;
  transition: all 0.2s ease;
  font-family: var(--font-sans);
}

.btn-toggle:hover {
  background: #e2e8f0;
}

.btn-toggle.active {
  background: #eff6ff;
  border-color: #3b82f6;
  color: #1d4ed8;
  box-shadow: 0 1px 3px rgba(59, 130, 246, 0.2);
}

.row-opt-btn {
  position: absolute;
  left: 250px;
  right: auto;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  background: #ffffff;
  color: #dc2626;
  border: 1px solid #fecaca;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
  cursor: pointer;
  margin: 0;
  line-height: 0;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
  z-index: 2;
}

.row-opt-btn svg,
.row-action-btn svg {
  display: block;
  width: 10px;
  height: 10px;
}

tr:hover .row-opt-btn {
  opacity: 1;
}

/* ================= DÒNG KÍNH GỬI ================= */
.inv-greeting-center {
  width: 100%;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  font-style: italic;
  margin: 6px 0 10px 0;
  letter-spacing: 0.3px;
  color: #000000;
}

/* ================= TABLE (TỔNG CHUẨN 734PX KHÔNG BAO GIỜ TRÀN) ================= */
.inv-table {
  width: 100%;
  border-collapse: collapse !important;
  border-spacing: 0 !important;
  border: 1.5px solid #000000 !important;
  margin-bottom: 12px;
  table-layout: fixed;
  border-radius: 0 !important;
}

.inv-table th,
.inv-table td {
  border: 1px solid #000000 !important;
  border-radius: 0 !important;
  padding: 6px 6px;
  font-size: 12.5px;
  vertical-align: middle;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.35;
  box-sizing: border-box;
}

.inv-table [contenteditable="true"] {
  border-radius: 0 !important;
  outline: none !important;
  box-shadow: none !important;
}

.inv-table [contenteditable="true"]:hover {
  background-color: #f8fafc !important;
  border-radius: 0 !important;
}

.inv-table [contenteditable="true"]:focus {
  background-color: #eff6ff !important;
  outline: 1.5px solid #2563eb !important;
  outline-offset: -1px !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

/* CĂN GIỮA TIÊU ĐỀ BẢNG */
.inv-table th {
  font-weight: 700;
  text-align: center !important;
  vertical-align: middle;
  background-color: #ffffff;
  color: #000000;
  text-transform: uppercase;
  font-size: 11px;
  height: 30px;
  letter-spacing: 0px;
  white-space: nowrap;
  padding: 6px 2px;
}

.inv-table .col-stt { width: 34px; text-align: center; font-size: 12px; }
.inv-table .col-name { width: 236px; text-align: left; font-size: 12.5px; }
.inv-table .col-code { width: 60px; text-align: center; font-size: 12px; }
.inv-table .col-price { width: 90px; text-align: right; font-size: 12.5px; }
.inv-table .col-qty { width: 76px; text-align: center; font-size: 12px; }
.inv-table .col-total { width: 118px; text-align: right; font-weight: 600; font-size: 13px; }
.inv-table .col-note { width: 120px; text-align: left; font-size: 12px; }

.inv-table tbody tr {
  height: 32px;
}

.inv-table tbody td.col-stt {
  position: relative;
  overflow: visible;
  padding-left: 4px;
  padding-right: 4px;
}

.inv-table .stt-num {
  display: inline-block;
  min-width: 1ch;
  line-height: 1.2;
}

.inv-table .row-action-btn {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translate(-72%, -50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  color: #dc2626;
  background: #ffffff;
  border: 1px solid #fecaca;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
  cursor: pointer;
  line-height: 0;
  opacity: 0;
  z-index: 3;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.inv-table .row-action-btn::before {
  content: "";
  position: absolute;
  inset: -7px;
}

.inv-table tbody tr:hover .row-action-btn,
.inv-table .row-action-btn:focus-visible {
  opacity: 1;
  background: #fef2f2;
}

/* Summary Rows - Căn trái bắt đầu từ cột Mã SP (276px), không có đường kẻ dọc chia cắt */
.summary-label {
  position: relative;
  text-align: left !important;
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: 0.2px;
  padding-left: 276px !important;
  padding-right: 6px !important;
  vertical-align: middle;
  white-space: nowrap;
}

.summary-hint {
  font-size: 10.5px;
  font-weight: normal;
  font-style: italic;
  color: #64748b;
  margin-left: 4px;
  letter-spacing: 0;
  text-transform: none;
  display: inline-block;
  vertical-align: baseline;
}

.summary-value {
  text-align: right !important;
  font-weight: 700;
  font-size: 13px;
}

.summary-value.text-red {
  color: #c41c13;
  font-size: 14px;
}

/* ================= FOOTER NOTES & SIGNATURES ================= */
.inv-footer {
  margin-top: 18px;
  font-size: 12.5px;
  line-height: 1.5;
  width: 100%;
}

.inv-footer-flex {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  gap: 16px;
}

.inv-notes-block {
  width: 100%;
  font-size: 12.5px;
  line-height: 1.6;
}

.inv-note-line {
  margin-bottom: 4px;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.inv-note-line.is-blank {
  display: none;
}

.inv-notes-block:hover .inv-note-line.is-blank,
.inv-notes-block:focus-within .inv-note-line.is-blank {
  display: block;
}

.inv-note-line.is-blank > .inv-note-label {
  display: none;
}

.inv-note-hint {
  display: none;
  color: #94a3b8;
  font-weight: normal;
  font-style: italic;
  font-size: 12px;
}

.inv-notes-block.is-all-blank:not(:hover):not(:focus-within) .inv-note-hint {
  display: inline;
}

.inv-note-line:empty:before,
#note-line-1:empty:before {
  content: attr(data-placeholder);
  color: #94a3b8;
  font-weight: normal;
  font-style: italic;
  font-size: 12px;
}

.inv-note-label {
  text-decoration: underline;
  font-weight: 700;
}

.inv-sign-block {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding-right: 64px;
  box-sizing: border-box;
  break-inside: avoid;
  page-break-inside: avoid;
}

.inv-sign-cluster {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
}

.inv-date-line {
  text-align: center;
  margin-bottom: 8px;
  font-size: 12.5px;
  width: max-content;
  max-width: 100%;
  white-space: normal;
  font-style: italic;
}

.inv-sign-columns {
  --sign-gap: 36px;
  --sign-col-min: 110px;
  display: flex;
  justify-content: center;
  gap: var(--sign-gap);
  width: max-content;
  min-width: 260px;
  max-width: 100%;
  text-align: center;
  transform: translateX(calc(-1 * (var(--sign-col-min) + var(--sign-gap)) / 2));
}

.inv-sign-col {
  min-width: var(--sign-col-min);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.inv-sign-col:first-child {
  transform: translateX(-64px);
}

.inv-sign-title {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 50px;
}

.inv-sign-name {
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
}

/* ================= EDITABLE CONTROLS STYLING (NON-TABLE) ================= */
.inv-cust-val[contenteditable="true"],
.inv-note-line[contenteditable="true"],
.inv-date-line[contenteditable="true"],
.inv-sign-name[contenteditable="true"],
.inv-title[contenteditable="true"],
.inv-greeting-center[contenteditable="true"] {
  outline: none;
  border-radius: var(--radius-xs);
  transition: background-color 0.15s ease;
}

.inv-cust-val[contenteditable="true"]:hover,
.inv-note-line[contenteditable="true"]:hover,
.inv-date-line[contenteditable="true"]:hover,
.inv-sign-name[contenteditable="true"]:hover,
.inv-title[contenteditable="true"]:hover,
.inv-greeting-center[contenteditable="true"]:hover {
  background-color: rgba(254, 240, 138, 0.25);
}

.inv-cust-val[contenteditable="true"]:focus,
.inv-note-line[contenteditable="true"]:focus,
.inv-date-line[contenteditable="true"]:focus,
.inv-sign-name[contenteditable="true"]:focus,
.inv-title[contenteditable="true"]:focus,
.inv-greeting-center[contenteditable="true"]:focus {
  background-color: #eff6ff;
  box-shadow: 0 0 0 1.5px #3b82f6;
}

/* ================= AUTOCOMPLETE DROPDOWN ================= */
.autocomplete-wrapper {
  position: relative;
}

.autocomplete-list {
  position: fixed;
  z-index: 10050;
  background: #ffffff;
  border: 1px solid var(--border-ui);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 280px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  font-family: var(--font-sans);
}

.autocomplete-item {
  padding: 12px 14px;
  min-height: 48px;
  box-sizing: border-box;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-subtle);
  transition: background 0.15s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.ac-item-main {
  min-width: 0;
  flex: 1;
}

.ac-item-code {
  font-size: 11px;
  color: #64748b;
  margin-left: 6px;
}

.autocomplete-item:hover {
  background: #f1f5f9;
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.ac-item-name {
  font-weight: 600;
  color: #1e293b;
}

.ac-item-price {
  font-weight: 700;
  color: var(--primary);
  font-size: 13px;
  flex-shrink: 0;
}

/* ================= MODERN MODAL SYSTEM ================= */
.modal-overlay {
  position: fixed;
  top: var(--vv-offset, 0px);
  left: 0;
  right: 0;
  height: var(--vv-height, 100%);
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: var(--font-sans);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 680px;
  max-height: calc(var(--vv-height, 90vh) - 32px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.96) translateY(8px);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid rgba(255, 255, 255, 0.8);
}

.modal-overlay.active .modal-card {
  transform: scale(1) translateY(0);
}

.modal-card > form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.modal-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-ui);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  flex-shrink: 0;
}

.modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--secondary);
  letter-spacing: -0.2px;
  line-height: 1.35;
}

.modal-close-btn {
  background: #f1f5f9;
  border: none;
  font-size: 18px;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.modal-close-btn:hover {
  background: #fee2e2;
  color: var(--primary);
  transform: rotate(90deg);
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  flex: 1 1 auto;
  min-height: 0;
  background: #fafafa;
}

#image-preview-container img {
  max-width: 100%;
  height: auto;
  display: block;
  -webkit-touch-callout: default;
  -webkit-user-select: auto;
  user-select: auto;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-ui);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  flex-shrink: 0;
  gap: 10px;
  background: #ffffff;
}

#modal-picker .modal-footer {
  flex-wrap: nowrap;
}

.picker-selected-count {
  margin-right: auto;
  font-size: 13px;
  font-weight: 700;
  color: #334155;
}

.picker-check-cell {
  width: 44px;
  text-align: center;
  vertical-align: middle;
}

.picker-choose {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin: 0;
  cursor: pointer;
}

.picker-check {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: #dc2626;
}

#picker-table-body tr.picker-row-selected td {
  background: #fff1f2;
}

/* ================= FORM CONTROLS & PRODUCT EDITOR ================= */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-label {
  font-size: 12px;
  font-weight: 700;
  color: #334155;
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font-sans);
  color: #0f172a;
  background: #ffffff;
  outline: none;
  transition: all 0.15s ease;
  box-sizing: border-box;
}

.form-control:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.stock-switch-wrap {
  display: block;
  cursor: pointer;
  user-select: none;
}

.stock-switch-wrap input[type="checkbox"] {
  display: none;
}

.stock-switch-slider {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px 10px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 700;
  color: #059669;
  transition: all 0.15s ease;
  text-align: center;
  box-sizing: border-box;
  min-height: 38px;
}

.stock-switch-slider .stock-txt-out {
  display: none;
}

.stock-switch-slider .stock-txt-in {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.stock-switch-wrap input[type="checkbox"]:checked + .stock-switch-slider {
  background: #fef2f2;
  border-color: #fecaca;
  color: #dc2626;
}

.stock-switch-wrap input[type="checkbox"]:checked + .stock-switch-slider .stock-txt-in {
  display: none;
}

.stock-switch-wrap input[type="checkbox"]:checked + .stock-switch-slider .stock-txt-out {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.install-help p {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.5;
  color: #334155;
}

.install-help ol {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
  line-height: 1.45;
  color: #0f172a;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 62vh;
  overflow-y: auto;
}

.history-card {
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #ffffff;
  padding: 12px;
}

.history-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.history-card-name {
  font-size: 15px;
  font-weight: 800;
  color: #0f172a;
  word-break: break-word;
}

.history-card-meta {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.45;
  color: #64748b;
}

.history-card-total {
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 800;
  color: #b91c1c;
  text-align: right;
}

.history-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.history-card-actions .btn {
  flex: 1;
  min-height: 40px;
  justify-content: center;
}

.history-empty {
  padding: 28px 12px;
  text-align: center;
  color: #64748b;
  font-size: 13px;
}

/* ================= PRODUCT MANAGER & PICKER MODAL ================= */
.catalog-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 220px;
  padding: 9px 14px;
  border: 1.5px solid var(--border-ui);
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-family: var(--font-sans);
  background: #ffffff;
  outline: none;
  transition: all 0.2s ease;
}

.search-input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.product-list-scroll {
  overflow-x: auto;
  max-height: 420px;
}

.catalog-row-actions {
  display: inline-flex;
  gap: 6px;
  justify-content: center;
}

.catalog-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: #ffffff;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-ui);
}

.catalog-table th, .catalog-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-ui);
  text-align: left;
}

.catalog-table th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.catalog-table tr:hover {
  background: #f8fafc;
}

.catalog-table tr:last-child td {
  border-bottom: none;
}

/* Stock Filter Bar & Pills */
.catalog-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 8px;
}

.stock-filter-pills {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  padding: 3px 5px;
  border-radius: var(--radius-md);
  border: 1px solid #e2e8f0;
}

.filter-pill {
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 11.5px;
  font-weight: 700;
  padding: 3.5px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--font-sans);
  white-space: nowrap;
}

.filter-pill:hover {
  color: #0f172a;
  background: rgba(255, 255, 255, 0.7);
}

.filter-pill.active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Stock Badges & Interactive Toggle */
.badge-stock {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2.5px 8px;
  font-size: 11px;
  font-weight: 700;
  border-radius: var(--radius-full);
  white-space: nowrap;
  user-select: none;
}

.badge-stock-in {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}

.badge-stock-out {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
  font-weight: 800;
}

.btn-stock-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 700;
  border-radius: var(--radius-full);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  font-family: var(--font-sans);
  white-space: nowrap;
}

.btn-stock-toggle.in-stock {
  background: #ecfdf5;
  color: #059669;
  border-color: #a7f3d0;
}

.btn-stock-toggle.in-stock:hover {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fecaca;
}

.btn-stock-toggle.out-of-stock {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fecaca;
}

.btn-stock-toggle.out-of-stock:hover {
  background: #ecfdf5;
  color: #059669;
  border-color: #a7f3d0;
}

.catalog-table tr.row-out-of-stock td {
  background: #fffdfd;
}

.catalog-table tr.row-out-of-stock:hover td {
  background: #fef2f2;
}

/* Autocomplete Out of Stock Tag */
.badge-ac-out {
  display: inline-block;
  padding: 1px 5px;
  font-size: 10px;
  font-weight: 800;
  color: #dc2626;
  background: #fee2e2;
  border: 1px solid #fca5a5;
  border-radius: 4px;
  margin-left: 6px;
  letter-spacing: 0.2px;
}

/* ================= TOAST NOTIFICATION ================= */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-family: var(--font-sans);
}

.toast {
  background: #0f172a;
  color: #ffffff;
  padding: 12px 18px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  font-weight: 600;
  min-width: 280px;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.toast-success {
  background: #064e3b;
  border-left: 4px solid #10b981;
}

.toast-error {
  background: #881337;
  border-left: 4px solid #f43f5e;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ================= PRINT MEDIA QUERY ================= */
@page {
  size: A4 portrait;
  margin: 8mm 7mm;
}

@media print {
  html, body {
    background: #ffffff !important;
    color: #000000 !important;
    margin: 0 !important;
    padding: 0 !important;
    height: auto !important;
    overflow: visible !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .app-header,
  .quick-bar,
  .mobile-bottom-bar,
  .mobile-sheet-overlay,
  .login-overlay,
  .autocomplete-list,
  .row-action-btn,
  .row-opt-btn,
  .btn,
  .toast-container,
  .modal-overlay,
  .no-print {
    display: none !important;
  }

  .inv-top-container.qr-off {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "brand"
      "title";
  }

  .inv-top-container.qr-off .inv-bank-qr-fixed {
    display: none !important;
  }

  .inv-cust-val:empty:before,
  [data-placeholder]:empty:before {
    content: "" !important;
  }

  .inv-note-line.is-blank,
  .inv-note-hint {
    display: none !important;
  }

  .app-container,
  .invoice-wrapper,
  .invoice-fit-container {
    display: block !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
    zoom: 1 !important;
    transform: none !important;
  }

  .invoice-paper {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    min-height: 0 !important;
    height: auto !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    zoom: 1 !important;
    transform: none !important;
    position: static !important;
  }

  .inv-table {
    width: 100% !important;
  }

  .inv-table .col-stt { width: 5% !important; }
  .inv-table .col-name { width: 32% !important; }
  .inv-table .col-code { width: 8% !important; }
  .inv-table .col-price { width: 13% !important; }
  .inv-table .col-qty { width: 10% !important; }
  .inv-table .col-total { width: 15% !important; }
  .inv-table .col-note { width: 17% !important; }

  .inv-table thead {
    display: table-header-group;
  }

  .inv-table tfoot {
    display: table-row-group;
  }

  .inv-table tr,
  .inv-top-container,
  .inv-footer,
  .inv-sign-block,
  .inv-notes-block,
  .inv-sign-columns,
  img {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .inv-sign-block {
    padding-right: 8mm !important;
  }
}

/* ================= EXPORTING IMAGE / PDF STYLES ================= */
body.exporting-image .no-print,
body.exporting-image .row-action-btn,
body.exporting-image .row-opt-btn,
body.exporting-image .autocomplete-list {
  display: none !important;
}

body.exporting-image .inv-top-container.qr-off {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "brand"
    "title";
}

body.exporting-image .inv-top-container.qr-off .inv-bank-qr-fixed {
  display: none !important;
}

body.exporting-image .inv-cust-val:empty:before,
body.exporting-image [data-placeholder]:empty:before {
  content: "" !important;
}

body.exporting-image .inv-note-line.is-blank,
body.exporting-image .inv-note-hint {
  display: none !important;
}

/* ================= RESPONSIVE & MOBILE OPTIMIZATIONS ================= */
.header-mobile-emp {
  display: none;
}

.mobile-bottom-bar {
  display: none;
}

.mobile-sheet-overlay {
  display: none;
}

@media (max-width: 1359px) and (min-width: 701px) and (min-height: 501px) {
  .app-header {
    flex-wrap: wrap;
    align-items: center;
    row-gap: 10px;
    height: auto;
  }

  .header-left-zone {
    order: 1;
    flex: 1 1 0;
    min-width: 0;
    max-width: calc(100% - 240px);
  }

  .brand-badge,
  .brand-title {
    min-width: 0;
    max-width: 100%;
  }

  .brand-title span:first-child,
  .brand-subtitle {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .header-right-zone {
    order: 2;
    flex: 0 0 auto;
    margin-left: auto;
  }

  .header-center-slot {
    display: flex;
    justify-content: center;
    order: 3;
    flex: 0 0 100%;
    width: 100%;
    max-width: none;
    margin-top: 2px;
  }

  .header-center-stack {
    order: 0;
    flex: 0 0 auto;
    width: min(794px, 100%);
    max-width: 794px;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    justify-content: center;
    align-items: stretch;
    gap: 6px;
  }

  .header-edit-stack,
  .header-tool-box,
  .header-manage-tools,
  .header-tool-box .toolbar-edit-group,
  .toolbar-export-group,
  .header-center-stack .summary-toggles-wrapper {
    display: contents;
  }

  .header-center-stack .btn,
  .header-center-stack .btn-toggle {
    width: 100%;
    min-width: 0;
    justify-content: center;
    box-sizing: border-box;
  }
}

@media (min-width: 1360px) and (min-height: 501px) {
  .app-header {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
  }

  .header-left-zone,
  .header-right-zone {
    flex: 1 1 0;
    min-width: 0;
    max-width: none;
  }

  .header-left-zone {
    overflow: hidden;
  }

  .header-right-zone {
    display: flex;
    justify-content: flex-end;
    margin-left: 0;
  }

  .header-center-stack {
    order: 0;
    flex: 0 0 794px;
    width: 794px;
    max-width: 794px;
    margin: 0;
  }

  .brand-badge,
  .brand-title {
    min-width: 0;
    max-width: 100%;
  }

  .brand-title span:first-child,
  .brand-subtitle {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 992px) {
  .invoice-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .app-header {
    padding: 10px 16px;
  }
}

@media (max-width: 700px), (orientation: landscape) and (max-height: 500px) {
  .mobile-bottom-bar {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.08);
    z-index: 1000;
    padding: 4px 0 calc(4px + env(safe-area-inset-bottom, 0px));
    align-items: center;
    font-family: var(--font-sans);
  }

.mob-util-menu {
  width: 100%;
  min-width: 0;
  display: flex;
  justify-content: center;
  position: relative;
}

.mob-util-menu .mob-btn {
  width: 100%;
  min-width: 0;
}

.mob-util-pop {
  top: auto;
  bottom: calc(100% + 10px);
  right: 6px;
  left: auto;
  z-index: 1200;
}

.mob-btn {
  width: 100%;
  min-width: 0;
  display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    padding: 3px 0;
    color: #64748b;
    cursor: pointer;
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    gap: 2px;
  }

  .mob-btn:active {
    background: rgba(241, 245, 249, 0.8);
    transform: scale(0.92);
  }

  .mob-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    color: #64748b;
    transition: all 0.18s ease;
  }

  .mob-btn:active .mob-icon-wrap {
    color: #0f172a;
  }

  .mob-label {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 0 1px;
    font-size: 10px;
    font-weight: 700;
    color: #475569;
    letter-spacing: -0.35px;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.18s ease;
  }

  /* Nút nổi bật trung tâm: Copy Zalo */
  .mob-btn-primary {
    color: #059669;
  }

  .mob-btn-primary .mob-hero-icon {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    border-radius: 9px;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.32);
    width: 32px;
    height: 28px;
    margin-bottom: 1px;
  }

  .mob-btn-primary .mob-label {
    color: #059669;
    font-weight: 800;
  }

  .mob-btn-primary:active .mob-hero-icon {
    transform: scale(0.95);
    box-shadow: 0 1px 4px rgba(16, 185, 129, 0.4);
  }

  .mobile-sheet-overlay {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(8px);
    z-index: 9999;
    align-items: flex-end;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: var(--font-sans);
  }

  .mobile-sheet-overlay.active {
    opacity: 1;
    visibility: visible;
  }

  .mobile-sheet-card {
    width: 100%;
    background: #ffffff;
    border-radius: 20px 20px 0 0;
    padding: 16px 16px calc(20px + env(safe-area-inset-bottom, 0px)) 16px;
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.2);
    max-height: 85vh;
    overflow-y: auto;
  }

  .mobile-sheet-overlay.active .mobile-sheet-card {
    transform: translateY(0);
  }

  .mobile-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f1f5f9;
  }

  .mobile-sheet-title {
    font-size: 14.5px;
    font-weight: 700;
    color: #0f172a;
  }

  .mobile-sheet-close {
    background: #f1f5f9;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 16px;
    line-height: 1;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .sheet-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
  }

  .sheet-section-label {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #64748b;
    padding: 0 4px;
  }

  .sheet-account {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 12px 14px;
  }

  .sheet-account-id {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .mobile-user-name {
    font-size: 16px;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.3;
    word-break: break-word;
  }

  .mobile-user-login {
    font-size: 12px;
    font-weight: 600;
    color: #2563eb;
    word-break: break-all;
  }

  .sheet-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 56px;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    background: #ffffff;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
  }

  .sheet-row:active {
    background: #f8fafc;
  }

  .sheet-row-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #eff6ff;
    color: #1d4ed8;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .sheet-row-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
  }

  .sheet-row-title {
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
  }

  .sheet-row-sub {
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
  }

  .sheet-row-chevron {
    font-size: 22px;
    line-height: 1;
    color: #94a3b8;
    flex-shrink: 0;
  }

  .sheet-row-danger .sheet-row-icon {
    background: #fef2f2;
    color: #dc2626;
  }

  .sheet-row-danger .sheet-row-title {
    color: #dc2626;
  }

  .app-container {
    padding: 0 6px 75px 6px !important;
    margin-top: 0 !important;
  }

  /* Header trên Mobile: Thu gọn tối đa, hiển thị Logo bên trái và Người lập bên phải, dính cố định đỉnh màn hình */
  .app-header {
    padding: 8px 12px !important;
    min-height: 46px !important;
    height: 46px !important;
    box-sizing: border-box !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-wrap: nowrap !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 1000 !important;
    overflow: hidden !important;
    background: #ffffff !important;
    border-bottom: 1px solid #e2e8f0 !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04) !important;
  }

  .brand-badge {
    gap: 8px !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
  }

  .brand-title {
    min-width: 0 !important;
  }

  .brand-badge img {
    height: 28px !important;
  }

  .brand-subtitle {
    display: none !important;
  }

  .brand-title span:first-child {
    display: block !important;
    font-size: 14.5px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  .header-right-zone {
    display: flex !important;
    flex: 0 0 auto !important;
    flex-shrink: 0 !important;
    margin-left: 0 !important;
    justify-content: flex-end !important;
  }

  .header-account-cluster {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    grid-template-columns: none !important;
  }

  /* Ẩn từng nút, không chỉ khung cha. Safari vẫn vẽ con của display:contents
     dù cha đã display:none, nên các nút desktop đè lên thanh soạn thảo. */
  .app-header .header-center-stack,
  .app-header .header-center-stack * {
    display: none !important;
  }

  .header-manage-tools,
  .user-auth-pill,
  .header-settings-label {
    display: none !important;
  }

  #btn-open-username,
  #btn-open-phone {
    display: none !important;
  }

  .header-gear-btn {
    width: 28px !important;
    height: 28px !important;
    flex: 0 0 28px !important;
    padding: 0 !important;
    border-radius: 999px !important;
  }

  .header-gear-btn .header-gear-icon {
    display: block !important;
  }

  /* Cụm Người Lập hiển thị góc phải trên cùng Mobile */
  .header-mobile-emp {
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    background: #eff6ff !important;
    border: 1px solid #bfdbfe !important;
    border-radius: var(--radius-full) !important;
    padding: 3px 8px !important;
    cursor: pointer !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    white-space: nowrap !important;
    max-width: 145px !important;
    flex-shrink: 0 !important;
  }

  .header-mob-name {
    color: #1e3a8a !important;
    font-size: 11.5px !important;
    font-weight: 700 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  .invoice-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 6px 0 75px 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    display: block !important;
  }

  /* Quick Bar trên Mobile: Gắn liền trực tiếp với Header, kín khít không bị khe hở hay lộ nội dung khi cuộn */
  .quick-bar {
    display: flex !important;
    position: sticky !important;
    top: 46px !important;
    z-index: 990 !important;
    padding: 6px 8px 8px 8px !important;
    margin: 0 -6px 10px -6px !important;
    border-radius: 0 0 10px 10px !important;
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-top: none !important;
    box-shadow: 0 4px 14px -2px rgba(15, 23, 42, 0.09) !important;
    width: calc(100% + 12px) !important;
    max-width: calc(100% + 12px) !important;
    box-sizing: border-box !important;
  }

  .quick-bar-left {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    gap: 5px !important;
    overflow: visible !important;
  }

  .quick-bar-actions-row {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 6px !important;
    width: 100% !important;
  }

  .quick-bar-actions-row .btn {
    width: 100% !important;
    padding: 6px 4px !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    justify-content: center !important;
    text-align: center !important;
    white-space: nowrap !important;
  }

  .summary-toggles-wrapper {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    gap: 6px !important;
    padding: 3px 6px !important;
    box-sizing: border-box !important;
    background: #f1f5f9 !important;
    border-radius: var(--radius-sm) !important;
    margin-left: 0 !important;
  }

  .summary-toggles-wrapper .toggle-hint-label {
    font-size: 11px !important;
    font-weight: 600 !important;
    color: #64748b !important;
    margin-right: 2px !important;
  }

  .summary-toggles-wrapper .btn-toggle {
    flex: 1 !important;
    justify-content: center !important;
    padding: 4px 6px !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    text-align: center !important;
  }

  .qr-quick {
    display: flex !important;
  }

  .quick-hint {
    display: none !important;
  }

  /* Toast Notification trên Mobile: Nhỏ gọn góc trên, không che đáy */
  .toast-container {
    top: 10px !important;
    bottom: auto !important;
    right: 10px !important;
    left: 10px !important;
    align-items: center !important;
    pointer-events: none !important;
  }

  .toast {
    padding: 6px 12px !important;
    font-size: 11.5px !important;
    min-width: auto !important;
    max-width: 90vw !important;
    border-radius: 8px !important;
  }

  .inv-table .row-action-btn,
  .summary-label .row-opt-btn {
    opacity: 1 !important;
    width: 22px !important;
    height: 22px !important;
    background: #ffffff !important;
  }

  .inv-table .row-action-btn {
    transform: translate(-58%, -50%) !important;
  }

  .inv-table .row-action-btn svg,
  .summary-label .row-opt-btn svg {
    width: 11px !important;
    height: 11px !important;
  }

  [contenteditable]:focus {
    outline: 2px solid #3b82f6 !important;
    background-color: #f0f7ff !important;
    border-radius: 2px;
  }

  .modal-overlay.active {
    padding: 8px !important;
  }

  .modal-card {
    width: 95vw !important;
    max-width: 95vw !important;
    max-height: calc(var(--vv-height, 100dvh) - 16px) !important;
    margin: auto !important;
    border-radius: var(--radius-lg) !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }

  .modal-header {
    padding: 12px 14px !important;
    flex-shrink: 0 !important;
  }

  .modal-title {
    font-size: 14px !important;
    font-weight: 800 !important;
    line-height: 1.35 !important;
  }

  .modal-body {
    padding: 12px 12px 20px !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    touch-action: pan-y;
  }

  .modal-footer {
    padding: 10px 12px !important;
    display: flex !important;
    gap: 8px !important;
    flex-shrink: 0 !important;
    background: #fafafa !important;
  }

  .modal-body input,
  .modal-body textarea,
  .modal-body select {
    font-size: 16px !important;
  }

  #modal-account-field.modal-overlay.active,
  #modal-change-password.modal-overlay.active,
  #modal-first-login-change-pwd.modal-overlay.active {
    align-items: flex-start !important;
    padding-top: 12px !important;
  }

  #modal-account-field .modal-footer .btn,
  #modal-change-password .modal-footer .btn,
  #modal-first-login-change-pwd .modal-footer .btn {
    flex: 1 1 0 !important;
    height: 44px !important;
    justify-content: center !important;
  }

  .btn-cfg-save {
    flex: 1.5 !important;
    height: 42px !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    justify-content: center !important;
  }

  .btn-cfg-close {
    flex: 1 !important;
    height: 42px !important;
    font-size: 14px !important;
    justify-content: center !important;
  }

  .cfg-grid-shop {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .cfg-col-full {
    grid-column: span 1 !important;
  }

  .cfg-input {
    height: 38px !important;
    font-size: 14px !important;
    padding: 6px 10px !important;
  }

  .cfg-grid-media {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .cfg-media-card {
    padding: 10px !important;
  }

  .cfg-media-preview-row {
    display: flex !important;
    gap: 10px !important;
    align-items: center !important;
  }

  .cfg-preview-box,
  .cfg-no-img-placeholder {
    width: 75px !important;
    height: 75px !important;
    flex-shrink: 0 !important;
  }

  .cfg-media-actions {
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
    flex: 1 !important;
  }

  .btn-media-action {
    width: 100% !important;
    height: 36px !important;
    font-size: 12.5px !important;
    justify-content: center !important;
  }

  .catalog-toolbar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }

  .catalog-toolbar .search-input {
    width: 100% !important;
    min-width: 0 !important;
  }

  .catalog-toolbar .btn {
    width: 100% !important;
    height: 38px !important;
    justify-content: center !important;
  }

  input, select, textarea {
    font-size: 16px !important;
  }
}

/* Điện thoại ngang: giữ thanh soạn thảo, gom một hàng cho khỏi chiếm hết chiều cao */
@media (orientation: landscape) and (max-height: 500px) {
  .quick-bar {
    display: flex !important;
    padding: 4px 8px !important;
    margin-bottom: 6px !important;
  }

  .quick-bar-left {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 6px !important;
  }

  .quick-bar-actions-row,
  .summary-toggles-wrapper {
    width: auto !important;
    flex: 1 1 0 !important;
    min-width: 0 !important;
  }

  .summary-toggles-wrapper .toggle-hint-label {
    display: none !important;
  }
}





/* ================= LOGIN SCREEN OVERLAY ================= */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: radial-gradient(circle at top left, #1e293b 0%, #0f172a 100%);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 99999;
  padding: 16px;
  overflow: auto;
  font-family: var(--font-sans);
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.login-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.login-card {
  background: #ffffff;
  border-radius: 20px;
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 420px;
  padding: 36px 30px;
  margin: auto;
  animation: loginCardPop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid rgba(255, 255, 255, 0.8);
}

@media (max-height: 640px) {
  .login-card {
    padding: 18px 16px;
    border-radius: 14px;
  }

  .login-header {
    margin-bottom: 12px;
  }
}

@keyframes loginCardPop {
  from { opacity: 0; transform: scale(0.95) translateY(16px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.login-header {
  text-align: center;
  margin-bottom: 24px;
}

.login-header h2 {
  font-size: 21px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.3px;
  margin-bottom: 4px;
}

.login-sub {
  font-size: 13px;
  color: #64748b;
  font-weight: 500;
}

.login-switch {
  margin: 14px 0 0;
  text-align: center;
}

.login-switch button {
  border: none;
  background: none;
  padding: 0;
  color: #2563eb;
  font-weight: 700;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

.login-form-group {
  margin-bottom: 16px;
}

.login-form-group label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #334155;
  margin-bottom: 6px;
}

.login-input {
  width: 100%;
  padding: 11px 12px;
  border: 1.5px solid #cbd5e1;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: var(--font-sans);
  transition: all 0.2s;
  outline: none;
}

.login-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.login-error-alert {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 14px;
}

.btn-block {
  width: 100%;
}

.btn-login {
  padding: 12px;
  font-size: 15px;
  font-weight: 800;
  border-radius: var(--radius-md);
  margin-top: 6px;
}

/* ================= CẤU HÌNH THIẾT LẬP (MODAL SETTINGS) ================= */
.modal-card-settings {
  max-width: min(860px, calc(100vw - 32px));
  width: 100%;
}

.modal-card-settings .modal-body {
  overflow-x: hidden;
}

.cfg-container {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.cfg-section {
  background: #ffffff;
  border: 1px solid var(--border-ui);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
  max-width: 100%;
}

.cfg-section-title {
  font-size: 14px;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 8px;
  letter-spacing: -0.2px;
}

.cfg-grid-shop {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.cfg-col-full {
  grid-column: span 2;
}

.cfg-field {
  display: flex;
  flex-direction: column;
}

.cfg-label {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  margin-bottom: 4px;
  color: #334155;
}

.cfg-input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.cfg-grid-media {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.cfg-media-card {
  background: #f8fafc;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-ui);
}

.cfg-media-card-title {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 8px;
}

.cfg-media-preview-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}

.cfg-media-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.btn-media-action {
  white-space: nowrap;
}

.cfg-hint-text {
  font-size: 11px;
  color: #64748b;
  margin: 0;
  line-height: 1.4;
}

.cfg-fields-vertical {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Image preview box in Settings */
.cfg-preview-box {
  height: 80px;
  width: auto;
  max-width: 120px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-md);
  background: #fff;
  padding: 4px;
  object-fit: contain;
  display: block;
}

.cfg-no-img-placeholder {
  height: 80px;
  width: 100px;
  border: 1.5px dashed #cbd5e1;
  border-radius: var(--radius-md);
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 11.5px;
  font-weight: 600;
  text-align: center;
  padding: 4px;
}

.cfg-qr-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.cfg-qr-actions {
  margin-bottom: 8px;
}

.cfg-qr-thumb {
  position: relative;
  width: 74px;
  height: 74px;
  flex: 0 0 74px;
}

.cfg-qr-thumb-pick {
  width: 74px;
  height: 74px;
  padding: 3px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.cfg-qr-thumb.is-active .cfg-qr-thumb-pick {
  border-color: #111111;
  box-shadow: 0 0 0 2px #111111;
}

.cfg-qr-thumb-pick img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.cfg-qr-thumb-no {
  position: absolute;
  left: 4px;
  bottom: 4px;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  color: #0f172a;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 4px;
  padding: 1px 4px;
  pointer-events: none;
}

.cfg-qr-thumb-del {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: #dc2626;
  color: #fff;
  font-size: 13px;
  line-height: 18px;
  cursor: pointer;
  padding: 0;
}

/* ================= MOBILE VIRTUAL KEYBOARD OPTIMIZATIONS ================= */
/* Thanh nút chân trang luôn hiện. Khi bàn phím mở, JS đẩy thanh lên sát vùng nhìn thấy. */

@media (max-width: 700px), (orientation: landscape) and (max-height: 500px) {
  .app-container {
    padding-bottom: 90px;
  }

  body.keyboard-active .app-container {
    padding-bottom: 240px;
  }

  /* Đảm bảo bảng và các ô nhập trên mobile có khoảng đệm để không bị bàn phím che */
  .invoice-wrapper {
    padding-bottom: 120px;
  }

  body.keyboard-active .invoice-wrapper {
    padding-bottom: 260px;
  }

  #modal-catalog .modal-body,
  #modal-picker .modal-body {
    overflow-x: hidden;
  }

  #modal-catalog .search-input,
  #modal-picker .search-input {
    flex: 1 1 100%;
    min-width: 0;
    width: 100%;
  }

  #modal-catalog .catalog-toolbar .btn {
    flex: 1 1 calc(50% - 8px);
    justify-content: center;
    min-height: 40px;
  }

  #modal-catalog .stock-filter-pills,
  #modal-picker .stock-filter-pills {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
  }

  #modal-catalog .product-list-scroll,
  #modal-picker .product-list-scroll {
    overflow-x: hidden;
    max-height: none;
  }

  #modal-catalog .catalog-table,
  #modal-picker .catalog-table {
    display: block;
    border: none;
    box-shadow: none;
    background: transparent;
    overflow: visible;
  }

  #modal-catalog .catalog-table thead,
  #modal-picker .catalog-table thead {
    display: none;
  }

  #modal-catalog .catalog-table tbody,
  #modal-picker .catalog-table tbody,
  #modal-catalog .catalog-table tr,
  #modal-picker .catalog-table tr {
    display: block;
    width: 100%;
  }

  #modal-catalog .catalog-table tr,
  #modal-picker .catalog-table tr {
    margin-bottom: 10px;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #ffffff;
    box-sizing: border-box;
  }

  #modal-catalog .catalog-table td,
  #modal-picker .catalog-table td {
    display: block;
    width: auto !important;
    border: none;
    padding: 3px 0;
    text-align: left !important;
    background: transparent;
    word-break: break-word;
  }

  #modal-catalog .catalog-table td:nth-child(2),
  #modal-picker .picker-name {
    font-size: 15px;
    padding-bottom: 6px;
  }

  #modal-picker .catalog-table tr {
    display: grid !important;
    grid-template-columns: 28px minmax(0, 1fr);
    column-gap: 8px;
    align-items: start;
  }

  #modal-picker .picker-check-cell {
    grid-column: 1;
    grid-row: 1 / span 6;
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 28px !important;
    margin: 0;
    padding: 2px 0 0 !important;
  }

  #modal-picker .catalog-table td:not(.picker-check-cell) {
    grid-column: 2;
  }

  #modal-catalog .catalog-row-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
  }

  #modal-catalog .catalog-row-actions .btn,
  #modal-picker .catalog-table td:last-child .btn {
    flex: 1;
    min-height: 42px;
    justify-content: center;
  }

  #modal-picker .modal-footer {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
  }

  #modal-picker .picker-selected-count {
    grid-column: 1 / -1;
    margin: 0;
  }

  #modal-picker #btn-picker-add,
  #modal-picker .modal-footer .btn-outline {
    width: 100%;
    min-height: 44px;
    justify-content: center;
  }

  #modal-picker tr.picker-row-selected {
    border-color: #f43f5e;
    background: #fff1f2;
  }

  #modal-picker .picker-choose {
    width: 28px;
    height: 28px;
  }
}
