/* Quote Builder (js/pages/quotes.js) */
.qb-filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.qb-filter { border: 1px solid var(--border); background: #fff; border-radius: 999px; padding: 6px 12px; font-weight: 700; font-size: 13px; cursor: pointer; color: var(--text); }
.qb-filter span { color: var(--text-dim); font-weight: 600; margin-left: 2px; }
.qb-filter.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.qb-filter.active span { color: #cfd5db; }
.qb-search { width: 100%; margin-bottom: 14px; }
.qb-list-card { padding: 0; overflow: hidden; }
.qb-table th, .qb-table td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; white-space: nowrap; }
.qb-table th { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .03em; background: #fafafb; }
.qb-table tbody tr { cursor: pointer; }
.qb-table tbody tr:hover { background: #fafafb; }
.qb-table .num { text-align: right; }
.qb-row-actions { text-align: right; }
.qb-row-actions .btn { margin-left: 4px; }

.qb-topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 14px; }
.qb-title { font-size: 20px; flex: 1; min-width: 160px; }
.qb-title span { color: var(--text-dim); font-weight: 600; font-size: 16px; margin-left: 6px; }
.qb-status { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13px; }
.qb-status select { padding: 7px 10px; border-radius: 8px; border: 1px solid var(--input-border); font-weight: 700; }
.qb-save-state { font-size: 13px; font-weight: 600; color: var(--text-dim); }
.qb-save-saved { color: var(--green-text); }
.qb-save-error, .qb-save-conflict { color: var(--red); }

.qb-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
/* The right column stays on screen while you scroll the quote, and scrolls on
   its own (mouse wheel over it) when it is taller than the screen. */
.qb-aside { position: sticky; top: 14px; max-height: calc(100vh - 110px); overflow-y: auto; overscroll-behavior: contain; padding-right: 4px; scrollbar-width: thin; }
/* Calculators box: drag it by its title to put it anywhere (computer only). */
.qb-calc-head { display: flex; align-items: center; gap: 8px; cursor: grab; user-select: none; touch-action: none; }
.qb-calc-head.dragging { cursor: grabbing; }
.qb-calc-hint { font-size: 11.5px; font-weight: 600; color: var(--text-dim); }
.qb-calc-dock { display: none; margin-left: auto; padding: 0; }
.qb-calc-card.qb-floating { position: fixed; z-index: 60; width: 380px; max-height: calc(100vh - 16px); overflow-y: auto; margin: 0; box-shadow: 0 14px 40px rgba(0,0,0,.30); border: 2px solid #1f3b4d; }
.qb-calc-card.qb-floating .qb-calc-head { background: #1f3b4d; color: #fff; margin: -16px -16px 12px; padding: 10px 14px; position: sticky; top: -16px; z-index: 1; }
.qb-calc-card.qb-floating .qb-calc-hint { color: #cfd8df; }
.qb-calc-card.qb-floating .qb-calc-dock { display: inline-block; color: #fff; }
.qb-card { padding: 16px; margin-bottom: 14px; }
.qb-card textarea { width: 100%; padding: 10px; border-radius: 9px; border: 1px solid var(--input-border); font: inherit; }
.qb-card-title { font-weight: 800; font-size: 15px; margin-bottom: 10px; }
.qb-chip { margin: 6px 6px 0 0; cursor: pointer; border: 1px solid var(--border); background: #fff; padding: 6px 10px; border-radius: 14px; font-size: 13px; }

.qb-service-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.qb-service-num { font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); }
.qb-service-name { width: 100%; font-size: 16px; font-weight: 700; padding: 10px 12px; border: 1px solid var(--input-border); border-radius: 9px; margin-bottom: 12px; }
.qb-band { background: #1f3b4d; color: #fff; font-weight: 800; font-size: 12px; letter-spacing: .03em; text-transform: uppercase; padding: 7px 10px; border-radius: 7px 7px 0 0; margin-top: 4px; }
.qb-band-labour { margin-top: 14px; }
.qb-grid { display: grid; grid-template-columns: minmax(0, 1fr) 70px 130px 110px 30px; gap: 6px; align-items: center; padding: 5px 0; }
.qb-grid input { width: 100%; padding: 8px 9px; border: 1px solid var(--input-border); border-radius: 7px; background: #fffbea; font: inherit; }
.qb-grid input[data-kind="money"], .qb-discount-row input[data-kind="money"] { text-align: right; }
.qb-grid output, .qb-discount-row output { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.qb-grid-head { font-size: 11.5px; color: var(--text-dim); font-weight: 700; text-transform: uppercase; padding: 6px 0 2px; }
.qb-grid-head span:nth-child(3), .qb-grid-head span:nth-child(4) { text-align: right; }
.qb-part.qb-warn input[data-path$=".qty"] { border-color: var(--amber); background: var(--amber-bg); }
.qb-x { border: none; background: none; color: var(--text-dim); font-size: 15px; cursor: pointer; padding: 4px; }
.qb-x:hover { color: var(--red); }
.qb-link { border: none; background: none; color: var(--text); text-decoration: underline; font-weight: 700; font-size: 13px; cursor: pointer; padding: 6px 0; }
.qb-service-head .qb-link { color: var(--text-dim); font-weight: 600; }
.qb-service-total { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; padding: 10px 12px; background: var(--green-bg); border-radius: 8px; font-weight: 800; color: var(--green-text); }
.qb-add-service { width: 100%; margin-bottom: 14px; padding: 12px; font-weight: 800; }
.qb-discount-row { display: grid; grid-template-columns: minmax(0, 1fr) 130px 110px; gap: 6px; align-items: center; }
.qb-discount-row input { width: 100%; padding: 8px 9px; border: 1px solid var(--input-border); border-radius: 7px; font: inherit; }
.qb-danger { text-align: right; margin: 4px 0 20px; }

.qb-summary { padding: 0; overflow: hidden; }
.qb-summary-title { background: #1f3b4d; color: #fff; text-align: center; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; font-size: 13px; padding: 10px; }
.qb-summary-who { padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.qb-summary-who span { color: var(--text-dim); font-size: 13px; }
.qb-summary dl { margin: 0; }
.qb-summary dl div { display: flex; justify-content: space-between; padding: 9px 14px; border-bottom: 1px solid var(--border); font-size: 14px; }
.qb-summary dt { font-weight: 700; }
.qb-summary dd { margin: 0; font-variant-numeric: tabular-nums; }
.qb-summary .qb-grand { background: var(--green-bg); color: var(--green-text); font-size: 17px; font-weight: 900; }
.qb-warnings { padding: 12px 14px; background: var(--amber-bg); font-size: 13px; }
.qb-warnings-title { font-weight: 800; margin-bottom: 4px; }
.qb-warnings ul { margin: 0; padding-left: 18px; }
.qb-ok { padding: 12px 14px; color: var(--green-text); font-weight: 700; font-size: 13px; }
.qb-mobile-total { display: none; }

/* Quote Builder: head buttons, panels, sending, calculators */
.qb-head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.qb-panel { margin-bottom: 16px; }
.qb-send textarea { width: 100%; margin-top: 10px; font-size: 13px; line-height: 1.45; background: #fafafb; resize: vertical; }
.qb-send-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.qc-tabs { display: flex; gap: 4px; background: var(--muted-bg); padding: 4px; border-radius: 10px; margin-bottom: 10px; }
.qc-tabs button { flex: 1; border: 0; background: transparent; padding: 7px 4px; border-radius: 7px; font-weight: 700; font-size: 13px; cursor: pointer; color: var(--text); }
.qc-tabs button.active { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.qc-switch { display: flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; margin-bottom: 10px; }
.qc-switch button { flex: 1; border: 0; background: #fff; padding: 7px 6px; font-weight: 700; font-size: 12.5px; cursor: pointer; color: var(--text); }
.qc-switch button.active { background: #1f3b4d; color: #fff; }
.qc-hint { font-size: 12.5px; color: var(--text-dim); margin: 0 0 8px; }
.qc-field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; font-weight: 700; color: var(--text-dim); margin-bottom: 8px; }
.qc-field input, .qc-field select { width: 100%; padding: 8px 9px; border: 1px solid var(--input-border); border-radius: 7px; background: #fffbea; font: inherit; font-size: 14px; color: var(--text); font-weight: 600; }
.qc-field input[data-kind="money"], .qc-field input[data-kind="pct"], .qc-field input[data-kind="qty"], .qc-field input[data-kind="hours"] { text-align: right; }
.qc-target select { background: #fff; }
.qc-grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.qc-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.qc-col { border: 1px solid var(--border); border-radius: 9px; padding: 8px; }
.qc-col-title { font-weight: 800; font-size: 13px; background: #fde68a; margin: -8px -8px 8px; padding: 7px 8px; border-radius: 8px 8px 0 0; }
.qc-row { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.qc-row output { font-variant-numeric: tabular-nums; font-weight: 600; }
.qc-strong { font-weight: 800; color: var(--green-text); }
.qc-strong output { font-weight: 800; }
.qc-add { width: 100%; margin-top: 8px; }
.qc-warn { background: var(--amber-bg); padding: 6px 8px; border-radius: 7px; font-size: 12.5px; margin-bottom: 6px; }
.qc .qb-link { display: block; margin-top: 6px; }
@media (max-width: 640px) {
  .qb-head-actions { width: 100%; }
  .qb-head-actions .btn { flex: 1; padding: 9px 8px; font-size: 13px; }
  .qc-cols { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .qb-layout { grid-template-columns: 1fr; }
  .qb-aside { position: static; max-height: none; overflow: visible; padding-right: 0; }
  .qb-calc-head { cursor: default; touch-action: auto; }
  .qb-calc-hint { display: none; }
  .qb-calc-card.qb-floating { position: static; width: auto; max-height: none !important; overflow: visible; margin-bottom: 14px; box-shadow: none; border: 0; }
  .qb-calc-card.qb-floating .qb-calc-head { background: none; color: inherit; margin: 0 0 10px; padding: 0; position: static; }
  .qb-calc-card.qb-floating .qb-calc-dock { display: none; }
}
@media (max-width: 640px) {
  .qb-table th:nth-child(2), .qb-table td:nth-child(2), .qb-table th:nth-child(4), .qb-table td:nth-child(4) { display: none; }
  .qb-row-actions .btn { padding: 5px 8px; font-size: 12px; }
  .qb-card { padding: 12px; }
  .qb-grid-head { display: none; }
  /* Each part on two lines: description on top, qty / price / total / ✕ below */
  .qb-grid { grid-template-columns: 58px minmax(0, 1fr) 92px 28px; grid-template-areas: "desc desc desc desc" "qty price total x"; border-bottom: 1px dashed var(--border); padding: 8px 0; }
  .qb-grid > :nth-child(1) { grid-area: desc; }
  .qb-grid > :nth-child(2) { grid-area: qty; }
  .qb-grid > :nth-child(3) { grid-area: price; }
  .qb-grid > :nth-child(4) { grid-area: total; }
  .qb-grid > :nth-child(5) { grid-area: x; }
  .qb-discount-row { grid-template-columns: minmax(0, 1fr) 110px; }
  .qb-discount-row output { grid-column: 1 / -1; }
  .qb-editor { padding-bottom: 70px; }
  .qb-mobile-total { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; align-items: center; gap: 10px; padding: 12px 16px; background: var(--ink); color: #fff; box-shadow: 0 -4px 14px rgba(0,0,0,.2); }
  .qb-mobile-total strong { margin-left: auto; font-size: 18px; }
  .qb-mobile-total em { font-style: normal; background: var(--amber); color: #111; border-radius: 999px; padding: 2px 8px; font-size: 12px; font-weight: 800; }
}
@media print {
  .sidebar, .topbar, .qb-topbar, .qb-add-service, .qb-danger, .qb-x, .qb-link, .qb-mobile-total, .qb-send, #qbCalcEditor, #qbCustSearch, #qbCustResults { display: none !important; }
  .qb-layout { grid-template-columns: 1fr; }
}
