/* Proposals: app specific styles only. Loaded after /shared/ui.css, which covers tokens, header,
   buttons, inputs, list page, badges, dialogs and toast. Never restyle shared components here;
   raise gaps against the standard (claude/web-app-ui-standard.md) instead.
   The list page needs nothing extra. Everything below is the proposal page (/p/, body.pp). */

/* ------------------------------------------------------------------ activity (every page)
   pbar: thin moving bar under the header while any API call runs (added by auth.js).
   ispin: small inline spinner for "Searching…" rows. Candidate for Shared/ui.css. */
.pbar { position: fixed; left: 0; right: 0; top: 52px; height: 3px; z-index: 60; overflow: hidden; background: transparent; pointer-events: none; }
.pbar::before { content: ""; position: absolute; top: 0; bottom: 0; width: 35%; background: var(--accent); border-radius: 3px; animation: pbar 1.1s ease-in-out infinite; }
@keyframes pbar { from { left: -35%; } to { left: 100%; } }
.ispin { display: inline-block; vertical-align: -3px; width: 16px; height: 16px; margin-right: 8px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--brand-2); animation: spin 1s linear infinite; }
/* list page: cards on phones, column table (#tw, ui.css .rt) from 721px */
.lres { margin: 8px var(--gutter) 0; }
#trows.stale { opacity: .45; transition: opacity .15s; }
@media (min-width: 721px) { #rows { display: none; } .lfoot { padding-bottom: 96px; } }
@media (max-width: 720px) { .lres { display: none; } }
.rows.stale { opacity: .45; transition: opacity .15s; }
.loadrow { padding: 24px var(--gutter); color: var(--muted); }
.ph.loading::after { content: ""; position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--brand-2); animation: spin 1s linear infinite; }

/* ------------------------------------------------------------------ top bar */
.pp .bar h1 { font-size: 1.35rem; }
.pp .back { padding: 6px 10px; }
.amt-big { font: 700 1.3rem var(--f-display); }
.pmeta { flex: 1 1 200px; }
.pacts { margin-left: auto; display: flex; gap: 8px; }
.need { flex: none; margin: 0; padding: 8px var(--gutter); background: var(--accent-soft); font-size: .92rem; font-weight: 600; border-bottom: 1px solid var(--line); }
.need.ok { background: var(--ok-soft); color: var(--brand-2); }
.ro { flex: none; margin: 0; padding: 8px var(--gutter); background: var(--surface-2); font-size: .92rem; border-bottom: 1px solid var(--line); }

/* ------------------------------------------------------------------ columns: 3 on desktop (each scrolls), 2 on tablet, 1 on phone */
.pcols { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding: 12px var(--gutter); }
.pcol { display: grid; gap: 12px; align-content: start; min-height: 0; overflow: auto; }
.pcol .card { display: grid; gap: 10px; }
.pcol h2 { display: flex; align-items: center; gap: 8px; }
.ch { display: flex; align-items: center; gap: 8px; }
.ch .btn { margin-left: auto; }
.stepn { display: none; width: 22px; height: 22px; border-radius: 50%; background: var(--brand); color: #fff; font: 700 .8rem/22px var(--f-body); text-align: center; }
.isnew .stepn { display: inline-block; }

/* segmented choice (Bill to, Approval, MyScape) */
.seg { display: flex; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.seg button { flex: 1; min-height: 40px; font-weight: 600; background: var(--surface); color: var(--muted); border: 0; border-right: 1px solid var(--line); padding: 8px 6px; cursor: pointer; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--brand); color: #fff; }
.seg button:disabled { cursor: default; }

/* customer picker */
.pick { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: var(--bg); cursor: pointer; }
.pick b { display: block; font-size: 1.05rem; }
.pick > span:first-child { display: grid; gap: 2px; min-width: 0; }
.pick .go { margin-left: auto; color: var(--brand-2); font-weight: 700; }
.pick:disabled { cursor: default; }
.billbox { display: grid; gap: 10px; }

/* lines */
.lines { list-style: none; margin: 0; padding: 0; }
.line { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 10px 0; cursor: pointer; min-height: 44px; }
.lines li:last-child .line { border-bottom: 0; }
.line:disabled { cursor: default; }
.line b { font-weight: 600; }
.line .lt { font: 700 1.05rem var(--f-display); text-align: right; }
.line .ls { grid-column: 1 / -1; font-size: .85rem; color: var(--muted); }
.sum { display: flex; justify-content: space-between; padding-top: 8px; border-top: 2px solid var(--line); font: 700 1.15rem var(--f-display); }

/* photos */
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.ph { position: relative; aspect-ratio: 1; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface-2); overflow: hidden; padding: 0; cursor: pointer; }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph span { position: absolute; left: 0; right: 0; bottom: 0; padding: 2px 6px; font-size: .72rem; color: #fff; background: rgba(0,0,0,.45); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photo-add { display: flex; align-items: center; justify-content: center; min-height: 44px; border: 2px dashed var(--line); border-radius: 10px; color: var(--muted); font-size: .95rem; cursor: pointer; }

/* ------------------------------------------------------------------ dialogs (bottom sheet on phones) */
.picklist { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.picklist:empty { display: none; }
.picklist li { border-bottom: 1px solid var(--line); }
.picklist li:last-child { border-bottom: 0; }
.picklist li.muted, .picklist li.err { padding: 12px; }
.picklist button { display: grid; gap: 2px; width: 100%; text-align: left; background: none; border: 0; padding: 12px; cursor: pointer; min-height: 44px; }
.picklist button:hover { background: var(--surface-2); }
.picklist span { font-size: .85rem; color: var(--muted); }
.trio { display: grid; grid-template-columns: 1fr 1.2fr 1fr; gap: 8px; }
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: end; }
.duo .toggle { min-height: 36px; }
.calc { display: flex; justify-content: space-between; background: var(--bg); border-radius: 10px; padding: 10px 12px; font: 700 1.15rem var(--f-display); }
.check { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.check li { display: flex; gap: 10px; align-items: center; }
.check li span { font-weight: 700; width: 1em; }
.check .y span { color: var(--brand-2); }
.check .n span, .check em { color: var(--danger); font-style: normal; }
.menu { display: grid; }
.menu button { display: grid; gap: 1px; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 12px 4px; cursor: pointer; min-height: 44px; }
.menu button span { font-size: .85rem; color: var(--muted); }
.menu button.red b { color: var(--danger); }
.menu button:disabled { opacity: .4; cursor: default; }
.prev { max-width: 100%; max-height: 40vh; border-radius: 10px; justify-self: center; }
dialog.viewer { max-width: 960px; background: #000; border-color: #000; }
dialog.viewer img { max-width: 100%; max-height: 75vh; justify-self: center; border-radius: 8px; }
.toast { display: flex; align-items: center; gap: 14px; }
.toast .undo { background: none; border: 0; color: var(--accent); font-weight: 700; cursor: pointer; padding: 4px; }
.toast .tspin { display: none; flex: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255,255,255,.3); border-top-color: var(--accent); animation: spin 1s linear infinite; }
.toast.busy .tspin { display: inline-block; }
.offscreen { position: absolute; left: -9999px; }

/* ------------------------------------------------------------------ desktop: fits one screen, columns scroll */
@media (min-width: 1101px) {
  body.pp { height: 100vh; }
}

/* ------------------------------------------------------------------ tablet: two columns, page scrolls */
@media (max-width: 1100px) {
  .pcols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pcol { overflow: visible; }
  .pcol:last-child { grid-column: 1 / -1; }
  .photos { grid-template-columns: repeat(5, 1fr); }
}

/* ------------------------------------------------------------------ phone: one column, actions docked at the bottom */
@media (max-width: 720px) {
  .pp .bar { gap: 6px 10px; }
  .pp .bar h1 { font-size: 1.15rem; }
  .pmeta { flex-basis: 100%; }
  .pcols { grid-template-columns: 1fr; padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
  .pcol:last-child { grid-column: auto; }
  .pcol { display: contents; }
  .photos { grid-template-columns: repeat(3, 1fr); }
  .pacts { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: auto 1fr 1.4fr; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -6px 20px rgba(0,0,0,.08); }
  .pacts .btn { min-height: 46px; }
  .pacts:has(#saveBtn[hidden]) { grid-template-columns: 1fr; }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
  dialog.sheet { margin: auto 0 0; width: 100%; max-width: none; max-height: 92vh; border-radius: 16px 16px 0 0; }
  dialog.sheet form { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .trio { grid-template-columns: 1fr 1.2fr 1fr; }
}

/* phone order: customer, job, lines, photos, signer (one column via display: contents) */
@media (max-width: 720px) {
  .pcols > .pcol:nth-child(1) > .card:nth-child(1) { order: 1; }
  .pcols > .pcol:nth-child(2) > .card:nth-child(1) { order: 2; }
  .pcols > .pcol:nth-child(3) > .card:nth-child(1) { order: 3; }
  .pcols > .pcol:nth-child(3) > .card:nth-child(2) { order: 4; }
  .pcols > .pcol:nth-child(1) > .card:nth-child(2) { order: 5; }
  .pcols > .pcol:nth-child(2) > .card:nth-child(2) { order: 6; }
}

/* list: Delete in the table's last column */
.rt td.act { width: 1%; white-space: nowrap; text-align: right; padding-top: 4px; padding-bottom: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
