/* Mobile sizing: constrain controls themselves, not by clipping their content. */
@media (max-width: 860px) {
  .form-group, .form-grid, .form-grid > *, .pg-filtros-grid > *,
  .modal-body, .page-header > *, .escala-grid > * {
    min-width: 0;
    max-width: 100%;
  }
  input.form-input, select.form-input, textarea.form-input {
    box-sizing: border-box;
    min-width: 0;
    max-width: 100%;
    font-size: 0.84rem;
  }
  select.form-input {
    display: flex;
    align-items: center;
    line-height: 1;
  }
  /* iOS date controls have an intrinsic width independent of their grid track. */
  input[type="date"], input[type="month"], input[type="time"], input[type="datetime-local"] {
    -webkit-appearance: none;
    appearance: none;
    display: block;
    box-sizing: border-box !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    min-inline-size: 0 !important;
    line-height: normal;
    padding-top: 0;
    padding-bottom: 0;
  }
  input::-webkit-date-and-time-value { min-width: 0; text-align: left; line-height: var(--control-h, 40px); }
  input::-webkit-datetime-edit {
    min-width: 0;
    padding: 0;
    display: inline-flex;
    align-items: center;
    height: 100%;
  }
  .form-grid-2, .form-grid-3, .escala-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .modal { min-width: 0; max-width: 100%; }
  .modal-title, .page-title, .form-label { overflow-wrap: anywhere; }
  .modal-close { flex-shrink: 0; }
  /* Wide tables keep their own scroll; they must not be cut off by overflow:clip. */
  .table-wrap { overflow-x: auto; max-width: 100%; }
  .table-wrap table:has(.empty-state) { min-width: 0; width: 100%; table-layout: fixed; }
  .table-wrap table:has(.empty-state) thead { display: none; }
  .table-wrap .empty-state { white-space: normal; overflow-wrap: anywhere; padding: 24px 12px; }
  .pg-filtros-btns .btn { min-width: 0; white-space: normal; height: auto; min-height: 40px; }
}
@media (max-width: 380px) {
  .topbar-logo { flex-shrink: 1; min-width: 0; }
  .topbar-brand { overflow: hidden; text-overflow: ellipsis; }
}
