/* Phone-width polish for the web panel (2026-11-27).
 *
 * Found by walking every page at 375 px: oversized cards, wasted lines,
 * empty boxes, items covered by the floating + button. Loaded LAST on every
 * page (config.php, after vitik-ui.css) and kept to phone widths, so the
 * desktop layout is untouched. Each rule names the page it is for.
 */
@media (max-width: 600px) {

  /* ── Every page: the header title fits (devices: «السكترات واللنكات» was cut) ── */
  .header-refresh-link { font-size: 13px !important; gap: 5px !important; }
  .header-refresh-link i { font-size: 12px !important; }

  /* ── main.php: «انتهت مؤخراً» / «تنتهي قريباً» — names as one-line chips,
        not three-line text squeezed into a 50 px circle ── */
  .user-avatars-grid {
    gap: 8px !important; padding: 12px 0 2px !important;
    justify-content: flex-start !important; align-items: center;
  }
  .user-avatars-grid .user-avatar-link {
    width: auto !important; height: 34px !important; min-width: 0 !important;
    padding: 0 12px !important; border-radius: 999px !important;
    max-width: 100%;
  }
  .user-avatars-grid .user-avatar-initials {
    width: auto !important; height: auto !important; padding: 0 !important;
    white-space: nowrap !important; line-height: 34px !important;
    font-size: 12.5px !important; font-weight: 700;
    overflow: hidden; text-overflow: ellipsis; max-width: 150px; display: block !important;
  }
  /* the dashboard script fits initials into the circle; the chip shows the full name */
  .user-avatars-grid .user-avatar-initials[data-full-name] { font-size: 0 !important; }
  .user-avatars-grid .user-avatar-initials[data-full-name] br { display: none; }
  .user-avatars-grid .user-avatar-initials[data-full-name]::after {
    content: attr(data-full-name); font-size: 12.5px; line-height: 34px;
  }
  .user-avatars-grid .more-users-message {
    width: auto !important; margin: 0 !important; padding: 0 6px !important;
    font-style: normal !important; font-size: 12.5px !important; font-weight: 700;
    color: var(--v-accent, #3d9eff) !important; text-decoration: none; white-space: nowrap;
  }
  .user-list-section .card-header { padding-bottom: 10px !important; }

  /* ── ppp.php and the lists: the list-settings button beside the search
        (it wrapped to a line of its own), and the sort bar on one slim line ── */
  .search-toolbar { flex-wrap: nowrap !important; gap: 8px; padding-bottom: 12px !important; margin-bottom: 12px !important; }
  .search-toolbar > .search-bar { flex: 1 1 auto !important; min-width: 0 !important; width: auto !important; }
  .search-toolbar > #subsPrefsBtn { flex: 0 0 44px !important; height: 44px !important; margin: 0 !important; justify-content: center; }
  html body #userTable thead tr { flex-wrap: nowrap !important; gap: 6px !important; }
  html body #userTable thead th { min-height: 34px !important; padding: 0 10px !important; font-size: 12.5px !important; }
  html body #userTable thead th#usersHeader { flex: 1 1 auto; min-width: 0; }
  html body #userTable thead th .users-header-content {
    display: flex !important; flex-direction: row !important; align-items: center; gap: 6px; flex-wrap: nowrap;
    width: 100%;
  }
  html body #userTable thead th .users-header-content > span:first-child { margin-inline-end: auto; white-space: nowrap; }
  html body #userTable thead th .phone-button-wrapper,
  html body #userTable thead th .uptime-button-wrapper { min-width: 28px !important; min-height: 28px !important; }
  html body #userTable thead th#expirationDateHeader { flex: 0 0 auto; white-space: nowrap; }
  /* an account with no end date: no empty box (it read «up-» or nothing) */
  html body #userTable tbody tr.user-row > td.expires-cell[data-sort="0"]:not(:has(.expires-date)) { display: none !important; }

  /* ── debts.php: the tools bar scrolls away (two stuck bars took ~130 px
        and the cards showed through them), and the avatar sits beside the
        name instead of on a line of its own ── */
  .page-actions-bar { position: static !important; backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
  .debt-card .debtor-info {
    display: grid !important; grid-template-columns: 38px minmax(0, 1fr);
    column-gap: 10px; row-gap: 2px; align-items: center;
  }
  .debt-card .debtor-info > .debt-avatar { grid-row: 1 / span 2; }
  .debt-card .debtor-info > .debtor-name { grid-column: 2; min-width: 0; }
  .debt-card .debtor-info > .debtor-note { grid-column: 2; }
  .debt-card .debtor-info > :not(.debt-avatar):not(.debtor-name):not(.debtor-note) { grid-column: 1 / -1; }

  /* ── devices_monitor.php: the three tabs on one row, a smaller device
        photo, and room under the last card for the + button ── */
  .tabs-container { flex-wrap: nowrap !important; gap: 6px !important; padding-inline: 12px !important; justify-content: stretch !important; }
  .tabs-container .tab-btn {
    flex: 1 1 0 !important; min-width: 0 !important; width: auto !important;
    padding: 8px 4px !important; font-size: 12px !important; gap: 4px !important;
    justify-content: center !important; white-space: nowrap; overflow: hidden;
  }
  .tabs-container .tab-btn > i { display: none !important; }
  /* the green «working» count repeats the total on a phone; the red «down» one stays */
  .tabs-container .tab-btn .dm-updown .u { display: none !important; }
  .tabs-container .tab-btn .count-badge { padding: 1px 6px !important; font-size: 11px !important; }
  /* the status filters: one row that scrolls, not a second line for «المكتومة» */
  #dmChips { flex-wrap: nowrap !important; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  #dmChips::-webkit-scrollbar { display: none; }
  #dmChips > .dm-chip { flex: 0 0 auto; white-space: nowrap; }
  .device-card .brand-logo { height: 84px !important; }
  .device-card .brand-logo img { max-height: 84px !important; }
  body:has(> .fab), body:has(.fab) { padding-bottom: 92px !important; }

  /* ── inventory.php: the total in the green bar was grey on green ── */
  .profile-total .inv-total-sum,
  .profile-total .inv-total-sum span { color: rgba(255, 255, 255, 0.9) !important; }

  /* ── agent_tools.php: a tool is a row (icon, name, line), not a 280 px tile ── */
  .tools-grid { gap: 10px !important; }
  .tools-grid .tool-card {
    display: grid !important; grid-template-columns: 52px minmax(0, 1fr);
    grid-template-areas: "icon title" "icon desc";
    column-gap: 14px; row-gap: 2px; align-items: center;
    padding: 16px !important; text-align: start !important; min-height: 0 !important;
  }
  .tools-grid .tool-card .icon-circle {
    grid-area: icon; width: 52px !important; height: 52px !important; margin: 0 !important; font-size: 22px !important;
  }
  .tools-grid .tool-card .icon-circle i { font-size: 22px !important; }
  .tools-grid .tool-card .tool-title { grid-area: title; margin: 0 !important; font-size: 16px !important; text-align: start !important; }
  .tools-grid .tool-card .tool-desc { grid-area: desc; margin: 0 !important; font-size: 12.5px !important; text-align: start !important; }
  .tools-grid .tool-card .tool-badge { position: absolute !important; top: -9px !important; inset-inline-end: 14px !important; inset-inline-start: auto !important; left: auto; z-index: 1; }
  .tools-grid .tool-card { overflow: visible !important; }
  .tools-grid .tool-card { position: relative; }

  /* ── collectors.php: the tabs read on two short lines at most ── */
  .tabs > .tab { flex: 1 1 auto !important; font-size: 12.5px !important; padding: 8px 6px !important; line-height: 1.35 !important; gap: 5px !important; }
  .tabs > .tab:first-child { flex-grow: 1.6 !important; }
}
