/* Stable shared layout primitives. Module-specific scrolling stays inside each module. */
html,body{width:100%;max-width:100%;margin:0;overflow-x:hidden}
body{min-width:0}
main{margin-left:246px;width:auto;max-width:none;min-width:0}
.page,.pmo-view,.module-view,.system-admin-view,.kanban-view{width:100%;max-width:none;min-width:0}
.page{margin:0;padding:30px 34px 50px}
.topbar,.top-actions,.crumb,.panel,.module-panel,.system-admin-content{min-width:0}
.crumb{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.module-panel{overflow:visible}

/* Records: preserve readable columns and confine horizontal scrolling to the table. */
.records{min-width:0;max-width:100%}
.records-table{width:100%;min-width:0!important;max-width:100%;overflow-x:auto;overflow-y:visible;overscroll-behavior-inline:contain}
.record-unified-head,.record-unified-row{min-width:1120px}
.record-unified-row>span,.record-unified-row>strong{min-width:0;word-break:normal;overflow-wrap:break-word;white-space:normal}
.record-unified-row>span:nth-child(3)>strong{display:block;word-break:normal;overflow-wrap:break-word}
.record-detail-panel .rd-facts span,.record-detail-panel .rd-repository code{word-break:normal!important;overflow-wrap:break-word!important}
.record-unified-row>button{position:sticky;right:0;z-index:2;background:#fff}
.record-unified-head>span:last-child{position:sticky;right:0;z-index:3;background:inherit}
.record-tabs{max-width:100%;overflow-x:auto;scrollbar-width:thin}

/* Kanban: columns never shrink; only the board scrolls horizontally. */
.kanban-view{padding:32px 34px}
.kanban-board-scroll,.kanban-timeline{width:100%;max-width:100%;min-width:0;overflow-x:auto;overflow-y:visible;overscroll-behavior-inline:contain}
.kanban-board{display:flex!important;width:max-content;min-width:100%;gap:12px;align-items:flex-start}
.kanban-column{flex:0 0 320px;width:320px;min-width:320px;max-width:320px}
.kanban-card{width:100%;min-width:0}
.kanban-card h3{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;word-break:normal}
.kanban-card h3:hover{white-space:normal;overflow-wrap:break-word}
.kanban-card-meta>*{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.kanban-swimlane{min-width:max-content}
.kanban-swimlane>h2{max-width:calc(100vw - 80px);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.kanban-filters,.record-filter-grid{min-width:0}
.kanban-filters input,.kanban-filters select,.record-filter-grid select{width:100%;min-width:0;max-width:100%}

/* Agenda and administration use the same content width and internal scrolling. */
#calendarCanvas{width:100%;max-width:100%;min-width:0;overflow-x:auto;overscroll-behavior-inline:contain}
.calendar-controls,.calendar-filterbar{max-width:100%;flex-wrap:wrap}
.calendar-filterbar select{min-width:0;max-width:100%;flex:1 1 150px}
.calendar-weekdays,.calendar-grid{min-width:760px}
.system-admin-layout,.project-admin-grid{min-width:0}
.email-admin-page input,.email-admin-page select,.email-admin-page textarea,.agenda-event-modal input,.agenda-event-modal select,.agenda-event-modal textarea{width:100%;max-width:100%;min-width:0;box-sizing:border-box}
.email-admin-page .form-row{grid-template-columns:repeat(2,minmax(0,1fr))}
.email-admin-page .modal-actions{position:sticky;bottom:0;padding:12px 0;background:#fff;border-top:1px solid #e4e9e7}
.project-admin-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;padding:18px}
.project-admin-grid article{min-width:0;padding:20px}
.project-admin-grid h2{color:#142d6b}
.project-admin-grid p{color:#687898;overflow-wrap:break-word}

/* Dialogs keep headers/actions visible while their body scrolls. */
.modal,.adaptive-modal,.meeting-modal,.agenda-event-modal,.agenda-type-modal{width:min(94vw,940px);max-width:94vw;max-height:90vh;overflow:hidden;display:flex;flex-direction:column}
.modal>form,.modal-scroll-body,.agenda-event-modal>form{min-height:0;overflow-y:auto}
.modal-head,.modal-actions{flex:0 0 auto}
.modal-actions{position:sticky;bottom:0;z-index:2;background:#fff;padding-block:10px}
button:disabled{cursor:wait;opacity:.65}

@media(max-width:1439px){
  .record-unified-head,.record-unified-row{grid-template-columns:110px 120px minmax(260px,1.7fr) minmax(150px,1fr) 105px 110px 100px 110px 58px!important;min-width:1020px}
  .record-unified-head>*:nth-child(4),.record-unified-row>*:nth-child(4),.record-unified-head>*:nth-child(6),.record-unified-row>*:nth-child(6),.record-unified-head>*:nth-child(10),.record-unified-row>*:nth-child(10){display:none}
  .kanban-metrics{grid-template-columns:repeat(4,minmax(0,1fr))}
  .kanban-filters{grid-template-columns:repeat(4,minmax(0,1fr))}
}

@media(max-width:1100px){
  main{margin-left:0;width:100%;max-width:100%}
  .sidebar{transform:translateX(-100%);transition:.25s}
  .sidebar.open{transform:none;box-shadow:10px 0 30px #081e4055}
  .menu-btn{display:block}
  .page,.kanban-view{padding:24px 18px}
  .system-admin-layout{grid-template-columns:1fr}
  .system-admin-menu{display:flex;flex-direction:row;overflow-x:auto}
  .system-admin-menu button{flex:0 0 auto}
  .kanban-filters,.record-filter-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .record-detail-drawer,.kanban-card-drawer,.meeting-drawer{width:min(520px,100vw)}
}

@media(max-width:767px){
  .page,.kanban-view{padding:18px 12px}
  .topbar{padding-inline:12px}
  .top-actions{gap:6px}
  .module-heading,.page-heading,.kanban-head{display:block}
  .kanban-view-switch{margin-top:12px;max-width:100%;overflow-x:auto}
  .module-stats,.kanban-metrics{grid-template-columns:repeat(2,minmax(0,1fr))}
  .record-filter-grid,.kanban-filters,.email-admin-page .form-row,.form-row,.project-admin-grid{grid-template-columns:1fr}
  .records-table{overflow:visible}
  .record-unified-head{display:none}
  .record-unified-row{min-width:0!important;display:grid!important;grid-template-columns:1fr!important;gap:8px;margin:10px;border:1px solid #dce4ef;border-radius:10px;padding:12px;background:#fff}
  .record-unified-row>*{display:block!important;position:static!important;min-width:0;max-width:100%}
  .record-unified-row>*:nth-child(4),.record-unified-row>*:nth-child(6),.record-unified-row>*:nth-child(9),.record-unified-row>*:nth-child(10){display:none!important}
  .record-unified-row>*:nth-child(2):before{content:'Código · ';color:#71809b;font-weight:500}
  .record-unified-row>*:nth-child(5):before{content:'Responsável · ';color:#71809b}
  .record-unified-row>*:nth-child(7):before{content:'Prazo · ';color:#71809b}
  .record-unified-row>button{width:100%;min-height:36px;border:1px solid #d7e0ec;border-radius:7px}
  .kanban-column{flex-basis:300px;width:300px;min-width:300px;max-width:300px}
  .calendar-weekdays,.calendar-grid{min-width:680px}
  .calendar-controls>div,.calendar-views{max-width:100%;overflow-x:auto}
  .record-detail-drawer,.kanban-card-drawer,.meeting-drawer{inset:0;width:100vw!important;height:100dvh;padding:18px;border-radius:0}
  .system-admin-menu{display:grid;grid-template-columns:1fr 1fr}
  .email-admin-page{padding-inline:12px}
  .email-admin-page .modal-actions{flex-direction:column}
  .email-admin-page .modal-actions button{width:100%}
  .modal-wrap{padding:6px}
  .modal,.adaptive-modal,.meeting-modal,.agenda-event-modal,.agenda-type-modal{width:calc(100vw - 12px)!important;max-width:calc(100vw - 12px)!important;max-height:calc(100dvh - 12px);border-radius:9px}
  .agenda-event-modal .form-grid{grid-template-columns:1fr}
  .agenda-event-modal .span-2{grid-column:auto}
}

@media(max-width:420px){
  .module-stats,.kanban-metrics,.system-admin-menu{grid-template-columns:1fr}
  .top-actions .secondary{display:none}
  .calendar-filterbar{display:grid;grid-template-columns:1fr}
  .calendar-filterbar select{width:100%}
  .calendar-controls{align-items:stretch}
  .calendar-controls>div{width:100%}
}
