/* Admin-only readability and responsive behavior. Public cashier pages have no aside. */
body:has(aside) {
  --xb-admin-control-height: 36px;
  --xb-admin-form-height: 36px;
}

body:has(aside) .text-\[10px\],
body:has(aside) .text-\[11px\],
body:has(aside) small {
  font-size: 12px !important;
  line-height: 1.4 !important;
}

body:has(aside) :is(.inline-flex, .flex).h-5.rounded-full {
  min-height: 24px;
  height: auto;
  line-height: 1.25;
}

body:has(aside) :is(header, aside, main) button:not([role="switch"]),
body:has(aside) :is(header, aside, main) [role="button"]:not([role="switch"]),
body:has(aside) [role="dialog"] button:not([role="switch"]),
body:has(aside) [role="menu"] [role="menuitem"],
body:has(aside) [role="listbox"] [role="option"],
body:has(aside) .xb-select-option {
  min-height: var(--xb-admin-control-height) !important;
}

body:has(aside) [role="switch"] {
  width: 36px !important;
  min-width: 36px !important;
  height: 20px !important;
  min-height: 20px !important;
  flex: 0 0 36px;
  padding: 0 !important;
}

body:has(aside) .xb-channel-avatar {
  width: 56px;
  height: 56px;
  position: relative;
  flex: 0 0 56px;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 5px 5px 16px;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 4px 12px hsl(var(--foreground) / .08);
}

body:has(aside) .xb-channel-avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

body:has(aside) .xb-channel-avatar span {
  height: 15px;
  position: absolute;
  right: 2px;
  bottom: 1px;
  left: 2px;
  overflow: hidden;
  color: #4b5563;
  font-size: 10px !important;
  font-weight: 700;
  line-height: 15px !important;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body:has(aside) :is(header, aside, main) button[aria-label],
body:has(aside) [role="dialog"] button[aria-label] {
  min-width: var(--xb-admin-control-height);
}

body:has(aside) main :is(
  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
  select,
  textarea
),
body:has(aside) [role="dialog"] :is(
  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
  select,
  textarea
) {
  min-height: var(--xb-admin-form-height) !important;
  font-size: 14px;
}

/* Sort labels are text controls, not primary touch targets. */
body:has(aside) main .responsive-table th button {
  min-width: 0;
}

body:has(aside) main .responsive-table td:last-child > div {
  flex-wrap: wrap;
}

body:has(aside) main .responsive-table:not(.xb-orders-table) .mono.truncate {
  max-width: 100%;
  overflow: visible;
  overflow-wrap: anywhere;
  text-overflow: clip;
  white-space: normal;
}

body:has(aside) main div:has(> div > p.truncate.font-mono) {
  gap: 4px !important;
}

body:has(aside) .xb-orders-table .text-\[10px\] {
  font-size: 12px !important;
  line-height: 1.4 !important;
}

body:has(aside) .xb-orders-table .xb-order-payment .grid.size-4.text-\[10px\] {
  width: 18px;
  height: 18px;
}

/* Dashboard labels were designed below the readable 12px floor. */
body:has(aside) :is(
  .xb-stat-note,
  .xb-outcome-day-label,
  .xb-outcome-values,
  .xb-day-trend-item-header span,
  .xb-day-donut-meta,
  .xb-day-donut-tooltip,
  .xb-channel-count,
  .xb-channel-sort,
  .xb-segmented button,
  .xb-chart-tooltip
) {
  font-size: 12px !important;
  line-height: 1.35;
}

body:has(aside) .xb-day-trends-title-text p,
body:has(aside) .xb-channel-table-wrap table,
body:has(aside) .xb-channel-rank {
  font-size: 12px !important;
  line-height: 1.35;
}

body:has(aside) .xb-chart-grid text {
  font-size: 12px !important;
}

body:has(aside) .xb-segmented button {
  min-height: var(--xb-admin-control-height);
  padding-inline: 10px;
}

/* The verification manager is mounted in its own fixed shell. */
body:has(aside) .xb-v-shell :is(p, span, small, code, button),
body:has(aside) .xb-v-nav-label,
body:has(aside) .xb-v-table th,
body:has(aside) .xb-v-table td::before {
  font-size: 12px !important;
  line-height: 1.4;
}

body:has(aside) .xb-v-add span {
  font-size: 17px !important;
}

body:has(aside) .xb-v-search > span {
  font-size: 18px !important;
}

body:has(aside) .xb-v-btn,
body:has(aside) .xb-v-icon-btn,
body:has(aside) .xb-v-resource-trigger,
body:has(aside) .xb-v-shell .xb-select-button {
  min-height: var(--xb-admin-control-height) !important;
}

body:has(aside) .xb-v-person-actions {
  width: auto;
  min-width: 208px;
}

body:has(aside) .xb-v-search input,
body:has(aside) .xb-v-filter select,
body:has(aside) .xb-v-filter input,
body:has(aside) .xb-v-field input,
body:has(aside) .xb-v-field select {
  min-height: var(--xb-admin-form-height);
  height: var(--xb-admin-form-height);
  font-size: 13px;
}

body:has(aside) .xb-v-status {
  min-height: 24px;
  padding-inline: 8px;
}

body:has(aside) .xb-proxy-test-button {
  min-height: var(--xb-admin-control-height) !important;
}

body:has(aside) > span {
  font-size: 12px !important;
}

/* Preserve the graphic-only brand mark after normalizing tiny utility text. */
body:has(aside) a[href="#/"] > span.grid.size-7 {
  font-size: 0 !important;
}

@media (max-width: 1199px) {
  body:has(aside) main p.truncate.font-mono {
    max-width: 100%;
    overflow: visible;
    overflow-wrap: anywhere;
    text-overflow: clip;
    white-space: normal;
  }

  body:has(aside) main div:has(> div > p.truncate.font-mono) {
    flex-wrap: wrap;
  }

  body:has(aside) main div:has(> p.truncate.font-mono) {
    flex: 1 0 100%;
  }
}

/* Generic data tables become cards before their actions overflow at tablet widths. */
@media (min-width: 768px) and (max-width: 1199px) {
  body:has(aside) main .responsive-table:not(.xb-orders-table),
  body:has(aside) main .responsive-table:not(.xb-orders-table) tbody,
  body:has(aside) main .responsive-table:not(.xb-orders-table) tr,
  body:has(aside) main .responsive-table:not(.xb-orders-table) td {
    display: block;
    width: 100%;
  }

  body:has(aside) main .responsive-table:not(.xb-orders-table) {
    min-width: 0;
  }

  body:has(aside) main .responsive-table:not(.xb-orders-table) thead {
    display: none;
  }

  body:has(aside) main .responsive-table:not(.xb-orders-table) tbody {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(440px, 100%), 1fr));
    gap: 10px;
    padding: 10px;
  }

  body:has(aside) main .responsive-table:not(.xb-orders-table) tbody tr {
    min-width: 0;
    overflow: hidden;
    border: 1px solid hsl(var(--border));
    border-radius: 8px;
    padding: 10px 12px;
    background: hsl(var(--card));
  }

  body:has(aside) main .responsive-table:not(.xb-orders-table) td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    max-width: none;
    min-height: 36px;
    padding: 6px 0 !important;
    border: 0 !important;
    text-align: right;
  }

  body:has(aside) main .responsive-table:not(.xb-orders-table) td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: hsl(var(--foreground) / 0.56);
    font-size: 12px;
  }

  body:has(aside) main .responsive-table:not(.xb-orders-table) td[data-primary="true"] {
    display: block;
    margin-bottom: 4px;
    padding-bottom: 10px !important;
    border-bottom: 1px solid hsl(var(--border)) !important;
    text-align: left;
  }

  body:has(aside) main .responsive-table:not(.xb-orders-table) td[data-primary="true"]::before {
    display: none;
  }

  body:has(aside) main div:has(> table.responsive-table:not(.xb-orders-table)) {
    max-height: none !important;
    min-height: 0 !important;
    overflow: visible !important;
  }

}

@media (min-width: 1400px) {
  body:has(aside) .xb-orders-table th:nth-child(2),
  body:has(aside) .xb-orders-table td:nth-child(2) {
    width: 21%;
  }

  body:has(aside) .xb-orders-table th:nth-child(4),
  body:has(aside) .xb-orders-table td:nth-child(4) {
    width: 13%;
  }

  body:has(aside) .xb-orders-table th:nth-child(9),
  body:has(aside) .xb-orders-table td:nth-child(9) {
    width: 10%;
  }
}

@media (max-width: 767px) {
  body:has(aside) {
    --xb-admin-control-height: 40px;
    --xb-admin-form-height: 42px;
  }

  body:has(aside) :is(header, main) button:not([role="switch"]),
  body:has(aside) :is(header, main) [role="button"]:not([role="switch"]),
  body:has(aside) [role="dialog"] button:not([role="switch"]),
  body:has(aside) [role="menu"] [role="menuitem"],
  body:has(aside) [role="listbox"] [role="option"],
  body:has(aside) .xb-select-option {
    min-height: var(--xb-admin-control-height) !important;
  }

  body:has(aside) :is(header, main) button[aria-label],
  body:has(aside) [role="dialog"] button[aria-label] {
    min-width: var(--xb-admin-control-height);
  }

  body:has(aside) main .responsive-table:not(.xb-orders-table) td {
    min-height: 36px;
  }

  body:has(aside) main .responsive-table:not(.xb-orders-table) td:last-child > div,
  body:has(aside) .xb-v-actions,
  body:has(aside) .xb-v-chips {
    flex-wrap: wrap;
  }

  body:has(aside) .xb-v-btn,
  body:has(aside) .xb-v-icon-btn,
  body:has(aside) .xb-v-resource-trigger,
  body:has(aside) .xb-v-shell .xb-select-button {
    min-height: var(--xb-admin-control-height) !important;
  }

  body:has(aside) .xb-v-search input,
  body:has(aside) .xb-v-filter select,
  body:has(aside) .xb-v-filter input,
  body:has(aside) .xb-v-field input,
  body:has(aside) .xb-v-field select {
    min-height: var(--xb-admin-form-height);
    height: var(--xb-admin-form-height);
    font-size: 14px;
  }

  body:has(aside) .xb-v-person-actions {
    min-width: 0;
  }

  body:has(aside) .xb-v-person-actions .xb-v-btn {
    min-width: 0;
    white-space: normal;
  }

}
