/* Shared phone and tablet layout; report tables scroll inside their panels. */
@media screen {
  .grid > *, .account-grid > *, .bet-columns > *, .bet-inputs > *,
  .commission-summary > *, .profit-summary > * { min-width: 0; }
  .field, .tablewrap { min-width: 0; max-width: 100%; }
  .tablewrap { overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
  .cardx p, .crud-list td, .menu-hero a { overflow-wrap: anywhere; }
  .crud-list td::before, .list-avatar { flex-shrink: 0; }
  body.menu-open { overflow: hidden; }
  body .sidebar { max-width: calc(100vw - 48px); overscroll-behavior: contain; }
  .commission-summary strong, .profit-summary strong { overflow-wrap: anywhere; }
}

@media screen and (max-width: 1000px) {
  .topbar {
    height: 76px;
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) 44px 44px;
    grid-template-rows: 48px 28px;
    align-items: center;
    gap: 0 4px;
    padding: 0 8px;
  }
  .topbar .menu-toggle { position: static; grid-column: 1; grid-row: 1; width: 44px; height: 44px; }
  .topbar .topbar-title {
    grid-column: 2; grid-row: 1; max-width: 100%; min-width: 0;
    font-size: 16px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .topbar .system-clock {
    position: static; grid-column: 1 / -1; grid-row: 2; height: auto;
    justify-content: center; align-self: start; font-size: 11px; line-height: 22px;
  }
  .topbar .activity-bell { position: static; grid-column: 3; grid-row: 1; }
  .activity-bell summary { width: 44px; height: 44px; }
  .activity-count { top: 1px; right: 0; }
  .topbar .topbar-account { position: static; grid-column: 4; grid-row: 1; width: 44px; height: 44px; }
  body.signed-in .main { padding-top: 76px; }
  .activity-panel {
    position: fixed; top: 82px; right: 10px;
    width: min(380px, calc(100vw - 20px));
    max-height: calc(100vh - 100px); max-height: calc(100dvh - 100px);
    overscroll-behavior: contain;
  }
  .notification-stack { top: 88px; }
}

@media screen and (max-width: 760px) {
  body .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .account-grid { grid-template-columns: minmax(0, 1fr); }
  body .field input, body .field select, body table input, body table select,
  .actions input, .actions select {
    min-width: 0; max-width: 100%; min-height: 44px; font-size: 16px;
  }
  body .btnx, .bet-type-picker button { min-height: 44px; }
  body .btnx { display: inline-flex; align-items: center; justify-content: center; text-align: center; }
  .actions { align-items: stretch; }
  form.actions > label { flex: 1 1 180px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
  form.actions > label input { width: 100%; }
  form.actions > .btnx { align-self: end; }
  .modal-close, .remove-bet, .notification-close {
    min-width: 44px; min-height: 44px; display: inline-flex; justify-content: center; align-items: center;
  }
  .crud-list td.record-actions { gap: 12px; flex-wrap: wrap; }
  .record-actions > a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 10px; }
  .cashout-actions input { min-height: 44px !important; font-size: 16px !important; }
  .bet-list table { min-width: 0; }
  .bet-list th, .bet-list td { padding: 8px 3px; }
  .bet-list th { white-space: normal; }
  .bet-inputs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .keypad { width: 100%; }
  .form-overlay { padding: 10px; }
  body .crud-form {
    padding: 16px; max-height: calc(100vh - 20px); max-height: calc(100dvh - 20px);
    overscroll-behavior: contain;
  }
  .notification-stack {
    top: auto; bottom: max(12px, env(safe-area-inset-bottom)); right: 10px;
    width: calc(100vw - 20px); max-height: 45vh; max-height: 45dvh;
    overflow-y: auto;
  }
  .notification-toast { gap: 6px; padding: 12px; }
  body.signed-out .content-container { padding-top: 20px; }
  body .auth { padding: 16px 8px; }
}

@media screen and (max-width: 480px) {
  body .grid, .draw-card .grid { grid-template-columns: minmax(0, 1fr); }
  .content-container { padding: 12px 10px 24px; }
  .actions > .btnx, .actions > form { flex: 1 1 auto; }
  .actions > form .btnx { width: 100%; }
  .crud-list tr { padding: 10px 12px; }
  .crud-list td { flex-wrap: wrap; }
  .commission-summary, .profit-summary { gap: 8px; }
  .commission-summary .cardx, .profit-summary .cardx { padding: 10px; }
  .commission-summary strong, .profit-summary strong { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .original-home h2 { animation: none; }
  body .sidebar, .menu-backdrop { transition: none; }
}
