:root {
  /* Layout: a sticky top-sheet rail on the left, the working sections on the right; one column with a total bar on small screens. */
  --bg: #0c0d0f;
  --panel: #141518;
  --panel-2: #1b1c20;
  --panel-3: #24262c;
  --line: #2d2f36;
  --line-soft: #212329;
  --text: #eeece6;
  --muted: #9a9ca6;
  --faint: #666872;
  --amber: #ffa01f;
  --amber-deep: #a65e00;
  --amber-wash: rgba(255, 160, 31, 0.12);
  --on-amber: #15100a;
  --good: #4cd08a;
  --bad: #ff5c5c;
  --info: #5b8def;
  --display: "Bebas Neue", "Arial Narrow", Impact, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --glide: cubic-bezier(0.16, 1, 0.3, 1);
  --inout: cubic-bezier(0.65, 0, 0.35, 1);
  --gut: 20px;
  /* The dot grid behind every page: one dot each 22px. */
  --dots: radial-gradient(rgba(255, 255, 255, 0.17) 1px, transparent 1.3px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background-color: var(--bg);
  background-image: var(--dots);
  background-size: 22px 22px;
  color: var(--text);
  font: 14px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
}
h1, h2, h3, p { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 36px; padding: 0 14px;
  background: var(--panel-3); border: 1px solid var(--line); border-radius: 9px;
  font-weight: 500; font-size: 13px; white-space: nowrap;
  transition: transform 0.4s var(--spring), background 0.2s, border-color 0.2s, color 0.2s;
}
.btn:hover { border-color: #44464f; background: #2a2c33; }
.btn:active { transform: scale(0.96); transition-duration: 0.06s; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--panel-2); }
.btn.sm { min-height: 32px; padding: 0 12px; font-size: 12.5px; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn.push {
  background: var(--amber); color: var(--on-amber); border: 0; font-weight: 600;
  box-shadow: 0 4px 0 var(--amber-deep); margin-bottom: 4px;
  transition: transform 0.06s ease, box-shadow 0.06s ease;
}
.btn.push:hover { background: #ffad3d; }
.btn.push:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--amber-deep); }
.btn[disabled] { opacity: 0.45; pointer-events: none; }

/* ---------- Status pill ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 8px; min-height: 28px; padding: 0 11px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--panel);
  font: 500 11.5px var(--mono); color: var(--muted); white-space: nowrap;
  transition: background 0.35s, border-color 0.35s, color 0.35s;
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; transition: background 0.35s; }
.pill[data-state="saved"] .dot, .pill[data-state="cloud"] .dot { background: var(--good); }
.pill[data-state="local"] .dot { background: var(--info); }
.pill[data-state="saving"], .pill[data-state="loading"] { color: var(--text); }
.pill[data-state="saving"] .dot, .pill[data-state="loading"] .dot {
  width: 10px; height: 10px; background: transparent;
  border: 2px solid rgba(255, 160, 31, 0.3); border-top-color: var(--amber);
  animation: spin 0.7s linear infinite;
}
.pill[data-state="error"] { color: var(--bad); border-color: rgba(255, 92, 92, 0.45); }
.pill[data-state="error"] .dot { background: var(--bad); }
.pill[data-state="readonly"] .dot { background: var(--amber); }
@keyframes spin { to { transform: rotate(1turn); } }

.chip {
  display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 5px;
  font: 600 10.5px var(--mono); letter-spacing: 0.06em; text-transform: uppercase;
  background: var(--panel-3); color: var(--muted); border: 1px solid var(--line);
}
.chip.demo { color: var(--info); border-color: rgba(91, 141, 239, 0.4); background: rgba(91, 141, 239, 0.1); }

/* Cost-code key: the A–Q reference letter of a bid form */
.key {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 26px; height: 24px; border-radius: 6px;
  font: 600 12px var(--mono); color: var(--muted);
  background: var(--panel-3); border: 1px solid var(--line); border-bottom-width: 2px;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.has > .cat-head .key, .lrow.has .key { color: var(--amber); border-color: rgba(255, 160, 31, 0.45); background: var(--amber-wash); }

/* ---------- Menus ---------- */
.menu-wrap { position: relative; }
.menu {
  position: absolute; z-index: 40; top: calc(100% + 8px); left: 0; min-width: 260px; padding: 6px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
  transform-origin: top left; animation: menuIn 0.28s var(--glide);
}
.menu.right { left: auto; right: 0; transform-origin: top right; }
@keyframes menuIn { from { opacity: 0; transform: scale(0.96) translateY(-4px); } }
.menu button, .menu label.mitem {
  display: flex; flex-direction: column; gap: 2px; width: 100%; padding: 9px 11px; text-align: left;
  background: transparent; border: 0; border-radius: 8px; cursor: pointer;
}
.menu button:hover, .menu label.mitem:hover { background: var(--panel-3); }
.menu b { font-weight: 600; font-size: 13.5px; }
.menu span { font-size: 12px; color: var(--muted); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }
.menu label.mitem { flex-direction: row; align-items: center; gap: 10px; }
.menu label.mitem b { flex: 1; }

/* ---------- List view ---------- */
.view { max-width: 1560px; margin: 0 auto; padding: 0 var(--gut) 96px; }
.lhead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 34px 0 22px; border-bottom: 1px solid var(--line); }
.lhead-left { display: flex; align-items: center; min-width: 0; }
.brand { display: flex; align-items: baseline; gap: 12px; }
.brand h1 { font: 400 56px/0.9 var(--display); letter-spacing: 0.03em; }
.brand .ver { font: 600 12px var(--mono); color: var(--amber); border: 1px solid rgba(255, 160, 31, 0.45); border-radius: 5px; padding: 2px 6px; transform: translateY(-14px); }
.lhead-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.lhead-actions .menu { left: auto; right: 0; transform-origin: top right; }

.notice {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 16px; padding: 12px 14px;
  border: 1px solid rgba(255, 160, 31, 0.4); border-left-width: 4px; border-radius: 10px;
  background: var(--amber-wash); font-size: 13.5px;
}
.notice span { flex: 1; min-width: 200px; }

.blist { display: flex; flex-direction: column; margin-top: 8px; }
.brow {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px 28px; align-items: center;
  padding: 18px 0; border-bottom: 1px solid var(--line-soft);
}
.brow-main { position: relative; display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 4px 0; text-align: left; border-radius: 8px; }
.brow-line { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brow-title { min-width: 0; padding: 0; background: none; border: 0; text-align: left; color: inherit; font: 400 34px/1 var(--display); letter-spacing: 0.02em; overflow-wrap: anywhere; transition: color 0.2s; }
.brow-title::after { content: ""; position: absolute; inset: 0; border-radius: 8px; } /* a press anywhere on the block opens the budget */
.brow-title:focus-visible { outline: none; }
.brow-title:focus-visible::after { outline: 2px solid var(--amber); outline-offset: 2px; }
.brow-edit {
  position: relative; z-index: 1; flex: none; display: grid; place-items: center; width: 32px; height: 32px; padding: 0;
  color: var(--muted); background: var(--panel-3); border: 1px solid var(--line); border-radius: 8px;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.brow-edit svg { width: 16px; height: 16px; transition: transform 0.4s var(--spring); }
.brow-edit:hover { color: var(--amber); border-color: rgba(255, 160, 31, 0.55); background: var(--amber-wash); }
.brow-edit:hover svg { transform: rotate(-12deg) scale(1.08); }
.brow-edit:active svg { transform: scale(0.9); transition-duration: 0.07s; }
.brow-line.editing .brow-title, .brow-line.editing .brow-edit { display: none; }
.brow-rename {
  position: relative; z-index: 1; width: min(100%, 560px); margin: -5px 0 -5px -9px; padding: 4px 8px;
  font: 400 34px/1 var(--display); letter-spacing: 0.02em; color: var(--text);
  background: var(--bg); border: 1px solid var(--amber); border-radius: 8px; outline: none;
}
.brow-main:hover:not(:has(.brow-edit:hover)) .brow-title { color: var(--amber); }
.brow-sub { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font: 12px var(--mono); color: var(--muted); }
.brow-nums { display: flex; gap: 28px; }
.brow-nums div { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.k { font: 500 10.5px var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.brow-nums .v { font: 500 17px var(--mono); font-variant-numeric: tabular-nums; }
.brow-nums .v.est { color: var(--amber); }
.brow-acts { display: flex; gap: 4px; }
.empty { padding: 56px 0; display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.empty h2 { font: 400 34px/1 var(--display); letter-spacing: 0.02em; }
.empty p { color: var(--muted); max-width: 52ch; }
.empty .row { display: flex; gap: 10px; flex-wrap: wrap; }
.skel { height: 74px; border-bottom: 1px solid var(--line-soft); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.04), transparent); background-size: 200% 100%; animation: sweep 1.4s linear infinite; }
@keyframes sweep { to { background-position: -200% 0; } }

/* ---------- Editor bar ---------- */
.ebar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px;
  margin: 0 calc(var(--gut) * -1); padding: 10px var(--gut);
  background: rgba(12, 13, 15, 0.88); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.ebar-title { display: flex; align-items: baseline; gap: 12px; min-width: 0; flex: 1; }
.ebar-title #ebTitle { font: 400 26px/1.1 var(--display); letter-spacing: 0.03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ebar-title .code { font: 500 12.5px var(--mono); color: var(--amber); white-space: nowrap; }
.ebar-actions { display: flex; align-items: center; gap: 8px; }
.only-narrow { display: none !important; }

.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch i { position: relative; width: 34px; height: 20px; border-radius: 999px; background: var(--panel-3); border: 1px solid var(--line); flex: none; transition: background 0.25s, border-color 0.25s; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: transform 0.4s var(--spring), background 0.25s; }
.switch input:checked + i { background: var(--amber-wash); border-color: rgba(255, 160, 31, 0.6); }
.switch input:checked + i::after { transform: translateX(14px); background: var(--amber); }
.switch input:focus-visible + i { outline: 2px solid var(--amber); outline-offset: 2px; }

/* ---------- Editor grid ---------- */
.egrid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; padding-top: 20px; }
.work { min-width: 0; display: flex; flex-direction: column; gap: 14px; container-type: inline-size; container-name: work; }

/* ---------- Top sheet ---------- */
.sheet { background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--amber); border-radius: 14px; padding: 16px 14px 12px; min-width: 0; }
.sheet-total { display: flex; flex-direction: column; gap: 2px; }
.big { font: 400 60px/0.95 var(--display); letter-spacing: 0.01em; color: var(--amber); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.sheet-total .k2 { font-size: 12px; color: var(--muted); }
/* Target budget: the number to stay under, with a gauge. */
.target { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 12px; row-gap: 8px; align-items: end; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.target-in { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.target .cash { position: relative; display: block; }
.target .cash i { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); font: 13px var(--mono); font-style: normal; color: var(--muted); pointer-events: none; }
.target .cash input {
  width: 100%; min-height: 34px; padding: 5px 8px 5px 22px; font-size: 14px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 7px; outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.target .cash input:hover { border-color: var(--muted); }
.target .cash input:focus { border-color: var(--amber); background: #101114; }
.target-out { display: flex; flex-direction: column; gap: 5px; min-width: 0; text-align: right; }
.target-out .v { font: 500 20px/34px var(--mono); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.target .s { grid-column: 1 / -1; font: 11.5px var(--mono); color: var(--muted); }
.tgauge { grid-column: 1 / -1; position: relative; height: 8px; border-radius: 4px; background: var(--line-soft); }
.tgauge i { position: absolute; top: 0; bottom: 0; }
.tgauge .use { left: 0; width: 0; border-radius: 4px; background: linear-gradient(90deg, var(--amber-deep), var(--amber)); transition: width 0.9s var(--glide); }
.tgauge .ovr { left: 100%; width: 0; border-radius: 0 4px 4px 0; background: var(--bad); transition: left 0.9s var(--glide), width 0.9s var(--glide); }
.tgauge .mark { left: 100%; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; border-radius: 1px; background: var(--text); transition: left 0.9s var(--glide); }
.target.over .use { border-radius: 4px 0 0 4px; }
.target.over .target-out .v { color: var(--bad); }
.target.under .target-out .v { color: var(--good); }
.target.none .target-out, .target.none .tgauge { display: none; }
.target.none { grid-template-columns: minmax(0, 1fr); }
.ro .target.none { display: none; }
.sheet-trio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 12px 0 8px; padding: 10px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.sheet-trio > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.sheet-trio .v { font: 500 16px var(--mono); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.sheet-trio .s { font: 11.5px var(--mono); color: var(--muted); }
.over .v, .over .s { color: var(--bad); }
.under .v, .under .s { color: var(--good); }

.ledger { display: flex; flex-direction: column; }
.lrow {
  position: relative; display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; column-gap: 10px; align-items: center;
  width: 100%; padding: 4px 6px 8px; text-align: left;
  background: transparent; border: 0; border-radius: 8px; transition: background 0.2s;
}
.lrow:hover { background: var(--panel-2); }
.lrow .key { width: 22px; height: 20px; font-size: 11px; }
.lrow .lt { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lrow.has .lt { color: var(--text); }
.lrow .le { font: 12.5px var(--mono); font-variant-numeric: tabular-nums; color: var(--faint); }
.lrow.has .le { color: var(--text); }
.lbar { position: absolute; left: 38px; right: 6px; bottom: 2px; height: 3px; border-radius: 2px; background: var(--line-soft); overflow: hidden; }
.lbar i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 3px; transition: width 0.9s var(--glide); }
.lbar .e { background: linear-gradient(90deg, var(--amber-deep), var(--amber)); }
.lbar .a { top: auto; height: 1.5px; background: var(--good); }
.lrow.over-act .lbar .a { background: var(--bad); }

.markups { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.mrow { display: grid; grid-template-columns: minmax(0, 1fr) auto 104px; gap: 10px; align-items: center; min-height: 30px; padding: 0 6px; font-size: 12.5px; }
.mrow > :first-child { color: var(--muted); }
.mrow .amt { font: 12.5px var(--mono); text-align: right; font-variant-numeric: tabular-nums; }
.mrow .pct { display: inline-flex; align-items: center; gap: 4px; font: 12.5px var(--mono); color: var(--muted); }
.mrow .pct input { width: 58px; min-height: 28px; padding: 3px 7px; }
.mrow.grand { margin-top: 6px; padding: 10px 6px; border-top: 2px solid var(--amber); min-height: 0; }
.mrow.grand > :first-child { font: 400 20px/1 var(--display); letter-spacing: 0.04em; color: var(--text); }
.mrow.grand .amt { font: 600 15px var(--mono); color: var(--amber); }

/* ---------- Inputs ---------- */
.in, .line input, .field input, .field textarea, .note-card textarea, .mrow input, .frow input {
  width: 100%; min-height: 32px; padding: 5px 8px;
  background: var(--bg); border: 1px solid var(--line-soft); border-radius: 7px; outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.line input:hover, .field input:hover, .field textarea:hover, .note-card textarea:hover, .mrow input:hover, .frow input:hover { border-color: var(--line); }
.line input:focus, .field input:focus, .field textarea:focus, .note-card textarea:focus, .mrow input:focus, .frow input:focus { border-color: var(--amber); background: #101114; }
input.num { font-family: var(--mono); text-align: right; font-variant-numeric: tabular-nums; }
input[aria-invalid="true"] { border-color: var(--bad) !important; }
::placeholder { color: var(--faint); }

/* ---------- Job details ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.card-head { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 50px; padding: 0 14px; background: none; border: 0; text-align: left; border-radius: 14px; }
.card-head .h, .cat-title { font: 400 21px/1.1 var(--display); letter-spacing: 0.04em; flex: 1; min-width: 0; }
.chev { width: 18px; height: 18px; color: var(--muted); flex: none; transition: transform 0.35s var(--spring); }
.open > .card-head .chev, .open > .cat-head .chev { transform: rotate(180deg); }
.fold { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.45s var(--glide); }
.open > .fold { grid-template-rows: 1fr; }
.fold > div { overflow: hidden; min-height: 0; }
.job-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; padding: 4px 14px 16px; }
.job-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 12px; color: var(--muted); }
.field textarea, .note-card textarea { min-height: 132px; resize: vertical; line-height: 1.5; }
.field.title input { font: 400 26px/1.1 var(--display); letter-spacing: 0.03em; min-height: 44px; }
.mini { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }

/* ---------- Category sections ---------- */
#sections { display: flex; flex-direction: column; gap: 10px; }
.cat { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; scroll-margin-top: 72px; }
.cat-head { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 8px 14px; background: none; border: 0; text-align: left; border-radius: 14px; }
.cat-title { color: var(--muted); transition: color 0.2s; }
.has > .cat-head .cat-title, .open > .cat-head .cat-title { color: var(--text); }
.cat-tot { display: flex; align-items: baseline; gap: 8px; font: 12.5px var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cat-tot b { font-weight: 500; color: var(--faint); min-width: 62px; text-align: right; }
.cat-tot span.k ~ span.k { margin-left: 16px; }
.has .cat-tot b[data-r="est"] { color: var(--amber); }
.has .cat-tot b[data-r="act"] { color: var(--text); }
.cat-inner { padding: 2px 12px 14px; }

.lhd, .line { display: grid; gap: 4px; align-items: center; }
.labor .lhd, .labor .line { grid-template-columns: 18px minmax(140px, 1.7fr) minmax(60px, 1fr) 44px 44px 72px 50px 50px 50px 92px 92px 24px; }
.expense .lhd, .expense .line { grid-template-columns: 18px minmax(140px, 1.7fr) minmax(60px, 1fr) 44px 44px 72px 92px 92px 24px; }
.lhd { padding: 6px 0; border-bottom: 1px solid var(--line); }
.lhd span { font: 500 10px var(--mono); letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); text-align: right; padding-right: 7px; white-space: nowrap; }
.lhd span.l { text-align: left; padding-left: 8px; }
.line { padding: 3px 0; border-bottom: 1px dashed var(--line-soft); }
.line .c { min-width: 0; display: block; }
.line .cl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.line input { min-height: 30px; padding: 4px 7px; font-size: 13px; background: transparent; border-color: transparent; }
.line .c-note input { color: var(--muted); font-size: 12.5px; }
.line .c-note input::placeholder { color: transparent; }
.line:hover .c-note input::placeholder, .line .c-note input:focus::placeholder { color: var(--faint); }
.line .c-est input { font-weight: 500; color: var(--amber); }
.line .c-est input::placeholder { color: var(--amber); opacity: 1; }
.line .c-est input:focus::placeholder { opacity: 0.4; }
/* A line with an estimate typed by hand: mark the amount, and dim the numbers that are not in use. */
.line.typed .c-est input { background: var(--amber-wash); border: 1px solid rgba(255, 160, 31, 0.45); }
.line.typed :is(.c-no, .c-days, .c-rate, .c-ot15, .c-ot2, .c-ot25) input:not(:focus) { opacity: 0.38; }
.drag { color: var(--faint); cursor: grab; text-align: center; font-size: 13px; line-height: 1; user-select: none; touch-action: none; }
.drag:active { cursor: grabbing; }
.del { width: 24px; height: 28px; padding: 0; background: none; border: 0; border-radius: 6px; color: var(--faint); font-size: 16px; line-height: 1; transition: color 0.2s, background 0.2s; }
.del:hover { color: var(--bad); background: rgba(255, 92, 92, 0.12); }
.sortable-ghost { background: var(--amber-wash); outline: 1px dashed var(--amber); border-radius: 8px; }
.filled-only .line[data-empty="1"]:not([data-keep]):not(:focus-within) { display: none; }
.no-sort .drag { visibility: hidden; }

.foot { display: flex; flex-direction: column; margin-top: 8px; }
.frow { display: grid; grid-template-columns: minmax(0, 1fr) 110px 110px 24px; gap: 4px; align-items: center; min-height: 32px; font-size: 12.5px; }
.frow > :first-child { display: flex; align-items: center; justify-content: flex-end; gap: 8px; color: var(--muted); text-align: right; }
.frow b { font: 500 13px var(--mono); text-align: right; padding-right: 7px; font-variant-numeric: tabular-nums; }
.frow input { width: 64px; min-height: 28px; }
.frow.total { margin-top: 4px; border-top: 2px solid var(--amber); padding-top: 4px; }
.frow.total > :first-child { color: var(--text); font-weight: 600; }
.frow.total b[data-r="tot"] { color: var(--amber); }
.cat-tools { display: flex; gap: 8px; margin-top: 10px; }

/* ---------- Notes ---------- */
.notes { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.note-card { padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.note-card h2 { font: 400 21px/1.1 var(--display); letter-spacing: 0.04em; }

/* ---------- Bottom total bar (narrow screens) ---------- */
.botbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; display: flex; align-items: center; gap: 18px; width: 100%;
  padding: 10px var(--gut) calc(10px + env(safe-area-inset-bottom, 0px)); text-align: left;
  background: rgba(20, 21, 24, 0.94); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border: 0; border-top: 2px solid var(--amber);
}
.botbar .bb { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.botbar .v { font: 400 28px/1 var(--display); letter-spacing: 0.02em; color: var(--amber); font-variant-numeric: tabular-nums; }
.botbar .v2 { font: 500 14px var(--mono); font-variant-numeric: tabular-nums; }
.botbar .grow { flex: 1; }
.botbar .hint { font-size: 12px; color: var(--muted); }

/* ---------- Snackbar ---------- */
.snackbar {
  position: fixed; left: 50%; bottom: 84px; z-index: 60; display: flex; align-items: center; gap: 14px;
  max-width: calc(100vw - 32px); padding: 11px 12px 13px 16px; overflow: hidden;
  background: var(--panel-3); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 36px rgba(0, 0, 0, 0.55);
  font-size: 13.5px; transform: translate(-50%, 140%); opacity: 0; visibility: hidden; pointer-events: none;
  transition: transform 0.4s var(--spring), opacity 0.2s, visibility 0s 0.4s;
}
.snackbar.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; pointer-events: auto; transition: transform 0.4s var(--spring), opacity 0.2s; }
.snackbar .progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--amber); transform-origin: left; }
.snackbar.show .progress { animation: drain var(--snack-ms, 4500ms) linear forwards; }
@keyframes drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* ---------- Wide: the top sheet becomes a sticky rail ---------- */
@media (min-width: 1200px) {
  .egrid { grid-template-columns: 330px minmax(0, 1fr); align-items: start; }
  .sheet { position: sticky; top: 72px; max-height: calc(100dvh - 88px); overflow: auto; overscroll-behavior: contain; }
  .botbar { display: none; }
  .view { padding-bottom: 64px; }
  .snackbar { bottom: 28px; }
}

/* ---------- Narrow top bar ---------- */
@media (max-width: 1199px) {
  .lrow { padding: 9px 6px 13px; }
  .lrow .lt, .lrow .le { font-size: 14px; }
  .lbar { bottom: 5px; }
}
@media (max-width: 860px) {
  .only-wide { display: none !important; }
  .only-narrow { display: flex !important; }
  .ebar { gap: 8px; }
  .ebar-title { flex-direction: column; gap: 0; align-items: flex-start; }
  .ebar-title #ebTitle { font-size: 22px; max-width: 100%; }
  .ebar-title .code { font-size: 11px; }
  #backBtn { padding: 0 8px; }
  #backBtn span { display: none; }
  .pill#savePill span { display: none; }
  .pill#savePill { padding: 0 9px; }
  .brand h1 { font-size: 44px; }
  .brow { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .brow-nums div { align-items: flex-start; }
  .brow-acts { margin-left: -12px; }
  .big { font-size: 56px; }
}
@media (max-width: 520px) {
  :root { --gut: 16px; }
  .cat-tot .k { display: none; }
  .cat-tot b { min-width: 0; }
  .cat-tot b[data-r="act"] { display: none; }
  .cat-title { font-size: 18px; }
  .mini { gap: 8px; }
}

/* ---------- Line rows become cards when the work column is narrow ---------- */
@container work (max-width: 799px) {
  .lhd { display: none; }
  .line {
    gap: 6px; align-items: end; padding: 8px 10px 10px; margin-top: 8px;
    background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: 12px;
  }
  .labor .line { grid-template-columns: minmax(0, 0.8fr) minmax(0, 0.8fr) minmax(0, 1.3fr) minmax(0, 1.9fr); grid-template-areas: "desc desc desc del" "note note note note" "no days rate est" "o1 o2 o3 act"; }
  .expense .line { grid-template-columns: repeat(6, minmax(0, 1fr)); grid-template-areas: "desc desc desc desc desc del" "note note note note note note" "no no days days rate rate" "est est est act act act"; }
  .line .cl { position: static; width: auto; height: auto; overflow: visible; clip: auto; display: block; margin-bottom: 2px; font: 500 9.5px var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
  .line .c-desc { grid-area: desc; } .line .c-note { grid-area: note; margin-top: -6px; }
  .line .c-no { grid-area: no; } .line .c-days { grid-area: days; } .line .c-rate { grid-area: rate; }
  .line .c-ot15 { grid-area: o1; } .line .c-ot2 { grid-area: o2; } .line .c-ot25 { grid-area: o3; }
  .line .c-est { grid-area: est; } .line .c-act { grid-area: act; }
  .line .c-desc .cl, .line .c-note .cl { display: none; }
  .line .del { grid-area: del; justify-self: end; align-self: center; width: 36px; height: 36px; }
  .line .drag { display: none; }
  .line input { min-height: 38px; font-size: 16px; padding: 4px 8px; background: var(--bg); border-color: var(--line-soft); }
  .line .c-desc input { min-height: 36px; font-weight: 600; background: transparent; border-color: transparent; padding-left: 2px; }
  .line .c-note input { min-height: 28px; font-size: 16px; background: transparent; border-color: transparent; padding: 0 2px; }
  .line .c-note input::placeholder { color: var(--faint); }
  .line .c-est input { background: transparent; border: 1px dashed var(--line); padding: 4px 6px; }
  .frow { grid-template-columns: minmax(0, 1fr) 96px 96px; }
  .frow > :first-child { flex-wrap: wrap; }
  .frow > span:last-child:empty { display: none; }
  .cat-inner { padding: 0 10px 12px; }
  .job-grid { padding: 4px 12px 14px; }
  .field input, .field textarea, .note-card textarea, .mrow input, .frow input { font-size: 16px; min-height: 40px; }
}

.site-only, .owner-only, .owner-narrow { display: none !important; }
.ro .del, .ro .cat-tools, .ro .drag, .ro #newBtn, .ro .brow-acts { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
