:root {
  --bg: #d9dfea;
  --panel: #efefef;
  --line: #d2d5de;
  --text: #2e3036;
  --accent: #4a54f4;
  --left-sidebar-width: 220px;
  --right-sidebar-width: 350px;
  --resize-handle-width: 2px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  font-family: Segoe UI, Tahoma, sans-serif;
  background: linear-gradient(180deg, #d5dcea 0%, #c9d1e0 100%);
  color: var(--text);
}


.app-shell {
  display: grid;
  grid-template-columns:
    var(--left-sidebar-width)
    var(--resize-handle-width)
    minmax(0, 1fr)
    var(--resize-handle-width)
    var(--right-sidebar-width);
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  column-gap: 0;
  row-gap: 0;
  padding: 0;
  overflow: hidden;
}

.sidebar {
  border: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.resize-handle {
  position: relative;
  width: var(--resize-handle-width);
  height: 100%;
  cursor: col-resize;
  border-radius: 8px;
  background: transparent;
}

.resize-handle::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 8px;
  bottom: 8px;
  width: 2px;
  transform: translateX(-50%);
  border-radius: 2px;
  background: rgba(83, 92, 113, 0.18);
  transition: background 140ms ease, box-shadow 140ms ease;
}

.resize-handle:hover::before,
.resize-handle.dragging::before {
  background: rgba(99, 90, 236, 0.72);
  box-shadow: 0 0 0 2px rgba(99, 90, 236, 0.15);
}

.sidebar-left {
  background: #cfd6e3;
  padding: 0;
}

.sidebar-shell {
  background: var(--panel);
  border-radius: 0;
  border: 0;
  box-shadow: 0 10px 24px rgba(40, 45, 57, 0.16);
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 8px;
}

.sidebar-left .sidebar-brand {
  display: none;
}

.brand-badge {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(140deg, #4a54f4 0%, #3d45d8 100%);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.brand-copy {
  min-width: 0;
}

.brand-title {
  font-size: 0.9rem;
  font-weight: 700;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: #6e7380;
}

.sidebar-right {
  border: 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 0;
  padding: 6px 10px 8px;
}

.sidebar-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #666b77;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.sidebar-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-search-wrap {
  padding: 8px 8px 4px;
}

.sidebar-search {
  width: 100%;
  border: 0;
  border-radius: 0;
  background: #e7e5ef;
  color: #5b5f6a;
  font: 600 0.85rem Segoe UI, Tahoma, sans-serif;
  padding: 9px 9px;
  outline: none;
}

.sidebar-search::placeholder {
  color: #666a78;
}

.hidden-file-input {
  display: none;
}

.icon-btn {
  width: 30px;
  height: 30px;
  border: 1px solid #d8dce8;
  border-radius: 0;
  background: linear-gradient(180deg, #fcfcff 0%, #eef1f8 100%);
  color: #4a566d;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(32, 36, 48, 0.1);
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
  font-size: 0.92rem;
  line-height: 1;
}

.icon-btn[aria-pressed="true"] {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(135deg, #4a54f4 0%, #3d45d8 100%);
  box-shadow: 0 8px 16px rgba(74, 84, 244, 0.32);
}

.icon-btn:disabled {
  cursor: default;
  opacity: 0.45;
  box-shadow: none;
}

.icon-btn:not(:disabled):hover {
  border-color: #c7cede;
  background: linear-gradient(180deg, #ffffff 0%, #edf1f8 100%);
  box-shadow: 0 5px 12px rgba(32, 36, 48, 0.14);
  transform: translateY(-1px);
}

.icon-btn:not(:disabled):active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(32, 36, 48, 0.12);
}

.icon-btn .icon-svg {
  width: 16px;
  height: 16px;
  display: block;
  object-fit: contain;
  opacity: 0.88;
  filter: saturate(0) brightness(0.45);
}

.icon-btn[aria-pressed="true"] .icon-svg {
  opacity: 1;
  filter: brightness(0) invert(1);
}

.thumbnail-list {
  flex: 1 1 auto;
  min-height: 0;
  padding: 6px 8px 10px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.thumbnail-item {
  display: block;
  width: 100%;
  border: 1px solid #dadde6;
  border-radius: 8px;
  padding: 6px;
  background: #fff;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

.thumbnail-item.active {
  border-color: #6a59ef;
  box-shadow: 0 0 0 2px rgba(102, 88, 237, 0.18);
}

.thumbnail-item canvas {
  width: 100%;
  display: block;
}

.thumbnail-label {
  margin-top: 6px;
  font-size: 0.8rem;
  text-align: center;
}

.page-rename-input {
  width: 100%;
  font: inherit;
  color: inherit;
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 2px 6px;
  outline: none;
  background: #fff;
}

.thumbnail-list.list-view .thumbnail-item {
  border: 0;
  border-radius: 7px;
  box-shadow: none;
  background: transparent;
  padding: 9px 8px;
  text-align: left;
}

.thumbnail-list.list-view .thumbnail-item canvas {
  display: none;
}

.thumbnail-list.list-view .thumbnail-label {
  margin-top: 0;
  text-align: left;
  font-size: 0.92rem;
  font-weight: 600;
  color: #5e5f66;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.thumbnail-list.list-view .thumbnail-label::before {
  content: "\1F4C4";
  font-size: 0.92rem;
  line-height: 1;
  opacity: 0.8;
}

.thumbnail-list.list-view .thumbnail-item.active {
  border-color: transparent;
  box-shadow: none;
  background: linear-gradient(90deg, #4a54f4 0%, #3d45d8 100%);
}

.thumbnail-list.list-view .thumbnail-item.active .thumbnail-label {
  color: #ffffff;
}

.thumbnail-list.list-view .thumbnail-item.active .thumbnail-label::before {
  opacity: 1;
}

.viewer-area {
  display: grid;
  grid-template-rows: 1fr;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.viewer-shell {
  display: grid;
  grid-template-rows: auto auto 1fr;
  min-width: 0;
  min-height: 0;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  background: var(--panel);
  box-shadow: 0 10px 24px rgba(40, 45, 57, 0.16);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: #ececf3;
  border-bottom: 0;
}

.toolbar-secondary {
  border-top: 1px solid #dde1eb;
  border-bottom: 1px solid #d8dee8;
}

.toolbar button {
  font: inherit;
}

.toolbar select,
.toolbar button {
  border: 1px solid #d2d6e3;
  border-radius: 0;
  background: #f6f6fb;
  color: #444a58;
  padding: 6px 10px;
}

/* Custom styled dropdowns / menus (group-by, context menus) */
.estimating-group-by-dropdown {
  position: relative;
  display: inline-block;
}

.estimating-group-by-button {
  height: 32px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: #f8fafd;
  color: #52657f;
  padding: 6px 10px;
  font: 600 0.8rem "Roboto", "Inter", "Segoe UI", Tahoma, sans-serif;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9), 0 4px 10px rgba(18, 36, 61, 0.08);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.estimating-group-by-button[aria-expanded="true"] {
  color: #ffffff;
  border-color: transparent;
  background: linear-gradient(135deg, #3c81ff 0%, #2a6ee8 100%);
  box-shadow: 0 10px 18px rgba(42, 110, 232, 0.24);
}

.estimating-group-by-button:hover {
  color: #ffffff;
  border-color: transparent;
  background: linear-gradient(135deg, #3c81ff 0%, #2a6ee8 100%);
  box-shadow: 0 10px 18px rgba(42, 110, 232, 0.24);
  transform: translateY(-1px);
}

.estimating-group-by-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(42, 110, 232, 0.18), 0 10px 18px rgba(42, 110, 232, 0.16);
}

.estimating-group-by-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  max-width: 360px;
  max-height: 300px;
  overflow: auto;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid rgba(30,44,88,0.06);
  box-shadow: 0 18px 36px rgba(16,24,40,0.18);
  padding: 8px;
  z-index: 70;
}

.estimating-group-by-menu-note {
  margin: 6px 8px;
  font: 600 0.78rem Segoe UI, Tahoma, sans-serif;
  color: #6b7280;
}

.estimating-group-by-list {
  display: grid;
  gap: 6px;
  padding: 6px;
}

.estimating-group-by-list > * {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  color: #243244;
  background: transparent;
  user-select: none;
}

.estimating-group-by-list > *:hover {
  background: linear-gradient(90deg,#f3f7ff 0%, #eef4ff 100%);
}

.estimating-group-by-list > *.is-selected {
  background: linear-gradient(90deg,#eaf0ff 0%, #dfe8ff 100%);
  box-shadow: 0 8px 20px rgba(58,64,145,0.08);
}

.estimating-group-by-list .item-label {
  min-width: 0;
  font: 600 0.9rem Segoe UI, Tahoma, sans-serif;
  color: #253244;
}

.estimating-group-by-list .item-meta {
  font: 500 0.78rem Segoe UI, Tahoma, sans-serif;
  color: #60708b;
}

.estimating-group-by-list .item-check {
  margin-left: auto;
  color: #3d45d8;
  font-weight: 800;
}

/* Scrollbar styling */
.estimating-group-by-menu::-webkit-scrollbar {
  width: 10px;
}
.estimating-group-by-menu::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #e6edf9 0%, #d9e6ff 100%);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

/* Generic custom dropdown used by toolbar selects */
.custom-dropdown {
  position: relative;
  display: inline-block;
}

.custom-dropdown-button {
  height: 32px;
  padding: 6px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: auto;
  min-width: 0;
  max-width: 100%;
}

.custom-dropdown-button .label {
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
}

.custom-dropdown-button .arrow {
  margin-left: auto;
  width: 14px;
  height: 14px;
  opacity: 0.9;
  display: inline-flex;
  align-items: center;
}

.custom-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 220px;
  max-width: 420px;
  max-height: 320px;
  overflow: auto;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid rgba(30,44,88,0.06);
  box-shadow: 0 18px 36px rgba(16,24,40,0.18);
  padding: 8px;
  z-index: 80;
}

.custom-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  color: #243244;
  user-select: none;
}

.custom-dropdown-item:hover,
.custom-dropdown-item.is-focused {
  background: linear-gradient(90deg,#f3f7ff 0%, #eef4ff 100%);
}

.custom-dropdown-item.is-selected {
  background: linear-gradient(90deg,#eaf0ff 0%, #dfe8ff 100%);
  box-shadow: 0 8px 20px rgba(58,64,145,0.06);
}

.custom-dropdown-item .item-label {
  font: 600 0.88rem Segoe UI, Tahoma, sans-serif;
}

.custom-dropdown-item .item-meta {
  font: 500 0.75rem Segoe UI, Tahoma, sans-serif;
  color: #64748b;
}

.custom-dropdown-item .item-check {
  margin-left: auto;
  color: #3d45d8;
  font-weight: 800;
}



.quick-add-toolbar {
  flex-wrap: wrap;
  gap: 8px;
  padding: 9px 12px;
  background: linear-gradient(180deg, #f8faff 0%, #eef3fb 100%);
  border-top: 1px solid #dce3ef;
  border-bottom: 1px solid #d4ddea;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.digitizer-toolbar {
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px;
  background: linear-gradient(180deg, #f4f8ff 0%, #e9f0fb 100%);
  border-top: 1px solid #d8e0ee;
  border-bottom: 1px solid #d3dcec;
}

header.toolbar.digitizer-toolbar {
  border-top: 0;
}

.digitizer-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: #3f4f67;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-right: 4px;
}

.digitizer-toolbar label {
  font: 700 0.75rem Segoe UI, Tahoma, sans-serif;
  color: #4f5f78;
}

.digitizer-toolbar select {
  height: 32px;
  border: 1px solid #e4e9f6;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f6f9ff 100%);
  color: #25374e;
  font: 600 0.8rem Segoe UI, Tahoma, sans-serif;
  padding: 6px 10px;
  padding-right: 32px; /* room for custom arrow */
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8), 0 3px 8px rgba(16,24,40,0.04);
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23454568' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.digitizer-toolbar select:focus {
  outline: 2px solid rgba(81,126,235,0.22);
  outline-offset: 2px;
  box-shadow: 0 6px 18px rgba(58,64,145,0.06);
}

.digitizer-toggle-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 2px;
  user-select: none;
}

.digitizer-stop-btn {
  height: 32px;
  border: 1px solid #d8dce8;
  border-radius: 0;
  background: linear-gradient(180deg, #fcfcff 0%, #eef1f8 100%);
  color: #4a566d;
  font: 600 0.8rem Segoe UI, Tahoma, sans-serif;
  padding: 0 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(32, 36, 48, 0.1);
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.digitizer-stop-btn:hover {
  border-color: #c7cede;
  background: linear-gradient(180deg, #ffffff 0%, #edf1f8 100%);
  transform: translateY(-1px);
  box-shadow: 0 5px 12px rgba(32, 36, 48, 0.14);
}

.digitizer-stop-btn:active {
  border-color: transparent;
  background: linear-gradient(135deg, #4a54f4 0%, #3d45d8 100%);
  color: #ffffff;
  transform: translateY(0);
  box-shadow: 0 8px 16px rgba(74, 84, 244, 0.32);
}

.digitizer-stop-btn:focus-visible {
  outline: 2px solid rgba(113, 157, 227, 0.4);
  outline-offset: 1px;
}

.digitizer-status {
  font: 600 0.76rem Segoe UI, Tahoma, sans-serif;
  color: #516680;
  margin-left: auto;
  max-width: min(50ch, 100%);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quick-add-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: #445066;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 2px;
}

.quick-add-input {
  height: 32px;
  border: 1px solid #ccd6e5;
  border-radius: 10px;
  background: linear-gradient(180deg, #ffffff 0%, #f7faff 100%);
  color: #1f2937;
  padding: 0 11px;
  font: 600 0.82rem Segoe UI, Tahoma, sans-serif;
  min-width: 64px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 1px 2px rgba(28, 41, 66, 0.06);
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.quick-add-input:focus {
  outline: 2px solid rgba(113, 157, 227, 0.35);
  border-color: #8baee0;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(113, 157, 227, 0.16);
}

.quick-add-description {
  flex: 1 1 280px;
  min-width: 220px;
}

.quick-add-unit {
  flex: 0 0 132px;
}

.quick-add-recommend-panel {
  position: fixed;
  z-index: 80;
  display: grid;
  gap: 4px;
  border: 1px solid #d7ddeb;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 14px 28px rgba(16, 24, 40, 0.2);
  padding: 6px;
  overflow: auto;
}

.quick-add-recommend-panel[hidden] {
  display: none !important;
}

.quick-add-recommend-item {
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: #ffffff;
  color: #1f344b;
  text-align: left;
  padding: 7px 9px;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.quick-add-recommend-item:hover,
.quick-add-recommend-item.is-active {
  background: #f3f7ff;
}

.quick-add-recommend-content {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.quick-add-recommend-icon {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #d4deec;
  background: #f8fbff;
  color: #39597c;
}

.quick-add-recommend-icon.is-assembly {
  background: #eef4ff;
  border-color: #cddbf3;
  color: #2f5f96;
}

.quick-add-recommend-icon.is-item {
  background: #f5f7fb;
  border-color: #d7deea;
  color: #4b5f79;
}

.quick-add-recommend-icon-img {
  width: 14px;
  height: 14px;
  display: block;
  object-fit: contain;
}

.quick-add-recommend-label {
  font: 600 0.8rem Segoe UI, Tahoma, sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quick-add-recommend-meta {
  font: 500 0.72rem Segoe UI, Tahoma, sans-serif;
  color: #64748b;
}

.quick-add-toolbar .quick-add-sort-types-btn {
  height: 32px;
  border: 1px solid #d8dce8;
  border-radius: 0;
  background: linear-gradient(180deg, #fcfcff 0%, #eef1f8 100%);
  color: #4a566d;
  font: 600 0.8rem Segoe UI, Tahoma, sans-serif;
  padding: 0 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(32, 36, 48, 0.1);
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.quick-add-toolbar .quick-add-sort-types-btn:hover {
  border-color: #c7cede;
  background: linear-gradient(180deg, #ffffff 0%, #edf1f8 100%);
  box-shadow: 0 5px 12px rgba(32, 36, 48, 0.14);
  transform: translateY(-1px);
}

.quick-add-toolbar .quick-add-sort-types-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(32, 36, 48, 0.12);
}

.quick-add-toolbar .quick-add-sort-types-btn:focus-visible {
  outline: 2px solid rgba(113, 157, 227, 0.35);
  outline-offset: 1px;
}

.quick-add-sort-types-summary {
  font-size: 0.76rem;
  color: #60708b;
  font-style: normal;
  font-weight: 600;
  max-width: 340px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 4px;
}

.quick-add-toolbar .quick-add-submit {
  height: 32px;
  border: 1px solid transparent;
  border-radius: 0;
  background: linear-gradient(135deg, #4a54f4 0%, #3d45d8 100%);
  color: #ffffff;
  font: 700 0.8rem Segoe UI, Tahoma, sans-serif;
  padding: 0 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 8px 16px rgba(74, 84, 244, 0.26);
  transition: box-shadow 140ms ease, transform 140ms ease, filter 140ms ease;
}

.quick-add-toolbar .quick-add-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 11px 18px rgba(74, 84, 244, 0.32);
  filter: brightness(1.02);
}

.quick-add-toolbar .quick-add-submit:active {
  transform: translateY(0);
  box-shadow: 0 6px 12px rgba(74, 84, 244, 0.24);
}

.quick-add-toolbar .quick-add-submit:focus-visible {
  outline: 2px solid rgba(113, 157, 227, 0.4);
  outline-offset: 1px;
}

.toolbar .toolbar-icon-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #d8dce8;
  border-radius: 0;
  background: linear-gradient(180deg, #fcfcff 0%, #eef1f8 100%);
  color: #4a566d;
  box-shadow: 0 2px 6px rgba(32, 36, 48, 0.1);
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
  line-height: 1;
}

.toolbar .toolbar-icon-btn:hover {
  border-color: #c7cede;
  background: linear-gradient(180deg, #ffffff 0%, #edf1f8 100%);
  box-shadow: 0 5px 12px rgba(32, 36, 48, 0.14);
  transform: translateY(-1px);
}

.toolbar .toolbar-icon-btn:active {
  border-color: transparent;
  background: linear-gradient(135deg, #4a54f4 0%, #3d45d8 100%);
  transform: translateY(0);
  box-shadow: 0 8px 16px rgba(74, 84, 244, 0.32);
}

.toolbar .toolbar-icon-btn:active .toolbar-icon-svg {
  opacity: 1;
  filter: brightness(0) invert(1);
}

.toolbar .toolbar-icon-svg {
  width: 16px;
  height: 16px;
  display: block;
  object-fit: contain;
  opacity: 0.88;
  filter: saturate(0) brightness(0.45);
}

.canvas-wrap {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 30% 20%, #e8ebf3 0%, #dde2ec 48%, #d4dae5 100%);
  min-width: 0;
  min-height: 0;
}

.canvas-wrap.is-digitizing::after {
  content: "";
  position: absolute;
  left: var(--digitizer-indicator-x, 16px);
  top: var(--digitizer-indicator-y, 16px);
  transform: translate(34px, -34px);
  z-index: 12;
  pointer-events: none;
  width: 18px;
  height: 18px;
  border-radius: 7px;
  border: 1px solid rgba(28, 106, 80, 0.36);
  background: linear-gradient(135deg, rgba(40, 166, 128, 0.92) 0%, rgba(24, 123, 95, 0.92) 100%);
  box-shadow: 0 5px 14px rgba(17, 88, 68, 0.28);
  color: #ffffff;
  font: 800 12px/18px Segoe UI, Tahoma, sans-serif;
  text-align: center;
  animation: digitizer-indicator-pulse 1.8s ease-in-out infinite;
  opacity: 0;
  transition: opacity 120ms ease;
}

.canvas-wrap.is-digitizing.show-cursor-indicator::after {
  opacity: 1;
}

.canvas-wrap.is-digitizing.digitizer-mode-count::after {
  content: "•";
}

.canvas-wrap.is-digitizing.digitizer-mode-linear::after {
  content: "／";
}

.canvas-wrap.is-digitizing.digitizer-mode-area::after {
  content: "□";
}

#vectorLayer.vector-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

#takeoffOverlaySurface.takeoff-overlay-surface {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 6;
}

#takeoffOverlaySurface svg {
  position: absolute;
  left: 0;
  top: 0;
}

.takeoff-entity {
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.takeoff-entity.is-item-active {
  stroke-width: 3.2;
  stroke-opacity: 1;
  filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.85)) drop-shadow(0 0 5px rgba(30, 64, 120, 0.45));
}

.takeoff-entity.is-selected {
  stroke: #f97316;
}

.takeoff-entity.is-hovered {
  stroke: #22d3ee;
  stroke-width: 3.4;
  stroke-opacity: 1;
  filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.9)) drop-shadow(0 0 7px rgba(34, 211, 238, 0.62));
}

.takeoff-entity.is-dimmed {
  opacity: 0.2;
  filter: saturate(0.45);
}

.takeoff-count-dot {
  stroke: #ffffff;
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.takeoff-count-dot.is-item-active {
  stroke-width: 2.4;
  filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.85)) drop-shadow(0 0 5px rgba(30, 64, 120, 0.45));
}

.takeoff-count-dot.is-selected {
  fill: #f97316;
}

.takeoff-count-dot.is-hovered {
  fill: #22d3ee;
  stroke: #ffffff;
  stroke-width: 2.2;
  filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.9)) drop-shadow(0 0 7px rgba(34, 211, 238, 0.62));
}

.takeoff-count-dot.is-dimmed {
  opacity: 0.24;
}

.takeoff-preview-area {
  fill: rgba(30, 79, 224, 0.12);
  stroke: #2b5de2;
  stroke-width: 2;
  stroke-dasharray: 6 4;
  vector-effect: non-scaling-stroke;
}

.takeoff-preview-line {
  fill: none;
  stroke: #2b5de2;
  stroke-width: 2;
  stroke-dasharray: 6 4;
  vector-effect: non-scaling-stroke;
}

.takeoff-handle {
  fill: #ffffff;
  stroke: #f97316;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.takeoff-handle.is-selected-vertex {
  fill: #f97316;
  stroke: #ffffff;
  stroke-width: 2.2;
  filter: drop-shadow(0 0 3px rgba(249, 115, 22, 0.7));
}

.takeoff-handle-arc-mid {
  fill: #eff6ff;
  stroke: #2563eb;
  stroke-width: 2;
}

.takeoff-cursor-guide {
  stroke: #0f172a;
  stroke-opacity: 1;
  stroke-width: 1.4;
  stroke-dasharray: 6 4;
  mix-blend-mode: normal;
  filter: drop-shadow(0 0 1px rgba(255, 255, 255, 0.9));
  vector-effect: non-scaling-stroke;
}

.takeoff-cursor-center {
  fill: #0f172a;
  stroke: #38bdf8;
  stroke-width: 1.6;
  mix-blend-mode: normal;
  filter: drop-shadow(0 0 2px rgba(56, 189, 248, 0.6));
  vector-effect: non-scaling-stroke;
}

.takeoff-selection-rect {
  fill: rgba(37, 99, 235, 0.14);
  stroke: #2563eb;
  stroke-width: 1.4;
  stroke-dasharray: 5 4;
  vector-effect: non-scaling-stroke;
}

.takeoff-label {
  font: 700 11px Segoe UI, Tahoma, sans-serif;
  fill: #263a58;
  paint-order: stroke;
  stroke: rgba(255, 255, 255, 0.92);
  stroke-width: 3;
  stroke-linejoin: round;
}

.takeoff-label.is-dimmed {
  opacity: 0.2;
}

#vectorLayer svg {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
}

#glCanvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

#glCanvas.digitizing {
  cursor: crosshair;
}

#glCanvas.digitizing:not(.dragging) {
  cursor: crosshair !important;
}

#glCanvas.select-target:not(.dragging):not(.digitizing) {
  cursor: pointer !important;
}

#glCanvas.dragging {
  cursor: grabbing;
}

@keyframes digitizer-indicator-pulse {
  0%,
  100% {
    transform: translateY(0);
    box-shadow: 0 5px 14px rgba(17, 88, 68, 0.28);
  }
  50% {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(17, 88, 68, 0.36);
  }
}

#statusText {
  font-size: 0.9rem;
  color: #3f4a59;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-placeholder {
  padding: 12px;
  color: #6a7080;
  font-size: 0.9rem;
}

.takeoff-items-panel {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 8px;
  padding: 8px;
}

.takeoff-table-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.takeoff-table-search {
  width: 100%;
  height: 32px;
  border: 1px solid #ced7e7;
  border-radius: 0;
  background: #ffffff;
  color: #223247;
  font: 600 0.8rem Segoe UI, Tahoma, sans-serif;
  padding: 0 10px;
}

.takeoff-table-search:focus {
  outline: 2px solid rgba(111, 144, 214, 0.35);
  border-color: #8ca8dc;
}

.takeoff-group-by-dropdown {
  position: relative;
}

.takeoff-group-by-dropdown .estimating-group-by-button {
  height: 32px;
  border: 1px solid #d8dce8;
  border-radius: 0;
  background: linear-gradient(180deg, #fcfcff 0%, #eef1f8 100%);
  color: #4a566d;
  font: 600 0.78rem Segoe UI, Tahoma, sans-serif;
  padding: 0 10px;
  white-space: nowrap;
}

.takeoff-group-by-dropdown .takeoff-group-by-icon-button {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.takeoff-group-by-icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.takeoff-group-by-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 25;
  width: min(320px, 70vw);
  border: 1px solid #d3dae8;
  border-radius: 0;
  background: #ffffff;
  box-shadow: 0 14px 32px rgba(19, 28, 45, 0.22);
  padding: 10px;
}

.estimating-group-by-menu-note {
  margin: 0 0 8px;
  font: 600 0.72rem Segoe UI, Tahoma, sans-serif;
  color: #5f6f87;
}

.estimating-group-by-list {
  display: grid;
  gap: 6px;
}

.estimating-group-by-option {
  display: grid;
  grid-template-columns: 20px auto 1fr;
  align-items: center;
  gap: 8px;
  border: 1px solid #dce2ef;
  border-radius: 9px;
  background: #f9fbff;
  padding: 6px 8px;
}

.estimating-group-by-option.is-drag-over {
  border-color: #9db4de;
  background: #edf4ff;
}

.estimating-group-by-option.is-dragging {
  opacity: 0.55;
}

.estimating-group-by-drag {
  color: #8ea0bb;
  font: 700 0.7rem Segoe UI, Tahoma, sans-serif;
  user-select: none;
  cursor: grab;
}

.estimating-group-by-option-label {
  font: 600 0.76rem Segoe UI, Tahoma, sans-serif;
  color: #334c6c;
}

.takeoff-group-menu-actions {
  margin-top: 8px;
  display: inline-flex;
  gap: 6px;
}

.takeoff-group-menu-button {
  height: 28px;
  border: 1px solid #d4dbe9;
  border-radius: 8px;
  background: #f7f9fd;
  color: #394c67;
  font: 700 0.72rem Segoe UI, Tahoma, sans-serif;
  padding: 0 8px;
  cursor: pointer;
}

.takeoff-items-table-wrap {
  min-height: 0;
  overflow: auto;
  border: 1px solid #d7deec;
  border-radius: 10px;
  background: #ffffff;
}

.takeoff-items-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.takeoff-items-table col.takeoff-col-qty {
  width: 76px;
}

.takeoff-items-table col.takeoff-col-unit {
  width: 56px;
}

.takeoff-items-table thead {
  display: none;
}

.takeoff-items-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: linear-gradient(180deg, #f5f8ff 0%, #e9eef8 100%);
  color: #43546f;
  font: 700 0.72rem Segoe UI, Tahoma, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  text-align: left;
  padding: 7px 8px;
  border-bottom: 1px solid #d7deea;
}

.takeoff-items-table td {
  padding: 7px 8px;
  border-bottom: 1px solid #edf1f8;
  font: 600 0.78rem Segoe UI, Tahoma, sans-serif;
  color: #2d3b4f;
  vertical-align: middle;
}

.takeoff-items-table tbody tr.takeoff-data-row:hover td {
  background: #f8fbff;
}

.takeoff-items-table tbody tr.takeoff-data-row td {
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.takeoff-items-table tbody tr.takeoff-data-row.is-active td {
  background: linear-gradient(90deg, #edf4ff 0%, #e5efff 55%, #edf4ff 100%);
  background-size: 220% 100%;
  animation: takeoff-active-sheen 2.8s ease-in-out infinite;
}

.takeoff-items-table tbody tr.takeoff-data-row.is-selected-item:not(.is-active) td {
  background: #f4f8ff;
}

.takeoff-items-table tbody tr.takeoff-data-row.is-selected-item:not(.is-active) td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}

.takeoff-items-table tbody tr.takeoff-data-row.is-measurement-selected:not(.is-active) td {
  background: #eef4ff;
}

.takeoff-items-table tbody tr.takeoff-data-row.is-measurement-selected:not(.is-active) td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}

.takeoff-items-table tbody tr.takeoff-data-row.is-db-dirty:not(.is-active):not(.is-selected-item) td:first-child {
  box-shadow: inset 3px 0 0 #3d45d8;
}

.takeoff-items-table tbody tr.takeoff-data-row.is-dragging-item td {
  opacity: 0.62;
}

.takeoff-items-table tbody tr.takeoff-data-row.is-drop-target td {
  background: #e8f6ff !important;
  box-shadow: inset 0 0 0 1px #8ec8ea;
}

.takeoff-items-table tbody tr.takeoff-data-row.is-active td:first-child {
  box-shadow: inset 3px 0 0 #d74a4a;
}

.takeoff-items-table tbody tr.takeoff-data-row.is-active .takeoff-item-name {
  color: #1f3f70;
  text-shadow: 0 0 0 rgba(0, 0, 0, 0), 0 0 10px rgba(74, 125, 224, 0.18);
}

.takeoff-items-table tbody tr.takeoff-data-row.is-active .takeoff-mode-icon {
  animation: takeoff-active-breathe 1.8s ease-in-out infinite;
  filter: drop-shadow(0 0 6px rgba(74, 125, 224, 0.32));
}

.takeoff-items-table tbody tr:last-child td {
  border-bottom: 0;
}

.takeoff-name-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  width: 100%;
}

.takeoff-child-name-cell {
  padding-left: 26px;
  color: #4f6078;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.takeoff-qty-cell,
.takeoff-unit-cell {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.takeoff-qty-cell {
  text-align: right;
}

.takeoff-item-toggle {
  width: 20px;
  height: 20px;
  min-width: 20px;
  border: 1px solid #d1d9e8;
  border-radius: 6px;
  background: #f8fbff;
  color: #3f5f86;
  font-size: 0.76rem;
  line-height: 1;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.takeoff-item-toggle-spacer {
  width: 20px;
  min-width: 20px;
  height: 20px;
  display: inline-block;
}

.takeoff-item-toggle:hover {
  background: #eef4ff;
}

.takeoff-mode-icon {
  width: 18px;
  min-width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  color: #3f5f86;
}

.takeoff-mode-icon svg {
  width: 14px;
  height: 14px;
  display: block;
}

.takeoff-mode-icon-image {
  width: 14px;
  height: 14px;
  display: block;
}

.takeoff-mode-icon-glyph {
  width: 14px;
  height: 14px;
  display: block;
  background-color: currentColor;
  -webkit-mask-image: var(--takeoff-icon-mask);
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;
  mask-image: var(--takeoff-icon-mask);
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
}

.takeoff-mode-icon-glyph-linear {
  mask-size: 14px 14px;
  -webkit-mask-size: 14px 14px;
}

.takeoff-mode-icon-glyph-segment {
  mask-size: 12px 12px;
  -webkit-mask-size: 12px 12px;
}

.takeoff-mode-icon-glyph-area {
  mask-size: 14px 14px;
  -webkit-mask-size: 14px 14px;
}

.takeoff-mode-toggle {
  cursor: pointer;
}

.takeoff-mode-toggle:focus-visible {
  outline: 2px solid rgba(113, 157, 227, 0.42);
  outline-offset: 1px;
  border-radius: 6px;
}

.takeoff-mode-icon-area {
  color: #2a6f5b;
}

.takeoff-mode-icon-linear {
  color: #2f5fa8;
}

.takeoff-mode-icon-segment {
  color: #1d4f91;
}

.takeoff-mode-icon-count {
  color: #8a5b22;
}

.takeoff-item-name {
  font: 700 0.8rem Segoe UI, Tahoma, sans-serif;
  color: #2a384d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.takeoff-item-push-db-btn {
  height: 18px;
  min-width: 24px;
  border: 1px solid #d1d9e8;
  border-radius: 6px;
  background: #f8fbff;
  color: #3f5f86;
  font: 700 0.62rem Segoe UI, Tahoma, sans-serif;
  letter-spacing: 0.02em;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  cursor: pointer;
}

.takeoff-item-push-db-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.takeoff-item-push-db-btn:not(:disabled):hover {
  border-color: #3d45d8;
  background: #eef1ff;
  color: #2f38c5;
}

.takeoff-assembly-child-row td {
  background: #f9fbff;
  color: #556984;
  cursor: pointer;
}

.takeoff-assembly-child-row.is-parent-active td {
  background: linear-gradient(90deg, #f3f8ff 0%, #ecf4ff 100%);
}

.takeoff-assembly-child-row.is-parent-active td:first-child {
  box-shadow: inset 2px 0 0 #8cb0ee;
}

@keyframes takeoff-active-sheen {
  0% {
    background-position: 0% 0%;
  }
  50% {
    background-position: 100% 0%;
  }
  100% {
    background-position: 0% 0%;
  }
}

@keyframes takeoff-active-breathe {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.9;
  }
  50% {
    transform: scale(1.08);
    opacity: 1;
  }
}

.takeoff-group-row td {
  padding: 0;
  border-bottom: 1px solid #dfe6f2;
  background: linear-gradient(180deg, #f3f7ff 0%, #ecf2fd 100%);
}

.takeoff-group-toggle {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 7px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #38506f;
  font: 700 0.75rem Segoe UI, Tahoma, sans-serif;
  cursor: pointer;
}

.takeoff-group-toggle .estimating-group-name {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
}

.takeoff-group-toggle .estimating-group-total {
  color: #4f6482;
  font-weight: 700;
}

.takeoff-group-row[data-group-level="2"] td {
  background: linear-gradient(180deg, #f8fbff 0%, #f1f6ff 100%);
}

.takeoff-group-row[data-group-level="3"] td {
  background: linear-gradient(180deg, #fbfdff 0%, #f5f9ff 100%);
}

.takeoff-group-row[data-group-level="2"] .takeoff-group-toggle {
  padding-left: 18px;
}

.takeoff-group-row[data-group-level="3"] .takeoff-group-toggle {
  padding-left: 26px;
}

.sort-type-modal {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(20, 25, 38, 0.42);
}

#sortTypeModal {
  z-index: 40;
}

.sort-type-modal[hidden] {
  display: none !important;
}

.sort-type-modal-card {
  width: min(700px, calc(100% - 28px));
  max-height: min(80vh, 650px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 10px;
  border: 1px solid #d6dcea;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 20px 44px rgba(11, 26, 45, 0.25);
  padding: 12px;
}

.sort-type-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sort-type-modal-header h3 {
  margin: 0;
  font-size: 1rem;
  color: #243247;
}

.sort-type-modal-close,
.sort-type-modal-add,
.sort-type-modal-cancel,
.sort-type-modal-save {
  height: 30px;
  border-radius: 8px;
  font: 700 0.8rem Segoe UI, Tahoma, sans-serif;
  cursor: pointer;
}

.sort-type-modal-close,
.sort-type-modal-cancel {
  border: 1px solid #d1d7e3;
  background: #f8f9fd;
  color: #3f4a5b;
  padding: 0 10px;
}

.sort-type-modal-add {
  border: 1px solid #cdd6e8;
  background: #eef3ff;
  color: #2f4672;
  padding: 0 10px;
}

.sort-type-modal-save {
  border: 1px solid transparent;
  background: linear-gradient(135deg, #4a54f4 0%, #3d45d8 100%);
  color: #ffffff;
  padding: 0 12px;
}

.sort-type-assignments-list {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sort-type-assignment-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border: 1px solid #d8deea;
  border-radius: 10px;
  background: #f9fbff;
  padding: 8px;
}

.sort-type-assignment-row select {
  width: 100%;
  height: 30px;
  border: 1px solid #ced6e4;
  border-radius: 8px;
  background: #ffffff;
  color: #334256;
  padding: 0 8px;
  font: 600 0.8rem Segoe UI, Tahoma, sans-serif;
}

.sort-type-assignment-remove {
  height: 30px;
  border: 1px solid #ddcfd1;
  border-radius: 8px;
  background: #fff6f6;
  color: #8e3d42;
  font: 700 0.74rem Segoe UI, Tahoma, sans-serif;
  padding: 0 9px;
  cursor: pointer;
}

.sort-type-modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sort-type-modal-actions-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.takeoff-item-modal-card {
  width: min(640px, 96vw);
  max-height: min(90vh, 760px);
  overflow: visible;
}

.create-folder-modal-card {
  width: min(460px, calc(100% - 28px));
  max-height: min(46vh, 280px);
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.takeoff-instances-modal-card {
  width: min(560px, calc(100% - 28px));
  max-height: min(72vh, 560px);
}

.takeoff-instances-modal-body {
  display: grid;
  gap: 8px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.takeoff-instances-list {
  display: grid;
  gap: 8px;
}

.takeoff-instances-empty {
  border: 1px dashed #d6deea;
  border-radius: 10px;
  background: #ffffff;
  color: #5e6f87;
  font: 600 0.76rem Segoe UI, Tahoma, sans-serif;
  padding: 12px;
}

.takeoff-instance-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid #d8deea;
  border-radius: 10px;
  background: #f9fbff;
  padding: 10px;
}

.takeoff-instance-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.takeoff-instance-title {
  color: #2f425d;
  font: 700 0.8rem Segoe UI, Tahoma, sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.takeoff-instance-meta {
  color: #63758f;
  font: 600 0.72rem Segoe UI, Tahoma, sans-serif;
}

.takeoff-instance-sort-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.takeoff-instance-sort-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 10px;
  font: 700 0.7rem Segoe UI, Tahoma, sans-serif;
  white-space: nowrap;
}

.takeoff-instance-sort-pill.is-assigned {
  background: #e8f1ff;
  color: #1849a9;
  border: 1px solid #cddaff;
}

.takeoff-instance-sort-pill.is-inherited {
  background: #f5f5f5;
  color: #52525b;
  border: 1px solid #e4e4e7;
}

.takeoff-instance-open {
  height: 30px;
  border: 1px solid #d1d7e3;
  border-radius: 8px;
  background: #f8f9fd;
  color: #3f4a5b;
  font: 700 0.78rem Segoe UI, Tahoma, sans-serif;
  padding: 0 12px;
  cursor: pointer;
}

.takeoff-instance-open:hover {
  background: #eef4ff;
  border-color: #c3d0e2;
}

.create-folder-modal-body {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.create-folder-modal-label {
  display: block;
  font: 700 0.74rem Segoe UI, Tahoma, sans-serif;
  color: #4a5b73;
  margin-bottom: 2px;
}

.create-folder-modal-input {
  width: 100%;
}

.create-folder-modal-input:focus {
  outline: none;
  border-color: #8baee0;
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(42, 110, 232, 0.2);
}

.create-folder-modal-input.is-invalid {
  border-color: #d55a5a;
  box-shadow: 0 0 0 1px rgba(213, 90, 90, 0.12);
  background: #fff8f8;
}

.create-folder-modal-error {
  margin: 0;
  color: #b23d3d;
  font: 700 0.72rem Segoe UI, Tahoma, sans-serif;
}

.takeoff-item-modal-body {
  display: grid;
  gap: 10px;
  min-height: 0;
  overflow: visible;
  padding-right: 2px;
}

.takeoff-item-modal-body .custom-dropdown,
.takeoff-item-modal-body .custom-listbox-wrap {
  overflow: visible;
}

.takeoff-item-modal-body .custom-dropdown-menu {
  z-index: 1405;
}

.takeoff-item-modal-body .custom-dropdown-host-takeoffItemModalAreaFillStyle .custom-dropdown-menu {
  left: auto;
  right: 0;
  min-width: 240px;
  max-height: none;
  overflow: visible;
}

.takeoff-item-modal-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.takeoff-item-modal-label {
  display: block;
  font: 700 0.74rem Segoe UI, Tahoma, sans-serif;
  color: #4a5b73;
  margin-bottom: 4px;
}

.takeoff-item-modal-input {
  width: 100%;
}

.takeoff-item-modal-input.is-invalid {
  border-color: #d55a5a;
  box-shadow: 0 0 0 1px rgba(213, 90, 90, 0.12);
  background: #fff8f8;
}

.takeoff-item-modal-error {
  margin: -4px 0 2px;
  color: #b23d3d;
  font: 700 0.7rem Segoe UI, Tahoma, sans-serif;
}

.takeoff-item-modal-color {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  padding: 0;
  border: 0;
}

.takeoff-item-modal-color-control {
  position: relative;
}

.takeoff-item-modal-color-dropdown {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  cursor: pointer;
  background-image: none !important;
  padding-right: 10px !important;
}

.takeoff-item-modal-color-dropdown::after {
  content: "";
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  background: currentColor;
  opacity: 0.65;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 20 20'%3E%3Cpath d='M5 7.5L10 12.5L15 7.5' stroke='black' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 20 20'%3E%3Cpath d='M5 7.5L10 12.5L15 7.5' stroke='black' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
}

.takeoff-item-modal-color-dropdown:disabled {
  cursor: not-allowed;
  opacity: 0.66;
}

.takeoff-item-modal-color-preview {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(30, 41, 59, 0.24);
  flex: 0 0 14px;
}

.takeoff-item-modal-color-label {
  min-width: 0;
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.takeoff-item-modal-color-palette-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 75;
  width: min(248px, 100%);
  border: 1px solid #d4dfef;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 16px 28px rgba(15, 23, 42, 0.2);
  padding: 8px;
  display: grid;
  gap: 8px;
}

.takeoff-item-modal-color-palette-menu[hidden] {
  display: none !important;
}

.takeoff-item-modal-color-palette {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}

.takeoff-item-modal-color-swatch {
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 1px solid rgba(133, 152, 178, 0.45);
  border-radius: 8px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 1px 2px rgba(15, 23, 42, 0.12);
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.takeoff-item-modal-color-swatch:hover {
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 4px 8px rgba(15, 23, 42, 0.16);
}

.takeoff-item-modal-color-swatch.is-selected {
  border-color: #1d4ed8;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.takeoff-item-modal-color-palette.is-disabled,
.takeoff-item-modal-color-palette-menu .takeoff-item-modal-color-custom:disabled {
  opacity: 0.58;
}

.takeoff-item-modal-color-palette.is-disabled .takeoff-item-modal-color-swatch {
  cursor: not-allowed;
  transform: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.takeoff-item-modal-color-custom {
  height: 30px;
  border: 1px solid #d1d7e3;
  border-radius: 8px;
  background: #f8f9fd;
  color: #3f4a5b;
  font: 700 0.78rem Segoe UI, Tahoma, sans-serif;
  cursor: pointer;
}

.takeoff-formula-helper-menu {
  z-index: 1400;
  max-height: 260px;
}

.takeoff-formula-helper-item {
  grid-template-columns: minmax(0, 1fr);
  padding: 8px 10px;
}

.takeoff-formula-helper-item .quick-add-recommend-label {
  font-family: "Consolas", "SFMono-Regular", Menlo, Monaco, monospace;
  font-size: 0.78rem;
}

.takeoff-item-modal-note {
  margin: 0;
  font: 600 0.73rem Segoe UI, Tahoma, sans-serif;
  color: #63758f;
}

.takeoff-item-modal-advanced {
  margin-top: 2px;
  border: 1px solid #d8e0ee;
  border-radius: 10px;
  background: #f9fbff;
  padding: 6px 8px 8px;
}

.takeoff-item-modal-advanced > summary {
  cursor: pointer;
  color: #415672;
  font: 700 0.74rem Segoe UI, Tahoma, sans-serif;
  user-select: none;
}

.takeoff-item-modal-advanced-grid {
  margin-top: 8px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 8px;
  row-gap: 6px;
  align-items: center;
}

.takeoff-item-modal-advanced-grid .takeoff-item-modal-label {
  margin: 0;
}

.takeoff-item-modal-advanced-grid .takeoff-item-modal-input[readonly] {
  background: #ffffff;
  color: #0f172a;
}

.takeoff-item-assembly-list {
  border: 1px solid #d8e0ee;
  border-radius: 10px;
  background: #f9fbff;
  padding: 8px;
  max-height: 190px;
  overflow: auto;
}

.takeoff-item-assembly-title {
  font: 700 0.74rem Segoe UI, Tahoma, sans-serif;
  color: #415672;
  margin-bottom: 6px;
}

.takeoff-item-assembly-grid {
  display: grid;
  gap: 5px;
}

.takeoff-item-assembly-row {
  font: 600 0.74rem Segoe UI, Tahoma, sans-serif;
  color: #2f425d;
  border: 1px solid #dde4f0;
  border-radius: 8px;
  background: #ffffff;
  padding: 6px 8px;
}

.takeoff-item-variables-list {
  border: 1px solid #d8e0ee;
  border-radius: 10px;
  background: #f9fbff;
  padding: 6px;
  max-height: 190px;
  overflow: auto;
  display: grid;
  gap: 4px;
}

.takeoff-item-variables-title {
  font: 700 0.74rem Segoe UI, Tahoma, sans-serif;
  color: #415672;
}

.takeoff-item-variables-section-title {
  font: 700 0.72rem Segoe UI, Tahoma, sans-serif;
  color: #4f6480;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.takeoff-item-variable-row {
  border: 1px solid #dde4f0;
  border-radius: 7px;
  background: #ffffff;
  padding: 5px 6px;
  display: grid;
  grid-template-columns: minmax(84px, 1fr) minmax(120px, 1.1fr);
  gap: 6px;
  align-items: center;
}

.takeoff-item-variable-name {
  font: 700 0.69rem Segoe UI, Tahoma, sans-serif;
  color: #2f425d;
  line-height: 1.1;
}

.takeoff-item-variable-value-wrap {
  display: flex;
  justify-content: flex-end;
}

.takeoff-item-variable-readonly {
  width: 100%;
  min-height: 28px;
  border: 1px solid #d6deeb;
  border-radius: 8px;
  background: #f7f9fd;
  color: #314761;
  font: 600 0.72rem Segoe UI, Tahoma, sans-serif;
  padding: 6px 8px;
  display: flex;
  align-items: center;
}

.takeoff-item-variable-value-wrap .takeoff-item-modal-input {
  width: 100%;
  min-width: 0;
  min-height: 28px;
  height: 28px;
  padding-top: 3px;
  padding-bottom: 3px;
  font-size: 0.72rem;
  border-radius: 8px;
}

.takeoff-item-variable-checkbox {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.takeoff-item-custom-variables {
  border: 1px solid #d8e0ee;
  border-radius: 10px;
  background: #f9fbff;
  padding: 8px;
  display: grid;
  gap: 8px;
}

.takeoff-item-custom-variables-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.takeoff-item-custom-variables-title {
  font: 700 0.74rem Segoe UI, Tahoma, sans-serif;
  color: #415672;
}

.takeoff-item-custom-variables-add {
  width: 28px;
  min-width: 28px;
  height: 28px;
  border: 1px solid #ccd8ec;
  border-radius: 8px;
  background: #ffffff;
  color: #2e466c;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.takeoff-item-custom-variables-add svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.takeoff-item-custom-variables-list {
  display: grid;
  gap: 6px;
}

.takeoff-item-custom-variable-row {
  display: grid;
  grid-template-columns: 1fr 1fr 0.7fr auto;
  gap: 6px;
  align-items: center;
}

.takeoff-item-custom-variable-remove {
  height: 30px;
  border: 1px solid #e4c7ca;
  border-radius: 8px;
  background: #fff4f4;
  color: #94414b;
  font: 700 0.72rem Segoe UI, Tahoma, sans-serif;
  padding: 0 10px;
  cursor: pointer;
}

.takeoff-item-custom-variable-empty {
  font: 600 0.72rem Segoe UI, Tahoma, sans-serif;
  color: #5e6f87;
  border: 1px dashed #d6deea;
  border-radius: 8px;
  padding: 8px;
  background: #ffffff;
}

.takeoff-item-modal-delete {
  height: 32px;
  border: 1px solid #e4c7ca;
  border-radius: 8px;
  background: #fff4f4;
  color: #94414b;
  font: 700 0.78rem Segoe UI, Tahoma, sans-serif;
  padding: 0 12px;
  cursor: pointer;
}

.estimating-fill-menu.takeoff-row-context-menu {
  position: fixed;
  z-index: 1400;
  width: 156px;
  min-width: 156px;
  max-width: 156px;
  padding: 4px;
  border: 1px solid #d0d9e6;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.16);
}

.estimating-fill-menu.digitizer-canvas-context-menu {
  position: fixed;
  z-index: 1401;
  width: 170px;
  min-width: 170px;
  max-width: 170px;
  padding: 4px;
  border: 1px solid #d0d9e6;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.16);
}

.digitizer-canvas-context-menu .estimating-fill-menu-item {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #0f172a;
  text-align: left;
  font: 600 0.78rem Segoe UI, Tahoma, sans-serif;
  padding: 6px 9px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.digitizer-canvas-context-menu .estimating-fill-menu-item:hover {
  background: #eff6ff;
  border-color: #cfe2ff;
}

.digitizer-canvas-context-menu .estimating-fill-menu-item:active {
  background: #dbeafe;
  border-color: #bfd7fb;
}

.digitizer-canvas-context-menu .estimating-fill-menu-item:focus-visible {
  outline: 2px solid rgba(113, 157, 227, 0.4);
  outline-offset: 1px;
}

.estimating-fill-menu-item.takeoff-row-context-item {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #0f172a;
  text-align: left;
  font-size: 0.78rem;
  padding: 5px 8px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.estimating-fill-menu-item.takeoff-row-context-item:hover {
  background: #eff6ff;
  border-color: #cfe2ff;
}

.takeoff-hover-pick-label {
  position: fixed;
  z-index: 1600;
  pointer-events: none;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid #7dd3fc;
  background: rgba(12, 35, 56, 0.92);
  color: #e0f2fe;
  font: 700 0.72rem Segoe UI, Tahoma, sans-serif;
  white-space: nowrap;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.28);
}

@media (max-width: 960px) {
  :root {
    --left-sidebar-width: 160px;
    --right-sidebar-width: 160px;
  }
}

/* Modern flat theme override */
:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --line: #d8dee8;
  --text: #1f2937;
  --accent: #2563eb;
}

body {
  font-family: "Roboto", "Inter", "Segoe UI", Tahoma, sans-serif;
  background: #f4f6fa;
  color: var(--text);
}

button,
input,
select,
textarea {
  font-family: "Roboto", "Inter", "Segoe UI", Tahoma, sans-serif;
}

.sidebar-left,
.sidebar-right,
.viewer-area {
  background: #f4f6fa;
}

.sidebar-shell,
.viewer-shell {
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.resize-handle::before {
  top: 0;
  bottom: 0;
  background: #d8dee8;
}

.resize-handle:hover::before,
.resize-handle.dragging::before {
  background: #94a3b8;
  box-shadow: none;
}

.sidebar-title {
  color: #475569;
}

.sidebar-search,
.takeoff-table-search,
.quick-add-input {
  background: #f8fafc;
  border: 1px solid #d8dee8;
  color: #1f2937;
  box-shadow: none;
}

.sidebar-search::placeholder,
.takeoff-table-search::placeholder {
  color: #94a3b8;
}

.toolbar,
.quick-add-toolbar,
.digitizer-toolbar,
.toolbar-secondary {
  background: #ffffff;
  border-color: #e2e8f0;
  box-shadow: none;
}

.icon-btn,
.toolbar .toolbar-icon-btn,
.digitizer-stop-btn,
.quick-add-toolbar .quick-add-sort-types-btn,
.takeoff-group-by-dropdown .estimating-group-by-button,
.custom-dropdown .estimating-group-by-button {
  background: #ffffff;
  border-color: #d0d7e2;
  color: #334155;
  box-shadow: none;
}

.icon-btn[aria-pressed="true"],
.toolbar .toolbar-icon-btn:active,
.digitizer-stop-btn:active,
.quick-add-toolbar .quick-add-submit,
.thumbnail-list.list-view .thumbnail-item.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
  box-shadow: none;
}

.icon-btn:not(:disabled):hover,
.toolbar .toolbar-icon-btn:hover,
.digitizer-stop-btn:hover,
.quick-add-toolbar .quick-add-sort-types-btn:hover {
  background: #f1f5f9;
  border-color: #c7d1df;
  transform: none;
  box-shadow: none;
}

.quick-add-toolbar .quick-add-submit:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
  transform: none;
  box-shadow: none;
  filter: none;
}

.thumbnail-item,
.takeoff-group-by-menu,
.quick-add-recommend-panel,
.digitizer-canvas-context-menu {
  background: #ffffff;
  border-color: #d8dee8;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.thumbnail-item.active {
  border-color: #2563eb;
  box-shadow: inset 0 0 0 1px #2563eb;
}

.canvas-wrap {
  background: #eef2f7;
}

.canvas-wrap.is-digitizing::after {
  background: #0f766e;
  box-shadow: none;
}

/* Keep takeoff controls rounded on the embedded viewer. */
button,
.toolbar button,
.icon-btn,
.toolbar .toolbar-icon-btn,
.digitizer-stop-btn,
.quick-add-toolbar .quick-add-sort-types-btn,
.quick-add-toolbar .quick-add-submit,
.takeoff-group-by-dropdown .estimating-group-by-button,
.custom-dropdown .estimating-group-by-button {
  border-radius: 8px;
}

/* Unified dropdown styling for takeoff viewer controls and modals. */
.toolbar select,
select.quick-add-input,
.sort-type-assignment-row select,
.takeoff-item-modal-body select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  min-height: 32px;
  border: 1px solid transparent;
  border-radius: 11px;
  background-color: #fbfdff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5 7.5L10 12.5L15 7.5' stroke='%23657993' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 14px 14px;
  color: #2d3f58;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9), 0 4px 10px rgba(18, 36, 61, 0.08);
  padding: 0 30px 0 10px;
  transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.toolbar select:hover,
select.quick-add-input:hover,
.sort-type-assignment-row select:hover,
.takeoff-item-modal-body select:hover {
  border-color: transparent;
  background: linear-gradient(180deg, #ffffff 0%, #f4f8ff 100%);
  box-shadow: 0 9px 18px rgba(18, 36, 61, 0.12);
}

.toolbar select:focus,
select.quick-add-input:focus,
.sort-type-assignment-row select:focus,
.takeoff-item-modal-body select:focus {
  outline: none;
  border-color: transparent;
  background-color: #ffffff;
  box-shadow: 0 0 0 2px rgba(42, 110, 232, 0.18), 0 10px 18px rgba(42, 110, 232, 0.16);
}

.toolbar select:disabled,
select.quick-add-input:disabled,
.sort-type-assignment-row select:disabled,
.takeoff-item-modal-body select:disabled {
  opacity: 0.6;
  cursor: default;
}

/* Search boxes aligned to navbar-like pill controls. */
.sidebar-search,
.takeoff-table-search {
  border: 1px solid transparent;
  border-radius: 11px;
  background: #f8fafd;
  color: #334155;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9), 0 4px 10px rgba(18, 36, 61, 0.08);
  transition: border-color 180ms ease, background-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.sidebar-search:hover,
.takeoff-table-search:hover {
  border-color: transparent;
  background: linear-gradient(180deg, #ffffff 0%, #f4f8ff 100%);
  box-shadow: 0 9px 18px rgba(18, 36, 61, 0.12);
}

.sidebar-search:focus,
.takeoff-table-search:focus {
  border-color: transparent;
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(42, 110, 232, 0.18), 0 10px 18px rgba(42, 110, 232, 0.16);
  transform: translateY(-1px);
}

.sidebar-search::placeholder,
.takeoff-table-search::placeholder {
  color: #8ea0b8;
}

/* Match shell buttons to the takeoff navbar pill style. */
.icon-btn,
.toolbar .toolbar-icon-btn,
.digitizer-stop-btn,
.autocount-trigger-btn,
.quick-add-toolbar .quick-add-sort-types-btn,
.takeoff-group-by-dropdown .estimating-group-by-button,
.custom-dropdown .estimating-group-by-button,
.sort-type-modal-close,
.sort-type-modal-cancel,
.sort-type-modal-add,
.takeoff-item-custom-variables-add {
  border: 1px solid transparent;
  border-radius: 11px;
  background: #f8fafd;
  color: #52657f;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9), 0 4px 10px rgba(18, 36, 61, 0.08);
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.custom-dropdown .estimating-group-by-button,
.custom-dropdown-button .label {
  font: 600 0.78rem Segoe UI, Tahoma, sans-serif;
  line-height: 1.2;
  letter-spacing: 0;
}

.icon-btn:not(:disabled):hover,
.toolbar .toolbar-icon-btn:hover,
.digitizer-stop-btn:hover,
.autocount-trigger-btn:hover,
.quick-add-toolbar .quick-add-sort-types-btn:hover,
.takeoff-group-by-dropdown .estimating-group-by-button:hover,
.custom-dropdown .estimating-group-by-button:hover,
.sort-type-modal-close:hover,
.sort-type-modal-cancel:hover,
.sort-type-modal-add:hover,
.takeoff-item-custom-variables-add:hover {
  color: #ffffff;
  border-color: transparent;
  background: linear-gradient(135deg, #3c81ff 0%, #2a6ee8 100%);
  box-shadow: 0 10px 18px rgba(42, 110, 232, 0.24);
  transform: translateY(-1px);
}

.icon-btn[aria-pressed="true"],
.toolbar .toolbar-icon-btn:active,
.digitizer-stop-btn:active,
.autocount-trigger-btn:active,
.quick-add-toolbar .quick-add-submit,
.sort-type-modal-save,
.takeoff-group-by-dropdown .estimating-group-by-button[aria-expanded="true"],
.custom-dropdown .estimating-group-by-button[aria-expanded="true"] {
  color: #ffffff;
  border-color: transparent;
  background: linear-gradient(135deg, #3c81ff 0%, #2a6ee8 100%);
  box-shadow: 0 10px 18px rgba(42, 110, 232, 0.24);
}

.quick-add-toolbar .quick-add-submit:hover,
.sort-type-modal-save:hover {
  background: linear-gradient(135deg, #2f73f3 0%, #225fd8 100%);
  box-shadow: 0 12px 20px rgba(42, 110, 232, 0.28);
  transform: translateY(-1px);
  filter: none;
}

.icon-btn:not(:disabled):hover .icon-svg,
.icon-btn[aria-pressed="true"] .icon-svg,
.toolbar .toolbar-icon-btn:hover .toolbar-icon-svg,
.toolbar .toolbar-icon-btn:active .toolbar-icon-svg {
  filter: brightness(0) invert(1);
}

.icon-btn:disabled,
.toolbar button:disabled,
.autocount-trigger-btn:disabled,
.sort-type-modal-close:disabled,
.sort-type-modal-add:disabled,
.sort-type-modal-cancel:disabled,
.sort-type-modal-save:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
}

/* Hard sync: Stop Digitizer matches Set Sort Types exactly. */
.digitizer-toolbar .digitizer-stop-btn,
.autocount-trigger-btn,
.quick-add-toolbar .quick-add-sort-types-btn {
  height: 32px;
  min-height: 32px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: #f8fafd;
  color: #52657f;
  font: 600 0.8rem "Roboto", "Inter", "Segoe UI", Tahoma, sans-serif;
  padding: 0 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9), 0 4px 10px rgba(18, 36, 61, 0.08);
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.digitizer-toolbar .digitizer-stop-btn:hover,
.autocount-trigger-btn:hover,
.quick-add-toolbar .quick-add-sort-types-btn:hover {
  color: #ffffff;
  border-color: transparent;
  background: linear-gradient(135deg, #3c81ff 0%, #2a6ee8 100%);
  box-shadow: 0 10px 18px rgba(42, 110, 232, 0.24);
  transform: translateY(-1px);
}

.digitizer-toolbar .digitizer-stop-btn:active,
.autocount-trigger-btn:active,
.quick-add-toolbar .quick-add-sort-types-btn:active {
  color: #ffffff;
  border-color: transparent;
  background: linear-gradient(135deg, #3c81ff 0%, #2a6ee8 100%);
  box-shadow: 0 10px 18px rgba(42, 110, 232, 0.24);
  transform: translateY(0);
}

.digitizer-toolbar .digitizer-stop-btn:focus-visible,
.autocount-trigger-btn:focus-visible,
.quick-add-toolbar .quick-add-sort-types-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(42, 110, 232, 0.18), 0 10px 18px rgba(42, 110, 232, 0.16);
}

/* Modernized page thumbnails */
.thumbnail-list {
  padding: 12px 12px 14px;
  gap: 12px;
}

.thumbnail-item {
  position: relative;
  border: 1px solid rgba(142, 157, 178, 0.26);
  border-radius: 14px;
  padding: 10px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.08);
  transition: border-color 160ms ease, box-shadow 180ms ease, transform 180ms ease, background-color 160ms ease;
}

.thumbnail-item canvas,
.thumbnail-item img {
  border-radius: 10px;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.08);
}

.thumbnail-item.has-takeoff {
  border-color: rgba(42, 110, 232, 0.34);
}

.thumbnail-takeoff-indicator {
  position: static;
  min-width: 0;
  height: auto;
  border-radius: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  background: transparent;
  color: inherit;
  box-shadow: none;
}

.thumbnail-label {
  margin-top: 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.79rem;
  font-weight: 650;
  color: #4f6380;
}

.thumbnail-takeoff-mode-icon {
  width: 14px;
  min-width: 14px;
  height: 14px;
}

.thumbnail-takeoff-mode-icon svg,
.thumbnail-takeoff-mode-icon .takeoff-mode-icon-glyph {
  width: 12px;
  height: 12px;
}

.thumbnail-item:hover {
  border-color: rgba(125, 151, 196, 0.36);
  background: #ffffff;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
  transform: translateY(-2px);
}

.thumbnail-item.active {
  border-color: #2563eb;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.18), inset 0 0 0 1px #2563eb;
}

.thumbnail-list.list-view {
  padding-top: 10px;
  gap: 8px;
}

.thumbnail-list.list-view .thumbnail-item {
  border: 1px solid rgba(142, 157, 178, 0.24);
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  box-shadow: 0 5px 12px rgba(15, 23, 42, 0.06);
  padding: 10px 11px;
}

.thumbnail-list.list-view .thumbnail-label {
  text-align: left;
  justify-content: flex-start;
}

.thumbnail-list.list-view .thumbnail-label .thumbnail-takeoff-indicator {
  margin-left: auto;
}

.thumbnail-list.list-view .thumbnail-item:hover {
  border-color: rgba(125, 151, 196, 0.34);
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.1);
  transform: translateY(-1px);
}

.sidebar-search-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.left-add-folder-btn {
  width: 36px;
  height: 36px;
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: #f8fafd;
  color: #52657f;
  padding: 0;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9), 0 4px 10px rgba(18, 36, 61, 0.08);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.left-add-folder-btn:hover {
  color: #ffffff;
  background: linear-gradient(135deg, #3c81ff 0%, #2a6ee8 100%);
  box-shadow: 0 10px 18px rgba(42, 110, 232, 0.24);
}

.left-add-folder-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.thumbnail-list.list-view {
  gap: 4px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  background: #f6f8fc;
  border: 1px solid #e2e8f2;
  border-radius: 12px;
  padding: 8px;
}

.thumbnail-folder-group {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

.thumbnail-folder-group.is-drop-target {
  background: rgba(42, 110, 232, 0.06);
  border-radius: 8px;
}

.thumbnail-folder-header {
  width: 100%;
  min-height: 32px;
  border: 0;
  background: transparent;
  color: #2f4462;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  padding: 0 6px;
  font: 700 0.76rem "Roboto", "Inter", "Segoe UI", Tahoma, sans-serif;
  cursor: pointer;
  text-align: left;
}

.thumbnail-folder-header:hover {
  background: #edf3ff;
  border-radius: 7px;
}

.thumbnail-folder-chevron {
  color: #60799c;
  font-size: 0.78rem;
  text-align: center;
}

.thumbnail-folder-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thumbnail-folder-name::before {
  content: "\1F4C1";
  margin-right: 6px;
  opacity: 0.9;
}

.thumbnail-folder-header[aria-expanded="true"] .thumbnail-folder-name::before {
  content: "\1F4C2";
}

.thumbnail-folder-count {
  border: 1px solid #d6e1f0;
  border-radius: 999px;
  background: #ffffff;
  color: #5d7495;
  font-size: 0.68rem;
  padding: 1px 7px;
}

.thumbnail-folder-body {
  margin: 2px 0 5px 10px;
  padding: 0 0 0 12px;
  display: grid;
  gap: 2px;
  max-height: min(52vh, 560px);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  border-left: 1px dashed #d0d9e7;
}

.thumbnail-folder-body[hidden] {
  display: none !important;
}

.thumbnail-list.list-view .thumbnail-item.thumbnail-item-in-folder {
  margin: 0;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  box-shadow: none;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
}

.thumbnail-list.list-view .thumbnail-item.thumbnail-item-in-folder canvas,
.thumbnail-list.list-view .thumbnail-item.thumbnail-item-in-folder img {
  display: none;
}

.thumbnail-list.list-view .thumbnail-item.thumbnail-item-in-folder .thumbnail-label {
  color: #556c8d;
  font: 600 0.8rem "Roboto", "Inter", "Segoe UI", Tahoma, sans-serif;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 0;
  text-align: left;
  justify-content: flex-start;
}

.thumbnail-list.list-view .thumbnail-item.thumbnail-item-in-folder .thumbnail-label::before {
  content: "\1F4C4";
  margin-right: 7px;
  opacity: 0.82;
}

.thumbnail-list.list-view .thumbnail-item.thumbnail-item-in-folder:hover {
  border-color: #d7e3f6;
  background: #ffffff;
  box-shadow: none;
  transform: none;
}

.thumbnail-list.list-view .thumbnail-item.thumbnail-item-in-folder.active {
  border-color: #c6d9fb;
  background: #eaf2ff;
  box-shadow: none;
}

.thumbnail-list.list-view .thumbnail-item.thumbnail-item-in-folder.active .thumbnail-label {
  color: #214f97;
}

.thumbnail-list.list-view .thumbnail-item.thumbnail-item-in-folder.active .thumbnail-label::before {
  opacity: 1;
}

.thumbnail-list.list-view .thumbnail-item.thumbnail-item-in-folder.is-multi-selected:not(.active) {
  border-color: #d9e5fa;
  background: #f3f8ff;
}

.thumbnail-list.list-view .thumbnail-item.thumbnail-item-in-folder.is-multi-selected:not(.active) .thumbnail-label {
  color: #355b91;
}

.thumbnail-list.list-view .thumbnail-item.thumbnail-item-in-folder .thumbnail-takeoff-indicator {
  position: static;
  flex: 0 0 auto;
  min-width: 0;
  height: auto;
  padding: 0;
  box-shadow: none;
  margin-left: auto;
}

.page-folder-context-menu {
  position: fixed;
  z-index: 1405;
  width: 196px;
  border: 1px solid #d4dfef;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 16px 28px rgba(15, 23, 42, 0.2);
  padding: 6px;
  display: grid;
  gap: 4px;
}

.page-folder-context-menu[hidden] {
  display: none !important;
}

.page-folder-context-item {
  width: 100%;
  min-height: 32px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #ffffff;
  color: #2f4668;
  font: 700 0.74rem "Roboto", "Inter", "Segoe UI", Tahoma, sans-serif;
  text-align: left;
  padding: 0 10px;
  cursor: pointer;
}

.page-folder-context-item:hover {
  color: #ffffff;
  background: linear-gradient(135deg, #3c81ff 0%, #2a6ee8 100%);
}

.page-folder-context-item:disabled {
  opacity: 0.55;
  cursor: default;
}

.page-folder-context-item:disabled:hover {
  color: #2f4668;
  background: #ffffff;
}

.thumbnail-item.is-dragging {
  opacity: 0.55;
}

/* Custom listbox dropdowns */
.custom-listbox-wrap {
  position: relative;
  width: auto;
  flex: 0 0 auto;
  min-width: 0;
}

.sort-type-assignment-row .custom-listbox-wrap,
.takeoff-item-modal-body .custom-listbox-wrap {
  width: 100%;
  flex: 1 1 auto;
}

.quick-add-toolbar .custom-listbox-host-quick-add-unit {
  flex: 0 0 132px;
  width: 132px;
}

.custom-listbox-host-id-qualitySelect {
  width: 96px;
}

.custom-listbox-host-id-takeoffModeSelect {
  width: 178px;
}

.custom-listbox-host-id-takeoffScalePreset {
  width: 118px;
}

.custom-listbox-host-id-takeoffSnapIncrement {
  width: 82px;
}

.custom-listbox-host-id-takeoffAreaFillStyle {
  width: 160px;
}

.custom-listbox-native {
  position: absolute !important;
  left: 0 !important;
  top: 0 !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.custom-listbox-trigger {
  width: 100%;
  min-height: 32px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: #f8fafd;
  color: #52657f;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9), 0 4px 10px rgba(18, 36, 61, 0.08);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 0 10px 0 12px;
  text-align: left;
  font: 600 0.8rem "Roboto", "Inter", "Segoe UI", Tahoma, sans-serif;
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.custom-listbox-trigger:hover {
  color: #ffffff;
  border-color: transparent;
  background: linear-gradient(135deg, #3c81ff 0%, #2a6ee8 100%);
  box-shadow: 0 10px 18px rgba(42, 110, 232, 0.24);
  transform: translateY(-1px);
}

.custom-listbox-trigger:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(42, 110, 232, 0.18), 0 10px 18px rgba(42, 110, 232, 0.16);
}

.custom-listbox-trigger[aria-expanded="true"] {
  border-color: transparent;
  background: linear-gradient(135deg, #3c81ff 0%, #2a6ee8 100%);
  color: #ffffff;
  box-shadow: 0 10px 18px rgba(42, 110, 232, 0.24);
  transform: translateY(0);
}

.custom-listbox-trigger:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
}

.custom-listbox-trigger-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-listbox-chevron {
  color: inherit;
  font-size: 0.85rem;
  line-height: 1;
  transition: transform 140ms ease;
}

.custom-listbox-trigger[aria-expanded="true"] .custom-listbox-chevron {
  transform: rotate(180deg);
}

.custom-listbox-menu {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  right: 0;
  z-index: 1400;
  max-height: 280px;
  overflow: auto;
  border: 1px solid #e1e7f1;
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(31, 46, 76, 0.14);
  padding: 12px;
  display: grid;
  gap: 6px;
}

.custom-listbox-menu::-webkit-scrollbar {
  width: 9px;
}

.custom-listbox-menu::-webkit-scrollbar-track {
  background: transparent;
}

.custom-listbox-menu::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #c8d0df;
  border: 2px solid #ffffff;
}

.custom-listbox-menu[hidden] {
  display: none !important;
}

.custom-listbox-option {
  width: 100%;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: #ffffff;
  color: #4e586b;
  font: 600 0.88rem "Roboto", "Inter", "Segoe UI", Tahoma, sans-serif;
  text-align: left;
  padding: 0 40px 0 12px;
  cursor: pointer;
  position: relative;
  transition: background-color 140ms ease, color 140ms ease;
}

.custom-listbox-option:hover {
  background: #f4f7fd;
}

.custom-listbox-option.is-selected {
  color: #3b63c7;
  background: #eef2ff;
  border-color: transparent;
}

.custom-listbox-option.is-selected::after {
  content: "\2713";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #4a72db;
  font-size: 1rem;
  font-weight: 800;
}

.custom-listbox-option:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Typography sync: mirror the projects page font system across the embedded takeoff viewer. */
body,
button,
input,
select,
textarea,
table,
.thumbnail-label,
.page-folder-context-item,
.custom-dropdown-button .label,
.custom-listbox-trigger,
.custom-listbox-option,
.sidebar-search,
.takeoff-table-search,
.digitizer-toolbar label,
.digitizer-status,
.takeoff-items-table th,
.takeoff-items-table td,
.sort-type-modal-close,
.sort-type-modal-cancel,
.sort-type-modal-add,
.sort-type-modal-save,
.takeoff-item-modal-label,
.create-folder-modal-label {
  font-family: "Manrope", "Avenir Next", "Segoe UI", Tahoma, sans-serif !important;
}

.brand-title,
.brand-subtitle,
.sidebar-title,
.digitizer-title,
.quick-add-title,
.sort-type-modal-header h3,
.takeoff-item-custom-variables-title,
.takeoff-item-variables-title,
.takeoff-item-variables-section-title,
.takeoff-item-assembly-title,
.thumbnail-folder-header,
.page-folder-context-item,
.takeoff-items-table th {
  font-family: "Space Grotesk", "Manrope", "Segoe UI", Tahoma, sans-serif !important;
}
