/* ================================================= */
/* RESET & BASE */
/* ================================================= */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

html,
body {
  height: 100%;
}

body {
  background: #f2f4f7;
  font-size: 22px;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ================================================= */
/* BIẾN ĐIỀU KHIỂN LAYOUT */
/* ================================================= */

:root {
  --dx-min: 300px;
  --dx-max: 40vh;
}

/* ================================================= */
/* MAIN LAYOUT – 6 / 4 */
/* ================================================= */

#main {
  flex: 1;
  display: grid;
  grid-template-columns: 6fr 4fr;
  min-height: 0;
  position: relative;
  margin-top: calc(var(--dx-min) * -1);
  padding-top: var(--dx-min);
}

/* ================================================= */
/* HÀNG TỒN PANEL (TRÁI) */
/* ================================================= */

#hangton-panel {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px;
}

/* ================================================= */
/* CỘT PHẢI – DUY NHẤT 1 SCROLL CONTAINER */
/* ================================================= */

#chu-nav {
  background: #fafafa;
  border-left: 2px solid #d1d5db;
  overflow-y: auto;
  padding: 14px;

  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ================================================= */
/* THẺ CHỦ / ĐƠN */
/* ================================================= */

.chu-item {
  padding: 18px 14px;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  border-radius: 16px;
  cursor: pointer;
  user-select: none;

  background: #e5e7eb;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
  transition: transform 0.08s, box-shadow 0.08s, background 0.15s;
}

.chu-item:active {
  transform: scale(0.97);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.chu-item.chu-goc {
  background: #e3f2fd;
  border-left: 6px solid #1e88e5;
}

.chu-item.gia-cong {
  background: #fce4ec;
  border-left: 6px solid #d81b60;
}

/* ================================================= */
/* 调货 – THẺ ĐẶC BIỆT */
/* ================================================= */

.chu-item.chu-tool {
  background: linear-gradient(135deg, #409eff, #2b7cd3);
  color: #fff;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 2px;
  border-left: 6px solid #1d4ed8;
}

.chu-item.chu-tool:hover {
  background: linear-gradient(135deg, #4aa3ff, #327fd8);
}

/* ================================================= */
/* TIÊU ĐỀ BLOCK */
/* ================================================= */

.section-title {
  margin-top: 22px;
  padding: 12px 14px;
  background: #e3f2fd;
  font-weight: 700;
  font-size: 22px;
  border-left: 6px solid #1e88e5;
}

.section-title.flash {
  background: #fff3cd;
  transition: background 0.6s;
}

/* ================================================= */
/* TABLE HÀNG TỒN */
/* ================================================= */

.hangton-table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
  margin-bottom: 20px;
  font-size: 20px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.hangton-table th,
.hangton-table td {
  border: 1px solid #d1d5db;
  padding: 6px 8px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* GRID CHO TABLE */

.hangton-table.chu-goc {
  display: grid;
  grid-template-columns:
    minmax(10ch, max-content)
    minmax(4ch, max-content)
    1fr;
}

.hangton-table.gia-cong {
  display: grid;
  grid-template-columns:
    minmax(8ch, max-content)
    minmax(10ch, max-content)
    minmax(4ch, max-content)
    1fr;
}

.hangton-table.chu-goc thead,
.hangton-table.chu-goc tbody,
.hangton-table.chu-goc tr,
.hangton-table.gia-cong thead,
.hangton-table.gia-cong tbody,
.hangton-table.gia-cong tr {
  display: contents;
}

/* ================================================= */
/* NGHIỆP VỤ – SEGMENTED */
/* ================================================= */

.nv-group {
  display: flex;
  width: 100%;
  max-width: 360px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  overflow: hidden;
}

.nv-btn {
  flex: 1;
  padding: 10px 0;
  font-size: 15px;
  font-weight: 600;
  background: #f5f5f5;
  color: #374151;
  border: none;
  cursor: pointer;
}

.nv-btn.active,
.nv-btn:active {
  background: #d32f2f;
  color: #fff;
}

.mode-xuathang,
.mode-banma {
  display: none;
}

/* ================================================= */
/* GHI CHÚ */
/* ================================================= */

.group-ghichu {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 8px;
  margin-bottom: 10px;
  align-items: center;
}

.group-ghichu select,
.group-ghichu input {
  height: 34px;
  padding: 4px 8px;
  border: 1px solid #cfd4dc;
  border-radius: 6px;
}

.group-ghichu input {
  font-size: 20px;
  font-weight: 600;
  background-color: #fafafa;
}

.group-ghichu input:focus,
.group-ghichu select:focus {
  outline: none;
  border-color: #4a90e2;
  background-color: #fff;
}

/* ================================================= */
/* BUTTON CUỐI */
/* ================================================= */

.chunghangcuoi {
  display: flex;
  gap: 8px;
  width: 100%;
  flex-direction: row-reverse;
}

.btn-del-wrap,
.btn-ghichu-wrap {
  display: flex;
}

.btn-del-wrap {
  flex: 3;
}
.btn-ghichu-wrap {
  flex: 7;
}

.chunghangcuoi button {
  width: 100%;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}

#btn-xoa1dong {
  background: #fee2e2;
  color: #dc2626;
  border: 1px solid #fca5a5;
}

#btn-writeghichu {
  background: #2563eb;
  color: #fff;
  border: none;
  font-weight: 600;
}

/* ================================================= */
/* 开单按钮 */
/* ================================================= */

#btn-kaidan {
  margin-left: auto;
  padding: 6px 14px;
  font-size: 14px;
  border-radius: 8px;
  border: 1px solid #3aa655;
  background: #3fc26b;
  color: #fff;
  cursor: pointer;
}

#btn-kaidan:hover {
  background: #36b15f;
}

#btn-kaidan:disabled {
  background: #9fd9b3;
  border-color: #9fd9b3;
  cursor: not-allowed;
}

/* Tool nằm dưới cùng */
#donxuat-tools {
  flex: 0 0 auto;
  padding: 8px;
  border-top: 1px solid #ddd;
  background: #fff;
}

/* Nút 调货 */
.dx-tool-btn {
  width: 100%;
  padding: 10px;
  font-size: 16px;
  font-weight: bold;
  background: #ffecec;
  color: #c00;
  border: 1px solid #f5b5b5;
  border-radius: 6px;
  cursor: pointer;
}

.dx-tool-btn:hover {
  background: #ffdede;
}
