/* Cost Details: 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.
   Everything after the activity section is the cost detail page (/c/, body.cd), adapted from proposals.css. */

/* ------------------------------------------------------------------ activity (every page)
   Same as Proposals (raised in claude/shared-ui-handoff.md; move to Shared/ui.css when adopted).
   pbar: thin moving bar under the header while any API call runs (added by auth.js).
   ispin: small inline spinner for "Loading…" rows. */
.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 */
.cd .bar h1 { font-size: 1.35rem; }
.cd .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; }

/* type: Irrigation (body.ty1) shows .t1 parts, Agronomy (body.ty2) shows .t2 parts, no type yet shows neither */
.ty1 .t2, .ty2 .t1, .ty0 .t1, .ty0 .t2 { display: none !important; }
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* segmented choice (type), same as Proposals */
.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; }

/* applicators: one picker per row with Remove */
.appls { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.appls li { display: flex; gap: 8px; align-items: center; }
.appls select { flex: 1; min-width: 0; }
.offscreen { position: absolute; left: -9999px; }

/* work order found by # */
.wo { display: grid; gap: 2px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--bg); }
.wo b { font-size: 1.05rem; }

/* totals */
.tots { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 0; }
.tots dt { color: var(--muted); }
.tots dd { margin: 0; text-align: right; font-weight: 600; }
.sum { display: flex; justify-content: space-between; padding-top: 8px; border-top: 2px solid var(--line); font: 700 1.15rem var(--f-display); }

/* 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; color: inherit; }
.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); white-space: pre-line; }

/* 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; color: inherit; }
.picklist button:hover { background: var(--surface-2); }
.picklist span { font-size: .85rem; color: var(--muted); }
.trio { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.calc { display: flex; justify-content: space-between; background: var(--bg); border-radius: 10px; padding: 10px 12px; font: 700 1.15rem var(--f-display); }
.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; color: inherit; }
.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; }

/* ------------------------------------------------------------------ desktop: fits one screen, columns scroll */
@media (min-width: 1101px) {
  body.cd { 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) {
  .cd .bar { gap: 6px 10px; }
  .cd .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: auto 1fr; }
  .pacts:has(#saveBtn[hidden]):has(#stepBtn[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)); }
}

/* phone order (one column via display: contents): work order, lines, photos, totals; set by the o1..o9 classes */
@media (max-width: 720px) {
  .o1 { order: 1; } .o2 { order: 2; } .o3 { order: 3; } .o4 { order: 4; } .o5 { order: 5; } .o6 { order: 6; } .o9 { order: 9; }
}

/* 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; }

/* bulk approve / complete (list): checkbox per row you may approve or complete, bar with the actions */
.rows li.can { display: flex; align-items: stretch; }
.rows li.can .rowlink { flex: 1; min-width: 0; padding-left: 8px; }
.rows .pick { display: flex; align-items: center; padding-left: var(--gutter); }
.rows .pick input, .rt .sel input { width: 20px; height: 20px; accent-color: var(--brand); cursor: pointer; }
.rt th.sel, .rt td.sel { width: 1%; padding-right: 0; }
.bulk { position: sticky; top: 0; z-index: 3; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 8px 0;
  padding: 10px 14px; background: var(--surface); border: 1px solid var(--brand-2); border-radius: var(--r-sm); box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.bulk #bulkN { font-weight: 700; margin-right: auto; }
