/* BIDR Connected - plan viewer, takeoff and markup (BidrPlans).
   Every class is prefixed bp-. UI colors come only from the host tokens (with fallbacks);
   the sheet itself stays white paper, and markup inks are fixed colors drawn on canvas. */

.bp-root {
  --bp-paper: var(--paper, #fff);
  --bp-mist: var(--mist, #f2f4f7);
  --bp-head: var(--head, #0a2248);
  --bp-body: var(--body, #42526a);
  --bp-rule: var(--rule, #c8ced6);
  --bp-rule-strong: var(--rule-strong, #5d6b80);
  --bp-gold: var(--gold, #d6ac4e);
  --bp-gold-text: var(--gold-text, #8c5f10);
  --bp-focus: var(--focus, #0a2248);
  --bp-card: var(--card, #fff);
  --bp-font: var(--font, "Assistant", "Segoe UI", system-ui, sans-serif);
  position: relative;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 320px;
  overflow: hidden;
  background: var(--bp-paper);
  color: var(--bp-body);
  border: 1px solid var(--bp-rule);
  border-radius: 2px;
  font-family: var(--bp-font);
  font-size: 14px;
  line-height: 1.35;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
.bp-root *,
.bp-root *::before,
.bp-root *::after { box-sizing: border-box; }
.bp-root [hidden] { display: none !important; }
.bp-root :focus-visible { outline: 2px solid var(--bp-focus); outline-offset: 1px; }
.bp-root :focus:not(:focus-visible) { outline: none; }

/* ---------- toolbars ---------- */
.bp-bar {
  display: flex;
  flex: none;
  align-items: center;
  gap: 2px;
  min-width: 0;
  padding: 4px 6px;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  background: var(--bp-paper);
  border-bottom: 1px solid var(--bp-rule);
  scrollbar-width: thin;
  scrollbar-color: var(--bp-rule) transparent;
  overscroll-behavior-x: contain;
}
.bp-opts {
  gap: 8px;
  height: 38px; /* fixed, so switching tools never shifts the sheet */
  font-size: 13px;
  background: var(--bp-mist);
}
.bp-btn {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  min-width: 32px;
  margin: 0;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 2px;
  background: transparent;
  color: var(--bp-head);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
}
.bp-btn:hover:not(:disabled) { background: var(--bp-mist); border-color: var(--bp-rule); }
.bp-btn:disabled { opacity: .4; cursor: default; }
.bp-btn[aria-pressed="true"],
.bp-btn[aria-pressed="true"]:hover:not(:disabled) {
  background: var(--bp-head);
  border-color: var(--bp-head);
  color: var(--bp-paper);
  box-shadow: inset 0 -3px 0 var(--bp-gold);
}
.bp-btn-sm { height: 28px; min-width: 28px; padding: 0 8px; font-size: 13px; }
.bp-btn-solid,
.bp-btn-solid:hover:not(:disabled) {
  background: var(--bp-head);
  border-color: var(--bp-head);
  color: var(--bp-paper);
}
.bp-btn-solid:hover:not(:disabled) { box-shadow: inset 0 -3px 0 var(--bp-gold); }
.bp-ico { display: block; flex: none; width: 18px; height: 18px; }
.bp-sep { flex: none; width: 1px; height: 22px; margin: 0 4px; background: var(--bp-rule); }
.bp-grow { flex: 1 1 auto; min-width: 4px; }

.bp-file {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 30ch;
  padding: 0 6px 0 2px;
  color: var(--bp-head);
  font-weight: 700;
}
.bp-file-name { overflow: hidden; text-overflow: ellipsis; }
.bp-page-select {
  flex: none;
  height: 32px;
  max-width: 150px;
  padding: 0 4px 0 8px;
  border: 1px solid var(--bp-rule);
  border-radius: 2px;
  background: var(--bp-paper);
  color: var(--bp-head);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.bp-page-select:disabled { cursor: default; opacity: .75; }
.bp-zoom { min-width: 54px; font-variant-numeric: tabular-nums; }
.bp-scale-val { font-weight: 700; }
.bp-scale-btn .bp-lbl { font-weight: 600; color: var(--bp-body); }
.bp-unset .bp-scale-val { color: var(--bp-gold-text); }
.bp-scale-ro { display: inline-flex; flex: none; align-items: center; gap: 6px; padding: 0 8px; color: var(--bp-head); }
.bp-panel-btn[aria-pressed="true"] .bp-lbl { color: inherit; }

.bp-swatches { display: inline-flex; flex: none; gap: 2px; }
.bp-swatch { min-width: 30px; padding: 0; }
.bp-swatch-dot {
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 2px;
  background: var(--bp-ink);
  box-shadow: 0 0 0 1px var(--bp-rule-strong);
}
.bp-swatch[aria-pressed="true"],
.bp-swatch[aria-pressed="true"]:hover:not(:disabled) {
  background: transparent;
  border-color: var(--bp-head);
  color: var(--bp-head);
  box-shadow: inset 0 -3px 0 var(--bp-gold);
}

/* tool options row */
.bp-opt-label { flex: none; color: var(--bp-head); font-weight: 700; }
.bp-input {
  min-width: 0;
  height: 28px;
  padding: 0 6px;
  border: 1px solid var(--bp-rule);
  border-radius: 2px;
  background: var(--bp-paper);
  color: var(--bp-head);
  font: inherit;
  font-size: 13px;
}
.bp-input:focus-visible { outline-offset: 0; }
.bp-label-input { flex: none; width: 170px; }
.bp-chips { display: inline-flex; flex: none; gap: 4px; }
.bp-chips:empty,
.bp-optwarn:empty { display: none; }
.bp-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 8px;
  border: 1px solid var(--bp-rule);
  border-radius: 2px;
  background: var(--bp-paper);
  color: var(--bp-head);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.bp-chip[aria-pressed="true"] { border-color: var(--bp-head); box-shadow: inset 0 -2px 0 var(--bp-gold); }
.bp-optwarn { flex: none; color: var(--bp-gold-text); font-weight: 600; }
.bp-hint { flex: none; color: var(--bp-body); }
.bp-linkbtn {
  -webkit-appearance: none;
  appearance: none;
  padding: 0 2px;
  border: 0;
  background: none;
  color: var(--bp-head);
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

/* ---------- sheet area ---------- */
.bp-main { position: relative; display: flex; flex: 1 1 auto; min-width: 0; min-height: 0; }
.bp-stage {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  background: var(--bp-mist);
  outline: none;
  cursor: default;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.bp-stage:focus-visible { outline: 2px solid var(--bp-focus); outline-offset: -2px; }
.bp-stage[data-cursor="hand"] { cursor: grab; }
.bp-stage[data-cursor="length"],
.bp-stage[data-cursor="area"],
.bp-stage[data-cursor="count"],
.bp-stage[data-cursor="pen"],
.bp-stage[data-cursor="arrow"],
.bp-stage[data-cursor="rect"],
.bp-stage[data-cursor="cloud"],
.bp-stage[data-cursor="calibrate"] { cursor: crosshair; }
.bp-stage[data-cursor="text"] { cursor: text; }
.bp-stage.bp-space { cursor: grab; }
.bp-stage.bp-grabbing { cursor: grabbing; }
.bp-world { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.bp-pagecanvas { position: absolute; left: 0; top: 0; display: block; transform-origin: 0 0; will-change: transform; }
.bp-ink { position: absolute; left: 0; top: 0; display: block; pointer-events: none; }

.bp-msg {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  background: var(--bp-mist);
  color: var(--bp-body);
  font-size: 15px;
  text-align: center;
}
.bp-msg-error .bp-msg-text { max-width: 46ch; color: var(--bp-head); font-weight: 600; }
.bp-spinner {
  flex: none;
  width: 18px;
  height: 18px;
  border: 2px solid var(--bp-rule);
  border-top-color: var(--bp-head);
  border-radius: 50%;
  animation: bp-spin .8s linear infinite;
}
@keyframes bp-spin { to { transform: rotate(360deg); } }

.bp-toast {
  position: absolute;
  left: 50%;
  top: 10px;
  z-index: 5;
  max-width: calc(100% - 24px);
  padding: 7px 12px;
  border-radius: 2px;
  background: var(--bp-head);
  color: var(--bp-paper);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -6px);
  transition: opacity .15s ease, transform .15s ease;
}
.bp-toast.bp-show { opacity: 1; transform: translate(-50%, 0); }
.bp-toast:empty { display: none; }

.bp-drawbar {
  position: absolute;
  left: 50%;
  bottom: 12px;
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: max-content;
  max-width: calc(100% - 16px);
  padding: 5px 6px 5px 12px;
  border: 1px solid var(--bp-rule-strong);
  border-radius: 2px;
  background: var(--bp-card);
  transform: translateX(-50%);
}
.bp-drawval { min-width: 0; color: var(--bp-head); font-weight: 700; font-variant-numeric: tabular-nums; }

.bp-textedit {
  position: absolute;
  z-index: 3;
  min-width: 80px;
  margin: 0;
  padding: 2px;
  overflow: hidden;
  border: 1px dashed var(--bp-rule-strong);
  border-radius: 2px;
  /* the note is typed onto the white sheet, so the editor mimics the sheet */
  background: rgba(255, 255, 255, .92);
  font-family: var(--bp-font);
  font-weight: 600;
  line-height: 1.25;
  resize: none;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}

/* ---------- side panel / bottom sheet ---------- */
.bp-panel {
  display: flex;
  flex: none;
  flex-direction: column;
  width: 300px;
  min-height: 0;
  background: var(--bp-card);
  border-left: 1px solid var(--bp-rule);
}
.bp-panel-head {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 6px 6px 12px;
  border-bottom: 1px solid var(--bp-rule);
}
.bp-panel-title { margin: 0; color: var(--bp-head); font-size: 15px; font-weight: 800; }
.bp-panel-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.bp-panel-foot {
  flex: none;
  max-height: 45%;
  overflow-y: auto;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--bp-rule-strong);
}
.bp-empty { margin: 12px; color: var(--bp-body); font-size: 13px; }
.bp-totals .bp-empty { margin: 0 0 10px; }
.bp-group { padding: 6px 10px 8px 12px; border-bottom: 1px solid var(--bp-rule); }
.bp-group-head { display: flex; align-items: center; gap: 8px; min-height: 28px; }
.bp-dot { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 2px; box-shadow: 0 0 0 1px var(--bp-rule-strong); }
.bp-group-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  color: var(--bp-head);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bp-group-kind { flex: none; color: var(--bp-body); font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.bp-group-total { flex: none; color: var(--bp-head); font-weight: 800; font-variant-numeric: tabular-nums; }
.bp-rows { margin: 2px 0 0; padding: 0; list-style: none; }
.bp-row { display: flex; align-items: center; gap: 4px; padding: 2px 0 2px 2px; }
.bp-row-sel { background: var(--bp-mist); box-shadow: inset 3px 0 0 var(--bp-gold); }
.bp-row-go { min-width: 40px; padding: 0 6px; color: var(--bp-body); font-variant-numeric: tabular-nums; }
.bp-row-label { flex: 1 1 auto; width: 0; }
.bp-row-name { flex: 1 1 auto; min-width: 0; overflow: hidden; color: var(--bp-head); text-overflow: ellipsis; white-space: nowrap; }
.bp-row-val { flex: none; color: var(--bp-head); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.bp-row-unset { color: var(--bp-gold-text); font-weight: 600; }
.bp-row-del { padding: 0 4px; color: var(--bp-body); }
.bp-totals-title { margin: 0 0 6px; color: var(--bp-body); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.bp-tot { width: 100%; margin: 0 0 10px; border-collapse: collapse; font-size: 14px; }
.bp-tot th,
.bp-tot td { padding: 4px 0; border-bottom: 1px solid var(--bp-rule); color: var(--bp-head); }
.bp-tot th { font-weight: 600; text-align: left; }
.bp-tot td { padding-left: 8px; font-weight: 800; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bp-warn { margin: 0 0 10px; color: var(--bp-gold-text); font-size: 12.5px; font-weight: 600; }
.bp-export { width: 100%; height: 36px; }

/* ---------- scale popover and calibrate dialog ---------- */
.bp-pop {
  position: absolute;
  z-index: 10;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--bp-rule-strong);
  border-radius: 2px;
  background: var(--bp-card);
}
.bp-pop-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  padding: 2px 4px 8px;
  border-bottom: 1px solid var(--bp-rule);
  color: var(--bp-head);
  font-weight: 800;
}
.bp-pop-cur { color: var(--bp-body); font-size: 13px; font-weight: 600; text-align: right; }
.bp-pop-item { justify-content: flex-start; width: 100%; height: 36px; }
.bp-pop-label { margin: 10px 4px 4px; color: var(--bp-body); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.bp-pop-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
.bp-pop-grid-wide { grid-template-columns: minmax(0, 1fr); }
.bp-pop-preset { justify-content: flex-start; border-color: var(--bp-rule); font-variant-numeric: tabular-nums; }
.bp-check { display: flex; align-items: center; gap: 8px; margin: 10px 4px 4px; color: var(--bp-head); font-weight: 600; cursor: pointer; }
.bp-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--bp-head); }

.bp-dlg-wrap {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: color-mix(in srgb, var(--bp-head) 22%, transparent);
}
.bp-dlg {
  width: min(400px, 100%);
  padding: 18px;
  border: 1px solid var(--bp-rule-strong);
  border-top: 3px solid var(--bp-gold);
  border-radius: 2px;
  background: var(--bp-card);
}
.bp-dlg-title { margin: 0 0 12px; color: var(--bp-head); font-size: 17px; font-weight: 800; }
.bp-field { display: grid; gap: 6px; color: var(--bp-head); font-weight: 600; }
.bp-field .bp-input { height: 38px; font-size: 16px; }
.bp-dlg-hint { margin: 6px 0 0; font-size: 13px; }
.bp-dlg-err { min-height: 1.2em; margin: 6px 0 0; color: var(--bp-gold-text); font-size: 13px; font-weight: 700; }
.bp-dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

.bp-sr {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- widths ---------- */
.bp-compact .bp-tools .bp-lbl { display: none; }
.bp-narrow .bp-lbl { display: none; }
.bp-narrow .bp-file { max-width: 12ch; }
.bp-narrow .bp-label-input { width: 130px; }
.bp-narrow .bp-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 6;
  width: auto;
  max-height: 64%;
  border-top: 2px solid var(--bp-head);
  border-left: 0;
}

@media (pointer: coarse) {
  .bp-btn { height: 40px; min-width: 40px; }
  .bp-btn-sm { height: 34px; min-width: 34px; }
  .bp-page-select { height: 40px; }
  .bp-input { height: 34px; font-size: 16px; }
  .bp-chip { height: 32px; }
  .bp-opts { height: 46px; }
  .bp-opts .bp-btn-sm { height: 34px; }
}
@media (prefers-reduced-motion: reduce) {
  .bp-spinner { animation-duration: 2.4s; }
  .bp-toast { transition: none; }
}
@media (forced-colors: active) {
  .bp-btn[aria-pressed="true"] { outline: 2px solid ButtonText; }
  .bp-swatch-dot { forced-color-adjust: none; }
}
