:root {
  --brand: #1a3a5c;
  --brand-dark: #122948;
  --bg: #f5f6f8;
  --card: #fff;
  --border: #d8dde2;
  --border-hover: #b8c0c8;
  --text: #1a1a1a;
  --muted: #666;
  --error: #b91c1c;
  --error-bg: #fef2f2;
  --success: #166534;
  --success-bg: #f0fdf4;
  --info: #1e40af;
  --info-bg: #eff6ff;
  /* Customer type badges */
  --tag-direct: #1d4ed8;
  --tag-direct-bg: #dbeafe;
  --tag-trade: #b45309;
  --tag-trade-bg: #fef3c7;
  --tag-contract: #166534;
  --tag-contract-bg: #dcfce7;
}
* { box-sizing: border-box; }
body {
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  line-height: 1.5;
}

/* --- Header --- */
.site-header {
  background: var(--brand);
  color: #fff;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
}
.brand { font-size: 15px; display: flex; align-items: center; }
.brand-logo {
  height: 32px;
  width: auto;
  display: block;
  /* Subtle white plate behind the logo so the brand-blue HUTTON text
     reads against the dark navy header band without altering the
     transparent-bg artwork. */
  background: #fff;
  padding: 4px 10px;
  border-radius: 4px;
}
/* Phase 4 v1 item 5 (2026-05-17): primary-nav is a responsive
   CSS grid. auto-fit + minmax(120px, 1fr) gives equal-width
   columns that re-flow into rows as the viewport narrows.
   nav-links sit centered in their grid cells so wrapped rows
   line up vertically into clean columns (vs. flex which let
   each row drift to its own widths). min-width:0 lets the
   flex item (this is still a flex item inside .site-header)
   shrink below its intrinsic content width so the grid wrap
   actually triggers. Wide viewports show a single row of
   equal cells; narrow viewports wrap into 2-4 rows. */
.primary-nav {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px 16px;
  margin-left: 24px;
}
.nav-link {
  color: #fff;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 4px;
  font-weight: 500;
  text-align: center;
  white-space: nowrap;
}
.nav-link:hover { background: rgba(255,255,255,0.1); }
/* Phase 4 v1 item 5 (2026-05-17): user-nav stacks the username
   on top of the Log out button instead of laying them out
   side-by-side. Halves the horizontal real estate user-nav
   consumes, freeing space for primary-nav, and keeps the
   right edge tidy via flex-end alignment. */
.user-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
}
.user-name { font-size: 14px; opacity: 0.9; }
.link-button {
  background: transparent; color: #fff; border: 1px solid rgba(255,255,255,0.4);
  padding: 4px 10px; border-radius: 4px; cursor: pointer; font: inherit;
}
.link-button:hover { background: rgba(255,255,255,0.1); }
.link-button-danger { color: var(--error); border-color: var(--error); }
.link-button-danger:hover { background: var(--error-bg); }
form.inline { display: inline; }
.content { max-width: 1400px; margin: 0 auto; padding: 24px; }
.site-footer { text-align: center; padding: 24px; color: var(--muted); }

/* --- Flash messages --- */
.flash { padding: 10px 16px; margin: 0 24px 16px; border-radius: 4px; }
.flash-error { background: var(--error-bg); color: var(--error); border: 1px solid var(--error); }
.flash-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success); }
.flash-info { background: var(--info-bg); color: var(--info); border: 1px solid var(--info); }

/* --- Login page --- */
.auth-card {
  max-width: 400px; margin: 80px auto; padding: 32px; background: var(--card);
  border: 1px solid var(--border); border-radius: 8px;
}
.auth-card h1 { margin-top: 0; color: var(--brand); }
.auth-card label { display: block; margin-bottom: 16px; font-weight: 500; }
.auth-card input { display: block; width: 100%; padding: 8px; margin-top: 4px;
  border: 1px solid var(--border); border-radius: 4px; font: inherit; }
.auth-card button {
  width: 100%; padding: 10px; background: var(--brand); color: #fff;
  border: 0; border-radius: 4px; cursor: pointer; font: inherit; font-weight: 600;
}
.auth-card button:hover { background: var(--brand-dark); }
.form-error {
  background: var(--error-bg); color: var(--error); padding: 8px 12px;
  margin-bottom: 16px; border-radius: 4px; border: 1px solid var(--error);
}

/* --- Page structure --- */
.page-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
}
.page-header h1 { margin: 0; color: var(--brand); }
.button-primary {
  background: var(--brand); color: #fff; padding: 8px 16px;
  text-decoration: none; border-radius: 4px; font-weight: 500;
  font-size: 14px;
}
.button-primary:hover { background: var(--brand-dark); }

.search-bar {
  display: flex; align-items: center; gap: 16px; margin-bottom: 16px;
  background: var(--card); padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 6px;
}
.search-bar input[type="search"] {
  flex: 1; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 4px; font: inherit; font-size: 14px;
}
.search-bar input[type="search"]:focus {
  outline: 2px solid var(--brand); outline-offset: -1px;
}
.filter-badge {
  font-size: 13px; color: var(--muted); padding: 4px 10px;
  background: var(--info-bg); border-radius: 12px;
}

/* --- Tables --- */
.table-wrap { background: var(--card); border: 1px solid var(--border); border-radius: 6px; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table thead { background: #f9fafb; }
.data-table th {
  text-align: left; padding: 10px 14px; font-weight: 600;
  color: var(--brand); border-bottom: 2px solid var(--border);
}
.data-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tr:hover { background: #fafbfc; }
.data-table a { color: var(--brand); text-decoration: none; font-weight: 500; }
.data-table a:hover { text-decoration: underline; }
.postcode { white-space: nowrap; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.muted { color: var(--muted); font-size: 12px; }
.empty-state { text-align: center; padding: 32px; color: var(--muted); }

/* --- Badges --- */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 12px;
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.3px;
}
.badge-direct { color: var(--tag-direct); background: var(--tag-direct-bg); }
.badge-trade { color: var(--tag-trade); background: var(--tag-trade-bg); }
.badge-contract { color: var(--tag-contract); background: var(--tag-contract-bg); }
.badge-chargeable { color: var(--tag-trade); background: var(--tag-trade-bg); }

/* --- Phase 5 substep 5.2 -- completed-jobs action queue chips --- */
.action-tag {
  display: inline-block; padding: 2px 10px; border-radius: 12px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.3px;
  color: #92400e; background: #fef3c7;
  margin-right: 4px; margin-bottom: 4px;
}
/* Tick-action chips (Phase 5 substep 5.2D) -- rendered as <button>
   inside their own <form>. Strip browser button chrome and adopt
   the same chip look; show a subtle hover state to hint it's
   clickable. */
button.action-tag-button {
  border: none; cursor: pointer; font: inherit;
  text-transform: uppercase; letter-spacing: 0.3px;
}
button.action-tag-button:hover { filter: brightness(0.95); }
button.action-tag-button:focus-visible {
  outline: 2px solid #d97706; outline-offset: 2px;
}
/* Text-action chips (TRADE RTF REQUIRED + CHARGEABLE REQ QUOTE ON
   PARTS) -- expose an inline textarea + submit button. */
.action-inline-form {
  display: inline-block; vertical-align: top;
  margin: 0 8px 6px 0; padding: 8px; max-width: 320px;
  background: #fffbeb; border: 1px solid #fef3c7; border-radius: 6px;
}
.action-tag-header {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.3px; color: #92400e; margin-bottom: 4px;
}
.action-engineer-note {
  font-size: 12px; color: var(--muted); margin-bottom: 4px;
}
.action-engineer-note em { color: var(--ink); font-style: italic; }
.action-inline-form textarea {
  width: 100%; min-height: 40px; padding: 4px;
  border: 1px solid #fed7aa; border-radius: 4px;
  font-family: inherit; font-size: 13px; box-sizing: border-box;
}
.action-inline-form button[type="submit"] {
  padding: 4px 10px; margin-top: 4px;
  background: #d97706; color: #fff; border: none;
  border-radius: 4px; font-size: 12px; cursor: pointer;
}
.action-inline-form button[type="submit"]:hover {
  background: #b45309;
}

/* --- Phase 5 substep 5.2 -- three-state filter on /jobs --- */
.segmented-filter {
  display: inline-flex; border: 1px solid var(--border); border-radius: 6px;
  overflow: hidden; padding: 0;
}
.segmented-filter-option { display: inline-flex; margin: 0; }
.segmented-filter-option input[type="radio"] { display: none; }
.segmented-filter-option span {
  display: inline-block; padding: 6px 12px; cursor: pointer;
  font-size: 13px; color: var(--muted); background: var(--card);
  border-right: 1px solid var(--border); white-space: nowrap;
}
.segmented-filter-option:last-child span { border-right: none; }
.segmented-filter-option input[type="radio"]:checked + span {
  background: var(--brand); color: #fff;
}
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Phase 5 substep 5.3 -- "NEW" chip on unviewed dispatch rows.
   Visible until any dispatch-capable user (SM / JC / director /
   admin) has opened the job's detail page or ticked "Mark viewed"
   on the dispatch action bar. Distinct colour from priority /
   action-tag chips so it doesn't get confused for an urgency
   signal -- this is a "have you looked at this?" marker, not a
   priority indicator. */
.new-chip {
  display: inline-block; padding: 1px 6px; margin-left: 6px;
  border-radius: 10px; font-size: 10px; font-weight: 700;
  letter-spacing: 0.5px;
  color: #1e3a8a; background: #dbeafe; border: 1px solid #93c5fd;
  vertical-align: middle;
}

/* Phase 5 substep 5.3 Commit E -- per-engineer day-plan page
   (/service/dispatch/engineers). One section per engineer with
   up/down reorder controls and an external Google Maps link. */
.engineer-plans { display: flex; flex-direction: column; gap: 20px; }
.engineer-section {
  border: 1px solid var(--border); border-radius: 6px;
  padding: 12px; background: var(--card);
}
.engineer-section-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 8px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.engineer-section-name { margin: 0; font-size: 16px; }
.engineer-section-map {
  margin-left: auto; font-size: 13px;
}
.engineer-section-empty { margin: 4px 0; font-size: 14px; }
.engineer-job-list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 4px;
}
.engineer-job-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 4px; font-size: 14px;
}
.engineer-job-row + .engineer-job-row {
  border-top: 1px solid var(--border);
}
.engineer-job-postcode {
  min-width: 80px; font-family: var(--font-mono, monospace);
  color: var(--muted);
}
.engineer-job-ref { font-weight: 600; min-width: 100px; }
.engineer-job-customer { flex: 1; }
.engineer-reorder-arrow {
  display: inline-block; width: 24px; height: 24px;
  padding: 0; border: 1px solid var(--border); border-radius: 4px;
  background: var(--card); cursor: pointer; font-size: 14px;
  line-height: 22px; text-align: center; vertical-align: middle;
}
.engineer-reorder-arrow:hover { background: var(--bg); }
.engineer-reorder-disabled {
  cursor: default; opacity: 0.3; pointer-events: none;
}

/* Phase 5 substep 5.3 Commit F -- embedded dispatch map.
   Collapsible <details> block above the dispatch table. Default
   closed; Leaflet lazy-initialises on first open. The container
   height is fixed so the map renders without measuring its parent;
   Leaflet's invalidateSize() is called after the <details> opens
   so tiles re-layout correctly. */
.dispatch-map-toggle {
  margin: 12px 0;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--card);
}
.dispatch-map-toggle > summary {
  padding: 8px 12px; cursor: pointer; font-weight: 600;
  list-style-position: inside;
}
.dispatch-map {
  height: 400px; width: 100%;
  border-top: 1px solid var(--border);
}

/* --- Customer detail page layout --- */
.customer-detail {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 24px;
}
@media (max-width: 900px) {
  .customer-detail { grid-template-columns: 1fr; }
}
.customer-form-area h2,
.contacts-panel h2,
.standard-pricing-box h2,
.charge-history-box h2 {
  color: var(--brand);
  margin: 0 0 12px;
  font-size: 18px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 8px;
}

/* Right column of the customer detail page stacks the standard-pricing
   box, charge history and contacts vertically. */
.customer-side {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* --- Standard pricing box (item Y) --- */
.standard-pricing-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
}
.standard-pricing-text {
  font-size: 14px;
  white-space: pre-wrap;
  margin: 0;
}

/* --- Charge history box (item Y) --- */
.charge-history-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
}
.charge-history-list { list-style: none; margin: 0; padding: 0; }
.charge-history-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
  border-bottom: 1px solid var(--border);
  padding: 8px 0;
  font-size: 13px;
}
.charge-history-line:last-child { border-bottom: 0; }
.charge-history-line .ch-serial {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--muted);
  margin: 0 4px;
}
.charge-history-line .ch-price { font-weight: 600; white-space: nowrap; }
.charge-history-line .ch-date {
  color: var(--muted);
  white-space: nowrap;
}

/* Read-only standard-pricing callout on the job booking form (item Y). */
.standard-pricing-note {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: 4px;
  padding: 10px 12px;
  margin: 0 0 16px;
  font-size: 14px;
}
.standard-pricing-note .standard-pricing-text {
  margin-top: 4px;
  color: var(--text);
}

/* --- Forms --- */
.form-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
}
.form-card fieldset {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px 16px;
  margin: 0 0 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-card fieldset legend {
  font-weight: 600;
  color: var(--brand);
  padding: 0 4px;
}
.form-card label {
  display: flex;
  flex-direction: column;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  gap: 4px;
}
.form-card label.full { grid-column: 1 / -1; }
.form-card label.checkbox-row {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-weight: 400;
  color: var(--text);
}
.form-card input[type="text"],
.form-card input[type="email"],
.form-card input[type="search"],
.form-card select,
.form-card textarea {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
}
.form-card input:focus,
.form-card select:focus,
.form-card textarea:focus {
  outline: 2px solid var(--brand);
  outline-offset: -1px;
  border-color: var(--brand);
}
.form-card textarea { resize: vertical; }
.form-card .postcode-input {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  text-transform: uppercase;
}
.form-card .invoice-fields {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-card .invoice-fields.hidden { display: none; }
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 8px;
}
.button-secondary {
  background: var(--card); color: var(--text);
  border: 1px solid var(--border); padding: 8px 16px;
  text-decoration: none; border-radius: 4px;
}
.button-secondary:hover { background: var(--bg); border-color: var(--border-hover); }
.link-quiet {
  background: transparent; border: 0; color: var(--muted);
  cursor: pointer; font: inherit; padding: 0;
  text-decoration: underline;
}
.link-quiet:hover { color: var(--brand); }
.link-quiet.danger:hover { color: var(--error); }

/* --- Read-only view --- */
.readonly-fields dl {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px 16px;
  margin: 0;
}
.readonly-fields dt { color: var(--muted); font-size: 13px; }
.readonly-fields dd { margin: 0; font-size: 14px; }

/* --- Contacts panel --- */
.contacts-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
}
/* item Y: contacts now sit below the details form in the left column. */
.customer-form-area .contacts-panel { margin-top: 24px; }
.contact-list { list-style: none; margin: 0; padding: 0; }
.contact-item {
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}
.contact-item:last-child { border-bottom: 0; }
.contact-header { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.contact-body { font-size: 13px; color: var(--muted); }
.contact-line { margin: 2px 0; }
.contact-actions { margin-top: 6px; display: flex; gap: 12px; font-size: 13px; }
.contact-edit { margin-top: 8px; padding: 8px; background: var(--bg); border-radius: 4px; }
.contact-edit form,
.add-contact form {
  display: grid; gap: 6px;
}
.contact-edit input,
.add-contact input {
  padding: 6px 8px; border: 1px solid var(--border); border-radius: 4px; font-size: 13px;
}
.tag {
  display: inline-block; font-size: 11px; padding: 1px 6px;
  border-radius: 8px; font-weight: 600;
}
.tag-primary { color: var(--tag-contract); background: var(--tag-contract-bg); }
.tag-invoicing { color: var(--tag-trade); background: var(--tag-trade-bg); }
.add-contact { margin-top: 16px; }
.add-contact summary { cursor: pointer; color: var(--brand); font-weight: 500; }
.add-contact[open] summary { margin-bottom: 8px; }

.hidden { display: none !important; }

/* --- Equipment panel on customer detail --- */
.equipment-panel {
  margin-top: 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
}
.equipment-panel .panel-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.equipment-panel h2 {
  margin: 0; color: var(--brand); font-size: 18px;
}
.button-primary.small { padding: 4px 10px; font-size: 13px; }

/* --- Equipment history list --- */
.history-list { list-style: none; margin: 0; padding: 0; }
.history-item {
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}
.history-item:last-child { border-bottom: 0; }
.history-header {
  display: flex; gap: 8px; align-items: center; margin-bottom: 4px;
}
.history-body { font-size: 13px; color: var(--text); }
/* Phase 3 step 3.6-3b: per-row Edit + Cancel actions on the
   /leave/request own-history list. Inline so the two actions sit
   side by side; the inline form drops its default margin so the
   row doesn't break to a new line. */
.history-actions {
  display: flex; gap: 12px; margin-top: 4px;
  font-size: 13px;
}
.history-actions form.inline { display: inline; margin: 0; }
.tag-history-install   { color: #1d4ed8; background: #dbeafe; }
.tag-history-repair    { color: #b45309; background: #fef3c7; }
.tag-history-ppm       { color: #166534; background: #dcfce7; }
.tag-history-resite    { color: #6b21a8; background: #f3e8ff; }
.tag-history-meter_reading { color: #475569; background: #f1f5f9; }
.tag-history-contract_change { color: #be185d; background: #fce7f3; }
.tag-history-note      { color: #475569; background: #f1f5f9; }
.muted.small { font-size: 12px; }

/* --- Contracts panel + status tags --- */
.contracts-list-panel {
  margin-top: 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
}
.contracts-list-panel .panel-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.contracts-list-panel h2 { margin: 0; color: var(--brand); font-size: 18px; }

.tag-status-active           { color: var(--tag-contract); background: var(--tag-contract-bg); }
.tag-status-expired          { color: var(--error); background: var(--error-bg); }
.tag-status-due_for_renewal  { color: var(--tag-trade); background: var(--tag-trade-bg); }
.tag-status-draft            { color: var(--muted); background: #f1f5f9; }

.page-header h1 .tag {
  font-size: 12px;
  margin-left: 12px;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
}

/* --- Form label-row (label + helper link side-by-side) --- */
.label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.label-row a.small {
  font-size: 12px;
  font-weight: 500;
}

/* --- Dashboard search bar elements --- */
.search-bar select {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font: inherit; font-size: 13px;
  background: var(--card);
}
.search-bar input[type="search"] { flex: 2 1 0; }

/* --- Job list rows --- */
.priority-emergency td { background: #fef2f2; }
.priority-high td { background: #fff7ed; }
.priority-tag {
  display: inline-block; padding: 1px 6px; border-radius: 12px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
}
.priority-tag-emergency { background: #b91c1c; color: white; }
.priority-tag-high { background: #f59e0b; color: white; }
.priority-tag-normal { background: #f1f5f9; color: var(--muted); }
.priority-tag-low { background: #f8fafc; color: var(--muted); }

.tag-status-draft { background: var(--bg); color: var(--muted); }
.tag-status-open { background: var(--info-bg); color: var(--info); }
.tag-status-assigned { background: var(--tag-trade-bg); color: var(--tag-trade); }
.tag-status-in_progress { background: var(--tag-contract-bg); color: var(--tag-contract); }
.tag-status-completed { background: #f1f5f9; color: var(--muted); }
.tag-status-cancelled { background: #fef2f2; color: var(--error); }

.fault-clamp {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Generic danger button (Step 11/12) --- */
.button-danger {
  background: var(--error); color: #fff;
  border: 0; padding: 8px 16px;
  border-radius: 4px; cursor: pointer; font: inherit; font-weight: 600;
  text-decoration: none; display: inline-block;
}
.button-danger:hover:not(:disabled) { background: #991b1b; }
.button-danger:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- Customer merge form (Step 11b) --- */
.merge-form { max-width: 900px; }
.merge-form .form-row {
  display: flex; align-items: center; gap: 16px; margin-bottom: 16px;
}
.merge-form .form-field { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.merge-form .form-field select { padding: 8px; border: 1px solid var(--border); border-radius: 4px; font: inherit; }
.merge-form .form-arrow { font-size: 24px; color: var(--muted); padding-top: 24px; }
.merge-form .form-actions { margin-top: 16px; display: flex; gap: 8px; }
.merge-preview {
  margin: 16px 0; padding: 16px;
  background: var(--info-bg); border-left: 4px solid var(--info);
  border-radius: 4px;
}
.merge-preview h3 { margin: 0 0 8px; color: var(--info); font-size: 16px; }
.merge-preview-counts {
  list-style: none; padding: 0; margin: 8px 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 4px;
}
.merge-preview-counts li {
  padding: 4px 8px; background: var(--card);
  border: 1px solid var(--border); border-radius: 4px;
  font-size: 14px;
}
.merge-preview .hint { font-size: 13px; color: var(--muted); margin-top: 8px; }
.info-box {
  background: var(--card); border: 1px solid var(--border);
  padding: 16px; border-radius: 6px; margin-bottom: 16px;
}
.info-box p { margin: 0 0 8px; }
.info-box p:last-child { margin-bottom: 0; }
.page-actions { display: flex; gap: 8px; }

/* --- ON STOP banner (Step 12) --- */
.on-stop-banner-active {
  background: #7f1d1d;
  color: #fff;
  padding: 16px 20px;
  border-radius: 6px;
  margin-bottom: 16px;
  border-left: 6px solid #fca5a5;
  box-shadow: 0 2px 8px rgba(127, 29, 29, 0.3);
}
.on-stop-banner-header {
  display: flex; align-items: center; gap: 10px;
  font-size: 18px; letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.on-stop-icon {
  font-size: 24px;
  display: inline-block;
}
.on-stop-reason {
  font-size: 16px;
  margin: 4px 0 8px;
  font-weight: 500;
}
.on-stop-meta {
  font-size: 13px;
  margin: 0 0 12px;
  opacity: 0.9;
}
.on-stop-clear-form { margin: 0; }
.on-stop-clear {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.5);
}
.on-stop-clear:hover {
  background: rgba(255,255,255,0.25);
  border-color: #fff;
}
.on-stop-toggle {
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: 4px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--muted);
}
.on-stop-toggle summary {
  cursor: pointer;
  font-weight: 500;
  user-select: none;
}
.on-stop-set-form {
  margin-top: 10px;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.on-stop-set-form label { font-weight: 500; color: var(--text); }
.on-stop-set-form input[type="text"] {
  flex: 1 1 280px;
  padding: 6px 10px;
  border: 1px solid var(--border); border-radius: 4px; font: inherit;
}
.on-stop-set-form .form-error { color: var(--error); font-size: 13px; }

/* Compact variant for inline display on the job-creation form */
.on-stop-inline {
  background: #7f1d1d;
  color: #fff;
  padding: 12px 16px;
  border-radius: 6px;
  border-left: 6px solid #fca5a5;
  margin: 12px 0;
}
.on-stop-inline strong { letter-spacing: 0.5px; }
.on-stop-inline .reason { display: block; margin-top: 4px; font-size: 14px; }

/* Invoice customer picker (Step 14c) */
.invoice-picker { display: flex; flex-direction: column; gap: 6px; }
.invoice-picker > label { font-size: 13px; color: var(--text); }
.picker-current {
  padding: 8px 12px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 4px;
  display: flex; justify-content: space-between; align-items: center;
}
.invoice-picker input[type="search"] {
  padding: 6px 10px; border: 1px solid var(--border);
  border-radius: 4px; font: inherit;
}
.picker-results-wrap:empty { display: none; }
.picker-results {
  list-style: none; margin: 4px 0 0; padding: 0;
  border: 1px solid var(--border); border-radius: 4px;
  max-height: 240px; overflow-y: auto; background: var(--card);
}
.picker-results li { border-bottom: 1px solid var(--border); }
.picker-results li:last-child { border-bottom: 0; }
.picker-row {
  display: block; width: 100%; text-align: left; padding: 8px 12px;
  background: transparent; border: 0; cursor: pointer; font: inherit;
}
.picker-row:hover { background: var(--bg); }

/* Site flag tags (Step 14b) */
.tag-main-site {
  background: #dbeafe; color: #1d4ed8;
  font-size: 11px; font-weight: 600; padding: 2px 8px;
  border-radius: 10px; letter-spacing: 0.3px;
}
.tag-invoice-site {
  background: #fef3c7; color: #b45309;
  font-size: 11px; font-weight: 600; padding: 2px 8px;
  border-radius: 10px; letter-spacing: 0.3px;
  margin-left: 4px;
}
.site-flags { white-space: nowrap; }

/* Site-filter banner on the new-job form (Step 14a) */
.site-filter-banner {
  background: var(--info-bg);
  color: var(--info);
  border-left: 4px solid var(--info);
  padding: 10px 14px;
  border-radius: 4px;
  margin-bottom: 16px;
  font-size: 14px;
}
.site-filter-banner .postcode { font-weight: 600; }
.site-filter-banner a { margin-left: 8px; }

/* Inline action links in table rows */
.row-actions { white-space: nowrap; }
.row-actions a { margin-right: 12px; }
.row-actions a:last-child { margin-right: 0; }

/* Customer list row tag */
.on-stop-row td { background: #fef2f2; }
.on-stop-tag {
  display: inline-block;
  background: #7f1d1d; color: #fff;
  font-size: 11px; font-weight: 700;
  padding: 1px 6px; border-radius: 10px;
  margin-left: 6px; letter-spacing: 0.5px;
}

/* --- Job status panel (Phase 2 step 1b) --- */
.status-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px 20px;
  margin: 16px 0;
}
.status-panel-header {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.status-panel-header h2 {
  margin: 0;
  font-size: 18px;
}
.status-actions {
  display: flex; flex-direction: column; gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.status-action-row {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.status-action-row label { font-weight: 500; }
.status-action-row select {
  padding: 6px 10px; border: 1px solid var(--border);
  border-radius: 4px; font: inherit; min-width: 180px;
}
.status-action-buttons {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start;
}
.inline-reason-panel {
  display: inline-block;
}
.inline-reason-panel summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.inline-reason-panel summary::-webkit-details-marker { display: none; }
.inline-reason-panel[open] {
  display: block;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-top: 4px;
}
.inline-reason-panel form {
  margin-top: 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.inline-reason-panel form label {
  font-weight: 500; font-size: 13px;
}
.inline-reason-panel form textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 4px;
  font: inherit; resize: vertical;
}
.status-history {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.status-history h3 {
  font-size: 14px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin: 0 0 10px;
}
.status-timeline {
  list-style: none; padding: 0; margin: 0;
}
.status-timeline-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.status-timeline-row:last-child { border-bottom: 0; }
.status-timeline-row time {
  color: var(--muted); font-variant-numeric: tabular-nums;
  font-size: 13px;
}
.status-history-reason {
  grid-column: 2;
  margin: 4px 0 0;
  padding: 6px 10px;
  background: var(--bg);
  border-left: 3px solid var(--border-hover);
  border-radius: 0 4px 4px 0;
  font-size: 13px;
  color: var(--muted);
}
.form-error.small { font-size: 12px; }

/* --- Inactive-row tint (engineer admin) --- */
.muted-row td { color: var(--muted); background: #fafbfc; }
.muted-row td strong { color: var(--muted); font-weight: 500; }

/* --- Error pages (smoke-test polish #7) --- */
.error-page {
  max-width: 560px;
  margin: 80px auto 0;
  padding: 32px;
  text-align: center;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.error-page .error-status {
  font-size: 56px;
  line-height: 1;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--muted);
  letter-spacing: -1px;
}
.error-page h1 {
  margin: 0 0 16px;
  color: var(--brand);
  font-size: 24px;
}
.error-page .error-detail {
  margin: 0 0 24px;
  color: var(--text);
  line-height: 1.5;
}
.error-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* --- Per-rep sales notes panel (Phase 2 step 2 / s4 step 4) --- */

.sales-notes-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  margin-top: 24px;
}
.sales-notes-panel .panel-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}
.sales-notes-panel .panel-header h2 {
  margin: 0;
  color: var(--brand);
  font-size: 18px;
}
.sales-note-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.sales-note-form textarea {
  width: 100%;
  min-height: 60px;
  font-family: inherit;
  resize: vertical;
}
.sales-notes-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sales-note {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px;
}
.sales-note-meta {
  font-size: 13px;
  margin-bottom: 6px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: baseline;
}
.sales-note-body {
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.sales-note-actions {
  margin-top: 8px;
  display: flex;
  gap: 12px;
}
.sales-note-edit-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sales-note-edit-form textarea {
  width: 100%;
  font-family: inherit;
  resize: vertical;
}
.button-link {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--brand);
  text-decoration: underline;
  font: inherit;
}
.button-link:hover {
  color: var(--brand-dark);
}
.button-link-danger {
  color: var(--error);
}
.button-link-danger:hover {
  color: #7f1d1d;
}

/* --- On-stop list page (Phase 2 step 2 / s4 step 5) --- */

.on-stop-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 12px;
  flex-wrap: wrap;
}
.sort-tabs {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.sort-tab {
  padding: 6px 12px;
  text-decoration: none;
  color: var(--text);
  background: var(--card);
  border-right: 1px solid var(--border);
  font-size: 14px;
}
.sort-tab:last-child { border-right: none; }
.sort-tab:hover { background: var(--bg); }
.sort-tab.is-active {
  background: var(--brand);
  color: #fff;
}
.on-stop-table .reason-clamp {
  max-width: 480px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Expiring contracts page (Phase 2 step 2 / s4 step 6) --- */

.expiring-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.filter-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.filter-chip {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
}
.filter-chip:hover { background: var(--bg); }
.filter-chip.is-active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
.tag-soon   { color: var(--error); background: var(--error-bg); }
.tag-medium { color: var(--tag-trade); background: var(--tag-trade-bg); }

/* --- Alphabet jump bar (s4 step 6.5) --- */

.alphabet-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 8px 0 12px;
}
.alphabet-letter {
  display: inline-block;
  min-width: 28px;
  padding: 4px 8px;
  text-align: center;
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}
.alphabet-letter:hover { background: var(--bg); }
.alphabet-letter.is-active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
.alphabet-letter.is-disabled {
  color: var(--muted);
  background: transparent;
  border-color: transparent;
  cursor: not-allowed;
}

/* --- Pagination (s4 step 6.5) --- */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 16px 0;
}
.page-link {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
}
.page-link:hover { background: var(--bg); }
.page-link.is-disabled {
  color: var(--muted);
  background: transparent;
  border-color: transparent;
  cursor: not-allowed;
}
.page-current {
  padding: 0 12px;
  font-size: 14px;
  color: var(--muted);
}

/* --- Equipment list page (s4 step 7) --- */

.equipment-filters {
  flex-wrap: wrap;
  gap: 8px;
}
.equipment-filters label.inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
.equipment-filters label.inline input[type="date"] {
  font-size: 13px;
}
.filter-chip-label {
  align-self: center;
}

/* --- Edit-completed form + shadow-log table (s4 step 8) --- */

.edit-completed-panel .form-card {
  padding: 12px;
}
.edit-completed-panel fieldset.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  border: none;
  padding: 0;
  margin: 0;
}
.edit-completed-panel fieldset.grid-2 label.full {
  grid-column: 1 / -1;
}
.edit-completed-panel fieldset.grid-2 label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}
.edit-completed-panel fieldset.grid-2 label.checkbox-row {
  flex-direction: row;
  align-items: center;
  color: var(--text);
  gap: 8px;
}
.edit-completed-panel input[type="text"],
.edit-completed-panel input[type="number"],
.edit-completed-panel input[type="date"],
.edit-completed-panel select,
.edit-completed-panel textarea {
  font-family: inherit;
  font-size: 14px;
}
.shadow-log code {
  font-size: 12px;
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 3px;
}

/* --- Leave status tags (s4 step 9) --- */

.tag-status-pending  { color: var(--info);    background: var(--info-bg); }
.tag-status-approved { color: var(--success); background: var(--success-bg); }
.tag-status-rejected { color: var(--error);   background: var(--error-bg); }
/* Phase 3 step 3.6-3b: cancelled leave reuses the existing
   .tag-status-cancelled rule at line ~423 (red on light red). The
   semantics carry across cleanly: "this isn't happening" reads the
   same for a cancelled job and a cancelled leave booking. Adding a
   second .tag-status-cancelled rule here would override the job
   one via source-order specificity -- DON'T. */

/* --- High-call-machine pills (s4 step 11) --- */

.tag-high-call-orange {
  color: var(--tag-trade);
  background: var(--tag-trade-bg);
  font-weight: 600;
}
.tag-high-call-red {
  color: var(--error);
  background: var(--error-bg);
  font-weight: 600;
}

/* --- Dashboard (PHASE-PLAN s4 step 12) --- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 8px;
}
@media (max-width: 900px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}
.dashboard-tile {
  padding: 14px 16px;
}
.dashboard-tile h2 {
  margin: 0 0 8px;
  font-size: 15px;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 600;
}
.dashboard-tile h2 .muted {
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
  margin-left: 4px;
}
.dashboard-tile p.muted {
  margin: 0 0 8px;
}
.dashboard-tile .tile-list {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
}
.dashboard-tile .tile-list > li {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.5;
}
.dashboard-tile .tile-list > li:last-child {
  border-bottom: 0;
}
.dashboard-tile .tile-list a {
  color: var(--brand);
  text-decoration: none;
  font-weight: 500;
}
.dashboard-tile .tile-list a:hover {
  text-decoration: underline;
}

/* --- Phase 3.5 D11 -- equipment lifecycle bulk move UI --- */

/* Narrow tickbox column on /equipment. Sized for a checkbox plus
   a little breathing room; sticks left so it's easy to find. */
.bulk-select-col {
  width: 32px;
  text-align: center;
}

/* Footer action bar under the equipment table. Sits flush to the
   bottom of the table-wrap so the user's eye doesn't have to
   travel after selecting rows. */
.bulk-action-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 6px 6px;
  margin-top: -1px;
}
.bulk-action-label {
  font-weight: 500;
}

/* Soft-warn confirmation page banner. Yellow-tinted callout so it
   reads as a "are you sure?" rather than a hard error. */
.bulk-confirm-warning {
  background: #fef3c7;
  border-left: 4px solid #b45309;
  padding: 12px 16px;
  margin: 16px 0;
  border-radius: 4px;
  color: #1f2937;
}
.bulk-confirm-form .form-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

/* Lifecycle badges -- inherit base .badge styling but tinted per
   state so the at-customer / warehouse / graveyard distinction
   is glanceable on the list. */
.badge-lifecycle-at_customer { color: #166534; background: #dcfce7; }
.badge-lifecycle-warehouse   { color: #1d4ed8; background: #dbeafe; }
.badge-lifecycle-graveyard   { color: #6b7280; background: #e5e7eb; }

/* Contract badges (Phase 3.6 D10 tail) -- one tint per active
   contract type for the /equipment Contract column. The 'none'
   variant uses warn tints so uncovered machines pop visually
   for both service planning and sales hunting. */
.badge-contract-lease   { color: #1d4ed8; background: #dbeafe; }
.badge-contract-sale    { color: #166534; background: #dcfce7; }
.badge-contract-rental  { color: #6b21a8; background: #f3e8ff; }
.badge-contract-service { color: #9a3412; background: #ffedd5; }
.badge-contract-none    { color: var(--error); background: var(--error-bg); }

/* Filter chip soft-warn variant (Phase 3.6 D10 tail) -- used by the
   'No active' chip on the /equipment Contract chip row so the
   uncovered-machines filter pops in the row. The .is-active state
   on the base .filter-chip selector has higher specificity (two
   classes vs one) so an active warn chip still gets the brand
   styling -- the warn tint only applies when the chip is inactive. */
.filter-chip-warn {
  color: var(--error);
  border-color: var(--error);
}
.filter-chip-warn:hover { background: var(--error-bg); }
