/* Phone layout additions, loaded after app.css and operations.css on every page. */

@media (max-width: 640px) {
  /* Wide data tables become label/value cards (labels set by table-labels.js). */
  table.stack-mobile, table.stack-mobile tbody, table.stack-mobile tr, table.stack-mobile td { display: block; width: 100%; }
  table.stack-mobile thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.stack-mobile { min-width: 0 !important; }
  table.stack-mobile tr { padding: 8px 12px; border-bottom: 1px solid var(--border-soft, #263241); }
  table.stack-mobile td { display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
    padding: 4px 0 !important; border: 0 !important; text-align: right; white-space: normal !important; overflow-wrap: anywhere; }
  table.stack-mobile td::before { content: attr(data-label); flex: 0 0 auto; max-width: 45%; text-align: left;
    color: var(--muted, #96a9bc); font-size: .78rem; letter-spacing: .02em; }
  table.stack-mobile td[data-label=""]::before { content: none; }
  table.stack-mobile td:first-child { font-weight: 600; }
  table.stack-mobile td form { display: inline; }
  /* Cards flow with the page: no inner scroll box (operations.css caps it at 34rem). */
  .table-scroll:has(> table.stack-mobile) { overflow: visible; max-height: none; }
  /* The first cell (often name + handle + ID) stacks its own lines under its label. */
  table.stack-mobile td:first-child { display: block; text-align: left; }
  table.stack-mobile td:first-child::before { display: block; max-width: none; margin-bottom: 2px; }
  table.stack-mobile td.message-cell { display: block; min-width: 0; max-width: none; text-align: left; }
  table.stack-mobile td.message-cell::before { display: block; max-width: none; }

  /* Opportunity cards: meters keep a usable width; the expanded details span the card. */
  table.stack-mobile td.meter-cell { flex-wrap: wrap; }
  table.stack-mobile td.meter-cell .bar-meter { flex: 1 1 120px; max-width: 160px; }
  table.stack-mobile tr.home-detail-row td { display: block; }
  table.stack-mobile tr.home-detail-row td::before { content: none; }
  .opp-details { display: block; }
  .entry-snapshot .snapshot-grid { grid-template-columns: 1fr; }

  /* Session strip: events read better across the full width. */
  .today-strip .strip-events { grid-column: 1 / -1; }
  .today-strip .strip-events .strip-value { font-size: 1.05rem; line-height: 1.5; }

  /* Finger-sized controls. */
  button, .home-detail-toggle, .nav-date-form button, input[type="date"], select { min-height: 40px; }
  .top-meta { flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
}
