/* Navegación móvil: reutiliza el menú y sus permisos existentes. */
.mobile-menu-toggle { display: none; }
@media (max-width: 980px) {
  #app-shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  #app-shell .sidebar { position: sticky; top: 0; z-index: 30; width: 100%; height: auto; max-height: 90vh; max-height: 90dvh; overflow-y: auto; display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; gap: 0; padding: 8px 12px; box-sizing: border-box; border-bottom: 1px solid var(--line); }
  #app-shell .sidebar .brand { padding: 0; min-height: 44px; }
  #app-shell .sidebar .sidebar-control { display: none; }
  #mobile-menu-toggle { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; min-width: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; }
  #mobile-menu-toggle[aria-expanded="true"] { background: var(--primary-soft); border-color: var(--primary); }
  #mobile-menu-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
  #app-shell #module-nav { display: none; grid-column: 1 / -1; overflow: visible; padding: 8px 0; }
  #app-shell.mobile-menu-open #module-nav { display: grid; gap: 4px; }
  #app-shell #module-nav .module-nav-group { width: 100%; position: static; }
  #app-shell #module-nav .module-button { display: flex; width: 100%; min-height: 46px; align-items: center; justify-content: flex-start; gap: 12px; padding: 10px 12px; }
  #app-shell #module-nav .module-button > span:not(.module-icon), #app-shell #module-nav .module-button b { display: block; }
  #app-shell #module-nav .module-expand-indicator { margin-left: auto; }
  #app-shell #module-nav .module-subnav:not([hidden]) { display: grid; position: static; width: auto; margin: 4px 0 8px 20px; padding: 0 0 0 12px; gap: 4px; overflow: visible; border-left: 1px solid var(--line); background: transparent; }
  #app-shell #module-nav .module-subnav::before { display: none; }
  #app-shell #module-nav .module-subnav-button { width: 100%; min-height: 44px; padding: 10px 12px; white-space: normal; text-align: left; }
  #app-shell #module-nav [hidden] { display: none !important; }
}

/* Acciones compactas y navegación superpuesta solo en pantallas pequeñas. */
.mobile-export-group, .mobile-export-options { display: contents; }
.mobile-export-toggle { display: none; }
@media (max-width: 980px) {
  body.mobile-navigation-locked { overflow: hidden; }
  #app-shell.mobile-menu-open .sidebar { position: fixed; inset: 0; height: 100vh; height: 100dvh; max-height: none; z-index: 1000; grid-template-rows: 44px minmax(0, 1fr); overflow: hidden; padding-bottom: env(safe-area-inset-bottom, 8px); }
  #app-shell.mobile-menu-open #module-nav { overflow-y: auto; overscroll-behavior: contain; min-height: 0; align-content: start; touch-action: pan-y; }
  #app-shell .sidebar .brand { justify-items: start; }
  #app-shell .transfer-toolbar-actions { display: flex; flex-direction: row; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
  #app-shell .transfer-toolbar-actions .control-button { width: auto; }
  #app-shell .board-copy-button { width: 44px; min-width: 44px; height: 44px; padding: 10px; justify-content: center; }
  #app-shell .board-copy-button span { display: none; }
  #app-shell :is([data-transfer-filter-open], #module-filter-button, #transfer-export-button, [data-bwrf-toggle], [data-wulc-filter-toggle], .lsp-weekly-filter-trigger) { font-size: 0; width: 44px; min-width: 44px; min-height: 44px; padding: 10px; gap: 0; justify-content: center; }
  #app-shell :is([data-transfer-filter-open], #module-filter-button, #transfer-export-button, [data-bwrf-toggle], [data-wulc-filter-toggle], .lsp-weekly-filter-trigger) > * { display: none; }
  #app-shell :is([data-transfer-filter-open], #module-filter-button, [data-bwrf-toggle], [data-wulc-filter-toggle], .lsp-weekly-filter-trigger)::before { content: ''; display: block; width: 20px; height: 20px; background: currentColor; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 4h18l-7 8v7l-4 2v-9z'/%3E%3C/svg%3E") center / contain no-repeat; }
  #app-shell #transfer-export-button::before { content: ''; display: block; width: 20px; height: 20px; background: currentColor; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 3v12m-5-5 5 5 5-5M4 16v5h16v-5' fill='none' stroke='black' stroke-width='2'/%3E%3C/svg%3E") center / contain no-repeat; }
  #app-shell .mobile-export-group { display: inline-block; position: relative; flex: 0 0 auto; }
  #app-shell .mobile-export-toggle { display: inline-flex; align-items: center; justify-content: center; width: 44px; min-height: 44px; padding: 10px; }
  #app-shell .mobile-export-options { display: none; }
  #app-shell .mobile-export-toggle[aria-expanded="true"] + .mobile-export-options { display: grid; gap: 4px; position: absolute; right: 0; top: calc(100% + 6px); min-width: 160px; padding: 8px; z-index: 45; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-soft); }
  #app-shell .mobile-export-options .control-button { width: 100%; min-height: 44px; white-space: nowrap; }
}

.mobile-profile-toggle { display: none; }
@media (max-width: 980px) {
  #app-shell .sidebar { grid-template-columns: minmax(0, 1fr) auto auto; column-gap: 8px; overflow: visible; }
  #mobile-profile-toggle { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); cursor: pointer; }
  #mobile-profile-toggle[aria-expanded="true"] { background: var(--primary-soft); }
  #mobile-profile-panel:not([hidden]) { display: block; position: absolute; top: calc(100% + 6px); right: 12px; width: min(320px, calc(100vw - 24px)); padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-soft); z-index: 60; }
  #mobile-profile-panel .top-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-start; }
  #mobile-profile-panel #auth-slot { display: flex; flex-wrap: wrap; width: 100%; }
  #mobile-profile-panel .auth-user { max-width: 100%; white-space: normal; width: 100%; }
  #mobile-profile-panel #source-info-center { display: none; }
  #mobile-profile-panel .notification-popover { position: fixed; left: 12px; right: 12px; top: 180px; width: auto; max-height: calc(100dvh - 200px); overflow: auto; }
  #app-shell .topbar { padding-block: 12px; min-height: 0; }
  #app-shell :is(.analytics-board-toolbar, .leads-dashboard-toolbar.has-board-actions) { display: flex; align-items: center; flex-wrap: nowrap; gap: 8px; }
  #app-shell :is(.analytics-board-toolbar, .leads-dashboard-toolbar.has-board-actions) > div:first-child { flex: 1 1 70px; min-width: 0; overflow: hidden; }
  #app-shell :is(.analytics-board-toolbar, .leads-dashboard-toolbar.has-board-actions) > div:first-child strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #app-shell :is(.analytics-board-toolbar, .leads-dashboard-toolbar.has-board-actions) > div:first-child > span { display: none; }
  #app-shell .dashboard-board-actions { display: flex; flex: 0 1 auto; flex-wrap: nowrap; width: auto; min-width: 0; gap: 6px; }
  #app-shell .dashboard-board-actions .dashboard-save-status:not(.error) { display: none; }
  #app-shell .dashboard-board-actions select { width: 145px; min-width: 0; max-width: 38vw; text-overflow: ellipsis; }
}
@media (max-width: 980px) {
  #app-shell .dashboard-board-actions { max-width: 100%; overflow-x: auto; }
  #app-shell .dashboard-board-actions > * { flex-shrink: 0; }
  #app-shell .dashboard-board-actions select { flex-shrink: 1; }
}

/* La administración de publicaciones permanece disponible en escritorio. */
@media (max-width: 980px) {
  #app-shell .dashboard-board-actions :is(#board-edit-publication, #board-hide-publication, #board-set-default, #board-manage-access) { display: none; }
}
