/*
 * Shared responsive layer. CSS only: no listeners, polling, API calls or data
 * changes. Natural page scrolling/zoom stay enabled; wide tables scroll locally.
 * any-pointer also covers touch laptops whose primary pointer is a mouse.
 */
:where(.container, .wrap, main, .card, .panel, .field, .filter-panel,
  .import-panel, .catalog-policy, .catalog-rule-fieldset) { min-width: 0; }
:where(.grid, .grid-2, .grid-3, .grid-4, .settings, .filters, .planner-controls,
  .workspace-controls, .catalog-policy-grid, .edit-grid) > * { min-width: 0; }
:where(input, select, textarea) { box-sizing: border-box; max-width: 100%; }
/* Touch sizing must never reveal actions hidden by authorization or app state. */
[hidden] { display: none !important; }
:where(.table-wrap, .table-scroll, .responsive-table, .catalog-table-wrap,
  .source-table, .category-chips) {
  min-width: 0;
  max-width: 100%;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}
/* Boss has a single desktop-width header and nine unbounded navigation tabs. */
.header { flex-wrap: wrap; }
.header > div { min-width: 0; }
#masterStatusBadge { flex-wrap: wrap; }
.tabs { max-width: 100%; overflow-x: auto; padding-block: 4px; gap: 4px; }
.tabs .tab { flex: 0 0 auto; white-space: nowrap; }
button.tab { font-family: inherit; border: 0; border-bottom: 2px solid transparent; background: transparent; }
.suite-scroll-hint { display: none; }
:where(button, a, summary, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid #d97706;
  outline-offset: 3px;
}
dialog {
  box-sizing: border-box;
  max-width: calc(100vw - 24px);
  max-height: 90vh;
  max-height: 90dvh;
  overflow: auto;
}

@media (max-width: 900px), (any-pointer: coarse) {
  /* Minimum target size includes icon buttons, pagination and compact actions.
   * !important is limited to controls because legacy mini buttons use it too. */
  button, .btn, .button, [role="button"], .tabs .tab,
  .suite-navigation a, .topbar a, .top a, .header a,
  nav a, summary, .suite-return-link, body[data-suite-page="pro"] header a,
  label:has(input[type="file"]), label[for="import-costs-input"] {
    min-height: 44px !important;
    min-width: 44px;
    box-sizing: border-box;
    touch-action: manipulation;
  }
  button, .btn, .button, .tabs .tab { line-height: 1.35 !important; }
  :where(.suite-navigation a, .topbar a, .top a, .header a, nav a,
    body[data-suite-page="pro"] header a) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  summary { padding-block: 10px; }
  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
  select, textarea {
    min-width: 0;
    min-height: 44px;
    font-size: 16px !important;
  }
  input[type="checkbox"], input[type="radio"] {
    width: 24px !important;
    height: 24px !important;
    min-height: 24px !important;
    min-width: 24px !important;
    flex: 0 0 24px;
  }
  label:has(> input[type="checkbox"]), label:has(> input[type="radio"]) {
    min-height: 44px;
    padding-block: 10px;
  }
  .category-chips button { flex-shrink: 0; }
  .dialog-heading { position: sticky; top: 0; z-index: 2; background: #fff; padding-block: 8px; }
}

@media (max-width: 900px) {
  .header { padding: 16px; gap: 10px; }
  .header > div:first-of-type { flex: 1 1 calc(100% - 56px); }
  .header a { margin-left: 0 !important; }
  .container { padding: 16px; }
  .suite-scroll-hint { display: block; margin: -10px 0 14px; font-size: 12px; color: #566b82; }
  body[data-suite-page="pro"] header > div,
  body[data-suite-page="pro"] header > div > div { flex-wrap: wrap; gap: 12px; min-width: 0; }
  body[data-suite-page="pro"] header h1 { font-size: 22px; flex: 1; min-width: 0; }
  body[data-suite-page="pro"] main { padding: 16px; }
  body[data-suite-page="pro"] main > .w-fit { width: 100%; flex-wrap: wrap; }
  body[data-suite-page="pro"] main > .w-fit > button { flex: 1 1 180px; }
  body[data-suite-page="pro"] .suite-return-link {
    position: static !important;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 0 !important;
  }
  .suite-column-picker[open] { width: 100%; }
  .suite-pro-filter-heading, .suite-pro-filter-heading > div,
  .suite-pro-product-toolbar, .suite-pro-product-toolbar > div,
  .suite-pro-product-toolbar > div > div {
    min-width: 0;
    flex-wrap: wrap;
    gap: 12px;
  }
  .suite-pro-product-toolbar > div > div { width: 100%; }
  .suite-pro-product-toolbar > div > div > .relative:first-child { flex-basis: 100%; }
  .suite-pro-product-toolbar input[type="text"] { width: 100%; }
  .suite-column-picker > div {
    position: static;
    width: 100%;
    max-height: 50vh;
    max-height: 50dvh;
    overflow: auto;
  }
}

@media (max-width: 600px) {
  .header a { flex: 1 1 135px; }
  .header h1 { font-size: 1.25rem; }
  .card { padding: 16px; }
  .settings, .filters, .planner-controls { grid-template-columns: minmax(0, 1fr); }
  .field input, .field select, .field textarea { width: 100%; }
  .filter-panel form > label, .import-panel form > label {
    flex: 1 1 100%;
    min-width: 0;
    width: 100%;
  }
  .filter-panel form > button, .import-panel form > button { width: 100%; }
  .table-heading, .dialog-heading, #pagination { flex-wrap: wrap; }
  .table-page-status { min-width: 0; }
  dialog { padding: 12px; }
  .catalog-cost-dialog .grid { grid-template-columns: minmax(0, 1fr); }
  .cost-editor { min-width: 180px; }
  .periods label { min-width: 0; }
  body[data-suite-page="stock"] main { padding: 12px; }
  body[data-suite-page="stock"] .grid { grid-template-columns: minmax(0, 1fr); }
  body[data-suite-page="stock"] .panel { padding: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .tab, .btn, .clickable-stat { transition: none; }
}
