
/* ===== Mobile-friendly add-on (phones & small tablets) ===== */
.menu-btn { display: none; }
@media (max-width: 800px) {
  /* Top bar with hamburger menu */
  .side { position: sticky; top: 0; z-index: 50; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0; padding: 10px 14px; max-height: 100vh; overflow-y: auto; }
  .brand { font-size: 1.2rem; }
  .menu-btn { display: inline-flex; align-items: center; gap: 6px; background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.35); border-radius: 8px; padding: 8px 12px; font: 600 .95rem var(--sans); cursor: pointer; min-height: 40px; }
  .menu-btn .bars, .menu-btn .bars::before, .menu-btn .bars::after { display: block; width: 18px; height: 2px; background: currentColor; border-radius: 2px; position: relative; content: ""; }
  .menu-btn .bars::before { position: absolute; top: -6px; }
  .menu-btn .bars::after { position: absolute; top: 6px; }
  .side nav, .side .who { grid-column: 1 / -1; display: none; }
  .side.open nav { display: flex; flex-direction: column; overflow: visible; margin: 10px 0 0; padding: 0; gap: 2px; }
  .side.open .who { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 4px 4px; margin-top: 8px; border-top: 1px solid rgba(255,255,255,.15); }
  .side nav a { padding: 12px 12px; font-size: 1rem; }
  .who .links { margin-top: 0; align-items: center; }

  /* Comfortable text and tap targets; 16px inputs stop iPhone auto-zoom */
  main { padding: 18px 14px 60px; }
  h1 { font-size: 1.45rem; }
  input, select, textarea { font-size: 16px; padding: 10px 11px; }
  .btn, button.btn { padding: 10px 16px; min-height: 42px; }
  .page-head { gap: 10px; }
  .page-head .btn { flex: 0 0 auto; }
  .toolbar .btn { width: 100%; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat .value { font-size: 1.5rem; }
  .card { padding: 14px; }

  /* Tables become stacked cards (timetable keeps its grid) */
  table.m-cards thead { display: none; }
  table.m-cards, table.m-cards tbody, table.m-cards tr, table.m-cards td { display: block; width: 100%; }
  table.m-cards tr { padding: 10px 2px; border-bottom: 1px solid var(--line); }
  table.m-cards tr:last-child { border-bottom: 0; }
  table.m-cards td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 5px 4px; border: 0; text-align: right; white-space: normal; min-height: 0; }
  table.m-cards td::before { content: attr(data-label); flex: 0 0 auto; max-width: 45%; text-align: left; font-size: .8rem; font-weight: 600; color: var(--muted); }
  table.m-cards td:not([data-label])::before, table.m-cards td[data-label=""]::before { display: none; }
  table.m-cards td:first-child { font-weight: 600; font-size: 1rem; justify-content: flex-start; text-align: left; }
  table.m-cards td:first-child::before { display: none; }
  table.m-cards td.actions { justify-content: flex-end; flex-wrap: wrap; padding-top: 8px; }
  table.m-cards td.actions::before { display: none; }
  table.m-cards td[colspan] { display: block; text-align: center; }
  table.m-cards td input, table.m-cards td select { max-width: 60%; }
  table.m-cards .seg { flex-wrap: wrap; justify-content: flex-end; }
  table.m-cards .seg span { padding: 7px 9px; font-size: .82rem; }

  /* Timetable: keep the grid, scroll sideways with sticky period column */
  .tt th:first-child, .tt td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); }
  .tt td { min-width: 96px; }

  /* Pop-up forms use the full screen */
  dialog { width: 100vw; max-width: 100vw; height: 100%; max-height: 100%; margin: 0; border-radius: 0; border: 0; padding: 18px 16px; }
  .dialog-actions { position: sticky; bottom: -18px; background: var(--surface); padding: 12px 0; margin-bottom: -18px; border-top: 1px solid var(--line); }
  .dialog-actions .btn { flex: 1; }
  .savebar { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; flex-wrap: wrap; }
  .login form { padding: 24px 18px; }
  .login-tabs button { padding: 9px 12px; font-size: .9rem; }
}
