/* BP Jobs — layout tuned for iPad (landscape and portrait) and Mac desktop; a phone layout comes later. */
:root {
  --bg: #eef1f5;
  --card: #ffffff;
  --ink: #18212b;
  --muted: #5d6b7a;
  --line: #d6dce4;
  --line-strong: #b9c2cd;
  --field: #f7f9fb;
  --field-focus: #ffffff;
  --head: #1f2a37;
  --head-ink: #e8edf3;
  --accent: #1f5fbf;
  --accent-soft: #e3edfb;
  --danger: #b42318;
  --ok: #1d7a46;
  --warn: #9a5b00;
  --s-proof: #c77700;
  --s-approved: #1f5fbf;
  --s-production: #6c3fc2;
  --s-printed: #0f7f86;
  --s-shipped: #1d7a46;
  --s-invoiced: #44546a;
  --s-paid: #b42318;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.35 var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; background: var(--head); color: var(--head-ink);
  display: flex; align-items: center; gap: 10px; padding: 8px 14px; padding-top: max(8px, env(safe-area-inset-top));
}
.brand { font-weight: 700; letter-spacing: .02em; white-space: nowrap; cursor: pointer; font-size: 16px; }
.brand small { font-weight: 500; opacity: .7; margin-left: 4px; }
.search { flex: 1; min-width: 160px; position: relative; }
.search input {
  width: 100%; height: 40px; border-radius: 9px; border: 1px solid #3a4757; background: #2a3646; color: #fff;
  padding: 0 12px 0 36px; outline: none;
}
.search input::placeholder { color: #9fb0c3; }
.search input:focus { background: #fff; color: var(--ink); border-color: #fff; }
.search svg { position: absolute; left: 11px; top: 11px; width: 18px; height: 18px; opacity: .7; pointer-events: none; }
.topbar .btn { height: 40px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 14px;
  border-radius: 9px; border: 1px solid var(--line-strong); background: #fff; color: var(--ink); cursor: pointer;
  font-weight: 600; font-size: 14px; white-space: nowrap; text-decoration: none; -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.dark { background: #2f3d4e; border-color: #3d4c5e; color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 13px; border-radius: 7px; }
.btn.danger { color: var(--danger); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn .count { background: rgba(0,0,0,.08); border-radius: 20px; padding: 1px 7px; font-size: 12px; }
.btn.dark .count { background: rgba(255,255,255,.16); }

.menu { position: relative; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); background: #fff; color: var(--ink); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(16,24,40,.25); min-width: 260px; padding: 6px; z-index: 40;
}
.menu-pop button {
  display: flex; justify-content: space-between; align-items: center; width: 100%; border: 0; background: none; padding: 11px 12px;
  border-radius: 8px; cursor: pointer; text-align: left; font-weight: 500;
}
.menu-pop button:hover { background: var(--accent-soft); }
.menu-pop .count { color: var(--muted); font-variant-numeric: tabular-nums; }
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: 4px 6px; }

/* ---------- sub bar (found set + actions) ---------- */
.subbar {
  position: sticky; top: 56px; z-index: 20; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 14px; background: rgba(238,241,245,.94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.subbar .found { color: var(--muted); font-size: 14px; margin-right: auto; display: flex; align-items: center; gap: 6px; }
.subbar .found b { color: var(--ink); }
.jump { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.jump a {
  text-decoration: none; color: var(--muted); font-weight: 600; font-size: 13px; padding: 6px 10px; border-radius: 7px; white-space: nowrap;
}
.jump a:hover { background: #fff; color: var(--ink); }
.save-state { font-size: 12px; color: var(--muted); min-width: 64px; text-align: right; }
.save-state.err { color: var(--danger); font-weight: 600; }

/* ---------- page ---------- */
.page { padding: 14px; max-width: 1500px; margin: 0 auto; padding-bottom: 80px; }
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; }
.span-12 { grid-column: span 12; } .span-8 { grid-column: span 8; } .span-7 { grid-column: span 7; }
.span-6 { grid-column: span 6; } .span-5 { grid-column: span 5; } .span-4 { grid-column: span 4; } .span-3 { grid-column: span 3; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; min-width: 0; }
.card > h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 10px;
  display: flex; align-items: center; gap: 8px;
}
.card > h2 .spacer { flex: 1; }
section.anchor { scroll-margin-top: 120px; }

/* ---------- job header ---------- */
.jobhead { display: grid; grid-template-columns: auto 1fr auto; gap: 18px; align-items: start; }
.docket { font: 700 34px/1 var(--font); letter-spacing: .01em; color: var(--accent); font-variant-numeric: tabular-nums; }
.docket-meta { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; font-size: 13px; }
.docket-meta .row { display: flex; gap: 6px; align-items: center; }
.chain { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.chain a { font-size: 13px; text-decoration: none; background: var(--accent-soft); padding: 3px 8px; border-radius: 6px; font-weight: 600; }
.what { display: grid; grid-template-columns: 120px 1fr; gap: 8px; }
.what .qty input { font-size: 20px; font-weight: 700; color: var(--danger); text-align: right; }
.what .desc textarea { font-size: 18px; font-weight: 700; color: var(--danger); min-height: 64px; }
.type-row { display: flex; gap: 8px; margin-top: 8px; }
.type-row .field { flex: 1; }

.statuses { display: grid; grid-template-columns: repeat(4, minmax(92px, 1fr)); gap: 6px; }
.pill {
  border: 1.5px solid var(--line-strong); background: #fff; color: var(--muted); border-radius: 9px; min-height: 40px;
  padding: 4px 8px; font-weight: 700; font-size: 13px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px;
  -webkit-tap-highlight-color: transparent; text-align: center; line-height: 1.1;
}
.pill .dot { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid currentColor; flex: none; }
.pill.on { color: #fff; border-color: transparent; }
.pill.on .dot { background: #fff; border-color: #fff; }
.pill.on[data-k=status_proof] { background: var(--s-proof); }
.pill.on[data-k=status_proof_approved] { background: var(--s-approved); }
.pill.on[data-k=status_production] { background: var(--s-production); }
.pill.on[data-k=status_printed] { background: var(--s-printed); }
.pill.on[data-k=status_shipped] { background: var(--s-shipped); }
.pill.on[data-k=status_invoiced] { background: var(--s-invoiced); }
.pill.on[data-k=status_prepaid] { background: #7a5a00; }
.pill.on[data-k=status_paid] { background: var(--s-paid); }
.pill small { font-weight: 600; opacity: .9; font-size: 11px; }

/* ---------- fields ---------- */
.fields { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 10px 12px; }
.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; grid-column: span 12; }
.field.w2 { grid-column: span 2; } .field.w3 { grid-column: span 3; } .field.w4 { grid-column: span 4; }
.field.w5 { grid-column: span 5; } .field.w6 { grid-column: span 6; } .field.w8 { grid-column: span 8; } .field.w9 { grid-column: span 9; }
.field > label, .field > .label { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .01em; }
.field input, .field select, .field textarea {
  width: 100%; min-height: 38px; border: 1px solid var(--line); background: var(--field); border-radius: 8px; padding: 7px 10px;
  outline: none; transition: border-color .12s, background .12s; -webkit-appearance: none; appearance: none;
}
.field select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 16px, calc(100% - 10px) 16px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 28px; }
.field textarea { resize: vertical; min-height: 70px; line-height: 1.4; }
.field textarea.tall { min-height: 140px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); background: var(--field-focus); box-shadow: 0 0 0 3px var(--accent-soft); }
.field input.money, .field input.num, .field .calc.money { text-align: right; font-variant-numeric: tabular-nums; }
.field input.saving { border-color: #e0b552; }
.field input.err, .field textarea.err { border-color: var(--danger); background: #fff5f4; }
.field .calc {
  min-height: 38px; display: flex; align-items: center; padding: 7px 10px; border-radius: 8px; background: #f0f3f7;
  font-weight: 600; font-variant-numeric: tabular-nums; border: 1px dashed var(--line);
}
.field .calc.money { justify-content: flex-end; }
.field .inline { display: flex; gap: 6px; align-items: center; }
.field .inline > input { flex: 1; }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.check {
  display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 8px; padding: 7px 11px;
  background: var(--field); cursor: pointer; min-height: 38px; font-weight: 500; -webkit-tap-highlight-color: transparent;
}
.field .check input, .check input { width: 20px; height: 20px; min-height: 0; margin: 0; padding: 0; accent-color: var(--accent); -webkit-appearance: checkbox; appearance: auto; border: 0; background: none; box-shadow: none; flex: none; }
.check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.subhead { grid-column: span 12; font-size: 12px; font-weight: 700; color: var(--ink); margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--line); text-transform: uppercase; letter-spacing: .06em; }
.subhead:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
.btnrow { grid-column: span 12; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.note { font-size: 12px; color: var(--muted); }
.note.warn { color: var(--warn); }
.soon { font-size: 12px; color: var(--muted); background: #f3f4f6; border: 1px dashed var(--line-strong); padding: 6px 10px; border-radius: 8px; }

/* customer block */
.addr { font-size: 15px; line-height: 1.45; }
.addr .co { font-weight: 700; }
.comments-log { white-space: pre-wrap; font-size: 14px; }

/* money summary */
.money-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.money-grid .field { grid-column: auto; }
.money-grid .big input { font-size: 18px; font-weight: 700; }

/* costing table */
.lines { width: 100%; border-collapse: separate; border-spacing: 0 6px; }
.lines th { font-size: 12px; color: var(--muted); text-align: left; font-weight: 600; padding: 0 4px; }
.lines td { padding: 0 4px; vertical-align: top; }
.lines td .field { grid-column: auto; }
.lines td.amt { width: 130px; }
.lines td.who { width: 30%; }
.total-row td { font-weight: 700; }

.estimates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.est { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: #fbfcfd; }
.est h3 { margin: 0 0 8px; font-size: 16px; color: var(--accent); display: flex; align-items: center; gap: 8px; }
.est h3 .spacer { flex: 1; }
.est .lines td.amt { width: 110px; }

/* ---------- list view ---------- */
.list-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.list-tabs .btn.active { background: var(--head); color: #fff; border-color: var(--head); }
.table-wrap { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto; }
table.jobs { width: 100%; border-collapse: collapse; font-size: 14px; }
table.jobs th { position: sticky; top: 0; background: #f6f8fa; text-align: left; font-size: 12px; color: var(--muted); padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.jobs td { padding: 10px; border-bottom: 1px solid #edf0f3; vertical-align: top; }
table.jobs tr { cursor: pointer; }
table.jobs tbody tr:hover { background: #f5f8fd; }
table.jobs .dk { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; white-space: nowrap; }
table.jobs .desc { max-width: 420px; }
table.jobs .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dots { display: flex; gap: 3px; }
.dots i { width: 10px; height: 10px; border-radius: 3px; background: #e3e7ec; display: block; }
.dots i.on.proof { background: var(--s-proof); } .dots i.on.appr { background: var(--s-approved); } .dots i.on.prod { background: var(--s-production); }
.dots i.on.prnt { background: var(--s-printed); } .dots i.on.ship { background: var(--s-shipped); } .dots i.on.inv { background: var(--s-invoiced); }
.dots i.on.paid { background: var(--s-paid); }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 5px; background: #eef1f5; color: var(--muted); }
.tag.ESTIMATE { background: #fff3d6; color: #8a5a00; } .tag.CANCELED { background: #fde7e5; color: var(--danger); } .tag.PENDING { background: #ecebff; color: #4b3fb3; }
.list-legend { display: flex; gap: 12px; font-size: 12px; color: var(--muted); margin: 8px 2px; flex-wrap: wrap; }
.list-legend span { display: inline-flex; gap: 4px; align-items: center; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(15, 23, 32, .45); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 40px 14px; overflow: auto; }
.modal { background: #fff; border-radius: 14px; width: min(860px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.wide { width: min(1100px, 100%); }
.modal header { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal header h2 { margin: 0; font-size: 18px; flex: 1; }
.modal .body { padding: 14px 16px; }
.modal footer { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.pick { display: flex; flex-direction: column; gap: 2px; max-height: 60vh; overflow: auto; margin-top: 10px; }
.pick button {
  text-align: left; border: 1px solid transparent; background: none; padding: 10px 12px; border-radius: 9px; cursor: pointer; display: grid;
  grid-template-columns: 1fr auto; gap: 2px 10px;
}
.pick button:hover { background: var(--accent-soft); border-color: #c9dbf5; }
.pick .t { font-weight: 700; } .pick .s { color: var(--muted); font-size: 13px; grid-column: 1; } .pick .r { color: var(--muted); font-size: 13px; text-align: right; grid-row: 1 / span 2; grid-column: 2; align-self: center; }
.pick h4 { margin: 10px 4px 4px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--head); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 60; box-shadow: 0 8px 24px rgba(0,0,0,.25); font-weight: 600; }
.toast.err { background: var(--danger); }

.subtable { width: 100%; border-collapse: collapse; }
.subtable td, .subtable th { padding: 4px; text-align: left; vertical-align: top; }
.subtable th { font-size: 12px; color: var(--muted); font-weight: 600; }
.subtable .field { grid-column: auto; }

/* ---------- login ---------- */
.login-page { display: flex; min-height: 100vh; align-items: center; justify-content: center; background: var(--head); }
.login-card { background: #fff; padding: 28px; border-radius: 16px; width: min(380px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-card h1 { margin: 0; font-size: 22px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.login-card input { height: 44px; border: 1px solid var(--line-strong); border-radius: 9px; padding: 0 12px; font-size: 16px; }
.login-card .btn { height: 44px; }
.form-error { color: var(--danger); font-weight: 600; margin: 0; }

/* ---------- responsive: iPad portrait and narrower ---------- */
@media (max-width: 1100px) {
  .span-5.cust, .span-4.notes { grid-column: span 6; }
  .span-3.pricing { grid-column: span 12; }
  .span-3.pricing .money-grid { grid-template-columns: repeat(4, 1fr); }
  .jobhead { grid-template-columns: auto 1fr; }
  .jobhead .statuses { grid-column: span 2; grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .topbar .hide-md { display: none; }
}
@media (max-width: 900px) {
  .span-7, .span-6, .span-5, .span-4, .span-8 { grid-column: span 12; }
  .span-5.cust, .span-4.notes { grid-column: span 12; }
  .jobhead .statuses { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .estimates { grid-template-columns: 1fr; }
  table.jobs .hide-sm { display: none; }
}
@media (max-width: 640px) {
  .jobhead { grid-template-columns: 1fr; }
  .jobhead .statuses { grid-column: auto; }
  .what { grid-template-columns: 1fr; }
  .span-3.pricing .money-grid { grid-template-columns: 1fr 1fr; }
  .field.w2, .field.w3, .field.w4 { grid-column: span 6; }
  .field.w5, .field.w6, .field.w8, .field.w9 { grid-column: span 12; }
  .topbar { flex-wrap: wrap; }
  .search { order: 5; flex-basis: 100%; }
  .subbar { top: 104px; }
}
