/* The bid desk. Everything general - cards, fields, tables, buttons, the dark
   mode - comes from app.css. Only what the bid desk adds is here: the two
   column layout, the pipeline list, the plan viewer and its measuring overlay. */

.desk {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

@media (max-width: 1040px) {
  .desk { grid-template-columns: 1fr; }
}

.eyebrow {
  margin: 0 0 4px;
  font-size: .7rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--orange);
}

/* ---- pipeline ---- */

.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }

.filters button {
  padding: 5px 11px;
  font-size: .8rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.filters button[aria-pressed="true"] {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
}

.pipeline { display: grid; gap: 8px; max-height: 58vh; overflow: auto; }

.bid-row {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.bid-row:hover { border-color: var(--orange); }
.bid-row[aria-current="true"] { border-left-color: var(--orange); background: var(--surface); }
.bid-row strong { display: block; margin-bottom: 3px; }

.bid-row .meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: .76rem;
  color: var(--muted);
}

.bid-row .due.soon { color: var(--danger); font-weight: 700; }
.bid-row .total { font-weight: 700; color: var(--ok-text); }

.tag {
  display: inline-block;
  font-size: .64rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
}

.tag.estimated, .tag.won { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok-text); }
.tag.lost, .tag.declined { background: var(--err-bg); border-color: var(--err-border); color: var(--err-text); }

/* ---- takeoff table ---- */

tr.off { opacity: .45; }

.method {
  font-size: .64rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
}

.method.measured, .method.sheet_text { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok-text); }

.no-cost { color: var(--danger); }

.qty-input { width: 96px; }

/* The unit cost names are long and the column is the one that has to stay
   readable - it is what the money is worked out from. The table scrolls
   sideways inside its wrapper rather than squeezing this down to a few
   characters. */
.cost-select { min-width: 210px; max-width: 280px; }
#takeoffRows { min-width: 0; }
.card .table-wrap table { min-width: 720px; }

/* ---- trade headings in the takeoff ---- */

tr.trade-head th {
  background: var(--surface-2);
  border-top: 2px solid var(--border);
  font-size: .72rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-weight: 800;
  color: var(--text);
}

/* ---- the full takeoff sheet ---- */

details.trade {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 0;
  margin-bottom: 8px;
  background: var(--surface);
}

details.trade > summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  padding: 10px 12px;
  color: var(--text);
  font-weight: 700;
}

details.trade > summary.has-lines { border-left: 3px solid var(--orange); border-radius: var(--radius) 0 0 var(--radius); }
details.trade > summary .trade-count { font-size: .74rem; color: var(--muted); font-weight: 500; }
details.trade[open] > summary { border-bottom: 1px solid var(--border); }

table.sheet-table { font-size: .84rem; }
table.sheet-table th, table.sheet-table td { padding: 5px 12px; }
table.sheet-table tr.on-bid { background: var(--ok-bg); }
table.sheet-table tr.locked td { color: var(--muted); }
table.sheet-table .rate { color: var(--muted); }

#sheetUsedOnly[aria-pressed="true"] { border-color: var(--orange); color: var(--orange); }

/* ---- where a number came from ---- */

.source {
  font-size: .64rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}

.source.learned { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok-text); }
.source.edited { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok-text); }
.source.suggested { background: var(--err-bg); border-color: var(--err-border); color: var(--err-text); }

/* A row of the estimate that rests on something weak enough to be worth
   checking before the number is sent. */
#provenanceRows tr.weak td { color: var(--err-text); }

#calibrationNote { margin-bottom: 12px; }

/* Both tables are built in script and dropped straight into these boxes, so
   the scrolling has to live on the box rather than on a wrapper that is not
   there. Without it the suggestion table runs off the side of the card. */
#calibrationJobs, #suggestions { overflow-x: auto; }
#calibrationJobs table, #suggestions table { margin-top: 10px; min-width: 640px; }
#suggestions .why { color: var(--muted); font-size: .78rem; max-width: 300px; }

/* ---- the headline numbers ---- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}

.stat small {
  display: block;
  font-size: .68rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 5px;
}

.stat strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.stat .range { display: block; font-size: .74rem; color: var(--muted); margin-top: 3px; }
.stat.headline strong { font-size: 1.6rem; color: var(--ok-text); }

/* ---- the plan viewer ---- */

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 26px;
  text-align: center;
  color: var(--muted);
  font-size: .9rem;
  cursor: pointer;
  background: var(--surface-2);
}

.dropzone.over { border-color: var(--orange); color: var(--text); }

.sheetbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.sheetbar select { flex: 1 1 240px; }
.sheetbar .scale { font-size: .78rem; color: var(--muted); }
.sheetbar .scale.missing { color: var(--danger); }

.viewer {
  position: relative;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  max-height: 74vh;
}

.viewer canvas { display: block; background: #fff; }
.viewer svg { position: absolute; inset: 0; pointer-events: none; }
.viewer.measuring canvas { cursor: crosshair; }
.viewer svg polyline, .viewer svg polygon { fill: rgba(255, 106, 19, .18); stroke: #ff6a13; stroke-width: 2; }
.viewer svg circle { fill: #fff; stroke: #ff6a13; stroke-width: 2; }

progress { width: 100%; height: 6px; }

details { margin-top: 12px; }
summary { cursor: pointer; font-size: .85rem; color: var(--muted); font-weight: 600; }

pre {
  font-size: .76rem;
  color: var(--muted);
  overflow-x: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
}

@media print {
  .bar, .filters, .pipeline, .dropzone, .viewer, button, #costsCard { display: none !important; }
  .desk { grid-template-columns: 1fr; }
}
