/* Treatment plans, inside the staff app (app.html). Layout only: the look is DESIGN.md and its
 * pieces (buttons, fields, panels, tabs, menus, tags) are css/components.css, loaded before this.
 * Don't style a new button, card or field here. No hex colours; sizes from tokens or rem.
 * Text people read is never smaller than 0.875rem (#52). */

.tp .page-head > div { gap: var(--space-1); }
.tp-main { width: 100%; display: grid; gap: var(--space-5); align-content: start; }
.tp-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.tp-head .title { margin-right: auto; }
.tp-tabs { border: 0; }
.sub-tabs { justify-self: start; }
.tp-phone-note { margin: 0; }
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-3); }
.filters .shop.narrow { flex: 1 1 18rem; }
.fu-more { align-self: center; }
.fu-more .menu { right: 0; top: calc(100% + 0.25rem); }
.fu-more .icon-btn { width: 2.5rem; height: 2.5rem; }
.tp select.sm-sel { width: auto; }
#tp-unsent-wrap { display: grid; gap: var(--space-2); }
#tp-unsent-wrap:empty { display: none; }
.unsent-bar .btn { margin-left: auto; flex: none; }
.hist-more { justify-content: center; align-items: center; }
.tp-logo { height: 3.25rem; width: auto; display: block; }

/* ---------- building a plan: one path down the left, the money on the right (Nov 23 2026) ----------
 * Left: patient and office, one search box (its list shows only while she types), then the plan.
 * Right: the money card (their peach), with the print buttons at its foot, staying on screen.
 * Measured on the plans area itself (a container query). Narrower than that (an iPad, either
 * way), it's one column and the total and print buttons become a bar at the bottom. */
.tp-builder { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); align-items: start; }
.tp-left { display: grid; gap: var(--space-4); min-width: 0; }
.tp-side { display: contents; }
@supports (container-type: inline-size) {
  .tp-main { container: tp-main / inline-size; }
  @container tp-main (min-width: 52rem) {
    .tp-builder { grid-template-columns: minmax(0, 1fr) 24.5rem; gap: var(--space-5); }
    .tp-side { display: grid; position: sticky; top: var(--space-4); max-height: calc(100vh - 7rem); max-height: calc(100dvh - 7rem); overflow-y: auto; overscroll-behavior: contain;
      border-radius: var(--radius-lg); background: var(--peach-bg); box-shadow: inset 0 0 0 0.0625rem var(--peach-line); }
    .tp-side .tp-plan.card.warm { box-shadow: none; border-radius: 0; background: transparent; }
    /* beside the plan the bar is the foot of the money card: "Patient pays", then the buttons */
    .tp-side .tp-bar { position: sticky; bottom: 0; display: grid; gap: 0.125rem; padding: var(--space-3) 1.25rem 1.25rem; border-radius: 0; background: var(--peach-bg); box-shadow: inset 0 0.0625rem 0 var(--peach-line); }
    .tp-side .tp-bar .bar-t { display: grid; }
    .tp-side .tp-bar .bar-t b { margin: 0; font-size: 2.125rem; letter-spacing: -0.02em; line-height: 1.15; }
    .tp-side .tp-bar .bar-l { font-size: var(--fs-small); font-weight: 500; }
    .tp-side .tp-bar .bar-p { flex: none; }
    .tp-side .tp-bar .bad { margin-top: var(--space-1); }
    .tp-side .tp-bar .bar-btns { display: grid; gap: var(--space-2); margin: var(--space-3) 0 0; }
    .tp-side .tp-bar .bar-btns .btn { margin: 0; width: 100%; }
    .tp-side .tp-bar .bar-btns .btn:not(.secondary) { min-height: 3rem; font-size: 1rem; }
  }
}

/* patient and office: one white strip */
.tp-who { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); padding: var(--space-2) var(--space-2) var(--space-2) 1.25rem; }
.tp .input.tp-name { flex: 1 1 14rem; min-width: 0; min-height: 3rem; padding: 0; border-color: transparent; background: transparent; font-size: 1.25rem; font-weight: 600; }
.tp .input.tp-name:hover { background: transparent; }
.tp .input.tp-name:focus { padding: 0 var(--space-2); background: var(--surface); }
.tp .input.tp-name::placeholder { font-weight: 400; font-size: 1.0625rem; }
.tp .tp-who .offices { flex: 0 1 auto; }
.tp .tp-who .office { white-space: nowrap; }
.tp-fam-add { flex: none; }
.tp-who-more { flex-basis: 100%; display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: var(--space-2) var(--space-3); padding: var(--space-1) var(--space-3) var(--space-3) 0; }
.tp-who-more .fine { grid-column: 1 / -1; margin: 0; }

/* the one search box; its list drops down only while she types */
.tp-find-row { display: flex; align-items: center; gap: var(--space-3); }
.tp-find-row > .tp-find { flex: 1; min-width: 0; }
.tp .tp-browse { flex: none; min-height: 3.25rem; padding: 0 1.25rem; }
.tp-find { position: relative; }
.tp-find > .ico { position: absolute; left: 1.25rem; top: 1.0625rem; width: 1.125rem; height: 1.125rem; fill: none; stroke: var(--ink-3); stroke-width: 2; pointer-events: none; z-index: 1; }
.tp .tp-find .input.shop-q { width: 100%; height: 3.25rem; padding: 0 7rem 0 3rem; border-radius: var(--radius-pill); background-color: var(--surface); box-shadow: var(--card-shadow); font-size: 1.0625rem; }
.tp .tp-find .input.shop-q:focus { box-shadow: 0 0 0 0.1875rem var(--focus); }
.tp-find-key { position: absolute; right: 1.25rem; top: 1rem; color: var(--ink-3); font-size: var(--fs-fine); pointer-events: none; }
.tp-find .shop-q::-webkit-search-cancel-button { margin-right: 0.25rem; }
.tp-codes { position: absolute; left: 0; right: 0; top: calc(100% + 0.375rem); z-index: 20; max-height: min(30rem, 62vh); overflow-y: auto; overscroll-behavior: contain; border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--sheet-shadow); }
.tp-codes[hidden], .tp-find:not(:focus-within) .tp-codes { display: none; }
.tp-codes-foot { margin: 0; padding: var(--space-2) 1.25rem; border-top: 0.0625rem solid var(--line); }
.code-group { position: sticky; top: 0; z-index: 1; padding: var(--space-2) 1.25rem; background: var(--surface); color: var(--ink-3); font-size: var(--fs-fine); font-weight: 600; box-shadow: 0 0.0625rem 0 var(--line); }
.tp .code-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3) var(--space-2) 1.25rem; border: 0; box-shadow: inset 0 -0.0625rem 0 var(--line); cursor: pointer; }
.tp .code-row:hover { background: var(--fill); }
.tp .code-row.hi { background: var(--sel-bg); }
.tp .code-row .what { display: grid; gap: 0.0625rem; min-width: 0; }
.tp .code-row .nm { color: var(--ink); font-weight: 500; }
.tp .code-row .fine { font-size: var(--fs-fine); }
.tp .code-row .price { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.code-row .price.soft { color: var(--ink-3); font-size: var(--fs-fine); font-weight: 400; }
.code-row .star { width: 1.75rem; height: 1.75rem; display: grid; place-items: center; border-radius: 50%; color: var(--ink-3); opacity: 0.35; }
.tp .code-row.more { grid-template-columns: minmax(0, 1fr); text-align: center; }
.tp .code-row.more .nm { color: var(--forest-text); font-weight: 600; }
.code-row:hover .star, .code-row.hi .star, .code-row .star.on { opacity: 1; }
.code-row .star:hover { background: var(--fill-hover); }
.code-row .star .ico { width: 1.125rem; height: 1.125rem; fill: none; stroke: currentColor; stroke-width: 1.6; }
.code-row .star.on { color: var(--warn); }
.code-row .star.on .ico { fill: currentColor; }
.code-row.super .nm { display: inline-flex; align-items: center; gap: var(--space-2); }
.code-row.super .fine { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.code-row.super .ico, .tl .grp .ico { width: 1rem; height: 1rem; color: var(--teal-ink); fill: currentColor; stroke: none; }
.code-row .in { color: var(--teal-ink); font-weight: 600; }
.tp-codes .empty { margin: 0; padding: var(--space-4) 1.25rem; }
.key { padding: 0.0625rem 0.4375rem; border-radius: var(--radius-pill); background: var(--teal-bg); color: var(--teal-ink); font-size: var(--fs-fine); font-weight: 600; }
.le { display: inline-block; padding: 0 0.375rem; border-radius: var(--radius-pill); background: var(--fill); color: var(--ink-2); font-size: var(--fs-fine); font-weight: 500; line-height: 1.4; }

/* ---------- the plan: each phase a heading, its lines under it ---------- */
.tp-empty { display: grid; gap: var(--space-1); padding: var(--space-5) 1.25rem var(--space-4); }
.tp-empty p { margin: 0; }
.tp-empty-h { font-weight: 600; }
.phase { display: grid; }
.phase + .phase { border-top: 0.0625rem solid var(--line-strong); }
.phase-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: var(--space-2); padding: var(--space-4) 1.25rem var(--space-1) var(--space-3); }
/* the phase: a teal number, then its name; the one new treatments go into is solid blue (a choice) */
.phase-name { display: inline-flex; align-items: center; gap: var(--space-2); min-height: 2.25rem; padding: 0 0.875rem 0 0.375rem; border: 0; border-radius: var(--radius-pill); background: transparent; color: var(--ink); font-family: inherit; font-size: var(--fs-small); font-weight: 600; white-space: nowrap; cursor: pointer; }
.phase-name::before { content: attr(data-n); width: 1.5rem; height: 1.5rem; display: grid; place-items: center; border-radius: 50%; background: var(--teal); color: var(--on-primary); font-size: 0.8125rem; font-weight: 700; }
.phase-name:hover { background: var(--fill-hover); }
.phase.active .phase-name { background: var(--forest); color: var(--on-primary); }
.phase.active .phase-name::before { background: var(--surface); color: var(--forest-text); }
.phase-note { min-width: 0; min-height: 2.25rem; border: 0.0625rem solid transparent; border-radius: var(--radius-md); background: transparent; padding: 0 var(--space-2); font: inherit; font-size: var(--fs-small); color: var(--ink-2); }
.phase-note::placeholder { color: var(--ink-3); }
.phase-note:hover { background: var(--fill); }
.phase-note:focus { outline: 0; background: var(--surface); border-color: var(--forest); box-shadow: 0 0 0 0.1875rem var(--focus); }
.phase-tot { color: var(--ink-3); font-size: var(--fs-fine); font-variant-numeric: tabular-nums; white-space: nowrap; }
.phase-empty { margin: 0; padding: var(--space-2) 1.25rem var(--space-4) 3.25rem; }
.phase-add { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); padding: var(--space-4) 1.25rem; border-top: 0.0625rem solid var(--line); }

/* a line: the tooth (only on codes that take one), the treatment, its fee, its three actions */
.tl { display: grid; grid-template-columns: 4rem minmax(0, 1fr) 7rem auto; grid-template-areas: "tooth what fee acts" ". sub sub sub"; align-items: center; gap: 0 var(--space-3); padding: var(--space-2) var(--space-3) var(--space-2) 1.25rem; }
.tl + .tl { box-shadow: inset 0 0.0625rem 0 var(--line); }
.tl .tooth, .tl .tooth-none { grid-area: tooth; }
.tp .tl .input.tooth { width: 100%; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; padding: 0.25rem; }
/* a tooth not picked yet: a dashed box that says so */
.tp .tl .input.tooth:placeholder-shown:not(:focus) { border: 0.0625rem dashed var(--line-strong); background: transparent; }
.tp .tl .input.tooth::placeholder { font-weight: 400; font-size: var(--fs-fine); }
.tl .what { grid-area: what; display: grid; gap: 0.0625rem; min-width: 0; }
.tl .nm { font-weight: 500; color: var(--ink); }
.tl-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.125rem var(--space-3); }
.tl .grp { display: inline-flex; align-items: center; gap: 0.25rem; color: var(--teal-ink); }
.tl-warn:empty { display: none; }
.tl .fee { grid-area: fee; text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; }
.tl .fee .input { width: 100%; }
.tl-acts { grid-area: acts; display: flex; align-items: center; }
.tl-acts .menu { right: 0; top: calc(100% + 0.25rem); }
.tl .menu-note { margin: var(--space-1) 0 0; padding: var(--space-2) 0.75rem var(--space-1); max-width: 22rem; border-top: 0.0625rem solid var(--line); color: var(--ink-3); font-size: var(--fs-fine); white-space: normal; }
.tl .menu-note .lbl { display: block; }
.tl-sub { grid-area: sub; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); padding: var(--space-2) 0 var(--space-1); }
.tl-sub[hidden], .tl-own[hidden] { display: none; }
.tl-own { display: contents; }
.le-f { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--fs-fine); color: var(--ink-2); }
.le-f .input { width: 6.5rem; }
.disc-tick input { width: 1.125rem; height: 1.125rem; margin: 0; }
.tl-tot { margin-left: auto; font-variant-numeric: tabular-nums; }

/* ---------- the money card: discount, insurance, payments, then the receipt ---------- */
.tp-plan { display: grid; padding: 0; }
.tp-sec { padding: var(--space-3) 1.25rem var(--space-4); }
.tp-sec + .tp-sec { border-top: 0.0625rem solid var(--peach-line); }
.tp-plan > .note-box { margin: var(--space-4) 1.25rem 0; }
.tp .adjs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.tp .adjs-3 { grid-template-columns: minmax(0, 0.9fr) minmax(0, 0.9fr) minmax(0, 1.45fr); }
.tp .adj { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; gap: 0.375rem; min-width: 0; padding: 0; box-shadow: none; }
.tp .adj .input { width: 100%; }
.tp .adj-why .input, .tp .adj select.input { text-align: left; }
.tp .adj-why[hidden] { display: none; }
.tp .adj-note { margin: var(--space-2) 0 0; }
.tp .adj-note:empty { display: none; }
.tp .ins-details { margin-top: var(--space-2); }
.tp .ins-details > .adjs { padding-top: var(--space-2); }
.fin-phases { border: 0; padding: 0; margin: var(--space-3) 0 0; display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.fin-phases legend { float: left; padding: 0 var(--space-1) 0 0; }
.fin-phases p { flex-basis: 100%; margin: 0; }
#fin-phases:empty { display: none; }

/* the receipt: each number once, then one "Patient pays" */
.tp #plan-sums { display: grid; gap: var(--space-2); }
.tp-sums-empty { margin: 0; }
.tp .sums .sum { display: flex; justify-content: space-between; gap: var(--space-3); padding: 0.1875rem 0; color: var(--ink-2); }
.tp .sums .sum .num { color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tp p.fine { margin: 0; }
.tp .schedule { display: grid; margin-top: var(--space-2); }
.tp .schedule div { display: flex; justify-content: space-between; padding: var(--space-1) 0; border-bottom: 0.0625rem solid var(--peach-line); font-variant-numeric: tabular-nums; }
.tp .schedule div:last-child { border-bottom: 0; }

/* one column (an iPad): the total and the print buttons are a bar that stays at the bottom (#27).
 * Its height goes in --bottom-ui (set by tp.js) so toasts sit above it. */
html:has(#tp-bar) { scroll-padding-bottom: calc(var(--bottom-ui, 4.5rem) + var(--tabbar-h, 0px) + env(safe-area-inset-bottom, 0px) + 1rem); }
.tp-bar { grid-column: 1 / -1; position: sticky; bottom: calc(var(--tabbar-h, 0px) + env(safe-area-inset-bottom, 0px) + var(--space-3)); z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); padding: var(--space-2) var(--space-2) var(--space-2) var(--space-5); border-radius: var(--radius-pill); background: var(--peach-bg); box-shadow: inset 0 0 0 0.0625rem var(--peach-line), var(--sheet-shadow); font-variant-numeric: tabular-nums; }
.tp-bar .bar-l { color: var(--ink-2); font-size: var(--fs-fine); }
.tp-bar .bar-t b { font-size: 1.375rem; font-weight: 700; margin-left: var(--space-1); }
.tp-bar .bar-p { color: var(--ink-2); flex: 1; }
.tp-bar .bar-btns { display: flex; gap: var(--space-2); margin-left: auto; }
.tp .tp-bar .btn { white-space: nowrap; }

/* a narrow plan (an iPad in portrait with the sidebar): the fee and actions share a second row */
@container tp-main (max-width: 40rem) {
  .tl { grid-template-columns: 3.75rem minmax(0, 1fr) auto; grid-template-areas: "tooth what what" ". fee acts" ". sub sub"; gap: var(--space-1) var(--space-2); }
  .tl .fee { justify-self: start; }
  .tl .fee .input { width: 8rem; }
  .tp .tp-who .offices { flex-basis: 100%; }
}

/* the smaller search boxes on the Saved plans pages */
.tp .shop .ico { left: 0.875rem; width: 1.125rem; height: 1.125rem; }
.tp .shop .input.shop-q { height: 2.75rem; padding-left: 2.5rem; border-radius: var(--radius-pill); background-color: var(--surface); box-shadow: var(--card-shadow); }

/* ---------- Saved plans: unfinished, history, follow-ups, numbers, settings ---------- */
.shop.narrow { max-width: 30rem; }
.tp .table-wrap { position: relative; }   /* screen-reader-only labels inside stay inside the scrolling box */
.tp td .fine, .tp td .strong { display: block; }
/* Follow-ups: a call list (Nov 23 2026). Beside the list on a computer, or under the row she
 * tapped on an iPad, the call panel (a peach .card.warm). Rows are .row-btn (components.css). */
.tp .fu-filters { align-items: center; }
.tp .fu-filters .shop.narrow { flex: 1 1 14rem; max-width: 24rem; }
.fu-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(22rem, 27rem); gap: var(--space-5); align-items: start; }
.fu-list { display: grid; padding: var(--space-2) 0; }
.fu-group { margin: 0; padding: var(--space-3) 1.25rem var(--space-1); font-size: var(--fs-small); font-weight: 600; color: var(--ink-2); }
.fu-group span { font-weight: 400; font-size: var(--fs-fine); color: var(--ink-3); }
.fu-empty { margin: 0; padding: var(--space-5) 1.25rem; }
.fu { grid-template-columns: minmax(0, 1fr) auto; min-height: 3.5rem; }
.fu .what { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--space-2); min-width: 0; }
.fu .what .strong { font-weight: 600; }
.fu .what .fine { flex-basis: 100%; }
.fu.done .what .strong { color: var(--ink-2); }
.fu-right { display: grid; justify-items: end; gap: 0.125rem; }
.fu-right b { font-weight: 600; }
.fu-when { color: var(--ink-2); font-size: var(--fs-fine); font-variant-numeric: tabular-nums; white-space: nowrap; }
/* the call panel */
.fu-panel { display: grid; }
.fu-cols > .fu-panel { position: sticky; top: var(--space-4); max-height: calc(100vh - 2rem); max-height: calc(100dvh - 2rem); overflow-y: auto; overscroll-behavior: contain; }
.fu-list > .fu-panel { margin: var(--space-1) var(--space-3) var(--space-3); }
/* under its row, the panel doesn't repeat the name and the badge the row already shows */
.fu-list > .fu-panel .fu-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.fu-list > .fu-panel .fu-p-top > .tag { display: none; }
.fu-p-top { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); padding: 1.25rem 1.25rem 0; }
.fu-p-who { display: grid; gap: 0.125rem; min-width: 0; }
.fu-p-who .fam { justify-self: start; margin: 0.125rem 0 0.25rem; }
.fu-name { margin: 0; font-size: 1.375rem; font-weight: 700; line-height: 1.2; }
.fu-portion { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); margin: var(--space-3) 1.25rem 0; }
.fu-portion span { color: var(--ink-2); }
.fu-portion b { font-size: 1.5rem; font-weight: 700; }
.tp p.fu-last { margin: var(--space-1) 1.25rem 0; }
.fu-sec { display: grid; gap: var(--space-3); padding: var(--space-4) 1.25rem; border-top: 0.0625rem solid var(--peach-line); }
.fu-p-top + .fu-portion + .fu-sec, .fu-last + .fu-sec { margin-top: var(--space-4); }
.fu-panel .panel-h { margin: 0; }
.fu-outs { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.tp .fu-panel .choice { background: var(--surface); }
.tp .fu-panel .choice:has(input:checked) { background: var(--sel-bg); }
.fu-save { width: 100%; min-height: 2.75rem; }
.fu-p-who .fu-status { justify-self: start; margin: 0.25rem 0; background: var(--sel-bg); color: var(--sel-ink); }
.fu-p-who .fu-status.closed { background: var(--fill); color: var(--ink-2); }
.fu-result { display: grid; gap: 0.125rem; }
.fu-result p { margin: 0; }
.fu-next b { font-weight: 600; }
.fu-next { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); }
/* "Change": a small secondary button that opens the date picker (the real date box sits invisibly over it) */
.tp .fu-change { position: relative; }
.tp .fu-change:focus-within { outline: 0.1875rem solid var(--focus); outline-offset: 0.0625rem; }
.fu-change input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; opacity: 0; cursor: pointer; font-size: 1rem; }
.fu-change input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; cursor: pointer; }
.fu-more { justify-items: start; }
.note-log { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-1); }
.note-log li { padding: var(--space-1) var(--space-3); border-left: 0.1875rem solid var(--teal); }
.note-log li .fine { display: block; }
.note-add { display: flex; gap: var(--space-2); }
.note-add .input { flex: 1; }
.sc { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: var(--space-4); padding: var(--space-3) 1.25rem; box-shadow: inset 0 -0.0625rem 0 var(--line); }
.sc:last-child { box-shadow: none; }
.sc .what { display: grid; gap: 0.125rem; min-width: 0; }
.tp .stack > section > .h3 .fine { margin-left: var(--space-1); font-weight: 400; }
.oda-cell { max-width: 36rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: var(--space-3); }
.tp .num-table th.row-h { font-size: var(--fs-small); font-weight: 500; color: var(--ink); padding: var(--space-3) var(--space-4); }
.tp .num-table tr:last-child th.row-h { border-bottom: 0; }
.tile { display: grid; gap: 0.125rem; padding: var(--space-4) 1.25rem; }
.tile-n { font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.fees-missing { max-width: 40rem; }
.imp-table { max-height: 22rem; overflow: auto; border-radius: var(--radius-md); background: var(--fill); }
.warn-list { margin: 0; padding-left: 1.25rem; display: grid; gap: var(--space-2); }

/* Saved plans is the quiet side: the sub-tab already names the page, so its heading is smaller (Nov 23 2026) */
.tp-main:not([data-tab="build"]) > .page-head .title { font-size: 1.375rem; }
.tp-main:not([data-tab="build"]) > .page-head .sub { font-size: var(--fs-fine); }

/* ---------- Browse all codes: a tall sheet, its own search, every code by kind of treatment ---------- */
#dialog.browse-dlg { width: min(58rem, calc(100vw - 2rem)); max-width: none; height: min(56rem, calc(100vh - 2rem)); height: min(56rem, calc(100dvh - 2rem)); }
#dialog.browse-dlg[open] { display: flex; flex-direction: column; }
.browse-top { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-5); border-bottom: 0.0625rem solid var(--line); }
.browse-top .shop { flex: 1 1 18rem; position: relative; }
.browse-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; position: relative; }
.br-sec { display: grid; }
.br-h { position: sticky; top: 0; z-index: 1; margin: 0; padding: var(--space-2) var(--space-5); background: var(--surface); box-shadow: 0 0.0625rem 0 var(--line); font-size: var(--fs-small); font-weight: 600; color: var(--ink-2); }
.br-h span { font-weight: 400; font-size: var(--fs-fine); color: var(--ink-3); }
.br-note { margin: 0; padding: var(--space-3) var(--space-5); }
.br-row { display: grid; grid-template-columns: 4rem minmax(0, 1fr) auto 6.5rem auto; align-items: center; gap: var(--space-3); min-height: 3rem; padding: var(--space-1) var(--space-5); box-shadow: inset 0 -0.0625rem 0 var(--line); }
.br-row:hover { background: var(--fill); }
.br-nm { display: block; min-width: 0; }
.br-nm .le { margin-left: var(--space-1); vertical-align: 0.0625rem; }
.br-nm .fine { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.br-super .key { justify-self: start; }
.br-in { color: var(--teal-ink); white-space: nowrap; }
.br-fee { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.br-fee.soft { color: var(--ink-3); font-weight: 400; font-size: var(--fs-fine); }
.browse-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.browse-foot .fine { margin: 0; }

/* ---------- sheets (dialogs): the layout inside them ---------- */
#dialog.print-dlg { width: min(60rem, calc(100vw - 2rem)); max-width: none; }
#dialog.small-dlg { width: min(36rem, calc(100vw - 2rem)); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-3) var(--space-5); position: sticky; top: 0; z-index: 2; background: var(--surface); box-shadow: 0 0.0625rem 0 var(--line); }
.dlg-body { padding: var(--space-4) var(--space-5); }
.dlg-note { margin: var(--space-3) var(--space-5) 0; }
#dialog .form { padding: var(--space-5); }
.print-opts { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: end; padding: var(--space-4) var(--space-5); }
.fu-pick { margin-left: auto; min-width: 15rem; }
.preview { display: grid; justify-content: safe center; gap: var(--space-5); padding: var(--space-5); background: var(--page-bg); overflow-x: auto; }
#preview .tp-sheet { zoom: var(--pv, 1); }
.dlg-foot { position: sticky; bottom: 0; padding: var(--space-3) var(--space-5); background: var(--surface); box-shadow: 0 -0.0625rem 0 var(--line); }

/* ---------- printed documents: letter paper, always white ---------- */
.tp-sheet { position: relative; box-sizing: border-box; width: 8.5in; height: 11in; padding: 0.5in; overflow: hidden; background: var(--paper-sheet); color-scheme: light; box-shadow: var(--card-shadow), 0 0 0 var(--border-w) var(--line); }
.tp-sheet-in { transform-origin: top left; }
.tp-sheet-foot { position: absolute; left: 0.5in; right: 0.5in; bottom: 0.35in; display: flex; justify-content: space-between; color: var(--ink-3); font-size: 0.75rem; }
#tp-measure { position: absolute; left: -10000px; top: 0; visibility: hidden; pointer-events: none; }
.doc { color: var(--ink); font-size: 0.875rem; line-height: 1.4; display: grid; gap: 0.85rem; align-content: start; }
.doc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1.5rem; padding-bottom: 0.75rem; border-bottom: 0.0625rem solid var(--line-strong); }
.doc-head img { height: 3.4rem; width: auto; }
.doc-head .right { text-align: right; }
.doc-head .right p { margin: 0; color: var(--ink-2); }
.doc-office { font-weight: 600; color: var(--ink) !important; font-size: 1rem; }
.doc-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 1.5rem; }
.doc-title h1 { font-family: inherit; font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; margin: 0; }
.doc-meta { text-align: right; color: var(--ink-2); }
.doc-meta p { margin: 0; }
.doc-meta b { color: var(--ink); font-weight: 600; }
.doc-soft { color: var(--ink-3); font-style: italic; }
.doc-rev { font-weight: 600; color: var(--ink) !important; }
.doc-lead { margin: 0; }
.doc-phase { font-size: 1rem; font-weight: 600; margin: 0.4rem 0 0.35rem; color: var(--ink); }
.doc .blk > .doc-phase { margin-top: 0.4rem; }
.doc table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.doc th { padding: 0.35rem 0.5rem; border-bottom: 0.0625rem solid var(--line-strong); color: var(--ink-2); font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; background: none; text-align: left; }
.doc th.right, .doc td.right { text-align: right; }
.doc td.num, .doc td.right { white-space: nowrap; }
.doc td { padding: 0.32rem 0.5rem; border-bottom: 0.0625rem solid var(--line); vertical-align: top; }
.doc tbody tr:hover td { background: none; }
.doc th.t { width: 3.25rem; }
.doc .code { color: var(--ink-3); font-size: 0.75rem; white-space: nowrap; }
.doc tr.psub td { border-bottom: 0; color: var(--ink-2); }
.doc tr.pdisc td { border-bottom: 0; color: var(--ink-2); }
.doc tr.ptot td { font-weight: 600; border-bottom: 0; border-top: 0.0625rem solid var(--line-strong); }
.doc-totals { display: grid; justify-self: end; min-width: 24rem; }
.dsum { display: flex; justify-content: space-between; gap: 2rem; padding: 0.2rem 0.5rem; color: var(--ink-2); }
.dsum .num { color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.dsum.strong { font-weight: 600; color: var(--ink); border-top: 0.0625rem solid var(--line-strong); padding-top: 0.35rem; }
.dsum.big { font-size: 1rem; }
.doc-note { margin: 0; padding: 0 0.5rem 0.2rem; color: var(--ink-3); font-size: 0.75rem; }
.doc-fine { font-size: 0.78rem; color: var(--ink-2); }
.doc-fine p { margin: 0 0 0.3rem; }
.doc sup { font-size: 0.65em; }
.doc-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; align-items: start; }
.doc-cols .doc-totals { justify-self: stretch; min-width: 0; }
.doc .pays td, .doc .pays th { padding: 0.12rem 0.5rem; }
.doc-terms { font-size: 0.8rem; color: var(--ink-2); }
.doc-terms b { color: var(--ink); }
.doc-terms p { margin: 0; }
.doc-terms ul { margin: 0.3rem 0 0; padding-left: 1.1rem; display: grid; gap: 0.15rem; }
.doc-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 2.5rem; margin-top: 0.75rem; }
.sign-col { display: grid; gap: 2.4rem; }
.sign-h { margin: 0 0 -1.4rem; font-weight: 600; color: var(--ink); }
.sign-col span { padding-top: 0.3rem; border-top: 0.0625rem solid var(--ink-2); font-size: 0.75rem; color: var(--ink-2); }

/* Printing: letter, no page margin (so the browser can't add its own header and footer; the
 * margin is inside each sheet), one sheet per page. A sheet is as tall as what's on it (at most
 * 9.2 in of content, see tp.js), so a printer, iPad or A4 page that adds its own margins still
 * prints one sheet per page, never a blank extra one (#33). The scale goes through zoom here
 * (it changes the layout size, so the sheet's height is the real one), and the content takes
 * the width the paper gives it. */
@media print {
  @page { size: letter portrait; margin: 0; }
  body.printing { background: var(--paper-sheet); display: block; min-height: 0; }
  body.printing #app, body.printing dialog, body.printing .toast, body.printing #tp-measure { display: none !important; }
  body.printing #print-root { display: block; }
  body.printing .tp-sheet { box-shadow: none; width: auto; height: auto; padding: 0.5in 0.5in 0; overflow: visible; zoom: 1; break-after: page; page-break-after: always; break-inside: avoid; }
  body.printing .tp-sheet:last-child { break-after: auto; page-break-after: auto; }
  body.printing .tp-sheet-in { width: auto !important; transform: none !important; zoom: var(--s, 1); }
  body.printing .tp-sheet-foot { position: static; margin-top: 0.2in; }
}

/* ---------- narrower screens ---------- */
@media (max-width: 60em) {
}

/* ---------- touch screens: the code list's star is a real target ---------- */
@media (pointer: coarse) {
  .tp .input.shop-q, .tp select.sm-sel { min-height: 2.75rem; font-size: 1rem; }
  .phase-name, .phase-note { min-height: 2.75rem; }
  .code-row .star { width: 2.75rem; height: 2.75rem; margin: -0.5rem -0.25rem -0.5rem 0; opacity: 0.6; }
  .code-row .star.on { opacity: 1; }
  .disc-tick input { width: 1.375rem; height: 1.375rem; }
}

/* ---------- phones (up to 640px) ---------- */
@media (max-width: 40em) {
  /* tables that became lists keep their labels (#31) */
  .tp .card td[data-label]::before { content: attr(data-label); display: block; color: var(--ink-3); font-size: var(--fs-fine); font-weight: 400; text-align: left; }
  .tp .card .num-table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2) var(--space-4); }
  .tp .card .num-table th.row-h { grid-column: 1 / -1; padding: 0; border: 0; font-weight: 600; }
  .tp .card .num-table td { text-align: left; }

  /* the print sheet slides up from the bottom, and its pages fit the width (#30) */
  #dialog.print-dlg, #dialog.small-dlg { width: 100%; max-width: 100%; margin: auto 0 0; max-height: 92vh; max-height: 92dvh; border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
  .print-opts { padding: var(--space-3) var(--space-4); }
  .fu-pick { margin-left: 0; flex: 1 1 100%; }
  .preview { padding: var(--space-3); gap: var(--space-3); }
  .dlg-head { padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4); }
  .dlg-foot { padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom, 0px)); }
  .dlg-foot .btn { flex: 1 1 auto; }
  .br-row { grid-template-columns: 3.5rem minmax(0, 1fr) auto; grid-template-areas: "cd nm add" ". fee in"; }
  .br-row .cd { grid-area: cd; } .br-row .br-nm { grid-area: nm; } .br-row .btn { grid-area: add; } .br-row .br-fee { grid-area: fee; text-align: left; } .br-row .br-in { grid-area: in; }
  .tp-find-row { flex-wrap: wrap; } .tp .tp-browse { width: 100%; }
  .unsent-bar, .offline-bar { flex-wrap: wrap; }
  .fu-list > .fu-panel { margin: var(--space-1) 0 var(--space-3); border-radius: 0; }
}
