/* Abaixo de 1100 px: menu vira gaveta. Abaixo de 700 px: tabelas viram cartões. */
@media (max-width: 1099px) {
  :root, body.side-collapsed { --side: 0px; }
  #sidebar { width: 260px; transform: translateX(-100%); transition: transform .2s; box-shadow: none; }
  body.drawer-open #sidebar { transform: none; box-shadow: 0 8px 30px rgba(0, 0, 0, .25); }
  body.side-collapsed .logo-text, body.side-collapsed .nav-label { display: initial; }
  .collapse-btn { display: none; }
  #scrim { display: block; position: fixed; inset: 0; background: rgba(31, 29, 84, .45); z-index: 25; opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.drawer-open #scrim { opacity: 1; pointer-events: auto; }
  .topbar {
    display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 20; height: 52px; padding: 0 12px;
    background: var(--page); border-bottom: 1px solid var(--line);
  }
  .topbar .icon-btn { width: 44px; height: 44px; }
  .topbar strong { font-size: 15px; font-weight: 600; }
  #main { margin-left: 0; padding: 20px 16px 96px; max-width: none; }
  .tile-grid { grid-template-columns: repeat(3, 1fr); }
  .course-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 699px) {
  body { font-size: 14px; }
  .grid4 { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .grid2 { grid-template-columns: 1fr; }
  .stat { padding: 14px; border-radius: 16px; }
  .stat-value { font-size: 18px; }
  .card { border-radius: 16px; padding: 14px; }
  .btn, .icon-btn, .search { min-height: 44px; border-radius: 10px; }
  .btn { padding: 0 16px; }
  .icon-btn.small { min-height: 36px; width: 36px; }
  .page-head h1 { font-size: 18px; }
  .hide-s { display: none; }
  .search { width: 100%; font-size: 16px; }
  .toolbar { flex-direction: column-reverse; flex-wrap: nowrap; align-items: stretch; }
  .pills { flex-wrap: nowrap; overflow-x: auto; margin: 0 -2px; padding-bottom: 4px; }
  .pill { padding: 8px 14px; font-size: 12px; }
  .month-nav { justify-content: space-between; }
  .bar-row { grid-template-columns: 80px 1fr auto; }
  .course-grid, .tile-grid, .tile-grid.compact { grid-template-columns: 1fr; }
  .tile-act { opacity: 1; }
  .tile-main { padding: 12px; }

  /* tabelas viram cartões */
  .tbl thead { display: none; }
  .tbl, .tbl tbody { display: block; }
  .tbl tr { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 2px 8px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
  .tbl td { padding: 0; border: 0; width: auto !important; }
  .tbl .c-chk { grid-row: 1 / span 2; }
  .tbl .c-name { grid-column: 2; }
  .tbl .num { grid-column: 3; grid-row: 1; }
  .tbl .c-date { grid-column: 3; grid-row: 1; text-align: right; }
  .tbl.fin .c-date { grid-column: 2; grid-row: 2; text-align: left; font-size: 12px; }
  .tbl .c-kind { grid-column: 2; grid-row: 2; }
  .tbl .c-status { grid-column: 2; grid-row: 3; }
  .tbl .c-link { grid-column: 3; grid-row: 2; }
  .chk { width: 22px; height: 22px; }
  .sub-line { max-width: 60vw; }

  /* popup em folha */
  dialog { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 18px 18px 0 0; max-height: 92vh; }
  #dform { max-height: 92vh; }
  .dlg-body { grid-template-columns: 1fr; padding-bottom: 8px; }
  .fld input:not([type=checkbox]):not([type=radio]), .fld select { height: 44px; font-size: 16px; border-radius: 10px; }
  .fld textarea { font-size: 16px; border-radius: 10px; }
  .chk-fld { height: 44px; }
  .dlg-foot { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .login-card input { min-height: 44px; }
}
@media (max-width: 699px) { .pills { scrollbar-width: none; } .pills::-webkit-scrollbar { display: none; } }
