/* C13 — camada responsiva final. Regras limitadas a telas móveis/tablets. */
@media (max-width: 900px) {
  :root { --mobile-v13-gap:10px; --mobile-v13-radius:14px; }
  html, body { width:100%; max-width:100%; overflow-x:hidden!important; }
  body { -webkit-text-size-adjust:100%; text-size-adjust:100%; }
  #appView, #menuHost, .main, .app.main, .page, .menu-page, .modal-body, .report-view { min-width:0!important; max-width:100%!important; }
  #menuHost *, #modalRoot * { box-sizing:border-box; min-width:0; }
  img, svg, canvas, video { max-width:100%; height:auto; }
  h1, h2, h3, h4, p, small, strong, span, td, th { overflow-wrap:break-word; word-break:normal; }

  input, select, textarea, button { font-size:max(16px, 1em); }
  button, .btn, [role="button"] { touch-action:manipulation; }
  .mobile-actions-v13,
  .actions, .top-actions, .status-actions-v166, .report-header-tools,
  .fac-actions, .materiais-actions, .consultas-actions, .modal-actions,
  .status-section-actions-v166, .fac-modal-actions, .fac-form-actions,
  .fac-hero-actions, .fac-filter-head-actions, .disp-filter-actions,
  .det-toolbar-actions, .det-filter-actions, .report-capture-actions-r91,
  .print-fallback-actions-r82 {
    display:grid!important;
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
    gap:8px!important;
    width:100%!important;
    align-items:stretch!important;
  }
  .mobile-actions-v13 > button, .mobile-actions-v13 > .btn, .mobile-actions-v13 > a,
  .actions > button, .actions > .btn, .top-actions > button, .top-actions > .btn,
  .status-actions-v166 > button, .report-header-tools > button, .report-header-tools > .btn,
  .modal-actions > button, .modal-actions > .btn, .status-section-actions-v166 > button,
  .fac-modal-actions > button, .fac-form-actions > button, .fac-filter-head-actions > button,
  .disp-filter-actions > button, .det-toolbar-actions > button, .det-filter-actions > button {
    width:100%!important;
    min-height:44px!important;
    height:auto!important;
    margin:0!important;
    padding:9px 10px!important;
    justify-content:center!important;
    text-align:center!important;
    white-space:normal!important;
    line-height:1.2!important;
  }

  .topbar { width:100%!important; max-width:100%!important; gap:10px!important; }
  .topbar-title-wrap, .topbar-title, .topbar h1, .topbar h2 { min-width:0!important; max-width:100%!important; }
  .filters, .filters-panel, .consultas-filters, .materiais-filters,
  .materiais-filters-enxutos, .filter-card, .fac-filter-grid,
  .gos-filter-grid, .status-filter-row-v166 {
    grid-template-columns:1fr!important;
    width:100%!important;
    gap:10px!important;
  }
  .filters > *, .filters-panel > *, .filter-card > *, .fac-filter-grid > * { width:100%!important; max-width:100%!important; }

  .table-shell, .table-wrap, .table-container, .materiais-table-shell,
  .disp-table-shell, .fac-table-shell, .status-table-shell-v166,
  .mat-consulta-table-wrap, .gos-table-shell, .disp-detail-table-shell {
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    overflow:auto!important;
    overscroll-behavior-inline:contain;
  }
  #tabelaDisponibilidade.matrix { max-width:none!important; }
  .disp-table-shell { border-radius:var(--mobile-v13-radius)!important; }

  #modalRoot { padding:0!important; }
  #modalRoot .modal, #modalRoot .modal.full, #modalRoot .report-modal-shell,
  #modalRoot .modal-card, #modalRoot [role="dialog"] {
    width:100vw!important;
    max-width:100vw!important;
    max-height:100dvh!important;
    margin:0!important;
    border-radius:0!important;
  }
  #modalRoot .modal-header, #modalRoot .report-modal-header {
    position:sticky!important;
    top:0!important;
    z-index:20!important;
    display:grid!important;
    grid-template-columns:1fr!important;
    gap:10px!important;
    padding:12px!important;
  }
  #modalRoot .modal-body, #modalRoot .report-view { padding:12px!important; overflow:auto!important; }
  .report-header-meta { text-align:left!important; white-space:normal!important; }
  .report-head, .report-print-head, .report-fit-head, .report-modal-header,
  .disp-report-hero-p251 { display:grid!important; grid-template-columns:1fr!important; gap:10px!important; }
  .report-section, .rel-aloc-front-card, .disp-report-summary-c3 > *,
  .report-view .card, .mobile-report-root-v13 { max-width:100%!important; }
  .rel-aloc-grid, .rel-aloc-type-row, .disp-report-summary-c3,
  .disp-report-hero-meta-p251, .status-kpis-v166 { grid-template-columns:1fr!important; }
  .report-legend-bar, .disp-report-legend { display:flex!important; flex-wrap:wrap!important; gap:7px!important; }

  /* Relatórios: no mobile toda linha é obrigatoriamente um card. */
  table.mobile-report-cards-v13,
  table.mobile-report-cards-v13 tbody,
  table.mobile-report-cards-v13 tr,
  table.mobile-report-cards-v13 td {
    display:block!important;
    width:100%!important;
    min-width:0!important;
    max-width:100%!important;
  }
  table.mobile-report-cards-v13 {
    table-layout:auto!important;
    border-collapse:separate!important;
    border-spacing:0!important;
    background:transparent!important;
  }
  table.mobile-report-cards-v13 colgroup,
  table.mobile-report-cards-v13 thead { display:none!important; }
  table.mobile-report-cards-v13 tbody { display:grid!important; gap:10px!important; }
  table.mobile-report-cards-v13 tbody > tr {
    position:relative!important;
    display:grid!important;
    grid-template-columns:1fr!important;
    gap:0!important;
    margin:0!important;
    padding:8px 11px!important;
    overflow:hidden!important;
    border:1px solid #dce8e3!important;
    border-left:5px solid #6b8d80!important;
    border-radius:var(--mobile-v13-radius)!important;
    background:#fff!important;
    box-shadow:0 5px 16px rgba(8,52,39,.08)!important;
  }
  table.mobile-report-cards-v13 tbody > tr.mobile-report-danger-v13 { border-left-color:#c63d3d!important; }
  table.mobile-report-cards-v13 tbody > tr.mobile-report-warning-v13 { border-left-color:#d69b24!important; }
  table.mobile-report-cards-v13 tbody > tr.mobile-report-info-v13 { border-left-color:#2879b8!important; }
  table.mobile-report-cards-v13 tbody > tr.mobile-report-ok-v13 { border-left-color:#26845d!important; }
  table.mobile-report-cards-v13 tbody > tr > td {
    display:grid!important;
    grid-template-columns:minmax(94px,34%) minmax(0,1fr)!important;
    gap:10px!important;
    align-items:start!important;
    padding:8px 0!important;
    border:0!important;
    border-bottom:1px solid #edf3f0!important;
    font-size:12px!important;
    line-height:1.35!important;
    text-align:left!important;
    white-space:normal!important;
  }
  table.mobile-report-cards-v13 tbody > tr > td:last-child { border-bottom:0!important; }
  table.mobile-report-cards-v13 tbody > tr > td::before {
    content:attr(data-mobile-label)!important;
    color:#60756c!important;
    font-size:10px!important;
    font-weight:900!important;
    letter-spacing:.035em!important;
    line-height:1.25!important;
    text-transform:uppercase!important;
  }
  table.mobile-report-cards-v13 td[colspan] { grid-template-columns:1fr!important; }
  table.mobile-report-cards-v13 td[colspan]::before { display:none!important; }
  table.mobile-report-cards-v13 .report-text-clamp,
  table.mobile-report-cards-v13 .compact-obs { display:block!important; max-height:none!important; overflow:visible!important; white-space:normal!important; }

  /* Listagens comuns permanecem em cards; a volta para tabela é bloqueada. */
  .mobile-card-toggle-v125 { display:none!important; }
  .mobile-card-shell-v125.mobile-table-mode-v125 table.mobile-cards-v125,
  table.mobile-cards-v125 { min-width:0!important; }
  .mobile-card-shell-v125 > .mobile-table-toolbar-v124 { display:none!important; }

  .status-tabs-v166 { display:flex!important; max-width:100%!important; overflow-x:auto!important; scroll-snap-type:x proximity; }
  .status-tabs-v166 > button { flex:0 0 auto!important; min-height:42px!important; scroll-snap-align:start; }
  .status-hero-v166, .status-content-v166, .sistema-page { max-width:100%!important; min-width:0!important; }
  .fac-subnav, .materiais-tabs, .gos-tabs { max-width:100%!important; overflow-x:auto!important; }
}

@media (max-width: 430px) {
  .mobile-actions-v13, .actions, .top-actions, .status-actions-v166,
  .report-header-tools, .fac-actions, .materiais-actions, .consultas-actions,
  .modal-actions, .status-section-actions-v166, .fac-modal-actions, .fac-form-actions,
  .fac-hero-actions, .fac-filter-head-actions, .disp-filter-actions,
  .det-toolbar-actions, .det-filter-actions, .report-capture-actions-r91,
  .print-fallback-actions-r82 {
    grid-template-columns:1fr!important;
  }
  table.mobile-report-cards-v13 tbody > tr > td {
    grid-template-columns:1fr!important;
    gap:4px!important;
  }
}

@media print {
  table.mobile-report-cards-v13 { display:table!important; }
  table.mobile-report-cards-v13 thead { display:table-header-group!important; }
  table.mobile-report-cards-v13 tbody { display:table-row-group!important; }
  table.mobile-report-cards-v13 tr { display:table-row!important; }
  table.mobile-report-cards-v13 td { display:table-cell!important; }
  table.mobile-report-cards-v13 td::before { display:none!important; }
}
