:root {
  --bh-primary: #0f4c81;
  --bh-primary-dark: #0b355c;
  --bh-accent: #e0a100;
  --bh-bg: #f4f7fb;
  --bh-card: #ffffff;
  --bh-text: #1c2834;
}

html, body {
  width: 100%;
  margin: 0;
  padding: 0;
  background: var(--bh-bg);
  color: var(--bh-text);
  font-family: "Segoe UI", "Be Vietnam Pro", sans-serif;
}

.app-shell {
  min-height: 100vh;
  width: 100%;
}

.bh-sidebar {
  width: 240px;
  background: var(--bh-primary);
  color: #fff;
  --bs-offcanvas-width: 280px;
  --bs-offcanvas-bg: var(--bh-primary);
  --bs-offcanvas-color: #fff;
}

@media (min-width: 992px) {
  .app-shell {
    display: flex;
    height: 100vh;
    width: 100%;
    overflow: hidden;
  }

  .bh-sidebar.offcanvas-lg {
    position: sticky;
    top: 0;
    flex: 0 0 240px;
    width: 240px !important;
    height: 100vh !important;
    visibility: visible !important;
    transform: none !important;
    background: var(--bh-primary) !important;
    border: 0 !important;
    overflow: auto;
  }

  /* ĐÂY LÀ DÒNG FIX LỖI: flex: 1 1 auto để bung tràn toàn bộ màn hình */
  .bh-content {
    flex: 1 1 auto !important;
    width: calc(100% - 240px);
    min-width: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
  }
}

.bh-sidebar a {
  color: rgba(255, 255, 255, 0.88);
  text-decoration: none;
  display: flex;
  gap: 0.6rem;
  align-items: center;
  padding: 0.7rem 1rem;
  border-radius: 0.6rem;
}

.bh-sidebar a:hover,
.bh-sidebar a.active {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.bh-brand {
  padding: 1.2rem 1rem 0.8rem;
}

.bh-logo {
  max-height: 42px;
  max-width: 160px;
  background: #fff;
  border-radius: 0.4rem;
  padding: 0.2rem;
}

.bh-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: nowrap;
  min-height: 3.5rem;
  padding: 0.5rem 1.5rem;
  background: #fff;
  border-bottom: 1px solid #e6edf5;
  z-index: 1020;
  width: 100%;
}

.bh-menu-btn {
  color: var(--bh-text);
  font-size: 1.7rem;
  line-height: 1;
  padding: 0 0.2rem;
}

.bh-user {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 42vw;
}

.bh-user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bh-content {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
}

main {
  flex: 1 1 auto;
  width: 100%;
}

.btn-primary,
.btn-primary:hover,
.btn-primary:focus {
  background: var(--bh-primary);
  border-color: var(--bh-primary);
}

.bh-card {
  background: var(--bh-card);
  border: 0;
  border-radius: 1rem;
  box-shadow: 0 8px 24px rgba(15, 76, 129, 0.06);
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
          radial-gradient(circle at top left, rgba(224, 161, 0, 0.25), transparent 30%),
          linear-gradient(160deg, var(--bh-primary-dark), var(--bh-primary));
}

.login-card {
  width: min(440px, calc(100% - 2rem));
}

.tabulator {
  border: 0;
  background: transparent;
  font-size: 0.92rem;
}

body.pos-page {
  height: 100vh;
  overflow: hidden;
}

body.pos-page .app-shell,
body.pos-page .bh-content {
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

body.pos-page .bh-sidebar {
  height: 100vh;
  min-height: 0;
  overflow: auto;
}

body.pos-page .bh-content {
  display: flex;
  flex-direction: column;
}

body.pos-page main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0.75rem 1rem;
  overflow: hidden;
}

.pos-screen {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 0.85rem;
  width: 100%;
}

.pos-catalog,
.pos-cart {
  min-height: 0;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pos-cart-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  padding: 0.85rem 1rem;
}

.pos-toolbar {
  display: grid;
  grid-template-columns: minmax(140px, 0.7fr) minmax(180px, 1.1fr) minmax(180px, 1fr);
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}

.pos-quick {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  margin-bottom: 0.6rem;
  padding-bottom: 0.15rem;
}

.pos-quick-btn {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  max-width: 11rem;
  border: 1px solid #d5e3f0;
  background: #f7fbff;
  color: var(--bh-text);
  border-radius: 0.7rem;
  padding: 0.35rem 0.7rem;
  font-size: 0.82rem;
  line-height: 1.2;
}

.pos-quick-btn span {
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pos-quick-btn small {
  color: #5c6b7a;
}

.pos-quick-btn:hover {
  border-color: var(--bh-primary);
  background: #fff;
}

.pos-table {
  flex: 1 1 auto;
  min-height: 0;
}

.pos-cart-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.pos-lines {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  border-top: 1px solid #e6edf5;
  border-bottom: 1px solid #e6edf5;
}

.pos-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.15rem 0.5rem;
  padding: 0.45rem 0.1rem;
  border-bottom: 1px solid #eef3f8;
}

.pos-line-name {
  font-weight: 600;
  line-height: 1.25;
}

.pos-line-meta {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: #5c6b7a;
  font-size: 0.82rem;
}

.pos-line-total {
  font-weight: 700;
  text-align: right;
}

.pos-qty {
  display: inline-flex;
  align-items: center;
  border: 1px solid #d5e3f0;
  border-radius: 0.5rem;
  overflow: hidden;
  background: #fff;
}

.pos-qty button {
  width: 1.7rem;
  height: 1.7rem;
  border: 0;
  background: #f4f7fb;
  color: var(--bh-text);
}

.pos-qty input {
  width: 2.4rem;
  height: 1.7rem;
  border: 0;
  text-align: center;
  font-weight: 600;
}

.pos-remove {
  border: 0;
  background: transparent;
  color: #b42318;
  padding: 0 0.2rem;
}

.pos-cart-foot {
  flex: 0 0 auto;
  overflow: hidden;
  padding-top: 0.35rem;
}

.pos-actions {
  flex: 0 0 auto;
  display: grid;
  gap: 0.4rem;
  overflow: hidden;
  padding-top: 0.45rem;
  background: #fff;
}

.pos-actions .btn {
  min-height: 2.6rem;
  font-weight: 650;
}

.pos-cart-foot .form-label {
  margin-bottom: 0.15rem;
  font-size: 0.78rem;
}

.pos-sum {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.18rem 0;
}

.pos-sum input {
  width: 6.5rem;
  text-align: right;
}

.pos-grand-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0.35rem 0 0.55rem;
  padding-top: 0.35rem;
  border-top: 2px solid var(--bh-primary);
}

.pos-grand {
  font-size: 1.85rem;
  font-weight: 800;
  line-height: 1;
  color: var(--bh-primary);
  letter-spacing: -0.03em;
}

.pos-change.is-short {
  color: #b42318;
  font-weight: 700;
}

.pos-change.is-ok {
  color: #067647;
  font-weight: 700;
}

.pos-customer {
  background: #f7fbff;
  border: 1px solid #d5e3f0;
  border-radius: 0.7rem;
  padding: 0.45rem 0.65rem;
  margin-bottom: 0.45rem;
}

.pos-tier {
  display: inline-block;
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
  background: #e7f0f8;
  color: var(--bh-primary-dark);
  font-size: 0.75rem;
  font-weight: 700;
}

.pos-transfer {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

@media (min-width: 768px) {
  .pos-cart.offcanvas-md {
    position: static;
    visibility: visible !important;
    transform: none !important;
    width: auto !important;
    height: 100% !important;
    background: var(--bh-card) !important;
    border: 0 !important;
    box-shadow: 0 8px 24px rgba(15, 76, 129, 0.06);
    z-index: auto;
  }

  .pos-cart.offcanvas-md .pos-cart-body {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0.85rem 1rem;
  }
}

@media (max-width: 767.98px) {
  body.pos-page,
  body.pos-page .app-shell,
  body.pos-page .bh-content,
  body.pos-page main {
    height: auto;
    overflow: visible;
  }

  body.pos-page main {
    padding-bottom: 5.25rem;
  }

  .pos-screen {
    display: block;
    height: auto;
  }

  .pos-catalog {
    height: auto;
    min-height: 70vh;
  }

  .pos-table {
    height: 52vh;
    min-height: 16rem;
  }

  .pos-toolbar {
    grid-template-columns: 1fr;
  }

  .pos-cart.offcanvas-bottom {
    --bs-offcanvas-height: 88vh;
    height: 88vh;
    border-radius: 1rem 1rem 0 0;
    background: #fff;
  }

  .pos-cart .pos-cart-body {
    height: 100%;
    padding: 0.35rem 0.85rem 0.85rem;
  }

  .pos-dock {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem calc(0.65rem + env(safe-area-inset-bottom));
    background: #fff;
    border-top: 1px solid #e6edf5;
    box-shadow: 0 -8px 24px rgba(15, 76, 129, 0.08);
  }

  .pos-dock-total {
    min-width: 0;
    font-size: 0.92rem;
    line-height: 1.25;
  }

  .pos-dock .btn {
    flex: 0 0 auto;
    white-space: nowrap;
  }
}

@media print {
  .bh-sidebar,
  .bh-topbar,
  .no-print,
  .pos-screen,
  .pos-dock,
  .modal,
  .modal-backdrop {
    display: none !important;
  }
  .print-sheet {
    display: block !important;
  }
}

.print-sheet {
  display: none;
}