/* Applications on a phone (G2: the kanban and its block-layout topbar). Split #8 of index.html: moved unchanged,
   wrapped in the same @media it sat in, and linked at the exact spot it used to sit (the phone block is closed and
   reopened around the link) so the cascade order is the same. */
@media (max-width: 768px) {
    /* ════════════════════════════════════════════════════════════════
       G2. Applications page (kanban + custom block-layout topbar)
       Outside-dev confirmed plain block layout works (display:contents
       + grid was buggy in Safari for the inline page-title SPAN).
    ════════════════════════════════════════════════════════════════ */
    /* Topbar — flex row: topbar-left (block stack) + topbar-right (button) */
    #page-apps .topbar {
      display: flex !important;
      flex-direction: row !important;
      flex-wrap: nowrap !important;
      align-items: center !important;
      /* Hamburger is bottom-left now, so the topbar reclaims its left edge.
         Top padding/margin/sticky-offset all account for notch (H3). */
      padding: max(12px, var(--safe-top)) 14px 12px !important;
      margin: max(8px, var(--safe-top)) 10px 0 !important;
      gap: 10px !important;
      min-height: 0 !important;
      height: auto !important;
      overflow: visible !important;
      flex: 0 0 auto !important;
      position: sticky; top: max(8px, var(--safe-top)); z-index: 5;
      /* Background intentionally inherits the desktop blue-glass gradient
         so the look is continuous across breakpoints. */
    }
    #page-apps .topbar-left {
      flex: 1 1 auto !important;
      min-width: 0 !important;
      padding-left: 0 !important;
      display: block !important;   /* plain block; children stack naturally */
    }
    #page-apps .topbar-right {
      flex: 0 0 auto !important;
      width: auto !important;
      padding: 0 !important;
      margin: 0 !important;
      align-self: center !important;
    }
    #page-apps .page-title {
      display: block !important;   /* SPAN forced to block so it owns its row */
      font-size: 17px !important;
      font-weight: 600 !important;
      letter-spacing: -0.022em !important;
      line-height: 1.25 !important;
      margin: 0 !important;
      padding: 0 !important;
      text-align: center !important;   /* centered between hamburger and Add button */
    }
    /* KPI tiles hidden on mobile — too noisy for small screens */
    #page-apps .topbar .topbar-tabs { display: none !important; }
    /* Apps topbar — compact icon-only squares matching all other pages */
    #page-apps .topbar-right .btn-add,
    #page-apps .topbar-right .filter-btn-mobile,
    #page-apps .topbar-right .search-btn-mobile {
      width: 34px !important;
      height: 34px !important;
      min-height: 34px !important;
      padding: 0 !important;
      border-radius: 10px !important;
      justify-content: center !important;
    }
    #page-apps .topbar-right .btn-add i,
    #page-apps .topbar-right .filter-btn-mobile i,
    #page-apps .topbar-right .search-btn-mobile i { width: 15px !important; height: 15px !important; }
    /* Show the Apps Search and Filter pills on mobile (kept hidden on desktop) */
    #page-apps .topbar-right .search-btn-mobile,
    #page-apps .topbar-right .filter-btn-mobile { display: inline-flex !important; }
    /* Equal spacing between the three pills */
    #page-apps .topbar-right { gap: 8px !important; }
    /* "Applications" is a long title, so always drop Search/Filter labels on
       Apps mobile (icons stay) — keeps the title from truncating to "Appli..." */
    #page-apps .search-btn-mobile span,
    #page-apps .filter-btn-mobile span:not(.filter-badge) { display: none; }
    #page-apps .topbar-right .search-btn-mobile,
    #page-apps .topbar-right .filter-btn-mobile {
      padding: 8px 10px !important;
      min-width: 36px;
      justify-content: center;
    }
    /* When the unit-chips bar lives inside #page-apps, drop the sticky
       positioning entirely — its global mobile rule sticks the chips at
       top: 56px, but the Apps topbar height varies on iOS Safari (notch /
       dynamic-island padding), causing the chips to sit *under* the bottom
       edge of the topbar mid-scroll. Flowing chips naturally below the
       topbar guarantees they're never clipped, regardless of topbar height.
       Also force flex: 0 0 auto + a min-height so the chips can never be
       compressed by the parent's flex layout (iOS Safari is more aggressive
       about flex-shrinking children of an overflow:auto column container). */
    #page-apps #unit-chips {
      position: relative !important;
      top: auto !important;
      z-index: auto !important;
      flex: 0 0 auto !important;
      flex-shrink: 0 !important;
      min-height: 78px !important;       /* 50px tile + 14+14 padding + safety */
      box-sizing: border-box !important;
    }
    #page-apps #unit-chips .uchip { flex-shrink: 0 !important; }

    /* ════════════════════════════════════════════════════════════════
       G2b. Tasks page — mirror the Apps mobile shell so the two tabs
       feel continuous. The topbar becomes a floating blue-glass card
       (same gradient as #page-apps), and the .tasks-toolbar below
       compacts into a tidy 4-row layout that fits an iPhone width.
    ════════════════════════════════════════════════════════════════ */
    #page-tasks .topbar {
      display: none !important; /* mobile: search/filter/New moved to the top-bar ⋮ menu, so the title row is dropped */
      flex-direction: row !important;
      flex-wrap: nowrap !important;
      align-items: center !important;
      /* Top padding/margin/sticky-offset all account for notch (D1). */
      padding: max(12px, var(--safe-top)) 14px 12px !important;
      margin: max(8px, var(--safe-top)) 10px 0 !important;
      gap: 10px !important;
      min-height: 0 !important;
      height: auto !important;
      border-radius: 14px !important;
      overflow: visible !important;
      flex: 0 0 auto !important;
      position: sticky; top: max(8px, var(--safe-top)); z-index: 5;
      background:
        linear-gradient(90deg,
          #1a1a2e 0%,
          #1a1a2e 18%,
          rgba(30,40,80,0.95) 35%,
          rgba(50,75,140,0.88) 55%,
          rgba(95,135,200,0.70) 75%,
          rgba(150,185,235,0.55) 90%,
          rgba(180,210,255,0.50) 100%),
        radial-gradient(circle at 95% 100%, rgba(100,160,240,0.32) 0%, transparent 55%) !important;
      backdrop-filter: blur(18px) saturate(1.6);
      -webkit-backdrop-filter: blur(18px) saturate(1.6);
      border: 1px solid rgba(200,220,255,0.55) !important;
      box-shadow:
        0 6px 20px rgba(20,50,140,0.15),
        0 1px 3px rgba(0,0,0,0.06),
        inset 0 1px 0 rgba(255,255,255,0.6),
        inset 0 -1px 0 rgba(80,130,210,0.12) !important;
    }
    #page-tasks .topbar-left {
      flex: 1 1 auto !important;
      min-width: 0 !important;
      padding-left: 0 !important;
      display: block !important;
    }
    #page-tasks .topbar-right {
      flex: 0 0 auto !important;
      width: auto !important;
      padding: 0 !important;
      margin: 0 !important;
      align-self: center !important;
    }
    #page-tasks .page-title {
      display: block !important;
      color: #ffffff !important;
      font-size: 17px !important;
      font-weight: 600 !important;
      letter-spacing: -0.022em !important;
      line-height: 1.25 !important;
      margin: 0 !important;
      padding: 0 !important;
      text-align: left !important;
    }
    /* Tasks topbar — compact icon-only squares matching all other pages */
    #page-tasks .topbar-right .search-btn-mobile,
    #page-tasks .topbar-right .filter-btn-mobile { display: inline-flex !important; }
    #page-tasks .topbar-right .btn-add,
    #page-tasks .topbar-right .filter-btn-mobile,
    #page-tasks .topbar-right .search-btn-mobile {
      width: 34px !important;
      height: 34px !important;
      min-height: 34px !important;
      padding: 0 !important;
      border-radius: 10px !important;
      justify-content: center !important;
    }
    #page-tasks .topbar-right .search-btn-mobile i,
    #page-tasks .topbar-right .filter-btn-mobile i,
    #page-tasks .topbar-right .btn-add i { width: 15px !important; height: 15px !important; }
    #page-tasks .topbar-right { gap: 6px !important; }
    /* Tasks view toggle: compact icon-only squares, hide List/Kanban labels */
    #page-tasks .tasks-view-toggle button {
      width: 34px !important;
      height: 34px !important;
      padding: 0 !important;
      justify-content: center !important;
      border-radius: 8px !important;
    }
    #page-tasks .tasks-view-toggle .btn-add-label { display: none !important; }
    #page-tasks .topbar-right .search-btn-mobile {
      padding: 8px 10px !important;
      min-width: 36px;
      justify-content: center;
    }
    /* On very narrow phones, also drop the Filter label so the row never wraps */
    @media (max-width: 380px) {
      #page-tasks .filter-btn-mobile span:not(.filter-badge) { display: none; }
      #page-tasks .topbar-right .filter-btn-mobile {
        padding: 8px 10px !important; min-width: 36px; justify-content: center;
      }
    }

    /* Mobile search row (toggleable via body.searching-tasks) */
    #tasks-srch-row-mobile { display: none; }
    body.searching-tasks #tasks-srch-row-mobile { display: block; }

    /* Hide the full .tasks-toolbar on mobile by default. Selects stay in
       the DOM (so tasksRender() can read them); the user accesses them
       through the slide-up sheet below. */
    #page-tasks .tasks-toolbar { display: none; }
    body.tasks-filters-open #page-tasks .tasks-toolbar {
      display: flex !important;
      flex-direction: column !important;
      align-items: stretch !important;
      gap: 12px !important;
      position: fixed; left: 0; right: 0; bottom: 0;
      max-height: 80vh; overflow-y: auto;
      z-index: 1060; /* above the fixed tab bar (1050) so lower filters aren't hidden */
      background: var(--bg) !important;
      border: 1px solid var(--border) !important;
      border-bottom: none !important;
      border-radius: 18px 18px 0 0 !important;
      margin: 0 !important;
      padding: 22px 18px max(22px, var(--safe-bottom)) 18px !important;
      box-shadow: 0 -12px 40px rgba(0,0,0,0.22) !important;
      backdrop-filter: none !important;
      -webkit-backdrop-filter: none !important;
      animation: filters-slide-up 0.22s ease;
    }
    body.tasks-filters-open #page-tasks .tasks-toolbar::before {
      content: 'Filter tasks';
      display: block;
      font-size: 15px; font-weight: 600;
      color: var(--text);
      padding-bottom: 4px;
      border-bottom: 1px solid var(--border);
      margin-bottom: 4px;
    }
    /* Suppress the desktop shimmer animation inside the sheet */
    body.tasks-filters-open #page-tasks .tasks-toolbar::after { display: none !important; }
    body.tasks-filters-open #page-tasks .tasks-toolbar > * {
      flex: 0 0 auto !important;
      min-height: 44px;
      width: 100% !important;
      max-width: none !important;
    }
    body.tasks-filters-open #page-tasks .tasks-toolbar .form-input {
      height: auto !important;
      font-size: 14px;
      padding: 12px 14px;
    }
    /* Search lives in #tasks-srch-row-mobile, not in the sheet */
    body.tasks-filters-open #page-tasks .tasks-toolbar .tasks-search { display: none !important; }
    /* Inline flex spacer is meaningless in a column layout */
    body.tasks-filters-open #page-tasks .tasks-toolbar > div[style*="flex:1"] { display: none !important; }
    /* View toggle: full-width row with equal halves */
    body.tasks-filters-open #page-tasks .tasks-toolbar .tasks-view-toggle { display: inline-flex !important; }
    body.tasks-filters-open #page-tasks .tasks-toolbar .tasks-view-toggle button {
      flex: 1; justify-content: center;
    }
    body.tasks-filters-open #tasks-filters-backdrop { display: block; }
    body.tasks-filters-open #mobile-menu-btn { display: none !important; }

    /* ════════════════════════════════════════════════════════════════
       G2c. Tasks list — convert the desktop table into a tap-friendly
       card list. Each task becomes its own card: status circle + title
       + delete on row 1, then a meta row (due / assignee / related).
       The colored bar on the left edge encodes priority.
    ════════════════════════════════════════════════════════════════ */
    #page-tasks .tasks-table-wrap {
      padding: 12px 12px 22px !important;
    }
    #page-tasks .tasks-table {
      display: block !important;
      border-spacing: 0 !important;
      background: transparent !important;
    }
    #page-tasks .tasks-table thead { display: none !important; }
    #page-tasks .tasks-table tbody {
      display: flex !important;
      flex-direction: column;
      gap: 10px;
    }
    #page-tasks .tasks-table tbody tr {
      display: flex !important;
      flex-wrap: wrap;
      align-items: center;
      align-content: center;
      column-gap: 9px;
      row-gap: 3px;
      height: 66px !important;
      min-height: 66px !important;
      max-height: 66px !important;
      padding: 6px 12px 6px 16px !important;
      border-radius: 14px !important;
      background: linear-gradient(180deg, rgba(255,255,255,0.78) 0%, rgba(232,242,255,0.58) 100%) !important;
      border: 1px solid rgba(200,220,255,0.6) !important;
      box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 1px 2px rgba(40,80,160,0.06) !important;
      position: relative;
      overflow: hidden;
    }
    #page-tasks .tasks-table tbody tr.task-done {
      background: linear-gradient(180deg, rgba(220,240,225,0.55) 0%, rgba(205,230,215,0.40) 100%) !important;
      border-color: rgba(180,220,195,0.6) !important;
    }
    #page-tasks .tasks-table tbody tr:active { filter: brightness(0.97); }

    /* Priority bar on the left edge */
    #page-tasks .tasks-table tbody tr::before {
      content: '';
      position: absolute;
      left: 0; top: 0; bottom: 0;
      width: 4px;
      background: #cbd5e1;
      z-index: 1;
    }
    #page-tasks .tasks-table tbody tr[data-priority="low"]::before    { background: #3b82f6; }
    #page-tasks .tasks-table tbody tr[data-priority="medium"]::before { background: #eab308; }
    #page-tasks .tasks-table tbody tr[data-priority="high"]::before   { background: #f97316; }
    #page-tasks .tasks-table tbody tr[data-priority="urgent"]::before {
      background: #dc2626;
      box-shadow: 0 0 8px rgba(220,38,38,0.5);
    }
    #page-tasks .tasks-table tbody tr.task-done[data-priority]::before {
      opacity: 0.45; box-shadow: none;
    }

    /* Force a wrap between row 1 (status/title/×) and the meta row */
    #page-tasks .tasks-table tbody tr::after {
      content: '';
      flex-basis: 100%;
      order: 3;
      height: 0;
      margin: 0;
    }

    /* Strip td chrome — they become bare flex children */
    #page-tasks .tasks-table tbody td {
      display: block !important;
      padding: 0 !important;
      background: transparent !important;
      border: none !important;
      border-radius: 0 !important;
      box-shadow: none !important;
    }
    #page-tasks .tasks-table tbody td:first-child::before { display: none !important; }

    /* Row 1 — status circle */
    #page-tasks .tasks-table tbody td:nth-child(1) {
      order: 1;
      flex: 0 0 auto;
    }
    #page-tasks .tasks-table tbody .task-status-btn {
      width: 20px !important;
      height: 20px !important;
      min-width: 0 !important;
      min-height: 0 !important;
    }
    /* Hide priority dot — the colored bar conveys priority */
    #page-tasks .tasks-table tbody td:nth-child(2) { display: none !important; }
    /* Row 1 — title (fills remaining width) */
    #page-tasks .tasks-table tbody td:nth-child(3) {
      order: 2;
      flex: 1 1 0;
      min-width: 0;
      display: flex !important;
      align-items: center;
      gap: 6px;
      overflow: hidden;
    }
    #page-tasks .tasks-table tbody td:nth-child(3) .task-title {
      font-size: 14px;
      font-weight: 600;
      line-height: 1.25;
      color: #1a2f5c;
      min-width: 0;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    #page-tasks .tasks-table tbody tr.task-done .task-title {
      color: #4b6b5a;
      text-decoration: line-through;
    }
    /* Row 1 — × (right-aligned) */
    #page-tasks .tasks-table tbody td:nth-child(7) {
      order: 2;
      flex: 0 0 auto;
      margin-left: auto;
    }
    #page-tasks .tasks-table .task-row-menu {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 22px; height: 22px;
      font-size: 16px; line-height: 1;
      color: rgba(120,140,170,0.85);
      border-radius: 50%;
      padding: 0;
    }

    /* Row 2 — meta cells (due, assignee, related) */
    #page-tasks .tasks-table tbody td:nth-child(4),
    #page-tasks .tasks-table tbody td.col-assignee,
    #page-tasks .tasks-table tbody td.col-related {
      display: flex !important;       /* override the 640px hide below */
      align-items: center;
      min-width: 0;
    }
    #page-tasks .tasks-table tbody td:nth-child(4) {
      order: 4;
      flex: 0 0 auto;
      margin-left: 0;                 /* no indent — reclaim width for the meta pills */
    }
    #page-tasks .tasks-table tbody td.col-assignee {
      order: 5;
      flex: 0 1 auto;
      min-width: 0;
      max-width: 46%;
      overflow: hidden;
    }
    #page-tasks .tasks-table tbody td.col-related {
      order: 6;
      flex: 1 1 0;
      min-width: 0;
      overflow: hidden;
      justify-content: flex-end;
    }
    /* Hide the placeholder em-dash when a meta field is empty */
    #page-tasks .tasks-table tbody td.col-related > span[style*="color"],
    #page-tasks .tasks-table tbody td.col-assignee > span[style*="color"] {
      display: none;
    }
    /* Compact the related chip */
    #page-tasks .task-related {
      max-width: 100%;
      padding: 3px 9px;
    }
    #page-tasks .task-related .tr-label { max-width: 130px; }
    /* Let the related chip shrink + its label ellipsize instead of the cell hard-cutting the pill */
    #page-tasks .tasks-table tbody .task-related { max-width: 100%; min-width: 0; }
    #page-tasks .tasks-table tbody .task-related .tr-type { flex: 0 0 auto; }
    #page-tasks .tasks-table tbody .task-related .tr-label { flex: 0 1 auto; min-width: 0; max-width: none; }
    /* Tighter pills so the title + meta rows fit the locked card height */
    #page-tasks .tasks-table tbody .task-assignee,
    #page-tasks .tasks-table tbody .task-related,
    #page-tasks .tasks-table tbody .task-due-pill { padding: 2px 8px !important; font-size: 10.5px !important; }
    #page-tasks .tasks-table tbody .task-assignee .ta-avatar {
      width: 15px !important; height: 15px !important; font-size: 8px !important;
    }

    /* Apps search row + filter sheet hidden by default on mobile */
    #apps-srch-row-mobile { display: none; }
    #apps-controls { display: none; }

    /* Fixed-height board — columns share a common bottom edge and each
       column scrolls vertically on its own instead of the whole page.
       Note: no !important on `display` — showPage() toggles inline
       style.display between 'none' and 'flex' to switch tabs, and an
       !important here would pin the Apps page visible on every tab. */
    #page-apps {
      overflow: hidden !important;
      height: 100dvh !important; min-height: 0 !important;
      flex-direction: column !important;
    }
    #page-apps .kanban-wrap {
      overflow-x: auto !important;
      overflow-y: hidden !important;
      flex: 1 1 0 !important;
      align-items: stretch !important;
      min-height: 0 !important;
      margin-left: 0 !important; margin-right: 0 !important;   /* desktop edge-insets off on phones (full-bleed board) */
      -webkit-mask-image: none !important; mask-image: none !important;   /* desktop edge-fade off on phones */
      padding: 10px 18px 14px !important;  /* 18px sides — matches the chip-bar visual inset */
      gap: 8px !important;
      scroll-snap-type: x proximity;
      /* Without scroll-padding the snap engine aligns the first column to
         scrollLeft:0 *inside* the padding, visually canceling our 18px inset.
         scroll-padding tells snap to honor the same 18px offset on both ends. */
      scroll-padding-left: 18px;
      scroll-padding-right: 18px;
      -webkit-overflow-scrolling: touch;
    }
    /* Mobile kanban — ~10% smaller across the board */
    #page-apps .kanban-col {
      width: 149px !important;
      height: 100% !important; max-height: 100% !important; min-height: 0 !important;
      scroll-snap-align: start;
    }
    #page-apps .kanban-cards {
      max-height: none !important;
      overflow-y: auto !important; overflow-x: hidden !important;
      -webkit-overflow-scrolling: touch;
      overscroll-behavior: contain;
      flex: 1 1 0 !important; min-height: 0 !important;
      padding: 5px !important; gap: 5px !important;
    }
    /* Column header */
    #page-apps .kanban-col-header { padding: 0 2px 5px !important; }
    #page-apps .kanban-col-title  { font-size: 9px !important;  letter-spacing: 0.06em !important; }
    #page-apps .kanban-col-count  { font-size: 9px !important;  padding: 1px 5px !important; }
    /* Cards — compact */
    #page-apps .kanban-card { padding: 8px 10px !important; border-radius: 9px !important; }
    #page-apps .kc-name     { font-size: 11px !important; margin-bottom: 2px !important; overflow-wrap: anywhere; word-break: break-word; }
    #page-apps .kc-unit     { font-size: 9px !important;  margin-bottom: 5px !important; overflow-wrap: anywhere; word-break: break-word; }
    #page-apps .kc-tags     { gap: 3px !important; margin-bottom: 5px !important; }
    #page-apps .kc-tag      { font-size: 8px !important;  padding: 1px 5px !important; border-radius: 9px !important; }
    #page-apps .kc-meta-row { gap: 3px !important; margin-bottom: 5px !important; }
    #page-apps .kc-footer   { font-size: 8px !important; }
    #page-apps .kc-agent    { font-size: 9px !important; }
    #page-apps .kc-date     { font-size: 8px !important; }
    /* Decorative orb/grain — kill on phones for perf */
    .kanban-orb { display: none; }
    .kanban-grain { display: none; }
    /* Right-edge fade band — desktop scroll hint, but on the snapped mobile
       board it veils the partially-shown next column and reads as a vertical
       blur/warp down the right side. Kill it on phones. */
    #page-apps .kanban-wrap::after { display: none !important; }
    /* Phone, Applications board: the PAGE never scrolls, only each column does.
       #page-apps is 100dvh tall but starts under the brand bar and the body keeps
       the tab bar's bottom padding, so the document was ~126px taller than the
       screen. Swiping on a column header or a short column dragged the whole board
       up and left an empty strip above the tab bar. While the board is showing the
       document is locked; the board's own geometry (it ends exactly where the tab
       bar starts) is untouched. Phone only: desktop never reaches this block. */
    html:has(#page-apps[style*="display: flex"]),
    html:has(#page-apps[style*="display: flex"]) body {
      overflow: hidden !important;
      overscroll-behavior: none;
    }
}

/* ── Fix #46 (26 Nov 2026): the phone board shows ONE stage at a time ─────────────────────────────────────────
   At 400px the nine-column board was ~2.5 cramped columns with clipped names and no title, search or filter.
   Under 768px the page now opens with its own large title (the Tasks / Residents phone look), a search box, the
   existing Filter sheet and Add, and a row of stage pills with counts (#apps-mhead in index.html, pills drawn by
   appsPhoneStageSync() in applications.js). Since 27 Nov the board swipes sideways between stages, one column per
   screen, and every card is the same size (see below). Desktop is untouched: the head is hidden above 768px and every other rule here is phone-only.
   Shell tokens only (CLAUDE.md "New screens match the app's design"). */
.apps-mhead { display: none; }
@media (max-width: 768px) {
  #page-apps .apps-mhead {
    display: block; flex: 0 0 auto;
    padding: 6px 16px 0; background: var(--bg2); color: var(--text);
  }
  #page-apps .apps-mhead-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  #page-apps .apps-mtitle {
    font-size: 30px; font-weight: 800; letter-spacing: -.6px; line-height: 1.1;
    color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  #page-apps .apps-mhead-actions { display: flex; align-items: center; gap: 8px; flex: none; }
  #page-apps .apps-mhead .apps-mbtn {
    position: relative; width: 40px; height: 40px; min-width: 40px; min-height: 40px;
    padding: 0; border-radius: 50%; justify-content: center;
  }
  #page-apps .apps-mhead .apps-mbtn svg { width: 18px; height: 18px; }
  #page-apps .apps-mfilter-badge {
    position: absolute; top: -3px; right: -3px;
    min-width: 17px; height: 17px; padding: 0 4px; box-sizing: border-box;
    align-items: center; justify-content: center;
    border-radius: 9px; font-size: 10px; font-weight: 700; line-height: 1;
    background: var(--accent); color: var(--bg);
  }
  #page-apps .apps-msearch { position: relative; margin-top: 10px; }
  #page-apps .apps-msearch > svg,
  #page-apps .apps-msearch > i {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    width: 17px; height: 17px; color: var(--text2); pointer-events: none; z-index: 1;
  }
  #page-apps .apps-msearch .form-input {
    width: 100%; height: 40px; box-sizing: border-box; margin: 0;
    padding: 0 14px 0 40px; border-radius: 20px; -webkit-appearance: none; appearance: none;
    font-size: 16px; /* 16px stops iOS zooming the page on focus */
  }
  #page-apps .apps-stage-pills {
    display: flex; gap: 6px; overflow-x: auto; overflow-y: hidden;
    margin: 10px -16px 0; padding: 0 16px 8px; scroll-padding: 0 16px;
    /* run to the screen edge with a soft fade, so a cut-off pill reads as "scroll for more" */
    -webkit-mask-image: linear-gradient(to right, var(--bg) 0, var(--bg) calc(100% - 28px), transparent 100%);
    mask-image: linear-gradient(to right, var(--bg) 0, var(--bg) calc(100% - 28px), transparent 100%);
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  #page-apps .apps-stage-pills::-webkit-scrollbar { display: none; }
  #page-apps .apps-stage-pill {
    flex: none; display: inline-flex; align-items: center; gap: 7px;
    height: 36px; min-height: 36px; padding: 0 12px 0 14px;
    border-radius: 18px; border: 1px solid var(--border2);
    background: var(--bg); color: var(--text2);
    font-family: inherit; font-size: 14px; font-weight: 600; white-space: nowrap; cursor: pointer;
  }
  #page-apps .apps-stage-pill[aria-selected="true"] {
    background: var(--accent-soft); color: var(--accent); border-color: var(--accent);
  }
  #page-apps .apps-stage-pill-n {
    min-width: 20px; padding: 1px 6px; box-sizing: border-box; text-align: center;
    border-radius: 10px; font-size: 12px; font-weight: 700;
    background: var(--bg3); color: var(--text2);
  }
  #page-apps .apps-stage-pill[aria-selected="true"] .apps-stage-pill-n { background: var(--bg); color: var(--accent); }

  /* All stages side by side, one column per screen, swiped sideways like the stage pills (Reuven, 27 Nov 2026).
     Each column is a little narrower than the screen so the next one peeks in. Swiping snaps to a column and
     moves the pill; tapping a pill slides the board (appsPhoneStageSync / _appsPhoneOnBoardScroll in
     applications.js). Gated on data-phone-stage so the board never changes before the picker has run. */
  #page-apps .kanban-wrap[data-phone-stage] {
    overflow-x: auto !important; overflow-y: hidden !important;
    scroll-snap-type: x mandatory; scroll-padding: 0 16px;
    overscroll-behavior-x: contain;
    padding: 4px 16px 12px !important; gap: 10px !important;
    scrollbar-width: none;
  }
  #page-apps .kanban-wrap[data-phone-stage]::-webkit-scrollbar { display: none; }
  /* Room after the last column so it can snap into place like the others. */
  #page-apps .kanban-wrap[data-phone-stage]::after { content: ''; flex: 0 0 16px; }
  #page-apps .kanban-wrap[data-phone-stage] .kanban-col {
    display: flex; flex: 0 0 auto; width: calc(100% - 26px) !important; min-width: 0;
    scroll-snap-align: start; scroll-snap-stop: always;
  }
  /* The pill already names the stage and its count, so no column header on the phone. The Incomplete "Remind all"
     bell moves up beside Filter and + (#apps-mremind-btn), so every column's tiles start at the same height
     (Reuven, 28 Nov 2026). */
  #page-apps .kanban-wrap[data-phone-stage] .kanban-col-header { display: none; }
  #page-apps .kanban-wrap[data-phone-stage] .kanban-cards { padding: 8px !important; gap: 8px !important; }
  #page-apps .kanban-wrap[data-phone-stage] .kanban-empty { font-size: 14px; padding: 24px 12px; }

  /* Every tile the same size (Reuven, 27 Nov 2026). One line each for name, address, agent and the tasks /
     follow-up row, cut with "..."; a missing address keeps its line so names and addresses line up; "New" sits
     in the top right corner; the footer is pinned to the bottom. If a card ever holds more than fits, the
     middle rows give way first, never the name or the footer. */
  #page-apps .kanban-wrap[data-phone-stage] .kanban-card {
    position: relative; box-sizing: border-box;
    display: flex; flex-direction: column; flex: 0 0 auto;
    height: 134px !important; min-height: 0; overflow: hidden;
    padding: 12px 14px !important; border-radius: 12px !important; cursor: pointer;
  }
  #page-apps .kanban-wrap[data-phone-stage] .kanban-card:hover { transform: none; }
  #page-apps .kanban-wrap[data-phone-stage] .kanban-card > * { flex: 0 0 auto; min-width: 0; }
  #page-apps .kanban-wrap[data-phone-stage] .kc-name {
    font-size: 15px !important; line-height: 1.3; margin-bottom: 3px !important;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  #page-apps .kanban-wrap[data-phone-stage] .kanban-card:has(.kc-tag-new) .kc-name { padding-right: 46px; }
  #page-apps .kanban-wrap[data-phone-stage] .kc-name.kc-name-group { display: flex; align-items: baseline; }
  #page-apps .kanban-wrap[data-phone-stage] .kc-name-group .kc-name-primary {
    min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  #page-apps .kanban-wrap[data-phone-stage] .kc-name-group .kc-name-more { flex: none; }
  #page-apps .kanban-wrap[data-phone-stage] .kc-unit {
    font-size: 13px !important; line-height: 1.35; height: 1.35em; margin-bottom: 7px !important;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  #page-apps .kanban-wrap[data-phone-stage] .kc-tags,
  #page-apps .kanban-wrap[data-phone-stage] .kc-meta-row {
    flex: 0 1 auto; min-height: 0; overflow: hidden; flex-wrap: nowrap !important;
    gap: 10px !important; margin-bottom: 5px !important;
  }
  #page-apps .kanban-wrap[data-phone-stage] .kc-tag {
    font-size: 12px !important; line-height: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  #page-apps .kanban-wrap[data-phone-stage] .kc-tags:has(.kc-tag-new) {
    position: absolute; top: 12px; right: 14px; margin: 0 !important;
  }
  #page-apps .kanban-wrap[data-phone-stage] .kc-tags:has(.kc-tag-new) .kc-tag { width: auto; }
  #page-apps .kanban-wrap[data-phone-stage] .kc-footer { margin-top: auto; flex-shrink: 0; min-width: 0; gap: 8px; }
  #page-apps .kanban-wrap[data-phone-stage] .kc-footer,
  #page-apps .kanban-wrap[data-phone-stage] .kc-rem,
  #page-apps .kanban-wrap[data-phone-stage] .kc-funding-sent,
  #page-apps .kanban-wrap[data-phone-stage] .kc-tour-status,
  #page-apps .kanban-wrap[data-phone-stage] .kc-date { font-size: 12px !important; line-height: 16px; }
}
