/* mobile.css – the phone layout, loaded last so it wins over the themes.
   Rule: on a phone every card is three clean bands – who (avatar, name, paid chip), the details line, the actions. */
@media (max-width: 640px) {
  /* ---------- order card header ---------- */
  .card header {
    display: flex !important; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 12px 14px 10px;
  }
  .card header::before, .card header::after { content: ""; flex-basis: 100%; height: 0; }
  .card header::before { order: 9; }   /* break before the details line */
  .card header::after { order: 19; }   /* break before the actions */
  .card header .av { order: 1; width: 36px; height: 36px; font-size: 15px; flex: none; grid-row: auto; }
  .card header b { order: 2; flex: 1 1 0; min-width: 0; width: auto; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; grid-column: auto; }
  .card header .pay { order: 3; flex: none; margin: 0; font-size: 13px; padding: 3px 9px; max-width: 48%; overflow: hidden; text-overflow: ellipsis; }
  /* the details line: phone · order · bought at – small, wraps as a line, never inside an item */
  .card header > span:not(.pay) { order: 10; flex: none; font-size: 13px; line-height: 1.3; white-space: nowrap; grid-row: auto; justify-self: auto; }
  .card header > span:not(.pay) + span:not(.pay)::before { content: "·"; margin-inline-end: 8px; opacity: .5; }
  /* on a phone the details line is the purchase time only: the phone and the order number are reachable from the search */
  .card header > span[dir="ltr"], .card header > span:not(.pay):not(.when) { display: none; }
  .card header .when { font-size: 13px; }
  .card header .when::before { content: none !important; }
  /* a site order: the change link leads; the manual seat move is desktop-only */
  .row-actions .act.move-2nd { display: none; }
  /* the actions: receipt, refund, change – one row of equal buttons, big enough for a thumb */
  .card header .pay-doc, .card header .pay-refund, .card header .act.mini { order: 20; flex: 1 1 0; min-width: 0; margin: 0; justify-content: center; min-height: 40px; font-size: 13px; padding: 6px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-radius: 12px; }
  .card header .pay-doc { max-width: 40%; }
  .card header .pay-refund { white-space: nowrap; }
  .card header .pay-refund::after { display: none; }

  /* ---------- the tour rows under the header ---------- */
  .card .row { padding: 12px 14px 14px; gap: 10px 12px; }
  .card .row .grow { min-width: 0; }
  .card .row .grow b, .card .row .grow span { display: block; overflow: hidden; text-overflow: ellipsis; }
  .card .row .grow b { white-space: normal; line-height: 1.3; font-size: 16px; }
  .card .row .grow span:not(.who) { white-space: nowrap; font-size: 13px; }
  .card .row .grow .who { white-space: normal; font-size: 13px; }
  .row-actions .act { min-height: 44px; font-size: 14px; padding: 8px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .row-actions .act svg { flex: none; }

  /* ---------- lists: heading and the payments refresh ---------- */
  .list-head { align-items: center; gap: 8px 12px; }
  .list-head .hint { flex-basis: 100%; order: 3; font-size: 13px; }
  .list-head #pay-sync { margin: 0; min-height: 38px; }

  /* ---------- accounting dashboard ---------- */
  .acct-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .acct-row { padding: 14px; gap: 10px; }
  .acct-cap { min-width: 0; }
  .acct-dates { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
  .acct-dates .acct-dash { display: none; }
  .acct-dates #acct-go { grid-column: 1 / -1; min-height: 44px; }
  .acct-bar-rows label { flex-direction: column; align-items: stretch; gap: 4px; }
  .acct-bar .acct-row input[type="date"], .acct-bar .acct-row select { width: 100%; min-height: 44px; }
  .acct-quick { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); }
  .acct-quick button { padding: 8px 4px; min-height: 40px; }
  #acct-xl { width: 100%; min-height: 44px; justify-content: center; }
  .acct-row-filters .acct-pick { width: 100%; }
  .acct-row-filters .acct-seg { width: 100%; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); }
  .acct-filters label { flex-direction: column; align-items: stretch; gap: 4px; }
  .acct-filters input[type="date"], .acct-filters select { width: 100%; max-width: none; min-height: 44px; }
  .acct-filters .acct-sep { display: none; }
  .acct-filters label:has(select) { grid-column: 1 / -1; }
  /* the themes force the tabs grid on phones; the accounting and national-service screens have no tabs */
  body.acct-mode #tabs, body.sherut-mode #tabs, body.acct-mode #stats, body.sherut-mode #stats, body.train-mode #tabs, body.train-mode .overview { display: none !important; }
  .acct-filters .acct-seg { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); }
  .acct-seg button { min-height: 44px; }
  .acct-filters > .act, .acct-filters > button { grid-column: 1 / -1; min-height: 44px; }
  .ac-tick, .ac-sub { font-size: 12.5px; }
  table.acct th, table.acct td { padding: 8px 6px; font-size: 13.5px; }
  table.acct td:nth-child(2) { white-space: normal; min-width: 110px; }
  .tbl-wrap { -webkit-overflow-scrolling: touch; }

  /* ---------- shuttles: the three icon buttons side by side, not stacked ---------- */
  .ride td.ride-row-actions { white-space: nowrap; }
  .ride-row-actions .act { width: 40px !important; height: 40px !important; min-height: 40px; margin-inline-start: 4px; }
  .ride-note.add { font-size: 13.5px; min-height: 36px; }

  /* ---------- small type that was under 13px ---------- */
  .auto-tag, .auto-tags button { font-size: 13px; }
  .tour small, .day small, .rt small { font-size: 13px; }
  .opt small, .opt em { font-size: 13px; }

  /* ---------- tabs: an odd last tab spans the row ---------- */
  .tabs > button:last-child:nth-child(odd) { grid-column: 1 / -1; }

  /* ---------- modals: the list scrolls, the buttons stay in reach ---------- */
  .modal { display: flex; flex-direction: column; max-height: calc(100dvh - 20px) !important; }
  .modal .options { flex: 1 1 auto; min-height: 120px; overflow: auto; }
  .modal footer { position: sticky; bottom: 0; background: var(--panel); padding-top: 8px; }
}

/* ---------- המלצות AI לשיבוץ: כרטיסים נוחים לאגודל ---------- */
@media (max-width: 640px) {
  .ai-card { padding: 14px 12px; }
  .ai-card input { width: 24px; height: 24px; margin-top: 2px; }
  .ai-members { gap: 6px 10px; }
  .ai-reason, .ai-unplaced small { font-size: 13px; }
  .modal footer #ai-apply, .modal footer #ai-skip { min-height: 44px; }
  .modal footer #ai-apply { flex: 1; }
  .waiting-head #rooms-ai { width: 100%; justify-content: center; }
}
