/* Task Helper — the Tables screen (job-intake.md §31; slice TB-1, BRIEF-956). Copyright Rapid Surveys Pty Ltd.
 * App tokens only (--bg --card --ink --muted --line --accent --accent-ink --ok --err --hover). Namespaced .tb-. Phone first:
 * cards below 768 px, a grid above it (its own sideways scroll inside its box — the page never scrolls sideways). */
.tb-screen.overlay { display: block; background: var(--bg); overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
html.tb-open { overflow: hidden; } html.tb-open body { overflow: clip; }   /* PHONE2: see hub.css — 'hidden' on body doubled the sticky top bar's offset under a notice strip */
.tb-bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; min-height: 56px;
  padding: max(8px, env(safe-area-inset-top)) 12px 8px; background: var(--ink); color: #fff; }
html.th-under .tb-bar { padding-top: 8px; }   /* BRIEF-1307: under the app's top bar, which carries the safe area */
.tb-titles { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tb-titles h2 { margin: 0; font-size: 18px; line-height: 1.25; color: #fff; text-transform: none; letter-spacing: 0; overflow-wrap: anywhere; outline: none; }
.tb-co { font-size: 12px; color: #9aa6b5; overflow-wrap: anywhere; }
.tb-back, .tb-x { width: auto; flex: none; margin: 0; min-height: 44px; min-width: 44px; padding: 0 8px; border: 0; border-radius: 8px;
  background: transparent; color: #fff; font-size: 15px; font-weight: 600; }
.tb-back { max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-x { font-size: 20px; }
.tb-back:focus-visible, .tb-x:focus-visible { outline-color: #fff; }
.tb-wrap { max-width: 1200px; margin: 0 auto; padding: 12px 16px 96px; }
.tb-msg { margin: 0 0 10px; }
.tb-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.tb-actions:empty { display: none; }
.tb-chip { padding: 0 10px; min-width: var(--btn-h); font-size: 13px; }   /* the shared .btn does the look; this is the small-label size */
.tb-chip:disabled { opacity: .4; }
.tb-check { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 12px; min-height: 44px; font-size: 14px; color: var(--ink); cursor: pointer; }
.tb-check input { width: 20px; height: 20px; margin: 0; }
.tb-pill { display: inline-block; padding: 0 7px; border: 1px solid var(--line); border-radius: 9px; font-size: 11px; font-weight: 600;
  color: var(--muted); background: var(--bg); vertical-align: middle; }
.tb-pill-verify { color: #8a5a00; border-color: #b8860b; background: #fff6dd; }
.tb-pill-name { color: var(--accent); border-color: var(--accent); background: var(--card); }
.tb-note { margin: 0 0 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); font-size: 14px; }
.tb-count { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.tb-none { color: var(--muted); }
.tb-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* cards: the table list, and rows on a phone */
.tb-cards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.tb-card { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; width: 100%; margin: 0; padding: 12px 14px; text-align: left;
  background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; font: inherit; min-height: 52px; }
button.tb-card:hover { background: var(--hover, var(--bg)); }
.tb-card-name { font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.tb-card-sub, .tb-card-line { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.tb-card-line b { color: var(--ink); font-weight: 600; }
.tb-retired { opacity: .7; }

/* search */
.tb-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0 0 4px; }
.tb-filter input[type="search"] { flex: 1 1 220px; min-width: 0; margin: 0; padding: 10px 12px; font-size: 16px; }
.tb-filter .tb-check { margin: 0; }

/* the grid (desktop) */
/* Gary 2026-11-04: the grid view uses the whole screen and its sideways bar is pinned to the viewport bottom — the screen is a
 * column (bar, controls, scroll box); the table scrolls BOTH ways inside .tb-gridwrap, whose own horizontal bar is therefore the
 * last thing on screen. The name column and header row stay frozen (sticky). Other table screens scroll as before. */
.tb-screen.tb-fit.overlay { display: flex; flex-direction: column; align-items: stretch; overflow: hidden; }   /* .overlay's own align-items is flex-end */
.tb-fit .tb-bar { flex: none; }
.tb-fit .tb-wrap { flex: 1 1 auto; min-height: 0; max-width: none; width: 100%; box-sizing: border-box; display: flex; flex-direction: column; padding-bottom: 0; margin: 0; }
.tb-fit .tb-wrap > .msg { flex: none; }
.tb-fit #tbBody { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.tb-fit #tbBody > * { flex: none; }
.tb-fit #tbBody > .tb-gridwrap { flex: 0 1 auto; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.tb-fit #tbBody > .tb-selbar { margin-bottom: 8px; }
.tb-fit .tb-gridwrap > .tb-more { position: sticky; left: 12px; width: auto; margin: 12px 0 12px 12px; display: block; }
.tb-gridwrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.tb-grid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 14px; }
.tb-grid th, .tb-grid td { padding: 0; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tb-grid thead th { position: sticky; top: 0; padding: 10px 12px; background: var(--bg); color: var(--muted); font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; z-index: 1; }
.tb-grid tr > :first-child { position: sticky; left: 0; z-index: 1; background: var(--card); border-right: 1px solid var(--line); min-width: 180px; font-weight: 600; }
.tb-grid thead tr > :first-child { background: var(--bg); z-index: 2; }
.tb-grid tbody tr:last-child > * { border-bottom: 0; }
.tb-grid td, .tb-grid tbody th { min-width: 120px; max-width: 320px; }
.tb-grid .tb-cell > :not(button):not(.tb-cell-edit), .tb-grid .tb-cell { overflow-wrap: anywhere; }
.tb-grid .tb-cell:not(:has(button)):not(:has(.tb-cell-edit)) { padding: 10px 12px; }
.tb-cellbtn { display: block; width: 100%; min-height: 44px; margin: 0; padding: 10px 12px; border: 0; border-radius: 0; background: transparent;
  color: var(--ink); font: inherit; font-weight: inherit; text-align: left; cursor: text; overflow-wrap: anywhere; }
.tb-cellbtn:hover { background: var(--hover, var(--bg)); }
.tb-cellbtn a { color: var(--accent); }
.tb-long .tb-cellbtn, .tb-long { white-space: pre-line; }
.tb-num .tb-cellbtn { font-variant-numeric: tabular-nums; }
.tb-cell-edit { padding: 4px; }
.tb-cell-edit input, .tb-cell-edit select, .tb-cell-edit textarea { width: 100%; margin: 0; padding: 8px 10px; font-size: 15px; }
.tb-act { width: 1%; padding: 6px 8px !important; white-space: nowrap; }
.tb-act-h { width: 1%; }
.tb-more { margin-top: 12px; }

/* forms (new table, a row, Columns & settings) */
.tb-form { display: flex; flex-direction: column; gap: 10px; margin: 0 0 14px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); max-width: 640px; }
.tb-f { display: flex; flex-direction: column; gap: 4px; }
.tb-f label, .tb-f > span { font-size: 13px; color: var(--muted); margin: 0; }
.tb-f input, .tb-f select, .tb-f textarea { margin: 0; color: var(--ink); width: 100%; }
.tb-f select { padding: 12px; font-size: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.tb-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.tb-danger-row { padding-top: 8px; border-top: 1px solid var(--line); }
.tb-form .hint { margin: 0; font-size: 13px; color: var(--muted); }
.tb-fielderr { margin: 2px 0 0; font-size: 13px; }
[aria-invalid="true"] { border-color: var(--err) !important; }
.tb-h3 { margin: 18px 0 8px; font-size: 15px; }
.tb-form .tb-h3 { margin: 0; }

/* the column list (design) */
.tb-cols { list-style: none; margin: 0 0 8px; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--card); max-width: 640px; }
.tb-colrow { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-top: 1px solid var(--line); min-height: 56px; }
.tb-colrow:first-child { border-top: 0; }
.tb-colmain { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tb-colname { font-weight: 600; overflow-wrap: anywhere; }
.tb-coltype { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.tb-colbtns { display: flex; gap: 6px; flex: none; }
.tb-colrow .tb-colform { flex: 1; margin: 4px 0; border: 0; padding: 4px 0; max-width: none; }

@media (max-width: 420px) { .tb-colrow { flex-wrap: wrap; } .tb-colbtns { width: 100%; justify-content: flex-end; } }

/* the LOOKUP field on a task form + its settings (public/tables/lookup-field.js; TB-2, BRIEF-959) */
.lk-pick { position: relative; display: flex; align-items: stretch; gap: 6px; }
.lk-pick input { flex: 1; min-width: 0; margin: 0; }
.lk-pick input.lk-retired { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.lk-clear { width: auto; flex: none; margin: 0; min-width: 44px; min-height: 44px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--muted); font-size: 16px; }
.lk-show { display: flex; flex-direction: column; gap: 2px; margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.lk-show:empty { display: none; }
.lk-line { overflow-wrap: anywhere; } .lk-line b { color: var(--ink); font-weight: 600; } .lk-line a { color: var(--accent); }
.lk-pill { align-self: flex-start; display: inline-block; padding: 0 7px; border: 1px solid var(--line); border-radius: 9px; font-size: 11px; font-weight: 600; color: var(--muted); background: var(--bg); }
.lk-warn { margin: 6px 0 0; padding: 8px 10px; border: 1px solid var(--err); border-radius: 10px; font-size: 13px; color: var(--ink); background: var(--card); overflow-wrap: anywhere; }
.lk-act { width: auto; margin: 0; min-height: 32px; padding: 0 4px; border: 0; background: none; color: var(--accent); font: inherit; font-weight: 600; text-decoration: underline; }
.lk-err { color: var(--err); }
.lk-cfg { display: flex; flex-direction: column; gap: 6px; margin: 6px 0; }
.lk-cfg select { width: 100%; padding: 12px; font-size: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); }
.lk-cols { margin: 6px 0 0; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; }
.lk-cols legend { padding: 0 4px; font-size: 13px; color: var(--muted); }
.lk-colopt { display: flex; align-items: center; gap: 8px; min-height: 40px; margin: 0; font-size: 15px; color: var(--ink); cursor: pointer; }
.lk-colopt input { width: 20px; height: 20px; margin: 0; }
@media (pointer: coarse) { .lk-act { min-height: 44px; } }
/* TB-3 (BRIEF-964): a dependent's "isn't in" flag, the address offer, the settings' extra rows, link cells */
.lk-mis, .lk-offer { margin: 6px 0 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; font-size: 13px; color: var(--ink); background: var(--card); overflow-wrap: anywhere; }
.lk-mis { border-color: var(--err); }
.lk-sub { margin: 8px 0 2px; font-size: 12px; font-weight: 700; color: var(--muted); }
.lk-cfgrow { display: flex; flex-direction: column; gap: 4px; margin: 8px 0 0; }
.lk-cfgrow select { width: 100%; padding: 12px; font-size: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); }
.lk-when { display: flex; flex-direction: column; gap: 2px; margin: 4px 0 0; }
.lk-pick input:disabled { background: var(--bg); color: var(--muted); }
.tb-link { position: relative; }
.tb-link input[type="text"] { width: 100%; margin: 0; }
.tb-indiv { display: flex; align-items: center; gap: 8px; min-height: 44px; font-size: 14px; cursor: pointer; }   /* IN1: "Individual (no company)" under the Company search */
.tb-indiv input { width: 20px; height: 20px; margin: 0; flex: none; }
/* the client page door (§36): Open beside Edit in the grid; under the card on a phone */
.tb-act .tb-door { margin-right: 4px; }
.tb-door-card { display: block; width: 100%; min-height: 44px; margin: 4px 0 0; text-align: left; font-size: 14px; }

/* Gary 2026-10-17 (t-t17a): the tables that come with TaTasque look different from your own — tinted card + accent edge (the Preset badge stays) */
.tb-card.tb-preset { background: color-mix(in srgb, var(--accent) 8%, var(--card)); border-left: 4px solid var(--accent); }
button.tb-card.tb-preset:hover { background: color-mix(in srgb, var(--accent) 14%, var(--card)); }

/* NM-2 (job-intake §50.3): a written name on a Lookup field — "Is it …?", "Written as …", the matched note. App tokens only. */
.lk-isit { margin: 6px 0 0; padding: 12px; border: 1px solid var(--accent); border-radius: 12px; background: var(--card); font-size: 14px; color: var(--ink); overflow-wrap: anywhere; }
.lk-isit p { margin: 0 0 6px; }
.lk-isit-q { font-weight: 700; }
.lk-isit-who { font-weight: 700; font-size: 15px; }
.lk-isit-name { color: var(--accent); }
.lk-isit-why { color: var(--muted); font-size: 13px; }
.lk-isit-why b { color: var(--ink); }
.lk-isit-btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 0; }
.lk-btn { width: auto; margin: 0; min-height: 44px; padding: 0 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); font: inherit; font-weight: 600; }
.lk-btn-go { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.lk-btn:disabled { opacity: .5; }
.lk-elsebox, .lk-newbox { display: flex; flex-direction: column; gap: 4px; margin: 10px 0 0; padding: 10px 0 0; border-top: 1px solid var(--line); }
.lk-elsebox[hidden], .lk-newbox[hidden] { display: none; }
.lk-elsebox input[type="text"], .lk-newbox input[type="text"] { margin: 0; padding: 10px 12px; font-size: 16px; }
.lk-done { margin: 6px 0 0; padding: 8px 10px; border: 1px solid var(--ok); border-radius: 10px; font-size: 13px; color: var(--ink); background: var(--card); overflow-wrap: anywhere; }
.lk-wrote { margin: 6px 0 0; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
/* BE1: select rows → Change a field… (bulk-change.js draws inside the bar) */
.tb-tick, .tb-tick-h { width: 1%; padding: 0 6px !important; vertical-align: middle; }
.tb-tick .tb-tickbox, .tb-cardtick .tb-tickbox { width: 20px; height: 20px; margin: 0; flex: none; }
.tb-cardtick { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; cursor: pointer; }
.tb-cards li.tb-sel { display: flex; align-items: flex-start; gap: 4px; }
.tb-selbar { position: sticky; bottom: 0; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 12px 0 0; padding: 10px 12px; border: 1px solid var(--accent); border-radius: 10px; background: var(--card); box-shadow: 0 -4px 14px rgba(0, 0, 0, .08); }
.tb-seln { font-weight: 700; }
.tb-said { color: var(--muted); font-size: 14px; }
.tb-selact { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.tb-selact button { min-height: 44px; width: auto; margin: 0; }

/* MOVE TO COMPANY TAB (lane comove; public/tables/company-move.js). App tokens only; namespace cmv-. A sheet anchored to the TOP; a phone: full width. */
html.cmv-open, html.cmv-open body { overflow: hidden; }
.cmv-back { position: fixed; inset: 0; z-index: 80; background: rgba(20, 28, 40, .45); display: flex; align-items: flex-start; justify-content: center; padding: 12px; overflow-y: auto; }
.cmv-sheet { width: 100%; max-width: 480px; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(20, 28, 40, .22); }
.cmv-bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--line); }
.cmv-bar h2 { flex: 1; min-width: 0; margin: 0; font-size: 18px; text-transform: none; letter-spacing: 0; overflow-wrap: anywhere; outline: none; }
.cmv-x { width: 44px; min-width: 44px; margin: 0; min-height: 44px; border: 0; background: transparent; color: var(--ink); font-size: 20px; }
.cmv-body { padding: 12px 16px; display: grid; gap: 8px; }
.cmv-q { margin: 0; font-size: 15px; overflow-wrap: anywhere; }
.cmv-h { margin: 6px 0 0; font-size: 13px; color: var(--muted); text-transform: none; letter-spacing: 0; }
.cmv-none { margin: 0; font-size: 14px; color: var(--muted); }
.cmv-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.cmv-list li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.cmv-m { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; overflow-wrap: anywhere; }
.cmv-m span { font-size: 13px; color: var(--muted); }
.cmv-l { font-size: 13px; color: var(--muted); }
.cmv-sheet input[type="text"] { margin: 0; font-size: 16px; }
.cmv-btn { width: auto; flex: none; margin: 0; min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); font: inherit; font-size: 14px; font-weight: 600; }
.cmv-go { width: 100%; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); overflow-wrap: anywhere; height: auto; padding: 8px 14px; }
.cmv-btn:disabled { opacity: .6; }
.cmv-every { display: flex; align-items: flex-start; gap: 10px; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; }
.cmv-every input { width: 22px; height: 22px; margin: 1px 0 0; flex: none; }
.cmv-count { display: block; font-size: 13px; color: var(--muted); }
.cmv-err { margin: 0; color: var(--err); font-size: 14px; }
.cmv-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 16px 14px; border-top: 1px solid var(--line); }
.lk-moverow { margin: 6px 0 0; }
.lk-move { width: auto; margin: 0; min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); font: inherit; font-size: 14px; font-weight: 600; }
.tb-ontt { display: block; font-size: 12px; font-weight: 600; color: var(--accent); }

/* sortable column headers (tblsearch): the header text is a button; ▲ / ▼ shows the sorted column */
.tb-sorthead { all: unset; box-sizing: border-box; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; white-space: nowrap; }
.tb-sorthead:hover, .tb-sorthead.tb-sorted { color: var(--text, inherit); }
.tb-sorthead:focus-visible { outline: 2px solid var(--accent, currentColor); outline-offset: 2px; border-radius: 4px; }
.tb-sortmark { display: inline-block; min-width: 1em; font-size: 10px; }
.tb-sortsel { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 14px; }
.tb-sortsel select { flex: 1 1 auto; min-width: 0; padding: 8px 10px; font-size: 16px; }
