:root {
  --cv-red: #e31d23;
  --cv-dark: #1a1a1a;
  --toolbar-bg: linear-gradient(180deg, #fbfbfc 0%, #f0f2f5 100%);
  --toolbar-border: #d4d8df;
  --toolbar-chip: #ffffff;
  --toolbar-shadow: 0 8px 18px rgba(20, 24, 31, 0.12);
  --page-strip-height: 0px;
}

html, body { margin: 0; height: 100%; overflow: hidden; font-family: "Bahnschrift", "Trebuchet MS", "Segoe UI", sans-serif; }
[hidden] { display: none !important; }

#header { display: none; }

#crmWorkspaceBar {
  margin-top: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid #d6dce5;
  border-radius: 12px;
  box-shadow: 0 8px 18px rgba(18, 28, 45, 0.08);
}

.worksheet-status-banner {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1600;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 320px;
  max-width: min(460px, calc(100vw - 36px));
  padding: 14px 16px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
  backdrop-filter: blur(8px);
}

#measureActionBanner {
  bottom: 96px;
}

#roomBuilderBanner {
  position: absolute;
  top: 14px;
  left: 50%;
  right: auto;
  bottom: auto;
  transform: translateX(-50%);
  width: min(760px, calc(100vw - 36px));
  max-width: min(760px, calc(100vw - 36px));
  justify-content: space-between;
  z-index: 1800;
  pointer-events: auto;
}

#measureActionBanner.is-success .worksheet-status-spinner {
  animation: none;
  border-color: rgba(34, 197, 94, 0.18);
  border-top-color: #22c55e;
}

.worksheet-status-spinner {
  width: 18px;
  height: 18px;
  border: 3px solid rgba(227, 29, 35, 0.18);
  border-top-color: var(--cv-red);
  border-radius: 50%;
  flex: 0 0 auto;
  animation: worksheetStatusSpin 0.85s linear infinite;
}

.worksheet-status-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.worksheet-status-copy strong {
  color: #17202a;
  font-size: 13px;
  font-weight: 800;
}

.worksheet-status-copy span {
  color: #475569;
  font-size: 12px;
  line-height: 1.4;
}

.room-builder-banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.room-builder-banner-actions button {
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 8px;
}

@media (max-width: 900px) {
  #roomBuilderBanner {
    top: 10px;
    left: 18px;
    right: 18px;
    bottom: auto;
    transform: none;
    width: auto;
    max-width: none;
  }
}

@keyframes worksheetStatusSpin {
  to {
    transform: rotate(360deg);
  }
}

.workspace-card {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border: 1px solid #d6dce5;
  border-radius: 12px;
  box-shadow: none;
  padding: 10px 12px;
}

.workspace-card > div:first-child {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.workspace-heading,
.workspace-primary {
  margin: 0;
}

.workspace-actions {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  align-items: center;
}

.workspace-actions-primary {
  margin-left: auto;
  padding-left: 18px;
  border-left: 1px solid #dbe2ec;
  align-self: stretch;
  justify-content: center;
}

.workspace-actions button {
  min-width: 80px;
  height: 32px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 8px;
}

#measureEstimateTitleInput {
  min-width: 220px;
  max-width: 400px;
}


.workspace-heading {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  margin-bottom: 6px;
}

.workspace-primary {
  font-size: 18px;
  font-weight: 800;
  color: #17202a;
}

.workspace-secondary {
  margin-top: 4px;
  color: #5f6b7a;
}

.workspace-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.workspace-list {
  color: #5f6b7a;
  font-size: 0.95rem;
}

.workspace-list-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #e8edf3;
}

.workspace-list-item:last-child {
  border-bottom: 0;
}

#toolNav {
  position: fixed;
  top: 0;
  width: 100%;
  background: var(--toolbar-bg);
  display: block;
  padding: 6px 10px 5px;
  border-bottom: 1px solid var(--toolbar-border);
  box-shadow: 0 5px 14px rgba(20, 24, 31, 0.1);
  z-index: 1100;
  box-sizing: border-box;
}

.toolbar-nav-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-basis: 100%;
  width: 100%;
  padding: 0;
  margin-bottom: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

#toolbar {
  position: fixed;
  top: 58px;
  width: 100%;
  background: var(--toolbar-bg);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 8px;
  padding: 6px 10px 7px;
  border-bottom: 1px solid var(--toolbar-border);
  box-shadow: var(--toolbar-shadow);
  z-index: 1000;
  box-sizing: border-box;
  max-height: calc(100vh - 70px);
  overflow-y: auto;
  overflow-x: auto;
  scrollbar-width: auto;
  -ms-overflow-style: auto;
}

.toolbar-nav-group {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.toolbar-nav-group-tools {
  justify-content: flex-end;
}

.page-display {
  min-width: 88px;
  padding: 0 4px;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  color: #334155;
}

.page-display-interactive {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 98px;
  min-height: 32px;
}

.page-number-input {
  width: 46px;
  min-width: 46px;
  height: 24px;
  padding: 2px 6px;
  border: 1px solid #cfd6e0;
  border-radius: 8px;
  background: #fff;
  color: #0f172a;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.page-number-input:focus {
  outline: none;
  border-color: #c91f25;
  box-shadow: 0 0 0 3px rgba(201, 31, 37, 0.12);
}

.page-display-divider {
  color: #64748b;
  font-weight: 800;
}

.favorite-pages-select {
  min-width: 168px;
  max-width: 220px;
  min-height: 28px;
  padding: 0 26px 0 8px;
  border: 1px solid #d4dae4;
  border-radius: 5px;
  background: #fff;
  color: #213145;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
}

.favorite-pages-select:focus {
  outline: none;
  border-color: #c91f25;
  box-shadow: 0 0 0 3px rgba(201, 31, 37, 0.12);
}

.favorite-pages-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.workspace-menu-list-favorites {
  min-width: 280px;
}

.workspace-menu-list-favorites .favorite-pages-bar {
  margin-top: 0;
}

.favorite-page-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid #d6dce5;
  border-radius: 999px;
  background: #fff;
  color: #334155;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  min-height: 30px;
}

.favorite-page-chip.active {
  border-color: #c91f25;
  background: rgba(201, 31, 37, 0.08);
  color: #8f161c;
}

.favorite-page-chip-label {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.favorite-page-chip-page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  color: #475569;
  font-size: 10px;
  font-weight: 800;
}

.favorite-page-chip-edit,
.favorite-page-chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 0;
  background: rgba(15, 23, 42, 0.08);
  color: inherit;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.favorite-page-chip-edit {
  width: auto;
  min-width: 18px;
  padding: 0 6px;
  font-size: 10px;
}

.workspace-toolbar-controls-page {
  align-items: center;
}

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

#tabbar {
  display: flex;
  gap: 6px;
  padding: 4px 10px;
  position: fixed;
  top: 0;
  width: 100%;
  box-sizing: border-box;
  background: #fff;
  z-index: 11;
}

.tab-btn {
  border: 1px solid #ccc;
  background: #f8f8f8;
  padding: 6px 10px;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  font-weight: 600;
}
.tab-btn.active {
  background: #fff;
  border-bottom-color: #fff;
}

.tool-section {
  display: flex;
  flex-direction: column;
  padding: 7px 9px;
  border: 1px solid #d6dce5;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.88);
  min-width: 0;
  transition: box-shadow 140ms ease, transform 140ms ease;
}

.tool-section:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 10px rgba(20, 24, 31, 0.1);
}

.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  color: #3a4350;
  margin-bottom: 6px;
  padding: 2px 2px 4px;
  letter-spacing: 0.65px;
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  flex-wrap: wrap;
}

#toolbar > .tool-section:first-of-type > .tool-group:last-child,
#toolbar > .tool-section:first-of-type > .tool-group:nth-of-type(2),
#toolbar > .tool-section:first-of-type > .tool-group[style*="flex-wrap:wrap"] {
  display: none;
}

.tool-group.stacked {
  flex-direction: column;
  align-items: stretch;
  height: auto;
  gap: 4px;
}

.tool-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.measure-room-panel {
  width: 100%;
  border: 1px solid #d6dce5;
  border-radius: 10px;
  background: rgba(245, 247, 250, 0.95);
  padding: 8px;
  box-sizing: border-box;
}

.measure-room-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 11px;
  color: #233047;
}

.measure-room-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font-size: 11px;
  font-weight: 700;
}

.measure-room-list {
  display: grid;
  gap: 10px;
  color: #526074;
  font-size: 11px;
  line-height: 1.4;
}

.measure-room-page-group {
  display: grid;
  gap: 6px;
}

.measure-room-page-heading {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #475569;
}

.measure-room-page-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.measure-room-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid #d6dce5;
  color: #233047;
  cursor: pointer;
  line-height: 1;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease, opacity 120ms ease;
}

.measure-room-chip.is-visible {
  background: #fee2e2;
  border-color: #ef4444;
  color: #991b1b;
}

.measure-room-chip.is-hidden {
  background: #e2e8f0;
  border-color: #94a3b8;
  color: #64748b;
}

.measure-room-chip-count {
  color: inherit;
  font-weight: 700;
}

.measure-room-chip-state {
  padding: 1px 5px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.04em;
  background: rgba(255, 255, 255, 0.72);
}

/* collapsible toolbar sections */
.tool-section.collapsed .tool-group { display: none; }
.tool-section .section-label { cursor: pointer; user-select: none; }
.tool-section .section-label:hover { color: #111827; }
.tool-section .section-label::after { content: " [v]"; font-size: 10px; color: #6a7482; }
.tool-section.collapsed .section-label::after { content: " [>]"; }

/* Dynamic panel visibility based on active tool mode */
.tool-section.mode-hidden {
  display: none !important;
}

/* Group accents */
.measurement-group { background: linear-gradient(180deg, rgba(227, 29, 35, 0.08), rgba(227, 29, 35, 0.02)); }
.cabinet-group, .countertop-group, .bid-group { background: linear-gradient(180deg, rgba(18, 70, 130, 0.08), rgba(18, 70, 130, 0.02)); }

#toolbar .tool-section:nth-of-type(2) > .tool-group:first-of-type {
  display: none;
}


#toolbar button, #toolbar select, #toolbar input {
  padding: 5px 9px;
  cursor: pointer;
  border: 1px solid #bcc5d2;
  background: var(--toolbar-chip);
  font-weight: 600;
  font-size: 11px;
  color: #1d2530;
  border-radius: 7px;
  transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}
#toolNav button,
#toolNav select,
#toolNav input {
  padding: 5px 9px;
  cursor: pointer;
  border: 1px solid #bcc5d2;
  background: var(--toolbar-chip);
  font-weight: 600;
  font-size: 11px;
  color: #1d2530;
  border-radius: 7px;
  transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}
#toolbar button[data-icon]::before {
  display: none;
}
#toolbar select#unitSelect {
  flex: 0 0 88px;
  width: 88px;
  min-height: 30px;
  height: 30px;
  padding: 5px 9px;
  font-size: 11px;
}

#toolbar input#textSize {
  width: 50px;
  font-size: 11px;
}
#toolbar button:hover, #toolbar select:hover, #toolbar input:hover {
  border-color: #9dabbc;
  box-shadow: 0 2px 5px rgba(20, 24, 31, 0.08);
}
#toolNav button:hover, #toolNav select:hover, #toolNav input:hover {
  border-color: #9dabbc;
  box-shadow: 0 2px 5px rgba(20, 24, 31, 0.08);
}
#toolbar button:focus-visible, #toolbar select:focus-visible, #toolbar input:focus-visible {
  outline: none;
  border-color: var(--cv-red);
  box-shadow: 0 0 0 2px rgba(227, 29, 35, 0.2);
}
#toolNav button:focus-visible, #toolNav select:focus-visible, #toolNav input:focus-visible {
  outline: none;
  border-color: var(--cv-red);
  box-shadow: 0 0 0 2px rgba(227, 29, 35, 0.2);
}
#toolbar button.active { background: var(--cv-red); color: white; border-color: var(--cv-red); }
#toolNav button.active { background: var(--cv-red); color: white; border-color: var(--cv-red); }

/* Layer toggle buttons in nav bar - grey when off, red when on */
#toolNav .layer-toggle {
  background: #e2e8f0;
  color: #64748b;
  border-color: #94a3b8;
  box-shadow: none;
}
#toolNav .layer-toggle:hover {
  border-color: #64748b;
  color: #334155;
}
#toolNav .layer-toggle.active {
  background: var(--cv-red);
  color: white;
  border-color: var(--cv-red);
  box-shadow: 0 0 0 2px rgba(227, 29, 35, 0.16);
}

.primary-btn { background: var(--cv-red) !important; color: white !important; border: none !important; }
.ghost-btn {
  background: transparent;
  border: 1px solid #d0d6e0;
  color: #1a1f2c;
}
.chip-btn {
  border: 1px solid #c6ccd6;
  background: #fff;
  border-radius: 14px;
  padding: 4px 9px;
  font-size: 12px;
  cursor: pointer;
}
.toolbar-nav-group .chip-btn {
  border-radius: 12px;
  padding: 4px 8px;
}
.chip-btn.active {
  background: var(--cv-red);
  color: #fff;
  border-color: var(--cv-red);
}

body.toolbar-compact .tool-section {
  padding: 4px 5px;
  border-radius: 8px;
}

body.toolbar-compact #toolbar {
  gap: 4px;
  padding: 4px 8px 5px;
}

body.toolbar-compact.toolbar-top #toolbar {
  flex-wrap: nowrap;
  align-items: stretch;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 6px;
}

body.toolbar-compact.toolbar-top .tool-section {
  flex: 0 0 auto;
  min-width: fit-content;
}

body.toolbar-compact.toolbar-top .tool-group,
body.toolbar-compact.toolbar-top .toolbar-nav-group {
  flex-wrap: nowrap;
  gap: 3px;
}

body.toolbar-compact.toolbar-top .tool-group.stacked {
  flex-direction: row;
  align-items: center;
}

body.toolbar-compact.toolbar-top .tool-row {
  flex-wrap: nowrap;
}

body.toolbar-compact .section-label {
  justify-content: space-between;
  margin-bottom: 0;
  min-height: 20px;
  padding: 0 1px 2px;
  font-size: 9px;
}

body.toolbar-compact .section-label::after {
  content: " +";
  font-size: 11px;
}

body.toolbar-compact .tool-section:not(.collapsed) .section-label {
  margin-bottom: 4px;
}

body.toolbar-compact .tool-section:not(.collapsed) .section-label::after {
  content: " -";
}

body.toolbar-compact #toolbar button[data-icon] {
  min-width: 28px;
  padding: 4px 6px;
  font-size: 0;
}

body.toolbar-compact #toolbar button[data-icon]::before {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

body.toolbar-compact #prevPage::before { content: "\25C0"; }
body.toolbar-compact #nextPage::before { content: "\25B6"; }
body.toolbar-compact #zoomOut::before { content: "\2212"; }
body.toolbar-compact #zoomIn::before { content: "\002B"; }
body.toolbar-compact #resetZoom::before { content: "\2302"; }
body.toolbar-compact #togglePageStripBtn::before { content: "\2630"; }
body.toolbar-compact #openFileBtn::before { content: "\1F4C2"; }
body.toolbar-compact #saveMeasureBtn::before,
body.toolbar-compact #saveMeasureBtnSecondary::before { content: "\1F4BE"; }
body.toolbar-compact #saveMeasureAsRevisionBtn::before,
body.toolbar-compact #saveMeasureAsRevisionBtnSecondary::before { content: "\271A"; }
body.toolbar-compact #openSettingsBtn::before { content: "\2699"; }
body.toolbar-compact #rotateBtn::before { content: "\21BB"; }
body.toolbar-compact #snapshotBtn::before { content: "\2398"; }
body.toolbar-compact #toggleDimensionsBtn::before { content: "\27C2"; }
body.toolbar-compact #toggleCabinetsBtn::before { content: "\25A6"; }
body.toolbar-compact #toggleCountertopsBtn::before { content: "\25AD"; }
body.toolbar-compact #calibrateBtn::before { content: "\25CE"; }
body.toolbar-compact #measureBtn::before { content: "\2194"; }
body.toolbar-compact #roughBidBtn::before { content: "\25A5"; }
body.toolbar-compact #countertopBtn::before { content: "\25AF"; }
body.toolbar-compact #refreshPricingBtn::before { content: "\21BA"; }
body.toolbar-compact #undoBtn::before { content: "\21B6"; }
body.toolbar-compact #toggleMapBtn::before { content: "\2316"; }
body.toolbar-compact #darkModeBtn::before { content: "\25D0"; }

body.toolbar-compact #toolbar .ghost-btn[data-icon]::before,
body.toolbar-compact #toolbar .chip-btn[data-icon]::before {
  font-size: 10px;
}

body.toolbar-compact #toolbar button,
body.toolbar-compact #toolbar select,
body.toolbar-compact #toolbar input {
  padding: 3px 6px;
  border-radius: 6px;
  font-size: 10px;
}

body.toolbar-compact .tool-group {
  gap: 3px;
  min-height: 26px;
}

body.toolbar-compact .tool-row {
  gap: 4px;
}

body.toolbar-compact #toolbar select,
body.toolbar-compact #toolbar input,
body.toolbar-compact #toolbar label {
  font-size: 10px;
}

/* Page strip (thumbnail overview) */
#pageStrip {
  position: fixed;
  top: 70px;
  left: 0;
  right: 0;
  margin: 0 auto;
  padding: 8px 10px;
  max-width: 1200px;
  background: #f7f9fb;
  border: 1px solid #dce3ed;
  border-radius: 10px;
  box-shadow: 0 6px 14px rgba(0,0,0,0.06);
  z-index: 900;
}
#pageStripList {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.page-thumb {
  display: grid;
  gap: 6px;
  border: 1px solid #cfd6e0;
  background: #fff;
  border-radius: 8px;
  padding: 6px;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(0,0,0,0.05);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.page-thumb img {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid #e4e8f0;
  border-radius: 6px;
  background: #fafbfd;
}
.page-thumb span {
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  color: #334155;
}
.page-thumb.active {
  border-color: #3b82f6;
  box-shadow: 0 4px 10px rgba(59,130,246,0.2);
}
.page-thumb.loading {
  justify-content: center;
  align-items: center;
  font-size: 12px;
  color: #556070;
}
.calib-status {
  appearance: none;
  cursor: pointer;
  font-size: 10px;
  font-weight: 800;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid #b8c2d0;
  background: #eef1f5;
  color: #394a5f;
  white-space: nowrap;
}
.calib-status.active {
  border-color: var(--cv-red);
  background: rgba(227, 29, 35, 0.12);
  color: #8d1318;
}
.calib-status:hover {
  box-shadow: 0 2px 5px rgba(20, 24, 31, 0.08);
  transform: translateY(-1px);
}
.calib-status.calibrated {
  border-color: #2f8f4e;
  background: #e6f6eb;
  color: #1d6f38;
}
.calib-status.uncalibrated {
  border-color: #b78d23;
  background: #fff7e1;
  color: #7a5710;
}
#toolNav .calib-status.calibrated.active {
  border-color: #2f8f4e;
  background: #e6f6eb;
  color: #1d6f38;
  box-shadow: 0 0 0 2px rgba(47, 143, 78, 0.16);
}
#toolNav .calib-status.uncalibrated.active {
  border-color: #b78d23;
  background: #fff7e1;
  color: #7a5710;
  box-shadow: 0 0 0 2px rgba(183, 141, 35, 0.16);
}

#viewport {
  position: fixed;
  top: calc(58px + var(--page-strip-height));
  left: 0; right: 0; bottom: 0;
  overflow: auto; background: #444;
  z-index: 100;
}
#toolNav .toolbar-nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: nowrap;
  padding: 8px;
}

.toolbar-nav-group-box {
  background: #f8f9fb;
  border: 1px solid #d6dce5;
  border-radius: 8px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  min-width: 180px;
  width: auto;
}

.toolbar-nav-group-title {
  font-size: 10px;
  font-weight: 700;
  color: #4b5563;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.toolbar-page-box {
  flex: 1;
  align-items: center;
}

.toolbar-tools-box,
.toolbar-filters-box {
  justify-content: flex-end;
}

#toolNav button,
#toolNav select,
#toolNav input {
  white-space: nowrap;
}

.toolbar-left #toolbar {
  width: 184px;
  top: 58px;
  height: 30vh;
}
.toolbar-left #roughBidTotalsContainer {
  position: fixed;
  top: calc(58px + 30vh + 2px);
  left: 0;
  width: 184px;
  bottom: 0;
  overflow-y: auto;
  padding: 10px;
  background: #fff;
  border-right: 1px solid #d6dce5;
}
.toolbar-left #viewport { left: 184px; }

.toolbar-right #toolbar {
  width: 184px;
  top: 58px;
  height: 30vh;
}
.toolbar-right #roughBidTotalsContainer {
  position: fixed;
  top: calc(58px + 30vh + 2px);
  right: 0;
  width: 184px;
  bottom: 0;
  overflow-y: auto;
  padding: 10px;
  background: #fff;
  border-left: 1px solid #d6dce5;
}
.toolbar-right #viewport { right: 184px; }

.toolbar-top #roughBidTotalsContainer {
  position: fixed;
  top: calc(58px + var(--page-strip-height));
  left: 0;
  width: 184px;
  max-height: calc(100vh - 58px);
  overflow-y: auto;
  padding: 10px;
  background: #fff;
  border-right: 1px solid #d6dce5;
}

.side-panel {
  box-sizing: border-box;
  background: #fff;
  border: 1px solid #d6dce5;
  border-radius: 10px;
  margin: 8px;
}
.side-panel-title {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.toolbar-top #toolNav { width: 100%; }
.toolbar-top #toolbar { width: 100%; }
.toolbar-top #toolbar {
  max-height: 70vh;
  overflow-y: auto;
  overflow-x: auto;
}
.toolbar-left #toolbar {
  width: 184px;
  left: 0;
  top: 58px;
  flex-direction: column;
  align-items: stretch;
  overflow-y: auto;
  overflow-x: hidden;
  height: 30vh;
  padding: 10px 10px 10px;
  background: #ffffff;
  border-right: 1px solid #d6dce5;
}
.toolbar-left #roughBidTotalsContainer {
  position: fixed;
  top: calc(58px + 30vh + 2px);
  left: 0;
  width: 184px;
  bottom: 0;
  overflow-y: auto;
  padding: 10px;
  background: #fff;
  border-right: 1px solid #d6dce5;
}
.toolbar-left #viewport {
  left: 184px;
  top: 58px;
}
.toolbar-right #toolbar {
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 8px;
  flex-wrap: wrap;
}
.toolbar-left .toolbar-nav-group,
.toolbar-right .toolbar-nav-group {
  width: auto;
}
.toolbar-left .toolbar-nav-group-tools,
.toolbar-right .toolbar-nav-group-tools {
  justify-content: flex-start;
}
.toolbar-left #viewport { left: 184px; }
.toolbar-right #toolbar {
  width: 184px;
  right: 0;
  left: auto;
  top: 58px;
  flex-direction: column;
  align-items: stretch;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: calc(100vh - 10px);
  padding: 10px 10px 18px;
  background: #ffffff;
  border-left: 1px solid #d6dce5;
}
.toolbar-right #viewport { right: 184px; }
.toolbar-left #viewport { left: 184px; }

/* Side-docked comfort: let groups wrap and buttons use full width without widening bar */
.toolbar-left .tool-group,
.toolbar-right .tool-group {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}
.toolbar-left #toolbar button,
.toolbar-right #toolbar button,
.toolbar-left #toolbar select,
.toolbar-right #toolbar select,
.toolbar-left #toolbar input,
.toolbar-right #toolbar input {
  width: 100%;
  max-width: 100%;
  white-space: normal;
}
.toolbar-left .tool-row,
.toolbar-right .tool-row {
  flex-wrap: wrap;
  width: 100%;
}
.toolbar-left .tool-group.stacked .tool-row,
.toolbar-right .tool-group.stacked .tool-row {
  flex-direction: row;
}
.toolbar-left .tool-section,
.toolbar-right .tool-section {
  width: 100%;
  gap: 6px;
}

#canvas-container {
  position: relative;
  display: block;
  margin: 0 auto;
  background: white;
  box-shadow: 0 0 20px rgba(0,0,0,0.4);
  transform-origin: top left;
}

.dark-mode { filter: invert(0.9) hue-rotate(180deg); background: #111 !important; }
.dark-mode #overlayCanvas { filter: invert(1) hue-rotate(180deg); }

#pdfCanvas, #overlayCanvas { position: absolute; top: 0; left: 0; }
#overlayCanvas { cursor: crosshair; }

#miniMapContainer {
  position: relative !important;
  inset: auto !important;
  width: 100%;
  max-width: 100%;
  min-height: 0;
  border: 2px solid var(--cv-red);
  border-radius: 12px;
  z-index: auto;
  background: white;
  overflow: hidden;
}
#miniMapCanvas { width: 100%; display: block; cursor: move; }
#miniMapWindow { position: absolute; border: 1px solid var(--cv-red); background: rgba(227, 29, 35, 0.2); pointer-events: none; }

#hotkey-legend { position: fixed; bottom: 25px; right: 25px; background: rgba(26, 26, 26, 0.9); color: white; padding: 12px; border-radius: 8px; font-size: 11px; z-index: 3000; border-left: 4px solid var(--cv-red); }
.toolbar-left #hotkey-legend { right: 25px; left: auto; }
.toolbar-right #hotkey-legend { right: 260px; }

/* Measurement workspace shell refresh */
body {
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(227, 29, 35, 0.08), transparent 28%),
    linear-gradient(180deg, #eef2f7 0%, #dde5ee 100%);
}

#measureAppShell {
  height: 100vh;
  padding: 8px;
  box-sizing: border-box;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
}

#measureAppMain {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 10px;
  height: 100%;
  min-height: 0;
}

#measureSidebar {
  display: grid;
  grid-template-rows: minmax(0, 1fr) minmax(220px, 0.9fr);
  gap: 12px;
  min-height: 0;
  position: relative;
  isolation: isolate;
}

#measureCenterStage {
  display: grid !important;
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
  min-height: 0;
}

#crmWorkspaceBar {
  margin-top: 0 !important;
  padding: 0 !important;
  grid-template-columns: minmax(0, 1fr);
}

.workspace-card {
  border-radius: 7px;
  border: 1px solid #d7dde7;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 18px 40px rgba(19, 31, 52, 0.08);
  padding: 8px 10px;
}

.workspace-card-primary {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 8px;
}

.workspace-project {
  min-width: 0;
  flex: 0 1 460px;
}

.workspace-heading {
  font-size: 9px;
  margin-bottom: 3px;
}

.workspace-primary {
  font-size: 14px;
}

.workspace-secondary {
  margin-top: 2px;
  font-size: 12px;
}

.workspace-info-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.workspace-info-row + .workspace-info-row {
  margin-top: 4px;
}

.workspace-field-label {
  flex: 0 0 auto;
  min-width: 78px;
  font-size: 9px;
  font-weight: 800;
  color: #5b6878;
}

.workspace-field-value {
  min-width: 0;
  font-size: 12px;
  font-weight: 700;
  color: #243447;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace-project-row {
  align-items: center;
}

.workspace-title-input {
  width: min(420px, 100%);
  margin-top: 0;
  border: 1px solid #d2dae5;
  border-radius: 5px;
  padding: 5px 7px;
  font-size: 10px;
  font-weight: 700;
  color: #243447;
  background: #fff;
  flex: 1 1 220px;
  min-width: 0;
}

.workspace-actions {
  align-self: flex-start;
  margin-top: 0;
  gap: 6px;
  display: flex;
  flex-direction: row;
  align-items: center;
  flex: 0 0 auto;
}

.workspace-menu {
  position: relative;
  align-self: center;
}

.workspace-menu summary {
  list-style: none;
  cursor: pointer;
  border: 1px solid #d4dae4;
  border-radius: 5px;
  height: 24px;
  padding: 0 10px;
  font-size: 9px;
  font-weight: 800;
  background: #f7f9fc;
  color: #213145;
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
}

.workspace-menu summary::-webkit-details-marker {
  display: none;
}

.workspace-menu[open] summary {
  border-color: #e31d23;
  color: #8d1318;
}

.workspace-menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 12px);
  min-width: 180px;
  display: grid;
  gap: 6px;
  padding: 8px;
  background: #fff;
  border: 1px solid #d7dde7;
  border-radius: 6px;
  box-shadow: 0 18px 40px rgba(19, 31, 52, 0.14);
  z-index: 1200;
}

.workspace-menu-list button {
  width: 100%;
  justify-content: flex-start;
}

.workspace-toolbar {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  align-items: center;
  min-width: 0;
  flex: 1 1 auto;
  overflow-x: auto;
  overflow-y: visible;
  padding: 0 0 2px;
  scrollbar-width: thin;
}

.workspace-toolbar-group {
  display: grid;
  gap: 2px;
  padding: 3px 5px;
  border: 1px solid #dbe2ec;
  border-radius: 5px;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.98), rgba(240, 244, 248, 0.95));
  flex: 0 0 auto;
  align-self: stretch;
  align-content: start;
}

.workspace-toolbar-title {
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #5b6878;
  line-height: 1;
  text-align: center;
}

.workspace-toolbar-controls {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 3px;
  min-height: 32px;
}

.workspace-toolbar-controls #textSize {
  width: 40px;
  min-width: 40px;
  height: 24px;
  box-sizing: border-box;
}

#measureCanvasShell {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
  border: 1px solid #ced7e2;
  border-radius: 14px;
  background: rgba(246, 249, 252, 0.84);
  box-shadow: 0 20px 40px rgba(24, 36, 58, 0.1);
  overflow: hidden;
}

#pageStrip {
  position: absolute !important;
  top: 70px !important;
  left: 20px !important;
  right: 20px !important;
  z-index: 15;
}

#viewport {
  position: relative !important;
  top: auto !important;
  right: auto !important;
  bottom: auto !important;
  left: auto !important;
  min-height: 0;
  overflow: auto;
  background:
    linear-gradient(180deg, rgba(203, 212, 224, 0.35), rgba(154, 166, 184, 0.18)),
    #c5cfdb;
  padding: 18px 18px 96px;
}

#pricingSheetPanel {
  min-height: 0;
  overflow: auto;
  padding: 12px;
  background:
    linear-gradient(180deg, rgba(248, 251, 254, 0.98), rgba(239, 244, 249, 0.96));
}

.pricing-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.pricing-sheet-kicker {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #64748b;
}

#pricingSheetPanel h2 {
  margin: 4px 0 0;
  font-size: 20px;
  line-height: 1.1;
  color: #162335;
}

.pricing-summary-panel {
  min-height: calc(100% - 72px);
  border-width: 1px;
  border-color: #d7dde7;
  box-shadow: 0 18px 40px rgba(19, 31, 52, 0.08);
}

#canvas-container {
  margin: 0 auto 40px;
  border-radius: 10px;
}

#toolbar {
  position: static !important;
  top: auto !important;
  right: auto !important;
  left: auto !important;
  width: 100% !important;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr);
  align-items: stretch !important;
  gap: 8px;
  padding: 8px !important;
  border: 1px solid #d7dde7;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96) !important;
  box-shadow: 0 18px 40px rgba(19, 31, 52, 0.08);
  position: relative !important;
  z-index: 1;
}

#inspectorModeSwitch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(255, 255, 255, 0.98);
  padding-bottom: 4px;
}

#inspectorModeSwitch button {
  min-height: 26px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  font-size: 9px;
  font-weight: 800;
  justify-content: center;
}

#toolbarInspectorSections {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  gap: 8px;
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding-right: 2px;
  width: 100%;
  min-width: 0;
  align-self: stretch;
}

#toolbar .tool-section {
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
  border-radius: 5px;
  padding: 6px;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.98), rgba(240, 244, 248, 0.95));
  border: 1px solid #dbe2ec;
  box-shadow: none;
  display: flex !important;
  flex-direction: column;
  align-items: stretch;
}

#toolbar .tool-section.mode-hidden,
#toolbar .tool-section[hidden] {
  display: none !important;
}

#toolbar .tool-section.collapsed .tool-group {
  display: none;
}

#toolbar .section-label {
  margin-bottom: 4px;
  font-size: 8px;
  letter-spacing: 0.08em;
}

#toolbar .tool-group {
  display: flex !important;
  gap: 5px;
}

#toolbar .measurement-group {
  min-height: 86px;
}

#toolbar .measurement-group .tool-group,
#toolbar .measurement-group .tool-row {
  width: 100%;
}

#toolbar .measurement-group .tool-group.stacked {
  align-items: stretch;
}

#toolbar .measurement-group .tool-row {
  display: flex;
  flex-wrap: nowrap;
  min-width: 0;
}

#toolbar .measurement-group .tool-row > * {
  min-width: 0;
  max-width: none;
}

#toolbar .measurement-group .tool-row > button,
#toolbar .measurement-group .tool-row > select {
  flex: 1 1 0;
  width: auto;
}

#toolbar .measurement-group .tool-row:first-child > button {
  flex: 1 1 0;
}

#toolbar .measurement-group .tool-row:first-child > select {
  flex: 0 0 88px;
  width: 88px;
}

#toolbar .measurement-group .tool-row:nth-child(2) > button {
  flex: 1 1 100%;
}

#toolbar .tool-row {
  gap: 5px;
}

#sidebarUtilityPanel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  padding: 8px;
  border: 1px solid #d7dde7;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 40px rgba(19, 31, 52, 0.08);
  overflow: hidden;
  position: relative;
  z-index: 3;
}

#sidebarUtilitySwitch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

#sidebarUtilitySwitch button {
  min-height: 26px;
  font-size: 9px;
  font-weight: 800;
}

#sidebarSummaryPanel,
#sidebarMapPanel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

.sidebar-summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-summary-header .side-panel-title {
  margin-bottom: 0;
}

.sidebar-summary-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.sidebar-summary-list {
  min-height: 0;
  overflow: auto;
  border: 1px solid #dbe2ec;
  border-radius: 5px;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.98), rgba(240, 244, 248, 0.95));
  padding: 8px;
  font-size: 10px;
  color: #334155;
}

.sidebar-summary-list p {
  margin: 0;
}

.sidebar-summary-rooms {
  display: grid;
  gap: 8px;
}

.sidebar-summary-room {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e2e8f0;
}

.sidebar-summary-room-name {
  min-width: 0;
  font-weight: 700;
}

.sidebar-summary-room-price {
  font-weight: 700;
  white-space: nowrap;
}

.sidebar-summary-room:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.sidebar-summary-total {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #d7dde7;
  font-weight: 800;
}

.summary-row-hidden {
  opacity: 0.58;
}

#toolbar button,
#toolbar select,
#toolbar input,
.workspace-actions button,
.workspace-toolbar-controls button,
.workspace-toolbar-controls input,
.workspace-menu summary,
.workspace-menu-list button,
.sidebar-summary-header button {
  min-height: 24px;
}

.workspace-actions button,
.workspace-toolbar-controls button,
.workspace-menu-list button,
.sidebar-summary-header button {
  border: 1px solid #c9d2de;
  background: #fff;
  color: #213145;
  border-radius: 5px;
  padding: 4px 7px;
  font-size: 9px;
  font-weight: 800;
  cursor: pointer;
}

#toolbar button,
#toolbar select,
#toolbar input,
.workspace-toolbar-controls button,
.workspace-toolbar-controls input,
.page-display,
.sidebar-summary-header button {
  font-size: 9px;
}

#toolbar input[type="text"],
#toolbar select,
#toolbar input[type="number"] {
  flex: 1 1 120px;
  min-width: 0;
}

.workspace-toolbar-controls input,
.workspace-toolbar-controls button {
  white-space: nowrap;
}

.workspace-toolbar-controls .page-display {
  min-width: 68px;
  padding: 0 2px;
  text-align: center;
}

.tool-inline-label {
  font-size: 10px;
  font-weight: 800;
  color: #3b4b60;
}
#toolbar .tool-section:nth-of-type(2) > .tool-group:first-of-type,
#toolbar .tool-section.measurement-group:not(.collapsed):has(#calibrateBtn),
#toolbar .tool-section.measurement-group.collapsed:has(#calibrateBtn) {
  display: flex !important;
}

.rough-bid-totals-card {
  background: #ffffff;
  border: 1px solid #d7dde7;
  border-radius: 12px;
  box-shadow: 0 8px 18px rgba(19, 31, 52, 0.08);
  padding: 12px;
  margin-bottom: 0;
}

.rough-bid-totals-card .summary-card-heading {
  font-size: 13px;
  font-weight: 800;
  color: #22324c;
  margin-bottom: 8px;
}

.rough-bid-totals-card .summary-card-body p {
  margin: 0;
  font-size: 12px;
  color: #4b5563;
}

.summary-panel {
  position: static;
  left: auto;
  bottom: auto;
  z-index: auto;
  width: 100%;
  margin-top: 12px;
  box-sizing: border-box;
}

#hotkey-legend {
  position: fixed !important;
  right: 16px !important;
  bottom: 16px !important;
  padding: 8px 10px;
  font-size: 10px;
  z-index: 5000;
}

body.toolbar-left #toolbar,
body.toolbar-right #toolbar,
body.toolbar-top #toolbar,
body.toolbar-left #viewport,
body.toolbar-right #viewport,
body.toolbar-top #viewport {
  left: auto !important;
  right: auto !important;
  width: auto !important;
}

body.toolbar-left #measureSidebar #toolbar,
body.toolbar-right #measureSidebar #toolbar,
body.toolbar-top #measureSidebar #toolbar {
  width: 100% !important;
  max-width: 100%;
  justify-self: stretch;
}

body.toolbar-compact #toolbar {
  gap: 6px;
}

body.toolbar-compact #toolbar .tool-section {
  padding: 8px;
}

body.toolbar-compact #toolbar button[data-icon] {
  font-size: 11px;
  min-width: auto;
}

body.toolbar-compact #toolbar button[data-icon]::before {
  display: none;
}

@media (max-width: 1400px) {
  #measureAppMain {
    grid-template-columns: 250px minmax(0, 1fr);
  }
}

@media (max-width: 1100px) {
  #measureAppShell {
    padding: 12px;
  }

  #measureAppMain {
    grid-template-columns: 1fr;
  }

  #measureSidebar {
    grid-template-rows: auto auto;
  }

  #toolbar {
    order: -1;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
    max-height: 42vh !important;
  }

  #inspectorModeSwitch {
    grid-template-columns: 1fr;
  }

  #toolbarInspectorSections {
    flex: 1 1 auto;
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .workspace-card-primary {
    flex-direction: column;
    align-items: stretch;
  }

  #crmWorkspaceBar {
    grid-template-columns: 1fr;
  }

  .workspace-toolbar {
    flex-wrap: wrap;
    overflow: visible;
  }
}

.custom-menu {
  position: fixed;
  background: white;
  border: 1px solid #ccc;
  box-shadow: 2px 2px 10px rgba(0,0,0,0.2);
  z-index: 10000;
  padding: 5px 0;
  border-radius: 4px;
  min-width: 180px;
  max-height: min(78vh, 620px);
  overflow-y: auto;
  overflow-x: hidden;
}
.custom-menu ul { list-style: none; margin: 0; padding: 0; }
.custom-menu li { padding: 6px 12px; cursor: pointer; font-size: 12px; }
.custom-menu li:hover { background: #f0f0f0; }
.menu-label { background: #eee; font-size: 10px; font-weight: bold; padding: 4px 12px; color: #666; cursor: default; }
.menu-save-row {
  padding: 10px 12px 12px !important;
  cursor: default !important;
  background: #fafbfc;
  border-top: 1px solid #e2e8f0;
}
.menu-save-row:hover {
  background: #fafbfc !important;
}
.menu-save-btn {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  background: #233047;
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.menu-save-btn:hover {
  background: #182132;
}

.edge-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-top: 5px; }
.edge-btn { border: 1px solid #ccc; padding: 5px; font-size: 10px; cursor: pointer; background: #eee; text-align: center; font-weight: bold; }
.edge-btn.state-polished { background: #ff8f1f !important; color: #2d1a00; border-color: #d66f00; }
.edge-btn.state-splash { background: #9b4dca !important; color: white; border-color: #7a2daf; }

.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 5000; }
.modal-content { background: white; padding: 25px; border-radius: 8px; width: 350px; }
.room-builder-modal-content {
  width: min(760px, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  border-radius: 14px;
}
.room-builder-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.room-builder-grid label,
.room-builder-checklist label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #334155;
}
.room-builder-grid input,
.room-builder-grid select,
.room-builder-checklist input,
.room-builder-checklist select {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
}
.room-builder-checklist {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
}
.room-builder-checklist-title {
  font-size: 12px;
  font-weight: 800;
  color: #1e293b;
  margin-bottom: 10px;
}
.room-builder-checklist-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
}
.room-builder-checklist-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.room-builder-checklist-grid label {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}
.room-builder-checklist-grid input[type="checkbox"] {
  width: auto;
  margin: 0;
  padding: 0;
}
.room-builder-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}
.room-builder-helper {
  margin: 8px 0 0;
  color: #64748b;
  font-size: 12px;
  line-height: 1.45;
}
.price-modal-content {
  width: min(1200px, 96vw) !important;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#priceModal .price-main {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(520px, 1.3fr);
  gap: 18px;
  min-height: 0;
  overflow: hidden;
}
#settingsTabPanel {
  max-height: calc(100vh - 140px);
  overflow: auto;
  padding-right: 8px;
}
#settingsTabPanel .price-main {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(520px, 1.3fr);
  gap: 18px;
  min-height: 0;
}
#settingsTabPanel .price-col {
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}
#settingsTabPanel .price-col + .price-col {
  border-left: 1px solid #d6d6d6;
  padding-left: 18px;
}
#priceModal .price-col {
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}
#priceModal .price-col + .price-col {
  border-left: 1px solid #d6d6d6;
  padding-left: 18px;
}
#factorPriceContainer, #ctMaterialContainer {
  max-height: none !important;
  overflow: auto !important;
}
#ctMaterialContainer {
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 8px;
  background: #fafafa;
}
.stone-pricing-table {
  overflow: visible;
}
.stone-pricing-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1.6fr) repeat(5, minmax(82px, 0.75fr)) 28px;
  gap: 6px;
  align-items: center;
  min-width: 760px;
}
.stone-pricing-grid input {
  width: 100%;
  box-sizing: border-box;
}
.stone-pricing-grid-header {
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 6px;
  color: #2f3c4f;
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f7f9fc;
  padding: 6px 0;
  border-bottom: 1px solid #d7dde6;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.03);
}
.stone-pricing-row {
  margin-bottom: 5px;
}
.stone-total-input {
  background: #f1f3f6;
}

@media (max-width: 1050px) {
  #priceModal .price-main {
    grid-template-columns: 1fr;
  }
  #priceModal .price-col + .price-col {
    border-left: 0;
    padding-left: 0;
    border-top: 1px solid #d6d6d6;
    margin-top: 10px;
    padding-top: 10px;
  }
  #settingsTabPanel .price-main {
    grid-template-columns: 1fr;
  }
  #settingsTabPanel .price-col + .price-col {
    border-left: 0;
    padding-left: 0;
    border-top: 1px solid #d6d6d6;
    margin-top: 10px;
    padding-top: 10px;
  }
}

.summary-panel {
  position: static;
  bottom: auto;
  right: auto;
  background: white;
  border: 2px solid var(--cv-red);
  padding: 10px;
  font-size: 11px;
  max-height: none;
  min-height: 0;
  overflow: auto;
  z-index: auto;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  box-shadow: -2px 2px 10px rgba(0,0,0,0.12);
}

.summary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.summary-header strong {
  display: block;
  font-size: 14px;
}

.summary-grand {
  display: block;
  margin-top: 3px;
  color: #b22222;
  font-weight: 700;
}

.summary-toggle-btn,
.summary-bulk-btn {
  border: 1px solid #c9d2df;
  background: #f8fafc;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.summary-toggle-btn:disabled,
.summary-bulk-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.summary-room-stack {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.summary-room-card {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 8px 10px;
  background: #fbfcfe;
}

.summary-room-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.summary-room-name {
  min-width: 0;
}

.summary-room-total {
  white-space: nowrap;
  gap: 8px;
}

.summary-room-meta {
  margin-top: 4px;
  color: #475569;
}

.summary-bulk-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.summary-bulk-input,
.summary-inline-input,
.summary-inline-select {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 11px;
  background: #fff;
}

.summary-bulk-input {
  flex: 1;
}

.summary-inline-input {
  width: 100%;
  box-sizing: border-box;
}

.summary-inline-input-small {
  width: 60px;
}

.summary-inline-select {
  max-width: 160px;
}

.summary-grid-wrap {
  overflow: auto;
}

.summary-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.summary-grid th,
.summary-grid td {
  border-bottom: 1px solid #e2e8f0;
  padding: 6px;
  vertical-align: top;
}

.summary-grid th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  z-index: 1;
}

.summary-num {
  text-align: right;
  white-space: nowrap;
}

.summary-empty {
  color: #64748b;
  text-align: center;
  padding: 12px;
}

#roughBidTableContainer table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

#roughBidTableContainer th, #roughBidTableContainer td {
  padding: 8px;
  text-align: left;
  border-bottom: 1px solid #ddd;
}

@media (max-width: 1500px) {
  #toolbar {
    gap: 6px;
    padding: 7px 8px 8px;
  }

  .tool-section {
    padding: 6px 8px;
  }

  #toolbar button, #toolbar select, #toolbar input {
    font-size: 10px;
    padding: 4px 8px;
  }
}

@media (max-width: 1150px) {
  #toolbar {
    max-height: 190px;
    overflow-y: auto;
    align-items: flex-start;
  }

  .tool-section {
    min-width: 300px;
    flex: 1 1 330px;
  }

  .tool-row {
    flex-wrap: wrap;
  }
}

@media (max-width: 860px) {
  #toolbar {
    max-height: 240px;
  }

  .tool-section {
    min-width: 100%;
    flex: 1 1 100%;
  }

  .tool-group {
    gap: 5px;
  }

  .section-label {
    font-size: 9px;
  }
}

body.toolbar-left #measureSidebar #toolbar .tool-section,
body.toolbar-right #measureSidebar #toolbar .tool-section,
body.toolbar-top #measureSidebar #toolbar .tool-section {
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100%;
  flex: 0 0 auto !important;
  align-self: stretch;
}

body.toolbar-left #measureSidebar #toolbar .tool-row,
body.toolbar-right #measureSidebar #toolbar .tool-row,
body.toolbar-top #measureSidebar #toolbar .tool-row {
  width: 100%;
}

body.toolbar-left #measureSidebar #toolbar #inspectorModeSwitch,
body.toolbar-right #measureSidebar #toolbar #inspectorModeSwitch,
body.toolbar-top #measureSidebar #toolbar #inspectorModeSwitch,
body.toolbar-left #measureSidebar #toolbar #toolbarInspectorSections,
body.toolbar-right #measureSidebar #toolbar #toolbarInspectorSections,
body.toolbar-top #measureSidebar #toolbar #toolbarInspectorSections {
  width: 100%;
  min-width: 0;
  justify-self: stretch;
}

/* Align the measuring workspace with the current CVCT application shell.
   These are presentation-only overrides; tool behavior and layout hooks stay intact. */
:root {
  --cv-red: #e31d23;
  --cv-ink: #1f2937;
  --cv-muted: #64748b;
  --cv-border: #d9e1ea;
  --cv-surface: #ffffff;
  --cv-surface-soft: #f8fafc;
}

body {
  color: var(--cv-ink);
  background:
    radial-gradient(circle at top left, rgba(227, 29, 35, 0.055), transparent 29%),
    linear-gradient(180deg, #f8fafc 0%, #eef3f8 100%);
}

#measureAppShell {
  padding: 14px;
  gap: 14px;
}

#measureAppMain {
  gap: 14px;
}

#measureSidebar {
  gap: 14px;
}

.workspace-card,
#toolbar,
#sidebarUtilityPanel,
#measureCanvasShell {
  border-color: var(--cv-border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.07);
}

.workspace-card {
  padding: 12px 14px;
}

.workspace-toolbar-group,
#toolbar .tool-section,
.sidebar-summary-list,
.measure-room-panel {
  border-color: var(--cv-border);
  border-radius: 10px;
  background: var(--cv-surface-soft);
}

#inspectorModeSwitch button,
#sidebarUtilitySwitch button,
#toolbar button,
#toolbar select,
#toolbar input,
.workspace-actions button,
.workspace-toolbar-controls button,
.workspace-toolbar-controls input,
.workspace-menu summary,
.workspace-menu-list button,
.sidebar-summary-header button {
  border-color: var(--cv-border);
  border-radius: 10px;
  background: var(--cv-surface);
  color: var(--cv-ink);
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease, background 140ms ease;
}

#toolbar button:hover,
.workspace-actions button:hover,
.workspace-toolbar-controls button:hover,
.sidebar-summary-header button:hover,
#inspectorModeSwitch button:hover,
#sidebarUtilitySwitch button:hover {
  border-color: #f0b7bd;
  box-shadow: 0 7px 16px rgba(214, 24, 40, 0.1);
  transform: translateY(-1px);
}

#toolbar button.active,
#toolNav button.active,
#inspectorModeSwitch button.active,
#sidebarUtilitySwitch button.active,
#openFileBtn,
#saveMeasureBtnSecondary,
#createPricingWorksheetBtn,
#printPricingBtn {
  border-color: var(--cv-red);
  background: var(--cv-red);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(227, 29, 35, 0.2);
}

#toolbar button.active:hover,
#toolNav button.active:hover,
#inspectorModeSwitch button.active:hover,
#sidebarUtilitySwitch button.active:hover,
#openFileBtn:hover,
#saveMeasureBtnSecondary:hover,
#createPricingWorksheetBtn:hover,
#printPricingBtn:hover {
  border-color: #c9161c;
  background: #c9161c;
}

.workspace-field-label,
.workspace-toolbar-title,
#toolbar .section-label,
.pricing-sheet-kicker {
  color: var(--cv-muted);
}

.workspace-title-input,
.page-number-input {
  border-color: var(--cv-border);
  border-radius: 10px;
}

#viewport {
  background:
    linear-gradient(180deg, rgba(203, 212, 224, 0.42), rgba(154, 166, 184, 0.2)),
    #cbd5e1;
}

#pricingSheetPanel,
.pricing-summary-panel,
.rough-bid-totals-card {
  border-color: var(--cv-border);
  border-radius: 14px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.07);
}

@media (max-width: 1100px) {
  #measureAppShell {
    padding: 10px;
    gap: 10px;
  }
}

