/* Loaded after page styles so the same layout contract applies throughout the portal. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
*, *::before, *::after { box-sizing: border-box; }
img, video, iframe { max-width: 100%; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
    outline: 3px solid #67b7ff;
    outline-offset: 4px;
}
:where(h1, h2, h3, p, a, label, small, strong) { overflow-wrap: anywhere; }
:where(.reference-hero-grid, .new-dash-grid, .initiative-grid, .article-layout,
       .article-hero-grid, .services-layout, .service-detail-layout, .footer-main) > * { min-width: 0; }
.shell, .reference-shell { max-width: calc(100% - 2 * var(--page-gutter, 24px)); }
.button, .reference-button, .btn-home, .btn-voltar { min-height: 44px; max-width: 100%; }
.button > span, .reference-button > b { flex-shrink: 0; }
.article-content, .service-detail-content, .frente-body { min-width: 0; overflow-wrap: anywhere; }
:is(.article-content, .service-detail-content, .frente-body) :is(img, video) { height: auto; }
:is(.article-content, .service-detail-content, .frente-body) iframe { width: 100%; }
:is(.article-content, .service-detail-content, .frente-body) :is(table, pre) {
    display: block;
    max-width: 100%;
    overflow-x: auto;
}
.article-content .evento-gallery-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); }
.semana-gallery-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); }
.evento-lightbox .evento-lightbox-inner, .semana-lightbox-inner {
    min-width: 0;
    max-height: calc(100dvh - 96px);
    max-width: min(1080px, calc(100vw - 96px));
}
.evento-lightbox .evento-lightbox-inner img, .semana-lightbox-inner img {
    min-height: 0;
    width: auto;
    max-width: 100%;
    max-height: calc(100dvh - 180px);
    margin: 0;
    object-fit: contain;
}
.evento-lightbox .evento-lightbox-caption, .semana-lightbox-caption {
    flex-shrink: 0;
    max-height: 20dvh;
    overflow-y: auto;
    overflow-wrap: anywhere;
    line-height: 1.5;
}
.frente-symbol { right: 0; }
.reference-nav .reference-mobile-nav[hidden] { display: none; }

/* Symmetric side columns keep the desktop navigation centered in the header. */
@media (min-width: 1051px) {
    .reference-nav-inner {
        grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
        column-gap: clamp(12px, 1.5vw, 24px);
    }
    .reference-nav-inner > .reference-brand { grid-column: 1; max-width: clamp(290px, 24vw, 450px); }
    .reference-nav-inner > nav:not(.reference-mobile-nav) {
        grid-column: 2;
        position: static;
        transform: none;
        gap: clamp(14px, 1.8vw, 30px);
        justify-content: center;
    }
    .reference-nav-inner > .btn-voltar { grid-column: 3; justify-self: end; }
    .reference-nav-inner > nav:not(.reference-mobile-nav) a { font-size: clamp(12px, .9vw, 15px); }
    .reference-nav .reference-mobile-nav { display: none; }
    .reference-copy { padding-bottom: 36px; }
}

/* Keep the original desktop hero; smaller screens use the adaptive composition. */
@media (max-width: 1050px) {
    .reference-hero-grid { align-items: center; }
    .reference-dashboard {
        height: auto;
        min-height: 0;
        width: 100%;
        margin: 0;
        padding: 24px 0;
    }
    .reference-dashboard .new-dash { inset: auto; margin: 0; }
}
.new-dash-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: none;
    grid-auto-rows: minmax(205px, auto);
}
.nd-card { height: auto; min-width: 0; }
.nd-body { min-height: auto; }
.nd-big-stat { flex-wrap: wrap; gap: 8px; padding-top: 8px; }
.new-dash-heading { flex-wrap: wrap; gap: 8px; }
.ndh-left, .ndh-right { min-width: 0; }
.ndh-icon, .ndh-right .dot { flex-shrink: 0; }
.new-dash-nav { gap: 8px; padding-inline: 0; }
.new-dash-nav nav {
    display: flex;
    flex: 1;
    min-width: 0;
    gap: 4px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
    scrollbar-color: #398dff transparent;
}
.new-dash-nav button {
    flex-shrink: 0;
    border: 0;
    cursor: pointer;
    min-height: 44px;
    color: #acbed6;
    background: transparent;
    font: 600 11px var(--body);
}
.new-dash-nav nav button { padding: 10px; white-space: nowrap; border-radius: 6px; }
.new-dash-nav button[aria-pressed="true"] { color: #a9d7ff; background: rgba(57, 141, 255, .18); }
.new-dash-nav > button { width: 36px; border-radius: 6px; background: rgba(73, 151, 255, .1); }
@media (min-width: 1051px) {
    .new-dash-grid { grid-auto-rows: minmax(185px, auto); }
    .reference-dashboard .new-dash-nav { padding: 10px 10px 0; }
    .reference-dashboard .new-dash-nav nav {
        flex: 0 1 auto;
        margin-inline: auto;
        gap: 12px;
        justify-content: safe center;
    }
    .reference-dashboard .new-dash-nav nav button {
        min-height: 20px;
        padding: 0;
        color: #8da5c5;
        font-size: 13px;
        letter-spacing: .05em;
        background: transparent;
    }
    .reference-dashboard .new-dash-nav nav button[aria-pressed="true"],
    .reference-dashboard .new-dash-nav nav button:hover { color: #398dff; }
    .reference-dashboard .new-dash-nav > button {
        flex: 0 0 20px;
        width: 20px;
        height: 20px;
        min-height: 20px;
        padding: 0;
        border-radius: 50%;
        color: #398dff;
        font-size: 10px;
    }
}
@media (max-width: 1050px) {
    .reference-stats { margin-top: 12px; }
}
.reference-stats .reference-stat > strong { display: block; padding-right: 28px; }
.reference-stats .stat-icon { right: 12px; width: 25px; height: 25px; }
.reference-stats .stat-icon svg { width: 100%; height: 100%; }
.reference-map > div { min-width: 0; }
.reference-map .map-grid { flex-shrink: 1; }
.reference-map a { white-space: normal; }
.service-links b { padding-right: 16px; }
.cal-nav h2 { min-width: 0; }
.cal-nav > .cal-arrow { flex-shrink: 0; }
.cal-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-day, .cal-mobile-day-events { min-width: 0; }
.cal-event { overflow-wrap: anywhere; }
.cal-mobile-event .cal-event-location { display: block; margin-top: 5px; color: #9ab7d4; font-size: 11px; font-weight: 400; line-height: 1.4; }
.cal-mobile-event time { font-size: 10px; }
.cal-mobile-events:has(> .cal-mobile-events-title:only-child)::after {
    content: 'Nenhum evento programado para este mês.';
    font-size: 14px;
    color: #aebed0;
    line-height: 1.6;
}
.empty-news { min-width: 0; padding: clamp(24px, 5vw, 60px); }
.article-content > img.article-image { display: block; }
.eventos-realizados-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 820px; }
@media (min-width: 1051px) {
    .eventos-realizados-grid { max-width: none; }
}
.card-evento-bar { gap: 12px; }

@media (min-width: 701px) and (max-width: 1200px) {
    .initiative-grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1051px) and (max-width: 1200px) {
    .new-dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .reference-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .reference-stats .reference-map { grid-column: 1 / -1; justify-content: center; }
    .reference-stats .reference-stat { padding: 20px; }
}
@media (max-width: 1050px) {
    .reference-dashboard { padding: 8px 0 24px; }
    .new-dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .reference-brand { max-width: 100%; }
    .reference-nav .reference-mobile-nav {
        position: absolute;
        top: calc(100% + 4px);
        left: 0;
        right: 0;
        max-height: calc(100dvh - 100px);
        overflow-y: auto;
        overscroll-behavior: contain;
        transform: none;
    }
    .reference-nav .reference-mobile-nav a { white-space: normal; }
    /* Keep the page scrollable when a menu is open on a short landscape screen. */
    body.reference-menu-open { overflow-y: auto; }
}
@media (max-width: 850px) {
    .reference-shell, .shell { --page-gutter: 16px; }
    .site-header .nav-wrap:has(.btn-home) {
        height: auto;
        min-height: 78px;
        padding: 12px 16px;
        display: flex !important;
        justify-content: space-between !important;
        gap: 16px;
    }
    .site-header .nav-wrap:has(.btn-home) .brand {
        position: static;
        transform: none;
        min-width: 0;
        flex: 1;
        max-width: 240px;
    }
    .site-header .nav-wrap:has(.btn-home) .brand-seal {
        width: 100% !important;
        height: auto !important;
        max-height: 56px;
        object-position: left center;
    }
    .site-header .btn-home {
        position: static;
        transform: none;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex: 0 1 auto;
        max-width: 44%;
        text-align: center;
        white-space: normal;
    }
    .footer-main { gap: 28px; }
}
@media (max-width: 700px) {
    .reference-copy h1 { font-size: clamp(36px, 10.5vw, 58px); }
    .reference-copy, .reference-hero-grid { min-height: 0; }
    .reference-dashboard { padding-bottom: 16px; }
    .new-dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: minmax(220px, auto); }
    .reference-dashboard .nd-body h3 { font-size: 15px; line-height: 1.25; }
    .reference-dashboard .nd-body p { font-size: 12px; line-height: 1.5; }
    .reference-dashboard .ndh-right { font-size: 9px; }
    .nd-img, .nd-img-pattern { height: 80px; flex-basis: 80px; }
    .nd-status { font-size: 10px; }
    .reference-stats h2 { font-size: 13px; line-height: 1.35; }
    .reference-stats p { line-height: 1.5; }
    .reference-stats .reference-stat > strong { font-size: clamp(29px, 9vw, 40px); }
    .initiative-grid.four { grid-template-columns: 1fr; }
    .eventos-realizados-grid { gap: 16px; }
    .card-evento-bar { padding: 12px; font-size: 10px; }
    .metric-list { grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); }
    .metric-list > div { border-bottom: 1px solid #b8c0ba; }
    .section, .destaque-noticia, .metrics, .agenda, .services { padding-block: clamp(48px, 9vw, 64px); }
    .section-heading h2, .metrics h2, .services h2 { font-size: clamp(32px, 9vw, 48px); }
    .article-hero h1, .service-detail-hero h1, .frente-hero h1 { font-size: clamp(34px, 9vw, 52px); }
    .article-meta { flex-wrap: wrap; }
    .article-content .evento-gallery-block { padding: 24px 16px; }
    .evento-gallery-header > *, .evento-admin-btns { min-width: 0; max-width: 100%; }
    .footer-contact a, .footer-social a { min-height: 44px; display: inline-flex; align-items: center; }
}
@media (max-width: 380px) {
    .reference-shell, .shell { --page-gutter: 14px; }
    .new-dash-grid { grid-template-columns: 1fr; }
    .eventos-realizados-grid { grid-template-columns: 1fr; }
    .reference-stats .stat-icon { width: 20px; height: 20px; right: 10px; }
}
@media (pointer: coarse) {
    .cursor-glow, .page-noise { display: none; }
    .initiative-card:hover, .event-row:hover, .small-news:hover, .featured-news:hover { transform: none; }
    input, select, textarea { font-size: 16px; }
}
/* Management needs room for uploads, long labels and the rich text editor. */
.manage-header { gap: 16px; }
.manage-header .brand { min-width: 0; }
.manage-header .brand img { max-width: 100%; }
.manage-header nav { flex-shrink: 0; }
.manage-header nav a { min-height: 44px; display: inline-flex; align-items: center; }
.manage-hero .intro { font: 400 15px/1.65 Manrope, Arial, sans-serif !important; text-align: left; }
.manage-main form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.manage-main :is(input, select, textarea) { min-width: 0; max-width: 100%; }
.manage-main :is(label, small, .item-copy, .album-meta) { overflow-wrap: anywhere; }
#id_subsecretarias { grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); }
#id_subsecretarias :is(label, div, li) { min-width: 0; }
#id_subsecretarias input { flex: 0 0 44px; }
.form-actions, .section-title { flex-wrap: wrap; }
.form-actions button { max-width: 100%; white-space: normal; }
.album-header, .album-photo-item { flex-wrap: wrap; }
.album-meta { min-width: 0; }
.modal-box { max-height: calc(100dvh - 32px); overflow-y: auto; }
.modal-actions { flex-wrap: wrap; }
@media (max-width: 600px) {
    .manage-main form { grid-template-columns: minmax(0, 1fr); }
    .manage-header nav { gap: 4px; }
    .manage-hero h1 { font-size: clamp(34px, 10vw, 52px); }
    .manage-main .actions { margin-left: 0; width: auto; flex-wrap: wrap; }
    .manage-main .actions :is(a, button) { min-height: 44px; display: inline-flex; align-items: center; }
    .album-toggle-btn { white-space: normal; }
    .album-meta { flex-basis: calc(100% - 100px); }
    .album-header { padding: 16px; gap: 12px; }
    .album-body { padding-inline: 12px; }
    .form-actions { flex-direction: column; }
    .form-actions > * { width: 100%; text-align: center; }
    .tabs { scrollbar-width: thin; scrollbar-color: #4fa4ff transparent; }
    .tab { min-height: 44px; display: inline-flex; align-items: center; }
}
@media (prefers-reduced-motion: reduce) {
    .reveal { opacity: 1; transform: none; transition: none; }
    .preloader { display: none; }
    body.preloader-active { overflow-y: auto; }
}
