
/* Backoffice master search width */
body[data-portal="backoffice"] .filter-bar > :first-child {
  min-width: 360px;
}

@media (max-width: 720px) {
  body[data-portal="backoffice"] .filter-bar > :first-child {
    min-width: 0;
    width: 100%;
  }
}

/* Backoffice master search input */
body[data-portal="backoffice"] .filter-bar > .filter-bar input[type="search"] {
  width: 420px;
  max-width: 45vw;
}

@media (max-width: 720px) {
  body[data-portal="backoffice"] .filter-bar > .filter-bar input[type="search"] {
    width: 100%;
    max-width: 100%;
  }
}

/* Flatten nested master search bar */
body[data-portal="backoffice"] .filter-bar > .filter-bar {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

body[data-portal="backoffice"] .filter-bar > .filter-bar input[type="search"] {
  width: 420px;
}

/* Hotel Rate form: two columns per row */
body[data-portal="backoffice"] dialog form[data-workflow="hotel-rate"] .typed-fields {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 20px;
}

body[data-portal="backoffice"] dialog form[data-workflow="hotel-rate"] .typed-fields label {
  min-width: 0;
}

@media (max-width: 720px) {
  body[data-portal="backoffice"] dialog form[data-workflow="hotel-rate"] .typed-fields {
    grid-template-columns: 1fr;
  }
}

/* Shop Commission Master forms */
body[data-portal="backoffice"] dialog form[data-workflow="shop-create"] .typed-fields,
body[data-portal="backoffice"] dialog form[data-workflow="shop-version"] .typed-fields,
body[data-portal="backoffice"] dialog form[data-workflow="sales-policy"] .typed-fields,
body[data-portal="backoffice"] dialog form[data-workflow="sales-shopping-policy"] .typed-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 16px;
}

body[data-portal="backoffice"] dialog form[data-workflow="shop-create"] .typed-fields label,
body[data-portal="backoffice"] dialog form[data-workflow="shop-version"] .typed-fields label,
body[data-portal="backoffice"] dialog form[data-workflow="sales-policy"] .typed-fields label,
body[data-portal="backoffice"] dialog form[data-workflow="sales-shopping-policy"] .typed-fields label {
  min-width: 0;
}

body[data-portal="backoffice"] dialog form[data-workflow="shop-create"] .typed-fields label:last-child,
body[data-portal="backoffice"] dialog form[data-workflow="shop-version"] .typed-fields label:last-child,
body[data-portal="backoffice"] dialog form[data-workflow="sales-policy"] .typed-fields label:last-child,
body[data-portal="backoffice"] dialog form[data-workflow="sales-shopping-policy"] .typed-fields label:last-child {
  grid-column: 1 / -1;
}

@media (max-width: 720px) {
  body[data-portal="backoffice"] dialog form[data-workflow="shop-create"] .typed-fields,
  body[data-portal="backoffice"] dialog form[data-workflow="shop-version"] .typed-fields,
  body[data-portal="backoffice"] dialog form[data-workflow="sales-policy"] .typed-fields,
  body[data-portal="backoffice"] dialog form[data-workflow="sales-shopping-policy"] .typed-fields {
    grid-template-columns: 1fr;
  }

  body[data-portal="backoffice"] dialog form[data-workflow="shop-create"] .typed-fields label:last-child,
  body[data-portal="backoffice"] dialog form[data-workflow="shop-version"] .typed-fields label:last-child,
  body[data-portal="backoffice"] dialog form[data-workflow="sales-policy"] .typed-fields label:last-child,
  body[data-portal="backoffice"] dialog form[data-workflow="sales-shopping-policy"] .typed-fields label:last-child {
    grid-column: auto;
  }
}


/* Representative Commission Rules */
.representative-rules {
  display: grid;
  gap: 18px;
}

.representative-rule-card {
  border: 1px solid var(--border, #dfe3e8);
  border-radius: 14px;
  padding: 18px;
  background: var(--surface, #fff);
}

.representative-rule-card > h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.representative-rule-card > .muted {
  margin: 0 0 16px;
}

.representative-rule-card .e2e-table,
.representative-rule-card table {
  margin-bottom: 14px;
}

.representative-bonus-card {
  padding-bottom: 14px;
}

@media (max-width: 760px) {
  .representative-rule-card {
    padding: 14px;
    overflow-x: auto;
  }
}


/* Agent Administration */
.agent-administration {
  display: grid;
  gap: 16px;
}

.agent-admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.agent-admin-toolbar p {
  margin: 0;
}

.agent-admin-manage {
  display: grid;
  gap: 18px;
}

.agent-admin-summary {
  border: 1px solid var(--border, #dfe3e8);
  border-radius: 14px;
  padding: 16px;
  background: var(--surface, #fff);
}

.agent-admin-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.agent-admin-facts > div {
  display: grid;
  gap: 4px;
}

.agent-admin-section {
  border: 1px solid var(--border, #dfe3e8);
  border-radius: 14px;
  padding: 18px;
  background: var(--surface, #fff);
}

.agent-admin-section > h3 {
  margin: 0 0 6px;
}

.agent-admin-section > .muted {
  margin: 0 0 14px;
}

.agent-admin-section form .typed-fields {
  display: grid;
  gap: 14px;
}

.checkbox-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 6px;
}

.checkbox-option {
  display: flex !important;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border, #dfe3e8);
  border-radius: 10px;
  cursor: pointer;
}

.checkbox-option input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
}

.checkbox-option span {
  font-weight: 600;
}

@media (max-width: 760px) {
  .agent-admin-facts,
  .checkbox-group {
    grid-template-columns: 1fr;
  }
}


/* Agent Administration Search + Create */
.agent-search-controls {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.agent-search-controls > label {
  display: grid;
  gap: 5px;
  min-width: 210px;
}

.agent-search-controls select,
.agent-search-controls input {
  min-height: 42px;
}

.agent-create-form {
  display: grid;
  gap: 14px;
}

.agent-create-form .typed-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.agent-create-form .typed-fields > label:has(textarea),
.agent-create-form .typed-fields > label:has(.checkbox-group) {
  grid-column: 1 / -1;
}

@media (max-width: 760px) {
  .agent-admin-toolbar,
  .agent-search-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .agent-search-controls > label,
  .agent-create-form .typed-fields {
    min-width: 0;
    grid-template-columns: 1fr;
  }
}


/* Agent Administration toolbar polish */
.agent-administration .agent-admin-toolbar {
  display: grid;
  gap: 9px;
  justify-content: start;
  padding: 16px;
  border: 1px solid var(--line, #dde3e8);
  border-radius: 12px;
  background: #fff;
}

.agent-administration .agent-search-controls {
  display: flex;
  align-items: end;
  justify-content: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}

.agent-administration .agent-search-controls > label {
  min-width: 220px;
  margin: 0;
}

.agent-administration .agent-search-button,
.agent-administration .agent-create-button {
  min-height: 42px;
  white-space: nowrap;
}

.agent-administration .agent-search-help {
  margin: 0;
}

.agent-administration > .table-scroll,
.agent-administration > .empty-state {
  margin-top: 2px;
}

@media (max-width: 760px) {
  .agent-administration .agent-search-controls {
    display: grid;
    grid-template-columns: 1fr;
  }

  .agent-administration .agent-search-controls > label {
    min-width: 0;
  }

  .agent-administration .agent-search-button,
  .agent-administration .agent-create-button {
    width: 100%;
  }
}

/* Agent Administration — wider Name search */
.agent-administration .agent-search-controls > label:first-child {
  min-width: 440px;
}

@media (max-width: 760px) {
  .agent-administration .agent-search-controls > label:first-child {
    min-width: 0;
  }
}
