:root {
  --res-navy: #0c3552;
  --res-green: #167965;
  --res-forest: #116554;
  --res-surface: #fff;
  --res-border: #d6e3e8;
  --res-muted: #496275;
}
.residency-page { background: #f4f8fa }
.residency-page .wrap { width: min(1440px, calc(100% - 64px)) }
.residency-page .res-top {
  background: linear-gradient(105deg, #0b2947, #123d4d);
  border-bottom: 2px solid #64958e;
}
.res-nav { display: flex; align-items: center; gap: 24px; min-height: 68px; padding-block: 8px }
.res-brand {
  flex: 0 0 auto;
  background: #fff;
  border: 1px solid #dbe8ed;
  border-radius: 10px;
  padding: 7px 12px;
}
.res-nav-links { display: flex; gap: 8px; flex-wrap: wrap }
.res-nav-links a {
  display: inline-flex; align-items: center; min-height: 42px; padding: 6px 12px;
  color: #f0f7fa; text-decoration: none; font-size: .86rem; font-weight: 650;
  border: 1px solid #ffffff34; border-radius: 9px;
}
.res-nav-links a:hover { background: #ffffff1c }
.res-breadcrumb { display: flex; align-items: center; gap: .6rem; margin-top: 1.1rem; color: var(--res-muted); font-size: .83rem }
.res-breadcrumb [aria-current] { color: var(--res-navy); font-weight: 700; text-decoration: none }
body.residency-page .res-hero {
  grid-template-columns: minmax(0, 1.7fr) minmax(225px, 1fr);
  background: radial-gradient(ellipse at top right, #e7f4ed, transparent 66%), #f9fbfc;
  align-items: stretch;
}
body.residency-page .res-hero h1 { font-size: clamp(2rem, 4vw, 3.55rem); letter-spacing: -.045em }
body.residency-page .res-hero h1 span { color: var(--res-green) }
body.residency-page .res-hero .res-coverage { margin-top: 10px; font-size: .8rem }
.res-highlight {
  display: flex; flex-direction: column; justify-content: center; gap: 12px; min-width: 0;
  border-radius: 15px; border: 1px solid #bed7cf; background: #fff; padding: 1.15rem 1.35rem;
}
.res-highlight-label { display: flex; gap: .6rem; align-items: center; color: var(--res-forest) }
.res-highlight-label span { font-size: 1.5rem; line-height: 1 }
.res-highlight h2 { font: 750 .86rem/1.3 system-ui, sans-serif; margin: 0 }
.res-highlight time { display: block; font-size: clamp(1.3rem, 2.1vw, 2rem); font-weight: 750; color: var(--res-navy) }
.res-highlight a { display: inline-block; margin-top: 2px; font-size: .88rem; font-weight: 700 }
.res-section { margin-block: 1.9rem; scroll-margin-top: 90px }
.res-section h2, .residency-page .detail-card h2 { color: var(--res-navy); letter-spacing: -.025em }
.residency-page .filters {
  grid-template-columns: minmax(0,1fr);
  gap: .7rem; padding: 1rem; border-color: var(--res-border); border-radius: 16px;
}
.res-saved { min-height: 44px; padding: .45rem .7rem; background: #edf6f2; border: 1px solid #d2e6df; border-radius: 9px; white-space: nowrap }
.res-saved input { accent-color: var(--res-green) }
.res-results { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .4rem 1rem; min-height: 48px }
.res-results p { margin-block: .35rem }
.res-hint { color: var(--res-muted); font-size: .88rem; margin: .35rem 0 }
.residency-page .cards {
  grid-template-columns: repeat(auto-fit,minmax(min(100%, 320px),1fr)); gap: 1rem;
}
.residency-page .card {
  border-radius: 16px; padding: 1.2rem; border-color: var(--res-border); box-shadow: 0 6px 18px #0c355209;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.residency-page .card:hover { border-color: #a5c5c6; box-shadow: 0 9px 23px #0c355214 }
.residency-page .card h3 { font-size: 1.2rem; line-height: 1.3; text-wrap: pretty }
.res-card-facts { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .75rem; margin: .85rem 0 .1rem; padding-top: .65rem; border-top: 1px solid var(--res-border) }
.res-card-facts dt { font-size: .78rem; color: var(--res-muted) }
.res-card-facts dd { margin: .15rem 0 0; font-weight: 750; overflow-wrap: anywhere }
.residency-page .button:not(.quiet), .residency-page button:not(.quiet) { background: var(--res-navy); border-color: var(--res-navy) }
.residency-page button[aria-pressed=true] { background: #e2f4eb; color: #0c5d47; border-color: #90bfad }
.res-compare-bar {
  position: sticky; bottom: .5rem; z-index: 6; display: flex; align-items: center; justify-content: space-between; gap: .5rem 1rem; flex-wrap: wrap;
  padding: .65rem .9rem; margin-top: .9rem; background: #edf7f3; border: 1px solid #a7cabc; border-radius: 13px; box-shadow: 0 4px 15px #0c355220;
}
.res-compare-bar p { margin: 0; color: var(--res-forest); font-weight: 750 }
#compare-dialog {
  width: min(960px, calc(100% - 22px)); max-height: 88dvh; padding: clamp(.85rem,3vw,1.5rem);
  border-radius: 18px; border: 1px solid var(--res-border); color: var(--res-navy); box-shadow: 0 16px 70px #092b4a4d;
}
#compare-dialog::backdrop { background: #112f49a6 }
.res-table-wrap { max-width: 100%; overflow: auto; margin-top: .65rem }
.res-table { width: 100%; border-collapse: collapse; font-size: .9rem }
.res-table :is(th,td) {
  min-width: 132px; padding: .72rem; border-bottom: 1px solid var(--res-border);
  text-align: left; vertical-align: top; overflow-wrap: anywhere;
}
.res-table th[scope=col] { background: #edf5f7 }
.res-table th[scope=row] { min-width: 108px; color: var(--res-muted) }
.res-agenda { background: #fff; border: 1px solid var(--res-border); border-radius: 16px; padding: clamp(.88rem,3vw,1.45rem) }
.res-agenda-list { margin: 0; padding: 0; list-style-type: none }
.res-agenda-list > li { border-top: 1px solid var(--res-border); padding-block: .65rem }
.res-agenda-row { display: grid; grid-template-columns: minmax(100px, 145px) minmax(0, 1fr); gap: .65rem }
.res-agenda-row time { font-weight: 750; color: var(--res-forest) }
.res-agenda-row strong { display: block; color: var(--res-navy) }
.res-agenda-row a { font-size: .87rem; overflow-wrap: anywhere }
.residency-page .detail-card { padding: clamp(1rem,3vw,2.1rem); border-radius: 18px }
.residency-page .facts { grid-template-columns: repeat(auto-fit,minmax(min(100%,190px),1fr)); padding-block: 1.1rem }
.residency-page .phases { list-style: none; border-left: 2px solid #c6ddd6; padding-left: 1rem; margin-left: .15rem }
.residency-page .phases li { padding: .45rem 0; position: relative }
.residency-page .phases li::before { content: ""; width: 8px; height: 8px; position: absolute; left: calc(-1rem - 5px); top: 1rem; border-radius: 50%; background: var(--res-green) }
@media(max-width: 720px) {
  .residency-page .wrap { width: calc(100% - 28px) }
  body.residency-page .res-hero { grid-template-columns: 1fr }
  .residency-page .res-top { position: static }
  .res-nav { min-height: auto; align-items: start; flex-direction: column; gap: .45rem }
  .res-nav-links a { font-size: .77rem; min-height: 36px }
  .res-agenda .section-head { flex-wrap: wrap }
}
@media(max-width: 390px) {
  .res-agenda-row { grid-template-columns: 1fr; gap: .1rem }
  .res-nav-links { gap: 4px }
  .res-nav-links a { padding-inline: 7px }
}
@media(prefers-reduced-motion: reduce) {
  .residency-page *, .residency-page *::before { transition: none !important; scroll-behavior: auto !important }
}
body.residency-admin .res-admin-hero { grid-template-columns: 1fr; margin-bottom: 1.05rem }
.residency-admin .top { background: #fff }
.res-editor-filters { display: grid; gap: .65rem; margin-top: 1rem }
.res-editor-filters :is(input,select) { min-height: 44px; padding: .56rem .64rem; border: 1px solid #b6c9d0; border-radius: 8px; color: var(--res-navy); background: #fff }
.residency-admin .sources li .actions { margin-block: .3rem .8rem }
.residency-admin .sources li button { font-size: .82rem }
.residency-admin .res-source-list { list-style: none; padding: 0 }
.residency-admin .res-source-list li { padding: .7rem 0; border-bottom: 1px solid var(--res-border); display: grid; justify-items: start; gap: .3rem }
.residency-admin .res-source-list li a { font-weight: 700 }
.res-doc-filters { grid-template-columns: repeat(2,minmax(0,1fr)) }
.res-application { margin: 1.55rem 0; border: 1px solid #cde4d9; border-radius: 14px; background: #f0f8f4; padding: clamp(.9rem, 3vw, 1.35rem) }
.res-application h3 { margin: 0; color: var(--res-navy) }
.res-application progress { accent-color: var(--res-green); width: min(100%, 22rem); height: .9rem }
.res-application fieldset { display: grid; gap: .15rem; margin: .85rem 0 0; padding: .45rem .75rem; border: 1px solid #cde4d9; border-radius: 8px }
.res-application legend { font-weight: 750; font-size: .86rem }
.res-application label { min-height: 44px; align-items: center }
.res-application input { accent-color: var(--res-green); width: 1rem; height: 1rem; flex: 0 0 auto }
.residency-page .card .res-application-card { color: var(--res-forest); font-weight: 650; font-size: .85rem; margin-top: .45rem }
.res-compare-warning { border: 1px solid #e8ce92; background: #fff8e8; color: #654305; border-radius: 8px; padding: .75rem .9rem; margin-top: .65rem }
.res-compare-warning :is(ul,p) { margin: .3rem 0 }
.res-compare-warning ul { padding-left: 1.2rem }
.res-doc-changes { grid-column: 1 / -1; min-height: 40px }
.res-pdf-tag { display: table; background: #fff0d7; color: #754807; border-radius: 999px; padding: .15rem .5rem; margin: 0 0 .25rem; font-size: .78rem }
.res-pdf-state { color: var(--res-muted) }
.res-pdf-state[data-state=changed] { color: #714c10; font-weight: 700 }
.res-pdf-state[data-state=error] { color: #901c36 }
.res-open-block, .res-attribution {
  padding: clamp(.85rem,3vw,1.45rem); border: 1px solid #cde4d9; border-radius: 16px; background: #eff8f3;
}
.res-open-block .section-head > a { font-size: .9rem; font-weight: 700 }
.res-open-block .card .button { align-self: flex-start; margin-top: .25rem }
.residency-page .res-open-card, .res-open-card { border-color: #88b8a6; border-left: 4px solid var(--res-green) }
.res-pagination { justify-content: center; margin-top: 1.25rem }
.res-attribution { border-color: var(--res-border); background: #fff }
.res-attribution h2 { font-size: 1.3rem }
.res-attribution p { color: var(--res-muted); font-size: .9rem }
.res-attribution .actions a { font-size: .88rem }
.res-program-edital { margin-top: 2rem }
.res-program-edital details { margin-top: .9rem }
.res-program-edital summary { cursor: pointer; font-weight: 700 }
.res-linked-notice { border: 1px solid var(--res-border); border-radius: 12px; padding: .85rem; margin: .8rem 0; background: #fff }
.res-linked-notice h4 { margin: .35rem 0 }
.res-linked-notice p { margin: .35rem 0 .75rem }
.res-program-edital .res-open-card { background: #eef8f2 }
@media(max-width: 650px) {
  .res-open-block .section-head { display: block }
}
.res-program-editor { margin-top: 1.6rem; border-top: 1px solid var(--res-border); padding-top: 1.2rem }
.res-program-editor :is(input[type=url],input[type=search]) { min-height: 44px; border: 1px solid #b6c9d0; padding: .55rem; border-radius: 8px }
.res-program-editor .actions { margin-block: .6rem }
.res-program-choices { display: grid; gap: .35rem; max-height: 270px; overflow: auto; margin-bottom: 1rem }
.res-program-choices .check { align-items: flex-start; min-height: 36px }
.res-program-choices input { flex: 0 0 auto; margin-top: .3rem }

.res-discovery { border: 1px solid #c8dfd8; border-radius: 16px; padding: clamp(1rem, 3vw, 1.6rem); background: #fff }
.res-program-search { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: .5rem }
.res-program-search label { grid-column: 1 / -1; font-weight: 650 }
.res-program-search input { min-width: 0; width: 100%; min-height: 44px; padding: .65rem .75rem; border: 1px solid #a7bfbf; border-radius: 8px; font: inherit }
.res-shortcuts { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; margin: .85rem 0 }
.res-shortcuts a { display: inline-flex; align-items: center; min-height: 40px; padding: .4rem .75rem; background: #eaf5f1; color: #0c5948; border: 1px solid #c1dcd3; border-radius: 9px; font-weight: 650; font-size: .88rem; text-decoration: none }
.res-shortcuts a:hover { background: #d9eee5 }
@media (max-width: 540px) {
  .res-program-search { grid-template-columns: minmax(0, 1fr) }
  .res-program-search button { justify-self: start }
}

.res-watch-control { display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem 1rem; margin: .75rem 0 }
.res-watch-control label { display: inline-flex; align-items: center; gap: .45rem; min-height: 40px; font-weight: 650 }
.res-watch-control input { accent-color: var(--res-green) }
.res-program-save[aria-pressed=true] { color: var(--res-forest); border-color: #a7cabc; background: #e2f4eb }
.res-program-dates { margin-top: .3rem; color: var(--res-forest); font-weight: 650 }

.res-sync-panel {max-width: 740px; margin: 1.5rem auto 3rem; padding: clamp(1rem, 4vw, 2rem); border: 1px solid #c9dfda; border-radius: 18px; background: #fff}
.res-sync-panel button {background: linear-gradient(120deg,#0c3552,#146858); border-color: #12565a; color: #fff}
.res-sync-panel progress {display: block; width: min(100%, 26rem); margin-top: 1rem; accent-color: #146858}
.res-official-updates {border-top: 1px solid #c9dfda; margin-top: 1.5rem; padding-top: .8rem}
.res-official-updates li {margin-bottom: .65rem}

/* Navegação e controles das telas públicas de Residência. */
.res-nav-links [aria-current] { background: #e4f4ee; border-color: #c9e4da; color: #124f43 }
.res-nav-links [aria-current]:hover { background: #f1faf7 }
.res-filter-options, .res-filter-fields { min-width: 0 }
.res-filter-options summary, .res-sync-panel summary {
  padding: .6rem .75rem; min-height: 44px; border: 1px solid var(--res-border);
  border-radius: 9px; color: var(--res-navy); cursor: pointer; font-weight: 700;
}
.res-filter-options[open] summary, .res-sync-panel details[open] summary { background: #f0f6f7 }
.res-filter-count, .res-sync-badge {
  display: inline-block; margin-inline-start: .35rem; padding: .12rem .5rem;
  border-radius: 999px; background: #e6f4ed; color: #0c5948; font-size: .76rem; font-weight: 700;
}
.res-filter-fields { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)) auto; gap: .7rem; align-items: end; margin-top: .75rem }
.residency-page .filters .res-filter-fields label { grid-column: auto; min-width: 0 }
.res-filter-fields :is(select,input) { width: 100% }
.res-load-more { display: flex; justify-content: center; margin-top: .85rem }
.res-load-more button { min-height: 44px }
.res-compare-hint { display: none }
.residency-page :is(.card,.detail-card,.res-linked-notice,.phases li) { min-width: 0; overflow-wrap: anywhere }

/* Ação de publicação manual centralizada em todas as larguras. */
.residency-admin .res-sync-panel { width: 100%; box-shadow: 0 10px 28px #0c35520b }
.res-sync-panel > h2 { text-align: center }
.res-sync-action { display: grid; justify-items: center; gap: .8rem; text-align: center }
.res-sync-action #sync-all { width: min(100%, 26rem); min-height: 50px; font-size: 1rem; line-height: 1.35; white-space: normal }
.res-sync-action #sync-all:disabled { opacity: .7; cursor: progress }
.res-sync-progress { width: min(100%, 26rem) }
.res-sync-progress progress { margin: 0; width: 100% }
.res-sync-progress p, #sync-status { margin: 0; min-width: 0; overflow-wrap: anywhere }
.res-sync-progress p { font-size: .82rem; color: var(--res-muted); margin-top: .25rem }
#sync-status[data-state] { padding: .55rem .75rem; border-radius: 9px; color: #125748; background: #eaf6ee }
#sync-status[data-state=partial] { background: #fff4db; color: #694513 }
.res-sync-panel details { margin-top: 1.25rem }
#sync-sources { padding: 0; list-style: none }
#sync-sources li { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin: 0; padding: .65rem 0; border-bottom: 1px solid var(--res-border) }
#sync-sources li p { flex-basis: 100%; margin: 0; color: var(--res-muted); font-size: .85rem }
.res-sync-badge[data-state=error] { background: #fcebf0; color: #8e2341 }
.res-sync-badge[data-state=waiting] { background: #edf2f5; color: #355369 }

@media (max-width: 900px) {
  .res-filter-fields { grid-template-columns: repeat(2,minmax(0,1fr)) }
  .res-filter-fields button { grid-column: 1/-1; justify-self: start }
}
@media (max-width: 720px) {
  .residency-page .res-nav { align-items: center; padding-block: 10px; gap: .5rem }
  .res-nav-links { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); width: 100%; gap: 5px }
  .res-nav-links a { justify-content: center; min-height: 44px; padding: .3rem .25rem; text-align: center; line-height: 1.3 }
  .res-breadcrumb { flex-wrap: wrap; gap: .2rem .45rem; margin-top: .7rem }
  .residency-page .res-section { scroll-margin-top: 12px }
  body.residency-page .mcPageHero.res-hero, body.residency-admin .mcPageHero.res-admin-hero { margin-block: .9rem; padding: 1rem; gap: 1rem }
  body.residency-page .res-hero h1, body.residency-admin .res-admin-hero h1 { margin-block: .5rem }
  .residency-page .res-hero .mcHeroActions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); margin-top: .8rem }
  body.residency-page .res-hero .mcHeroActions a { width: 100%; min-height: 44px; padding-inline: .45rem; gap: .2rem }
  .res-highlight { padding: .8rem 1rem; gap: .35rem }
  .res-shortcuts a { min-height: 44px }
  .res-program-search button { width: 100% }
  .residency-page .filters label { font-size: .88rem }
  .residency-page :is(.filters,.res-program-search) :is(input,select) { font-size: 16px }
  .residency-page :is(.actions,.card,.detail-card) :is(button,.button) { min-height: 44px; white-space: normal }
  .residency-page .detail-card .actions > :first-child { flex-basis: 100%; text-align: center; justify-content: center }
  .res-compare-hint { display: block; margin: .5rem 0; color: var(--res-muted); font-size: .85rem }
  .res-table th[scope=row] { position: sticky; left: 0; background: #f4f8fa }
}
@media (max-width: 360px) {
  .res-filter-fields { grid-template-columns: minmax(0,1fr) }
}

.residency-page .card .res-verification {
  margin-block: .55rem 0;
  padding-top: .5rem;
  border-top: 1px solid var(--res-border);
  color: var(--res-muted);
  font-size: .8rem;
}
.residency-page .card .res-verification[data-state=ok] { color: var(--res-forest) }
.residency-page .card .res-verification[data-state=error] { color: #8e2341 }

.res-sync-summary {
  margin-top: 1.25rem;
  padding: .9rem;
  border: 1px solid var(--res-border);
  border-radius: 12px;
  background: #f4f8f9;
}
.res-sync-summary h3 { margin: 0 0 .35rem }
.res-sync-summary p { margin: .45rem 0 0; font-size: .86rem }
.res-sync-metrics {
  display: grid;
  grid-template-columns: repeat(4,minmax(0,1fr));
  gap: .5rem;
  margin: .75rem 0 0;
}
.res-sync-metrics > div { padding: .55rem; background: #fff; border: 1px solid var(--res-border); border-radius: 8px }
.res-sync-metrics dt { color: var(--res-muted); font-size: .8rem }
.res-sync-metrics dd { margin: .1rem 0 0; color: var(--res-navy); font-weight: 750; font-size: 1.2rem }
#sync-failed-feeds { color: #8e2341; overflow-wrap: anywhere }

@media (max-width: 575px) {
  .res-sync-metrics { grid-template-columns: repeat(2,minmax(0,1fr)) }
}

body.mcPageFrame.residency-page .mcHeroActions > .res-catalog-cta {
  background: linear-gradient(115deg, #116452, #0c493c 62%, #105b50);
  border-color: #3eaa88;
  color: #fff;
  font-weight: 700;
  box-shadow: inset 0 1px 0 #ffffff40, 0 3px 14px #14796048;
  animation: res-catalog-glow 2.8s ease-in-out 4;
}

body.mcPageFrame.residency-page .mcHeroActions > .res-catalog-cta:hover {
  filter: brightness(1.13);
}

@keyframes res-catalog-glow {
  50% { box-shadow: inset 0 1px 0 #ffffff80, 0 0 0 4px #35ba9333, 0 3px 22px #14796088 }
}

@media (prefers-reduced-motion: reduce) {
  body.mcPageFrame.residency-page .mcHeroActions > .res-catalog-cta { animation: none }
}
