/**
 * Estilos solo móvil (≤768px). Escritorio no se modifica.
 */

@media (max-width: 768px) {
  .portal-mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    margin: 0 4px 0 0;
    padding: 0;
    border: 1px solid rgba(26, 39, 68, 0.2);
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    color: var(--navy, #1a2744);
  }

  .portal-mobile-menu-btn[aria-expanded="true"] {
    background: rgba(26, 39, 68, 0.08);
  }

  .portal-mobile-menu-icon {
    display: block;
    width: 20px;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
    position: relative;
  }

  .portal-mobile-menu-icon::before,
  .portal-mobile-menu-icon::after {
    content: "";
    position: absolute;
    left: 0;
    width: 20px;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
  }

  .portal-mobile-menu-icon::before {
    top: -6px;
  }

  .portal-mobile-menu-icon::after {
    top: 6px;
  }

  body.portal-mobile-nav-open {
    overflow: hidden;
  }

  .portal-mobile-drawer {
    position: fixed;
    inset: 0;
    z-index: 10080;
    pointer-events: none;
    visibility: hidden;
    transition: visibility 0.2s;
  }

  .portal-mobile-drawer.is-open {
    pointer-events: auto;
    visibility: visible;
  }

  .portal-mobile-drawer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0;
    transition: opacity 0.2s;
  }

  .portal-mobile-drawer.is-open .portal-mobile-drawer-backdrop {
    opacity: 1;
  }

  .portal-mobile-drawer-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: min(300px, 88vw);
    height: 100%;
    background: #fffdf7;
    box-shadow: 4px 0 24px rgba(16, 32, 57, 0.18);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    overflow-y: auto;
    padding: 12px 0 24px;
    -webkit-overflow-scrolling: touch;
  }

  .portal-mobile-drawer.is-open .portal-mobile-drawer-panel {
    transform: translateX(0);
  }

  .portal-mobile-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px 14px;
    border-bottom: 1px solid rgba(26, 39, 68, 0.1);
    margin-bottom: 8px;
  }

  .portal-mobile-drawer-head strong {
    font-size: 14px;
    color: var(--navy, #1a2744);
  }

  .portal-mobile-drawer-close {
    appearance: none;
    border: 0;
    background: transparent;
    font-size: 22px;
    line-height: 1;
    padding: 8px;
    cursor: pointer;
    color: var(--navy, #1a2744);
    min-width: 44px;
    min-height: 44px;
  }

  .portal-mobile-nav-section {
    padding: 6px 14px 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #64748b;
  }

  .portal-mobile-nav-link {
    display: block;
    padding: 12px 14px;
    margin: 2px 8px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--navy, #1a2744);
    font-size: 15px;
    font-weight: 600;
    min-height: 44px;
    line-height: 1.3;
    box-sizing: border-box;
  }

  .portal-mobile-nav-link:active,
  .portal-mobile-nav-link:hover {
    background: rgba(201, 168, 76, 0.18);
  }

  .header .user-info #logoutButton {
    font-size: 11px;
  }

  .header .brand h2 {
    font-size: 15px;
  }

  .header .header-sub {
    display: none;
  }

  #app-view main,
  #portal-content main {
    padding: 16px 12px 20px;
  }

  #app-view .com-hub-grid,
  .com-hub-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  #app-view .com-hub-card,
  .com-hub-card {
    padding: 18px 16px;
    min-height: 44px;
  }

  #app-view .com-hub-card .count,
  .com-hub-card .count {
    font-size: 32px;
  }

  #app-view .com-hub-actions .btn,
  .com-hub-actions .btn {
    min-height: 44px;
    padding: 12px 16px;
    width: 100%;
    justify-content: center;
  }

  #app-view .cp-filters,
  .cp-filters {
    flex-direction: column;
    align-items: stretch;
  }

  #app-view .cp-filters .btn,
  .cp-filters .btn {
    min-height: 44px;
    width: 100%;
  }

  #app-view .cp-summary,
  .cp-summary {
    flex-direction: column;
  }

  #app-view .cp-summary .pill,
  .cp-summary .pill {
    width: 100%;
    text-align: center;
    padding: 10px 12px;
  }

  /* Tablas → tarjetas */
  .portal-table-cards .table-container {
    overflow: visible;
  }

  .portal-table-cards table.compact {
    border: 0;
  }

  .portal-table-cards table.compact thead {
    display: none;
  }

  .portal-table-cards table.compact tbody tr {
    display: block;
    margin-bottom: 12px;
    border: 1px solid var(--border, #dde4ee);
    border-radius: 12px;
    padding: 10px 12px;
    background: var(--surface, #fff);
    box-shadow: 0 2px 8px rgba(24, 37, 76, 0.06);
  }

  .portal-table-cards table.compact tbody tr.cp-row-pend-auth,
  .portal-table-cards table.compact tbody tr.project-row.active + tr,
  .portal-table-cards table.compact tbody tr:has(+ tr[style*="table-row"]) {
    /* detail rows stay block */
  }

  .portal-table-cards table.compact tbody tr.project-row + tr {
    margin-top: -8px;
    border-top: 0;
    border-radius: 0 0 12px 12px;
    padding-top: 0;
  }

  .portal-table-cards table.compact td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 0;
    border: 0;
    border-bottom: 1px solid rgba(221, 228, 238, 0.8);
    text-align: right;
    font-size: 13px;
  }

  .portal-table-cards table.compact td:last-child {
    border-bottom: 0;
    flex-direction: column;
    align-items: stretch;
  }

  .portal-table-cards table.compact td::before {
    content: attr(data-label);
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    color: #64748b;
    text-align: left;
    flex: 0 0 42%;
  }

  .portal-table-cards table.compact td .btn {
    min-height: 40px;
    margin-top: 4px;
  }

  .portal-table-cards .com-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
  }

  .portal-table-cards .com-row-actions .btn {
    flex: 1 1 auto;
    min-width: calc(50% - 4px);
  }
}

@media (min-width: 769px) {
  .portal-mobile-menu-btn,
  .portal-mobile-drawer {
    display: none !important;
  }
}
