/* ============================================================
   CONTRACT + CHANGE ORDERS (M2) — .co-* styles.
   A per-module sheet on the quotes.css precedent: styles.css
   sits at the per-file upload ceiling, and the brief (§1)
   names the split convention for exactly this case. Loaded
   after quotes.css in index.html. Tokens are the portal's own
   (styles.css :root); the design-system skin layers over these
   the same way it does the other module sheets.
   ============================================================ */

.co-card { margin-bottom: 22px; }
.co-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.co-card-head .sum-card-h { margin-bottom: 6px; }
.co-actions { display: inline-flex; gap: 8px; flex-wrap: wrap; }

/* Contract facts — the quote client-rows shape: quiet labels,
   values beside them, wrapping on narrow screens. */
.co-rows { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 6px; margin: 6px 0 2px; }
.co-rows dt { color: var(--muted); font-size: 12.5px; }
.co-rows dd { margin: 0 18px 0 0; font-size: 14px; color: var(--ink); overflow-wrap: anywhere; }
.co-notes { margin: 8px 0 0; font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.co-doc-name { font-size: 13px; color: var(--muted); margin-left: 6px; overflow-wrap: anywhere; }
.co-doc-gone { color: var(--muted); font-style: italic; }
.co-viewdoc { vertical-align: baseline; }

/* Earlier contracts — the superseded rows stay readable. */
.co-earlier { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.co-earlier summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); }
.co-earlier-row { padding: 8px 0 2px; border-bottom: 1px dashed var(--line); }
.co-earlier-row:last-child { border-bottom: 0; }

/* The register. */
.co-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 6px; }
.co-h { font-size: 15.5px; margin: 0; }
.co-reg-note { margin: 0 0 12px; max-width: 68ch; }
/* Wave 20 responsive pass: the register and view tables scroll
   sideways inside their card on narrow screens (the projects
   table's #projects-table-wrap precedent) instead of clipping. */
.co-table-wrap { overflow-x: auto; }
.co-table .co-num, .co-table th.co-num { text-align: right; }
.co-table td.co-num { font-weight: 600; color: var(--ink); white-space: nowrap; font-variant-numeric: tabular-nums; }
.co-doc-no { font-weight: 600; color: var(--ink); white-space: nowrap; }

/* Origin badge (§5.1): renders only on rows whose origin is not
   manual — none can exist until M4, and the column carries the
   concept honestly rather than hiding the field. */
.co-origin-badge {
  display: inline-block; margin-left: 8px; padding: 1px 8px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--card);
  font-size: 11.5px; font-weight: 600; letter-spacing: .02em; color: var(--muted);
  white-space: nowrap; vertical-align: middle;
}

/* The record / edit / replace dialog form (fxDialog shell; the
   grid + labels come from styles.css .qm-form-grid). */
.co-form textarea {
  display: block; width: 100%; margin-top: 5px; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 8px; font: inherit;
  font-size: 14px; font-weight: 400; color: var(--ink); background: #fff;
}
.co-form textarea:focus { outline: 2px solid var(--gold); border-color: var(--gold); }
.co-form > label > span { display: block; }

/* Register rows that open (WS3): draft rows for ops. */
.co-row-open { cursor: pointer; }
.co-row-open:hover td { background: var(--bg); }
.co-row-open:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }

.co-form-note { margin: 10px 0 0; font-size: 13px; line-height: 1.5; }

/* ================================================================
   WS3 — the CO editor. The line grid mirrors the quote grid's
   anatomy (Billdr's shape, delta D1) in this module's own
   classes; tokens are the portal's (styles.css :root), with the
   quotes sheet's warning palette carried as values.
   ================================================================ */
.co-ed-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 14px; }
.co-ed-title { flex: 1; min-width: 0; }
.co-ed-title h3 { margin: 2px 0 2px; font-size: 17px; color: var(--ink); }
.co-ed-title p { margin: 0; font-size: 13px; }
.co-save { font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; padding-top: 6px; }
.co-save.err { color: #b3261e; }

.co-conflict {
  border: 1px solid #ecd9ac; background: #fdf6e7; color: #8a5a00;
  border-radius: 10px; padding: 12px 16px; margin-bottom: 14px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.co-conflict p { margin: 0; font-size: 13.5px; line-height: 1.5; flex: 1; min-width: 240px; }

.co-ed-card { margin-bottom: 0; }
.co-ed-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; margin-bottom: 6px; }
@media (max-width: 760px) { .co-ed-fields { grid-template-columns: 1fr; } }
.co-ed-fields textarea, .co-detail-grid textarea, .co-note-field textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; font-size: 14px; line-height: 1.5; resize: vertical; background: #fff; color: var(--ink);
  box-sizing: border-box;
}
.co-ed-fields textarea:focus, .co-detail-grid textarea:focus, .co-note-field textarea:focus {
  outline: 2px solid var(--gold); border-color: var(--gold);
}

.co-ed-tools { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 4px; }

.co-warnings {
  border: 1px solid #ecd9ac; background: #fdf6e7; border-radius: 10px;
  padding: 10px 14px; margin: 12px 0;
}
.co-warnings p { margin: 4px 0; font-size: 13px; line-height: 1.5; color: #8a5a00; }

/* The lines grid — the quote grid's row shape in .co- classes. */
.co-lines-wrap { overflow-x: auto; margin: 0 -6px; padding: 0 6px; }
.co-lines-table { width: 100%; border-collapse: collapse; margin: 0; background: transparent; }
.co-lines-table th {
  font-size: 12px; font-weight: 500; color: var(--muted); text-align: left;
  padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.co-lines-table td { padding: 14px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.co-lines-table tbody tr:last-child td { border-bottom: 0; }
.co-lines-table th:nth-child(2) { width: 170px; }
.co-lines-table th:nth-child(3), .co-lines-table th:nth-child(4) { width: 116px; }
.co-lines-table th:nth-child(5) { width: 104px; }
.co-lines-table th:nth-child(6) { width: 112px; }
.co-lines-table th.q-n, .co-lines-table td.q-n { text-align: right; }
.co-lines-table td input[type="text"] {
  width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; font-size: 14px; color: var(--ink); background: #fff; box-sizing: border-box;
}
.co-lines-table td input.q-n { text-align: right; font-variant-numeric: tabular-nums; }
.co-lines-table td select {
  height: 36px; padding: 0 6px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; font-size: 13px; color: var(--ink); background: #fff;
}
.co-lines-table td input[type="text"]:focus, .co-lines-table td select:focus {
  outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(176, 141, 62, .18);
}

.co-line-task { position: relative; min-width: 200px; }
.co-line-task input[type="text"] { font-weight: 500; }
.co-line-flags { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.co-line-flags:empty { display: none; }
.co-pill {
  font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 99px;
  background: #fff; color: var(--ink); border: 1px solid var(--line); white-space: nowrap;
}
.co-pill.muted-pill { color: var(--muted); background: var(--bg); border-color: var(--line); }
.co-badge-unpriced {
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px;
  background: #fdf6e7; color: #8a5a00; border: 1px solid #ecd9ac;
}

.co-qty-cell { white-space: nowrap; }
.co-qty-cell input[type="text"] { width: 64px; }
.co-qty-cell select { margin-left: 6px; width: 92px; }
.co-cost-cell { display: inline-flex; align-items: center; gap: 4px; }
.co-cost-cell input[type="text"] { width: 84px; }
.co-unit-echo { font-size: 12px; color: var(--muted); }

.co-markup-cell { text-align: right; }
.co-markup-badge {
  display: block; font-size: 12px; font-weight: 500; color: var(--muted);
  margin: -10px 0 2px; height: 12px; line-height: 12px; white-space: nowrap;
}
.co-markup-input { display: flex; align-items: center; justify-content: flex-end; gap: 3px; }
.co-markup-input input[type="text"] { width: 64px; }
.co-pct-sign { font-size: 13px; color: var(--muted); }

.co-calc { font-size: 14px; white-space: nowrap; line-height: 36px; font-variant-numeric: tabular-nums; }
.co-line-total { font-weight: 600; color: var(--ink); }
.co-line.is-unpriced .co-line-total { color: var(--muted); }
.co-line.is-credit .co-line-total { color: #b3261e; }

.co-line-acts { white-space: nowrap; width: 1%; text-align: right; }
.co-icon-btn {
  appearance: none; background: none; border: 1px solid transparent; border-radius: 7px;
  width: 28px; height: 28px; padding: 0; cursor: pointer; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
}
.co-icon-btn:hover:not(:disabled) { color: var(--ink); background: var(--bg); }
.co-icon-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(15, 34, 51, .12); color: var(--ink); }
.co-icon-btn:disabled { opacity: .3; cursor: default; }
.co-icon-btn svg.flip { transform: rotate(180deg); }
.co-line-acts .co-icon-btn { opacity: .55; transition: opacity .12s; }
.co-line:hover .co-line-acts .co-icon-btn, .co-line:focus-within .co-line-acts .co-icon-btn { opacity: 1; }
@media (hover: none) { .co-line-acts .co-icon-btn { opacity: 1; } }

.co-line-detail td { background: var(--bg); padding: 2px 16px 18px; }
.co-detail-grid { display: grid; grid-template-columns: 1fr 260px; gap: 12px 20px; align-items: end; }
.co-detail-grid select, .co-detail-grid input[type="text"] {
  width: 100%; height: 36px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; font-size: 13px; background: #fff; color: var(--ink); box-sizing: border-box;
}
@media (max-width: 760px) { .co-detail-grid { grid-template-columns: 1fr; } }
.co-note-field { display: block; margin-top: 12px; }
.co-note-field textarea { border-style: dashed; }
.co-prov { margin: 10px 0 0; font-size: 12px; }
.co-detail-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

/* The pricing panel — the quote ledger's anatomy, right-aligned
   under the grid. */
.co-panel { justify-self: end; width: min(100%, 440px); margin: 8px 0 0 auto; }
.co-panel .sum-card { background: transparent; border: 0; padding: 4px 0 0; margin: 0; box-shadow: none; }
.co-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.co-panel-head .sum-card-h { margin: 0; font-size: 14px; font-weight: 600; }
.co-panel-head .btn { height: 28px; padding: 0 10px; font-size: 12px; }
.co-panel-mode { margin: 4px 0 0; font-size: 13px; color: var(--ink); }
.co-panel-mode .muted { font-size: 12px; }
.co-panel-editor { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 10px 0 4px; background: #fff; }
.co-panel-editor .qm-field input { width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 14px; }
.co-panel-editor p { margin: 8px 0 0; font-size: 12px; line-height: 1.5; }
.co-mode-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 10px; }
.co-mode-toggle button {
  appearance: none; border: 0; background: #fff; padding: 6px 14px; font: inherit;
  font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.co-mode-toggle button.active { background: var(--ink); color: #fff; }
.co-panel-rows { margin: 10px 0 0; }
.co-panel-rows > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 5px 0; }
.co-panel-rows dt { color: var(--ink); font-size: 13px; }
.co-panel-rows dt .co-link-btn { margin-left: 8px; font-size: 12px; }
.co-panel-rows dt.muted { color: var(--muted); }
.co-panel-rows dd { margin: 0; font-size: 13px; font-weight: 500; color: var(--ink); white-space: nowrap; font-variant-numeric: tabular-nums; }
.co-panel-editrow dd { display: flex; gap: 10px; align-items: center; }
.co-panel-editrow input {
  width: 110px; height: 32px; padding: 0 8px; border: 1px solid var(--line);
  border-radius: 7px; font: inherit; font-size: 13px; text-align: right;
}
.co-link-btn {
  appearance: none; background: none; border: 0; padding: 0; font: inherit;
  font-size: 13px; font-weight: 600; color: var(--ink); cursor: pointer;
  text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px;
}
.co-link-btn:hover { text-decoration-color: var(--ink); }
.co-link-btn.danger-text { color: #b3261e; }
.co-breakdown { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
.co-breakdown h4 { margin: 0; font-size: 13px; font-weight: 600; }
.co-breakdown h4 .muted { font-weight: 400; font-size: 12px; }

/* The running Total — navy bar pinned to the editor's bottom,
   Total in gold: the screen's one gold number (§3.3). */
.co-totalbar {
  position: sticky; bottom: 0; z-index: 25;
  display: flex; align-items: center; justify-content: flex-end; gap: 14px;
  margin-top: 24px; padding: 14px 24px;
  background: #0f2233; color: #fff;
  border-radius: 12px 12px 0 0;
  box-shadow: 0 -8px 20px -12px rgba(15, 34, 51, .45);
}
.co-totalbar-label { font-size: 16px; font-weight: 600; color: rgba(255, 255, 255, .82); }
.co-totalbar-amt { font-size: 22px; font-weight: 700; color: var(--gold); letter-spacing: .01em; font-variant-numeric: tabular-nums; }

/* Picker lists (bulk copy + catalogue) — one row shape. */
.co-bulk-list { display: flex; flex-direction: column; max-height: 46vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
.co-bulk-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13.5px;
}
.co-bulk-row:last-child { border-bottom: 0; }
.co-bulk-row:hover { background: var(--bg); }
.co-bulk-row input[type="checkbox"] { width: 16px; height: 16px; flex: none; }
.co-bulk-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.co-bulk-title { font-weight: 500; color: var(--ink); overflow-wrap: anywhere; }
.co-bulk-main .muted { font-size: 12px; }
.co-bulk-price { font-weight: 600; color: var(--ink); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* --- WS4: the read-only view, record result, history --------- */
.co-nextver {
  border: 1px solid var(--line); border-left: 3px solid var(--gold);
  border-radius: 10px; padding: 10px 14px; margin: 0 0 14px; background: #fff;
}
.co-nextver p { margin: 0; font-size: 13px; line-height: 1.55; }
.co-result {
  border: 1px solid var(--line); border-left: 3px solid #2e7d32;
  border-radius: 10px; padding: 10px 14px; margin: 0 0 14px; background: #fff;
}
.co-result p { margin: 0; font-size: 13px; line-height: 1.55; }
.co-view-card { margin-bottom: 16px; }
.co-frozen-note { font-weight: 400; font-size: 12px; }
.co-view-lines td .co-line-title { display: block; font-weight: 500; color: var(--ink); }
.co-view-lines td .co-line-desc { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.co-view-lines td .co-line-code { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.co-view-lines tr.is-credit td { color: #b3261e; }
.co-view-lines tr.is-credit td .co-line-title { color: #b3261e; }
.co-group-row td {
  font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); padding-top: 12px;
}
.co-view-totals { max-width: 420px; margin-left: auto; }
.co-view-grand { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 8px !important; }
.co-view-grand dt, .co-view-grand dd { font-size: 15px; font-weight: 700; }
.co-view-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 0 16px; }
.co-locked-note { font-size: 13px; }
.co-outcome-badge {
  border: 1px solid var(--line); border-left: 3px solid var(--gold);
  border-radius: 8px; padding: 8px 12px; font-size: 13px; margin: 10px 0;
}
/* wave184: the Invoicing card's just-created notice */
.co-inv-notice {
  border: 1px solid var(--line); border-left: 3px solid var(--gold);
  border-radius: 8px; padding: 8px 12px; font-size: 13px; margin: 10px 0;
}
.co-ver-block { border-top: 1px solid var(--line); padding: 10px 0 4px; }
.co-ver-block:first-of-type { border-top: 0; }
.co-ver-head { margin: 0 0 6px; font-size: 13.5px; font-weight: 600; color: var(--ink); }
.co-ver-head .muted { font-weight: 400; font-size: 12.5px; }
.co-send-row {
  display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center;
  font-size: 13px; padding: 5px 0 5px 14px; color: var(--ink);
}
.co-pdf-link { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; color: var(--ink); }
.co-pdf-missing { color: #b3261e; font-size: 12.5px; }
.co-events { list-style: none; margin: 6px 0 0; padding: 0; }
.co-events li {
  display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline;
  padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px;
}
.co-events li:last-child { border-bottom: 0; }
.co-ev-kind { font-weight: 600; color: var(--ink); }
.co-ev-note { color: var(--ink); }
.danger-text { color: #b3261e !important; }

/* ============================================================
   DW2 P08 — the CO register's search / status filter / Export
   bar and the plain contract-gate note. Structure in plain
   selectors (Navy appearance too); the light skin's
   .ds-filters rules style the controls.
   ============================================================ */
.co-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 14px; }
.co-filters input[type="search"] { flex: 1 1 260px; max-width: 460px; }
.co-filters .ds-push { margin-left: auto; }
/* The label names the select for assistive tech; the select's own first
 * option ("All statuses") names it on screen (Billdr's pattern). */
.co-filters > label { font-size: 0; line-height: 0; }
.co-filters input[type="search"], .co-filters select {
  min-height: 38px; padding: 0 12px; font: inherit; font-size: 14px; color: var(--ink);
  background: var(--card, #fff); border: 1px solid var(--line); border-radius: 8px;
}
.co-gate-note {
  border: 1px solid var(--line); border-left: 3px solid var(--gold);
  border-radius: 8px; padding: 9px 12px; font-size: 13px; margin: 0 0 14px;
}
body.skin-billdr #app .co-gate-note { border-color: var(--ds-warn-line); border-left-color: var(--ds-gold); background: var(--ds-warn-bg); color: var(--ds-warn-ink); }
