/*
 * Camada responsiva do Radar MS.
 * Mantém os layouts de desktop intactos e corrige grids, painéis, mapas,
 * formulários e modais que ainda usavam dimensões fixas em telas menores.
 */

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

img,
canvas,
svg {
    max-width: 100%;
}

button,
input,
select,
textarea {
    max-width: 100%;
}

@media (max-width: 1100px) {
    /* Planejamento e operação deixam de depender de três colunas estreitas. */
    #view-arquitect > div[style*="grid-template-columns:280px"] {
        grid-template-columns: minmax(230px, 300px) minmax(0, 1fr) !important;
        height: auto !important;
    }

    #view-arquitect > div[style*="grid-template-columns:280px"] > :last-child {
        grid-column: 1 / -1;
    }

    .mon-main,
    #view-monitoramento {
        min-width: 0;
    }

    .mon-board,
    .rede-layout {
        grid-template-columns: 1fr !important;
    }

    /* Quando a rede fica em uma coluna, os indicadores devem rolar junto.
       Manter o sticky aqui faz os cartões das cidades passarem por trás deles. */
    #section-rede .rede-side {
        position: static !important;
        top: auto !important;
        z-index: auto;
    }

    #section-central .cc-pane > div[style*="grid-template-columns:340px"],
    #section-central .cc-pane > div[style*="grid-template-columns: 340px"] {
        grid-template-columns: minmax(260px, 340px) minmax(0, 1fr) !important;
    }

    #section-central .cc-pane > div[style*="grid-template-columns:340px"] > :last-child,
    #section-central .cc-pane > div[style*="grid-template-columns: 340px"] > :last-child {
        grid-column: 1 / -1;
    }

    #dia-regions {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

@media (max-width: 768px) {
    :root {
        --mobile-page-pad: 12px;
    }

    body {
        min-width: 0;
        min-height: 100dvh;
        overscroll-behavior-y: none;
    }

    .v2-app {
        width: 100%;
        min-width: 0;
        height: 100dvh;
    }

    .v2-main {
        width: 100%;
        min-width: 0;
        height: 100dvh;
        padding-bottom: calc(66px + env(safe-area-inset-bottom));
        overscroll-behavior-y: contain;
        -webkit-overflow-scrolling: touch;
    }

    .v2-content {
        width: 100%;
        min-width: 0;
    }

    /* Todas as rotas ganham o mesmo respiro lateral no telefone. */
    .v2-main > [id^="view-"],
    .v2-content > [id^="view-"],
    #dash-root {
        width: 100%;
        min-width: 0;
        padding: 12px var(--mobile-page-pad) 18px !important;
    }

    #view-full-map {
        height: calc(100dvh - 86px) !important;
        min-height: 520px;
    }

    #view-full-map > .v2-panel,
    #full-ms-map {
        height: 100% !important;
        min-height: 0;
    }

    /* No telefone, os filtros do mapa funcionam como uma folha inferior. */
    #map-filter-panel {
        inset: auto 12px 12px 12px !important;
        width: auto !important;
        max-height: 44dvh;
        overflow-y: auto;
        overscroll-behavior: contain;
        border-radius: 14px;
    }

    #map-filter-move-left,
    #map-filter-move-right {
        display: none !important;
    }

    .v2-page-header,
    .pv-h-row,
    .crm-h-row,
    .mon-header,
    .dash-header {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
    }

    .v2-page-title,
    .pv-page-title,
    .crm-page-title,
    .mon-title,
    .dash-title {
        overflow-wrap: anywhere;
    }

    .v2-header-actions,
    .crm-actions,
    .dash-actions {
        width: 100%;
    }

    .v2-header-actions > .btn,
    .crm-actions > .btn,
    .dash-actions > .btn {
        flex: 1 1 auto;
        justify-content: center;
    }

    /* Alvos de toque confortáveis sem inflar chips e ícones compactos. */
    .v2-mobile-nav button,
    .v2-mobile-sidebar-close,
    .btn,
    .v2-input,
    .v2-select,
    .v2-textarea {
        min-height: 44px;
    }

    .btn {
        padding-inline: 14px;
    }

    /* Dashboard */
    .dash-strip,
    .dash-strip-operacional,
    .dash-today-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .dash-stat-cell {
        border-right: 0;
        border-bottom: 1px solid var(--border);
        padding: 13px 12px;
    }

    .dash-stat-cell:nth-last-child(-n+2) {
        border-bottom: 0;
    }

    .dash-alerts {
        display: flex !important;
        flex-direction: column;
        align-items: stretch;
    }

    .dash-alerts-lbl {
        border-right: 0;
        border-bottom: 1px solid var(--border);
        padding: 4px 0 8px;
    }

    .dash-alert {
        width: 100%;
        min-width: 0;
    }

    .dash-insights-bar,
    .dash-panel-head {
        flex-wrap: wrap;
    }

    .dash-feed-filters {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 4px;
        scrollbar-width: none;
    }

    /* Mapa de votos */
    .pv-layout,
    .pv-split {
        grid-template-columns: 1fr !important;
    }

    .pv-facets {
        position: static;
        max-height: none;
    }

    .pv-kpi-row {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .pv-h-row > div:last-child {
        width: 100%;
        flex-wrap: wrap;
    }

    .pv-h-row > div:last-child .btn {
        flex: 1;
        justify-content: center;
    }

    .pv-panel-head {
        align-items: stretch;
        padding: 14px 12px;
    }

    .pv-panel-head > div:last-child {
        width: 100%;
        min-width: 0;
        flex-wrap: wrap !important;
    }

    .pv-panel-head > div:last-child > div:first-child {
        width: 100% !important;
        min-width: 0;
    }

    .pv-tabs-bar {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .pv-tab {
        min-width: 0;
        padding-inline: 6px;
    }

    /*
     * No desktop cada ranking rola dentro do card. No celular isso deixava
     * a primeira e a última linha visualmente cortadas. A página passa a ter
     * uma única rolagem contínua.
     */
    #main-chart,
    #party-list-container {
        max-height: none;
        min-height: 0;
        overflow: visible;
    }

    .pv-rank-item {
        grid-template-columns: 26px minmax(0, 1fr) auto;
        gap: 8px;
        padding: 10px 10px;
    }

    .pv-rank-item > div {
        min-width: 0;
    }

    .pv-rank-name {
        line-height: 1.25;
        overflow-wrap: anywhere;
    }

    .pv-rank-meta {
        flex-wrap: wrap;
        gap: 4px;
    }

    .pv-rank-party,
    .pv-rank-elected {
        margin-left: 0;
    }

    .pv-party-row,
    .pv-section-title {
        padding-inline: 12px;
    }

    #candidate-map-view > div:first-child {
        flex-direction: column;
        gap: 12px;
    }

    #candidate-map-view > div[style*="grid-template-columns:1fr 380px"] {
        grid-template-columns: 1fr !important;
        height: auto !important;
    }

    #candidate-map-view #leaflet-map {
        height: 52dvh !important;
        min-height: 330px;
    }

    #cand-sidebar {
        height: auto !important;
        max-height: 52dvh;
    }

    /* CRM */
    .crm-view-toggle,
    .crm-view-toggle button {
        min-width: 0;
    }

    .crm-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .crm-actions > * {
        width: 100%;
        justify-content: center;
    }

    .crm-actions .crm-view-toggle,
    #btn-new-leader,
    #btn-simulate {
        grid-column: 1 / -1;
    }

    .crm-view-toggle {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .crm-kpi-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        overflow: hidden;
    }

    .crm-kpi {
        min-width: 0;
        padding: 15px 14px;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .crm-kpi:nth-child(odd) {
        border-right: 1px solid var(--border);
    }

    .crm-kpi:nth-last-child(-n + 2) {
        border-bottom: 0;
    }

    .crm-kpi-val,
    .crm-kpi-input {
        font-size: 25px;
    }

    .crm-toolbar {
        display: grid;
        grid-template-columns: 1fr;
        padding: 10px;
    }

    .crm-search-wrap,
    .crm-search {
        width: 100%;
    }

    .crm-pills {
        max-width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 3px;
        scrollbar-width: none;
    }

    .crm-prog {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
        padding: 14px;
    }

    .crm-prog > :nth-child(3) {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .crm-main,
    .crm-kanban,
    .crm-funnel {
        grid-template-columns: 1fr !important;
    }

    .crm-map-wrap {
        min-height: 52dvh;
    }

    #crm-map,
    #crm-view-mapa .crm-main > .crm-panel:first-child {
        min-height: 52dvh !important;
    }

    .crm-list-tablewrap,
    .pc-card:has(.pc-table) {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .crm-list-table,
    .pc-table {
        min-width: 680px;
    }

    /* Plano de Vitória */
    #view-arquitect > div[style*="grid-template-columns:280px"] {
        display: flex !important;
        height: auto !important;
        flex-direction: column;
    }

    #view-arquitect > div[style*="grid-template-columns:280px"] > :nth-child(2) {
        order: 1;
    }

    #view-arquitect > div[style*="grid-template-columns:280px"] > :first-child {
        order: 2;
    }

    #view-arquitect > div[style*="grid-template-columns:280px"] > :last-child {
        order: 3;
    }

    #view-arquitect > div[style*="grid-template-columns:280px"] > div {
        width: 100%;
        overflow: visible !important;
    }

    #view-arquitect .v2-bento-card {
        max-height: none !important;
    }

    #view-arquitect > div[style*="grid-template-columns:280px"] > :nth-child(2),
    #arq-ms-map {
        height: 52dvh !important;
        min-height: 360px;
    }

    #arq-compare-picker {
        grid-template-columns: 1fr !important;
    }

    /* Agenda e estoque */
    #pc-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    #view-plano-campo > div[style*="width:fit-content"] {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        width: 100% !important;
        overflow: visible;
        gap: 4px;
        padding: 4px;
    }

    .pc-tab {
        width: 100%;
        min-width: 0;
        min-height: 40px;
        padding-inline: 6px;
        white-space: normal;
        text-align: center;
    }

    .pc-week-grid {
        min-width: 700px;
    }

    .pc-card:has(.pc-week-grid) {
        overflow-x: auto;
    }

    #view-estoque > div:first-child {
        align-items: stretch !important;
        flex-direction: column;
        gap: 12px;
    }

    #view-estoque > div:first-child #btn-novo-item {
        width: 100%;
        justify-content: center;
    }

    #view-estoque > div[style*="grid-template-columns:repeat(3"] {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }

    #view-estoque > div[style*="grid-template-columns:repeat(3"] > :first-child {
        grid-column: 1 / -1;
    }

    #view-estoque > div[style*="grid-template-columns:repeat(3"] .v2-bento-card {
        padding: 16px;
    }

    #view-estoque > div[style*="display:flex"][style*="gap:10px"] {
        align-items: stretch;
        flex-direction: column;
    }

    #estoque-search,
    #estoque-cat-filter {
        width: 100%;
        min-height: 44px;
    }

    /* Monitoramento, Central e Rede */
    #view-monitoramento {
        padding: 8px var(--mobile-page-pad) 16px !important;
    }

    /* Cabeçalho compacto, inspirado na densidade visual do iOS. */
    #view-monitoramento .mon-header {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 7px;
        margin-bottom: 14px;
    }

    #view-monitoramento .mon-eyebrow {
        font-size: 9px;
        letter-spacing: .08em;
    }

    #view-monitoramento .mon-title {
        margin: 2px 0 1px;
        font-size: 22px !important;
        line-height: 1.08;
        letter-spacing: -.04em !important;
    }

    #view-monitoramento .mon-subtitle {
        font-size: 11px;
        line-height: 1.35;
    }

    #view-monitoramento .mon-header > div:last-child {
        gap: 6px !important;
    }

    #view-monitoramento .mon-status-pill {
        padding: 4px 9px;
        font-size: 9.5px;
        border-color: rgba(60, 60, 67, .14);
        box-shadow: none;
    }

    #view-monitoramento #mon-status {
        display: none;
    }

    #view-monitoramento #mon-last-update::before {
        content: "";
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: var(--success);
        box-shadow: 0 0 0 3px rgba(22, 163, 74, .10);
        flex: 0 0 auto;
    }

    #view-monitoramento .mon-pulse {
        width: 6px;
        height: 6px;
    }

    .mon-kpi-grid,
    #cc-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    #cc-summary > .mon-kpi-card:last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }

    #cc-summary .mon-kpi-card {
        min-height: 118px;
    }

    #aq-filters {
        width: 100%;
        overflow: visible;
    }

    #aq-filters > button {
        flex: 1 1 auto;
        justify-content: center;
    }

    .mon-board,
    .rede-layout,
    #section-central .cc-pane > div[style*="grid-template-columns:340px"],
    #section-central .cc-pane > div[style*="grid-template-columns: 340px"],
    #section-central .cc-pane > div[style*="grid-template-columns:340px 1fr 320px"],
    #section-central .cc-pane > div[style*="grid-template-columns:340px 1fr"],
    #section-central .cc-pane > div[style*="grid-template-columns: 340px 1fr"] {
        grid-template-columns: 1fr !important;
    }

    #section-central .cc-pane > div[style*="grid-template-columns"] > * {
        grid-column: auto !important;
    }

    .mon-panel-head {
        align-items: flex-start;
        flex-wrap: wrap;
        gap: 8px;
    }

    #section-pulse .mon-panel {
        height: calc(100dvh - 160px) !important;
        min-height: 480px;
    }

    #section-pulse .mon-panel-head > div {
        width: 100%;
        margin-left: 0 !important;
        flex-wrap: wrap;
    }

    #mon-pulse-city {
        width: 100%;
        min-width: 0 !important;
    }

    .rede-toolbar,
    .rede-pager {
        align-items: stretch;
        flex-direction: column;
    }

    .rede-search-wrap {
        width: 100%;
        max-width: none;
        min-width: 0;
    }

    .rede-tabs {
        width: 100%;
        height: auto;
        overflow-x: auto;
        flex-wrap: nowrap;
        scrollbar-width: none;
    }

    .rede-tabs button {
        min-height: 40px;
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .rede-grid {
        grid-template-columns: 1fr;
    }

    .rede-pager-ctrl {
        max-width: 100%;
        overflow-x: auto;
        padding-bottom: 3px;
    }

    #dia-regions,
    #rede-tree-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    /* Árvore da Rede: composição mobile em blocos claros, sem ações espremidas. */
    #rede-tree-view > .mon-panel > .mon-panel-head {
        display: grid;
        grid-template-columns: repeat(6, minmax(0, 1fr));
        align-items: center;
        gap: 7px;
        padding: 10px;
    }

    #rede-back-to-cities {
        grid-column: 1 / 3;
        margin: 0 !important;
        min-height: 36px;
        justify-content: center;
    }

    #rede-tree-view .mon-panel-title {
        grid-column: 3 / -1;
        min-width: 0;
        line-height: 1.25;
    }

    #rede-tree-meta {
        grid-column: 1 / -1;
        padding: 7px 9px;
        border-radius: 9px;
        background: rgba(118, 118, 128, .08);
        font-size: 10px;
        line-height: 1.4;
    }

    #rede-show-map,
    #rede-add-coord,
    #rede-add-apoiador {
        width: 100%;
        min-width: 0;
        min-height: 38px;
        margin: 0 !important;
        padding-inline: 6px !important;
        border-radius: 9px !important;
        font-size: 9.5px !important;
        justify-content: center;
        text-align: center;
    }

    #rede-show-map { grid-column: 1 / 3; }
    #rede-add-coord { grid-column: 3 / 5; }
    #rede-add-apoiador { grid-column: 5 / 7; }

    #rede-add-apoiador {
        color: var(--text-secondary) !important;
        border-color: var(--border) !important;
        background: var(--bg-card) !important;
    }

    #rede-tree-stats {
        padding: 9px !important;
        gap: 7px !important;
        background: rgba(118, 118, 128, .035);
    }

    #rede-tree-stats > .rede-tree-stat {
        padding: 6px 8px !important;
        border-radius: 10px !important;
        background: rgba(118, 118, 128, .07) !important;
        border-color: rgba(60, 60, 67, .10) !important;
    }

    #rede-tree-stats > .rede-tree-stat > div:first-child {
        font-size: 17px !important;
        font-weight: 800 !important;
    }

    #rede-tree-stats > .rede-tree-stat > div:last-child {
        margin-top: 2px !important;
        font-size: 7.5px !important;
        letter-spacing: .08em !important;
    }

    #rede-tree-stats > .rede-tree-stat:last-child {
        grid-column: 1 / -1;
    }

    #rede-tree-stats > .rede-tree-stat:last-child > div:first-child {
        color: var(--error) !important;
    }

    #rede-tree-body {
        min-height: 0 !important;
        max-height: none !important;
        overflow: visible !important;
        padding: 9px !important;
    }

    .rede-tree-node {
        margin-left: 0 !important;
    }

    .rede-tree-node-card {
        display: grid !important;
        grid-template-columns: 18px 34px minmax(0, 1fr);
        align-items: start !important;
        gap: 8px !important;
        padding: 10px !important;
        border-radius: 11px !important;
        background: var(--bg-card) !important;
    }

    .rede-tree-node-avatar {
        width: 30px !important;
        height: 30px !important;
        font-size: 10px !important;
    }

    .rede-tree-node-content {
        align-self: center;
    }

    .rede-tree-node-heading {
        row-gap: 5px !important;
    }

    .rede-tree-node-meta {
        margin-top: 6px !important;
        line-height: 1.45;
    }

    .rede-tree-node-actions {
        grid-column: 2 / -1;
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px !important;
        width: 100%;
    }

    .rede-tree-node-actions > button {
        min-width: 0;
        min-height: 34px;
        padding: 6px 7px !important;
        border-radius: 9px !important;
        font-size: 9.5px !important;
        justify-content: center;
    }

    .rede-tree-children {
        margin-left: 9px !important;
        padding-left: 10px !important;
    }

    /* Cadastro da rede como bottom sheet: conteúdo aberto, sem cartões aninhados. */
    #rede-cadastro-overlay {
        align-items: flex-end !important;
        padding: 0 !important;
        background: rgba(15, 15, 18, .54) !important;
        backdrop-filter: blur(10px) !important;
    }

    #rede-cadastro-overlay > div {
        width: 100% !important;
        max-width: none !important;
        max-height: 92dvh !important;
        border: 0 !important;
        border-radius: 20px 20px 0 0 !important;
        box-shadow: 0 -8px 32px rgba(0, 0, 0, .18) !important;
    }

    #rede-cadastro-overlay > div > div:first-child {
        padding: 14px 16px 12px !important;
        background: var(--bg-card) !important;
    }

    #rede-cadastro-overlay > div > div:first-child > div > div:first-child {
        width: 30px !important;
        height: 30px !important;
        border-radius: 9px !important;
        font-size: 14px !important;
    }

    #rede-cadastro-overlay > div > div:first-child > div > div:last-child > div:first-child {
        font-size: 14px !important;
        letter-spacing: -.02em !important;
    }

    #rede-cadastro-overlay > div > div:nth-child(2) {
        padding: 10px 16px 18px !important;
        gap: 8px !important;
        overscroll-behavior: contain;
    }

    #rede-cadastro-overlay [data-cad-step] {
        gap: 0 !important;
    }

    #rede-cadastro-overlay [data-cad-step] > section {
        padding: 14px 0 !important;
        gap: 10px !important;
        border: 0 !important;
        border-top: 1px solid var(--border) !important;
        border-radius: 0 !important;
        background: transparent !important;
    }

    #rede-cadastro-overlay [data-cad-step] > section:first-child {
        border-top: 0 !important;
    }

    #rede-cadastro-overlay [data-cad-step] > section > div:first-child {
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        font-size: 10px !important;
        letter-spacing: .06em !important;
    }

    #rede-cadastro-overlay [data-cad-step] > section > div:first-child > span {
        display: none !important;
    }

    #rede-cadastro-overlay [data-cad-step] > section > div[style*="display:grid"] {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }

    #rede-cadastro-overlay [data-cad-step="1"] > section:first-child > div:last-child > div:first-child,
    #rede-cadastro-overlay [data-cad-step="1"] > section:nth-child(2) > div:last-child > div:last-child,
    #rede-cadastro-overlay [data-cad-step="2"] > section:first-child > div:nth-child(2) > div:last-child,
    #rede-cadastro-overlay [data-cad-step="2"] > section:first-child > div:nth-child(3) > div:last-child,
    #rede-cadastro-overlay [data-cad-step="2"] > section:nth-child(2) > div:last-child > div:last-child {
        grid-column: 1 / -1 !important;
    }

    #rede-cadastro-overlay input,
    #rede-cadastro-overlay select,
    #rede-cadastro-overlay textarea {
        min-height: 42px;
        border-radius: 10px !important;
        border-color: rgba(60, 60, 67, .16) !important;
        background: rgba(118, 118, 128, .08) !important;
        box-shadow: none !important;
    }

    #rede-cadastro-overlay label {
        font-size: 9px !important;
        letter-spacing: .055em !important;
    }

    #rede-cadastro-overlay > div > div:last-child {
        display: flex !important;
        gap: 8px !important;
        padding: 10px 16px calc(10px + env(safe-area-inset-bottom)) !important;
        background: color-mix(in srgb, var(--bg-card) 94%, transparent) !important;
        box-shadow: 0 -1px 0 var(--border) !important;
    }

    #rede-cadastro-overlay > div > div:last-child > button {
        width: auto;
        flex: 1 1 0;
        min-height: 44px;
        margin: 0 !important;
        padding: 9px 12px !important;
        border-radius: 11px !important;
        box-shadow: none !important;
    }

    #section-central div[style*="grid-template-columns:340px 1fr"],
    #section-central div[style*="grid-template-columns: 340px 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Formulários e modais */
    .v2-modal-overlay,
    [id$="-modal"][style*="position:fixed"] {
        padding: 0 !important;
    }

    .v2-modal,
    .v2-report-modal,
    .ldr-container,
    [id$="-modal"][style*="position:fixed"] > div[style*="position:relative"] {
        width: 100% !important;
        max-width: none !important;
        max-height: 92dvh !important;
        min-height: 0 !important;
        border-radius: 18px 18px 0 0 !important;
    }

    .ldr-grid,
    .ldr-grid-3,
    .ldr-grid[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    .ldr-span-2 {
        grid-column: auto;
    }

    .ldr-body,
    .v2-modal-body {
        padding: 16px !important;
    }

    .v2-modal-footer {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .v2-modal-footer .btn {
        justify-content: center;
    }

    #lh-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        padding-inline: 14px !important;
    }

    #lh-tabs {
        overflow-x: auto;
        padding-inline: 14px !important;
    }

    #lh-timeline {
        padding-inline: 14px !important;
    }

    #city-detail-drawer {
        width: 100% !important;
        max-width: none !important;
        height: 100dvh !important;
    }

    #city-detail-drawer > div[style*="grid-template-columns:1fr 1fr 1fr"] {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        padding-inline: 12px !important;
    }

    #copilot-window {
        border-radius: 16px 16px 0 0 !important;
    }
}

@media (max-width: 480px) {
    :root {
        --mobile-page-pad: 10px;
    }

    .v2-mobile-nav {
        padding-inline: 3px;
    }

    .v2-mobile-nav button {
        font-size: 9px;
    }

    .crm-crumb {
        display: none;
    }

    .dash-strip,
    .dash-strip-operacional,
    .dash-today-grid,
    .mon-kpi-grid,
    #cc-summary,
    #pc-kpis,
    #dia-regions,
    .pv-kpi-row {
        grid-template-columns: 1fr !important;
    }

    .dash-stat-cell,
    .dash-stat-cell:nth-last-child(-n+2) {
        border-bottom: 1px solid var(--border);
    }

    .dash-stat-cell:last-child {
        border-bottom: 0;
    }

    .v2-page-title,
    .pv-page-title,
    .crm-page-title,
    .mon-title {
        font-size: 21px;
    }

    .v2-header-actions,
    .crm-actions,
    .dash-actions,
    .v2-modal-footer {
        grid-template-columns: 1fr;
    }

    .v2-header-actions,
    .crm-actions,
    .dash-actions {
        display: grid;
    }

    .v2-header-actions > *,
    .crm-actions > *,
    .dash-actions > * {
        width: 100%;
    }

    .crm-view-toggle {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .crm-view-btn span {
        display: inline;
    }

    .crm-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .crm-actions .crm-view-toggle,
    #btn-new-leader,
    #btn-simulate {
        grid-column: 1 / -1;
    }

    #cc-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    #pc-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    #pc-kpis > .pc-kpi:last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }

    #pc-kpis .pc-kpi {
        padding: 13px;
    }

    #view-estoque > div[style*="grid-template-columns:repeat(3"] {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    #city-detail-drawer > div[style*="grid-template-columns:1fr 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
}

/* ============================================================
   Preenchimento de dados no mobile
   Unifica cadastros, edições e confirmações como folhas inferiores.
   ============================================================ */
@media (max-width: 768px) {
    :where(
        .v2-modal-overlay,
        [id$="-modal"][style*="position:fixed"],
        [id^="modal-"][style*="position:fixed"]
    ) {
        align-items: flex-end !important;
        justify-content: center !important;
        padding: 0 !important;
        background: rgba(15, 15, 18, .54) !important;
        backdrop-filter: blur(10px) !important;
    }

    :where(
        .v2-modal-overlay > .v2-modal,
        .v2-modal-overlay > .v2-report-modal,
        [id$="-modal"][style*="position:fixed"] > div[style*="position:relative"],
        [id^="modal-"][style*="position:fixed"] > div[style*="position:relative"],
        [id^="modal-"][style*="position:fixed"][style*="background:"] > div:first-child,
        #modal-confirm > .v2-confirm
    ) {
        width: 100% !important;
        max-width: none !important;
        max-height: 92dvh !important;
        min-height: 0 !important;
        margin: 0 !important;
        border: 0 !important;
        border-radius: 20px 20px 0 0 !important;
        box-shadow: 0 -10px 34px rgba(0, 0, 0, .2) !important;
    }

    :where(
        .v2-modal-overlay,
        [id$="-modal"][style*="position:fixed"],
        [id^="modal-"][style*="position:fixed"]
    ) :where(
        input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
        select,
        textarea
    ) {
        width: 100%;
        min-width: 0;
        min-height: 44px;
        border-radius: 10px !important;
        font-size: 16px !important;
        line-height: 1.25;
        box-shadow: none !important;
    }

    :where(
        .v2-modal-overlay,
        [id$="-modal"][style*="position:fixed"],
        [id^="modal-"][style*="position:fixed"]
    ) textarea {
        min-height: 84px;
        resize: vertical;
    }

    :where(
        .v2-modal-overlay,
        [id$="-modal"][style*="position:fixed"],
        [id^="modal-"][style*="position:fixed"]
    ) :where(.v2-label, .pc-modal-lbl, label) {
        line-height: 1.3;
    }

    .v2-modal-header,
    .v2-report-header {
        flex: 0 0 auto;
        padding: 14px 16px 12px !important;
        background: var(--bg-card) !important;
    }

    .v2-modal-title,
    .v2-report-title {
        font-size: 15px !important;
        line-height: 1.2;
    }

    .v2-modal-body,
    .v2-report-terminal {
        min-height: 0;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        overscroll-behavior: contain;
        padding: 14px 16px 18px !important;
    }

    .v2-modal-footer,
    .v2-report-footer {
        position: relative;
        flex: 0 0 auto;
        display: flex !important;
        gap: 8px !important;
        padding: 10px 16px calc(10px + env(safe-area-inset-bottom)) !important;
        background: var(--bg-card) !important;
        box-shadow: 0 -1px 0 var(--border);
    }

    .v2-modal-footer > .btn,
    .v2-report-footer > .btn {
        flex: 1 1 0 !important;
        min-width: 0;
        min-height: 44px;
        margin: 0 !important;
        padding-inline: 10px;
        justify-content: center;
    }

    /* CRM / Lideranças: duas colunas úteis e seções abertas. */
    #modal-leader .ldr-header {
        padding: 13px 16px 11px !important;
        background: var(--bg-card) !important;
    }

    #modal-leader .ldr-header-icon {
        width: 32px;
        height: 32px;
        border-radius: 9px;
        box-shadow: none;
    }

    #modal-leader .ldr-title {
        font-size: 15px !important;
    }

    #modal-leader .ldr-sub {
        font-size: 10px;
    }

    #modal-leader .ldr-body {
        gap: 8px !important;
        padding: 10px 16px 18px !important;
    }

    #modal-leader [data-leader-step] {
        gap: 0 !important;
    }

    #modal-leader .ldr-section {
        padding: 14px 0 !important;
        border: 0 !important;
        border-top: 1px solid var(--border) !important;
        border-radius: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
    }

    #modal-leader [data-leader-step] > .ldr-section:first-child {
        border-top: 0 !important;
    }

    #modal-leader .ldr-section-head {
        margin-bottom: 10px !important;
        padding-bottom: 0 !important;
        border: 0 !important;
        font-size: 10px !important;
    }

    #modal-leader .ldr-section-head::after {
        display: none !important;
    }

    #modal-leader .ldr-grid,
    #modal-leader .ldr-grid-3,
    #modal-leader .ldr-grid[style*="grid-template-columns"] {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }

    #modal-leader .ldr-grid-1 {
        grid-template-columns: 1fr !important;
    }

    #modal-leader .ldr-span-2,
    #modal-leader [data-leader-step="1"] > .ldr-section:first-child .ldr-grid > .v2-form-group:first-child,
    #modal-leader [data-leader-step="2"] > .ldr-section:first-child .ldr-grid:nth-of-type(2) > .v2-form-group:last-child,
    #modal-leader [data-leader-step="2"] > .ldr-section:nth-child(2) .ldr-grid > .v2-form-group:last-child {
        grid-column: 1 / -1 !important;
    }

    #modal-leader .ldr-footer > div[style*="flex:1"] {
        display: none !important;
    }

    #modal-leader .ldr-footer .btn {
        flex: 1 1 0;
        min-width: 0;
        padding-inline: 8px;
    }

    #modal-leader .ldr-save span {
        font-size: 0;
    }

    #modal-leader .ldr-save span::after {
        content: "Salvar";
        font-size: 12px;
    }

    /* Pares de campos dentro dos demais cadastros. */
    :where(
        #rep-cadastro-modal,
        #pc-action-modal,
        #pc-exec-modal,
        #arq-partner-modal,
        #arq-scenario-modal,
        #modal-estoque-item,
        #modal-estoque-mov,
        #aq-triage-modal,
        #cob-just-modal
    ) div[style*="display:grid"][style*="grid-template-columns"] {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }

    #pc-action-modal > div,
    #pc-exec-modal > div {
        display: flex !important;
        flex-direction: column;
        overflow: hidden;
    }

    #pc-action-modal > div > div:nth-child(2),
    #pc-exec-modal > div > div:nth-child(2) {
        min-height: 0;
        overflow-y: auto !important;
        overscroll-behavior: contain;
        padding: 12px 16px 18px !important;
    }

    #pc-action-modal > div > div:first-child,
    #pc-exec-modal > div > div:first-child {
        padding: 13px 16px 11px !important;
    }

    #pc-action-modal > div > div:last-child,
    #pc-exec-modal > div > div:last-child {
        flex: 0 0 auto;
        gap: 8px !important;
        padding: 10px 16px calc(10px + env(safe-area-inset-bottom)) !important;
        background: var(--bg-card);
    }

    #pc-action-modal > div > div:last-child > div {
        flex: 1 1 auto;
        display: flex;
        gap: 8px !important;
        margin-left: 0 !important;
    }

    #pc-action-modal > div > div:last-child .btn,
    #pc-exec-modal > div > div:last-child .btn {
        flex: 1 1 0;
        min-width: 0;
        justify-content: center;
    }

    :where(
        #modal-estoque-item,
        #modal-estoque-mov,
        #modal-estoque-hist,
        #modal-hist-detail
    ) > div:first-child {
        overflow-y: auto !important;
        overscroll-behavior: contain;
        padding: 18px 16px calc(16px + env(safe-area-inset-bottom)) !important;
    }

    #mov-lider-suggestions,
    #mov-dest-cidade-suggestions {
        max-height: min(34dvh, 220px) !important;
    }
}

@media (max-width: 420px) {
    :where(
        #pc-action-modal,
        #pc-exec-modal,
        #arq-partner-modal,
        #arq-scenario-modal,
        #modal-estoque-item,
        #modal-estoque-mov,
        #aq-triage-modal,
        #cob-just-modal
    ) div[style*="display:grid"][style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    #modal-leader .ldr-grid,
    #modal-leader .ldr-grid-3,
    #modal-leader .ldr-grid[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    #modal-leader .ldr-footer {
        padding-inline: 10px !important;
    }
}

/* Ações mobile com contraste suave, no padrão iOS. */
@media (max-width: 768px) {
    :where(
        .btn.btn-primary,
        .btn.btn-brand,
        #pc-btn-new,
        .pc-tab.active,
        .crm-view-btn.active,
        .pv-tab.active,
        .rede-tabs button.active
    ) {
        color: var(--primary) !important;
        background: color-mix(in srgb, var(--primary) 10%, var(--bg-card)) !important;
        border: 1px solid color-mix(in srgb, var(--primary) 24%, var(--border)) !important;
        box-shadow: none !important;
    }

    :where(
        .btn.btn-primary,
        .btn.btn-brand,
        #pc-btn-new,
        .pc-tab.active,
        .crm-view-btn.active,
        .pv-tab.active,
        .rede-tabs button.active
    ) :where(svg, .lc, .lc-nav) {
        color: currentColor !important;
        stroke: currentColor !important;
    }

    :where(
        .btn.btn-primary,
        .btn.btn-brand,
        #pc-btn-new,
        .pc-tab,
        .crm-view-btn,
        .pv-tab,
        .rede-tabs button
    ):active {
        background: color-mix(in srgb, var(--primary) 16%, var(--bg-card)) !important;
        transform: scale(.985);
    }

    :where(
        .btn.btn-primary,
        .btn.btn-brand,
        #pc-btn-new,
        .pc-tab,
        .crm-view-btn,
        .pv-tab,
        .rede-tabs button
    ):focus-visible {
        outline: 2px solid color-mix(in srgb, var(--primary) 42%, transparent);
        outline-offset: 2px;
    }

    .rede-tabs button.active .cnt {
        color: var(--primary) !important;
        background: color-mix(in srgb, var(--primary) 12%, transparent) !important;
    }
}

/* ============================================================
   Refinamento mobile — hierarquia, toque e acabamento
   ============================================================ */
@media (max-width: 768px) {
    .v2-main {
        scroll-padding-top: 12px;
        scroll-padding-bottom: calc(92px + env(safe-area-inset-bottom));
    }

    .v2-main > [id^="view-"],
    .v2-content > [id^="view-"] {
        animation-duration: .2s !important;
    }

    .v2-page-eyebrow,
    .mon-eyebrow,
    .crm-crumb,
    .pv-crumb,
    .dash-crumb {
        letter-spacing: .055em;
    }

    .v2-page-title,
    .pv-page-title,
    .crm-page-title,
    .mon-title,
    .dash-title,
    #view-estoque h1 {
        font-size: clamp(22px, 7vw, 27px) !important;
        letter-spacing: -.035em !important;
        line-height: 1.08;
    }

    .v2-page-subtitle,
    .pv-page-sub,
    .crm-page-sub,
    .mon-subtitle,
    .dash-subtitle {
        max-width: 36rem;
        line-height: 1.45;
    }

    /* Tema e saída já ficam disponíveis no menu da conta no mobile. */
    #btn-theme-toggle,
    #btn-logout,
    #btn-theme-toggle-crm,
    #btn-logout-crm {
        display: none !important;
    }

    .v2-bento-card,
    .v2-kpi-card,
    .dash-panel,
    .dash-strip,
    .crm-kpi-strip,
    .crm-toolbar,
    .crm-panel,
    .pc-card,
    .pc-kpi,
    .pv-panel,
    .pv-facets,
    .mon-panel,
    .mon-kpi-card,
    .rede-panel,
    .rede-grid-wrap {
        border-radius: 14px;
        box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
    }

    .btn,
    .pc-tab,
    .pv-tab,
    .crm-view-btn,
    .rede-tabs button {
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .btn:active,
    .pc-tab:active,
    .pv-tab:active,
    .crm-view-btn:active,
    .v2-mobile-nav button:active {
        transform: scale(.98);
    }

    .v2-mobile-nav {
        min-height: 68px;
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    }

    .v2-mobile-nav button {
        min-height: 54px;
        border-radius: 12px;
        transition: color .16s ease, background-color .16s ease, transform .12s ease;
    }

    .v2-mobile-nav button.active svg {
        transform: translateY(-1px);
        stroke-width: 2.35;
    }

    #copilot-fab {
        width: 48px !important;
        height: 48px !important;
        right: 10px !important;
        bottom: calc(78px + env(safe-area-inset-bottom)) !important;
        box-shadow: 0 8px 24px rgba(68, 76, 231, .28) !important;
    }

    #copilot-fab svg {
        width: 21px !important;
        height: 21px !important;
    }

    /* Agenda: três opções na primeira linha, duas equilibradas na segunda. */
    #view-plano-campo > div[style*="width:fit-content"] {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }

    #view-plano-campo > div[style*="width:fit-content"] > .pc-tab {
        grid-column: span 2;
    }

    #view-plano-campo > div[style*="width:fit-content"] > .pc-tab:nth-child(n + 4) {
        grid-column: span 3;
    }

    /* Central: as três áreas principais viram um controle segmentado estável. */
    #cc-tabs {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        width: 100%;
        overflow: hidden;
    }

    #cc-tabs button {
        min-width: 0;
        padding-inline: 6px;
        justify-content: center;
    }

    #aq-filters > button {
        min-height: 34px;
    }

    .pv-rank-votes,
    .pv-party-pct,
    .crm-kpi-val,
    .pc-kpi-val,
    .mon-kpi-value {
        font-variant-numeric: tabular-nums;
    }
}

@media (max-width: 380px) {
    :root {
        --mobile-page-pad: 8px;
    }

    .v2-mobile-nav button {
        font-size: 8.5px;
    }

    .v2-mobile-nav button svg {
        width: 18px;
        height: 18px;
    }

    #copilot-fab {
        width: 44px !important;
        height: 44px !important;
        right: 8px !important;
    }

    .crm-actions {
        grid-template-columns: 1fr;
    }

    .crm-actions > *,
    .crm-actions .crm-view-toggle,
    #btn-new-leader,
    #btn-simulate {
        grid-column: 1;
    }

    .crm-view-toggle {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .crm-kpi,
    #pc-kpis .pc-kpi,
    #cc-summary .mon-kpi-card {
        padding: 12px 10px;
    }

    .crm-kpi-meta,
    .pc-kpi-sub,
    .mon-kpi-sub {
        font-size: 10px;
    }
}

/* ============================================================
   Auditoria mobile geral — sem estouro horizontal
   ============================================================ */
@media (max-width: 768px) {
    html,
    body,
    .v2-app,
    .v2-main,
    .v2-content,
    .v2-main > [id^="view-"] {
        max-width: 100%;
        overflow-x: hidden;
    }

    .v2-main > [id^="view-"] > *,
    .v2-content > [id^="view-"] > * {
        min-width: 0;
        max-width: 100%;
    }

    .v2-main :where(input, select, textarea)[style*="min-width"] {
        min-width: 0 !important;
    }

    /* Agenda inicial */
    #view-plano-campo {
        gap: 12px !important;
    }

    #view-plano-campo .v2-page-header {
        margin-bottom: 0;
    }

    #view-plano-campo .v2-header-actions,
    #view-plano-campo #pc-btn-new {
        width: 100%;
    }

    #view-plano-campo #pc-btn-new {
        justify-content: center;
    }

    #pc-kpis {
        gap: 8px !important;
    }

    #pc-kpis .pc-kpi {
        min-width: 0;
        min-height: 104px;
        padding: 12px !important;
    }

    #pc-kpis .pc-kpi-lbl {
        font-size: 9px;
        line-height: 1.25;
    }

    #pc-kpis .pc-kpi-val {
        font-size: 20px;
    }

    #view-plano-campo > div[style*="width:fit-content"] {
        position: static;
        grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
        border-radius: 12px !important;
    }

    #view-plano-campo > div[style*="width:fit-content"] > .pc-tab {
        grid-column: span 2;
        min-height: 42px;
        font-size: 11px;
        line-height: 1.2;
    }

    #view-plano-campo > div[style*="width:fit-content"] > .pc-tab:nth-child(n + 4) {
        grid-column: span 3;
    }

    #pc-tab-cidades .pc-card-head {
        padding: 12px !important;
    }

    #pc-tab-cidades .pc-card-head > div {
        display: grid !important;
        grid-template-columns: 1fr !important;
        align-items: stretch !important;
        gap: 10px !important;
    }

    #pc-tab-cidades .pc-card-head > div > div[style*="flex:1"] {
        display: none !important;
    }

    #pc-tab-cidades .pc-card-head > div > div[style*="position:relative"] {
        width: 100%;
    }

    #pc-cidades-search {
        width: 100% !important;
        min-width: 0 !important;
        min-height: 42px;
        padding-left: 30px !important;
        border-color: var(--border);
        background: var(--bg-input);
    }

    #pc-tab-cidades .pc-card-head label {
        min-height: 40px;
        padding: 8px 10px;
        border-radius: 9px;
        background: var(--bg-elevated);
    }

    /* Tabelas operacionais viram cartões legíveis no telefone. */
    .crm-list-tablewrap,
    .pc-card:has(.pc-table),
    .pc-card:has(.pc-table) > div[style*="overflow-x:auto"] {
        max-height: none !important;
        overflow: visible !important;
    }

    .crm-list-table,
    .pc-table {
        display: block;
        width: 100%;
        min-width: 0 !important;
    }

    .crm-list-table thead,
    .pc-table thead {
        display: none;
    }

    .crm-list-table tbody,
    .pc-table tbody {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 8px;
    }

    .crm-list-table tbody tr,
    .pc-table tbody tr {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 9px 12px;
        padding: 12px;
        border: 1px solid var(--border);
        border-radius: 12px;
        background: var(--bg-card);
        box-shadow: 0 1px 2px rgba(0, 0, 0, .03);
    }

    .crm-list-table tbody td,
    .pc-table tbody td {
        display: flex;
        min-width: 0;
        padding: 0 !important;
        border: 0 !important;
        text-align: left !important;
        flex-direction: column;
        align-items: flex-start;
        gap: 3px;
        overflow-wrap: anywhere;
    }

    .crm-list-table tbody td[data-label]::before,
    .pc-table tbody td[data-label]::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-size: 8px;
        font-weight: 800;
        line-height: 1.2;
        letter-spacing: .07em;
        text-transform: uppercase;
    }

    .crm-list-table tbody td[colspan],
    .pc-table tbody td[colspan] {
        grid-column: 1 / -1;
        align-items: center;
    }

    #pc-tab-cidades .pc-table tbody tr {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    #pc-tab-cidades .pc-table tbody td:nth-child(1) {
        grid-column: 1 / 4;
        font-size: 14px;
    }

    #pc-tab-cidades .pc-table tbody td:nth-child(2) {
        grid-column: 1 / 3;
    }

    #pc-tab-cidades .pc-table tbody td:nth-child(9) {
        grid-column: 3 / 5;
    }

    #pc-tab-cidades .pc-table tbody td:nth-child(10) {
        grid-column: 4;
        grid-row: 1;
        align-items: flex-end;
        justify-content: center;
    }

    #pc-tab-cidades .pc-row-actions {
        gap: 6px;
    }

    #pc-tab-cidades .pc-icon-btn {
        min-width: 34px;
        min-height: 34px;
        border: 1px solid var(--border);
        border-radius: 9px;
    }

    #pc-tab-tarefas .pc-table tbody td:nth-child(1) {
        grid-column: 1;
    }

    #pc-tab-tarefas .pc-table tbody td:nth-child(2) {
        grid-column: 1 / -1;
        grid-row: 1;
        padding-right: 42px !important;
    }

    #pc-tab-tarefas .pc-table tbody td:last-child {
        grid-column: 2;
        grid-row: 1;
        align-items: flex-end;
    }

    #pc-drawer-body .pc-table tbody td:first-child {
        grid-column: 1 / -1;
        font-size: 13px;
    }

    .crm-list-table tbody tr {
        grid-template-columns: 34px minmax(0, 1fr) auto;
    }

    .crm-list-table tbody td:nth-child(1) {
        grid-column: 1;
        grid-row: 1 / 3;
        justify-content: center;
    }

    .crm-list-table tbody td:nth-child(2) {
        grid-column: 2 / 4;
        grid-row: 1;
        font-size: 14px;
    }

    .crm-list-table tbody td:nth-child(3) {
        grid-column: 2;
        grid-row: 2;
    }

    .crm-list-table tbody td:nth-child(6) {
        grid-column: 3;
        grid-row: 2;
        align-items: flex-end;
    }

    .crm-list-table tbody td:nth-child(4),
    .crm-list-table tbody td:nth-child(5) {
        grid-column: auto;
    }

    /* Roteiro semanal deixa de exigir arraste horizontal. */
    .pc-card:has(.pc-week-grid) {
        overflow: hidden !important;
    }

    .pc-week-grid {
        width: 100%;
        min-width: 0 !important;
        grid-template-columns: 1fr !important;
        gap: 7px !important;
    }

    .pc-week-day {
        display: grid;
        grid-template-columns: 74px minmax(0, 1fr);
        align-items: start;
        min-height: 64px;
        padding: 9px;
    }

    .pc-week-day-header {
        grid-column: 1;
        padding-top: 5px;
    }

    .pc-week-day > :not(.pc-week-day-header) {
        grid-column: 2;
    }

    #pc-tab-roteiro .pc-card > div:last-child {
        padding: 10px !important;
    }

    #pc-tab-roteiro .pc-card-head > div {
        gap: 8px !important;
    }

    #pc-tab-roteiro .pc-card-head > div > div[style*="flex:1"] {
        display: none !important;
    }

    #pc-tab-roteiro .pc-card-head > div > div:last-child {
        width: 100%;
        justify-content: space-between;
    }

    /* Drawer da Agenda */
    #pc-city-drawer,
    #all-cities-drawer,
    #party-detail-drawer,
    #city-rank-drawer {
        width: 100% !important;
        max-width: none !important;
        border-left: 0 !important;
        border-right: 0 !important;
    }

    #pc-drawer-head {
        padding: 14px !important;
    }

    #pc-drawer-head div[style*="grid-template-columns:repeat(6"] {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }

    #pc-city-drawer > div:nth-child(2) {
        display: grid !important;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 4px !important;
        padding: 7px 8px !important;
    }

    #pc-city-drawer .pc-drawer-tab {
        min-width: 0;
        min-height: 40px;
        padding: 6px 4px;
        font-size: 10.5px;
    }

    #pc-drawer-body {
        padding: 12px !important;
    }

    /* Administração */
    #view-usuarios > div:first-child,
    #view-historico > div:first-child {
        align-items: stretch !important;
        flex-direction: column;
    }

    #btn-refresh-users,
    #btn-refresh-historico {
        width: 100%;
        justify-content: center;
    }

    #invite-form > div:first-child,
    #invite-result > div:nth-child(2) {
        align-items: stretch !important;
        flex-direction: column;
    }

    #invite-form > div:first-child > div {
        width: 100%;
        min-width: 0 !important;
    }

    #btn-invite-generate,
    #btn-invite-copy {
        width: 100%;
        justify-content: center;
    }

    #view-usuarios .v2-bento-card > div[style*="display:flex"][style*="flex-wrap:wrap"] {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #view-usuarios .v2-bento-card > div[style*="display:flex"][style*="flex-wrap:wrap"] > label,
    #view-usuarios .v2-bento-card > div[style*="display:flex"][style*="flex-wrap:wrap"] > div {
        grid-column: 1 / -1;
        width: auto !important;
        height: auto !important;
        margin: 0 !important;
    }

    #view-historico > div:nth-child(2) {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: stretch !important;
    }

    #view-historico > div:nth-child(2) > :where(select, button) {
        width: 100%;
        min-width: 0 !important;
    }

    #hist-counter {
        grid-column: 1 / -1;
        margin-left: 0 !important;
        text-align: center;
    }

    #users-list,
    #historico-list {
        max-height: none !important;
        overflow: visible !important;
        padding-right: 0 !important;
    }

    #historico-pagination[style*="display:flex"] {
        display: grid !important;
        grid-template-columns: 1fr auto 1fr;
        width: 100%;
    }

    #historico-pagination .btn {
        min-width: 0;
        padding-inline: 8px !important;
        justify-content: center;
    }

    #hist-page-info {
        min-width: 0 !important;
    }

    /* Simulação rápida do CRM */
    #sim-quick-add > div:last-child {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: end !important;
    }

    #sim-quick-add .v2-form-group:first-child,
    #sim-add-btn {
        grid-column: 1 / -1;
        width: 100% !important;
        min-width: 0 !important;
    }

    #sim-quick-add .v2-form-group {
        width: 100% !important;
        min-width: 0 !important;
    }

    /* Copilot e painéis flutuantes nunca ultrapassam o telefone. */
    #copilot-window {
        inset: auto 0 0 0 !important;
        width: 100% !important;
        max-width: none !important;
        height: min(76dvh, 680px) !important;
        max-height: none !important;
        border-left: 0 !important;
        border-right: 0 !important;
        border-bottom: 0 !important;
    }

    /* Modais do mapa estratégico e diálogos da Rede seguem o mesmo padrão. */
    .estr-modal-backdrop,
    #rede-meta-overlay,
    #rede-newparent-overlay {
        align-items: flex-end !important;
        padding: 0 !important;
        background: rgba(15, 15, 18, .54) !important;
        backdrop-filter: blur(10px) !important;
    }

    .estr-modal,
    #rede-meta-overlay > div,
    #rede-newparent-overlay > div {
        width: 100% !important;
        max-width: none !important;
        max-height: 92dvh !important;
        margin: 0 !important;
        border: 0 !important;
        border-radius: 20px 20px 0 0 !important;
        box-shadow: 0 -10px 34px rgba(0, 0, 0, .2) !important;
    }

    .estr-modal-head {
        padding: 14px 16px 12px !important;
    }

    .estr-modal-head h3 {
        font-size: 15px !important;
    }

    .estr-modal-body {
        padding: 14px 16px 18px !important;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .estr-modal-foot {
        padding: 10px 16px calc(10px + env(safe-area-inset-bottom)) !important;
        background: var(--bg-card);
    }

    .estr-modal-foot > button {
        flex: 1 1 0;
        min-width: 0;
        min-height: 44px;
        justify-content: center;
    }

    .estr-field :where(input, select, textarea),
    #rede-meta-overlay input,
    #rede-newparent-overlay :where(input, select, textarea) {
        width: 100%;
        min-width: 0;
        min-height: 44px;
        border-radius: 10px !important;
        font-size: 16px !important;
    }
}

@media (max-width: 420px) {
    #pc-tab-cidades .pc-table tbody tr {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #pc-tab-cidades .pc-table tbody td:nth-child(1) {
        grid-column: 1 / 2;
    }

    #pc-tab-cidades .pc-table tbody td:nth-child(2),
    #pc-tab-cidades .pc-table tbody td:nth-child(9) {
        grid-column: 1 / -1;
    }

    #pc-tab-cidades .pc-table tbody td:nth-child(10) {
        grid-column: 2;
    }

    #view-historico > div:nth-child(2),
    #view-usuarios .v2-bento-card > div[style*="display:flex"][style*="flex-wrap:wrap"],
    #sim-quick-add > div:last-child {
        grid-template-columns: 1fr !important;
    }

    #view-usuarios .v2-bento-card > div[style*="display:flex"][style*="flex-wrap:wrap"] > * {
        grid-column: 1 !important;
        width: 100%;
        justify-content: center;
    }
}
