/* ============================================================
   MTZ FLOW · Responsividade
   Desktop → Notebook → Tablet → Smartphone
   ============================================================ */

/* Notebook / telas médias */
@media (max-width: 1240px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .g-6 { grid-template-columns: repeat(3, 1fr); }
  .g-4 { grid-template-columns: repeat(2, 1fr); }
  .dash-cols-3 { grid-template-columns: 1fr; }
}

/* Tablet */
@media (max-width: 1024px) {
  :root { --sidebar-w: 240px; }
  .dash-cols { grid-template-columns: 1fr; }
  .g-3 { grid-template-columns: repeat(2, 1fr); }
  .login { grid-template-columns: 1fr; }
  .login__aside { display: none; }
  .login__aside.mobile-strip {
    display: flex; grid-template-columns: none; min-height: auto; flex-direction: row; align-items: center;
    padding: 20px 24px; gap: 14px;
  }
}

/* Sidebar vira off-canvas a partir de tablet estreito */
@media (max-width: 900px) {
  .app, .app.is-collapsed { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; width: var(--sidebar-w); height: 100vh;
    transform: translateX(-100%); transition: transform var(--dur) var(--ease); z-index: var(--z-sidebar);
    box-shadow: var(--sh-lg);
  }
  .app.mobile-open .sidebar { transform: none; }
  .is-collapsed .sidebar__brand .badge-flow,
  .is-collapsed .sidebar__brand .brand-word { display: inline; }
  .is-collapsed .nav-item { justify-content: flex-start; padding: 10px 14px; }
  .is-collapsed .nav-item .nav-label, .is-collapsed .nav-item .nav-badge { display: flex; }
  .is-collapsed .sidebar__promo { display: block; }
  .topbar__toggle { display: none; }
  .topbar__burger { display: grid; }
  .topbar__search { width: 200px; }
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Smartphone */
@media (max-width: 680px) {
  .content { padding: 16px; }
  .topbar { padding: 0 14px; gap: 10px; }
  .topbar__search { display: none; }
  #btn-mobile-search { display: grid; }
  .topbar__search.mobile-show { display: flex; position: absolute; top: var(--topbar-h); left: 0; right: 0; width: auto; margin: 8px 14px; z-index: 40; }
  .topbar__title h1 { font-size: 16px; }
  .profile-switch .who { display: none; }
  .profile-switch { padding: 0 6px; }

  .kpi-grid, .g-2, .g-3, .g-4, .g-6 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .grid.one-col-mobile { grid-template-columns: 1fr; }
  .col-span-2, .col-span-3, .col-span-4 { grid-column: span 1; }

  .page-head { flex-direction: column; align-items: flex-start; }
  .page-head__actions { width: 100%; }
  .page-head__actions .btn { flex: 1; }

  .card { padding: 18px; border-radius: var(--r-lg); }
  .card--pad-lg { padding: 20px; }

  /* Tabelas viram cartões empilhados */
  .tbl.stack-mobile thead { display: none; }
  .tbl.stack-mobile, .tbl.stack-mobile tbody, .tbl.stack-mobile tr, .tbl.stack-mobile td { display: block; width: 100%; }
  .tbl.stack-mobile tr { border: 1px solid var(--hair); border-radius: var(--r-md); margin-bottom: 10px; padding: 6px 4px; background: var(--surface); }
  .tbl.stack-mobile td { border: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 14px; text-align: right; }
  .tbl.stack-mobile td::before { content: attr(data-label); font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); text-align: left; }
  .tbl.stack-mobile td.cell-actions { justify-content: flex-end; }
  .tbl.stack-mobile td.cell-actions::before { content: ""; }

  /* Modais quase full-screen no mobile */
  .modal { width: calc(100vw - 20px); max-height: calc(100vh - 24px); }
  .modal__foot { flex-wrap: wrap; }
  .modal__foot .btn { flex: 1; }
  .drawer { width: 100vw; }

  .kanban__col { flex-basis: 84vw; }
  .toast-stack { left: 14px; right: 14px; bottom: 14px; align-items: stretch; }
  .toast { min-width: 0; max-width: none; }

  .heatmap__row { grid-template-columns: 90px repeat(var(--cols, 8), 1fr); }
  .heatmap__label { font-size: 10.5px; }

  .podium { grid-template-columns: 1fr; }
  .demo-profiles { grid-template-columns: 1fr; }
  .cal__cell { min-height: 74px; padding: 5px; }
  .cal__events .cal-ev { display: none; }
  .cal__events .cal-ev:first-child { display: flex; }
  .cal__cell .cal-more-dot { display: block; }

  .workload-row { grid-template-columns: 110px 1fr 44px; }
  .criteria-row { grid-template-columns: 1fr 80px 40px; }
}

/* Telas muito estreitas */
@media (max-width: 400px) {
  .kpi-grid, .g-2, .g-3, .g-4, .g-6 { grid-template-columns: 1fr; }
  .page-head h2 { font-size: 1.5rem; }
}

/* Impressão (relatórios) */
@media print {
  .sidebar, .topbar, .page-head__actions, .toast-stack, .btn { display: none !important; }
  .app { grid-template-columns: 1fr; }
  .card { break-inside: avoid; box-shadow: none; border: 1px solid #ddd; }
  body { background: #fff; }
}
