/* Screen-only corrections: preserve domain logic, palette and printed reports. */
@media screen {
  /* Frozen and scrolling cells must share the native, content-sized row box. */
  #content :is(#condition-table,#license-table,.ibama-frozen-table,#enterprise-table) table > tbody > tr {
    display:table-row;
    height:auto;
  }
  #content :is(#condition-table,#license-table,.ibama-frozen-table,#enterprise-table) table > :is(thead,tbody) > tr > :is(th,td) {
    display:table-cell;
    box-sizing:border-box;
    height:auto;
    transform:none;
  }
  #content :is(#condition-table,#license-table,.ibama-frozen-table,#enterprise-table) table > tbody > tr > td:nth-child(-n+2) {
    top:auto;
    bottom:auto;
    vertical-align:middle;
  }
  /* One paint owner per row: sticky and scrolling cells cannot round the
     separator independently. Keep the original border pixel in layout. */
  #content :is(#condition-table,#license-table,.ibama-frozen-table,#enterprise-table) table > tbody > tr > td {
    border-top:1px solid transparent;
    padding-top:14px;
    box-shadow:none;
  }
  /* No vertical dividers in Conditions, including frozen cells and the
     floating header. Preserve native geometry and horizontal separators. */
  #content #condition-table table > :is(thead,tbody) > tr > :is(th,td):not(:last-child),
  body > .condition-table.license-floating-header th:not(:last-child) {
    box-shadow:none!important;
    background-image:none!important;
  }
  #content :is(#condition-table,#license-table,.ibama-frozen-table,#enterprise-table) { position:relative; }
  #content :is(#condition-table,#license-table,.ibama-frozen-table,#enterprise-table) > .condition-row-separators {
    position:absolute;
    top:0;
    left:0;
    height:0;
    z-index:3;
    pointer-events:none;
  }
  #content :is(#condition-table,#license-table,.ibama-frozen-table,#enterprise-table) > .condition-row-separators > i {
    position:absolute;
    left:0;
    width:100%;
    height:1px;
    background:var(--line);
    pointer-events:none;
  }
  /* Keep condition actions together without changing other tables or reports. */
  #content #condition-table .row-actions {
    display:flex!important;
    flex-direction:row;
    flex-wrap:nowrap!important;
    align-items:center;
    gap:6px;
    min-width:max-content;
    max-width:none;
  }
  #content #condition-table .row-actions > button {
    flex:0 0 auto;
    width:auto;
    max-width:none;
    white-space:nowrap;
  }
}
@media screen {
  html { -webkit-text-size-adjust:100%; text-size-adjust:100%; }
  #content :is(section,article,fieldset,form,dl,figure) { min-width:0; }
  #content :is(.form-grid,.toolbar,.filter-panel,.control-head,.modal-head,.section-title)>*,
  dialog :is(.form-grid,.modal-head,.modal-actions)>* { min-width:0; }
  #content :is(h1,h2,h3,h4,label,button),dialog :is(h1,h2,h3,h4,label,button) {
    word-break:normal;overflow-wrap:break-word;hyphens:none;
  }
  #content :is(.badge,.alert-chip,.training-status,.control-status,.condition-status,.art-status,.inema-status,.sst-status,.rtga-status,.finance-status,.notification-status,.user-status,.legal-status,.license-state,.dtrp-seia-badge,.renewal-status,.renewal-mini,.note-badge,.note-priority,.condition-priority),
  dialog :is(.badge,.alert-chip,.dtrp-seia-badge,.note-badge,.renewal-status) {
    max-width:100%;white-space:normal;word-break:normal;overflow-wrap:normal;hyphens:none;line-height:1.4;
  }
  #content table td.align-status { min-width:150px; }
  #content .training-table :is(th,td):nth-child(2) { min-width:130px; }
  #content .training-table .training-status { white-space:nowrap;max-width:none; }
  #content :is(.table-card,.archived-license-list) { min-width:0;max-width:100%;overflow-x:auto;overscroll-behavior-inline:contain; }
  #content :is(.row-actions,.table-actions) { flex-wrap:wrap;gap:6px; }
  #content :is(.toolbar,.control-head,.section-title,.filter-heading,.condition-detail-head,.dtrp-unit-head,.dtrp-head-actions,.agenda-pdf-actions,.notes-filter-actions) { flex-wrap:wrap; }
  #content :is(.toolbar,.filter-panel,.form-grid) :is(input,select,textarea),
  dialog :is(input,select,textarea) { min-width:0;max-width:100%; }
  #content :is(.toolbar,.filter-panel) select { max-width:100%; }
  #content :is(.primary,.secondary,.mini),dialog :is(.primary,.secondary,.mini) { white-space:normal;max-width:100%; }
  #content :is(.report-sheet,.preventive-report,.rtga-document) { max-width:100%;overflow-x:auto; }
  #content :is(.report-sheet,.preventive-report) table { min-width:850px; }
  .detail-drawer { height:100dvh;max-height:100dvh; }
  .detail-drawer :is(.drawer-body,.drawer-content) { min-height:0;overflow:auto; }
  .detail-drawer :is(.drawer-head,.drawer-status,.training-drawer-status)>* { min-width:0;overflow-wrap:break-word; }
  .detail-drawer :is(.drawer-head,.training-drawer-head) .icon { flex-shrink:0; }
  dialog .modal-head { gap:12px;align-items:flex-start; }
  dialog .modal-head .icon { flex-shrink:0; }
  dialog :is(fieldset,.form-grid label) { min-width:0; }
  dialog :is(label,p,small,output) { overflow-wrap:break-word; }
  dialog.notes-panel textarea.notes-description-text,dialog.notes-panel #notes-description-plain { resize:none; }
  .app aside .nav { min-width:0; }
  .app aside .nav b { flex-shrink:0; }
  .app aside .nav span { min-width:0;word-break:normal;overflow-wrap:normal; }
  #content .finance-bars span { white-space:normal;overflow:visible;text-overflow:clip;overflow-wrap:break-word; }
}
@media screen and (min-width:768px) and (max-width:1199px) {
  #content :is(.notification-filters,.sst-filters,.finance-manager-filters,.finance-list-tools,.portal-filters,.notes-filters,.rtga-filters,.action-filters) {
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
  #content :is(.notification-import,.ibama-reader,.ibama-recognized,.pdf-analysis-summary,.condition-detail-head) { grid-template-columns:minmax(0,1fr); }
  #content :is(.notification-cards,.action-primary-kpis,.control-summary,.training-summary) { grid-template-columns:repeat(2,minmax(0,1fr)); }
  #content .action-row { grid-template-columns:105px minmax(0,1.35fr) minmax(0,.8fr) minmax(0,1fr); }
}
@media screen and (max-width:767px) {
  #content :is(.notification-filters,.notification-import,.notification-form-grid,.sst-filters,.finance-manager-filters,.finance-list-tools,.portal-filters,.notes-filters,.rtga-filters,.action-filters,.condition-detail-head,.ibama-reader,.ibama-recognized,.pdf-analysis-summary,.finance-upload form) { grid-template-columns:minmax(0,1fr); }
  #content :is(.notification-cards,.notification-detail-summary,.notification-report-summary,.control-summary,.training-summary,.notes-kpis) { grid-template-columns:repeat(2,minmax(0,1fr)); }
  #content :is(.filter-panel,.form-grid,.notification-filters,.sst-filters,.finance-manager-filters) :is(input,select,textarea,button) { width:100%; }
  #content :is(input:not([type=checkbox]):not([type=radio]),select,textarea),dialog :is(input:not([type=checkbox]):not([type=radio]),select,textarea) { font-size:16px; }
  #content :is(.primary,.secondary,.mini,.notes-quick button,.notes-filter-actions button),dialog :is(.primary,.secondary,.icon,.notes-detail-nav button) { min-height:44px; }
  #content :is(.control-head,.section-title,.filter-heading,.dtrp-unit-head,.dtrp-head-actions) { gap:12px; }
  #content .toolbar :is(input,select) { min-width:0;width:100%; }
  #content .action-row { grid-template-columns:minmax(0,1fr); }
  #content .calendar-event { grid-template-columns:18px minmax(0,1fr)!important; }
  #content .calendar-event :is(time,.badge),#content .calendar-event>div:nth-of-type(2) { grid-column:2!important;grid-row:auto!important; }
  dialog .modal-head :is(h3,.eyebrow) { white-space:normal;overflow:visible;text-overflow:clip; }
  dialog.notes-panel .notes-detail-nav { flex-wrap:wrap; }
  .detail-drawer :is(.drawer-history article,.drawer-status,.training-drawer-status) { grid-template-columns:minmax(0,1fr); }
  .detail-drawer :is(.drawer-action,.drawer-data) { grid-template-columns:minmax(0,1fr); }
  .detail-drawer :is(.drawer-head,.drawer-footer) { padding-bottom:max(14px,env(safe-area-inset-bottom)); }
}
@media screen and (max-width:359px) {
  #content :is(.notification-cards,.notification-detail-summary,.notification-report-summary,.control-summary,.training-summary,.notes-kpis) { grid-template-columns:minmax(0,1fr); }
}
@media screen and (orientation:landscape) and (max-height:600px) {
  dialog { max-height:calc(100dvh - 16px); }
  .detail-drawer { height:100dvh; }
}

/* All module headers, including mirrored frozen headers. Geometry unchanged. */
@media screen {
  #content table th, .license-floating-header th, dialog table th {
    text-transform:uppercase!important;
    text-align:center!important;
  }
}

/* Companies directory: align all labels with their cells; freeze only the header. */
@media screen {
  html body #content #enterprise-table table :is(th,td),
  html body .enterprise-table.license-floating-header th {
    text-align:center!important;
    vertical-align:middle!important;
  }
  #content #enterprise-table .row-actions {justify-content:center}
}

/* Shared screen alignment for module tables; exported report layouts are separate. */
@media screen {
  html body #content table:not(:is(.report-sheet *, .preventive-report *, .rtga-document *, .action-report *)) > :is(thead,tbody,tfoot) > tr > :is(th,td) {
    display:table-cell;
    box-sizing:border-box;
    height:auto;
    transform:none;
    text-align:center!important;
    text-align-last:auto;
    vertical-align:middle!important;
  }
  #content table:not(:is(.report-sheet *, .preventive-report *, .rtga-document *, .action-report *)) > :is(thead,tbody,tfoot) > tr {
    display:table-row;
    height:auto;
  }
  #content table:not(:is(.report-sheet *, .preventive-report *, .rtga-document *, .action-report *)) :is(.row-actions,.table-actions) {justify-content:center}
}

/* Unit names only: headers and every other column retain their current alignment. */
@media screen {
  html body #content table:not(:is(.report-sheet *, .preventive-report *, .rtga-document *, .action-report *)) > tbody > tr > td[data-unit-name-column="true"],
  html body #content #enterprise-table td[data-unit-name-column="true"] {
    text-align:justify!important;
    text-align-last:left;
    text-justify:inter-word;
  }
}

/* Condition descriptions always override the general centered table presentation. */
html body #content #condition-table td.condition-description,
html body #content .report-condition-full,
html body .client-management-report .report-condition-full,
html body #condition-form textarea[name="description"],
html body .condition-text textarea {
  text-align:justify!important;
  text-align-last:left!important;
  text-justify:inter-word;
}

/* IBAMA and INEMA/SEIA landing actions only: separate phone touch targets. */
@media screen and (max-width:600px){
 #content .control-head>div:has(>:is(#ibama-calendar,#inema-calendar)){display:grid;grid-template-columns:minmax(0,1fr);gap:12px;width:100%}
 #content .control-head>div:has(>:is(#ibama-calendar,#inema-calendar))>button{width:100%;margin:0}
}
