/* RC1.1-MOBILE-COMPACT-FIX1 — Web 8204.
   Presentation-only patch for the Customer/Supplier and Cost Category views.
   Desktop tables and every canonical business handler remain unchanged. */

/* --------------------------------------------------------------------------
   Customer / supplier master data
   -------------------------------------------------------------------------- */

body.cmd-p17-mobile #customersView {
  min-width: 0;
  overflow-x: clip;
}

body.cmd-p17-mobile #customersView > .v713-master-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  width: 100%;
  margin-bottom: 10px;
}

body.cmd-p17-mobile #customersView > .v713-master-toolbar > input {
  width: 100%;
  max-width: none !important;
  min-height: 44px;
  font-size: 15px !important;
}

body.cmd-p17-mobile #customersView > .v713-master-toolbar > .toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  width: 100%;
}

body.cmd-p17-mobile #customersView > .v713-master-toolbar > .toolbar > .btn {
  min-width: 0;
  min-height: 42px;
  padding: 8px 9px;
  font-size: 13px !important;
  line-height: 1.25;
  white-space: normal;
}

body.cmd-p17-mobile #customersView > .v713-master-toolbar > .toolbar > .btn.primary {
  order: -1;
  grid-column: 1 / -1;
}

body.cmd-p17-mobile #customersView > .panel {
  margin-top: 0 !important;
  overflow: visible;
  border: 0;
  background: transparent;
  box-shadow: none;
}

body.cmd-p17-mobile #customersView .table-wrap {
  width: 100%;
  overflow: visible;
  overscroll-behavior: auto;
}

body.cmd-p17-mobile #customersView table {
  display: block;
  width: 100%;
  min-width: 0 !important;
  border: 0;
}

body.cmd-p17-mobile #customersView thead {
  display: none;
}

body.cmd-p17-mobile #customersView tbody {
  display: grid;
  gap: 9px;
  width: 100%;
}

body.cmd-p17-mobile #customersView tbody > tr {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 12px;
  width: 100%;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--cmd-color-border, #d7e0ea);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 3px 12px rgba(15, 23, 42, .045);
}

body.cmd-p17-mobile #customersView tbody > tr:has(.v713-customer-check) {
  padding-left: 52px;
}

body.cmd-p17-mobile #customersView tbody > tr > td {
  min-width: 0;
  padding: 0 !important;
  border: 0;
  background: transparent !important;
  color: var(--cmd-color-text, #0f172a);
  font-size: 13px !important;
  line-height: 1.35;
}

body.cmd-p17-mobile #customersView tbody > tr > td:has(> .v713-customer-check) {
  position: absolute;
  top: 13px;
  left: 14px;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
}

body.cmd-p17-mobile #customersView .v713-customer-check {
  width: 20px !important;
  height: 20px !important;
  min-height: 0 !important;
  margin: 0;
}

/* Eight data cells remain stable whether the permission checkbox is present. */
body.cmd-p17-mobile #customersView tbody > tr > td:nth-last-child(8) {
  order: 2;
  grid-column: 1 / -1;
  color: #175cd3;
  font-size: 12px !important;
  letter-spacing: .005em;
  overflow-wrap: anywhere;
}

body.cmd-p17-mobile #customersView tbody > tr > td:nth-last-child(8) > strong {
  font-weight: 800;
}

body.cmd-p17-mobile #customersView tbody > tr > td:nth-last-child(7) {
  order: 1;
  grid-column: 1 / -1;
  font-size: 15px !important;
  font-weight: 750;
  line-height: 1.32;
  overflow-wrap: anywhere;
}

body.cmd-p17-mobile #customersView tbody > tr > td:nth-last-child(6) {
  order: 3;
  grid-column: 1 / -1;
  justify-self: start;
  width: fit-content;
  max-width: 100%;
  padding: 4px 8px !important;
  border-radius: 999px;
  background: #edf7f4 !important;
  color: #067647;
  font-size: 11.5px !important;
  font-weight: 750;
}

body.cmd-p17-mobile #customersView tbody > tr > td:nth-last-child(6) > .status {
  padding: 0;
  background: transparent;
  color: #b54708;
  font-size: inherit !important;
}

body.cmd-p17-mobile #customersView tbody > tr > td:nth-last-child(5),
body.cmd-p17-mobile #customersView tbody > tr > td:nth-last-child(4),
body.cmd-p17-mobile #customersView tbody > tr > td:nth-last-child(3),
body.cmd-p17-mobile #customersView tbody > tr > td:nth-last-child(2) {
  display: grid;
  align-content: start;
  gap: 2px;
  padding-top: 7px !important;
  border-top: 1px solid #edf1f5;
}

body.cmd-p17-mobile #customersView tbody > tr > td:nth-last-child(5) {
  order: 4;
}

body.cmd-p17-mobile #customersView tbody > tr > td:nth-last-child(4) {
  order: 5;
}

body.cmd-p17-mobile #customersView tbody > tr > td:nth-last-child(3) {
  order: 6;
  grid-column: 1 / -1;
}

body.cmd-p17-mobile #customersView tbody > tr > td:nth-last-child(2) {
  order: 7;
}

body.cmd-p17-mobile #customersView tbody > tr > td:nth-last-child(5)::before,
body.cmd-p17-mobile #customersView tbody > tr > td:nth-last-child(4)::before,
body.cmd-p17-mobile #customersView tbody > tr > td:nth-last-child(3)::before,
body.cmd-p17-mobile #customersView tbody > tr > td:nth-last-child(2)::before {
  color: var(--cmd-color-muted, #64748b);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .035em;
  text-transform: uppercase;
}

body.cmd-p17-mobile #customersView tbody > tr > td:nth-last-child(5)::before {
  content: "MST";
}

body.cmd-p17-mobile #customersView tbody > tr > td:nth-last-child(4)::before {
  content: "Điện thoại";
}

body.cmd-p17-mobile #customersView tbody > tr > td:nth-last-child(3)::before {
  content: "Tài khoản";
}

body.cmd-p17-mobile #customersView tbody > tr > td:nth-last-child(2)::before {
  content: "Công nợ";
}

body.cmd-p17-mobile #customersView tbody > tr > td:nth-last-child(5):empty,
body.cmd-p17-mobile #customersView tbody > tr > td:nth-last-child(4):empty {
  display: none;
}

body.cmd-p17-mobile #customersView tbody > tr > td:nth-last-child(3) small {
  color: var(--cmd-color-muted, #64748b);
  font-size: 11.5px;
}

body.cmd-p17-mobile #customersView tbody > tr > td:last-child {
  order: 8;
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 6px;
}

body.cmd-p17-mobile #customersView tbody > tr > td:last-child:not(:has(button)) {
  display: none;
}

body.cmd-p17-mobile #customersView tbody > tr > td:last-child .mini-btn {
  min-width: 50px;
  min-height: 38px;
  padding: 7px 9px;
  font-size: 12.5px !important;
}

/* --------------------------------------------------------------------------
   Tracked cost-category tree
   -------------------------------------------------------------------------- */

body.cmd-p17-mobile #categoriesView {
  min-width: 0;
  overflow-x: clip;
}

body.cmd-p17-mobile #categoriesView .v7101-category-toolbar {
  gap: 9px;
  margin-bottom: 10px;
}

body.cmd-p17-mobile #categoriesView .v7101-category-toolbar :is(input, select) {
  min-height: 44px;
  font-size: 14px !important;
}

body.cmd-p17-mobile #categoriesView .v7101-category-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  width: 100%;
}

body.cmd-p17-mobile #categoriesView .v7101-category-actions > :is(.btn, a, details),
body.cmd-p17-mobile #categoriesView .qscm-category-tree-actions {
  min-width: 0;
  width: 100%;
}

body.cmd-p17-mobile #categoriesView .v7101-category-actions .btn,
body.cmd-p17-mobile #categoriesView .v7101-category-actions a.btn {
  min-width: 0;
  min-height: 40px;
  padding: 7px 8px;
  font-size: 12.5px !important;
  line-height: 1.25;
  white-space: normal;
}

body.cmd-p17-mobile #categoriesView .v7101-category-panel {
  margin-top: 0;
  min-width: 0;
  overflow: hidden;
}

body.cmd-p17-mobile #categoriesView .v7101-category-panel-header {
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
}

body.cmd-p17-mobile #categoriesView .v7101-category-panel-header > div:first-child {
  min-width: 0;
}

body.cmd-p17-mobile #categoriesView .v7101-category-panel-header h3 {
  font-size: 15px;
}

body.cmd-p17-mobile #categoriesView .v7101-category-panel-header .muted {
  display: -webkit-box;
  margin-top: 3px;
  overflow: hidden;
  color: var(--cmd-color-muted, #64748b);
  font-size: 11px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

body.cmd-p17-mobile #categoriesView .v7101-category-summary {
  flex: 0 0 auto;
  align-items: flex-end;
  gap: 2px;
}

body.cmd-p17-mobile #categoriesView .v7101-category-summary .status {
  padding: 5px 8px;
  font-size: 12px !important;
}

body.cmd-p17-mobile #categoriesView .v7101-category-summary small {
  max-width: 105px;
  font-size: 10px;
  line-height: 1.25;
  text-align: right;
  white-space: normal;
}

body.cmd-p17-mobile #categoriesView .qscm-category-selectionbar {
  padding: 8px 10px;
}

body.cmd-p17-mobile #categoriesView .qscm-category-selectionbar .v713-category-bulk {
  gap: 6px;
}

body.cmd-p17-mobile #categoriesView .qscm-category-selectionbar .v713-category-bulk .btn {
  min-height: 40px;
  padding: 7px 5px;
  font-size: 12.5px !important;
  line-height: 1.2;
}

body.cmd-p17-mobile #categoriesView .v7101-category-scroll {
  width: 100%;
  height: auto !important;
  min-height: 0 !important;
  max-height: none;
  overflow: visible !important;
  scrollbar-gutter: auto;
  border-top-color: #e5eaf0;
  background: #f6f8fb;
}

body.cmd-p17-mobile #categoriesView .v7101-category-table {
  display: block;
  width: 100%;
  min-width: 0 !important;
  border: 0;
}

body.cmd-p17-mobile #categoriesView .v7101-category-table thead {
  display: none;
}

body.cmd-p17-mobile #categoriesView .v7101-category-table tbody {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 8px;
}

body.cmd-p17-mobile #categoriesView .v7101-category-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px 10px;
  width: 100%;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--cmd-color-border, #d7e0ea);
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 2px 9px rgba(15, 23, 42, .035);
}

body.cmd-p17-mobile #categoriesView .v7101-category-row:has(.v713-row-check) {
  padding-left: 50px;
}

body.cmd-p17-mobile #categoriesView .v7101-category-row > td {
  min-width: 0;
  padding: 0 !important;
  border: 0;
  background: transparent !important;
  font-size: 12.5px !important;
}

body.cmd-p17-mobile #categoriesView .v7101-category-row > .v713-check-cell {
  position: absolute;
  top: 14px;
  left: 13px;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
}

body.cmd-p17-mobile #categoriesView .v7101-category-row > .v713-check-cell input {
  width: 19px !important;
  height: 19px !important;
  min-height: 0 !important;
  margin: 0;
}

body.cmd-p17-mobile #categoriesView .v7101-category-main {
  grid-column: 1 / -1;
  min-width: 0 !important;
}

body.cmd-p17-mobile #categoriesView .v7101-tree-line {
  min-width: 0;
  min-height: 36px;
  gap: 7px;
  padding-left: calc(var(--tree-level, 0) * 12px);
}

body.cmd-p17-mobile #categoriesView .v7101-tree-toggle,
body.cmd-p17-mobile #categoriesView .v7101-tree-leaf {
  width: 36px;
  min-width: 36px;
  height: 36px;
}

body.cmd-p17-mobile #categoriesView .v7101-tree-toggle {
  border-radius: 10px;
  font-size: 20px !important;
}

body.cmd-p17-mobile #categoriesView .v7101-tree-leaf {
  display: grid;
  place-items: center;
}

body.cmd-p17-mobile #categoriesView .v7101-category-code-name {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  gap: 3px 8px;
  min-width: 0;
}

body.cmd-p17-mobile #categoriesView .v7101-category-code {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  color: #175cd3;
  font-size: 13px;
  overflow-wrap: anywhere;
}

body.cmd-p17-mobile #categoriesView .v7101-category-title {
  flex: 1 1 150px;
  min-width: 0;
  color: var(--cmd-color-text, #0f172a);
  font-size: 14px;
  line-height: 1.32;
  overflow-wrap: anywhere;
}

body.cmd-p17-mobile #categoriesView .v7101-standard-tag {
  flex: 0 0 auto;
  align-self: center;
  padding: 3px 6px;
  font-size: 10.5px;
}

body.cmd-p17-mobile #categoriesView .v7101-category-path {
  max-width: none;
  margin: 4px 0 0 calc(43px + (var(--tree-level, 0) * 12px));
  color: var(--cmd-color-muted, #64748b);
  font-size: 10.5px;
}

body.cmd-p17-mobile #categoriesView .v7101-category-row > td:nth-last-child(3) {
  grid-column: 1;
  justify-self: start;
}

body.cmd-p17-mobile #categoriesView .category-level-pill {
  padding: 4px 7px;
  font-size: 10.5px;
}

body.cmd-p17-mobile #categoriesView .v7101-category-row > td:nth-last-child(2) {
  grid-column: 1 / -1;
  color: var(--cmd-color-muted, #64748b);
  font-size: 11px !important;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

body.cmd-p17-mobile #categoriesView .v7101-category-row:not(.v7101-root-row) > td:nth-last-child(2)::before {
  content: "Thuộc: ";
  font-weight: 700;
}

body.cmd-p17-mobile #categoriesView .v7101-root-row > td:nth-last-child(2) {
  display: none;
}

body.cmd-p17-mobile #categoriesView .v7101-category-row > td:last-child {
  grid-column: 2;
  grid-row: 2;
  align-self: center;
  color: #344054;
  font-size: 11.5px !important;
  font-weight: 700;
  text-align: right;
}

body.cmd-p17-mobile #categoriesView .v7101-category-row > td:last-child::before {
  content: "Đã duyệt ";
  color: var(--cmd-color-muted, #64748b);
  font-size: 10px;
  font-weight: 600;
}

@media (max-width: 380px) {
  body.cmd-p17-mobile #customersView tbody > tr,
  body.cmd-p17-mobile #categoriesView .v7101-category-row {
    gap: 6px 8px;
  }

  body.cmd-p17-mobile #customersView tbody > tr {
    padding-right: 10px;
  }

  body.cmd-p17-mobile #customersView tbody > tr:has(.v713-customer-check) {
    padding-left: 48px;
  }

  body.cmd-p17-mobile #categoriesView .v7101-category-row:has(.v713-row-check) {
    padding-left: 47px;
  }

  body.cmd-p17-mobile #categoriesView .v7101-category-title {
    flex-basis: 130px;
  }
}
