/* ============ Quotely — "The Estimate Ledger" (v2) ============
   A trades estimating desk with a ledger's character: warm paper ground,
   white sheet surfaces, hairline ledger rules, mono reference numbers,
   and a contractor-amber accent (field-mark orange). Sharp square geometry
   throughout; one accent; tabular numerals on every dollar figure. */
:root {
  --bg: #f3f1ea;
  --card: #ffffff;
  --line: #ddd6c4;
  --line-soft: #e9e5d4;
  --ink: #1d201b;
  --ink-soft: #3d4239;
  --muted: #6f7466;
  --faint: #9a9e8e;
  --amber: #b45309;
  --amber-dark: #92400e;
  --amber-soft: #faf0df;
  --amber-line: #e8d3ac;
  --green: #1c7a3f;
  --green-dark: #145c30;
  --green-soft: #e6f3ea;
  --blue: #1d4ed8;
  --blue-soft: #e9effe;
  --red: #b42323;
  --red-soft: #fdeeee;
  --slate-soft: #efede4;
  --sidebar: #21251f;
  --sidebar-ink: #d8d5c8;
  --sidebar-muted: #8f8c7d;
  --sidebar-active: #2c312a;
  --shadow: 0 1px 2px rgba(29, 32, 27, .07);
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --disp: "Inter Tight", "Inter", -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; border-radius: 0 !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--sans); background: var(--bg); color: var(--ink);
  font-size: 14.5px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
h1 { font-family: var(--disp); font-size: 27px; font-weight: 800; letter-spacing: -.6px; margin: 0; }
h3 { font-family: var(--disp); font-size: 15px; font-weight: 700; margin: 0; letter-spacing: -.1px; }
button { font-family: var(--sans); cursor: pointer; }
input, select, textarea {
  font-family: var(--sans); font-size: 14px; color: var(--ink);
  border: 1px solid var(--line); background: #fff;
  padding: 9px 12px; width: 100%; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px rgba(180, 83, 9, .15);
}
textarea { resize: vertical; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--amber); cursor: pointer; }
.hint { color: var(--muted); font-size: 12.5px; margin: 8px 0 0; line-height: 1.5; }
.hint-inline { color: var(--faint); font-weight: 400; font-size: 12px; }
.hidden { display: none !important; }
.num, .t-num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); }
.kicker {
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 2.2px; color: var(--amber-dark);
  margin-bottom: 5px;
}
.step-num {
  font-family: var(--mono); font-size: 11px; font-weight: 600; color: var(--amber-dark);
  background: var(--amber-soft); border: 1px solid var(--amber-line);
  padding: 2px 7px; margin-right: 8px; letter-spacing: 1px;
}

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--sidebar); color: var(--sidebar-ink);
  padding: 24px 14px; display: flex; flex-direction: column; gap: 26px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px; }
.brand-mark {
  width: 34px; height: 34px; background: var(--amber); color: #fff; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--disp); font-weight: 800; font-size: 19px; letter-spacing: -.5px;
}
.brand-name { font-family: var(--disp); font-weight: 800; font-size: 17px; letter-spacing: -.2px; color: #fff; }
.brand-sub { font-family: var(--mono); font-size: 10px; color: var(--sidebar-muted); letter-spacing: 1.8px; text-transform: uppercase; margin-top: 2px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; background: none; border: none;
  color: var(--sidebar-muted); font-size: 14px; font-weight: 500;
  padding: 10px 12px; text-align: left; width: 100%;
  border-left: 3px solid transparent;
  transition: background .13s, color .13s, border-color .13s;
}
.nav-item svg { width: 17px; height: 17px; flex: none; opacity: .85; }
.nav-item:hover { background: rgba(255, 255, 255, .05); color: var(--sidebar-ink); }
.nav-item.active { background: var(--sidebar-active); color: #fff; border-left-color: var(--amber); font-weight: 600; }
.nav-item.active svg { opacity: 1; }
.nav-count {
  margin-left: auto; background: rgba(255, 255, 255, .12);
  font-family: var(--mono); font-size: 11px; font-weight: 600; padding: 1px 8px; color: var(--sidebar-ink);
}
.nav-count:empty { display: none; }
.side-foot { margin-top: auto; padding: 0 8px; font-size: 11.5px; color: var(--sidebar-muted); line-height: 1.6; }

main { padding: 30px 36px 64px; max-width: 1280px; width: 100%; margin: 0 auto; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; }
.page-sub { color: var(--muted); margin: 6px 0 0; font-size: 13.5px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- buttons ---------- */
.btn, .btn-ghost, .btn-danger, .linklike {
  font-weight: 600; font-size: 14px; padding: 9px 18px; border: 1px solid transparent;
  transition: background .13s, border-color .13s, color .13s;
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  text-decoration: none; white-space: nowrap;
}
.btn { background: var(--amber); color: #fff; }
.btn:hover { background: var(--amber-dark); }
.btn:disabled { background: #cdb68f; cursor: not-allowed; }
.btn-ghost { background: var(--card); border-color: var(--line); color: var(--ink); box-shadow: var(--shadow); }
.btn-ghost:hover { border-color: var(--amber); color: var(--amber-dark); }
.btn-danger { background: transparent; border-color: #eec9c9; color: var(--red); }
.btn-danger:hover { background: var(--red-soft); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.linklike { background: none; border: none; color: var(--amber-dark); font-weight: 600; padding: 2px 0; font-size: 13px; }
.linklike:hover { color: var(--amber); text-decoration: underline; }
.row-end { display: flex; justify-content: flex-end; margin-top: 12px; }

/* ---------- status badges: flat, square, consistent ---------- */
.badge {
  display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .7px; padding: 3px 9px; white-space: nowrap; line-height: 1.5;
  border: 1px solid transparent;
}
.badge.draft { background: var(--slate-soft); color: var(--ink-soft); border-color: var(--line); }
.badge.sent { background: var(--blue-soft); color: var(--blue); }
.badge.won { background: var(--green-soft); color: var(--green-dark); }
.badge.lost { background: var(--slate-soft); color: var(--muted); }
.badge.expired { background: var(--red-soft); color: var(--red); border-color: #f3c8c8; }
.badge.opt { background: var(--amber-soft); color: var(--amber-dark); border-color: var(--amber-line); }
.stamp {
  font-size: 12px; font-weight: 600; letter-spacing: 1.6px; color: var(--muted);
  text-transform: uppercase;
}

/* ---------- dashboard ---------- */
.stat-strip {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
  margin-bottom: 18px; border-top: 3px solid var(--amber);
}
.stat { padding: 16px 20px; border-left: 1px solid var(--line-soft); }
.stat:first-child { border-left: none; }
.stat-label { font-family: var(--mono); font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.6px; color: var(--muted); }
.stat-num { font-family: var(--disp); font-size: 27px; font-weight: 800; letter-spacing: -.6px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat-num.good { color: var(--green-dark); }
.stat-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.panel {
  background: var(--card); border: 1px solid var(--line);
  padding: 20px 22px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.panel-head .hint { margin: 0; }
.panel.narrow { max-width: 620px; }
.cols-2 { display: grid; grid-template-columns: 1.35fr 1fr; gap: 18px; }
.cols-2 .panel { margin-bottom: 0; }

/* ---------- pipeline board (JobNimbus-boards spirit) ---------- */
.board-panel { padding-bottom: 14px; }
.board {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px;
}
.board-col {
  background: #faf8f1; border: 1px solid var(--line-soft);
  display: flex; flex-direction: column; min-height: 120px; cursor: pointer;
  transition: border-color .13s, background .13s;
}
.board-col:hover { border-color: var(--amber-line); background: #fbf7ea; }
.board-col-head { padding: 10px 12px 8px; border-bottom: 1px solid var(--line-soft); }
.board-col-name { font-family: var(--mono); font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.6px; color: var(--muted); }
.board-col-num { font-family: var(--disp); font-size: 21px; font-weight: 800; letter-spacing: -.4px; font-variant-numeric: tabular-nums; margin-top: 2px; }
.board-col-val { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.board-cards { padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.board-card {
  background: #fff; border: 1px solid var(--line); border-left: 3px solid var(--amber);
  padding: 9px 11px; font-size: 12.5px; transition: border-color .13s, box-shadow .13s;
}
.board-card:hover { border-color: var(--amber-line); box-shadow: var(--shadow); }
.board-card.st-draft { border-left-color: var(--faint); }
.board-card.st-sent { border-left-color: var(--blue); }
.board-card.st-won { border-left-color: var(--green); }
.board-card.st-lost { border-left-color: var(--line); }
.board-who { font-weight: 700; color: var(--ink); }
.board-num { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 1px; }
.board-amt { font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 5px; }
.board-fu { font-size: 11px; font-weight: 700; margin-top: 3px; }
.board-fu.due { color: var(--red); }
.board-fu.soon { color: var(--amber-dark); }
.board-empty { font-size: 12px; color: var(--faint); padding: 6px 4px; font-style: italic; }
.board-more { font-size: 11.5px; color: var(--muted); padding: 2px 4px; font-family: var(--mono); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  text-align: left; font-family: var(--mono); font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
  background: #faf8f1;
}
.tbl td { padding: 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr.rowlink { cursor: pointer; }
.tbl tbody tr.rowlink:hover { background: #fbf7ea; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .t-num { font-weight: 700; font-variant-numeric: tabular-nums; }
.tbl .t-cust { font-weight: 600; }
.tbl .t-sub { color: var(--muted); font-size: 12.5px; }
.tbl input, .tbl select { padding: 7px 9px; font-size: 13px; }
.tbl .qlink { color: var(--ink); font-weight: 700; text-decoration: none; border-bottom: 1px solid transparent; }
.tbl .qlink:hover { color: var(--amber-dark); border-bottom-color: var(--amber); }
.tbl .mono-num { font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }
.empty-row td { text-align: center; color: var(--muted); padding: 30px 12px; }
.fu-due { color: var(--red); font-weight: 700; font-size: 12.5px; }
.fu-soon { color: var(--amber-dark); font-weight: 700; font-size: 12.5px; }
.fu-none { color: var(--muted); font-size: 12.5px; }
.empty-state { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty-state strong { display: block; color: var(--ink); font-size: 14.5px; margin-bottom: 4px; }
.empty-state p { margin: 0 0 14px; font-size: 13px; }
.opt-check { display: flex; align-items: center; justify-content: center; }
tr.is-optional td { background: #fdf9ef; }
tr.is-optional td:first-child { border-left: 3px solid var(--amber); }

/* ---------- quotes list toolbar ---------- */
.quotes-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 6px; flex-wrap: wrap; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); }
.tab {
  background: none; border: none; border-bottom: 3px solid transparent; margin-bottom: -1px;
  padding: 10px 14px; font-size: 13.5px; font-weight: 600; color: var(--muted);
  transition: color .13s, border-color .13s;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--amber-dark); border-bottom-color: var(--amber); }
.search { max-width: 300px; }
.list-summary {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 12px 2px 4px; font-size: 13px; color: var(--muted);
}
.list-summary strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.alert {
  background: var(--amber-soft); border: 1px solid var(--amber-line); border-left: 4px solid var(--amber);
  color: #6b3c06; padding: 12px 16px; font-size: 13.5px; margin-bottom: 14px;
}
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- follow-ups ---------- */
.fu-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; }
.fu-item:last-child { border-bottom: none; }
.fu-who { font-weight: 600; }
.fu-what { font-family: var(--mono); color: var(--muted); font-size: 11.5px; }
.fu-empty { color: var(--muted); font-size: 13.5px; padding: 6px 0; }

/* ---------- builder ---------- */
.editor { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 20px; align-items: start; }
.form-col { display: flex; flex-direction: column; min-width: 0; }
.field { margin-bottom: 13px; }
.field > label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin-bottom: 5px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .grid-3 { grid-template-columns: 1fr; } }
.preview-col { position: sticky; top: 22px; min-width: 0; }
.template-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.template-bar select { flex: 1; }

/* ---------- the quote document (the sheet) ---------- */
.doc {
  background: #fff; border: 1px solid var(--line);
  padding: 34px 36px 30px; font-size: 13.5px; color: var(--ink);
  box-shadow: var(--shadow);
  border-top: 4px solid var(--ink);
}
.doc-head { display: flex; justify-content: space-between; gap: 18px; padding-bottom: 18px; border-bottom: 2px solid var(--ink); margin-bottom: 20px; }
.doc-co { font-family: var(--disp); font-size: 25px; font-weight: 800; letter-spacing: -.4px; }
.doc-co-sub { color: var(--muted); font-size: 12.5px; margin-top: 5px; line-height: 1.6; }
.doc-logo { max-height: 46px; margin-bottom: 8px; display: block; }
.doc-meta { text-align: right; font-size: 12.5px; color: var(--ink-soft); line-height: 1.75; flex: none; }
.doc-kicker { font-family: var(--mono); font-size: 12px; font-weight: 600; letter-spacing: 3.5px; color: var(--ink); }
.doc-number { font-family: var(--mono); font-size: 12px; font-weight: 600; }
.doc-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 22px; }
.doc-parties h4 { margin: 0 0 6px; font-family: var(--mono); font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.8px; color: var(--muted); }
.doc-parties .who { font-weight: 700; font-size: 14.5px; }
.doc-parties .sub { color: var(--muted); font-size: 12.5px; line-height: 1.65; }
table.doc-items { width: 100%; border-collapse: collapse; margin-bottom: 4px; }
table.doc-items th {
  font-family: var(--mono); font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.4px; color: var(--muted);
  text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--ink); background: none;
}
table.doc-items td { padding: 11px 6px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.doc-items .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.doc-items .item-name { font-weight: 600; }
table.doc-items .item-desc { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
table.doc-items tr.opt-line td { background: #fdf9ef; }
.doc-options { margin-top: 18px; border: 1px dashed var(--amber-line); padding: 14px 16px 6px; background: #fffdf7; }
.doc-options h4 { margin: 0 0 6px; font-family: var(--mono); font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.8px; color: var(--amber-dark); }
table.doc-totals { width: 64%; margin-left: auto; border-collapse: collapse; margin-top: 10px; }
table.doc-totals td { padding: 5px 4px; font-size: 13px; }
table.doc-totals td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.doc-totals tr.grand td { font-weight: 800; font-size: 16.5px; border-top: 2px solid var(--ink); padding-top: 9px; font-family: var(--disp); }
table.doc-totals tr.with-options td { color: var(--amber-dark); font-weight: 700; }
.doc-terms { margin-top: 16px; font-size: 13px; color: var(--ink-soft); border-top: 1px solid var(--line-soft); padding-top: 12px; line-height: 1.7; }
.doc-notes { margin-top: 12px; font-size: 13px; color: var(--ink-soft); }
.doc-photos { margin-top: 22px; }
.doc-photos h4 { margin: 0 0 10px; font-family: var(--mono); font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.8px; color: var(--muted); }
.doc-photos-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.doc-photos figure { margin: 0; border: 1px solid var(--line); padding: 6px; }
.doc-photos img { width: 100%; height: 96px; object-fit: cover; display: block; }
.doc-photos figcaption { font-family: var(--mono); font-size: 10.5px; color: var(--muted); padding-top: 5px; }
.doc-sign { display: flex; gap: 32px; margin-top: 36px; color: var(--muted); font-size: 12px; }
.doc-sign > div { flex: 1; border-top: 1px solid var(--ink); padding-top: 6px; }

/* ---------- quote detail: the job file ---------- */
.crumb-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.crumb { background: none; border: none; color: var(--muted); font-size: 13.5px; font-weight: 600; padding: 4px 0; }
.crumb:hover { color: var(--amber-dark); }
.jobfile { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 4fr); gap: 20px; align-items: start; }
.jobfile-main { min-width: 0; }
.detail-head {
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
  border-top: 3px solid var(--amber);
  padding: 20px 24px; margin-bottom: 18px; display: flex; justify-content: space-between;
  align-items: flex-start; gap: 18px; flex-wrap: wrap;
}
.detail-cust { font-family: var(--disp); font-size: 23px; font-weight: 800; letter-spacing: -.4px; margin: 0 0 6px; }
.detail-sub { color: var(--muted); font-size: 13px; }
.detail-sub .mono { font-size: 12px; }
.detail-badges { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.detail-side { text-align: right; }
.detail-total { font-family: var(--disp); font-size: 28px; font-weight: 800; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.detail-total-sub { font-size: 12px; color: var(--muted); margin-top: 3px; font-variant-numeric: tabular-nums; }
.detail-total-label { font-family: var(--mono); font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.8px; color: var(--muted); }
.jobfile-rail { min-width: 0; display: flex; flex-direction: column; gap: 14px; position: sticky; top: 22px; }
.rail-mod {
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
  padding: 15px 17px;
}
.rail-kicker {
  font-family: var(--mono); font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 1.8px; color: var(--amber-dark); margin-bottom: 10px;
  padding-bottom: 8px; border-bottom: 1px solid var(--line-soft);
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.rail-kicker .hint { margin: 0; font-family: var(--sans); text-transform: none; letter-spacing: 0; }
.detail-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.rail-customer .rc-name { font-weight: 700; font-size: 14.5px; }
.rail-customer .rc-line { font-size: 13px; color: var(--ink-soft); margin-top: 4px; }
.rail-customer .rc-line a { color: var(--amber-dark); }
.rail-note { font-size: 13px; color: var(--ink-soft); line-height: 1.6; white-space: pre-wrap; }
.rail-note.empty { color: var(--faint); font-style: italic; }
.rail-bill-row { display: flex; justify-content: space-between; font-size: 13px; padding: 5px 0; border-bottom: 1px solid var(--line-soft); }
.rail-bill-row:last-child { border-bottom: none; }
.rail-bill-row .num { font-variant-numeric: tabular-nums; font-weight: 600; }
.hist-mini { font-size: 13px; color: var(--ink-soft); margin-bottom: 8px; }

/* ---------- job pipeline (trades pipeline: sitevisit -> quotely -> signpilot) ---------- */
.pipe-block { padding: 11px 0; border-top: 1px solid var(--line-soft); }
.pipe-block:first-child { border-top: none; padding-top: 0; }
.pipe-label { font-family: var(--mono); font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.6px; color: var(--muted); margin-bottom: 6px; }
.pipe-val { font-size: 13px; }
.pipe-val .hint { display: inline; margin: 0 0 0 6px; }
.pipe-tbl { margin: 0 0 8px; }
.pipe-tbl td, .pipe-tbl th { padding: 7px 10px; }
.co-form { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.co-form input { flex: 1 1 180px; }
.pipe-actions { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 8px; }

/* ---------- job photos: clean attachments ---------- */
.dropzone {
  border: 1.5px dashed var(--line); background: #faf8f1;
  padding: 22px 18px; text-align: center; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 13.5px; color: var(--ink-soft); transition: border-color .15s, background .15s;
  margin-bottom: 14px;
}
.dropzone:hover, .dropzone.drag { border-color: var(--amber); background: var(--amber-soft); }
.dropzone:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.dz-plus {
  width: 28px; height: 28px; background: var(--amber); color: #fff; flex: none;
  display: inline-flex; align-items: center; justify-content: center; font-size: 17px; font-weight: 700;
}
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 12px; }
.photo-card { background: #fff; border: 1px solid var(--line); padding: 10px; }
.photo-card img { width: 100%; height: 132px; object-fit: cover; display: block; background: #efede4; }
.photo-card .cap {
  margin-top: 8px; padding: 6px 8px; font-size: 12.5px; border: 1px solid var(--line-soft); width: 100%;
}
.photo-meta { display: flex; gap: 6px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.tag {
  border: 1px solid var(--line); background: #fff; padding: 4px 10px;
  font-size: 12px; font-weight: 600; color: var(--muted); width: auto;
}
.tag.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.photo-card .iconbtn {
  border: 1px solid var(--line); background: #fff; padding: 4px 10px;
  font-size: 12px; font-weight: 600; color: var(--ink-soft); width: auto;
}
.photo-card .iconbtn:hover { border-color: var(--amber); color: var(--amber-dark); }
.photo-card .iconbtn.danger { color: var(--red); }
.photo-card .iconbtn.danger:hover { background: var(--red-soft); border-color: #eec9c9; }
.photo-analysis {
  display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap;
  font-size: 11.5px; color: var(--muted); font-family: var(--mono);
}
.flag { font-weight: 700; font-family: var(--sans); font-size: 11.5px; }
.flag.ok { color: var(--green-dark); }
.flag.warn { color: var(--red); }
.swatches { display: inline-flex; gap: 3px; }
.swatch { width: 13px; height: 13px; border: 1px solid var(--line); display: inline-block; }
.ai-panel {
  margin-top: 8px; font-size: 12.5px; background: var(--amber-soft); color: var(--ink-soft);
  border: 1px solid var(--amber-line); border-left: 3px solid var(--amber); padding: 9px 11px; line-height: 1.55;
}
.ai-panel.warn { background: var(--red-soft); border-color: #eec9c9; border-left-color: var(--red); }
.ai-items { margin: 8px 0; display: grid; gap: 4px; }
.ai-items div { background: #fff; border: 1px solid var(--line-soft); padding: 6px 10px; }
.photo-empty {
  border: 1.5px dashed var(--line); padding: 26px; text-align: center; color: var(--faint);
  font-size: 13px; grid-column: 1 / -1;
}

/* ---------- modals ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(29, 32, 27, .55); z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal.hidden { display: none; }
.modal-card {
  background: #fff; border: 1px solid var(--line); border-top: 4px solid var(--amber);
  max-width: 560px; width: 100%; max-height: 84vh; overflow: auto; padding: 22px 24px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .25);
}
.modal-card.wide { max-width: 720px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; }
.hist-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 1px solid var(--line); padding: 10px 12px; margin-bottom: 8px;
}
.hist-row .mono { font-size: 11.5px; color: var(--muted); }
.send-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

/* ---------- price bank picker ---------- */
.bank-tools { display: flex; gap: 8px; margin-bottom: 12px; }
.bank-tools select { flex: 0 0 200px; }
.bank-list { border: 1px solid var(--line); max-height: 46vh; overflow: auto; }
.bank-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft); font-size: 13.5px;
}
.bank-row:last-child { border-bottom: none; }
.bank-row:hover { background: #fffdf7; }
.bank-name { font-weight: 600; flex: 1; }
.bank-trade { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.bank-price { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bank-unit { color: var(--muted); font-size: 12px; white-space: nowrap; }
.bank-empty { padding: 22px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- settings ---------- */
#logoPreview img { max-width: 180px; border: 1px solid var(--line); margin: 8px 0 14px; display: block; }

/* ---------- motion (restrained) ---------- */
@media (prefers-reduced-motion: no-preference) {
  .view-enter { animation: viewIn .28s ease-out; }
  @keyframes viewIn { from { opacity: 0; transform: translateY(10px); } }
}
.toast {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 80;
  background: var(--ink); color: #fff; font-size: 13.5px; font-weight: 600;
  padding: 11px 20px; display: flex; align-items: center; gap: 9px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
  animation: toastIn .25s ease-out;
}
.toast .tick {
  width: 18px; height: 18px; background: var(--amber); color: #fff; flex: none;
  display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -8px); } }
@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
}

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .editor { grid-template-columns: 1fr; }
  .preview-col { position: static; }
  .jobfile { grid-template-columns: 1fr; }
  .jobfile-rail { position: static; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); align-items: start; }
  .stat-strip { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(3) { border-left: none; }
  .stat { border-top: 1px solid var(--line-soft); }
  .stat:nth-child(-n+2) { border-top: none; }
  .cols-2 { grid-template-columns: 1fr; }
  .board { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; padding: 12px 14px; gap: 10px; flex-wrap: wrap; min-width: 0; }
  .brand-sub, .side-foot { display: none; }
  .nav { flex-direction: row; flex-wrap: wrap; gap: 2px; flex: 1 1 200px; min-width: 0; }
  .nav-item { width: auto; padding: 8px 10px; font-size: 13px; border-left: none; border-bottom: 3px solid transparent; }
  .nav-item.active { border-bottom-color: var(--amber); }
  .nav-item svg { display: none; }
  main { padding: 22px 16px 48px; min-width: 0; }
  .board { grid-template-columns: repeat(2, 1fr); }
  .doc { padding: 22px 18px; }
  .doc-parties { grid-template-columns: 1fr; }
  table.doc-totals { width: 100%; }
  .detail-head { flex-direction: column; }
  .detail-side { text-align: left; }
  .quotes-toolbar { flex-direction: column; align-items: stretch; }
  .search { max-width: none; }
  .jobfile-rail { grid-template-columns: 1fr; }
}

/* ---------- print: the document only ---------- */
@media print {
  .no-print, .sidebar, .page-head, .crumb-row, .detail-head, .jobfile-rail,
  .form-col, .panel-head, .quotes-toolbar, .list-summary, #followUpAlert { display: none !important; }
  body { background: #fff; }
  .app { display: block; }
  main { padding: 0; max-width: none; }
  .view.hidden { display: none !important; }
  .panel { border: none; box-shadow: none; padding: 0; margin: 0; }
  .doc { border: none; box-shadow: none; }
  .jobfile { display: block; }
  .editor { display: block; }
}
