:root {
  --bg: #f4f1ea;
  --card: #ffffff;
  --ink: #1f2933;
  --muted: #5b6670;
  --line: #d7d0c4;
  --accent: #0f6e56;
  --accent-soft: #e4f3ee;
  --warn: #9a3412;
  --warn-soft: #ffedd5;
  --prio1: #b91c1c;
  --prio2: #c2410c;
  --prio3: #64748b;
  --shadow: 0 1px 2px rgba(31, 41, 51, 0.06), 0 8px 24px rgba(31, 41, 51, 0.06);
  --radius: 12px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, #efe7d6 0, transparent 40%),
    linear-gradient(180deg, #f7f4ee 0%, var(--bg) 100%);
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 20px 20px 48px; }

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}
.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.92rem;
  text-decoration: none;
}
.nav a.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.nav .count {
  display: inline-block;
  min-width: 1.4em;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(0,0,0,0.08);
  font-size: 0.8rem;
  text-align: center;
}
.nav a.active .count { background: rgba(255,255,255,0.22); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: #fbfaf7;
  align-items: end;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
}
.field.grow { flex: 1 1 220px; }
.field label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
input[type="search"],
input[type="text"],
select,
textarea {
  font: inherit;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  min-height: 38px;
}
textarea { min-height: 110px; resize: vertical; width: 100%; }
.btn {
  font: inherit;
  font-weight: 700;
  border: 0;
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  min-height: 38px;
}
.btn.secondary {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn:hover { filter: brightness(0.97); }
.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  color: var(--muted);
  font-size: 0.9rem;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

/* Scrollable tables: native desktop bars plus two-axis touch panning. */
.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
}
.table-scroll {
  /* Keep long tables usable without making the whole page excessively tall. */
  max-height: min(70vh, 720px);
  scrollbar-gutter: stable;
  scrollbar-width: auto;
  scrollbar-color: #8a969f #eef1f3;
}
.table-scroll::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}
.table-scroll::-webkit-scrollbar-track { background: #eef1f3; }
.table-scroll::-webkit-scrollbar-thumb {
  background: #8a969f;
  border: 2px solid #eef1f3;
  border-radius: 999px;
}
.table-scroll::-webkit-scrollbar-thumb:hover { background: #65727b; }
table.jobs {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
table.jobs th,
table.jobs td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
table.jobs th {
  background: #f7f3eb;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  position: sticky;
  top: 0;
  z-index: 1;
}
table.jobs tbody tr { cursor: pointer; transition: background 0.12s ease; }
table.jobs tbody tr:hover { background: var(--accent-soft); }
table.jobs td.folder { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
table.jobs td.client { min-width: 220px; font-weight: 600; }
table.jobs td.muted, .muted { color: var(--muted); }
.empty {
  padding: 36px 20px;
  text-align: center;
  color: var(--muted);
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: #eef2f6;
  color: #334155;
  white-space: nowrap;
}
.badge.prio1 { background: #fee2e2; color: var(--prio1); }
.badge.prio2 { background: #ffedd5; color: var(--prio2); }
.badge.prio3 { background: #e2e8f0; color: var(--prio3); }
.badge.status { background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }

.profile-head {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  align-items: start;
}
.profile-head h2 {
  margin: 0 0 6px;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}
.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  padding: 16px;
}
.panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfaf7;
  padding: 14px;
}
.panel h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
}
.kv {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 6px 10px;
  font-size: 0.92rem;
}
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; word-break: break-word; }
.note-block {
  white-space: pre-wrap;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.92rem;
  line-height: 1.45;
  margin: 0 0 10px;
}
.note-block:last-child { margin-bottom: 0; }
.case-list { list-style: none; margin: 0; padding: 0; }
.case-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 0.92rem;
}
.case-list li:last-child { border-bottom: 0; }
.edit-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: end;
}
.flash {
  margin: 0 16px 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.back-link { font-weight: 600; }
.footer-note {
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.82rem;
}
@media (max-width: 720px) {
  .edit-form { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
}

/* Notes column on Current Work */
table.jobs td.notes-cell {
  min-width: 200px;
  max-width: 280px;
  position: relative;
}
.note-preview {
  position: relative;
  display: block;
}
.note-preview-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--ink);
  font-weight: 500;
  font-size: 0.88rem;
  line-height: 1.35;
}
.note-popover {
  display: none;
  position: absolute;
  z-index: 20;
  left: 0;
  top: calc(100% + 6px);
  width: min(420px, 70vw);
  max-height: 320px;
  overflow-y: auto;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  white-space: pre-wrap;
  cursor: default;
}
.note-preview:hover .note-popover,
.note-preview:focus-within .note-popover {
  display: block;
}
.note-popover-item + .note-popover-item {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}
.note-popover-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.78rem;
  margin-bottom: 4px;
}
.note-popover-body {
  font-size: 0.86rem;
  line-height: 1.4;
  color: var(--ink);
  white-space: pre-wrap;
}

.edit-form-wide {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.edit-form-wide .form-actions {
  min-width: 120px;
}
.placeholder-note {
  margin: 12px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f3f4f6;
  color: var(--muted);
  font-size: 0.85rem;
  font-style: italic;
}

/* Stage 4 — Act as + permissions */
.act-as-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 14px;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.act-as-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.act-as-form label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.act-as-form select {
  min-width: 200px;
}
.act-as-current {
  color: var(--muted);
  font-size: 0.9rem;
}
.act-as-current strong { color: var(--ink); }

.flash-error {
  background: #fee2e2;
  color: var(--prio1);
}

.perm-section {
  padding: 16px 20px 8px;
  border-top: 1px solid var(--line);
}
.perm-section h3 {
  margin: 0 0 6px;
  font-size: 1.05rem;
}
.perm-actions {
  padding: 12px 0 16px;
}
.perm-table tbody tr.no-click,
table.jobs tbody tr.no-click {
  cursor: default;
}
table.jobs tbody tr.no-click:hover {
  background: transparent;
}
.check-cell {
  white-space: nowrap;
  vertical-align: middle !important;
}
.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}
.check input {
  width: 16px;
  height: 16px;
}
.locked-note {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f3f4f6;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}
input.locked,
select:disabled {
  background: #f3f4f6;
  color: var(--muted);
  cursor: not-allowed;
}

/* Stage 5 — login + session + per-person */
.login-wrap {
  max-width: 440px;
  padding-top: 64px;
}
.login-card {
  padding: 28px 24px 20px;
}
.login-head h1 {
  margin: 0 0 6px;
  font-size: 1.35rem;
}
.login-head p {
  margin: 0 0 18px;
  color: var(--muted);
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
  font-size: 0.9rem;
}
.login-form input[type="text"],
.login-form input[type="password"] {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}
.login-hint {
  margin: 16px 0 0;
  font-size: 0.82rem;
  line-height: 1.4;
}
.login-hint code {
  background: #f3f4f6;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.8rem;
}

.session-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 10px;
  padding: 8px 14px;
  background: var(--accent-soft);
  border: 1px solid #b7d9cc;
  border-radius: var(--radius);
}
.session-who {
  font-size: 0.92rem;
  color: var(--muted);
}
.session-who strong { color: var(--ink); }
.acting-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 0.78rem;
  font-weight: 700;
}
.logout-form { margin: 0; }

.add-person-box {
  margin: 8px 0 16px;
  padding: 14px;
  background: #f8faf9;
  border: 1px dashed var(--line);
  border-radius: 10px;
}
.add-person-box h4 {
  margin: 0 0 6px;
  font-size: 0.98rem;
}
.add-person-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}
.add-person-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}
.add-person-form input,
.add-person-form select {
  min-width: 140px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  color: var(--ink);
}
.person-pick-form {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.person-pick-form label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.person-pick-form select { min-width: 220px; }
.person-source {
  margin: 0 0 10px;
  font-size: 0.9rem;
  color: var(--muted);
}
.perm-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.btn.secondary {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn.secondary:hover {
  background: #f8faf9;
  text-decoration: none;
}


/* Stage 6+ — Maps / councils */
a.maps-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  pointer-events: auto;
}
a.maps-link:hover { color: #1d4ed8; }
.flash-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
  padding: 0.6rem 0.85rem;
  border-radius: 8px;
}
table.jobs td.addr-cell { max-width: 200px; font-size: 0.9rem; }
textarea {
  width: 100%;
  min-height: 4rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}
textarea.locked { background: #f1f5f9; color: var(--muted); }


/* Column header icons — colourful, architect-friendly */
table.jobs thead th {
  white-space: nowrap;
}
.col-ico {
  display: inline-block;
  font-size: 1.05rem;
  margin-right: 0.2rem;
  vertical-align: -0.1em;
  filter: saturate(1.25);
}
.ico-contact { filter: saturate(1.4) hue-rotate(-10deg); }
.ico-house { filter: saturate(1.3) hue-rotate(20deg); }
.ico-sg { filter: saturate(1.5) hue-rotate(80deg); }
.ico-draftsman { filter: saturate(1.35) hue-rotate(200deg); }
.ico-folder { filter: saturate(1.2) hue-rotate(35deg); }
.ico-council { filter: saturate(1.2); }
.ico-status { filter: saturate(1.4) hue-rotate(300deg); }
.ico-priority { filter: saturate(1.5); }
.ico-eov { filter: saturate(1.2) hue-rotate(160deg); }
.ico-notes { filter: saturate(1.3) hue-rotate(50deg); }
.ico-cases { filter: saturate(1.2) hue-rotate(240deg); }


/* Stage 7 — Quotes */
.badge.quote-draft { background: #e2e8f0; color: #334155; }
.badge.quote-sent { background: #dbeafe; color: #1e40af; }
.badge.quote-accepted { background: var(--accent-soft); color: var(--accent); }
.badge.quote-declined { background: #fee2e2; color: #991b1b; }
.badge.quote-revised { background: #fef3c7; color: #92400e; }
.badge.quote-open-ind { margin-left: 0.35rem; font-size: 0.7rem; vertical-align: middle; }
.check-inline { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.9rem; color: var(--muted); padding-top: 1.4rem; }

.allocation-board { padding: 0.5rem 1rem 1.25rem; display: grid; gap: 1rem; }
.alloc-group {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  background: #fafaf8;
}
.alloc-group h3 {
  margin: 0 0 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.05rem;
}
.alloc-group .count {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 0 0.55rem;
  font-size: 0.85rem;
}


/* Stage 8 — Invoices + line items */
.badge.inv-draft { background: #e2e8f0; color: #334155; }
.badge.inv-sent { background: #dbeafe; color: #1e40af; }
.badge.inv-paid { background: #dcfce7; color: #166534; }
.badge.inv-cancelled { background: #fee2e2; color: #991b1b; }
.profile-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: flex-start; }
table.line-items input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.35rem 0.45rem;
  font: inherit;
  background: #fff;
}
table.line-items td { vertical-align: middle; }
table.line-items tbody tr { cursor: default; }
.plain-list { margin: 0; padding-left: 1.1rem; }
.plain-list li { margin: 0.35rem 0; }
.flash-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  margin: 0.5rem 0 1rem;
}

/* New job — core fields + optional details */
.core-fields h3 { margin-top: 0; }
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.optional-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: #fafaf8;
}
.optional-panel > summary {
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--ink);
  list-style: none;
}
.optional-panel > summary::-webkit-details-marker { display: none; }
.optional-panel > summary::before {
  content: "▸ ";
  color: var(--accent);
  font-weight: 700;
}
.optional-panel[open] > summary::before { content: "▾ "; }


/* Stage 4 add-on — account + recovery */
.session-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.login-links {
  margin: 14px 0 0;
  font-size: 0.9rem;
}
.login-links a { font-weight: 600; }
.account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 12px;
}
.account-panel {
  padding: 14px;
  background: #f8faf9;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.account-panel h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}
.account-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.account-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
  font-size: 0.9rem;
}
.account-form input[type="text"],
.account-form input[type="email"],
.account-form input[type="password"] {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}
.account-dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  font-size: 0.92rem;
}
.account-dl dt {
  color: var(--muted);
  font-weight: 600;
}
.account-dl dd { margin: 0; }
.recovery-result { margin-top: 4px; }
.recovery-steps {
  margin: 10px 0 0;
  padding-left: 1.2rem;
  line-height: 1.45;
  font-size: 0.92rem;
}
.recovery-steps li { margin: 0 0 8px; }
.reset-link-box {
  margin-top: 8px;
  padding: 10px 12px;
  background: #f3f4f6;
  border-radius: 8px;
  word-break: break-all;
  font-size: 0.88rem;
}

/* Current Work: stacked header sort + last-movement age. */
table.jobs th.sortable { padding: 0; }
table.jobs th .sort-link {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: inherit;
  text-decoration: none;
}
table.jobs th .sort-link:hover {
  text-decoration: none;
  background: rgba(31, 41, 51, 0.05);
}
table.jobs .sort-mark {
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
}
table.jobs td.move-cell { white-space: nowrap; font-variant-numeric: tabular-nums; }
table.jobs td.move-green,
.age-swatch.move-green { background: #15803d; color: #fff; }
table.jobs td.move-orange,
.age-swatch.move-orange { background: #ea580c; color: #fff; }
table.jobs td.move-red,
.age-swatch.move-red { background: #dc2626; color: #fff; }
table.jobs td.move-black,
.age-swatch.move-black { background: #000; color: #fff; }
.age-legend { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.age-swatch {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

/* Quotation workbook (read-only copy of the sheet layout). Scrolls on touch. */
.doc-scroll {
  max-width: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
  max-height: min(78vh, 920px);
}
.ao-doc {
  font-family: Arial, Helvetica, sans-serif;
  color: #222;
  background: #fff;
  min-width: 920px;
  padding: 12px 18px 20px;
}
.ao-doc-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; }
.ao-doc-titleblock { text-align: center; }
.ao-doc-title { margin: 0; font-size: 36px; font-weight: 700; text-align: center; letter-spacing: 0.5px; }
.ao-doc-sub { color: #828282; font-size: 15px; text-align: center; min-height: 1.2em; }
.ao-co { text-align: right; font-size: 12px; line-height: 1.45; justify-self: end; }
.ao-logo { display: block; height: 92px; width: auto; margin: 0; justify-self: start; }
.ao-sacap { text-align: right; font-size: 11px; margin-top: 8px; }
.ao-rule { border-top: 3px solid #BEBEBE; margin: 8px 0 12px; }
.ao-bill-grid { display: grid; grid-template-columns: 1.3fr 0.9fr; gap: 18px; }
.ao-bill-label { font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.ao-mini { display: block; font-size: 11px; color: #666; margin-bottom: 2px; }
.ao-kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px; align-items: center; margin: 4px 0; font-size: 12px; }
.ao-kv input, .ao-doc select, .ao-doc textarea { font-family: Arial, Helvetica, sans-serif; font-size: 12px; width: 100%; }
.ao-meta .ao-kv span { font-weight: 700; text-align: right; }
.ao-grand input, .ao-grand { background: #F4F5F5; }
.ao-bar {
  background: #6A9C76;
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  padding: 8px 10px;
  margin: 12px 0 0;
}
.ao-bar.right { text-align: right; }
.ao-bar.tight { margin: 0; }
.ao-scope {
  background: transparent;
  color: #fff;
  border: 0;
  border-bottom: 1px solid rgba(255,255,255,0.5);
  font-weight: 700;
  width: calc(100% - 130px);
}
.ao-lines { width: 100%; border-collapse: collapse; margin-top: 0; }
.ao-lines th { background: #6A9C76; color: #fff; font-size: 12px; padding: 8px; }
.ao-lines th.svc, .ao-lines td:first-child { text-align: left; }
.ao-lines td { padding: 6px; border-bottom: 1px solid #eee; color: #666; font-weight: 700; }
.ao-lines td:first-child { font-weight: 400; color: #222; }
.ao-lines input { border: 0; background: transparent; color: #666; font-weight: 700; }
.ao-lines td:first-child input { color: #222; font-weight: 400; }
.ao-bank-grid { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 12px; margin-top: 8px; }
.ao-bank div { background: #F3F3F3; padding: 4px 8px; font-size: 12px; }
.ao-bank .ao-bar { background: #6A9C76; color: #fff; }
.ao-tot-row { display: grid; grid-template-columns: 1fr 140px; gap: 8px; align-items: center; font-size: 12px; font-weight: 700; padding: 4px 0; }
.ao-tot-row.shade input { background: #EFEFEF; }
.ao-tot-row select { width: 100%; font: inherit; font-size: 12px; font-weight: 700; }
.ao-notes { width: 100%; min-height: 140px; font-size: 10px; line-height: 1.35; border: 1px solid #e5e5e5; padding: 8px; }
.ao-accept { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 24px; padding: 12px 4px; font-size: 12px; }
.ao-line { letter-spacing: 1px; }
.ao-sign-note { color: #888; font-size: 11px; margin: 0; }
.ao-foot { text-align: center; color: #B7B7B7; font-weight: 700; margin-top: 16px; }
.ao-optional { margin-top: 12px; }
.qc-row { display: contents; }
.quotes-group { margin: 0 0 10px; background: #fff; border-bottom: 1px solid var(--line); }
.quotes-group > summary {
  cursor: pointer;
  padding: 10px 14px;
  font-weight: 650;
  list-style: none;
}
.quotes-group > summary::-webkit-details-marker { display: none; }
.quotes-group > summary::before { content: "▸ "; color: var(--muted); }
.quotes-group[open] > summary::before { content: "▾ "; }
.quotes-group .count {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 0 8px;
  font-size: 0.85rem;
  margin-left: 6px;
}
.quotes-group-body .empty { padding: 12px 14px; }

/* Current Work: table zoom (pinch / Ctrl+wheel / buttons). See static/work_zoom.js. */
.zoom-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  padding: 8px 14px;
}
.zoom-bar[hidden] { display: none; }
.zoom-bar .zoom-label { font-size: 0.82rem; font-weight: 650; color: var(--muted); }
.zoom-bar .btn { padding: 0.25rem 0.7rem; min-height: 36px; line-height: 1; }
.zoom-bar .zoom-btn { min-width: 40px; font-size: 1.15rem; font-weight: 700; }
.zoom-bar .btn:disabled { opacity: 0.45; cursor: default; }
.zoom-bar .zoom-pct {
  min-width: 3.6em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.zoom-bar .zoom-hint { font-size: 0.78rem; }
.current-work-table-wrap.zoom-ready { position: relative; }
/* iOS Safari must not autosize text in this wide table (cells would stop
   following the zoom). */
.current-work-table-wrap { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* Narrower job-name column on Current Work: names wrap instead of stretching
   the column to the longest name (was ~710px wide at 100%). */
.current-work-table-wrap table.jobs td.client {
  width: 15em;
  min-width: 0;
  max-width: 15em;
  white-space: normal;
  overflow-wrap: anywhere;
}
.current-work-table-wrap .zoom-stage { width: 100%; }
.current-work-table-wrap .zoom-spacer {
  position: absolute; left: 0; top: 0; width: 1px; height: 1px;
  visibility: hidden; pointer-events: none;
}
/* At very large zooms the header row would cover most of the visible table;
   it then scrolls with the rows instead of staying pinned (still aligned). */
.current-work-table-wrap.zoom-unpin-head table.jobs th { position: static; }

/* ---- /quotes archive / multi-select ---- */
.view-tabs { display: flex; gap: 4px; margin: 0 0 0.75rem; border-bottom: 1px solid var(--line); }
.view-tabs a { padding: 8px 14px; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; font-weight: 600; }
.view-tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
.view-tabs .tab-count { display: inline-block; min-width: 1.6em; padding: 0 6px; border-radius: 999px; background: #eee9df; color: var(--muted); font-size: 0.8em; text-align: center; }
.view-tabs a.active .tab-count { background: var(--accent-soft); color: var(--accent); }
.badge.archived { background: #e5e7eb; color: #374151; }
.section-label.archived-label { margin: 1.25rem 0 0.5rem; font-size: 1rem; }
.quotes-table tr.is-archived td { color: #4b5563; }
.quotes-table .sel-cell { display: none; width: 44px; text-align: center; padding-left: 8px; padding-right: 4px; }
.quotes-selecting .quotes-table .sel-cell { display: table-cell; }
.quotes-table .sel-cell input { width: 22px; height: 22px; accent-color: var(--accent); pointer-events: none; }
.quotes-table tr.quote-row { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.quotes-selecting .quotes-table tr.quote-row { cursor: pointer; }
.quotes-table tr.quote-row.is-selected td { background: var(--accent-soft); }
.select-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -6px 20px rgba(31,41,51,0.12); }
.select-bar[hidden] { display: none; }
.select-bar .select-count { font-weight: 700; }
.select-bar .select-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.select-bar .btn { padding: 8px 12px; }
.select-bar .btn[hidden] { display: none; }
.select-bar .btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.danger { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.quotes-selecting main, .quotes-selecting .container { padding-bottom: 90px; }
.archived-banner { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.archived-banner form { margin: 0; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; }

/* ---- /work tools: find-in-page + column state + zoom (sticky) ---- */
.work-tools { position: sticky; top: 0; z-index: 20; background: var(--card); margin: 0 -2px; padding: 4px 2px 2px; }
.find-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 14px 2px; }
.find-bar[hidden] { display: none; }
.find-bar .find-field { flex: 1 1 180px; display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 8px; padding: 0 8px; background: #fff; min-height: 38px; }
.find-bar .find-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.find-bar input[type=search] { flex: 1; border: 0; outline: 0; font: inherit; font-size: 16px; padding: 6px 0; background: transparent; min-width: 0; }
.find-bar .find-count { min-width: 5.5em; font-size: 0.85rem; font-weight: 650; color: var(--muted); font-variant-numeric: tabular-nums; }
.find-bar.no-hits .find-count { color: var(--warn); }
.find-bar .find-btn { min-width: 38px; padding: 0.25rem 0.55rem; min-height: 36px; line-height: 1; }
.find-bar .find-btn[hidden] { display: none; }
.find-bar .find-btn:disabled { opacity: 0.45; cursor: default; }
.find-bar .find-scope { flex-basis: 100%; font-size: 0.75rem; }
mark.ff-hit { background: #fde68a; color: inherit; padding: 0; border-radius: 2px; }
mark.ff-hit.ff-current { background: #f97316; color: #fff; outline: 2px solid #c2410c; outline-offset: 1px; }
.col-tools { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; padding: 2px 14px; font-size: 0.82rem; }
.col-tools[hidden] { display: none; }
.col-tools .link-btn[hidden] { display: none; }

/* ---- column headers: menu, indicators, drag ---- */
table.jobs th.col-head { cursor: pointer; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
table.jobs th .col-ind { position: absolute; right: 3px; top: 3px; display: inline-flex; gap: 2px; align-items: center; color: var(--accent); font-size: 0.7rem; pointer-events: none; }
table.jobs th.has-sort, table.jobs th.has-filter { color: var(--accent); background: #e9f4ef; }
table.jobs .col-dragging { background: #fff7d6 !important; box-shadow: inset 2px 0 0 #f59e0b, inset -2px 0 0 #f59e0b; }
table.jobs th.col-dragging { color: #92400e; }
.col-drag-active { cursor: grabbing; }
.col-drag-active table.jobs { -webkit-user-select: none; user-select: none; }
.col-menu { position: fixed; z-index: 80; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(31,41,51,0.18); padding: 6px; overflow: auto; font-size: 15px; -webkit-text-size-adjust: 100%; }
.col-menu .cm-head { font-weight: 700; padding: 6px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.col-menu .cm-item { display: block; width: 100%; text-align: left; background: none; border: 0; font: inherit; padding: 9px 8px; border-radius: 6px; color: var(--ink); cursor: pointer; text-decoration: none; }
.col-menu .cm-item:hover { background: var(--accent-soft); }
.col-menu .cm-filter { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 4px 0; padding: 6px 8px; }
.col-menu .cm-sub { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 4px; }
.col-menu .cm-list { max-height: 210px; overflow: auto; }
.col-menu .cm-check { display: flex; align-items: center; gap: 6px; padding: 5px 0; }
.col-menu .cm-check input { width: 20px; height: 20px; accent-color: var(--accent); }
.col-menu .cm-text { width: 100%; font: inherit; font-size: 16px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 6px; }
.col-menu .cm-row { display: flex; gap: 8px; align-items: center; padding: 4px 0; }
.col-menu .cm-move { padding: 6px 8px; }
.col-menu .cm-move .btn { flex: 1; padding: 6px 8px; min-height: 36px; }
.col-menu .cm-move .btn:disabled { opacity: 0.4; }

/* ---- /work inline editing ---- */
.current-work-table-wrap table.jobs tbody tr { cursor: default; }
.current-work-table-wrap td[data-nav] { cursor: pointer; }
.current-work-table-wrap td.client a.job-link { color: inherit; text-decoration: none; font-weight: 650; }
.current-work-table-wrap td.client a.job-link:hover { text-decoration: underline; }
.current-work-table-wrap td[data-edit] { cursor: text; position: relative; }
.current-work-table-wrap td[data-edit]:hover { box-shadow: inset 0 0 0 1px #9cc9b9; }
.current-work-table-wrap td.is-editing { box-shadow: inset 0 0 0 2px var(--accent); background: var(--accent-soft); }
.current-work-table-wrap td.cell-saving { opacity: 0.6; }
.current-work-table-wrap td.cell-saved { animation: cellSaved 1.6s ease; }
.current-work-table-wrap td.cell-saved::after { content: "✓"; position: absolute; right: 4px; top: 4px; color: #fff; background: var(--accent); border-radius: 999px; font-size: 11px; line-height: 16px; width: 16px; text-align: center; font-weight: 700; }
.current-work-table-wrap td.cell-error { box-shadow: inset 0 0 0 2px #b91c1c; background: #fee2e2; }
@keyframes cellSaved { 0% { background: #bbf7d0; } 100% { background: transparent; } }
.current-work-table-wrap .maps-pin { text-decoration: none; }
.inline-editor { position: fixed; z-index: 85; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(31,41,51,0.2); padding: 10px; font-size: 16px; -webkit-text-size-adjust: 100%; }
.inline-editor .ie-head { font-size: 0.8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; }
.inline-editor .ie-control { width: 100%; font: inherit; font-size: 16px; padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); min-height: 40px; }
.inline-editor textarea.ie-control { resize: vertical; }
.inline-editor .ie-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.inline-editor .ie-actions .btn { padding: 6px 12px; min-height: 36px; }
.inline-toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 90; background: #0f6e56; color: #fff; padding: 8px 16px; border-radius: 999px; font-weight: 700; box-shadow: 0 6px 18px rgba(0,0,0,0.2); transition: opacity 0.5s; max-width: calc(100vw - 32px); }
.inline-toast.is-error { background: #b91c1c; border-radius: 10px; }
.inline-toast.bye { opacity: 0; }
@media (max-width: 640px) {
  .work-tools .zoom-hint, .work-tools .zoom-label { display: none; }
  .work-tools .zoom-bar { padding-top: 4px; padding-bottom: 4px; }
  .find-bar .find-scope { font-size: 0.7rem; }
}

/* ---- /work column widths (work_columns.js) ----
   Each column is sized to its content (longest value + header label); long
   text columns get a maximum width and wrap onto at most 2 lines with "…".
   Widths are set on the header cells with table-layout: fixed, so the sticky
   header always lines up and CSS zoom scales the widths with the table. */
.current-work-table-wrap td > .cc { overflow-wrap: anywhere; }
.current-work-table-wrap .cc .badge { white-space: normal; }
.current-work-table-wrap.cw-sized table.jobs { table-layout: fixed; min-width: 0; }
.current-work-table-wrap.cw-sized table.jobs th,
.current-work-table-wrap.cw-sized table.jobs td { box-sizing: border-box; min-width: 0; max-width: none; }
.current-work-table-wrap.cw-sized table.jobs td { width: auto; white-space: normal; }
/* header labels may wrap onto 2 lines (at spaces) so short-value columns stay narrow */
.current-work-table-wrap.cw-sized table.jobs th { white-space: normal; overflow: hidden; overflow-wrap: normal; word-break: normal; line-height: 1.35; }
.current-work-table-wrap.cw-sized table.jobs th .sort-link { display: block; overflow: hidden; padding-left: 9px; padding-right: 9px; }
/* slightly tighter side padding so narrow columns stay narrow (PAD in work_columns.js) */
.current-work-table-wrap.cw-sized table.jobs th:not(.sortable),
.current-work-table-wrap.cw-sized table.jobs td { padding-left: 9px; padding-right: 9px; }
.current-work-table-wrap.cw-sized td > .cc {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
  overflow: hidden; overflow-wrap: anywhere; word-break: normal;
}
.current-work-table-wrap.cw-sized .cc .badge { display: inline; -webkit-box-decoration-break: clone; box-decoration-break: clone; line-height: 1.6; }
.current-work-table-wrap.cw-sized td.notes-cell .note-preview-text { overflow-wrap: anywhere; }
/* the current find match is never hidden by the 2-line clamp */
.current-work-table-wrap.cw-sized td > .cc:has(mark.ff-current),
.current-work-table-wrap.cw-sized .note-preview-text:has(mark.ff-current) { -webkit-line-clamp: unset; line-clamp: none; display: block; }
/* measuring pass: natural one-line width of every cell */
.current-work-table-wrap table.jobs.cw-measure { table-layout: auto !important; width: max-content !important; min-width: 0 !important; }
.current-work-table-wrap table.jobs.cw-measure th,
.current-work-table-wrap table.jobs.cw-measure td { width: auto !important; min-width: 0 !important; max-width: none !important; white-space: nowrap !important; }
.current-work-table-wrap table.jobs.cw-measure td > .cc,
.current-work-table-wrap table.jobs.cw-measure .note-preview-text { display: block !important; -webkit-line-clamp: unset !important; overflow: visible !important; white-space: nowrap !important; }
.current-work-table-wrap table.jobs.cw-measure .cc .badge { display: inline-block !important; white-space: nowrap !important; }
.current-work-table-wrap table.jobs.cw-measure.cw-measure-all tbody tr[hidden] { display: table-row !important; }
.current-work-table-wrap table.jobs.cw-measure.cw-measure-head tbody { display: none !important; }
.current-work-table-wrap table.jobs.cw-measure.cw-measure-body thead { display: none !important; }
.current-work-table-wrap table.jobs.cw-measure.cw-measure-wrap { width: 1px !important; }
.current-work-table-wrap table.jobs.cw-measure.cw-measure-wrap th { white-space: normal !important; }
.current-work-table-wrap table.jobs.cw-measure .col-resize { display: none !important; }
/* resize handle on the right edge of each header (mouse drag / touch drag) */
.current-work-table-wrap.zoom-unpin-head table.jobs th { position: relative; }
table.jobs th .col-resize {
  position: absolute; top: 0; bottom: 0; right: 0; width: 14px; z-index: 3;
  cursor: col-resize; touch-action: none; -webkit-user-select: none; user-select: none;
}
table.jobs th .col-resize::after {
  content: ""; position: absolute; top: 22%; bottom: 22%; right: 3px; width: 3px; border-radius: 2px;
  background: #c9c1b1; opacity: 0.75;
}
table.jobs th .col-resize:hover::after, table.jobs th.col-resizing .col-resize::after { background: var(--accent); opacity: 1; }
table.jobs th.col-resizing { background: #e9f4ef; }
.col-resize-active, .col-resize-active * { cursor: col-resize !important; -webkit-user-select: none !important; user-select: none !important; }
.current-work-table-wrap.cw-sized table.jobs th .col-ind { right: 14px; }
.col-menu .cm-width { flex-wrap: wrap; }
.col-menu .cm-width .cm-wlabel { flex-basis: 100%; font-size: 0.75rem; color: var(--muted); }
@media (hover: hover) and (pointer: fine) { table.jobs th .col-resize::after { opacity: 0.35; } }
/* /quotes: quote numbering panel + hint under the quotation number */
.quote-numbering { margin: 0 0 0.75rem; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fbf9f4; }
.quote-numbering summary { cursor: pointer; font-weight: 600; }
.quote-numbering form { align-items: center; gap: 8px; flex-wrap: wrap; }
.ao-qn-hint small { font-size: 0.72rem; line-height: 1.3; }
/* quote "sent to client" record (internal; never on the quotation PDF) */
.badge.quote-sent { background: #e0f2fe; color: #075985; }
.quote-sent-box { margin-top: 0.5rem; }
.quote-sent-box summary { cursor: pointer; }
.quote-sent-form { align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 0.4rem; }
.quote-sent-form input[type=date], .quote-sent-form input[type=time] { font: inherit; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; }
