/* ==========================================================================
   HuntsUnited — portals (hunter, guide, business, admin)
   Built on the site tokens in styles.css. Light working surface, dark rail.
   ========================================================================== */
/* Portal tokens (--pt-*, chart palette, status colors) live in styles.css :root */
body.portal { background: var(--pt-bg); min-height: 100vh; }
.pt { display: grid; grid-template-columns: var(--pt-side-w) minmax(0, 1fr); min-height: 100vh; min-height: 100svh; }

/* Sidebar */
.pt-side { background: var(--pt-side); color: #d9d6cc; position: sticky; top: 0; height: 100vh; height: 100svh; display: flex; flex-direction: column; padding: 18px 14px; overflow-y: auto; z-index: 40; }
.pt-side .logo { padding: 4px 8px 6px; }
.pt-side .logo-word { font-size: 1.3rem; }
.pt-role { margin: 6px 8px 18px; font-size: var(--label-fs); font-weight: var(--label-fw); letter-spacing: var(--label-ls); text-transform: uppercase; color: var(--blaze); }
.pt-nav { display: grid; gap: 2px; }
.pt-nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-sm); font-size: var(--fs-base); line-height: 1.55; font-weight: 500; color: #c9c6bb; transition: background .15s, color .15s; }
.pt-nav a .icon { width: 18px; height: 18px; opacity: .8; }
.pt-nav a:hover { background: var(--pt-side-2); color: #fff; }
.pt-nav a.active { background: var(--pt-side-2); color: #fff; box-shadow: inset 3px 0 0 var(--blaze); }
.pt-nav a.active .icon { color: var(--blaze); opacity: 1; }
.pt-nav .nb { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill); background: var(--blaze); color: #fff; font-size: var(--fs-2xs); font-weight: 700; display: grid; place-items: center; }
.pt-nav .sep { height: 1px; background: rgba(255,255,255,.08); margin: 10px 8px; }
.pt-side-foot { margin-top: auto; padding-top: 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.pt-map { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 12px; border-radius: var(--r-sm); background: var(--blaze); color: #fff; font-weight: 600; font-size: .84rem; transition: background .15s; }
.pt-map:hover { background: var(--blaze-dark); }
.pt-map .icon { width: 16px; height: 16px; }
.pt-fb { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin-bottom: 8px; padding: 8px 12px; border-radius: var(--r-sm); border: 1px solid rgba(255,255,255,.18); background: transparent; color: rgba(255,255,255,.85); font: 600 .84rem var(--font-body); cursor: pointer; transition: background .15s, border-color .15s; }
.pt-fb:hover { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.32); color: #fff; }
.pt-fb .icon { width: 16px; height: 16px; color: var(--blaze); }
.pt-me { display: flex; align-items: center; gap: 8px; padding: 6px 4px 6px 6px; border-radius: var(--r-sm); background: var(--pt-side-2); }
.pt-me .avatar { width: var(--av-sm); height: var(--av-sm); font-size: .68rem; box-shadow: none; }
.pt-me-txt { flex: 1; min-width: 0; line-height: 1.25; }
.pt-me-txt b { display: block; color: #fff; font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pt-me-txt small { display: block; font-size: var(--fs-2xs); font-weight: 600; }
.pt-ic { flex: none; width: 30px; height: 30px; display: grid; place-items: center; border-radius: var(--r-sm); border: 0; background: none; color: #9b998f; transition: background .15s, color .15s; }
.pt-ic:hover { background: rgba(255,255,255,.08); color: #fff; }
.pt-ic .icon { width: 16px; height: 16px; }

/* Main */
.pt-main { min-width: 0; display: flex; flex-direction: column; }
.pt-top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; padding: 14px 28px; background: rgba(243,239,230,.92); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.pt-top h1 { font-size: 1.7rem; margin: 0; }
.pt-top .sub { color: var(--muted); font-size: var(--fs-sm); }
.pt-top .grow { flex: 1; }
.pt-burger { display: none; background: none; border: 0; padding: 6px; margin-left: -6px; }
.pt-burger .icon { width: 24px; height: 24px; }
.pt-view { padding: 24px 28px 64px; display: grid; gap: 20px; align-content: start; }
.pt-verify { display: flex; align-items: center; gap: 12px; margin: 16px 28px 0; padding: 10px 12px 10px 16px; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--blaze-tint); color: var(--ink); font-size: var(--fs-sm); line-height: 1.4; }
.pt-verify > .icon { flex: none; width: 18px; height: 18px; color: var(--blaze-ink); }
.pt-verify { flex-wrap: wrap; }
.pt-verify > span { flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; }
.pt-verify .pt-ic { color: var(--muted); }

/* Cards & grids */
.p-card { background: var(--card-bg); border: var(--card-border); border-radius: var(--card-r); padding: var(--card-pad); min-width: 0; }
.p-card > h3, .p-card-head h3 { font-size: 1.25rem; margin: 0; }
.p-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.p-card-head .muted { color: var(--muted); font-size: var(--fs-sm); }
.p-grid { display: grid; gap: 20px; }
.p-grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.p-grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.p-grid.c21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.p-grid.c12 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.kpi { background: var(--card-bg); border: var(--card-border); border-radius: var(--card-r-sm); padding: var(--card-pad-sm); min-width: 0; }
.kpi small { display: block; font-size: var(--label-fs); font-weight: var(--label-fw); letter-spacing: var(--label-ls); text-transform: uppercase; color: var(--muted); }
.kpi b { display: block; font-family: var(--font-display); font-size: 2.1rem; line-height: 1.05; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .delta { font-size: var(--fs-xs); font-weight: 600; }
.kpi .delta.up { color: var(--good); } .kpi .delta.down { color: var(--bad); }
.kpi .spark { height: 30px; margin-top: 8px; }
.p-note { font-size: .84rem; color: var(--muted); margin: 0; }

/* Status pills (always icon/label, never color alone) */

/* Person chip from Portal.who(): avatar, then name over a small subtitle (cards, lists, tables) */
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who .avatar { width: var(--av-sm); height: var(--av-sm); font-size: .75rem; flex: none; }
.who > div { min-width: 0; }
.who b { display: block; font-size: var(--fs-sm); overflow-wrap: anywhere; }
.who small { display: block; color: var(--muted); font-size: var(--fs-xs); overflow-wrap: anywhere; }
/* Inside wide tables the row scrolls sideways, so emails stay on one line instead of breaking mid-word */
.p-table .who small { overflow-wrap: normal; white-space: nowrap; }
/* Empty-table message stays in view when the table is wider than the phone */
.p-tablewrap td[colspan] > .empty { position: sticky; left: 0; max-width: min(100%, calc(100vw - 96px)); }
/* "Scroll sideways" hint under tables that overflow (added by portal.js scrollHints) */
.sc-hint { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin-top: 8px; font-size: var(--fs-xs); font-weight: 600; color: var(--muted); }
.sc-hint .icon { width: 14px; height: 14px; }
@media (min-width: 961px) { .sc-hint { display: none; } }

/* Tables */
.p-tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: #fff; }
.p-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.p-table th { text-align: left; font-size: var(--label-fs); letter-spacing: var(--label-ls); text-transform: uppercase; color: var(--muted); font-weight: var(--label-fw); padding: 11px 14px; background: var(--paper-2); border-bottom: 1px solid var(--line); white-space: nowrap; cursor: default; user-select: none; }
.p-table th[data-sort] { cursor: pointer; }
.p-table th[data-sort]:hover { color: var(--ink); }
.p-table td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.p-table tr:last-child td { border-bottom: 0; }
@media (hover: hover) { .p-table tbody tr:hover td { background: var(--paper-2); } }
.p-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.p-table .who { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.p-table .who .avatar { width: var(--av-sm); height: var(--av-sm); font-size: .75rem; }
.p-table .who b { display: block; font-size: var(--fs-sm); }
.p-table .who small { color: var(--muted); font-size: var(--fs-xs); }
.p-table .acts { display: flex; gap: 6px; justify-content: flex-end; white-space: nowrap; }
.p-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.p-tools .eb-search { height: 40px; max-width: 320px; }
.p-tools .eb-select { height: 40px; }
.p-tools .count { margin-left: auto; color: var(--muted); font-size: var(--fs-sm); }

/* Lists */
.p-list { display: grid; }
.p-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); min-width: 0; }
.p-item:last-child { border-bottom: 0; }
.p-item .avatar { width: var(--av-md); height: var(--av-md); font-size: var(--fs-xs); }
.p-item .grow { flex: 1; min-width: 0; }
.p-item .grow b { display: block; font-size: var(--fs-base); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-item .grow small { color: var(--muted); font-size: var(--fs-xs); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-item .ico { width: 36px; height: 36px; border-radius: var(--r-sm); display: grid; place-items: center; background: #f6e3d6; color: var(--blaze); flex: none; }
.p-item .ico .icon { width: 18px; height: 18px; }

/* Tabs inside a page */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 4px; overflow-x: auto; scrollbar-width: none; }
/* Underline tabs: one component (UI audit 3.6) for portal sections, hunter/finance sub-nav and admin settings */
.tabs > :is(button, a) { display: inline-block; background: none; border: 0; padding: 10px 14px; font-weight: 600; font-size: var(--fs-sm); color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; transition: color .15s, border-color .15s; }
.tabs > :is(button, a):hover { color: var(--ink); }
.tabs > .on { color: var(--ink); border-color: var(--blaze); }
.tabs .cnt { color: var(--muted); font-weight: 500; margin-left: 4px; }

/* Kanban (guide pipeline) */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 6px; }
.kcol { background: #ebe5d8; border-radius: var(--r-md); padding: 12px; min-width: 220px; }
.kcol h4 { display: flex; justify-content: space-between; align-items: center; font-size: 1rem; margin: 2px 4px 10px; }
.kcol h4 span { font-family: var(--font-body); font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.kcard { background: #fff; border: var(--card-border); border-radius: var(--card-r-sm); padding: 12px; margin-bottom: 10px; display: grid; gap: 6px; font-size: var(--fs-sm); cursor: pointer; transition: box-shadow .15s; }
.kcard:hover { box-shadow: var(--shadow-sm); }
.kcard b { font-size: var(--fs-base); }
.kcard .row { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); }

/* Messages */
.msg-shell { display: grid; grid-template-columns: 320px minmax(0, 1fr); height: calc(100vh - 150px); min-height: 480px; background: var(--pt-card); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.msg-list { border-right: 1px solid var(--line); overflow-y: auto; }
.msg-list button { width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line-soft); padding: 14px 16px; display: flex; gap: 12px; align-items: flex-start; }
.msg-list button.on { background: #f6efe2; box-shadow: inset 3px 0 0 var(--blaze); }
.msg-list .avatar { width: var(--av-md); height: var(--av-md); font-size: var(--fs-xs); }
.msg-list .grow { flex: 1; min-width: 0; }
.msg-list b { display: flex; justify-content: space-between; gap: 8px; font-size: var(--fs-sm); }
.msg-list b time { font-weight: 500; font-size: var(--fs-2xs); color: var(--muted); white-space: nowrap; }
.msg-list small { display: block; color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-list .about { color: var(--blaze); font-weight: 600; font-size: var(--fs-2xs); }
.msg-list .dot { width: 9px; height: 9px; border-radius: var(--r-round); background: var(--blaze); flex: none; margin-top: 6px; }
.msg-thread { display: flex; flex-direction: column; min-width: 0; }
.msg-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.msg-head .avatar { width: var(--av-md); height: var(--av-md); font-size: var(--fs-xs); }
.msg-head b { display: block; } .msg-head small { color: var(--muted); font-size: var(--fs-xs); }
.msg-body { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; background: var(--paper-2); }
.bubble { max-width: 72%; padding: 10px 14px; border-radius: 16px 16px 16px 4px; background: #fff; border: 1px solid var(--line); font-size: var(--fs-sm); }
.bubble.me { align-self: flex-end; background: var(--ink); color: #fff; border-color: var(--ink); border-radius: 16px 16px 4px 16px; }
.bubble time { display: block; font-size: var(--fs-2xs); opacity: .6; margin-top: 4px; }
.msg-form { display: flex; gap: 10px; padding: 12px; border-top: 1px solid var(--line); }
.msg-form input { flex: 1; min-width: 0; border: 1.5px solid var(--line); border-radius: var(--r-pill); padding: 11px 16px; outline: 0; font-size: 16px; }
.msg-form input:focus { border-color: var(--blaze); }
.msg-back { display: none; }

/* Charts */
.chart { width: 100%; }
.chart svg { width: 100%; height: auto; overflow: visible; display: block; }
.chart .grid line { stroke: #e7e1d3; stroke-width: 1; }
.chart .axis text, .chart .lbl { fill: #77756b; font-size: 11px; font-family: var(--font-body); }
.chart .val { fill: var(--ink-2); font-size: 11px; font-weight: 600; font-family: var(--font-body); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hl { stroke: #b9b2a2; stroke-width: 1; stroke-dasharray: 3 3; }
.chart-tip { position: absolute; pointer-events: none; background: var(--ink); color: #fff; padding: 8px 10px; border-radius: var(--r-sm); font-size: var(--fs-xs); line-height: 1.45; white-space: nowrap; box-shadow: var(--shadow); transform: translate(-50%, calc(-100% - 10px)); opacity: 0; transition: opacity .1s; z-index: 5; }
.chart-tip.on { opacity: 1; }
.chart-tip i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.legend-row { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: var(--fs-xs); color: var(--ink-2); margin-bottom: 8px; }
.legend-row span { display: inline-flex; align-items: center; gap: 6px; }
.legend-row i { width: 10px; height: 10px; border-radius: 3px; }
.dist { display: grid; gap: 10px; }
.dist .r { display: grid; grid-template-columns: 110px minmax(0, 1fr) minmax(54px, auto); gap: 10px; align-items: center; font-size: var(--fs-sm); }
.dist .bar { height: 10px; border-radius: 0 4px 4px 0; background: var(--c1); }
.dist .track { background: var(--line-soft); border-radius: var(--r-xs); overflow: hidden; }
.dist .num { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); font-weight: 600; }

/* Forms in portals */
.p-form { display: grid; gap: 16px; }
.p-form .form-grid { gap: 14px; }
.p-form .actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.switch-row:last-child { border-bottom: 0; }
.switch-row b { display: block; font-size: var(--fs-base); } .switch-row small { color: var(--muted); font-size: var(--fs-xs); }
.tgl { position: relative; width: 44px; height: 26px; flex: none; }
.tgl input { opacity: 0; width: 0; height: 0; position: absolute; }
.tgl span { position: absolute; inset: 0; border-radius: var(--r-pill); background: #d6cfbf; transition: background .2s; cursor: pointer; }
.tgl span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: var(--r-round); background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.tgl input:checked + span { background: var(--blaze); }
.tgl input:checked + span::after { transform: translateX(18px); }
.tgl input:focus-visible + span { box-shadow: var(--ring); }

/* Plan picker (billing pages & signup) */
.plan-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.pp { position: relative; background: #fff; border: 1.5px solid var(--line); border-radius: var(--r-md); padding: 18px; display: flex; flex-direction: column; gap: 8px; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.pp:hover { border-color: var(--line-strong); }
.pp.on { border-color: var(--blaze); box-shadow: var(--ring); }
.pp input { position: absolute; opacity: 0; pointer-events: none; }
.pp .n { font-family: var(--font-display); font-size: 1.4rem; text-transform: uppercase; font-weight: 700; }
.pp .p { font-family: var(--font-display); font-size: 1.9rem; font-weight: 700; line-height: 1; }
.pp .p small { font-family: var(--font-body); font-size: var(--fs-xs); color: var(--muted); font-weight: 500; }
.pp ul { list-style: none; padding: 0; margin: 4px 0 0; display: grid; gap: 6px; font-size: var(--fs-xs); color: var(--ink-2); }
.pp li { display: flex; gap: 6px; } .pp li .icon { width: 14px; height: 14px; color: var(--blaze); margin-top: 3px; }
.pp .tag-pop { position: absolute; top: -10px; right: 14px; }
.pp .cur { position: absolute; top: -10px; left: 14px; }

/* Hunt cards in hunter portal */
.trip { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 0; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: #fff; }
.trip img { width: 100%; height: 100%; object-fit: cover; min-height: 120px; }
.trip .tb { padding: 14px 16px; display: grid; gap: 6px; min-width: 0; }
.trip .tb b { font-size: 1rem; }
.trip .tb .row { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: var(--fs-xs); color: var(--muted); }
.trip .tb .row span { display: inline-flex; gap: 5px; align-items: center; }
.trip .tb .row .icon { width: 14px; height: 14px; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal .dh { font-size: var(--label-fs); text-transform: uppercase; letter-spacing: var(--label-ls); color: var(--muted); text-align: center; padding: 4px 0; font-weight: var(--label-fw); }
.cal button { aspect-ratio: 1; border: 1px solid var(--line-soft); background: #fff; border-radius: var(--r-sm); font-size: var(--fs-xs); font-weight: 600; color: var(--ink-2); display: grid; place-items: center; position: relative; }
.cal button.out { opacity: .35; }
.cal button.today { border-color: var(--ink); }
.cal button.booked { background: var(--blaze); color: #fff; border-color: var(--blaze); }
.cal button.blocked { background: repeating-linear-gradient(135deg, #e9e2d3 0 5px, var(--paper-2) 5px 10px); color: #8b877a; }
.cal button.req::after { content: ""; position: absolute; bottom: 5px; width: 5px; height: 5px; border-radius: var(--r-round); background: var(--c2); }
.cal-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: var(--fs-xs); color: var(--muted); margin-top: 10px; }
.cal-legend span { display: inline-flex; gap: 6px; align-items: center; }
.cal-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

.banner { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-radius: var(--r-md); background: var(--blaze-tint); border: 1px solid #f3cfb7; font-size: var(--fs-sm); }
.banner .icon { width: 20px; height: 20px; color: var(--blaze); flex: none; }
.banner .grow { flex: 1; }
.banner.dark { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ===== Responsive ===== */
@media (max-width: 1100px) {
  .p-grid.c3 { grid-template-columns: 1fr 1fr; }
  .p-grid.c21, .p-grid.c12 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .pt { grid-template-columns: 1fr; }
  .pt-side { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  body.pt-open .pt-side { transform: none; }
  body.pt-open::after { content: ""; position: fixed; inset: 0; background: rgba(14,12,10,.5); z-index: 35; }
  .pt-burger { display: inline-flex; }
  .pt-top { padding: 12px 16px; }
  .pt-top h1 { font-size: 1.4rem; }
  .pt-top .sub { display: none; }
  .pt-view { padding: 16px 16px 56px; gap: 16px; }
  .pt-verify { margin: 12px 16px 0; }
  .p-grid.c2, .p-grid.c3 { grid-template-columns: 1fr; }
  .msg-shell { grid-template-columns: 1fr; height: calc(100svh - 120px); }
  .msg-shell.thread-open .msg-list { display: none; }
  .msg-shell:not(.thread-open) .msg-thread { display: none; }
  .msg-back { display: inline-flex; }
  .bubble { max-width: 86%; }
  .kanban { grid-template-columns: repeat(4, 78vw); scroll-snap-type: x mandatory; }
  .kcol { scroll-snap-align: start; }
}
@media (max-width: 560px) {
  .kpi b { font-size: 1.7rem; }
  .kpi small { letter-spacing: .05em; overflow-wrap: anywhere; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 12px 14px; }
  .p-card { padding: 16px; border-radius: var(--r-md); }
  .trip { grid-template-columns: 90px minmax(0, 1fr); }
  .pt-top .btn span.hide-sm { display: none; }
  .dist .r { grid-template-columns: 96px minmax(0, 1fr) minmax(46px, auto); }
  .dist .r > span:first-child { min-width: 0; overflow-wrap: anywhere; line-height: 1.25; }
}

/* Charts with no data yet, and the "Test" label for pre-launch test accounts */
.chart { position: relative; }
.chart-empty { position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%); background: var(--bone, #f6f1e7); border: 1px solid var(--line, #e2dccf); color: var(--muted, #6b675e); font-size: .84rem; font-weight: 600; padding: 6px 12px; border-radius: var(--r-pill); white-space: normal; overflow-wrap: anywhere; max-width: 90%; text-align: center; pointer-events: none; }
.test-pill { margin-left: 6px; vertical-align: middle; }

/* Feature flags (js/flags.js): a grid with a switched-off column becomes one column */
.p-grid.c2:has(> .hu-off, > .hu-flag-empty), .p-grid.c21:has(> .hu-off, > .hu-flag-empty), .p-grid.c12:has(> .hu-off, > .hu-flag-empty) { grid-template-columns: minmax(0, 1fr); }
.p-grid.c3:has(> .hu-off, > .hu-flag-empty) { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* ===== Phones & touch: safe areas, drawer, tap targets, iOS zoom ===== */
/* Notch / home bar (pages use viewport-fit=cover) */
.pt-side { padding-left: max(14px, env(safe-area-inset-left)); padding-bottom: max(18px, env(safe-area-inset-bottom)); }
.pt-view { padding-right: max(28px, env(safe-area-inset-right)); padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
.pt-top { padding-right: max(28px, env(safe-area-inset-right)); }
/* Wide tables and tab strips fade at the edge that has more to scroll (classes set by portal.js) */
.p-tablewrap, .fn-scroll { overscroll-behavior-x: contain; }
.p-filters { display: contents; }
.sc-r { -webkit-mask-image: linear-gradient(to left, transparent, #000 32px); mask-image: linear-gradient(to left, transparent, #000 32px); }
.sc-l { -webkit-mask-image: linear-gradient(to right, transparent, #000 32px); mask-image: linear-gradient(to right, transparent, #000 32px); }
.sc-l.sc-r { -webkit-mask-image: linear-gradient(to right, transparent, #000 32px, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to right, transparent, #000 32px, #000 calc(100% - 32px), transparent); }
.chart .hit { touch-action: pan-y; -webkit-tap-highlight-color: transparent; }
/* 12px text floor for the shell at every width (tablets show the sidebar too) */
.pt-role, .pt-me-txt small, .pt-me .avatar, .kpi small, .p-table th, .bubble time, .msg-list b time, .msg-list .about, .pt-nav .nb { font-size: .75rem; }
@media (max-width: 900px) {
  .pt-side { height: 100vh; height: 100dvh; padding-top: max(18px, env(safe-area-inset-top)); overscroll-behavior: contain; visibility: hidden; transition: transform .25s ease, visibility 0s .25s; }
  body.pt-open .pt-side { visibility: visible; transition: transform .25s ease; }
  body.pt-open { overflow: hidden; }
  body.pt-open::after { touch-action: none; }
  .pt-burger { flex: none; width: 44px; height: 44px; padding: 0; margin-left: -10px; align-items: center; justify-content: center; border-radius: var(--r-sm); color: inherit; }
  .pt-top { padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left)); gap: 10px; }
  .pt-top > div:nth-child(2) { min-width: 0; }
  .pt-top h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .pt-view { padding: 16px max(16px, env(safe-area-inset-right)) calc(56px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  .pt-nav a { min-height: 44px; }
  .bubble { overflow-wrap: anywhere; }
  .msg-back { min-width: 44px; align-self: center; }
  .pt-map { min-height: 44px; }
  .pt-side .logo { min-height: 44px; display: flex; align-items: center; }
  .pt-ic { width: 40px; height: 40px; }
  .pt-me { padding: 4px 4px 4px 8px; }
  .pt-role, .pt-me-txt small { font-size: .75rem; }
  .kpi small, .p-table th, .bubble time, .msg-list b time, .msg-list .about, .pt-nav .nb { font-size: .75rem; }
  /* Table filters: one swipeable row instead of a stack of full-width selects */
  .p-filters { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; flex: 1 1 100%; min-width: 0; margin: 0 -16px; padding: 2px 16px; overscroll-behavior-x: contain; }
  .p-filters::-webkit-scrollbar { display: none; }
  .p-tools .p-filters .eb-select { flex: none; width: auto; height: 44px; }
  .p-tools .eb-search { flex: 1 1 100%; max-width: none; }
  body.portal .pill { font-size: .75rem; }
  body.portal .field label small { font-size: .75rem; }
  /* iOS zooms the page when a focused field is under 16px */
  body.portal input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]):not([type=button]):not([type=submit]), body.portal select, body.portal textarea { font-size: 16px !important; }
  .p-tools .eb-search, .p-tools .eb-select { height: 44px; }
  .tabs > :is(button, a) { padding-top: 13px; padding-bottom: 13px; }
  body.portal input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]):not([type=button]):not([type=submit]), body.portal select, body.portal textarea { font-size: 16px !important; }
  .msg-shell { height: calc(100dvh - 120px - env(safe-area-inset-bottom)); }
}
@media (pointer: coarse) {
  /* Invisible hit areas: the control keeps its size, the finger target reaches ~44px */
  .seg > button, .tgl, .chip, .ib, .bz-ib, .pt-ic, .hchip, .msg-back { position: relative; }
  /* Pads grow up and down only, so buttons side by side never overlap */
  .seg > button::after, .chip::after, .hchip::after { content: ""; position: absolute; left: 0; right: 0; top: -8px; bottom: -8px; }
  .p-tools .eb-search, .p-tools .eb-select { height: 44px; }
  .tabs > :is(button, a) { padding-top: 13px; padding-bottom: 13px; }
  body.portal input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]):not([type=button]):not([type=submit]), body.portal select, body.portal textarea { font-size: 16px !important; }
  .tgl::after { content: ""; position: absolute; left: -6px; right: -6px; top: -9px; bottom: -9px; }
  .pt .ib, .pt .bz-ib { width: 36px; height: 36px; }
  .ib::after, .bz-ib::after { content: ""; position: absolute; left: -4px; right: -4px; top: -4px; bottom: -4px; }
  .pt-ic { width: 36px; height: 36px; }
  .pt-ic::after { content: ""; position: absolute; left: -4px; right: -4px; top: -4px; bottom: -4px; }
  .pt-map { min-height: 44px; }
}
@media (max-width: 560px) {
  .banner { flex-wrap: wrap; padding: 14px 16px; }
  .banner .grow { flex: 1 1 calc(100% - 40px); min-width: 0; }
  .banner > .btn { flex: 1 1 100%; }
  .p-card-head { gap: 8px 12px; }
}

/* Small buttons keep their compact 40px face in the portals at every width;
   on touch screens an invisible pad gives the 44px finger target. */
body.portal { --btn-h-sm: 40px; }
@media (pointer: coarse) {
  body.portal .btn-sm { position: relative; }
  body.portal .btn-sm::after { content: ""; position: absolute; left: 0; right: 0; top: -4px; bottom: -4px; }
}
