:root {
  --teal: #0B4C92;
  --dark: #333333;
  --white: #ffffff;
  --bg: #f5f7f7;
  --line: #dfe7e7;
  --muted: #6f7a7a;
  --soft-teal: rgba(11, 76, 146, 0.1);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--dark);
}
button, input, select { font: inherit; }
button { cursor: pointer; }
.app-shell { display: flex; height: 100vh; width: 100vw; overflow: hidden; }
.hidden-file-input { display: none; }

.sidebar {
  width: 360px;
  background: var(--teal);
  color: var(--white);
  padding: 18px;
  overflow-y: auto;
  box-shadow: 10px 0 30px rgba(0,0,0,0.18);
  z-index: 5;
}
.brand-block {
  margin-bottom: 8px;
  padding: 0;
}
.brand-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  align-items: center;
  gap: 10px;
}

.brand-logo-img {
  display: block;
  width: 100%;
  max-width: 220px;
  max-height: 90px;
  height: auto;
  object-fit: contain;
}
.brand-license-slot {
  min-height: 44px;
  border: 1px dashed rgba(255,255,255,0.28);
  border-radius: 12px;
  padding: 7px 9px;
  color: rgba(255,255,255,0.78);
}
.brand-license-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  opacity: .72;
}
.brand-license-value {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 700;
}
.panel {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 18px;
  padding: 14px;
  margin-bottom: 14px;
  backdrop-filter: blur(4px);
}
.panel-title { font-size: 12px; color: rgba(255,255,255,0.78); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 10px; font-weight: 800; }
.small-muted { color: rgba(255,255,255,0.66); font-size: 12px; margin-top: 8px; overflow-wrap: anywhere; }
.small-help { color: var(--muted); font-size: 13px; margin-top: 14px; }
.pdf-status {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 12px;
  padding: 10px 11px;
  font-size: 13px;
  color: var(--white);
  overflow-wrap: anywhere;
}
.project-fields {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}
.project-fields label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.68);
}
.project-fields input {
  width: 100%;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.12);
  color: white;
  border-radius: 12px;
  padding: 9px 11px;
  outline: none;
}
.project-fields input::placeholder { color: rgba(255,255,255,0.52); }
.project-fields input:focus { border-color: white; box-shadow: 0 0 0 3px rgba(255,255,255,0.14); }
.item-form { display: flex; gap: 8px; margin-bottom: 8px; }
.item-form input[type="text"] {
  width: 100%;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.12);
  color: white;
  border-radius: 12px;
  padding: 10px 11px;
  outline: none;
}
.item-form input[type="text"]::placeholder { color: rgba(255,255,255,0.55); }
.item-form input[type="text"]:focus { border-color: white; box-shadow: 0 0 0 3px rgba(255,255,255,0.14); }
.item-form input[type="color"] { width: 46px; height: 42px; border: 0; background: transparent; cursor: pointer; }
.primary-btn {
  width: 100%;
  background: white;
  color: var(--teal);
  border: 0;
  border-radius: 12px;
  padding: 10px;
  font-weight: 800;
  cursor: pointer;
}
.button-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
.button-grid button:not(.primary-btn) {
  background: rgba(255,255,255,0.12);
  color: white;
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 12px;
  padding: 10px;
}
.item-list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.item-row {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.1);
  cursor: pointer;
}
.item-row.active { outline: 2px solid white; background: rgba(255,255,255,0.2); }
.color-dot { width: 14px; height: 14px; border-radius: 99px; border: 2px solid rgba(255,255,255,0.9); }
.delete-item { background: transparent; color: #ffd8d8; border: 0; cursor: pointer; font-weight: 800; font-size: 18px; }
.totals-header, .total-row {
  display: grid;
  grid-template-columns: 1fr 70px 50px;
  gap: 8px;
  align-items: center;
}
.totals-header { color: rgba(255,255,255,0.62); font-size: 11px; text-transform: uppercase; margin-bottom: 8px; }
.total-row { font-size: 13px; padding: 8px 0; border-top: 1px solid rgba(255,255,255,0.1); }
.marked-sheet-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid rgba(255,255,255,0.1);
  cursor: pointer;
}
.marked-sheet-row:hover { color: white; text-decoration: underline; }
.marked-sheet-row strong { color: white; }

.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.toolbar {
  min-height: 60px;
  background: white;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 4px 18px rgba(51,51,51,0.06);
  flex-wrap: wrap;
  z-index: 4;
}
.toolbar-group { display: flex; align-items: center; gap: 8px; }
.toolbar-group.grow { flex: 1; justify-content: flex-end; }
.toolbar button {
  background: white;
  color: var(--dark);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 13px;
  cursor: pointer;
}
.toolbar button:hover { background: var(--soft-teal); border-color: rgba(11, 76, 146,0.35); }
.toolbar button:disabled { opacity: .45; cursor: not-allowed; }
.danger-soft { color: #a33535 !important; border-color: #efd2d2 !important; }
.sheet-name-label { color: var(--muted); font-size: 13px; font-weight: 600; }
#sheetNameInput,
#legendPositionSelect,
#dotSizeSelect {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 11px;
  background: white;
  color: var(--dark);
  outline: none;
}
#sheetNameInput { width: 170px; }
#sheetNameInput:focus,
#legendPositionSelect:focus,
#dotSizeSelect:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(11, 76, 146,0.12); }

.workspace { flex: 1; overflow: auto; position: relative; padding: 30px; background: linear-gradient(180deg, #f8fbfb 0%, #eef3f3 100%); }
.empty-state {
  width: min(720px, 90%);
  margin: 90px auto;
  background: white;
  border-radius: 26px;
  padding: 38px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(51,51,51,0.1);
  border: 1px solid var(--line);
  cursor: pointer;
}
.empty-state:hover { border-color: rgba(11, 76, 146,0.35); box-shadow: 0 22px 64px rgba(51,51,51,0.14); }
.empty-state:focus-visible { outline: 3px solid rgba(11, 76, 146,0.25); outline-offset: 3px; }
.empty-state h1 { margin: 0 0 10px; font-size: 30px; color: var(--teal); letter-spacing: -0.03em; }
.empty-state p { color: var(--muted); }
.pdf-stage {
  display: block;
  min-height: 100%;
  min-width: 100%;
  width: max-content;
}
.page-wrap {
  position: relative;
  background: white;
  box-shadow: 0 22px 60px rgba(51,51,51,0.24);
  margin: 0 auto 60px auto;
  border-radius: 2px;
}
#pdfCanvas { display: block; }
#dotLayer { position: absolute; inset: 0; cursor: crosshair; }
#pdfTextLayer {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  user-select: none;
}
#pdfTextLayer.text-select-active {
  pointer-events: auto;
  user-select: text;
  cursor: text;
}
.pdf-text-item {
  position: absolute;
  color: transparent;
  line-height: 1;
  white-space: pre;
  overflow: hidden;
  user-select: text;
}
.pdf-text-item::selection {
  color: transparent;
  -webkit-text-fill-color: transparent;
  background: rgba(255, 193, 7, 0.45);
}
.pdf-text-item::-moz-selection {
  color: transparent;
  background: rgba(255, 193, 7, 0.45);
}
.count-dot {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 2px solid white;
  box-shadow: 0 1px 5px rgba(0,0,0,0.45);
  opacity: 0.5;
}
.count-dot:hover { outline: 3px solid rgba(11, 76, 146,0.26); opacity: 0.75; }
.hidden { display: none !important; }

#legendLayer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.sheet-legend-box {
  position: absolute;
  right: 18px;
  bottom: 18px;
  min-width: 245px;
  max-width: 360px;
  background: rgba(255,255,255,0.94);
  border: 1px solid rgba(11, 76, 146,0.45);
  border-radius: 16px;
  box-shadow: 0 10px 28px rgba(51,51,51,0.18);
  padding: 12px;
  font-size: 12px;
  color: var(--dark);
}
.sheet-legend-title { font-weight: 800; margin-bottom: 8px; color: var(--teal); }
.sheet-legend-header,
.sheet-legend-row {
  display: grid;
  grid-template-columns: 1fr 46px 42px;
  gap: 7px;
  align-items: center;
}
.sheet-legend-header {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 800;
  margin-bottom: 5px;
}
.sheet-legend-row {
  border-top: 1px solid rgba(11, 76, 146,0.13);
  padding-top: 6px;
  margin-top: 6px;
}
.legend-name {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.legend-name i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,0.3);
  flex: 0 0 auto;
  opacity: .65;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(51,51,51,0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal-card {
  width: min(520px, calc(100vw - 40px));
  background: white;
  border-radius: 24px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.35);
  padding: 26px;
  border: 1px solid var(--line);
}
.modal-card h2 {
  margin: 0 0 8px;
  font-size: 23px;
  color: var(--teal);
}
.modal-help {
  color: var(--muted);
  font-size: 13px;
  margin: 7px 0 12px;
}
.modal-label {
  display: block;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--dark);
  margin-bottom: 6px;
}
#pageRangeInput {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 13px;
  font-size: 15px;
  outline: none;
}
#pageRangeInput:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(11, 76, 146,0.12); }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}
.modal-actions button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 9px 14px;
}
.modal-actions .primary-modal-btn {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
  font-weight: 800;
}
.sheet-legend-box.legend-bottom-right { right: 18px; bottom: 18px; left: auto; top: auto; }
.sheet-legend-box.legend-bottom-left { left: 18px; bottom: 18px; right: auto; top: auto; }
.sheet-legend-box.legend-top-right { right: 18px; top: 18px; left: auto; bottom: auto; }
.sheet-legend-box.legend-top-left { left: 18px; top: 18px; right: auto; bottom: auto; }

.toast-container {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  max-width: 380px;
  background: var(--dark);
  color: var(--white);
  border-left: 6px solid var(--teal);
  border-radius: 16px;
  padding: 12px 14px;
  box-shadow: 0 14px 36px rgba(0,0,0,0.28);
  font-size: 13px;
  line-height: 1.35;
  pointer-events: none;
  animation: toastIn 140ms ease-out;
}
.toast.toast-with-action {
  pointer-events: auto;
}
.toast-action {
  margin-left: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #ffffff;
  font: inherit;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.toast.toast-warning { border-left-color: #f2b84b; }
.toast.toast-error { border-left-color: #d85d5d; }
.toast.toast-success { border-left-color: #6abf69; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.confirm-card { max-width: 440px; }
.confirm-card .danger-confirm { background: #9b3131; border-color: #9b3131; }

/* Beta3 additions */
.library-search {
  width: 100%;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.12);
  color: white;
  border-radius: 12px;
  padding: 9px 11px;
  outline: none;
  margin-bottom: 10px;
}
.library-search::placeholder { color: rgba(255,255,255,0.52); }
.library-search:focus { border-color: white; box-shadow: 0 0 0 3px rgba(255,255,255,0.14); }
.library-list { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow: auto; padding-right: 3px; }
.library-category { margin-top: 6px; font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: rgba(255,255,255,0.7); }
.library-row {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 9px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.08);
  color: white;
  cursor: pointer;
}
.library-row:hover { background: rgba(255,255,255,0.18); }
.library-row button { border: 0; border-radius: 99px; width: 24px; height: 24px; font-weight: 900; color: var(--teal); background: white; }
.library-actions { margin-top: 10px; }
#pageSelect, #toolModeSelect {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 11px;
  background: white;
  color: var(--dark);
  outline: none;
  max-width: 220px;
}
#toolModeSelect { max-width: 170px; }
.scale-status {
  color: var(--muted);
  font-size: 12px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f9fbfb;
}
.measurement-export-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
#measurementLayer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
  z-index: 2;
}
#dotLayer { z-index: 3; }
#legendLayer { z-index: 4; }
.distance-measure {
  stroke: #0B4C92;
  stroke-width: 3px;
  stroke-linecap: round;
  opacity: .9;
  vector-effect: non-scaling-stroke;
}
.area-measure {
  fill: rgba(11, 76, 146,.12);
  stroke: #0B4C92;
  stroke-width: 3px;
  opacity: .95;
  vector-effect: non-scaling-stroke;
}
.scale-line {
  stroke: #333333;
  stroke-width: 2px;
  stroke-dasharray: 8 6;
  opacity: .85;
  vector-effect: non-scaling-stroke;
}
.pending-measure-point { fill: #0B4C92; stroke: #ffffff; stroke-width: 2px; }
.measurement-label {
  fill: #0B4C92;
  stroke: white;
  stroke-width: 4px;
  paint-order: stroke;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  font-weight: 800;
}
#scaleDistanceInput {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 11px;
  outline: none;
}

/* Beta3.1 layout updates */
.bottom-nav {
  min-height: 58px;
  background: #ffffff;
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 18px rgba(51,51,51,0.06);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  flex-wrap: nowrap;
  z-index: 4;
}
.bottom-group { display: flex; align-items: center; gap: 8px; min-width: 0; }
#pageInfo {
  display: inline-block;
  max-width: clamp(120px, 20vw, 280px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bottom-group button {
  background: white;
  color: var(--dark);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 13px;
  cursor: pointer;
}
.bottom-group button:hover { background: var(--soft-teal); border-color: rgba(11, 76, 146,0.35); }
.bottom-group button:disabled { opacity: .45; cursor: not-allowed; }
.bottom-group label { color: var(--muted); font-size: 13px; font-weight: 600; }
#pageSelect, #toolModeSelect, #findSensitivitySelect {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 11px;
  background: white;
  color: var(--dark);
  outline: none;
}
#pageSelect { max-width: 260px; min-width: 0; text-overflow: ellipsis; }
#findSensitivitySelect { max-width: 120px; }
#sheetNameInput {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 11px;
  background: white;
  color: var(--dark);
  outline: none;
  width: clamp(120px, 16vw, 210px);
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#sheetNameInput:focus,
#pageSelect:focus,
#toolModeSelect:focus,
#findSensitivitySelect:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(11, 76, 146,0.12); }
.find-controls {
  background: #f9fbfb;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 8px;
}
.find-status {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}
#findSimilarLayer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
.find-suggestion-box,
.find-selection-box {
  position: absolute;
  border: 2px solid #ffcc00;
  background: rgba(255, 204, 0, 0.12);
  box-shadow: 0 0 0 2px rgba(51,51,51,0.15);
  border-radius: 3px;
}
.find-selection-box {
  border-color: #00bcd4;
  background: rgba(0, 188, 212, 0.12);
}
.find-suggestion-label {
  position: absolute;
  left: -2px;
  top: -22px;
  background: #ffcc00;
  color: #333333;
  border-radius: 8px 8px 8px 0;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}


/* Beta3.2 text find */
.text-find-group {
  background: #f9fbfb;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 8px;
  gap: 6px;
}
#textFindInput {
  width: 180px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  outline: none;
  color: var(--dark);
  background: #ffffff;
}
#textFindInput:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(11, 76, 146,0.12); }
.text-find-count {
  min-width: 44px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
#textFindPrevBtn,
#textFindNextBtn,
#textFindClearBtn { padding: 7px 10px; }
#textSearchLayer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
.text-search-highlight {
  position: absolute;
  border: 2px solid rgba(255, 204, 0, 0.95);
  background: rgba(255, 204, 0, 0.26);
  box-shadow: 0 0 0 1px rgba(51,51,51,0.12);
  border-radius: 3px;
}
.text-search-highlight.active {
  border-color: #ff7a00;
  background: rgba(255, 122, 0, 0.32);
  box-shadow: 0 0 0 3px rgba(255,122,0,0.22);
}

/* Beta3.3 export and Find Similar cleanup */
.modal-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  color: var(--dark);
  font-weight: 700;
}
.modal-checkbox input { transform: scale(1.15); }
.find-suggestion-box { opacity: .55; }
.find-suggestion-box.active {
  border-color: #ff7a00;
  background: rgba(255, 122, 0, 0.22);
  box-shadow: 0 0 0 4px rgba(255,122,0,0.24), 0 0 18px rgba(255,122,0,0.45);
  opacity: 1;
}
.find-suggestion-box.active .find-suggestion-label {
  background: #ff7a00;
  color: #ffffff;
}
#findSimilarPrevBtn,
#findSimilarNextBtn { padding: 7px 10px; }

/* Beta3.4 toolbar/workflow cleanup */
.toolbar { gap: 9px; }
.toolbar-section-label {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--teal);
  margin-right: 2px;
  white-space: nowrap;
}
.markup-tools-group,
.tool-group {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 8px;
  gap: 7px;
}
#setScaleBtn,
#findSimilarBtn {
  background: var(--teal);
  color: #ffffff;
  border-color: var(--teal);
  font-weight: 800;
}
.align-assist-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  font-weight: 700;
}
.align-assist-toggle input { transform: scale(1.05); }
#textFindInput { width: 120px; }
.text-find-group { padding: 4px 7px; }
.text-find-group .sheet-name-label { font-size: 11px; }
#textFindPrevBtn,
#textFindNextBtn,
#textFindClearBtn { padding: 6px 8px; }
.find-controls { gap: 6px; }
.legend-bottom-group { margin-left: auto; }
#legendPositionSelect {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 11px;
  background: white;
  color: var(--dark);
  outline: none;
  max-width: 160px;
}
#legendPositionSelect:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(11, 76, 146,0.12); }
#alignGuideLayer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
.align-guide {
  position: absolute;
  background: rgba(11, 76, 146,0.55);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.9);
}
.align-guide-v { top: 0; bottom: 0; width: 1px; }
.align-guide-h { left: 0; right: 0; height: 1px; }
.find-suggestion-box {
  border-color: #00bcd4;
  background: rgba(0, 188, 212, 0.12);
  opacity: .85;
}
.find-suggestion-label {
  background: #00bcd4;
  color: #ffffff;
}


/* Beta3.4.1 focused toolbar fixes */
#findSimilarBtn::after { content: ''; }
.find-controls { padding-right: 8px; }
.find-controls .find-status { display: none !important; }
.text-find-group.hidden { display: none !important; }

/* Beta3.4.2 UI polish */
.text-find-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(15,23,42,0.06);
  flex: 0 0 auto;
  z-index: 25;
}
.text-find-bar.hidden { display: none !important; }
.text-find-bar input {
  width: 220px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 11px;
  outline: none;
}
.text-find-bar input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(11, 76, 146,0.12); }
.text-find-bar button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  color: var(--dark);
  padding: 6px 10px;
  cursor: pointer;
}
.text-find-bar button:hover { background: var(--soft-teal); border-color: rgba(11, 76, 146,0.35); }
.text-find-bar .icon-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  font-weight: 700;
}
#setScaleBtn,
#findSimilarBtn,
.toolbar button,
.toolbar select,
.toolbar label,
.markup-size-label,
#dotSizeSelect {
  font-family: "Segoe UI", Arial, sans-serif;
}
.markup-size-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
#dotSizeSelect {
  min-width: 58px;
  text-align: center;
  font-weight: 700;
}

/* Beta3.4.3 Symbol matching/button polish */
#setScaleBtn,
#findSimilarBtn {
  min-width: 74px;
  padding: 8px 14px;
  font-weight: 800;
  letter-spacing: 0;
  font-size: 13px;
  line-height: 1;
}
.find-controls #clearSuggestionsBtn,
.compact-actions button,
.tool-group button,
.toolbar button {
  font-family: "Segoe UI", Arial, sans-serif;
}


/* Beta3.4.6 cursor visibility and Set Scale polish */
:root {
  --countonme-crosshair-cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='25' height='25' viewBox='0 0 25 25'%3E%3Cline x1='12' y1='1' x2='12' y2='24' stroke='white' stroke-width='4' stroke-linecap='round'/%3E%3Cline x1='1' y1='12' x2='24' y2='12' stroke='white' stroke-width='4' stroke-linecap='round'/%3E%3Cline x1='12' y1='1' x2='12' y2='24' stroke='%23333333' stroke-width='2' stroke-linecap='round'/%3E%3Cline x1='1' y1='12' x2='24' y2='12' stroke='%23333333' stroke-width='2' stroke-linecap='round'/%3E%3Ccircle cx='12' cy='12' r='2.5' fill='%23014d4e' stroke='white' stroke-width='1'/%3E%3C/svg%3E") 12 12, crosshair;
}

#workspace,
.pdf-stage,
.page-wrap,
#pdfCanvas,
#dotLayer {
  cursor: var(--countonme-crosshair-cursor) !important;
}

.count-dot {
  cursor: pointer !important;
}

#measurementLayer,
#legendLayer,
#alignGuideLayer,
#textHighlightLayer,
#selectionLayer {
  pointer-events: none;
  cursor: inherit;
}

button,
.item-row,
.marked-sheet-row,
select,
input[type="color"],
label {
  cursor: pointer;
}

input[type="text"],
input[type="search"],
textarea,
#sheetNameInput,
#textFindInput,
#scaleDistanceInput {
  cursor: text !important;
}

#setScaleBtn {
  font-weight: 600 !important;
  font-size: 12.5px !important;
  letter-spacing: 0 !important;
  background: var(--teal);
  color: #ffffff;
  border-color: var(--teal);
  box-shadow: none;
}

.add-library-btn {
  width: 100%;
  margin-top: 10px;
  justify-content: center;
}

/* ===== BETA4.0 focused improvements ===== */
.panel-title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.panel-title-plus, .library-mini-plus {
  width: 24px; height: 24px; border-radius: 999px; border: 1px solid rgba(255,255,255,0.28);
  background: rgba(255,255,255,0.94); color: var(--teal); font-weight: 900; line-height: 1; padding: 0;
}
.library-category.beta4-category-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-right: 4px; }
.library-mini-plus { width: 22px; height: 22px; font-size: 14px; flex: 0 0 auto; }
.library-row { grid-template-columns: 14px 1fr auto auto; }
.library-row .library-row-action, .item-row .library-row-action { border: 0; border-radius: 99px; height: 24px; min-width: 24px; padding: 0 7px; font-weight: 800; color: var(--teal); background: white; }
.library-row .library-edit-action, .item-row .library-edit-action { font-size: 11px; }
#libraryItemNameInput, #libraryItemCategorySelect, #libraryCategoryNameInput, #commonScaleSelect {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 10px 11px; background: white; color: var(--dark); outline: none; margin-bottom: 10px;
}
.modal-card input[type="text"], .modal-card select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 11px;
  background: white;
  color: var(--dark);
  outline: none;
  margin-bottom: 10px;
}
#libraryItemColorInput { width: 54px; height: 42px; border: 0; background: transparent; margin-bottom: 10px; }
.scale-choice-grid { display: grid; gap: 14px; }
.scale-preset-box { border: 1px solid var(--line); border-radius: 16px; padding: 12px; background: #f9fbfb; }
.scale-preset-box button { width: 100%; border-radius: 12px; border: 1px solid var(--line); padding: 10px; background: white; }
#measurementLayer { pointer-events: none; z-index: 5; }
.measurement-click-target { pointer-events: auto; cursor: pointer; }
.distance-measure-hit { stroke: transparent; stroke-width: 18px; stroke-linecap: round; fill: none; pointer-events: stroke; cursor: pointer; }
.area-measure.measurement-click-target { cursor: pointer; }
body.space-panning #workspace, body.space-panning .pdf-stage, body.space-panning .page-wrap, body.space-panning #pdfCanvas, body.space-panning #dotLayer { cursor: grabbing !important; }
body.pan-selection-locked,
body.pan-selection-locked * {
  user-select: none !important;
  -webkit-user-select: none !important;
}


/* BETA4.0.1 focused UI/pan cleanup */
.panel-title-plus {
  width: auto;
  min-width: 46px;
  padding: 0 8px;
  font-size: 11px;
  letter-spacing: .02em;
}
.library-row .library-edit-action {
  min-width: 28px;
  width: 28px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
  font-weight: 900;
}
body.tool-pan-active #workspace,
body.tool-pan-active .pdf-stage,
body.tool-pan-active .page-wrap,
body.tool-pan-active #pdfCanvas,
body.tool-pan-active #dotLayer {
  cursor: grab !important;
}
body.space-panning #workspace,
body.space-panning .pdf-stage,
body.space-panning .page-wrap,
body.space-panning #pdfCanvas,
body.space-panning #dotLayer {
  cursor: grabbing !important;
}

.increment-controls, .cable-pipe-controls {
  flex-wrap: wrap;
  padding-left: 8px;
  border-left: 1px solid var(--line);
}
.increment-controls.hidden, .cable-pipe-controls.hidden, .general-markup-controls.hidden { display: none !important; }
.general-markup-controls input[type="color"] {
  width: 34px;
  height: 32px;
  border: 0;
  background: transparent;
  cursor: pointer;
}
#incrementSpacingInput, #cablePipeRunsInput, #cablePipeExtraFeetInput, #cablePipeEditExtraFeetInput {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 11px;
  background: white;
  color: var(--dark);
  outline: none;
}
#incrementSpacingInput { width: 82px; }
.increment-path-line {
  stroke: #0B4C92;
  stroke-width: 2.5;
  stroke-dasharray: 8 5;
  fill: none;
  opacity: .85;
}
.increment-path-point {
  fill: #0B4C92;
  stroke: #ffffff;
  stroke-width: 1.5;
}
.increment-path-label {
  fill: #0B4C92;
  font: 700 13px "Segoe UI", Arial, sans-serif;
}
.general-highlight {
  opacity: 0.32;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
}
.general-arrow {
  stroke-width: 3px;
  stroke-linecap: round;
  fill: none;
  vector-effect: non-scaling-stroke;
}
.general-text-note {
  font-size: 16px;
  font-weight: 500;
  paint-order: stroke;
  stroke: white;
  stroke-width: 2px;
  cursor: move;
  user-select: text;
}
.general-text-note.selected-text-note {
  stroke: rgba(255,255,255,0.98);
  stroke-width: 3px;
  filter: drop-shadow(0 0 3px rgba(11, 76, 146,0.55));
}
.text-markup-box {
  stroke-width: 1.5px;
  stroke-dasharray: 5 4;
  vector-effect: non-scaling-stroke;
  cursor: move;
}
.text-markup-box-solid {
  stroke-dasharray: none;
}
.text-markup-box-draft {
  stroke: #0B4C92;
  opacity: 0.85;
  pointer-events: none;
}
.text-markup-resize-handle {
  fill: #ffffff;
  stroke: #0B4C92;
  stroke-width: 1.4px;
  vector-effect: non-scaling-stroke;
  cursor: nwse-resize;
}
.text-markup-resize-handle[data-corner="ne"],
.text-markup-resize-handle[data-corner="sw"] {
  cursor: nesw-resize;
}
.text-markup-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: start;
}
#textMarkupInput {
  width: 100%;
  resize: vertical;
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  font: 14px "Segoe UI", Arial, sans-serif;
  color: var(--dark);
}
#textMarkupColorInput {
  width: 54px;
  height: 42px;
  border: 0;
  background: transparent;
}
#textMarkupSizeInput {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
}
#textMarkupBorderStyleSelect {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  background: white;
  color: var(--dark);
}
.text-border-toggle {
  margin-top: 12px;
  color: var(--dark);
}

.cable-pipe-controls {
  flex-wrap: wrap;
  padding-left: 8px;
  border-left: 1px solid var(--line);
}
.tool-status-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 11px;
  background: rgba(11, 76, 146,0.08);
  color: var(--teal);
  font-weight: 700;
  font-size: 12px;
}
.cable-pipe-path-short { stroke: #2563eb; stroke-width: 2.5; stroke-dasharray: 7 5; fill: none; opacity: .85; }
.cable-pipe-path-long { stroke: #d97706; stroke-width: 2.5; stroke-dasharray: 7 5; fill: none; opacity: .85; }
.cable-pipe-path-active { stroke: #0B4C92; stroke-width: 2.5; fill: none; opacity: .9; }
.cable-pipe-path-point { fill: #0B4C92; stroke: #ffffff; stroke-width: 1.5; }
.cable-pipe-path-label { fill: #0B4C92; font: 700 13px "Segoe UI", Arial, sans-serif; }
#cablePipeRunsInput, #cablePipeExtraFeetInput, #cablePipeEditExtraFeetInput { width: 100%; margin: 8px 0 12px; }


/* Firebase licensing gate */
.license-gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0B4C92 0%, #002C5E 55%, #333333 100%);
  color: white;
  padding: 28px;
}
.license-gate.hidden { display: none; }
body.license-locked .app-shell {
  pointer-events: none;
  user-select: none;
  filter: blur(1.5px);
}
.license-card {
  width: min(460px, 94vw);
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.24);
  border-radius: 28px;
  padding: 30px;
  box-shadow: 0 28px 90px rgba(0,0,0,0.34);
  backdrop-filter: blur(12px);
}
.license-logo {
  display: block;
  width: min(320px, 88%);
  height: auto;
  margin: 0 auto 24px;
}
.license-view h1 { margin: 0 0 10px; font-size: 27px; letter-spacing: -0.04em; }
.license-view p { color: rgba(255,255,255,0.78); }
.license-view label {
  display: block;
  margin-top: 13px;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.74);
}
.license-view input {
  width: 100%;
  border: 1px solid rgba(255,255,255,0.28);
  border-radius: 13px;
  padding: 12px 13px;
  background: rgba(255,255,255,0.12);
  color: white;
  outline: none;
}
.license-view input::placeholder { color: rgba(255,255,255,0.48); }
.license-view input:focus { border-color: white; box-shadow: 0 0 0 3px rgba(255,255,255,0.14); }
.license-primary, .license-actions button, .license-view button {
  border-radius: 999px;
  padding: 10px 16px;
}
.license-primary {
  width: 100%;
  margin-top: 18px;
  border: 0;
  background: white;
  color: #0B4C92;
  font-weight: 850;
}
.license-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.license-actions button:not(.license-primary) {
  border: 1px solid rgba(255,255,255,0.28);
  background: rgba(255,255,255,0.12);
  color: white;
}
.license-message { margin-top: 12px; min-height: 18px; color: #ffe0a3; font-size: 13px; }
.license-small { font-size: 13px; margin-top: 16px; }
.license-link-btn {
  border: 0;
  padding: 0;
  background: transparent;
  color: white;
  text-decoration: underline;
  font-weight: 700;
}
.license-dots { animation: licenseBlink 1.1s infinite; }
@keyframes licenseBlink { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }

.license-forgot-btn {
  display: inline-block;
  margin-top: 8px;
  font-size: 13px;
}

/* CountOnMe 4.4.1 focused bugfix/features */
.modal-backdrop.confirm-modal-active {
  z-index: 5000 !important;
}
.confirm-modal-active .modal-card {
  box-shadow: 0 30px 90px rgba(0,0,0,0.45);
}
.library-category-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}
.library-mini-delete {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.28);
  background: rgba(255,255,255,0.18);
  color: #ffd8d8;
  font-weight: 900;
  line-height: 1;
  padding: 0;
}
.library-mini-delete:hover {
  background: rgba(255,216,216,0.24);
}
.item-row {
  grid-template-columns: 18px minmax(0, 1fr) 92px auto auto;
}
.item-row-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item-row.item-hidden {
  opacity: 0.68;
}
.item-size-override {
  min-width: 86px;
  border: 1px solid rgba(255,255,255,0.24);
  background: rgba(255,255,255,0.14);
  color: #fff;
  border-radius: 999px;
  padding: 5px 7px;
  outline: none;
}
.item-size-override option {
  color: #333;
}
.item-visibility-toggle {
  border: 1px solid rgba(255,255,255,0.24);
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-radius: 999px;
  width: 30px;
  height: 30px;
  font-weight: 800;
}
.total-row-hidden {
  opacity: 0.68;
}
.total-row em {
  color: rgba(255,255,255,0.65);
  font-style: normal;
  font-size: 11px;
}
.cable-pipe-sidebar-results {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.14);
}
.cable-pipe-sidebar-results.hidden {
  display: none;
}
.cable-pipe-sidebar-title {
  color: rgba(255,255,255,0.72);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.cable-pipe-sidebar-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 7px 0;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 12px;
}
.cable-pipe-sidebar-row:first-of-type {
  border-top: 0;
}
.cable-pipe-sidebar-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}
.cable-pipe-sidebar-row strong {
  color: #fff;
  white-space: nowrap;
}
.cable-pipe-options-btn {
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 999px;
  min-width: 24px;
  height: 22px;
  padding: 0 6px;
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-weight: 800;
  line-height: 1;
}


/* Symbol markup experiment */
.count-symbol {
  position: absolute;
  transform: translate(-50%, -50%);
  background: #2563eb;
  color: #fff;
  border: 2px solid #2563eb;
  text-align: center;
  font-weight: 650;
  font-family: "Segoe UI", Arial, sans-serif;
  box-shadow: 0 1px 3px rgba(0,0,0,0.16);
  user-select: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.count-symbol span, .legend-symbol span, .symbol-mini span, .symbol-preview span { display: inline-block; line-height: 1; }
.symbol-shape-circle { border-radius: 999px; }
.symbol-shape-square { border-radius: 3px; }
.symbol-shape-triangle { clip-path: polygon(50% 3%, 96% 95%, 4% 95%); border-radius: 0; }
.count-symbol.symbol-shape-triangle {
  position: absolute;
  transform: translate(-50%, -46%);
  background: #2563eb;
  border: 0;
  overflow: hidden;
  isolation: isolate;
}
.count-symbol.symbol-shape-triangle span {
  position: relative;
  z-index: 1;
  transform: translateY(20%);
}
.symbol-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
  font-size: 10px;
  font-weight: 650;
  line-height: 1;
}
.legend-symbol {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  margin-right: 7px;
  background: #2563eb;
  color: #fff;
  border: 2px solid #2563eb;
  font-size: 10px;
  font-weight: 650;
  line-height: 1;
  vertical-align: middle;
  opacity: 1;
  font-family: "Segoe UI", Arial, sans-serif;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}
.legend-name .legend-symbol {
  display: inline-flex;
  width: 17px;
  height: 17px;
  border-width: 2px;
  opacity: 1;
}
.legend-symbol span {
  display: block;
  line-height: 1;
  transform: translateY(-0.5px);
}
.legend-symbol.symbol-shape-triangle span {
  transform: translateY(2px);
}
.appearance-mode-row { display: flex; gap: 16px; align-items: center; margin: 8px 0 14px; }
.appearance-mode-row label { display: flex; gap: 6px; align-items: center; font-size: 13px; }
.appearance-grid { display: grid; grid-template-columns: minmax(86px, 1fr) minmax(120px, 1.2fr) 92px; gap: 14px; align-items: end; }
.appearance-section { display: grid; gap: 8px; min-width: 0; }
.appearance-section input[type="text"], .appearance-section select, .library-symbol-grid input[type="text"], .library-symbol-grid select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 9px;
  background: white;
  color: var(--dark);
  width: 100%;
  min-width: 0;
}
.appearance-preview-box { display: grid; place-items: center; gap: 8px; }
.appearance-preview-label { font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.symbol-preview {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #2563eb;
  color: #fff;
  border: 3px solid #2563eb;
  font-size: 32px;
  font-weight: 650;
  line-height: 1;
}
.color-preview-dot { border-radius: 999px; border-color: white; color: transparent; }
.library-appearance-compact { margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(0,0,0,0.08); }
.library-preview-box { margin-top: 12px; }
.appearance-mode-row.compact { margin-bottom: 10px; flex-wrap: wrap; }
.library-symbol-grid { display: grid; grid-template-columns: 56px minmax(56px, 0.8fr) 52px minmax(110px, 1.2fr); gap: 8px; align-items: center; max-width: 100%; }
#libraryItemModal .modal-card { overflow: visible; max-width: min(520px, calc(100vw - 36px)); }
#librarySymbolShapeSelect, #appearanceShapeSelect { max-width: 100%; }


/* Symbol experiment v3: sidebar appearance trigger */
.hidden-appearance-color-input {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
.appearance-trigger {
  width: 46px;
  height: 42px;
  flex: 0 0 46px;
  border: 2px solid rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.94);
  color: #111;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  font-weight: 600;
  line-height: 1;
  padding: 0;
}
.appearance-trigger.color-mode {
  border-radius: 12px;
  color: transparent;
}
.appearance-trigger.symbol-mode {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}
.appearance-trigger:hover {
  box-shadow: 0 0 0 3px rgba(255,255,255,0.16);
}

.standard-color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.standard-color-swatch {
  width: 22px;
  height: 22px;
  border: 2px solid rgba(255,255,255,0.95);
  border-radius: 999px;
  padding: 0;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.22);
}
.standard-color-swatch:hover,
.standard-color-swatch:focus-visible {
  outline: 2px solid rgba(11, 76, 146,0.35);
  outline-offset: 2px;
}
.general-markup-controls .standard-color-swatches {
  margin-top: 0;
  flex-wrap: nowrap;
}
.general-markup-controls .standard-color-swatch {
  width: 18px;
  height: 18px;
}
