/* Alinhamento global: topo e rodapé começam na mesma régua do conteúdo. */
@media (min-width:1181px){
  .topbar{padding-inline:28px}
  footer{margin-inline:28px}
}
@media (min-width:851px) and (max-width:1180px){
  .topbar{padding-inline:22px}
  footer{margin-inline:22px}
}

/* Mobile do SETAI: só entra abaixo de 850px; desktop permanece intacto. */
@media (max-width:850px){
  body{overflow-x:hidden}
  .sidebar.open{width:min(320px,86vw);padding:22px 16px;box-shadow:0 0 0 100vmax rgba(12,28,30,.58)}
  .sidebar.open .nav-item{min-height:44px}
  .topbar{position:sticky;top:0;z-index:25;background:var(--paper);border-bottom:1px solid var(--line)}
  .topbar .breadcrumb{min-width:0;flex:1}
  .topbar .breadcrumb strong{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  .top-actions{flex-shrink:0}
  .top-actions .button.small{min-height:36px;padding:0 10px}
  main{min-width:0}
  .page-heading{width:100%;min-width:0}
  .page-heading>div{min-width:0}
  .page-heading h1{overflow-wrap:anywhere}
  .toolbar{width:100%;min-width:0}
  .toolbar input,.toolbar select{min-height:44px}
  .toolbar .search{min-width:0}
  .work-group,.work-heading,.work-summary,.task-table,.task-table tbody{max-width:100%;min-width:0}
  .work-name,.task-open,.task-title{overflow-wrap:anywhere}
  .task-table tr{min-width:0}
  .task-table td{min-width:0}
  .task-table .badge,.task-table .owner,.task-table .date{overflow-wrap:anywhere}
  .detail-dialog{width:100vw;max-width:100vw}
  .detail-dialog .detail-head,.detail-dialog .detail-body{padding-inline:18px}
  .detail-dialog .detail-top-actions{flex-wrap:wrap}
  .detail-dialog .detail-top-actions .button{min-height:40px}
  .form-dialog{max-width:calc(100vw - 24px)}
}
@media (max-width:600px){
  .topbar{height:58px;padding-inline:12px}
  .topbar .slash,.topbar .breadcrumb>span:not(.slash):not(.mobile-menu){display:none}
  .top-actions .visual-toggle,.top-actions #help-toggle{display:none}
  .top-actions .icon-button{width:38px;height:38px}
  .top-actions .button.small{font-size:10px}
  .sync-status{max-width:110px;padding-inline:6px;font-size:9px}
  main,.obras-page{padding-inline:12px}
  .page-heading{margin-bottom:16px}
  .page-heading h1{font-size:24px}
  .page-heading>.button{width:100%;margin-top:4px}
  .stats{gap:8px}
  .stat{padding:12px 10px}
  .stat-label{line-height:1.35}
  .obras-page .toolbar{gap:8px;margin-bottom:12px}
  .obras-page .toolbar select{min-height:44px}
  .obras-page .work-group,.obras-page .work-heading{display:block}
  .obras-page .work-heading{max-width:100%}
  .obras-page .work-summary{display:block}
  .obras-page .work-summary .summary-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px 12px}
  .obras-page .summary-metric{min-width:0}
  .obras-page .summary-label,.obras-page .summary-metric strong{display:block;overflow-wrap:anywhere}
  .obras-page .work-summary{padding:0 10px 11px!important}
  .obras-page .task-table tr{padding:13px 10px}
  .obras-page .task-table td:first-child{font-size:12px}
  .obras-page .task-table tr{grid-template-columns:minmax(0,1fr) minmax(0,1fr);row-gap:10px;align-items:start}
  .obras-page .task-table td{grid-column:auto!important;grid-row:auto!important;display:block;text-align:left!important;min-width:0;overflow:visible}
  .obras-page .task-table td:nth-child(1){grid-column:1/-1!important;grid-row:1!important}
  .obras-page .task-table td:nth-child(2){grid-column:1!important;grid-row:2!important}
  .obras-page .task-table td:nth-child(3){grid-column:2!important;grid-row:2!important}
  .obras-page .task-table td:nth-child(4){grid-column:1!important;grid-row:3!important}
  .obras-page .task-table td:nth-child(5){grid-column:2!important;grid-row:3!important}
  .obras-page .task-table td:nth-child(6){grid-column:1!important;grid-row:4!important}
  .obras-page .task-table td:nth-child(7){grid-column:2!important;grid-row:4!important}
  .obras-page .task-table td:nth-child(8){grid-column:1!important;grid-row:5!important}
  .obras-page .task-table td:nth-child(9){grid-column:2!important;grid-row:5!important}
  .obras-page .task-table td:nth-child(6)::before{content:'Solicitada em';display:block;color:#737983;font-size:10px;margin-bottom:4px}
  .obras-page .task-table td:nth-child(7)::before{content:'Próximo lembrete';display:block;color:#737983;font-size:10px;margin-bottom:4px}
  .obras-page .task-table td:nth-child(8)::before{content:'Prazo de entrega';display:block;color:#737983;font-size:10px;margin-bottom:4px}
  .obras-page .task-table td:nth-child(9)::before{content:'Data de entrega';display:block;color:#737983;font-size:10px;margin-bottom:4px}
  .obras-page .task-table .type-cell-trigger,.obras-page .task-table .status-cell-trigger{display:inline-flex;max-width:100%;align-items:center}
  .obras-page .task-table .service-type,.obras-page .task-table .status-label,.obras-page .task-table .priority-label{max-width:100%;white-space:normal;overflow-wrap:anywhere}
  footer{margin-inline:12px;padding-bottom:18px}
  .detail-dialog .detail-tabs{padding-inline:18px}
  .detail-dialog .info-grid{grid-template-columns:1fr;gap:15px}
  .detail-actions .button{min-height:44px}
  .notifications-panel{right:-8px;max-width:calc(100vw - 24px)}
}
@media (max-width:600px){
  .topbar{background:#fff;border-bottom:1px solid #e4e6eb;box-shadow:0 1px 3px #1f29370d}
  main,.shell{background:#f4f5f7}
  .obras-page{padding-top:14px}
  .obras-page .page-heading h1{color:#20242b;font-size:22px;letter-spacing:-.2px}
  .obras-page .page-heading p{color:#737983}
  .obras-page .stats{background:#fff;border:1px solid #e4e6eb;border-radius:10px;padding:12px;margin-bottom:12px}
  .obras-page .stat{background:transparent;border-color:#e4e6eb}
  .obras-page .stat-number{color:#20242b}
  .obras-page .toolbar{padding:0;margin-bottom:12px}
  .obras-page .toolbar input,.obras-page .toolbar select{background:#fff;border-color:#dfe3e8;color:#343942;border-radius:8px}
  .obras-page .work-group{background:#fff;border:1px solid #e4e6eb!important;border-left:4px solid #13aeea!important;border-radius:10px!important;box-shadow:0 2px 8px #1f29370d;overflow:hidden}
  .obras-page .work-heading,.obras-page .work-identity,.obras-page .work-summary{background:#fff}
  .obras-page .work-identity{padding:14px 12px 10px}
  .obras-page .work-name{font-size:16px;color:#20242b}
  .obras-page .work-summary{padding:0 12px 12px!important}
  .obras-page .summary-label{color:#727982;font-size:10px;text-transform:uppercase;letter-spacing:.7px}
  .obras-page .summary-metric strong{color:#20242b;font-size:16px;margin-top:5px}
  .obras-page .table-wrap{background:#fff}
  .obras-page .task-table tr{background:#fff;border-top:1px solid #e6e8ec;padding:14px 12px}
  .obras-page .task-open{color:#20242b;font-size:14px;line-height:1.35}
  .obras-page .task-id{color:#7b818a;margin-top:4px}
  .obras-page .badge{border-radius:6px;padding:7px 9px;font-size:10px}
  .obras-page .owner,.obras-page .date{color:#343942}
  .obras-page footer{background:#f4f5f7}

  /* Cartão mobile: cada bloco tem sua própria área; nada divide a linha do título. */
  .obras-page .task-table tr{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);column-gap:18px;row-gap:0;align-items:start;overflow:hidden}
  .obras-page .task-table td:first-child{grid-column:1/-1!important;grid-row:1!important;display:grid!important;grid-template-columns:minmax(0,1fr);grid-auto-rows:max-content;align-content:start;align-self:start;height:auto!important;min-height:0;padding:0 0 12px!important;border-bottom:1px solid #e6e8ec}
  .obras-page .task-title-line{grid-row:auto}
  .obras-page .row-labels{grid-row:auto}
  .obras-page .subtask-toggle{grid-row:auto;margin-top:0}
  .obras-page .task-title-line{display:flex;align-items:flex-start;width:100%;min-width:0;gap:8px}
  .obras-page .task-title-line .demand-drag-handle{flex:0 0 20px;margin-top:2px}
  .obras-page .task-title-line .demand-select{flex:0 0 20px;width:20px;height:20px;margin:1px 0 0}
  .obras-page .task-title-line .task-open{display:block;flex:1 1 auto;width:auto;min-width:0;padding:0;text-align:left;white-space:normal;overflow-wrap:anywhere;line-height:1.35}
  .obras-page .task-title-line .task-id{display:block;margin-top:4px}
  .obras-page .task-title-line .task-chat{flex:0 0 40px;min-width:40px;height:36px;min-height:36px;margin-top:-3px}
  .obras-page .task-title-line .task-delete{flex:0 0 32px;min-width:32px;height:36px;margin-top:-3px}
  .obras-page .row-labels{display:flex;flex-wrap:wrap;align-items:flex-start;gap:6px;margin-top:10px;min-width:0}
  .obras-page .row-labels>*{min-width:0;max-width:100%;white-space:normal;overflow-wrap:anywhere}
  .obras-page .task-table td:nth-child(2),.obras-page .task-table td:nth-child(3),.obras-page .task-table td:nth-child(4),.obras-page .task-table td:nth-child(5){padding-top:12px!important;padding-bottom:12px!important;border-bottom:1px solid #e6e8ec}
  .obras-page .task-table td:nth-child(2) .type-cell-trigger,.obras-page .task-table td:nth-child(4) .status-cell-trigger{width:100%;max-width:100%;text-align:left}
  .obras-page .task-table td:nth-child(3){overflow-wrap:anywhere}
  .obras-page .task-table td:nth-child(6),.obras-page .task-table td:nth-child(7),.obras-page .task-table td:nth-child(8),.obras-page .task-table td:nth-child(9){padding-top:12px!important;padding-bottom:12px!important;border-bottom:1px solid #e6e8ec}
  .obras-page .task-table td:nth-child(n+6) .date{display:block;overflow-wrap:anywhere;line-height:1.35}
}

@media (max-width:600px){
  /* Revisão geral: nenhum componente móvel pode criar uma segunda largura de página. */
  html,body{max-width:100%;overflow-x:hidden}
  .shell,main,#main,.obras-page,.page-heading,.toolbar,.topbar,.top-actions{min-width:0;max-width:100%}
  .topbar{box-sizing:border-box}
  .top-actions{min-width:0;gap:5px}
  .top-actions>*{min-width:0}
  .top-actions .button.small{flex:0 0 auto;min-width:38px;padding-inline:7px}
  .topbar .breadcrumb{min-width:0;max-width:100%}
  .topbar .breadcrumb strong{min-width:0;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  main button,main input,main select,main textarea{max-width:100%}
  img,svg,video,canvas{max-width:100%}
  .detail-dialog,.form-dialog,#work-popover,#type-popover,#status-popover,#priority-popover,.notifications-panel{box-sizing:border-box;max-width:calc(100vw - 16px)}
  .detail-dialog{overflow-x:hidden}
  .detail-dialog .detail-tabs{max-width:100%;overflow-x:auto;overscroll-behavior-x:contain}
  .detail-dialog .detail-body,.detail-dialog .detail-head,.detail-dialog .detail-section,.detail-dialog .comment,.detail-dialog .comment-content,.detail-dialog .sub-card{min-width:0;max-width:100%}
  .detail-dialog .comment-content,.detail-dialog .description,.detail-dialog .field-label,.detail-dialog .value{overflow-wrap:anywhere}
  .activity-label,.activity-label.dependency-badge{max-width:100%;white-space:normal;overflow-wrap:anywhere;line-height:1.3}
  .label-options,.status-catalog-grid,.priority-label-dialog .status-catalog-grid{min-width:0}
}

@media (max-width:750px){
  /* Revisão geral de usabilidade: ações e formulários cabem na largura útil. */
  #main:not(.obras-page) .page-heading{width:100%;gap:12px}
  #main:not(.obras-page) .page-heading h1{max-width:100%;overflow-wrap:anywhere}
  #main:not(.obras-page) .page-heading>.button,.page-create-actions{width:100%;max-width:100%}
  #main:not(.obras-page) .toolbar{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
  #main:not(.obras-page) .toolbar>*{width:100%;min-width:0;max-width:100%}
  #main:not(.obras-page) .toolbar .search,#main:not(.obras-page) .toolbar .searchable-filter{grid-column:1/-1;width:100%}
  #main:not(.obras-page) .tw{max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}
  #main:not(.obras-page) .tw table{min-width:680px}
  .form-dialog,.discard-dialog{max-width:calc(100vw - 24px);max-height:calc(100dvh - 24px);overflow:auto}
  .form-dialog .detail-head,.form-dialog .detail-body,.discard-dialog{padding-inline:18px}
  .form-dialog .edit-grid,.form-dialog .form-grid,.form-dialog .activity-edit-form{grid-template-columns:minmax(0,1fr)!important}
  .form-dialog .edit-wide{grid-column:auto!important}
  .form-dialog .edit-buttons,.form-dialog .discard-buttons{display:flex;flex-direction:column;gap:8px}
  .form-dialog .edit-buttons .button,.form-dialog .discard-buttons .button{width:100%;min-height:44px}
  .detail-dialog.is-obras .detail-body{display:flex;flex-direction:column;min-width:0}
  .detail-dialog.is-obras .detail-panel,.detail-dialog.is-obras .detail-side{width:100%;max-width:100%;min-width:0}
  .detail-dialog.is-obras .detail-side{order:-1;position:static;max-height:none;margin:0 0 14px;padding:16px;border-radius:12px}
  .detail-dialog.is-obras .detail-head h2{max-width:100%;overflow-wrap:anywhere}
  .detail-dialog.is-obras .detail-top-actions{width:100%;justify-content:stretch}
  .detail-dialog.is-obras .detail-top-actions .button{flex:1 1 140px;min-height:44px}
  .detail-dialog.is-obras .detail-tabs{max-width:100%;overflow-x:auto;white-space:nowrap;-webkit-overflow-scrolling:touch}
  #main[data-surface=usuarios] .users-search,#main[data-surface=usuarios] .users-search input{width:100%;max-width:100%}
  .work-situation .ws-institution{align-items:flex-start;flex-direction:column;gap:12px}
  .work-situation .ws-institution>span{border-left:0;border-top:1px solid var(--line);padding:10px 0 0;width:100%}
  .work-situation .ws-filters{grid-template-columns:minmax(0,1fr)!important;align-items:stretch}
  .work-situation .ws-filters>*{width:100%;max-width:100%}
  .work-situation .ws-filters>.button{justify-self:stretch}
  .work-situation .ws-update-heading{grid-template-columns:minmax(0,1fr)!important;padding:18px}
  .work-situation .ws-update-heading>.ws-progress{grid-column:auto;max-width:none}
  .work-situation .ws-detail-dialog{width:calc(100vw - 16px);max-width:calc(100vw - 16px)}
}

@media (max-width:420px){
  .topbar .breadcrumb strong{font-size:14px}
  #main:not(.obras-page) .toolbar{grid-template-columns:minmax(0,1fr)}
  .detail-dialog.is-obras .detail-top-actions .button{flex-basis:100%}
  .detail-dialog.is-obras .detail-side{padding:12px}
  .work-situation .ws-tabs{gap:18px;overflow-x:auto;white-space:nowrap}
}

@media (max-width:380px){
  .topbar{padding-inline:8px}
  .top-actions{gap:3px}
  .top-actions .icon-button,.top-actions .button.small,.top-avatar{min-width:32px;width:32px;height:32px}
  .top-actions .button.small{font-size:0;padding:0}
  .top-actions .button.small::after{content:'↪';font-size:16px}
  .sync-status{max-width:80px}
  .obras-page{padding-inline:10px}
  .obras-page .task-table tr{column-gap:12px;padding-inline:10px}
}