:root {
  --brand: #e8590c;
  --brand-dark: #a83800;
  --brand-light: #fff1e6;
  --ink: #1b1f24;
  --ink-soft: #5b6470;
  --border: #e3e6ea;
  --bg: #f5f6f8;
  --card: #ffffff;
  --danger: #d64545;
  --success: #1f9254;
  --warn: #c98a02;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0 0 1em 0; }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--ink);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
}
.sidebar-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; padding: 0 4px; }
.logo-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--brand);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 1px 0 rgba(255,255,255,.18) inset, 0 2px 6px rgba(0,0,0,.25);
}
.logo-mark svg {
  width: 68%; height: 68%;
  transition: transform .6s cubic-bezier(.34, 1.4, .64, 1);
}
/* The sprocket turns and the droplet gives a little hop. Small enough to be a
   grace note rather than a distraction on a screen someone stares at all day. */
.sidebar-logo:hover .logo-mark--gear svg { transform: rotate(135deg); }
.sidebar-logo:hover .logo-mark--drop svg { transform: translateY(-2px) scale(1.1); }
.login-marks { display: flex; gap: 10px; justify-content: center; margin-bottom: 12px; }
.login-marks .logo-mark:first-child { background: #e8590c; }
.login-marks .logo-mark:last-child { background: #1861ac; }
.login-marks:hover .logo-mark--gear svg { transform: rotate(135deg); }
.login-marks:hover .logo-mark--drop svg { transform: translateY(-2px) scale(1.1); }

@media (prefers-reduced-motion: reduce) {
  .logo-mark svg { transition: none; }
  .sidebar-logo:hover .logo-mark svg,
  .login-marks:hover .logo-mark svg { transform: none; }
}
.logo-text { font-weight: 700; font-size: 15px; color: #fff; }

.biz-switcher { display: flex; gap: 6px; margin-bottom: 18px; }
.biz-pill {
  flex: 1;
  text-align: center;
  padding: 8px 6px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  color: rgba(255,255,255,0.6);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
}
.biz-pill:hover { text-decoration: none; color: #fff; }
.biz-pill-active {
  background: var(--pill-color, var(--brand));
  color: #fff;
  border-color: transparent;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-link {
  color: rgba(255,255,255,0.75);
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
}
.nav-link:hover { background: rgba(255,255,255,0.08); text-decoration: none; color: #fff; }
.nav-link-active { background: var(--brand); color: #fff !important; }

.sidebar-footer { padding: 10px 4px 2px; border-top: 1px solid rgba(255,255,255,0.1); margin-top: 10px; }
.biz-name { font-weight: 700; font-size: 13px; color: #fff; }
.biz-tagline { font-size: 11.5px; color: rgba(255,255,255,0.55); }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 58px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-weight: 700; font-size: 16px; }
.topbar-user { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--ink-soft); }
.user-name { font-weight: 600; color: var(--ink); }

.content { padding: 24px; max-width: 1180px; }
.content-plain { padding: 60px 20px; max-width: 420px; margin: 0 auto; }

.link-btn { background: none; border: none; padding: 0; color: var(--ink-soft); cursor: pointer; font-size: 13px; text-decoration: underline; }
.link-btn:hover { color: var(--brand); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--brand); }
.stat-label { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
th { color: var(--ink-soft); font-weight: 650; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }
tbody tr:hover { background: #fafbfc; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--brand); color: #fff;
  padding: 9px 16px; border-radius: 8px;
  font-weight: 650; font-size: 13.5px;
  border: none; cursor: pointer;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; color: #fff; }
.btn-secondary { background: #fff; color: var(--ink); border: 1px solid var(--border); }
.btn-secondary:hover { background: #f3f4f6; color: var(--ink); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #a83030; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em;
  background: #eef0f2; color: var(--ink-soft);
}
.badge-draft { background: #eef0f2; color: #5b6470; }
.badge-sent { background: #e6f0ff; color: #2657c9; }
.badge-accepted, .badge-paid, .badge-completed, .badge-ready { background: #e5f6ec; color: var(--success); }
.badge-declined, .badge-overdue, .badge-cancelled { background: #fbe9e9; color: var(--danger); }
.badge-booked_in { background: #f1eafd; color: #7c3aed; }
.badge-in_progress { background: #fff4e0; color: var(--warn); }
.badge-awaiting_parts { background: #ffe9e0; color: #c2410c; }

form .field { margin-bottom: 14px; }
label { display: block; font-weight: 650; font-size: 12.5px; color: var(--ink-soft); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .02em; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
textarea { resize: vertical; min-height: 70px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }
.checkbox-row label { text-transform: none; font-weight: 500; margin: 0; }

.hint { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

.flash { padding: 11px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 13.5px; font-weight: 600; }
.flash-info { background: #e6f0ff; color: #2657c9; }
.flash-success { background: #e5f6ec; color: var(--success); }
.flash-error { background: #fbe9e9; color: var(--danger); }

.empty-state { text-align: center; padding: 50px 20px; color: var(--ink-soft); }
.empty-state h3 { color: var(--ink); }

.line-items-table input { padding: 6px 8px; font-size: 13px; }
.line-items-table td { padding: 6px; }
.item-remove { color: var(--danger); cursor: pointer; background: none; border: none; font-size: 18px; line-height: 1; }
.totals-box { margin-left: auto; width: 260px; }
.totals-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13.5px; }
.totals-row.total { font-weight: 800; font-size: 16px; border-top: 1px solid var(--border); margin-top: 4px; padding-top: 10px; }

/* A whole card that is one big link - the tiles on the Settings index. */
.settings-tile { display: block; color: inherit; margin-bottom: 0; }
.settings-tile:hover { text-decoration: none; border-color: var(--brand); }
.settings-tile h3 { color: var(--brand); margin-bottom: 4px; }

.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab { padding: 9px 4px; margin-right: 20px; font-weight: 650; color: var(--ink-soft); border-bottom: 2px solid transparent; }
.tab-active { color: var(--brand); border-bottom-color: var(--brand); }

.login-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 32px; }
.login-logo { text-align: center; margin-bottom: 20px; }
.login-logo .logo-mark { width: 46px; height: 46px; border-radius: 13px; }

.doc-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; }
.doc-brand { font-size: 20px; font-weight: 800; color: var(--brand); }
.doc-meta { text-align: right; font-size: 13px; color: var(--ink-soft); }
.doc-meta .doc-number { font-size: 17px; font-weight: 800; color: var(--ink); }
.printable { background: #fff; }

.small { font-size: 12px; color: var(--ink-soft); }
.muted { color: var(--ink-soft); }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }

/* Coating colour picker (SVB) */
.coating-picker { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; background: #fafbfc; }
.cp-selected-list { margin-bottom: 12px; }
.cp-selected-row { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--border); }
.cp-selected-row:last-child { border-bottom: none; }
.cp-selected-info { flex: 1; min-width: 120px; display: flex; flex-direction: column; }
.cp-part-label { max-width: 220px; padding: 6px 8px; font-size: 12.5px; }
.cp-swatch { width: 26px; height: 26px; border-radius: 6px; flex-shrink: 0; border: 1px solid rgba(0,0,0,0.15); }
.cp-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.cp-search { flex: 1 1 220px; min-width: 0; }
.cp-brand-filter { max-width: 190px; }
.cp-series-filter { max-width: 170px; }
.cp-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; max-height: 260px; overflow-y: auto; padding: 4px; background: #fff; border: 1px solid var(--border); border-radius: 8px; }
.cp-tile { display: flex; align-items: center; gap: 8px; text-align: left; padding: 6px; border: 1px solid var(--border); border-radius: 8px; background: #fff; cursor: pointer; font-family: inherit; }
.cp-tile:hover { border-color: var(--brand); background: var(--brand-light); }
.cp-tile-swatch { width: 24px; height: 24px; border-radius: 6px; flex-shrink: 0; border: 1px solid rgba(0,0,0,0.15); }
.cp-tile-label { font-size: 12px; line-height: 1.3; }
.coating-summary { display: flex; flex-wrap: wrap; gap: 10px; }
.coating-chip { display: flex; align-items: center; gap: 7px; padding: 5px 10px 5px 6px; border-radius: 999px; background: #f1f2f4; font-size: 12.5px; }
.coating-chip .cp-swatch { width: 18px; height: 18px; border-radius: 5px; }

/* An empty square to tick with a pen on the printed job card. Drawn with a
   border rather than a ☐ glyph, which renders inconsistently across printers. */
.tickbox {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 1.5px solid #444;
  border-radius: 3px;
  vertical-align: middle;
}
.tickbox-cell { width: 30px; text-align: center; }

/* Blank space for handwritten notes on the printed sheet. */
.print-only { display: none; }
.write-lines { margin-top: 6px; }
.write-lines div { border-bottom: 1px solid #bbb; height: 26px; }

/* A table column that exists only on paper. Needs table-cell rather than block,
   or the row layout breaks when it appears. */
.print-cell { display: none; }
.write-cell { min-width: 180px; }
.write-cell span { display: block; border-bottom: 1px solid #bbb; height: 18px; }

/* ---- Edit-in-place documents (the job card) ----------------------------
   The document IS the form. Fields sit quietly until you go near them, so the
   page still reads as a job card rather than a wall of boxes. */
.doc-edit input[type="text"],
.doc-edit input[type="date"],
.doc-edit input[type="number"],
.doc-edit textarea,
.doc-edit select {
  border-color: transparent;
  background: transparent;
  transition: background .12s, border-color .12s;
}
.doc-edit input[type="text"]:hover,
.doc-edit input[type="date"]:hover,
.doc-edit input[type="number"]:hover,
.doc-edit textarea:hover,
.doc-edit select:hover { background: var(--bg); border-color: var(--border); }
.doc-edit input:focus, .doc-edit textarea:focus, .doc-edit select:focus { background: #fff; }
.doc-edit textarea { min-height: 44px; overflow: hidden; }
/* Field rows that read as a sentence: "Assigned to [ Sam ]". */
.doc-inline { display: flex; align-items: center; gap: 8px; }
.doc-inline > strong { white-space: nowrap; }
.doc-block { margin-bottom: 14px; }
/* An input standing in for a heading - the quote's title. Inherits the h3's
   type so it doesn't shrink to form-field size in the middle of a document. */
.doc-edit .doc-title { font: inherit; padding: 2px 6px; }
.doc-block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.doc-block-head h3 { margin-bottom: 6px; }
.doc-toggle { display: flex; align-items: center; gap: 6px; text-transform: none; font-weight: 500; margin: 0; }
.doc-toggle input { width: auto; }
/* Save bar rides along the bottom so it's reachable from anywhere on a long card. */
.doc-save {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  margin: 18px -20px -20px; padding: 14px 20px;
  background: var(--card); border-top: 1px solid var(--border);
  border-radius: 0 0 14px 14px;
}

/* Pricing lives in the form either way - hidden only means hidden. The job card
   starts hidden because it's the workshop copy and carries no money. */
.pricing-hidden .cell-price,
.pricing-hidden .bundle-price-note { display: none; }

@media print {
  .no-print, .sidebar, .topbar { display: none !important; }
  body { background: #fff; }
  .app-shell { display: block; }
  .main-col { display: block; }
  .content { padding: 0; max-width: none; }
  .card { border: none; padding: 0; margin-bottom: 8px; }
  .print-only { display: block !important; }
  .print-cell { display: table-cell !important; }
  /* Keep the tick squares crisp - browsers drop backgrounds/borders otherwise. */
  .tickbox { border-color: #000; -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  /* A4 portrait is about 794 CSS px wide, which trips the max-width:900px
     breakpoint above and would stack the columns on paper even though the
     screen shows them side by side. Restore them for print. This block is
     later in the file, so it wins when both media queries match. */
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }

  /* Don't let a table or a column block be split across two pages. */
  table { break-inside: auto; }
  tr { break-inside: avoid; break-after: auto; }
  h3 { break-after: avoid; }
  .grid > div { break-inside: avoid; }

  /* An edit-in-place document has to print as a document: no boxes, no dropdown
     arrows, no spinners. The long text fields print from their .print-only
     mirror instead of the textarea, which would clip at a page break. */
  .doc-edit input, .doc-edit select, .doc-edit textarea {
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
    color: #000;
    -webkit-appearance: none;
    appearance: none;
  }
  .doc-edit input[type="checkbox"] {
    -webkit-appearance: checkbox;
    appearance: checkbox;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .doc-edit input[type="number"]::-webkit-inner-spin-button,
  .doc-edit input[type="number"]::-webkit-outer-spin-button { display: none; }
  /* appearance:none doesn't reach this one - it's a shadow-DOM pseudo-element,
     and without the rule a little calendar icon prints beside every date. */
  .doc-edit input[type="date"]::-webkit-calendar-picker-indicator { display: none; }

  /* Belt and braces: the job card never prints money, whatever the on-screen
     pricing toggle is set to. */
  .jc-doc .cell-price, .jc-doc .bundle-price-note { display: none !important; }
}
