:root {
  color-scheme: light;
  --bg: #f5f7f6;
  --surface: #ffffff;
  --surface-2: #eef3f1;
  --line: #d7e0dc;
  --text: #17211d;
  --muted: #68756f;
  --accent: #1f7a5a;
  --accent-dark: #145d44;
  --danger: #b23a48;
  --warn: #8b5d11;
  --shadow: 0 18px 44px rgba(28, 45, 38, 0.12);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

*,
*::before,
*::after {
  min-width: 0;
}

html {
  min-height: 100%;
  max-width: 100%;
  overflow-x: hidden;
  background: var(--bg);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 100%;
  overflow-x: hidden;
  margin: 0;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  color: var(--text);
  background: var(--bg);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

img,
svg,
canvas,
video {
  max-width: 100%;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  min-height: calc(100dvh - var(--safe-top) - var(--safe-bottom));
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
  min-height: calc(100dvh - var(--safe-top) - var(--safe-bottom));
  padding: 18px;
  border-right: 1px solid var(--line);
  background: #fbfcfb;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.sidebar-head > div {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.sidebar-head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}

.settings-head-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  width: 38px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.app-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
}

h1,
h2 {
  margin: 0;
  line-height: 1.1;
}

h1 {
  font-size: 30px;
  font-weight: 800;
}

h2 {
  font-size: 20px;
  font-weight: 750;
}

.sidebar-head h2 {
  font-size: 18px;
}

.sidebar-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 22px 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface);
}

.sidebar-meta strong {
  color: var(--text);
}

.sidebar-create {
  margin-bottom: 12px;
}

.sidebar-order-search {
  display: block;
  margin-bottom: 12px;
}

.sidebar-order-search input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 11px;
  color: var(--text);
  background: var(--surface);
  font: inherit;
}

.sidebar-order-search input:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(31, 122, 90, 0.14);
  outline-offset: 1px;
}

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

.compact-empty {
  padding: 14px;
}

.order-list {
  display: grid;
  gap: 8px;
  overflow: auto;
  padding-right: 2px;
}

.order-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 82px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
  text-align: left;
}

.order-row-main {
  display: grid;
  gap: 5px;
  min-width: 0;
  width: 100%;
  min-height: 64px;
  border: 0;
  padding: 4px;
  color: inherit;
  background: transparent;
  text-align: left;
}

.order-row:hover,
.order-row.is-active {
  border-color: rgba(31, 122, 90, 0.55);
  background: #f3faf7;
}

.order-row-title {
  overflow: hidden;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.order-row-sum {
  font-weight: 750;
}

.order-row-actions {
  display: grid;
  gap: 6px;
}

.order-row-icon {
  width: 32px;
  min-height: 32px;
}

.danger-icon-btn,
.icon-btn.danger-icon,
.icon-btn.reset-price-btn,
.icon-btn.module-delete-btn {
  border-color: rgba(178, 58, 72, 0.32);
  color: var(--danger);
  background: #fff3f5;
}

.purchase-module-lines {
  display: grid;
  gap: 10px;
  grid-column: 1 / -1;
  width: 100%;
}

.purchase-module-line {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 112px 132px 40px;
  gap: 10px;
  align-items: end;
}

.purchase-module-line .danger-icon {
  min-height: 40px;
}

@media (max-width: 700px) {
  .purchase-module-line {
    grid-template-columns: minmax(0, 1fr) 92px 108px 38px;
    gap: 7px;
  }

  .purchase-module-line .field span {
    font-size: 11px;
  }
}

.danger-icon-btn:hover,
.icon-btn.danger-icon:hover,
.icon-btn.reset-price-btn:hover,
.icon-btn.module-delete-btn:hover {
  border-color: rgba(178, 58, 72, 0.56);
  color: #a32739;
  background: #ffe8ec;
}

.sidebar-actions {
  display: grid;
  gap: 8px;
  margin-top: auto;
  padding-top: 16px;
}

.main-content {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
  min-height: calc(100dvh - var(--safe-top) - var(--safe-bottom));
  padding: 24px;
}

.main-content > * {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.workspace-empty {
  display: grid;
  width: 100%;
  max-width: 100%;
  min-height: calc(100vh - 48px);
  min-height: calc(100dvh - 48px - var(--safe-top) - var(--safe-bottom));
  place-items: center;
  text-align: center;
}

.workspace-empty > div {
  width: min(100%, 520px);
  max-width: 100%;
}

.workspace-empty.small {
  min-height: 360px;
}

.workspace-empty p {
  max-width: 460px;
  margin: 12px auto 20px;
  color: var(--muted);
}

.empty-actions {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  max-width: 100%;
  justify-content: center;
  gap: 8px;
}

.order-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.order-contact {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

.order-composition {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
  max-width: 100%;
}

.composition-chip {
  appearance: none;
  cursor: pointer;
  min-width: 0;
  max-width: 100%;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.composition-chip:hover,
.composition-chip:focus-visible {
  border-color: var(--accent);
  color: var(--accent-dark);
  outline: none;
}

.is-navigation-target {
  animation: navigationTargetPulse 1.4s ease;
  scroll-margin-top: calc(88px + var(--safe-top));
}

@keyframes navigationTargetPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(31, 122, 90, 0.28);
  }
  45% {
    box-shadow: 0 0 0 5px rgba(31, 122, 90, 0.16);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(31, 122, 90, 0);
  }
}

.order-total {
  display: grid;
  gap: 4px;
  min-width: 180px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-align: right;
}

.order-total span {
  color: var(--muted);
  font-size: 13px;
}

.order-total strong {
  font-size: 24px;
}

.order-summary {
  display: grid;
  gap: 8px;
  flex: 0 0 210px;
}

.order-icon-actions {
  display: flex;
  width: 100%;
  justify-content: space-evenly;
  gap: 0;
}

.order-action-icon {
  width: 38px;
  min-height: 38px;
  border-color: var(--line);
  color: var(--text);
  background: var(--surface);
  font-size: 18px;
}

.order-action-icon:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.order-toolbar {
  align-items: stretch;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.toolbar-zone {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.block-tabs-zone {
  flex: 1 1 auto;
}

.add-block-zone {
  flex: 0 0 auto;
}

.empty-actions .primary-btn svg {
  width: 16px;
  height: 16px;
}

.toolbar-zone-title {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.block-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.block-tab-wrap {
  display: inline-flex;
  align-items: stretch;
  min-width: 0;
  max-width: 320px;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  background: var(--surface);
}

.block-tab-add {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 40px;
  padding: 0 11px;
  border: 1px dashed #9ab8ac;
  border-radius: 9px;
  color: var(--accent-dark);
  background: #f8fcfa;
  font: inherit;
  font-weight: 750;
  white-space: nowrap;
}

.block-tab-add .icon-svg {
  width: 16px;
  height: 16px;
}

.block-tab-add:hover,
.block-tab-add:focus-visible {
  border-style: solid;
  border-color: var(--accent);
  background: #edf8f3;
  outline: none;
}

.block-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 40px;
  padding: 8px 12px;
  border: 0;
  color: var(--text);
  background: var(--surface);
}

.block-tab span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.block-tab b {
  color: var(--accent-dark);
  white-space: nowrap;
}

.block-tab-wrap.is-active {
  border-color: var(--accent);
  background: #edf8f3;
}

.block-tab-wrap.is-active .block-tab {
  background: #edf8f3;
}

.block-tab-delete {
  display: grid;
  place-items: center;
  flex: 0 0 38px;
  width: 38px;
  min-height: 40px;
  padding: 0;
  border: 0;
  border-left: 1px solid #f0caca;
  color: #b53030;
  background: #fff2f2;
}

.block-tab-delete:hover,
.block-tab-delete:focus-visible {
  background: #ffe1e1;
}

.fence-view-tabs {
  display: inline-flex;
  gap: 3px;
  width: fit-content;
  margin: 0 0 12px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f4f8f6;
}

.fence-view-tab {
  min-height: 34px;
  padding: 6px 13px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
}

.fence-view-tab.is-active {
  color: #175b49;
  background: #fff;
  box-shadow: 0 1px 3px rgba(27, 64, 53, 0.14);
}

.elevation-panel { overflow: hidden; }
.elevation-hint, .modal-copy { margin: -3px 0 12px; color: var(--muted); font-size: 13px; line-height: 1.4; }
.elevation-drawing-wrap { margin: 4px 0 12px; overflow: hidden; border: 1px solid #d7e5df; border-radius: 10px; background: linear-gradient(#fafffd, #f4faf7); }
.elevation-drawing { display: block; width: 100%; min-height: 220px; }
.elevation-level { stroke: #5c756c; stroke-width: 1.4; stroke-dasharray: 7 6; }
.elevation-fence-fill { fill: rgba(31, 122, 90, 0.08); }
.elevation-fence-top { stroke: #1f7a5a; stroke-width: 3; }
.elevation-ground { fill: none; stroke: #9b7045; stroke-width: 3; stroke-linejoin: round; }
.elevation-post { stroke: #1e5041; stroke-width: 3.2; }
.elevation-ground-point { fill: #9b7045; }
.elevation-level-label, .elevation-axis-label { fill: #62776e; font-size: 12px; font-weight: 700; }
.elevation-point-label { fill: #193c31; font-size: 13px; font-weight: 800; paint-order: stroke; stroke: #fff; stroke-width: 4px; }
.elevation-post-label { fill: #1d4c3e; font-size: 10px; font-weight: 800; paint-order: stroke; stroke: #fff; stroke-width: 3px; }
.elevation-dimension { stroke: #7a8d85; stroke-width: 1.2; }
.elevation-dimension-label { fill: #526962; font-size: 12px; font-weight: 800; }
.elevation-base-height { max-width: 230px; margin-bottom: 10px; }
.elevation-points { display: grid; gap: 8px; }
.elevation-point-row { display: grid; grid-template-columns: minmax(70px, .7fr) 1fr 1fr 38px; gap: 8px; align-items: end; padding: 8px; border: 1px solid #e0ebe7; border-radius: 8px; background: #fbfdfc; }
.elevation-point-row label { display: grid; gap: 4px; min-width: 0; color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.elevation-point-row input, .manual-material-name, .manual-material-unit { width: 100%; min-width: 0; }
.print-option-list { display: grid; gap: 8px; margin: 8px 0 16px; }
.print-option { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 9px; background: #fbfdfc; cursor: pointer; }
.print-option input { width: 19px; height: 19px; accent-color: var(--accent); }
.print-option span { display: grid; gap: 2px; }
.print-option small { color: var(--muted); }

.top-view-panel { overflow: hidden; }
.top-view-wrap { overflow: hidden; border: 1px solid #d7e5df; border-radius: 10px; background: #fafffd; }
.top-view-drawing { display: block; width: 100%; min-height: 170px; }
.top-view-zone { fill: rgba(31, 122, 90, 0.035); stroke: #d7e5df; stroke-width: 1; }
.top-view-rail { stroke: #1f7a5a; stroke-width: 4; stroke-linecap: square; }
.top-view-opening-fill { stroke-width: 1.5; }
.top-view-wicket-fill { fill: rgba(56, 109, 181, 0.18); stroke: #386db5; }
.top-view-swing-fill { fill: rgba(208, 113, 43, 0.18); stroke: #bd6421; }
.top-view-sliding-fill { fill: rgba(126, 87, 183, 0.18); stroke: #7650a8; }
.top-view-wicket-line { stroke: #1967a2; stroke-width: 4; stroke-linecap: square; stroke-dasharray: 9 3; }
.top-view-swing-line { stroke: #b85c16; stroke-width: 4; stroke-linecap: square; stroke-dasharray: 10 3 2 3; }
.top-view-sliding-line { stroke: #663a98; stroke-width: 4; stroke-linecap: square; stroke-dasharray: 2 3; }
.top-view-leaf { fill: #f4f8f6; stroke: #43675b; stroke-width: 2; }
.top-view-tail { fill: rgba(139, 93, 17, 0.14); stroke: #805817; stroke-width: 1.5; stroke-dasharray: 4 3; }
.top-view-opening-member { stroke: #202624; stroke-width: 1.15; }
.top-view-wicket .top-view-zone { fill: rgba(72, 118, 196, 0.08); }
.top-view-swing .top-view-zone, .top-view-sliding .top-view-zone { fill: rgba(139, 93, 17, 0.08); }
.top-view-label, .top-view-post-label, .top-view-legend { fill: #334f45; font-size: 12px; font-weight: 800; }
.top-view-post-label { font-size: 10px; }
.top-view-post { fill: #fff; stroke: #1c493d; stroke-width: 1.5; }
.top-view-post-large { fill: #fff; stroke-width: 2.5; }
.top-view-pile { fill: none; stroke: #7b857f; stroke-width: 1.25; stroke-dasharray: 2 2; }
.top-view-legend { fill: #34715f; }
.top-view-legend.large { fill: #1c493d; }

.elevation-section-fill { fill: rgba(31, 122, 90, 0.12); stroke: #1f7a5a; stroke-width: 1.5; }
.elevation-section-top { stroke: #1f7a5a; stroke-width: 3; }
.elevation-section-inner { fill: none; stroke: #1f7a5a; stroke-width: 1.6; }
.elevation-section-wicket .elevation-section-fill { fill: rgba(56, 109, 181, 0.18); stroke: #386db5; }
.elevation-section-wicket .elevation-section-top, .elevation-section-wicket .elevation-section-inner { stroke: #386db5; }
.elevation-section-swing .elevation-section-fill { fill: rgba(208, 113, 43, 0.18); stroke: #bd6421; }
.elevation-section-swing .elevation-section-top, .elevation-section-swing .elevation-section-inner { stroke: #bd6421; }
.elevation-section-sliding .elevation-section-fill { fill: rgba(126, 87, 183, 0.18); stroke: #7650a8; }
.elevation-section-sliding .elevation-section-top, .elevation-section-sliding .elevation-section-inner { stroke: #7650a8; }

.supplemental-price-list {
  display: grid;
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.supplemental-price-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: 12px;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid #e5eeea;
  font-size: 13px;
}

.supplemental-price-row:last-child { border-bottom: 0; }
.supplemental-price-row strong { color: #145e49; white-space: nowrap; }
.supplemental-price-row small { margin-left: 2px; color: var(--muted); font-weight: 700; }
.custom-price-list .supplemental-price-row { grid-template-columns: minmax(0, 1fr) max-content 36px; }
.custom-price-list .supplemental-price-row small { display: block; margin: 2px 0 0; }

@media (orientation: landscape) and (max-height: 620px) {
  .app-shell { grid-template-columns: 236px minmax(0, 1fr); }
  .main-content { padding: 14px 18px 24px; }
  .order-head { gap: 12px; margin-bottom: 8px; padding-bottom: 8px; }
  .order-head .eyebrow { display: none; }
  .order-head h1 { font-size: 24px; }
  .order-contact { gap: 6px; margin-top: 3px; font-size: 12px; }
  /* При повороте телефон нужен прежде всего для схемы. Состав заказа остаётся
     доступным через вкладки, поэтому не забирает высоту у чертежа второй раз. */
  .order-composition { display: none; }
  .order-summary { flex-basis: 172px; gap: 4px; }
  .order-total { min-width: 0; padding: 7px 10px; }
  .order-total strong { font-size: 20px; }
  .order-icon-actions { justify-content: space-between; }
  .order-action-icon { width: 34px; min-height: 34px; }
  .toolbar { margin-bottom: 8px; }
  .order-toolbar { gap: 10px; padding: 7px 8px; }
  .toolbar-zone { gap: 4px; }
  .toolbar-zone-title { font-size: 10px; }
  .block-tab-add { min-height: 34px; padding: 5px 9px; }
  .elevation-drawing { min-height: 270px; }
  .line-drawing { min-height: 290px; }
  .elevation-point-row { grid-template-columns: 100px 1fr 1fr 38px; }
  .block-tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
  .block-tab-wrap { flex: 0 0 auto; }
}

@media (max-width: 680px) {
  .elevation-point-row { grid-template-columns: minmax(56px, .7fr) 1fr 1fr 36px; gap: 6px; padding: 7px; }
  .elevation-point-row label { font-size: 9px; }
  .elevation-point-row input { min-height: 34px; padding: 6px; }
  .block-tab-wrap { max-width: min(100%, 260px); }
}

.active-block-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -8px 0 14px;
  padding: 10px 12px 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f3f8f6;
}

.selected-block-shell {
  min-width: 0;
  padding: 14px;
  border: 1px solid #d8e7e1;
  border-radius: 10px;
  background: #f8fbfa;
}

.selected-block-shell .active-block-bar {
  margin: 0 0 14px;
}

.active-block-bar h2 {
  margin: 2px 0 0;
}

.active-block-total {
  margin-left: auto;
  color: var(--accent-dark);
  font-size: 18px;
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
}

.auto-recalc-hint {
  align-self: center;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.active-block-bar .toolbar-zone-title {
  margin-bottom: 2px;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(360px, 1.1fr);
  width: 100%;
  max-width: 100%;
  gap: 18px;
  align-items: start;
}

.fence-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
  max-width: 100%;
  gap: 14px;
  align-items: start;
}

.module-list {
  display: grid;
  gap: 14px;
}

.module-card {
  box-shadow: none;
  scroll-margin-top: calc(88px + var(--safe-top));
}

.module-card .panel-head {
  margin-bottom: 10px;
  flex-direction: row;
  align-items: flex-start;
}

.module-card .module-card-head {
  align-items: center;
  margin: -18px -18px 12px;
  padding: 10px 12px 10px 14px;
  border-bottom: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
  background: #f3f8f6;
  cursor: pointer;
  transition: background 160ms ease;
}

.module-card .module-card-head:hover {
  background: #eaf5f0;
}

.module-card .module-card-head h2 {
  margin: 0;
}

.module-card-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.module-card-summary {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.module-card.is-collapsed .panel-head {
  margin-bottom: 8px;
}

.module-card-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex: 0 0 auto;
}

.module-card-icon {
  width: 38px;
  height: 38px;
  min-height: 38px;
  border-radius: 5px;
}

.module-toggle-btn {
  background: #fff;
  border-color: #cbdad5;
}

.module-compact {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
}

.module-card.is-collapsed .module-compact {
  margin-bottom: 0;
}

.coverage-box {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  scroll-margin-top: calc(88px + var(--safe-top));
}

.segments-box {
  margin-top: 0;
}

.segments-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.segments-head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}

.segments-hint {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
}

.segments-summary {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
}

.segments-total-pill {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid rgba(31, 122, 90, 0.25);
  border-radius: 999px;
  color: var(--accent-dark);
  background: #edf8f3;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.line-drawing-wrap {
  width: 100%;
  margin-bottom: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(#f8faf9 1px, transparent 1px),
    linear-gradient(90deg, #f8faf9 1px, transparent 1px),
    #ffffff;
  background-size: 24px 24px;
}

.line-drawing {
  display: block;
  min-width: 0;
  width: 100%;
  height: auto;
}

.line-drawing-empty {
  margin-bottom: 12px;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fbfcfb;
  font-weight: 700;
}

.line-ground {
  stroke: #9aa9a2;
  stroke-width: 1.5;
  stroke-dasharray: 8 7;
}

.line-fill,
.line-frame {
  fill: rgba(31, 122, 90, 0.1);
  stroke: #1f7a5a;
  stroke-width: 2.2;
}

.fence-fill {
  stroke: none;
}

.line-piece-wicket .line-frame {
  fill: rgba(56, 109, 181, 0.17);
  stroke: #386db5;
}

.line-piece-swing .line-frame {
  fill: rgba(208, 113, 43, 0.18);
  stroke: #bd6421;
}

.line-piece-sliding .line-frame {
  fill: rgba(126, 87, 183, 0.18);
  stroke: #7650a8;
}

.line-piece-sliding .line-tail {
  fill: rgba(139, 93, 17, 0.14);
  stroke: #805817;
  stroke-width: 1.4;
  stroke-dasharray: 5 3;
}

.line-rail,
.line-inner,
.line-tail-divider {
  fill: none;
  stroke: #263a33;
  stroke-width: 2;
}

.line-piece-fence .line-rail { stroke: #1f7a5a; }
.line-piece-wicket .line-inner { stroke: #386db5; }
.line-piece-swing .line-inner { stroke: #bd6421; }
.line-piece-sliding .line-inner { stroke: #7650a8; }

.line-post {
  fill: #263a33;
}

.module-post {
  fill: #1f7a5a;
}

.line-pile-cap { fill: #fff; stroke: #6e7c75; stroke-width: 1.25; }
.line-pile-shaft { fill: none; stroke: #6e7c75; stroke-width: 1.4; stroke-linecap: round; }

.line-dim-guide {
  stroke: #8a9892;
  stroke-width: 1;
}

.line-drawing .bp-dim {
  stroke: #1c2823;
  stroke-width: 1.15;
}

.line-drawing .bp-dim-text {
  fill: #17211d;
  font-size: 14px;
  font-weight: 800;
  paint-order: stroke;
  stroke: #ffffff;
  stroke-width: 4px;
}

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

.segment-row {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr) 72px 42px;
  align-items: end;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.line-item-row.is-module {
  align-items: center;
}

.line-item-title {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.line-item-title span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.line-item-title strong {
  overflow-wrap: anywhere;
}

.line-item-size {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 5px;
  min-height: 38px;
  padding: 0 8px 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.line-item-size:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 90, 0.12);
}

.line-item-size input {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  font-weight: 800;
}

.line-item-size input:focus {
  outline: 0;
}

.line-item-size span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.compact-measure-field {
  display: inline-grid;
  grid-template-columns: 92px auto;
  align-items: center;
  gap: 8px;
  width: fit-content;
  min-height: 42px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
}

.compact-measure-field input {
  width: 92px;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-weight: 800;
}

.compact-measure-field input:focus {
  border-color: var(--accent);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(31, 122, 90, 0.12);
}

.line-item-kind {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  text-align: center;
}

.segment-field input,
.segment-field select {
  background: #fff;
}

.segment-post-result {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 800;
}

.line-builder-list {
  gap: 7px;
}

.line-builder-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 108px 38px;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}

.line-builder-row.is-module {
  background: #fbfcfb;
}

.line-builder-row:not(:has(input:focus, button:focus)) {
  cursor: grab;
}

.line-drag-handle {
  display: grid;
  place-items: center;
  width: 32px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
  cursor: grab;
  font-weight: 900;
  line-height: 1;
  touch-action: none;
}

.line-drag-handle:active {
  cursor: grabbing;
}

body.is-line-dragging {
  cursor: grabbing;
  user-select: none;
}

.line-builder-row.is-drag-source {
  position: relative;
  z-index: 4;
  opacity: 1;
  border-color: var(--accent);
  box-shadow: 0 14px 30px rgba(31, 122, 90, 0.22);
  transition: none;
}

.line-builder-row.is-drag-source .line-drag-handle {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
}

.line-builder-row.is-drag-target-before {
  box-shadow: inset 0 3px 0 var(--accent);
}

.line-builder-row.is-drag-target-after {
  box-shadow: inset 0 -3px 0 var(--accent);
}

.line-builder-index {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  color: var(--accent-dark);
  background: #edf8f3;
  font-size: 13px;
  font-weight: 900;
}

.line-builder-field {
  gap: 4px;
}

.line-builder-field input {
  min-height: 40px;
}

.line-drawing .line-brace {
  stroke: #a66d21;
  stroke-width: 2.4;
  fill: none;
}

.line-drawing .line-piece-label {
  fill: #435c53;
  font-size: 11px;
  font-weight: 800;
  text-anchor: middle;
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 3px;
}

.segments-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.panel-subhead {
  margin-bottom: 10px;
  font-weight: 800;
}

.module-add-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0;
}

.panel {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field.full {
  grid-column: 1 / -1;
}

.material-select-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(92px, 118px);
  gap: 8px;
  min-width: 0;
}

.material-select-pair .field {
  min-width: 0;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.readonly-field strong {
  display: flex;
  align-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: var(--surface-2);
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--text);
  background: #fff;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 90, 0.12);
}

.switch-row {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.switch {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-size: 14px;
}

.switch input {
  width: 18px;
  min-height: 18px;
}

.calc-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.fence-bottom-options {
  margin-top: 16px;
}

.calc-notes span {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
}

.statement-sections {
  display: grid;
  gap: 22px;
}

.statement-section {
  display: grid;
  gap: 10px;
}

.statement-group {
  display: grid;
  gap: 8px;
}

.statement-group + .statement-group {
  margin-top: 8px;
}

.statement-group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

.statement-group-head span {
  font-weight: 800;
}

.statement-group-head strong {
  font-size: 15px;
}

.statement-section + .statement-section {
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.technical-sheet {
  display: grid;
  gap: 10px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.technical-note {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.qty-stock-note {
  display: block;
  margin-top: 3px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
  white-space: normal;
}

.technical-table th:nth-child(n+2),
.technical-table td:nth-child(n+2) {
  text-align: right;
}

.technical-modal {
  width: min(1120px, calc(100vw - 28px));
  padding: 18px;
}

.technical-modal-group {
  padding: 12px;
}

.technical-modal-group .statement-head {
  margin-bottom: 8px;
}

.technical-table {
  min-width: 0;
  table-layout: fixed;
}

.technical-table .technical-material-col {
  width: 34%;
}

.technical-table .technical-qty-col {
  width: 108px;
}

.technical-table .technical-usage-col {
  width: auto;
}

.technical-table th,
.technical-table td,
.technical-table th:nth-child(n+2),
.technical-table td:nth-child(n+2) {
  text-align: left;
}

.technical-table .technical-qty-cell,
.technical-table th:nth-child(2) {
  text-align: left;
}

.technical-unit-cell {
  overflow-wrap: anywhere;
}

.technical-material-cell strong {
  margin-bottom: 0;
  line-height: 1.25;
  overflow-wrap: anywhere;
  word-break: normal;
  white-space: normal;
}

.technical-usage-cell {
  line-height: 1.35;
  overflow-wrap: anywhere;
  white-space: normal;
}

.statement-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.statement-head h3 {
  margin: 0;
  font-size: 18px;
}

.statement-head strong {
  font-size: 18px;
}

table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
}

.compact-statement-table {
  min-width: 520px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

td strong {
  display: block;
  margin-bottom: 4px;
}

td span {
  color: var(--muted);
  font-size: 12px;
}

.price-type {
  display: block;
}

.work-price-cell {
  display: grid;
  gap: 6px;
  min-width: 210px;
}

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

.price-input {
  flex: 0 0 130px;
  width: 130px;
  min-height: 34px;
  padding: 6px 8px;
}

.tiny-btn {
  flex: 0 0 auto;
  width: auto !important;
  min-height: 28px;
  padding: 4px 8px;
  font-size: 12px;
}

.reset-price-btn {
  flex: 0 0 34px;
  width: 34px;
  min-height: 34px;
  border-color: rgba(178, 58, 72, 0.26);
  color: var(--danger);
  background: #fff7f8;
}

.work-price-cell .price-type {
  display: block;
}

.search-panel {
  position: sticky;
  top: 18px;
}

.search-results {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 250px);
  overflow: auto;
  margin-top: 12px;
  padding-right: 2px;
}

.search-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-top: 12px;
}

.catalog-stat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-2);
  white-space: nowrap;
}

.catalog-stat strong {
  color: var(--text);
}

.catalog-stat.inline {
  justify-content: flex-start;
}

.result-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 82px 42px;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.result-main {
  min-width: 0;
}

.result-main strong,
.result-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-main span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.result-qty,
.qty-input {
  min-height: 36px;
}

.qty-input {
  width: 82px;
}

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

.qty-value-row .qty-input,
.qty-override-row .qty-input {
  flex: 1 1 82px;
  min-width: 0;
}

.qty-unit {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.primary-btn,
.ghost-btn,
.danger-btn,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 8px 12px;
  font-weight: 750;
  text-decoration: none;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  text-align: center;
}

.primary-btn {
  color: #fff;
  background: var(--accent);
}

.primary-btn:hover {
  background: var(--accent-dark);
}

.ghost-btn {
  border-color: var(--line);
  color: var(--text);
  background: var(--surface);
}

.ghost-btn:hover {
  border-color: var(--accent);
}

.danger-btn {
  border-color: rgba(178, 58, 72, 0.26);
  color: var(--danger);
  background: #fff7f8;
}

.danger-btn:hover {
  border-color: var(--danger);
}

.icon-btn {
  width: 40px;
  padding: 0;
  border-color: var(--line);
  color: var(--text);
  background: var(--surface);
  font-size: 22px;
  line-height: 1;
}

.icon-svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.primary-icon {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
}

.danger-icon {
  color: var(--danger);
}

.small-btn {
  min-height: 36px;
  padding: 6px 10px;
}

.full-btn {
  width: 100%;
}

.empty-panel {
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fbfcfb;
}

.empty-title {
  margin-bottom: 4px;
  color: var(--text);
  font-weight: 750;
}

.muted {
  color: var(--muted);
}

.floating-add {
  position: fixed;
  right: 20px;
  top: calc(18px + var(--safe-top));
  display: none;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: var(--accent);
  box-shadow: var(--shadow);
  font-size: 30px;
  line-height: 1;
  z-index: 20;
}

.fence-quick-add {
  position: fixed;
  right: 20px;
  bottom: calc(20px + var(--safe-bottom));
  z-index: 45;
  display: grid;
  justify-items: end;
  gap: 10px;
  transform: none;
  pointer-events: none;
}

.quick-add-toggle {
  pointer-events: auto;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 16px 36px rgba(31, 122, 90, 0.28);
}

.quick-add-toggle .icon-svg {
  width: 24px;
  height: 24px;
}

.quick-add-menu {
  pointer-events: none;
  display: grid;
  gap: 8px;
  width: 176px;
  max-height: min(440px, calc(100dvh - 130px - var(--safe-top) - var(--safe-bottom)));
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateX(16px) scale(0.96);
  transform-origin: right bottom;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.fence-quick-add.is-open {
  pointer-events: auto;
}

.fence-quick-add.is-open .quick-add-menu {
  pointer-events: auto;
  opacity: 1;
  transform: translateX(0) scale(1);
}

.quick-add-option {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0 12px;
  color: var(--text);
  background: #f5f8f6;
  font-weight: 850;
  text-align: left;
}

.quick-add-option:hover,
.quick-add-option:focus-visible {
  border-color: rgba(31, 122, 90, 0.35);
  background: #edf8f3;
  outline: none;
}

.quick-add-paint,
.quick-add-dismantle {
  background: #f7f5ef;
}

.mobile-menu-btn {
  position: fixed;
  left: 20px;
  top: calc(18px + var(--safe-top));
  display: none;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 16px;
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-weight: 800;
  z-index: 40;
}

.mobile-settings-btn {
  position: fixed;
  left: 108px;
  top: calc(18px + var(--safe-top));
  display: none;
  align-items: center;
  justify-content: center;
  width: 48px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0;
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 22px;
  font-weight: 800;
  z-index: 40;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  background: rgba(12, 20, 17, 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease;
  z-index: 65;
}

.drawer-close {
  display: none;
}

.print-frame {
  position: fixed;
  left: -10000px;
  top: 0;
  width: 1px;
  height: 1px;
  border: 0;
  opacity: 0.01;
  pointer-events: none;
}

.print-host {
  display: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 20, 17, 0.45);
  z-index: 90;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(620px, calc(100vw - 28px));
  max-height: calc(100vh - 28px - var(--safe-top) - var(--safe-bottom));
  max-height: calc(100dvh - 28px - var(--safe-top) - var(--safe-bottom));
  overflow: auto;
  transform: translate(-50%, -50%);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  z-index: 100;
}

.wide-modal {
  width: min(980px, calc(100vw - 28px));
}

.modal form {
  padding: 18px;
}

.confirm-body {
  padding: 18px;
}

.confirm-body p {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.45;
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  padding: 0 0 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.modal-actions.split {
  justify-content: space-between;
}

.modal-actions.split > div {
  display: flex;
  gap: 10px;
}

.settings-note {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #e6d9b7;
  border-radius: 8px;
  color: var(--warn);
  background: #fff9ea;
  font-size: 14px;
}

.settings-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}

.sync-status {
  display: grid;
  align-content: center;
  gap: 2px;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid #b8d8cc;
  border-radius: 8px;
  color: #195d4a;
  background: #eff8f4;
}

.sync-status span,
.sync-status small {
  color: var(--muted);
  font-size: 12px;
}

.upload-btn {
  position: relative;
  overflow: hidden;
}

.upload-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-btn.is-loading {
  opacity: 0.7;
  pointer-events: none;
}

.settings-section {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.settings-section summary {
  min-height: 44px;
  padding: 12px 14px;
  cursor: pointer;
  font-weight: 800;
}

.settings-section .form-grid {
  padding: 0 14px 14px;
}

.settings-switch {
  grid-column: 1 / -1;
  min-height: 42px;
  align-self: end;
}

.compact-switch {
  min-height: 34px;
}

.trim-choice-list {
  grid-column: 1 / -1;
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.segments-card-head {
  padding: 9px 10px 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f3f8f6;
  cursor: pointer;
}

.segments-card-head:hover {
  background: #eaf5f0;
}

.scheme-panel .segments-card-head {
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
}

.stock-length-choice {
  grid-column: 1 / -1;
}

.inline-choice-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-top: 5px;
}

.trim-choice-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.blueprint {
  margin: 0 14px 14px;
  border: 1px solid #cfd8d4;
  border-radius: 8px;
  background:
    linear-gradient(#f0f4f2 1px, transparent 1px),
    linear-gradient(90deg, #f0f4f2 1px, transparent 1px),
    #ffffff;
  background-size: 18px 18px;
}

.blueprint svg {
  display: block;
  width: 100%;
  height: auto;
  min-height: 230px;
}

.settings-blueprints {
  display: grid;
  gap: 16px;
  padding: 0 14px 14px;
}

.settings-blueprint-item h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.settings-blueprints .blueprint {
  margin: 0;
}

.settings-blueprints .blueprint svg {
  min-height: 180px;
}

.bp-frame,
.bp-post {
  fill: none;
  stroke: #47352f;
  stroke-width: 10;
  stroke-linecap: square;
  stroke-linejoin: miter;
}

.bp-post-outline {
  fill: none;
  stroke: #47352f;
  stroke-width: 6;
  stroke-linejoin: miter;
}

.bp-frame-thin {
  fill: none;
  stroke: #47352f;
  stroke-width: 7;
  stroke-linecap: square;
}

.bp-inner-frame {
  fill: none;
  stroke: #47352f;
  stroke-width: 6;
}

.bp-inner,
.bp-diag {
  fill: none;
  stroke: #47352f;
  stroke-width: 6;
  stroke-linecap: square;
}

.bp-strip {
  stroke: #756159;
  stroke-width: 8;
  stroke-linecap: square;
}

.bp-hinge {
  fill: #756159;
  stroke: #2b211d;
  stroke-width: 2;
}

.bp-ground {
  stroke: #567463;
  stroke-width: 3;
  stroke-dasharray: 8 7;
}

.bp-channel {
  fill: #ded9d3;
  stroke: #4d4843;
  stroke-width: 3;
}

.bp-pile {
  stroke: #4d4843;
  stroke-width: 8;
}

.bp-dim {
  stroke: #2b2f2d;
  stroke-width: 2;
}

.blueprint marker path {
  fill: #2b2f2d;
}

.bp-dim-text,
.bp-label {
  fill: #1d2622;
  font-size: 16px;
  font-weight: 700;
}

.bp-dim-text {
  text-anchor: middle;
}

.scheme-preview {
  display: grid;
  grid-template-columns: 90px minmax(180px, 1fr) 90px;
  gap: 10px;
  align-items: stretch;
  min-height: 118px;
  margin: 0 14px 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.scheme-preview.sliding-preview,
.scheme-preview.swing-preview {
  grid-template-columns: 1fr;
}

.scheme-preview.swing-preview {
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 1fr);
}

.scheme-post,
.scheme-channel {
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 8px;
  border-radius: 6px;
  color: #fff;
  background: #3e6f64;
  font-size: 12px;
  font-weight: 750;
  text-align: center;
  overflow-wrap: anywhere;
}

.scheme-channel {
  min-height: 30px;
  background: #65615a;
}

.scheme-frame {
  position: relative;
  min-height: 92px;
  border: 8px solid #1f7a5a;
  border-radius: 6px;
  background: #eff8f4;
  overflow: hidden;
}

.scheme-frame.wide {
  min-height: 108px;
}

.scheme-frame.leaf {
  min-height: 112px;
}

.scheme-top,
.scheme-inner {
  position: absolute;
  left: 10px;
  right: 10px;
  display: block;
  padding: 3px 6px;
  border-radius: 5px;
  color: #fff;
  background: rgba(31, 122, 90, 0.95);
  font-size: 12px;
  font-weight: 750;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scheme-top {
  top: 8px;
}

.scheme-inner {
  bottom: 8px;
  background: rgba(65, 97, 143, 0.95);
}

.scheme-diag,
.scheme-vertical {
  position: absolute;
  display: block;
  background: #41618f;
}

.scheme-diag {
  top: 46%;
  left: 12%;
  width: 76%;
  height: 5px;
  transform: rotate(22deg);
  transform-origin: center;
}

.scheme-diag.two {
  transform: rotate(-22deg);
}

.scheme-vertical {
  top: 0;
  bottom: 0;
  width: 5px;
}

.scheme-vertical.a {
  left: 38%;
}

.scheme-vertical.b {
  left: 66%;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: calc(20px + var(--safe-bottom));
  max-width: min(360px, calc(100vw - 40px));
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  background: #17211d;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.16s ease, transform 0.16s ease;
  pointer-events: none;
  z-index: 80;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(340px, calc(100vw - 34px));
    min-height: 100dvh;
    max-width: calc(100vw - 34px);
    border-right: 1px solid var(--line);
    border-bottom: 0;
    box-shadow: var(--shadow);
    transform: translateX(calc(-100% - 18px));
    transition: transform 0.18s ease;
    z-index: 70;
  }

  .main-content {
    padding-top: 84px;
  }

  .order-list {
    display: grid;
    max-width: 100%;
    overflow: auto;
    padding-bottom: 4px;
  }

  .order-row {
    min-width: 0;
  }

  .tool-grid {
    grid-template-columns: 1fr;
  }

  .fence-layout {
    grid-template-columns: 1fr;
  }

  .search-panel {
    position: static;
  }

  .search-results {
    max-height: 420px;
  }

  .floating-add {
    display: grid;
    place-items: center;
  }

  .mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-settings-btn {
    display: inline-flex;
  }

  .drawer-backdrop {
    display: block;
  }

  .drawer-close {
    display: inline-flex;
  }

  body.is-drawer-open {
    overflow: hidden;
  }

  body.is-drawer-open .sidebar {
    transform: translateX(0);
  }

  body.is-drawer-open .drawer-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar-head .primary-icon {
    display: none;
  }

  .settings-head-btn {
    flex: 0 0 auto;
    width: 38px;
  }
}

@media (max-width: 680px) {
  .app-shell,
  .main-content,
  .sidebar,
  .panel,
  .toolbar,
  .block-tabs,
  .toolbar-actions,
  .module-add-row {
    max-width: 100%;
  }

  .main-content,
  .sidebar {
    padding: 14px;
  }

  .main-content {
    padding-top: 82px;
  }

  .order-head,
  .panel-head {
    flex-direction: column;
    align-items: stretch;
  }

  .order-summary {
    flex: none;
  }

  .toolbar {
    display: grid;
    gap: 10px;
  }

  .order-toolbar {
    grid-template-columns: 1fr;
  }

  .block-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .block-tab {
    flex: 0 0 auto;
    max-width: 210px;
  }

  .order-total {
    text-align: left;
  }

  .order-icon-actions {
    justify-content: space-evenly;
  }

  .auto-recalc-hint {
    display: none;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .segment-row {
    grid-template-columns: minmax(0, 1fr) minmax(94px, 0.65fr) 64px 38px;
    gap: 6px;
    padding: 8px;
  }

  .segment-row .field span {
    font-size: 12px;
  }

  .segment-post-result {
    min-height: 40px;
  }

  .segments-head {
    flex-direction: column;
    align-items: stretch;
  }

  .segments-head-actions {
    justify-content: flex-start;
  }

  .segments-total-pill {
    width: fit-content;
  }

  .line-builder-row {
    grid-template-columns: 32px minmax(0, 1fr) 100px 38px;
    align-items: center;
  }

  .line-builder-row .danger-icon {
    grid-column: 4;
    grid-row: 1;
  }

  .line-drawing {
    min-width: 0;
  }

  .fence-quick-add {
    right: 14px;
    top: auto;
    bottom: calc(18px + var(--safe-bottom));
    transform: none;
  }

  .quick-add-menu {
    width: min(342px, calc(100vw - 28px));
    max-height: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    transform-origin: right bottom;
  }

  .quick-add-option {
    min-height: 38px;
    padding: 0 9px;
    font-size: 13px;
  }

  .toolbar-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .modal-actions,
  .modal-actions.split,
  .modal-actions.split > div {
    flex-direction: column;
  }

  .search-tools,
  .scheme-preview,
  .scheme-preview.swing-preview {
    grid-template-columns: 1fr;
  }

  .settings-row {
    align-items: stretch;
  }

  .catalog-stat {
    justify-content: flex-start;
  }

  .ghost-btn,
  .primary-btn,
  .danger-btn {
    width: 100%;
  }

  .segments-head-actions .small-btn,
  .module-card-actions .icon-btn {
    width: auto;
  }

  .module-card-actions .module-card-icon {
    width: 38px;
  }

  .module-list { gap: 8px; }

  .module-card {
    padding: 12px;
  }

  .module-card .module-card-head {
    min-height: 44px;
    margin: -12px -12px 8px;
    padding: 7px 9px 7px 11px;
  }

  .module-card .module-card-head h2 {
    font-size: 17px;
  }

  .active-block-total { font-size: 16px; }

  .module-card-title { gap: 6px; }
  .module-card-summary { font-size: 11px; }

  .module-card .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .module-card .field { gap: 3px; }
  .module-card .field span { font-size: 10px; line-height: 1.15; }
  .module-card input, .module-card select { min-height: 36px; padding: 7px 8px; }
  .module-card .field.full { grid-column: 1 / -1; }
  .module-compact { margin-bottom: 8px; font-size: 12px; }

  .supplemental-price-row {
    gap: 8px;
    padding: 8px;
    font-size: 12px;
  }

  .settings-head-btn,
  .mobile-settings-btn {
    width: 48px;
  }

  .result-row {
    grid-template-columns: minmax(0, 1fr) 70px 40px;
  }

  .statement-table-wrap,
  .material-table-wrap,
  .technical-table-wrap {
    overflow: visible;
  }

  .statement-table,
  .data-table,
  .technical-table {
    min-width: 0;
  }

  .statement-table thead,
  .data-table thead,
  .technical-table thead {
    display: none;
  }

  .statement-table tbody,
  .data-table tbody,
  .technical-table tbody {
    display: grid;
    gap: 8px;
  }

  .statement-table tr,
  .data-table tr,
  .technical-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px 12px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
  }

  .statement-table td,
  .data-table td,
  .technical-table td {
    display: block;
    min-width: 0;
    padding: 0;
    border: 0;
  }

  .statement-table td::before,
  .data-table td::before,
  .technical-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .statement-table .statement-title-cell,
  .data-table .statement-title-cell,
  .data-table .statement-price-cell,
  .data-table .statement-sum-cell,
  .technical-table .statement-title-cell,
  .technical-table .statement-price-cell,
  .technical-table .statement-sum-cell,
  .data-table .row-action-cell {
    grid-column: 1 / -1;
  }

  .statement-table .statement-title-cell::before,
  .data-table .statement-title-cell::before,
  .technical-table .statement-title-cell::before,
  .data-table .row-action-cell::before {
    display: none;
  }

  .technical-table th:nth-child(n+2),
  .technical-table td:nth-child(n+2) {
    text-align: left;
  }

  .statement-table td strong {
    margin-bottom: 0;
  }

  /* На телефоне строки сметы остаются читаемыми, но не растягиваются на
     четыре вертикальных блока: название, количество и цена, затем итог. */
  .statement-table .statement-sum-cell {
    grid-column: 2;
    text-align: right;
    align-self: end;
  }

  .technical-modal {
    width: calc(100vw - 20px);
    max-height: calc(100dvh - 20px - var(--safe-top) - var(--safe-bottom));
    padding: 12px;
  }

  .technical-modal-group {
    padding: 10px;
  }

  .technical-table tr {
    grid-template-columns: minmax(0, 1fr) 72px;
    gap: 10px;
  }

  .technical-table .technical-usage-cell {
    grid-column: 1 / -1;
    order: 1;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
  }

  .technical-table .technical-material-cell {
    grid-column: 1 / -1;
    order: 2;
  }

  .technical-table .technical-qty-cell {
    order: 3;
    text-align: left;
  }

  .technical-table .technical-unit-cell {
    order: 4;
  }

  .technical-table .technical-material-cell::before,
  .technical-table .technical-usage-cell::before {
    display: block;
  }

  .technical-modal {
    width: calc(100vw - 10px);
    padding: 10px 6px;
  }

  .technical-modal .modal-head {
    padding: 0 4px 10px;
  }

  .technical-modal-group {
    margin-top: 12px;
    padding: 0;
    border: 0;
    background: transparent;
  }

  .technical-modal-group .statement-head {
    padding: 0 4px;
  }

  .technical-table-wrap {
    overflow-x: visible;
  }

  .technical-modal .technical-table {
    display: table;
    width: 100%;
    min-width: 0;
    table-layout: fixed;
    border-collapse: collapse;
  }

  .technical-modal .technical-table thead {
    display: table-header-group;
  }

  .technical-modal .technical-table tbody {
    display: table-row-group;
  }

  .technical-modal .technical-table tr {
    display: table-row;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  .technical-modal .technical-table th,
  .technical-modal .technical-table td {
    display: table-cell;
    padding: 7px 4px;
    border: 0;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
    font-size: 11px;
    line-height: 1.25;
    text-align: left;
  }

  .technical-modal .technical-table th {
    color: var(--muted);
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
    background: #f3f7f5;
  }

  .technical-modal .technical-table td::before {
    display: none;
  }

  .technical-modal .technical-material-col {
    width: 40%;
  }

  .technical-modal .technical-qty-col {
    width: 64px;
  }

  .technical-modal .technical-usage-col {
    width: auto;
  }

  .technical-modal .technical-material-cell,
  .technical-modal .technical-usage-cell,
  .technical-modal .technical-qty-cell {
    grid-column: auto;
    order: initial;
    overflow-wrap: anywhere;
  }

  .technical-modal .technical-material-cell strong {
    display: block;
    font-size: 11px;
    line-height: 1.25;
  }

  .technical-modal .technical-usage-cell {
    padding-bottom: 7px;
    border-bottom: 1px solid var(--line);
  }

  .work-table .statement-detail-cell {
    display: none;
  }

  .work-price-cell {
    min-width: 0;
  }

  .work-price-row {
    justify-content: flex-start;
  }

  .qty-input {
    width: 100%;
  }

  .qty-value-row .qty-input,
  .qty-override-row .qty-input {
    width: auto;
  }

  .row-action-cell .icon-btn {
    width: 100%;
  }

  .empty-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  h1 {
    font-size: 24px;
  }
}

@media print {
  body {
    background: #fff;
    padding: 0;
  }

  body,
  body * {
    font-family: "Times New Roman", Times, serif !important;
    font-size: 14px !important;
  }

  body.is-printing-document > :not(.print-host) {
    display: none !important;
  }

  body.is-printing-document .print-host {
    display: block !important;
  }

  body.is-printing-document .print-document {
    display: block;
  }

  .sidebar,
  .toolbar,
  .floating-add,
  .mobile-menu-btn,
  .mobile-settings-btn,
  .drawer-backdrop,
  .danger-btn,
  .ghost-btn,
  .primary-btn,
  .icon-btn,
  .search-panel,
  .fence-config-panel,
  .module-list,
  .module-add-row,
  .toast,
  .modal-backdrop,
  .modal {
    display: none !important;
  }

  .app-shell {
    display: block;
  }

  .main-content {
    padding: 0;
  }

  .order-head {
    margin-bottom: 12px;
  }

  .statement-table,
  .data-table,
  table {
    min-width: 0;
    font-size: 14px;
  }

  th,
  td {
    padding: 6px 5px;
  }

  .panel,
  .order-total {
    box-shadow: none;
  }

  .panel {
    border: 0;
    padding: 0;
  }

  .technical-sheet {
    break-before: page;
    page-break-before: always;
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
  }
}

/* Project-document drawing system: readable both on screen and in black-and-white print. */
.line-drawing-wrap,
.top-view-wrap,
.elevation-drawing-wrap,
.blueprint {
  border-color: #b9c0bd;
  border-radius: 4px;
  background: #fff;
}

.blueprint { background: #fff; }
.top-view-zone,
.top-view-wicket .top-view-zone,
.top-view-swing .top-view-zone,
.top-view-sliding .top-view-zone,
.elevation-fence-fill,
.elevation-section-fill,
.elevation-section-wicket .elevation-section-fill,
.elevation-section-swing .elevation-section-fill,
.elevation-section-sliding .elevation-section-fill,
.line-piece-wicket .line-frame,
.line-piece-swing .line-frame,
.line-piece-sliding .line-frame,
.line-piece-sliding .line-tail,
.top-view-opening-fill,
.top-view-wicket-fill,
.top-view-swing-fill,
.top-view-sliding-fill,
.top-view-tail,
.top-view-leaf,
.line-fill,
.fence-fill {
  fill: none !important;
}

.line-drawing .line-frame,
.line-drawing .line-rail,
.line-drawing .line-inner,
.line-drawing .line-tail,
.line-drawing .line-tail-divider,
.top-view-rail,
.top-view-wicket-line,
.top-view-swing-line,
.top-view-sliding-line,
.top-view-opening-fill,
.top-view-opening-member,
.top-view-tail,
.elevation-fence-top,
.elevation-section-top,
.elevation-section-inner,
.elevation-ground,
.elevation-post,
.bp-frame,
.bp-post,
.bp-post-outline,
.bp-frame-thin,
.bp-inner-frame,
.bp-inner,
.bp-diag,
.bp-strip,
.bp-channel,
.bp-pile {
  stroke: #202624 !important;
  stroke-width: 1.35px !important;
}

.line-piece-wicket .line-frame,
.top-view-wicket-line,
.elevation-section-wicket .elevation-section-top,
.elevation-section-wicket .elevation-section-inner { stroke-dasharray: 7 3; }
.line-piece-swing .line-frame,
.top-view-swing-line,
.elevation-section-swing .elevation-section-top,
.elevation-section-swing .elevation-section-inner { stroke-dasharray: 11 3 2 3; }
.line-piece-sliding .line-frame,
.top-view-sliding-line,
.elevation-section-sliding .elevation-section-top,
.elevation-section-sliding .elevation-section-inner { stroke-dasharray: 2 3; }

.line-post,
.module-post,
.top-view-post,
.line-pile-cap,
.elevation-ground-point,
.bp-hinge { fill: #fff !important; stroke: #202624 !important; stroke-width: 1.1px !important; }
.module-post,
.top-view-post-large { stroke-width: 2px !important; }
.line-pile-shaft,
.top-view-pile,
.bp-ground,
.elevation-level,
.elevation-dimension,
.line-dim-guide,
.line-drawing .bp-dim,
.bp-dim { stroke: #66706c !important; stroke-width: 0.9px !important; }

.top-view-label,
.top-view-post-label,
.top-view-legend,
.elevation-level-label,
.elevation-axis-label,
.elevation-point-label,
.elevation-post-label,
.elevation-dimension-label,
.line-drawing .bp-dim-text,
.bp-dim-text,
.bp-label {
  fill: #202624 !important;
  font-weight: 600 !important;
  stroke: #fff;
  stroke-width: 2px;
  paint-order: stroke;
}
