/* Phone shell (debate pmsphoneux, 2026-11-24).

   Every rule that changes a page is inside the one phone media query (max-width: 767px), so the PC
   layout (768px and wider) does not change. Rules on a phone:
   - one scroller: the page scrolls, nothing inside it does -- no scroll boxes, no tables or boards
     panning sideways, no frames holding a second app;
   - text 16px, nothing under 14px; tap targets 44px (48px for the main action);
   - a slim header with Back on every page that is not a tab, and the bottom bar only on tabs. */

@media (min-width: 768px) {
  .phone-only { display: none !important; }
}

@media (max-width: 767px) {
  :root {
    --ph-header-h: 52px;
    --ph-bar-h: 60px;
    --ph-safe-top: env(safe-area-inset-top, 0px);
    --ph-safe-bottom: env(safe-area-inset-bottom, 0px);
    --ph-gutter: 16px;
    --ph-ink: #10273d;
    --ph-muted: #4a5d70;
    --ph-line: #d6e0e9;
    --ph-canvas: #f3f6f9;
    --ph-surface: #ffffff;
    --ph-accent: #0f5f96;
    --ph-accent-ink: #ffffff;
    --ph-radius: 14px;
  }
  .pc-only { display: none !important; }
  .ph-visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

  html { font-size: 16px; scroll-padding-top: calc(var(--ph-header-h) + var(--ph-safe-top) + 12px); background: var(--ph-canvas); }
  body {
    min-height: 100vh;
    background: var(--ph-canvas);
    color: var(--ph-ink);
    padding-bottom: calc(var(--ph-safe-bottom) + 16px) !important;
  }
  body.has-phone-bar { padding-bottom: calc(var(--ph-bar-h) + var(--ph-safe-bottom) + 16px) !important; }
  /* Focused fields must not hide under the sticky header or the bottom bar (WCAG 2.2, 2.4.11). */
  html { scroll-padding-bottom: calc(var(--ph-bar-h) + var(--ph-safe-bottom) + 12px); }
  main.container {
    width: auto;
    margin: 0 var(--ph-gutter);
    padding-top: 12px;
    padding-left: 0;
    padding-right: 0;
    padding-bottom: 0;
  }

  /* ---- Header: Back, page title, notifications ---- */
  .site-header {
    padding: var(--ph-safe-top) 0 0;
    background: var(--ph-surface);
    border-bottom: 1px solid var(--ph-line);
    backdrop-filter: none;
  }
  .site-header > .container { width: auto; max-width: none; margin: 0; padding: 0 4px; }
  .header-shell { gap: 0; }
  .header-top, .site-nav-panel, .nav-toggle { display: none !important; }
  .phone-header {
    display: flex;
    align-items: center;
    gap: 4px;
    height: var(--ph-header-h);
  }
  .phone-back,
  .phone-header-actions .notif-bell {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-height: 44px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--ph-ink);
  }
  .phone-back:focus-visible, .phone-header-actions .notif-bell:focus-visible { outline: 3px solid var(--ph-accent); }
  .phone-back svg, .phone-header-actions .notif-bell svg { width: 26px; height: 26px; }
  .phone-title {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0 0 0 12px;
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--ph-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .phone-back + .phone-title { margin-left: 0; }
  .phone-header-actions { flex: 0 0 auto; display: flex; align-items: center; }
  .phone-header-actions .notif { position: static; }
  .phone-header-actions .notif-badge {
    min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
    font-size: 14px; line-height: 20px; top: 2px; right: 0;
  }

  /* ---- Bottom bar (tabs only) ---- */
  .mobile-bottom-nav {
    display: block;
    background: var(--ph-surface);
    border-top: 1px solid var(--ph-line);
    box-shadow: 0 -2px 10px rgba(16, 39, 61, .08);
  }
  .mobile-nav-item {
    min-height: var(--ph-bar-h);
    gap: 3px;
    padding: 6px 2px;
    color: var(--ph-muted);
    font-size: 14px;
    font-weight: 600;
  }
  .mobile-nav-item.is-active { color: var(--ph-accent); background: #e7f0f8; }
  .mobile-nav-item:hover { color: var(--ph-accent); background: transparent; }
  .mobile-nav-item svg { width: 26px; height: 26px; }
  .mobile-nav-label {
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.15;
  }
  /* Icons only when a label would be cut off or the bar would run past the screen (phone.js
     fitBar; operator 2026-11-25, same rule as the Android app). The words stay the links' names. */
  .mobile-bottom-nav.is-icons-only .mobile-nav-label { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .mobile-bottom-nav.is-icons-only .mobile-nav-item svg { width: 30px; height: 30px; }
  .mobile-nav-badge {
    top: 4px !important; right: calc(50% - 26px) !important;
    min-width: 20px !important; height: 20px !important; border-radius: 10px !important;
    font-size: 14px !important;
  }
  /* The keyboard takes the bottom of the screen; the bar would sit on top of what is typed. */
  body.kb-open .mobile-bottom-nav { display: none; }
  body.kb-open.has-phone-bar { padding-bottom: 16px !important; }

  /* ---- Text and tap sizes ---- */
  button, [role="button"], input[type="submit"], input[type="button"], a[role="button"], .button {
    min-height: 44px;
    font-size: 1rem;
  }
  select, textarea,
  input[type="text"], input[type="email"], input[type="password"], input[type="number"],
  input[type="search"], input[type="date"], input[type="datetime-local"], input[type="time"],
  input[type="tel"], input[type="url"], input:not([type]) {
    min-height: 44px;
    font-size: 1rem;   /* under 16px, iOS Safari zooms the page on focus */
  }
  input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; }
  .muted, small { font-size: 0.875rem; color: var(--ph-muted); }
  .entity-subtitle, .action-card-copy, .activity-item small { font-size: 0.9375rem; }
  .pill, .badge-soft { font-size: 0.875rem; padding: .3rem .65rem; }
  .entity-eyebrow, .hero-eyebrow, .stat-label, .metric-tile span, .dashboard-table th { font-size: 0.875rem; letter-spacing: .02em; }
  .dashboard-table { font-size: 0.875rem; }
  /* typography.css sizes these labels 13px per language with html:lang(..); the phone floor is 14px. */
  html:root :is(.stat-label, .metric-tile span, .entity-eyebrow, .hero-eyebrow, .dashboard-table th, .eyebrow, .section-eyebrow) {
    font-size: 0.875rem;
  }
  .entity-title a { display: inline-flex; align-items: center; min-height: 44px; }
  /* White on orange was 3.9:1; this orange keeps the badge readable (about 5:1). */
  .notif-badge, .mobile-nav-badge { background: #c2410c !important; color: #fff !important; }
  .point-mark { color: #4a5d70 !important; }

  /* ---- One scroller: nothing inside the page scrolls on its own ---- */
  .table-wrap, .fin-scroll { overflow: visible !important; }
  .table-wrap table { min-width: 0 !important; }
  .log, .dc-log, .rc-list, .ops-chat-thread-list, .ops-chat-log, .chat-dialog-users,
  .booking-detail-messages, .module-scroll {
    max-height: none !important;
    overflow: visible !important;
  }
  pre {
    max-height: none !important;
    overflow: visible !important;
    white-space: pre-wrap !important;
    overflow-wrap: anywhere;
  }
  /* Label/value tables (no header row) take the screen width and wrap; nothing in them may widen the page. */
  main table:not(:has(thead)) { width: 100% !important; table-layout: fixed; }
  main table:not(:has(thead)) th, main table:not(:has(thead)) td { white-space: normal !important; overflow-wrap: anywhere; }
  main table:not(:has(thead)) th { width: 38% !important; }
  /* A grid track sized "1fr" grows to its widest unbreakable content; on a phone it must not pass the screen. */
  .booking-detail-grid, .info-split-grid, .grid-2 { grid-template-columns: minmax(0, 1fr) !important; }
  /* Tables become one card per row; phone.js copies each column heading into data-label. */
  table.phone-cards, table.phone-cards tbody, table.phone-cards tr, table.phone-cards td { display: block; width: 100%; }
  table.phone-cards thead { display: none; }
  table.phone-cards tr {
    margin: 0 0 10px;
    padding: 10px 12px;
    border: 1px solid var(--ph-line);
    border-radius: 12px;
    background: var(--ph-surface);
  }
  table.phone-cards td {
    display: grid;
    grid-template-columns: minmax(6.5rem, 38%) 1fr;
    gap: 8px;
    padding: 6px 0 !important;
    border: 0 !important;
    white-space: normal !important;
    overflow-wrap: anywhere;
    font-size: 1rem;
    text-align: left !important;
  }
  table.phone-cards td::before {
    content: attr(data-label);
    color: var(--ph-muted);
    font-size: 0.875rem;
    font-weight: 600;
  }
  table.phone-cards td:not([data-label])::before, table.phone-cards td[data-label=""]::before { content: none; }
  table.phone-cards td:not([data-label]), table.phone-cards td[data-label=""] { grid-template-columns: 1fr; }

  /* A frame holding a second web app (video, conference, cameras) becomes a button that opens it
     as its own page: two headers and two scrollbars in one screen is not usable on a phone. */
  .module-embed-frame { display: none !important; }
  .module-open-full {
    display: flex !important;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    margin-top: 12px;
    border-radius: 12px;
    background: var(--ph-accent);
    color: var(--ph-accent-ink);
    font-size: 1.0625rem;
    font-weight: 700;
    text-decoration: none;
  }

  /* A hero whose text and counters step aside on the phone keeps only its buttons, without the hero look. */
  .hero-panel.ph-hero-plain { padding: 0; margin-bottom: 12px; border: 0; background: none; box-shadow: none; color: inherit; }
  .hero-panel.ph-hero-plain::after { display: none; }
  .hero-panel.ph-hero-plain .action-row { margin-top: 0; }
  /* Tables that fit the width stay tables, with text allowed to wrap (phone.js decides). */
  table.phone-fit th, table.phone-fit td { white-space: normal !important; padding: 8px 6px !important; font-size: 0.9375rem; }
  table.phone-fit th { font-size: 0.875rem; }

  /* 320px is the WCAG reflow width: grids and rows that assumed 320px of content widened the page there. */
  .dc-panels, .ops-calendar-shell, .ops-panel-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .ops-calendar-topbar > * { min-width: 0; max-width: 100%; }
  .ops-calendar-topbar h2, .ops-calendar-topbar h3, .ops-calendar-topbar p, .ops-calendar-topbar .mono { overflow-wrap: anywhere; }
  .entity-card-header { flex-wrap: wrap; }
  .ops-calendar-actions { flex-wrap: wrap !important; max-width: 100%; }
  .ops-calendar-actions > a.pill, .ops-calendar-actions > .pill { display: inline-flex; align-items: center; min-height: 44px; }

  /* data-phone-collapse / data-phone-list (phone.js) */
  .ph-collapsed, .ph-more-hidden { display: none !important; }
  .ph-collapse-toggle, .ph-more-button {
    display: flex; align-items: center; justify-content: space-between; width: 100%;
    min-height: 48px; margin: 0 0 12px; padding: 0 16px;
    border: 1px solid var(--ph-line); border-radius: 12px;
    background: var(--ph-surface); color: var(--ph-ink);
    font-size: 1rem; font-weight: 700; text-align: left;
  }
  .ph-collapse-toggle::after { content: "BE"; color: var(--ph-muted); font-size: 1.1rem; }
  .ph-collapse-toggle[aria-expanded="true"]::after { content: "B4"; }
  .ph-more-button { justify-content: center; color: var(--ph-accent); }

  /* ---- Shared phone pieces used by the phone screens ---- */
  .ph-segment {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 4px;
    padding: 4px;
    margin: 0 0 12px;
    border-radius: 12px;
    background: #e3eaf1;
  }
  .ph-segment a {
    display: flex; align-items: center; justify-content: center;
    min-height: 44px;
    border-radius: 9px;
    color: var(--ph-ink);
    font-weight: 700;
    text-decoration: none;
  }
  .ph-segment a[aria-current="page"] { background: var(--ph-surface); color: var(--ph-accent); box-shadow: 0 1px 3px rgba(16,39,61,.15); }
  .ph-status-line { margin: 0 0 12px; font-size: 1rem; font-weight: 600; color: var(--ph-ink); }
  .ph-card {
    margin: 0 0 12px;
    padding: 14px;
    border: 1px solid var(--ph-line);
    border-radius: var(--ph-radius);
    background: var(--ph-surface);
  }
  .ph-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
  .ph-card-title { margin: 0; font-size: 1.125rem; font-weight: 700; line-height: 1.3; color: var(--ph-ink); }
  .ph-meta { margin: 4px 0 0; font-size: 0.875rem; color: var(--ph-muted); }
  .ph-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-top: 1px solid var(--ph-line);
  }
  .ph-row:first-of-type { border-top: 0; }
  .ph-row-title { font-size: 1rem; font-weight: 600; color: var(--ph-ink); }
  .ph-row-meta { font-size: 0.875rem; color: var(--ph-muted); }
  .ph-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 48px; min-width: 48px; padding: 0 14px;
    border-radius: 12px; border: 0;
    background: var(--ph-accent); color: var(--ph-accent-ink);
    font-size: 1rem; font-weight: 700; text-decoration: none; white-space: nowrap;
  }
  .ph-btn.is-quiet { background: #e7f0f8; color: var(--ph-accent); }
  .ph-btn svg { width: 22px; height: 22px; }
  .ph-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
  .ph-links a {
    display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px;
    border: 1px solid var(--ph-line); border-radius: 10px;
    color: var(--ph-accent); font-weight: 600; text-decoration: none; background: var(--ph-surface);
  }
  .ph-empty { padding: 24px 16px; text-align: center; color: var(--ph-muted); font-size: 1rem; }

  /* Status chips: always a word, colour only supports it (WCAG 1.4.1). */
  .ph-chip {
    display: inline-flex; align-items: center; gap: 4px;
    min-height: 28px; padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.875rem; font-weight: 700; line-height: 1.2; white-space: nowrap;
    border: 1px solid transparent;
  }
  .ph-chip.is-turnover { background: #fde8e6; color: #8f1a12; border-color: #f3b9b3; }
  .ph-chip.is-checkout { background: #fff1db; color: #7a4300; border-color: #f1cf98; }
  .ph-chip.is-arrival  { background: #e3f0fb; color: #0b4675; border-color: #b4d3ee; }
  .ph-chip.is-stayover, .ph-chip.is-occupied { background: #e6f3ea; color: #1b5e33; border-color: #b7dcc2; }
  .ph-chip.is-vacant   { background: #eef1f4; color: #3f5163; border-color: #d2dae2; }
  .ph-chip.is-done     { background: #e6f3ea; color: #1b5e33; border-color: #b7dcc2; }
  .ph-chip.is-todo     { background: #eef1f4; color: #3f5163; border-color: #d2dae2; }

  /* Live check 2026-11-25 (app 1.2.12 test, operator session): the Home tile labels were 12.5px
     (notifications.css loads after this file, hence the .ops-tile scope), the "view tasks" link 19px tall,
     and the task filter chips 13.6px (inline style, hence !important). */
  .ops-tile .ops-label { font-size: .875rem; }
  .stat-card .muted a { display: inline-flex; align-items: center; min-height: 44px; }
  .task-filter { display: inline-flex; align-items: center; justify-content: center; min-width: 48px; min-height: 48px; font-size: 1rem !important; }
  .task-col-head { font-size: .875rem !important; }
  .task-empty { font-size: 1rem !important; }
  .task-fold { display: flex; align-items: center; min-height: 44px; }
  .task-title { display: inline-flex; align-items: center; min-height: 44px; }
}
