/* ========================================
   MOBILE CSS — OfficeWork CRM
   Arquivo dedicado para otimizações mobile
   Breakpoint: max-width 767px
   ======================================== */

/* ── Badge dropdown: estilos desktop (base) ── */
.badge-dropdown {
  position: absolute;
  right: 0;
  margin-top: 0.5rem;
  width: 20rem;
  z-index: 50;
  border-color: var(--gc-color-border-strong) !important;
}

body > header {
  padding-top: var(--gc-safe-area-top);
  padding-left: var(--gc-safe-area-left);
  padding-right: var(--gc-safe-area-right);
}

body > footer {
  padding-right: var(--gc-safe-area-right);
  padding-bottom: var(--gc-safe-area-bottom);
  padding-left: var(--gc-safe-area-left);
}

/* O componente global de ações também define display. Esta regra base
   garante que o acionador do painel móvel nunca apareça no shell desktop. */
.mobile-hamburger.gc-action.gc-action--icon {
  display: none;
}

@media (max-width: 767px) {
  .custom-checkbox,
  .custom-radio,
  label:has(input[type="checkbox"]),
  label:has(input[type="radio"]) {
    min-height: 44px;
  }

  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="tel"],
  input[type="url"],
  input[type="search"],
  input[type="date"],
  input[type="month"],
  input[type="time"],
  input[type="datetime-local"],
  input[type="file"]:not(.hidden),
  select,
  textarea,
  .custom-select-wrapper .custom-select-button,
  .custom-date-text-input,
  .custom-date-button {
    min-height: 44px;
    font-size: 16px;
  }

  main .flex,
  main .grid,
  main form,
  main section,
  main header { min-width: 0; }

  main header.flex-col > .flex,
  .content-header > .flex > .flex,
  main > .flex.flex-col > .flex.items-center.justify-between > .flex,
  main > .flex.flex-col > .flex.items-start.justify-between > .flex {
    width: 100%;
    flex-wrap: wrap;
  }
  .content-header > .flex,
  main > .flex.flex-col > .flex.items-center.justify-between,
  main > .flex.flex-col > .flex.items-start.justify-between {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .grid-cols-24 {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .grid-cols-24 > [class*="col-span-"] {
    grid-column: 1 / -1 !important;
    min-width: 0;
  }

  .custom-date-dropdown { display: none; }
  .custom-date-wrapper.open .custom-date-dropdown {
    display: block;
    position: fixed;
    inset: 50% max(12px, var(--gc-safe-area-right)) auto max(12px, var(--gc-safe-area-left)) !important;
    width: auto;
    min-width: 0;
    max-height: calc(100vh - 24px);
    overflow-y: auto;
    transform: translateY(-50%);
    z-index: 10000;
  }

  main form .flex.gap-6,
  main form .flex.gap-4,
  main form .flex.gap-3 { flex-wrap: wrap; }
  main form .flex.gap-6 > [class*="w-["],
  main form .flex.gap-4 > [class*="w-["],
  main form .flex.gap-3 > [class*="w-["] {
    width: 100% !important;
    min-width: 0 !important;
  }

  .template-editor-container {
    flex-direction: column;
    height: auto;
    min-height: 0;
  }
  .template-sidebar-left,
  .template-sidebar-right {
    width: 100%;
    flex: none;
    overflow: visible;
  }

  main .overflow-x-auto {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  main section > header.flex { flex-wrap: wrap; }
  main section > header.flex > .flex { flex-wrap: wrap; }

  .sticky.-mx-6 {
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  header [class*="max-w-[55%]"] { max-width: 100% !important; }
  header [class*="max-w-[55%]"].flex { flex-wrap: wrap; }

  .item-image-layout { flex-direction: column; }
  .item-image-layout > .flex-1 { width: 100%; }
  .item-image-layout > .flex-1 > .flex { flex-wrap: wrap; }

  .package-financial-row {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .package-financial-row > * { min-width: 0; }

  main form .grid-cols-5 { grid-template-columns: minmax(0, 1fr) !important; }

  [class*="group-hover/tooltip"] { display: none !important; }

  /* Hamburger visible */
  .mobile-hamburger.gc-action.gc-action--icon {
    display: flex;
  }

  /* Desktop nav hidden */
  .desktop-nav-links {
    display: none !important;
  }

  /* Menu overlay + panel: only visible when .open is added by JS */
  .mobile-menu-overlay.open {
    display: block;
  }
  .mobile-menu-panel.open {
    display: block;
    transform: translateX(0);
    pointer-events: auto;
  }

  /* Header: 2 rows layout */
  .header-row-1 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
  }
  .header-row-2 {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid #f1f5f9;
    margin-top: 8px;
  }

  /* Hide summary cards on mobile */
  .mobile-hide-cards {
    display: none !important;
  }

  /* Hide export buttons */
  .mobile-hide-export {
    display: none !important;
  }

  /* Hide dashboard calendar section */
  .mobile-hide-calendar {
    display: none !important;
  }

  /* Hide profit gauge card */
  .mobile-hide-profit {
    display: none !important;
  }

  /* REGRA: Fullwidth mobile — todas as páginas usam largura total no mobile */
  main {
    max-width: 100% !important;
    padding-left: max(6px, var(--gc-safe-area-left)) !important;
    padding-right: max(6px, var(--gc-safe-area-right)) !important;
    padding-top: 12px !important;
    padding-bottom: 12px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  .mobile-menu-panel {
    padding-right: var(--gc-safe-area-right);
    padding-bottom: var(--gc-safe-area-bottom);
  }

  .badge-dropdown {
    max-width: calc(100vw - var(--gc-safe-area-left) - var(--gc-safe-area-right) - 12px);
  }

  /* ===== EDITOR FORMS ===== */

  /* Editor forms: stack fields vertically on mobile */
  .mobile-editor-form .flex.gap-3 {
    flex-wrap: wrap !important;
  }
  .mobile-editor-form .flex.gap-3 > div {
    width: 100% !important;
    min-width: 0 !important;
    flex: none !important;
  }
  .mobile-editor-form .flex.gap-3 > div[style*="width"] {
    width: 100% !important;
  }
  .mobile-editor-form .px-6 {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
  /* Editor section headers: stack title + buttons */
  .mobile-editor-form section > header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
  .mobile-editor-form section > header > .flex {
    flex-wrap: wrap !important;
    width: 100%;
  }
  /* Hide button text on mobile, show only icon */
  .mobile-btn-text {
    display: none !important;
  }
  /* Thicker icons on mobile for all buttons/links in editor page */
  .mobile-editor-actions svg,
  .mobile-editor-form button svg,
  .mobile-editor-form a svg {
    width: 1.125rem !important;
    height: 1.125rem !important;
    stroke-width: 2.5 !important;
  }
  /* Fix empty table message wrapping */
  .mobile-editor-form table tbody tr#emptyRow td {
    display: table-cell !important;
    text-align: center !important;
    width: 100% !important;
    white-space: normal !important;
    word-break: normal !important;
  }

  /* ===== ITEMS TABLE: card layout ===== */

  .mobile-editor-form table tbody tr {
    display: block !important;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: #fff;
  }
  .mobile-editor-form table tbody td {
    display: block !important;
    width: 100% !important;
    padding: 4px 0 !important;
    border: none !important;
    text-align: left !important;
  }

  .mobile-editor-form .overflow-visible {
    overflow-x: visible !important;
    overflow: visible !important;
  }
  .mobile-editor-form table.min-w-full {
    min-width: 0 !important;
    width: 100% !important;
  }
  .mobile-editor-form table thead {
    display: none !important;
  }
  .mobile-editor-form table tbody td::before {
    content: attr(data-label);
    display: block;
    font-weight: 600;
    font-size: 0.6rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 2px;
  }
  .mobile-editor-form table tbody td:first-child::before {
    display: none;
  }
  .mobile-editor-form table tbody td input[type="number"],
  .mobile-editor-form table tbody td input[type="text"] {
    width: 100% !important;
    min-width: 0 !important;
  }
  /* Qtd + Valor side by side */
  .mobile-editor-form table tbody td[data-label="Qtd."],
  .mobile-editor-form table tbody td[data-label="Valor Unit."] {
    display: inline-block !important;
    width: 48% !important;
    vertical-align: top;
  }
  /* Subtotal + Ações na mesma linha */
  .mobile-editor-form table tbody td[data-label="Subtotal"] {
    display: inline-block !important;
    width: 65% !important;
    vertical-align: middle;
  }
  .mobile-editor-form table tbody td:last-child {
    display: inline-flex !important;
    justify-content: flex-end !important;
    width: 30% !important;
    vertical-align: middle;
    text-align: right !important;
    padding-top: 4px !important;
    margin-top: 0;
    border-top: none !important;
  }
  .mobile-editor-form table tbody td:last-child::before {
    display: none;
  }
  /* Custom item: min-width override on mobile */
  .mobile-editor-form table tbody td input[style*="min-width: 700px"],
  .mobile-editor-form table tbody td input[style*="min-width: 800px"] {
    min-width: 0 !important;
  }
  .mobile-editor-form table tbody td select[style*="min-width: 160px"] {
    min-width: 0 !important;
    width: 100% !important;
  }
  .mobile-editor-form table tbody td .flex.items-center.gap-2 {
    flex-wrap: wrap !important;
  }

  /* ===== ADDED ITEM CARDS: reorganize content ===== */

  /* Hide drag handle on mobile (touch reorder not practical) */
  .mobile-editor-form table tbody td:first-child .drag-handle {
    display: none !important;
  }

  /* Any flex that has a badge (span.inline-flex) as direct child:
     Reorder to: Title → Badge → Description/SKU */
  .mobile-editor-form table tbody td:first-child div.flex:has(> span.inline-flex) {
    flex-direction: column !important;
    gap: 2px !important;
    align-items: flex-start !important;
  }
  /* Flatten content div so its children participate in parent flex */
  .mobile-editor-form table tbody td:first-child div.flex:has(> span.inline-flex) > .flex-1 {
    display: contents !important;
  }
  /* Title: first */
  .mobile-editor-form table tbody td:first-child div.flex:has(> span.inline-flex) > .flex-1 > p:first-child {
    order: 1 !important;
    width: 100%;
  }
  /* Badge: second (below title) */
  .mobile-editor-form table tbody td:first-child div.flex:has(> span.inline-flex) > span.inline-flex {
    order: 2 !important;
    margin-top: 2px;
  }
  /* Description + SKU: after badge */
  .mobile-editor-form table tbody td:first-child div.flex:has(> span.inline-flex) > .flex-1 > p:not(:first-child) {
    order: 3 !important;
    width: 100%;
  }

  /* ===== MODAL ITEM CARD — mobile layout ===== */
  .item-card-inner {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
  .item-card-image {
    order: 2 !important;
    width: 48px !important;
    height: 48px !important;
    min-width: 48px !important;
    min-height: 48px !important;
  }
  .item-card-content {
    order: 1 !important;
    flex: none !important;
    width: calc(100% - 60px) !important;
  }
  .item-card-price {
    order: 3 !important;
    width: 100% !important;
    text-align: left !important;
    margin-left: 0 !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    flex-wrap: wrap !important;
    border-top: 1px solid #f1f5f9;
    padding-top: 6px !important;
  }
  .item-card-price > span {
    order: 1;
  }
  .item-card-price > p.money-value,
  .item-card-price > p:nth-child(2) {
    order: 2;
    margin-top: 0 !important;
    font-size: 0.875rem !important;
  }
  .item-card-price > p:last-child {
    order: 3;
    margin-top: 0 !important;
  }
  .item-card-desc {
    -webkit-line-clamp: unset !important;
    line-clamp: unset !important;
    overflow: visible !important;
    font-size: 0.75rem !important;
  }

  /* ===== MODAL PACKAGE CARD — mobile layout ===== */
  .package-card-inner {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
  .package-card-image {
    order: 2 !important;
    width: 48px !important;
    height: 48px !important;
    min-width: 48px !important;
    min-height: 48px !important;
  }
  .package-card-content {
    order: 1 !important;
    flex: none !important;
    width: calc(100% - 60px) !important;
  }
  .package-card-price {
    order: 3 !important;
    width: 100% !important;
    text-align: left !important;
    margin-left: 0 !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    flex-wrap: wrap !important;
    border-top: 1px solid #f1f5f9;
    padding-top: 6px !important;
  }
  .package-card-price > span {
    order: 1;
  }
  .package-card-price > p {
    margin-top: 0 !important;
  }
  .package-card-desc {
    -webkit-line-clamp: unset !important;
    line-clamp: unset !important;
    overflow: visible !important;
    font-size: 0.75rem !important;
  }

  /* ===== TOTALS SECTION ===== */
  .mobile-editor-form .flex.items-end.gap-4,
  .mobile-editor-form .flex.gap-4 {
    flex-direction: column !important;
    gap: 8px !important;
  }
  .mobile-editor-form .flex.items-end.gap-4 > *,
  .mobile-editor-form .flex.gap-4 > * {
    width: 100% !important;
    flex: none !important;
  }
  /* Grid 2-cols to 1-col on mobile */
  .mobile-editor-form .grid.grid-cols-1.lg\:grid-cols-2 {
    grid-template-columns: 1fr !important;
  }
  /* Editor action buttons: compact on mobile */
  .mobile-editor-actions {
    flex-wrap: wrap !important;
    gap: 6px !important;
  }
  .mobile-editor-actions a,
  .mobile-editor-actions button {
    padding: 6px 10px !important;
    font-size: 0.75rem !important;
  }

  /* ===== PAGINATION ===== */
  #paginationContainer {
    flex-direction: column !important;
    align-items: center !important;
    gap: 8px;
    padding: 12px 16px !important;
  }
  #paginationContainer > div:first-child {
    font-size: 0.75rem;
  }
  #paginationContainer .flex.gap-2 {
    flex-wrap: wrap;
    justify-content: center;
  }
  #paginationContainer .flex.gap-2 a {
    min-width: 36px !important;
    padding: 6px 10px !important;
  }

  /* ===== TABLE HEADER ===== */
  div.mobile-table-header,
  header.mobile-table-header {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    justify-content: flex-start !important;
    gap: 2px !important;
  }
  .mobile-table-header h2 {
    font-size: 1rem;
  }

  /* ===== LISTING TABLE: card layout ===== */
  .mobile-table thead {
    display: none;
  }
  .mobile-table tbody tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 8px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 10px 12px;
    background: #fff;
  }
  .mobile-table tbody tr:hover {
    background: #fff;
  }
  /* Default: every td is full-width block row */
  .mobile-table tbody td {
    width: 100%;
    padding: 2px 0;
    border: none;
    font-size: 0.8125rem;
    text-align: left !important;
  }
  .mobile-table tbody td::before {
    display: none;
  }
  /* First td = card title (reference code) */
  .mobile-table tbody td:first-child {
    font-weight: 600;
    font-size: 0.9rem;
    color: #0f172a;
    padding-bottom: 2px;
  }
  /* Label above value for non-title, non-inline cells */
  .mobile-table tbody td[data-label]:not(:first-child):not(.mobile-inline):not(.mobile-td-actions)::before {
    content: attr(data-label);
    display: block;
    font-weight: 600;
    font-size: 0.625rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 4px;
    margin-bottom: 1px;
  }
  .mobile-table tbody td:empty::before {
    display: none;
  }
  /* Inline cells (Valor, Status): share row, auto width */
  .mobile-table tbody td.mobile-inline {
    width: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    margin-right: 12px;
  }
  .mobile-table tbody td.mobile-inline::before {
    content: attr(data-label);
    display: block;
    font-weight: 600;
    font-size: 0.5625rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 1px;
  }
  /* Actions: auto width, pushed to right */
  .mobile-table tbody td.mobile-td-actions {
    width: auto;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    padding: 0;
  }
  .mobile-table tbody td.mobile-td-actions::before {
    display: none;
  }
  /* Thicker action icons in listing tables */
  .mobile-table tbody td.mobile-td-actions svg {
    width: 1.125rem !important;
    height: 1.125rem !important;
    stroke-width: 2.5 !important;
  }

  /* Hide columns on mobile */
  .mobile-hide-col {
    display: none !important;
  }

  /* ===== DASHBOARD SUBNAV ===== */
  .dashboard-subnav .dash-subnav-separator {
    display: none !important;
  }
  .dashboard-subnav .dash-subnav-disabled {
    display: none !important;
  }
  .dashboard-subnav .flex {
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
    overflow-x: visible !important;
    overflow: visible !important;
  }
  .dashboard-subnav .flex > a {
    flex: 1 1 auto;
    justify-content: center;
    min-width: 0;
  }

  /* ===== BUDGET VIEW PAGE ===== */

  /* Show mobile tabs */
  .budget-view-tabs {
    display: flex !important;
    gap: 0;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 0;
  }
  .budget-view-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 8px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #64748b;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
  }
  .budget-view-tab.active {
    color: #0369a1;
    border-bottom-color: #0ea5e9;
  }
  .budget-view-tab svg {
    stroke-width: 2.5 !important;
  }

  /* Layout: stack columns, full width */
  .budget-view-layout {
    flex-direction: column !important;
    gap: 0 !important;
  }
  .budget-view-layout > #budgetTabContent,
  .budget-view-layout > #analysisTabContent {
    width: 100% !important;
    flex-shrink: 1 !important;
  }
  /* Tab visibility: controlled by JS class toggle */
  .budget-view-layout > #analysisTabContent {
    display: none;
  }
  .budget-view-layout > .mobile-tab-visible {
    display: block !important;
  }
  .budget-view-layout > .mobile-tab-hidden {
    display: none !important;
  }

  /* Action buttons: icon only + thicker strokes */
  .mobile-view-actions {
    flex-wrap: wrap !important;
    gap: 6px !important;
  }
  .mobile-view-actions svg {
    width: 1.125rem !important;
    height: 1.125rem !important;
    stroke-width: 2.5 !important;
  }
  .mobile-view-actions .flex-grow {
    display: none !important;
  }
  .mobile-view-actions a,
  .mobile-view-actions button {
    padding: 8px !important;
    white-space: nowrap;
  }

  /* Items table: responsive card layout */
  .budget-view-layout table thead {
    display: none !important;
  }
  .budget-view-layout table {
    table-layout: auto !important;
  }
  .budget-view-layout table tbody tr {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: stretch !important;
    border-bottom: 1px solid #e2e8f0;
    padding: 10px 0;
    gap: 0;
  }
  .budget-view-layout table tbody td {
    display: block !important;
    border: none !important;
    padding: 2px 0 !important;
    text-align: left !important;
  }
  /* Type badge: full row */
  .budget-view-layout table tbody td:first-child {
    width: 100% !important;
    padding-bottom: 2px !important;
  }
  /* Item name + description: full row */
  .budget-view-layout table tbody td:nth-child(2) {
    width: 100% !important;
    padding-bottom: 6px !important;
  }
  /* Qty, Unit, Price, Total: inline row with labels */
  .budget-view-layout table tbody td:nth-child(3),
  .budget-view-layout table tbody td:nth-child(4),
  .budget-view-layout table tbody td:nth-child(5),
  .budget-view-layout table tbody td:nth-child(6) {
    font-size: 0.8125rem !important;
    padding: 6px 2px 2px !important;
    border-top: 1px solid #f1f5f9 !important;
    display: inline-flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
  }
  /* QTD + UNID: alinhados à esquerda */
  .budget-view-layout table tbody td:nth-child(3),
  .budget-view-layout table tbody td:nth-child(4) {
    width: auto !important;
    text-align: left !important;
    align-items: flex-start !important;
    padding-right: 12px !important;
  }
  /* VALOR + TOTAL: alinhados à direita, com espaço entre eles */
  .budget-view-layout table tbody td:nth-child(5) {
    width: auto !important;
    text-align: right !important;
    align-items: flex-end !important;
    margin-left: auto;
    padding-right: 20px !important;
  }
  .budget-view-layout table tbody td:nth-child(6) {
    width: auto !important;
    text-align: right !important;
    align-items: flex-end !important;
    font-weight: 700 !important;
    color: #0f172a !important;
  }
  .budget-view-layout table tbody td:nth-child(3)::before,
  .budget-view-layout table tbody td:nth-child(4)::before,
  .budget-view-layout table tbody td:nth-child(5)::before,
  .budget-view-layout table tbody td:nth-child(6)::before {
    content: attr(data-mobile-label);
    display: block;
    font-size: 0.5625rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 1px;
  }

  /* Header logo: smaller on mobile */
  .budget-view-layout .h-16 {
    height: 2rem !important;
  }

  /* Mobile financial summary (visible only on mobile) */
  .budget-mobile-summary {
    display: block !important;
  }

  /* ===== FOOTER ===== */
  .footer-links-desktop {
    display: none !important;
  }
  /* ── Badge notification dropdowns: modal flutuante no mobile ── */
  .badge-dropdown {
    position: fixed;
    top: 50%;
    left: 50%;
    right: auto;
    transform: translate(-50%, -50%);
    width: 90vw;
    max-width: 360px;
    max-height: 70vh;
    overflow-y: auto;
    margin: 0;
    padding-bottom: 4px;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    z-index: 10000;
    background: #fff;
  }

  .footer-mobile-toggle {
    display: flex;
  }
  .footer-links-mobile {
    display: none;
    flex-wrap: wrap;
    gap: 8px 16px;
    padding-top: 12px;
  }
  .footer-links-mobile.open {
    display: flex;
  }

  /* Budget-view: esconder tag de cópia no mobile */
  .budget-view-layout .bg-purple-100.text-purple-700 {
    display: none !important;
  }

  /* Budget-view: título à esquerda, tags à direita */
  .budget-view-layout #budgetTabContent .flex.items-center.justify-between {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: flex-start !important;
    gap: 0.5rem !important;
  }
  .budget-view-layout #budgetTabContent .flex.items-center.justify-between > h2 {
    flex-shrink: 0;
  }
  .budget-view-layout #budgetTabContent .flex.items-center.justify-between > .flex.items-center.gap-2 {
    flex-direction: column !important;
    align-items: flex-end !important;
    gap: 0.25rem !important;
    margin-left: auto;
  }
}

/* Faixa tablet: preserva a tabela, mas reduz apenas o espaçamento horizontal
   para acomodar alvos de ação universais de 40 px sem expandir o documento. */
@media (min-width: 768px) and (max-width: 900px) {
  .mobile-table :is(th, td) {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
  }
  .mobile-table .mobile-td-actions > .flex {
    gap: 0.25rem !important;
  }
  .mobile-hide-cards article {
    min-width: 0;
    overflow: hidden;
  }
  .mobile-hide-cards .money-value {
    font-size: 0.875rem !important;
  }
}

/* Admin: navegação acima do conteúdo em tablets; formulários empilhados em celulares. */
@media (max-width: 1023px) {
  .admin-layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .admin-navigation { position: static; }
  .admin-sidebar { width: 100%; }
  #budgetForm .flex.gap-3 { flex-wrap: wrap; }
  .project-main-fields {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .project-main-fields > * {
    width: auto !important;
    min-width: 0;
  }
  .project-attachment-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  main header.flex-col {
    flex-direction: column !important;
    align-items: flex-start !important;
  }
  main header.flex-col > .flex {
    width: 100%;
    flex-wrap: wrap;
  }
  main header > .flex.flex-col {
    flex-direction: column !important;
    align-items: flex-start !important;
  }
  main header > .flex.flex-col > [class*="max-w-"] { max-width: 100% !important; }
  main header > .flex.flex-col > .flex { width: 100%; flex-wrap: wrap; justify-content: flex-start; }
  main > .flex.flex-col > .flex.items-center.justify-between,
  main > .flex.flex-col > .flex.items-start.justify-between {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }
  main > .flex.flex-col > .flex.items-center.justify-between > .flex,
  main > .flex.flex-col > .flex.items-start.justify-between > .flex {
    width: 100%;
    flex-wrap: wrap;
  }
  .admin-layout .admin-content .flex.items-center.justify-between {
    flex-wrap: wrap;
    gap: 8px;
  }
  .admin-layout .admin-content .space-y-2 > .flex.items-center.justify-between > div {
    min-width: 0;
    flex-wrap: wrap;
  }
}

@media (max-width: 639px) {
  .project-main-fields { grid-template-columns: minmax(0, 1fr); }
  .admin-layout .admin-content .space-y-2 > .flex.items-center.justify-between {
    align-items: stretch;
    flex-direction: column;
  }
  .admin-layout .admin-content .space-y-2 > .flex.items-center.justify-between > div {
    width: 100%;
  }
}
@media (max-width: 767px) {
  .admin-layout { --admin-control-height: 44px; --admin-control-font: 16px; }
  .admin-layout .admin-card-header { padding: 16px; }
  .admin-layout .admin-card-body { padding: 16px; }
  .admin-layout .admin-primary, .admin-layout .admin-secondary { min-height: 44px; width: 100%; }
  .admin-layout input:not([type="hidden"]), .admin-layout textarea,
  .admin-layout .custom-select-wrapper .custom-select-button { font-size: 16px; }
  .admin-layout .admin-content .grid { grid-template-columns: minmax(0, 1fr); }
  .admin-layout .admin-content form .flex { flex-wrap: wrap; }
  .admin-layout .admin-content form .flex > .flex-1 { flex-basis: 100%; min-width: 0; }
  .admin-layout .admin-content section > header { flex-wrap: wrap; gap: 12px; }
  .admin-layout .admin-content section > header > div { min-width: 0; }
  .admin-layout .admin-content section > .p-6,
  .admin-layout .admin-content section > form.p-6 { padding: 16px; }
  .admin-layout .admin-content input, .admin-layout .admin-content textarea { max-width: 100%; }
}
