:root {
  --sideMenuWidth: 240px;
  --sideMenuWidthMb: 64px;
  --navHeight: 60px;
  --primary-gradient: linear-gradient(180deg, #062136 0%, #062136 40%, #d8d8d8 100%);
  --primary-gradient-invert: linear-gradient(180deg, #062136 0%);
  --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  --header-gradient: linear-gradient(135deg, #1a3c5e 0%, #2d6a9f 100%);
  /* แถบคั่นกลุ่มในตาราง (เช่น หัวเดือนในหน้าติดตามสินค้านำเข้า) — โทนอ่อนของธีมโมดูล */
  --group-band: #a5f3fc;
}

/* ===== ธีมสีต่อโมดูล (override ตัวแปรหลัก → navbar + sidebar + active + header การ์ด เปลี่ยนตาม) ===== */
/* ขาย (Sale) — แดงเข้ม */
body.module-sale {
  --primary-gradient: linear-gradient(180deg, rgb(80, 0, 28) 0%, rgb(80, 0, 28) 40%, #d8d8d8 100%);
  --primary-gradient-invert: linear-gradient(180deg, rgb(80, 0, 28) 0%);
  --accent-gradient: linear-gradient(135deg, rgb(200, 0, 43) 0%, rgb(80, 0, 28) 100%);
  --header-gradient: linear-gradient(135deg, rgb(80, 0, 28) 0%, rgb(180, 0, 40) 100%);
  --group-band: #fecdd3;
}
/* คลัง/สโตร์ (Store) — เขียวเข้ม */
body.module-store {
  --primary-gradient: linear-gradient(180deg, #14532d 0%, #14532d 40%, #d8d8d8 100%);
  --primary-gradient-invert: linear-gradient(180deg, #14532d 0%);
  --accent-gradient: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  --header-gradient: linear-gradient(135deg, #14532d 0%, #16a34a 100%);
  --group-band: #bbf7d0;
}

/* ===== App Form — ฟอร์มสร้าง/แก้ไข (pre-item ฯลฯ) โทนตามธีมโมดูล ===== */
.app-form-wrap {
  max-width: 1040px;
  margin: 0 auto;
}
.app-form-card {
  background: #fff;
  border: none;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(6, 33, 54, 0.08);
}
.app-form-header {
  background: var(--header-gradient);
  color: #fff;
  padding: 1.1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.app-form-header .afh-title {
  display: flex;
  align-items: center;
  gap: .85rem;
}
.app-form-header .afh-ico {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex: 0 0 auto;
}
.app-form-header h5 {
  margin: 0;
  font-weight: 700;
  line-height: 1.2;
}
.app-form-header .afh-sub {
  font-size: .78rem;
  opacity: .8;
  margin-top: 2px;
}

.app-form {
  padding: 1.5rem;
}
.app-form .form-section {
  border: 1px solid #e9eef4;
  border-radius: 12px;
  background: #fff;
  margin-bottom: 1.25rem;
  overflow: hidden;
}
.app-form .form-section-head {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .75rem 1.1rem;
  background: #f6f9fc;
  border-bottom: 1px solid #eef2f7;
  font-weight: 700;
  color: #1e293b;
  font-size: .95rem;
}
.app-form .form-section-head .sec-ico {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--header-gradient);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .82rem;
  flex: 0 0 auto;
}
.app-form .form-section-body {
  padding: 1.15rem 1.1rem .35rem;
}
.app-form label {
  font-size: .8rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: .35rem;
}
.app-form .req {
  color: #e11d48;
}
.app-form .form-control {
  border: 1px solid #d9e1ea;
  border-radius: 8px;
  padding: .5rem .8rem;
  font-size: .9rem;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.app-form .form-control::placeholder {
  color: #b6c0cc;
}
.app-form .form-control:focus {
  border-color: #2d6a9f;
  box-shadow: 0 0 0 .18rem rgba(45, 106, 159, 0.15);
}
.app-form select.form-control {
  cursor: pointer;
}
.app-form .field-hint {
  display: block;
  font-size: .72rem;
  color: #9aa7b4;
  margin-top: .28rem;
}
.app-form .form-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: .6rem;
  padding-top: .5rem;
  border-top: 1px dashed #e3e9f0;
  margin-top: .25rem;
  padding-top: 1.1rem;
}
.app-form .btn-rounded {
  border-radius: 9px;
  font-weight: 600;
  padding: .55rem 1.6rem;
}

@font-face {
  font-family: "Mitr-Light";
  font-weight: 100;
  font-style: normal;
  src: url("../fonts/Mitr-Light.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "Kanit";
  font-style: normal;
  src: url("../fonts/Kanit-Regular.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "Kanit";
  font-weight: 100;
  font-style: normal;
  src: url("../fonts/Kanit-Light.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "Mitr";
  font-style: normal;
  src: url("../fonts/Mitr-Regular.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "Mitr-Light";
  font-weight: 100;
  font-style: normal;
  src: url("../fonts/Mitr-Light.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "Avenir";
  src: url("../fonts/Avenir_95_Black.ttf");
}

@font-face {
  font-family: "Material Icons";
  font-style: normal;
  font-weight: 400;
  src: url(../fonts/MaterialIcons-Regular.eot);
  /* For IE6-8 */
  src: local("Material Icons"), local("MaterialIcons-Regular"), url(../fonts/MaterialIcons-Regular.woff2) format("woff2"), url(../fonts/MaterialIcons-Regular.woff) format("woff"), url(../fonts/MaterialIcons-Regular.ttf) format("truetype");
}

@font-face {
  font-family: "FontAwesome";
  font-style: normal;
  font-weight: 400;
  src: url(../../../dist/fonts/vendor/font-awesome/fontawesome-webfont.eot);
  /* For IE6-8 */
  src: local("Material Icons"), url(../../../dist/fonts/vendor/font-awesome/fontawesome-webfont.woff2) format("woff2"), url(../../../dist/fonts/vendor/font-awesome/fontawesome-webfont.woff) format("woff"), url(../../../dist/fonts/vendor/font-awesome/fontawesome-webfont.ttf) format("truetype");
}

.material-icons {
  font-family: "Material Icons";
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  /* Preferred icon size */
  display: inline-block;
  line-height: 1;
  text-transform: none;
  letter-spacing: normal;
  word-wrap: normal;
  white-space: nowrap;
  direction: ltr;
  /* Support for all WebKit browsers. */
  -webkit-font-smoothing: antialiased;
  /* Support for Safari and Chrome. */
  text-rendering: optimizeLegibility;
  /* Support for Firefox. */
  -moz-osx-font-smoothing: grayscale;
  /* Support for IE. */
  font-feature-settings: "liga";
}

.swal2-popup.swal2-app-popup:not(.swal2-toast) {
  border-radius: 16px;
  border-top: 4px solid #062136;
  font-family: "Kanit", "Mitr-Light", sans-serif;
  padding: 2rem 2rem 1.5rem;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.14), 0 8px 24px rgba(6, 33, 54, 0.12);
}

.swal2-popup.swal2-app-popup:not(.swal2-toast) .swal2-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1e293b;
  padding-top: .4rem;
  line-height: 1.3;
}

.swal2-popup.swal2-app-popup:not(.swal2-toast) .swal2-html-container {
  font-size: .92rem;
  color: #475569;
  line-height: 1.6;
}

.swal2-popup.swal2-app-popup:not(.swal2-toast) .swal2-icon {
  width: 4rem;
  height: 4rem;
  margin-bottom: 1.1rem;
  margin-top: 0;
}

.swal2-popup.swal2-app-popup:not(.swal2-toast) .swal2-icon .swal2-icon-content {
  font-size: 2.2rem;
}

.swal2-popup.swal2-app-popup:not(.swal2-toast) .swal2-actions {
  gap: .5rem;
  margin-top: 1.5rem;
}

.swal2-popup.swal2-app-popup:not(.swal2-toast) .swal2-confirm,
.swal2-popup.swal2-app-popup:not(.swal2-toast) .swal2-cancel {
  border-radius: 8px !important;
  font-family: inherit;
  font-weight: 600;
  font-size: .875rem;
  padding: .55rem 1.6rem;
  letter-spacing: .01em;
  transition: filter .15s ease, transform .15s ease;
  box-shadow: none !important;
  border: none !important;
}

.swal2-popup.swal2-app-popup:not(.swal2-toast) .swal2-confirm:hover,
.swal2-popup.swal2-app-popup:not(.swal2-toast) .swal2-cancel:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.swal2-popup.swal2-app-popup:not(.swal2-toast) .swal2-confirm:focus,
.swal2-popup.swal2-app-popup:not(.swal2-toast) .swal2-cancel:focus {
  outline: 3px solid rgba(6, 33, 54, 0.3);
}

.swal2-popup.swal2-app-popup:not(.swal2-toast) .swal2-loader {
  border-color: #062136 transparent #062136 transparent;
}

.swal2-app-popup .swal2-icon.swal2-success {
  border-color: #10b981 !important;
}

.swal2-app-popup .swal2-icon.swal2-success .swal2-success-ring {
  border-color: rgba(16, 185, 129, 0.3) !important;
}

.swal2-app-popup .swal2-icon.swal2-success [class^="swal2-success-line"] {
  background-color: #10b981 !important;
}

.swal2-app-popup .swal2-icon.swal2-error {
  border-color: #ef4444 !important;
}

.swal2-app-popup .swal2-icon.swal2-error .swal2-x-mark-line-left,
.swal2-app-popup .swal2-icon.swal2-error .swal2-x-mark-line-right {
  background-color: #ef4444 !important;
}

.swal2-app-popup .swal2-icon.swal2-warning {
  border-color: #f59e0b !important;
  color: #f59e0b !important;
}

.swal2-app-popup .swal2-icon.swal2-info {
  border-color: #3b82f6 !important;
  color: #3b82f6 !important;
}

.swal2-app-popup .swal2-icon.swal2-question {
  border-color: #062136 !important;
  color: #062136 !important;
}

.swal2-container.swal2-backdrop-show,
.swal2-container.swal2-noanimation {
  background: rgba(15, 23, 42, 0.55) !important;
  backdrop-filter: blur(3px);
}

.swal2-popup.swal2-app-popup.swal2-toast {
  border-radius: 10px !important;
  font-family: "Kanit", "Mitr-Light", sans-serif;
  font-size: .88rem;
  font-weight: 500;
  padding: .65rem 1rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12) !important;
  border-left: 4px solid #062136;
  min-width: 260px;
}

.swal2-popup.swal2-app-popup.swal2-toast.swal2-icon-success {
  border-left-color: #10b981 !important;
}

.swal2-popup.swal2-app-popup.swal2-toast.swal2-icon-error {
  border-left-color: #ef4444 !important;
}

.swal2-popup.swal2-app-popup.swal2-toast.swal2-icon-warning {
  border-left-color: #f59e0b !important;
}

.swal2-popup.swal2-app-popup.swal2-toast.swal2-icon-info {
  border-left-color: #3b82f6 !important;
}

.swal2-popup.swal2-app-popup.swal2-toast .swal2-title {
  font-size: .88rem;
  font-weight: 600;
  color: #1e293b;
  margin: 0;
  padding: 0;
  text-align: left;
}

.swal2-popup.swal2-app-popup.swal2-toast .swal2-timer-progress-bar {
  background: #062136;
  opacity: .4;
}

body {
  font-family: "Mitr-Light";
  font-size: 16px;
  background-color: white;
}

body.sidebar-collapsed {
  --sideMenuWidth: 0px;
}

body.sidebar-collapsed #sidebar-wrapper {
  left: calc(var(--sideMenuWidth) - 240px);
  opacity: 0;
  visibility: hidden;
}

.logo-img {
  width: 70px;
  height: 40px;
}

.purchase-navbar {
  position: fixed;
  top: 0;
  left: 0;
  height: var(--navHeight);
  width: 100%;
  z-index: 1050;
  background: var(--primary-gradient-invert) !important;
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  padding: 0;
}

.purchase-navbar .container-fluid {
  display: flex;
  align-items: center;
  height: 100%;
}

.purchase-navbar #sidebar-toggle-btn {
  font-size: 1.25rem;
  padding: 0.5rem;
  transition: transform 0.3s ease;
}

.purchase-navbar #sidebar-toggle-btn:hover {
  transform: scale(1.1);
}

.purchase-navbar .navbar-brand {
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #febb12 !important;
  margin-left: 10px;
  margin-bottom: 0;
  line-height: var(--navHeight);
  display: flex;
  align-items: center;
}

.purchase-navbar .navbar-nav {
  align-items: center;
}

.purchase-navbar .navbar-nav .nav-link {
  line-height: normal;
  display: flex;
  align-items: center;
  height: 100%;
}

.purchase-navbar .nav-link {
  color: rgba(255, 255, 255, 0.8) !important;
  font-weight: 500;
  transition: all 0.3s ease;
  padding: 0.5rem 1rem;
  border-radius: 8px;
}

.purchase-navbar .nav-link:hover {
  color: white !important;
  background: rgba(255, 255, 255, 0.05);
}

/* เมนูหลัก (โมดูล) จัดซื้อ/ขาย/คลัง บน top-bar */
.purchase-navbar .module-nav .nav-link {
  border-radius: 6px;
  margin: 0 2px;
}
.purchase-navbar .module-nav .nav-link.active {
  color: #fff !important;
  background: rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 -3px 0 rgba(255, 255, 255, 0.9);
}
/* center จริงเทียบทั้ง navbar (ไม่ให้โลโก้ซ้าย/ดรอปดาวน์ขวาดันให้เบี้ยว) — เฉพาะจอ lg ขึ้นไป */
@media (min-width: 992px) {
  .purchase-navbar .container-fluid {
    position: relative;
  }
  .purchase-navbar .module-nav {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    margin: 0 !important;
  }
}

.purchase-navbar .dropdown-menu {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  margin-top: 10px;
  padding: 0.5rem;
}

.purchase-navbar .dropdown-menu .dropdown-item {
  color: rgba(255, 255, 255, 0.8);
  border-radius: 6px;
  padding: 0.6rem 1rem;
  transition: all 0.2s;
}

.purchase-navbar .dropdown-menu .dropdown-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: white;
}

.purchase-navbar .dropdown-menu .dropdown-item i {
  width: 20px;
  text-align: center;
  opacity: 0.8;
}

.purchase-navbar .dropdown-menu .dropdown-divider {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

#sidebar-wrapper {
  position: fixed;
  top: var(--navHeight);
  left: 0;
  height: calc(100vh - var(--navHeight));
  width: var(--sideMenuWidth);
  background: var(--primary-gradient);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  z-index: 1040;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
}

#sidebar-wrapper::-webkit-scrollbar {
  width: 4px;
}

#sidebar-wrapper::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

#sidebar-wrapper .sidebar-heading {
  padding: 1.25rem 1rem 0.75rem;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.35);
  border: none;
  background: transparent !important;
}

#sidebar-wrapper .sidebar-nav {
  padding: 0 0.5rem;
}

#sidebar-wrapper .sidebar-menu-group {
  margin-bottom: 0.25rem;
}

#sidebar-wrapper .sidebar-menu-group .sidebar-menu-parent {
  display: flex;
  align-items: center;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

#sidebar-wrapper .sidebar-menu-group .sidebar-menu-parent i:first-child {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  margin-right: 10px;
}

#sidebar-wrapper .sidebar-menu-group .sidebar-menu-parent span {
  flex: 1;
}

#sidebar-wrapper .sidebar-menu-group .sidebar-menu-parent .sidebar-arrow {
  font-size: 0.65rem;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0.5;
  width: auto;
  margin-right: 0;
}

#sidebar-wrapper .sidebar-menu-group .sidebar-menu-parent:hover {
  color: white;
  background: rgba(255, 255, 255, 0.05);
}

#sidebar-wrapper .sidebar-menu-group .sidebar-submenu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding-left: 0.5rem;
}

#sidebar-wrapper .sidebar-menu-group .sidebar-submenu .sidebar-submenu-item {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.85rem 0.5rem 1.75rem;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 400;
  transition: all 0.2s ease;
  margin-bottom: 0.1rem;
}

#sidebar-wrapper .sidebar-menu-group .sidebar-submenu .sidebar-submenu-item i {
  font-size: 0.8rem;
  width: 18px;
  text-align: center;
  margin-right: 8px;
  opacity: 0.7;
}

#sidebar-wrapper .sidebar-menu-group .sidebar-submenu .sidebar-submenu-item:hover {
  color: white;
  background: rgba(255, 255, 255, 0.05);
}

#sidebar-wrapper .sidebar-menu-group .sidebar-submenu .sidebar-submenu-item:hover i {
  opacity: 1;
}

#sidebar-wrapper .sidebar-menu-group .sidebar-submenu .sidebar-submenu-item.active {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

#sidebar-wrapper .sidebar-menu-group .sidebar-submenu .sidebar-submenu-item.active i {
  color: white;
  opacity: 1;
}

#sidebar-wrapper .sidebar-menu-group.open .sidebar-menu-parent {
  color: white;
}

#sidebar-wrapper .sidebar-menu-group.open .sidebar-menu-parent .sidebar-arrow {
  transform: rotate(90deg);
  opacity: 0.8;
}

/* เปิดกลุ่มเมนู — max-height ใช้เพื่อให้ transition ทำงาน (transition height: auto ไม่ได้)
   ⚠️ ต้องเผื่อไว้ให้มากกว่าจำนวนรายการจริงเสมอ เพราะคู่กับ overflow:hidden ด้านบน
      เกินเมื่อไหร่ = รายการท้าย ๆ **หายไปเงียบ ๆ** ไม่มีสกรอลล์ ไม่มีอะไรบอก
      (เคยตั้ง 300px = ~8 รายการ พอเมนูขายเพิ่มเป็น 9 รายการก็โดนตัดทันที — แก้ 2026-08-21)
   1 รายการสูง ~36px → 720px รองรับ ~20 รายการ · ตัวเมนูด้านนอกสกรอลล์ได้อยู่แล้ว */
#sidebar-wrapper .sidebar-menu-group.open .sidebar-submenu {
  max-height: 720px;
}

#app {
  display: flex;
  flex-direction: column;
  align-items: start;
  width: 100%;
  padding-top: calc(var(--navHeight) + 24px);
  padding-left: calc(var(--sideMenuWidth) + 24px);
  padding-right: 24px;
  padding-bottom: 40px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background-color: #f8fafc;
  min-height: 100vh;
  box-sizing: border-box;
}

#app .btn-cancel {
  border: 1px solid #212529;
}

#app .btn-primary {
  background-color: #212529 !important;
  border-color: #212529 !important;
}

#app .btn-blue {
  background-color: #366afc !important;
  border-color: #366afc !important;
  color: white;
}

#app .btn-white {
  background-color: white !important;
  border-color: rgba(0, 0, 0, 0.127) !important;
  color: black;
}

#app .text-light-blue {
  color: #87cefa;
}

#app .card:not(.card-horizontal) {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 16px;
  overflow: hidden;
  width: 100%;
}

#app .card:not(.card-horizontal) .card-header {
  padding: 16px 20px;
  background-color: white;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

#app .card-header-body {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

#app .pagination {
  margin-top: 1rem;
  gap: 5px;
}

#app .pagination .page-item .page-link {
  border: none;
  background: #fff;
  color: #64748b;
  border-radius: 8px !important;
  padding: 8px 14px;
  font-weight: 500;
  font-size: 0.9rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
}

#app .pagination .page-item .page-link:hover {
  background: #f1f5f9;
  color: #1e293b;
  transform: translateY(-1px);
}

#app .pagination .page-item .page-link:focus {
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

#app .pagination .page-item.active .page-link {
  background: var(--accent-gradient) !important;
  color: #fff !important;
  box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.2);
}

#app .pagination .page-item.disabled .page-link {
  background: #f8fafc;
  color: #cbd5e1;
  opacity: 0.7;
}

#app .input-group .form-control {
  border: 1px solid #e2e8f0;
  border-radius: 10px 0 0 10px !important;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
}

#app .input-group .form-control:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.05);
}

#app .input-group .btn {
  border-radius: 0 10px 10px 0 !important;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
  background: #1e293b;
  border: none;
}

#app .input-group .btn:hover {
  background: #0f172a;
}

#app .select2 {
  border: 1px solid #a7a7a7 !important;
  border-radius: 5px !important;
}

/* จำกัดความสูงลิสต์ของ select2 — ต้องครอบ **ทั้งสองธีม**
   plugins/select2.min.css ที่โปรเจกต์โหลด **ไม่มีกฎ max-height เลยสักข้อ** (เช็คแล้ว 0 กฎ)
   ลิสต์จึงไม่มีเพดานไม่ว่าจะธีมไหน → ช่องที่ตัวเลือกเยอะได้ dropdown สูงเป็นพัน px
   ช่องที่ตัวเลือกเยอะจึงได้ dropdown สูงเป็นพัน px (ขนส่ง 93 ราย = 3,428px บนจอ 674px)
   แล้ว select2 ไล่จัดตำแหน่ง/สลับเปิดบน-ล่างทุก scroll event = อาการ "เด้ง"
   15rem = ค่าเดียวกับธีม bootstrap4 ทางการ (วัดหลังแก้: 3,428px → 284px, จัดตำแหน่งใหม่ 0 ครั้ง) */
.select2-container--bootstrap4 .select2-results__options,
.select2-container--default .select2-results__options {
  max-height: 15rem;
  overflow-y: auto;
}

@media (max-width: 991.98px) {
  :root {
    --sideMenuWidth: 0px;
  }

  #sidebar-wrapper {
    left: -240px;
    opacity: 0;
    visibility: hidden;
    width: 240px; /* จอเล็ก --sideMenuWidth = 0 — sidebar ต้องมีความกว้างจริงตอนเปิด overlay */
  }

  /* body.sidebar-open ต้อง specificity ≥ body.sidebar-collapsed (user อาจติดสถานะ collapsed มาจาก desktop) */
  #sidebar-wrapper.active,
  body.sidebar-open #sidebar-wrapper {
    left: 0;
    opacity: 1;
    visibility: visible;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.2);
  }

  /* backdrop มืดหลัง sidebar — แตะเพื่อปิด (z-index ต่ำกว่า sidebar:1040 สูงกว่าเนื้อหา) */
  body.sidebar-open::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1035;
  }

  /* top-bar: ตอนกางเมนู (navbar-collapse) ให้แถบยืดสูงตามเนื้อหา ไม่ล้นออกนอกพื้นหลัง */
  .purchase-navbar {
    height: auto;
    min-height: var(--navHeight);
  }

  .purchase-navbar .container-fluid {
    flex-wrap: wrap;
    min-height: var(--navHeight);
    padding-left: 12px;
    padding-right: 12px;
  }

  .purchase-navbar .navbar-brand {
    line-height: normal;
    font-size: 1.05rem;
    margin-left: 6px;
  }

  .logo-img {
    width: 54px;
    height: 31px;
  }

  /* ปุ่มไอคอนซ้าย-ขวาให้เป็นคู่หน้าตาเดียวกัน: ซ้าย = เมนูย่อยของโมดูล, ขวา = สลับโมดูล/บัญชี
     (.purchase-navbar ไม่ได้ใส่ class .navbar เลยไม่ได้ justify-content:space-between
      ของ bootstrap มาเอง → ปุ่มขวาต้องดันด้วย margin-left:auto) */
  .purchase-navbar #sidebar-toggle-btn,
  .purchase-navbar .navbar-toggler {
    width: 38px;
    height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
    transition: background 0.2s ease, border-color 0.2s ease;
  }

  .purchase-navbar #sidebar-toggle-btn {
    margin-right: 0 !important;
    font-size: 1.05rem;
  }

  .purchase-navbar .navbar-toggler {
    margin-left: auto;
  }

  .purchase-navbar #sidebar-toggle-btn:hover,
  .purchase-navbar .navbar-toggler:hover {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.28);
  }

  .purchase-navbar #sidebar-toggle-btn:hover {
    transform: none; /* ทับ scale(1.1) ของ desktop — ปุ่มมีกรอบแล้วขยับแล้วดูสั่น */
  }

  /* ปุ่มขวาเป็นไอคอน 4 ช่อง (สลับโมดูล) ไม่ใช่ ☰ ซ้ำกับปุ่มซ้ายจนสับสน */
  .purchase-navbar .navbar-toggler .navbar-toggler-icon {
    width: 19px;
    height: 19px;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='rgba(255,255,255,0.92)'%3e%3crect x='3' y='3' width='7.5' height='7.5' rx='1.8'/%3e%3crect x='13.5' y='3' width='7.5' height='7.5' rx='1.8'/%3e%3crect x='3' y='13.5' width='7.5' height='7.5' rx='1.8'/%3e%3crect x='13.5' y='13.5' width='7.5' height='7.5' rx='1.8'/%3e%3c/svg%3e");
  }

  .purchase-navbar .navbar-toggler[aria-expanded='true'] {
    background: rgba(254, 187, 18, 0.18);
    border-color: rgba(254, 187, 18, 0.55);
  }

  /* แผงเมนูที่กางออกมา — เป็นรายการเต็มความกว้าง ไอคอนตรงคอลัมน์เดียวกัน */
  .purchase-navbar .navbar-collapse {
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.4rem 0 0.6rem;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
  }

  .purchase-navbar .navbar-nav {
    width: 100%;
    align-items: stretch;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  .purchase-navbar .navbar-nav .nav-link {
    height: auto;
    justify-content: flex-start;
    padding: 0.7rem 0.85rem;
    margin: 2px 0;
    border-radius: 10px;
  }

  .purchase-navbar .navbar-nav .nav-link i {
    width: 1.4rem;
    text-align: center;
    margin-right: 0.55rem;
  }

  /* จอเล็กเมนูเรียงลงมา — ขีดใต้ของ desktop ใช้ไม่ได้ เปลี่ยนเป็นแถบสีด้านซ้าย */
  .purchase-navbar .module-nav .nav-link.active {
    box-shadow: inset 3px 0 0 #febb12;
  }

  .purchase-navbar .navbar-collapse > .navbar-nav + .navbar-nav {
    margin-top: 0.4rem;
    padding-top: 0.4rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
  }

  /* ดรอปดาวน์ผู้ใช้: กางในแผงเลย ไม่ลอยทับเนื้อหา
     popper.js ยัด transform/top/left เป็น inline style ต้องล้างด้วย !important
     ไม่งั้นถึงจะ position:static แล้ว transform ก็ยังดันเมนูหลุดออกนอกแถบ */
  .purchase-navbar .navbar-collapse .dropdown-menu {
    position: static !important;
    transform: none !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    float: none;
    width: 100%;
    margin: 0.15rem 0 0;
    padding: 0.25rem;
    background: rgba(255, 255, 255, 0.06);
    border: none;
    box-shadow: none;
  }

  #app {
    padding-left: 20px !important;
    padding-right: 20px !important;
  }
}

.summary-card {
  transition: all 0.2s ease;
}

.summary-card.ring-active {
  border: 2px solid #17a2b8 !important;
}

.summary-card.ring-active-warning {
  border: 2px solid #ffc107 !important;
}

.summary-card.ring-active-success {
  border: 2px solid #28a745 !important;
}

.summary-card.ring-active-primary {
  border: 2px solid #007bff !important;
}

.summary-card.ring-active-danger {
  border: 2px solid #dc3545 !important;
}

.summary-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1) !important;
}

#preview_table {
  table-layout: fixed;
}

#preview_table th,
#preview_table td {
  word-wrap: break-word;
  white-space: normal;
  vertical-align: middle !important;
}

.preview-scroll {
  max-height: 600px;
  overflow-y: auto;
}

.skeleton-box {
  display: inline-block;
  position: relative;
  overflow: hidden;
  background-color: #e2e8f0;
  border-radius: 4px;
}

.skeleton-box::after {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  transform: translateX(-100%);
  background-image: linear-gradient(90deg, rgba(255, 255, 255, 0) 0, rgba(255, 255, 255, 0.4) 20%, rgba(255, 255, 255, 0.6) 60%, rgba(255, 255, 255, 0));
  animation: shimmer 1.5s infinite;
  content: '';
}

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

.supplier-duplicate-row {
  background-color: rgba(255, 193, 7, 0.12) !important;
  border-left: 4px solid #ffc107 !important;
}

.duplicate-supplier-badge {
  display: inline-block;
  background: #ffc107;
  color: #6b4c00;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: middle;
  white-space: nowrap;
  cursor: default;
}

.table-responsive:has(.fix-header-table) {
  max-height: calc(100vh - 220px);
  overflow-y: auto;
}

.fix-header-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.fix-header-table thead th {
  background-color: #f8f9fa !important;
  background-clip: padding-box;
  border-bottom: 1px solid #dee2e6;
}

.fix-header-table thead.thead-dark th {
  background-color: #343a40 !important;
  color: #fff !important;
  border-bottom: 1px solid #454d55;
}

.currency-list-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.07);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background-color 0.15s ease, border-left 0.15s ease;
}

.currency-list-item:last-child {
  border-bottom: none;
}

.currency-list-item:hover {
  background-color: rgba(45, 106, 159, 0.07);
}

.currency-list-item.active {
  background-color: rgba(45, 106, 159, 0.12);
  border-left: 3px solid #2d6a9f;
  padding-left: calc(1rem - 3px);
}

.currency-list-item .currency-item-info {
  flex: 1;
  min-width: 0;
}

.currency-list-item .currency-code {
  font-weight: 700;
  color: #1a3c5e;
  font-size: 1rem;
}

.currency-list-item .currency-name {
  font-size: 0.8rem;
  color: #6c757d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.currency-list-item .btn-delete-currency {
  flex-shrink: 0;
  margin-left: 0.5rem;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.currency-list-item:hover .btn-delete-currency,
.currency-list-item.active .btn-delete-currency {
  opacity: 1;
}

/* แถว item ที่ user เพิ่มเอง (supplier preview / draft) — ฟ้าอ่อนกว่า .table-info ของ bootstrap */
.table-info-light,
.table-info-light > td,
.table-info-light > th {
  background-color: #eaf7fa;
}

.table-hover .table-info-light:hover,
.table-hover .table-info-light:hover > td {
  background-color: #dcf0f6;
}

/*# sourceMappingURL=global.css.map */