*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #1e1e2e;
  color: #cdd6f4;
  height: 100vh;
  height: 100dvh; /* mobile: accounts for browser chrome */
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* mobile: accounts for browser chrome */
}

header {
  background: #181825;
  padding: 0.6rem 1.2rem;
  border-bottom: 1px solid #313244;
  flex-shrink: 0;
}

header h1 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #cba6f7;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ── Sidebar ─────────────────────────────────────────────── */

#sidebar {
  width: 260px;
  background: #181825;
  border-right: 1px solid #313244;
  padding: 0.75rem 1rem;
  overflow-y: auto;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.section-title {
  font-size: 0.68rem;
  font-weight: 600;
  color: #6c7086;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.6rem;
}

/* Roof type selector */
.rts-wrapper {
  position: relative;
}

.rts-selected {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #252535;
  border: 1px solid #45475a;
  border-radius: 5px;
  color: #cdd6f4;
  font-size: 0.78rem;
  padding: 0.38rem 0.6rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s;
}

.rts-selected:hover {
  border-color: #cba6f7;
}

.rts-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rts-arrow {
  margin-left: 0.4rem;
  color: #6c7086;
  font-size: 0.7rem;
  flex-shrink: 0;
}

.rts-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #1e1e2e;
  border: 1px solid #45475a;
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
  z-index: 200;
  overflow: hidden;
}

.rts-dropdown.hidden {
  display: none;
}

.rts-item {
  display: block;
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid #252535;
  color: #a6adc8;
  font-size: 0.78rem;
  padding: 0.45rem 0.7rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

.rts-item:last-child {
  border-bottom: none;
}

.rts-item:hover {
  background: #252535;
  color: #cdd6f4;
}

.rts-item.active {
  color: #cba6f7;
  font-weight: 600;
}

/* Controls */
.controls-form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}

.input-group label {
  font-size: 0.7rem;
  color: #a6adc8;
  display: block;
  margin-bottom: 0.18rem;
}

/* Wrapper: [input + "mm"][▲▼] all in one row */
.input-wrapper {
  display: flex;
  align-items: stretch;
  border: 1px solid #45475a;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.input-wrapper:focus-within {
  border-color: #cba6f7;
}

.input-group input {
  background: #1e1e2e;
  border: none;
  color: #cdd6f4;
  padding: 0.32rem 2.4rem 0.32rem 0.5rem; /* right padding leaves room for unit */
  font-size: 0.88rem;
  width: 100%;
  min-width: 0;
}

.input-group input:focus {
  outline: none;
}

/* "mm" floated inside the input on the right */
.input-suffix {
  position: absolute;
  right: 30px; /* sits left of the spinners */
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.68rem;
  color: #555570;
  pointer-events: none;
  user-select: none;
}

/* Custom ▲▼ buttons outside the input field */
.input-spinners {
  display: flex;
  flex-direction: column;
  border-left: 1px solid #45475a;
  flex-shrink: 0;
}

.spin-btn {
  flex: 1;
  width: 28px;
  background: #252535;
  border: none;
  color: #7070a0;
  font-size: 0.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}

.spin-btn:hover {
  background: #313150;
  color: #cdd6f4;
}

.spin-btn:active {
  background: #cba6f7;
  color: #1e1e2e;
}

/* ── Step layers container (Darbai / Medžiagos žingsniai) ── */

.step-layers-container {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 100;
  width: auto !important;
  max-width: none !important;
  margin-bottom: 0 !important;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.4rem;
}

.step-layers-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: #ffffff;
  border: 1px solid #d0d0d8;
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  transition: background 0.15s, box-shadow 0.15s;
}

.step-layers-btn:hover {
  background: #f0f0f5;
  box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}

.step-layers-btn img { display: block; }


/* ── Layers button & popup ───────────────────────────────── */

#layers-container {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 100;
  display: flex;
  flex-direction: row;
  gap: 0.4rem;
}

#rotate-btn,
#layers-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: #ffffff;
  border: 1px solid #d0d0d8;
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  transition: background 0.15s, box-shadow 0.15s;
}

#rotate-btn:hover,
#layers-btn:hover {
  background: #f0f0f5;
  box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}

#rotate-btn img,
#layers-btn img {
  display: block;
}

.layers-popup {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 230px;
  background: #1e1e2e;
  border: 1px solid #313244;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  overflow: hidden;
}

.layers-popup.hidden {
  display: none;
}

.layers-popup-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.9rem;
  background: #181825;
  border-bottom: 1px solid #313244;
  font-size: 0.82rem;
  font-weight: 700;
  color: #cdd6f4;
  letter-spacing: 0.04em;
}

.layers-popup-header img {
  opacity: 0.75;
}

#layers-list {
  padding: 0.5rem 0;
}

/* Layer rows */
.layer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.42rem 0.9rem;
  cursor: pointer;
  user-select: none;
}

.layer-row:hover {
  background: #252535;
}

.layer-label {
  font-size: 0.8rem;
  color: #a6adc8;
}

.layer-row:hover .layer-label {
  color: #cdd6f4;
}

/* iOS-style switch */
.layer-switch {
  position: relative;
  width: 36px;
  height: 20px;
  background: #45475a;
  border-radius: 10px;
  transition: background 0.2s;
  flex-shrink: 0;
}

.layer-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.layer-switch.on {
  background: #cba6f7;
}

.layer-switch.on::after {
  transform: translateX(16px);
}

/* Area panel */
.area-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.area-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: #a6adc8;
}

.area-total {
  border-top: 1px solid #313244;
  margin-top: 0.3rem;
  padding-top: 0.3rem;
  font-size: 0.82rem;
  color: #cdd6f4;
  font-weight: 600;
}

.area-value {
  color: #cba6f7;
  font-weight: 600;
}

/* Ridge panel */
.ridge-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.ridge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.ridge-label {
  font-size: 0.75rem;
  color: #a6adc8;
  flex-shrink: 0;
}

.ridge-readonly-val {
  font-size: 0.78rem;
  color: #cdd6f4;
  text-align: right;
}

.ridge-input-wrapper {
  display: flex;
  align-items: center;
  border: 1px solid #45475a;
  border-radius: 4px;
  overflow: hidden;
  background: #1e1e2e;
}

.ridge-input-wrapper:focus-within {
  border-color: #cba6f7;
}

.ridge-input {
  background: transparent;
  border: none;
  color: #cdd6f4;
  font-size: 0.82rem;
  padding: 0.22rem 0.4rem;
  width: 96px;
  min-width: 0;
}

.ridge-input:focus {
  outline: none;
}

.ridge-suffix {
  font-size: 0.68rem;
  color: #555570;
  padding-right: 0.35rem;
  pointer-events: none;
}

/* ── Lock buttons ────────────────────────────────────────── */

/* Row wrapper that holds .input-wrapper + optional lock button side by side */
.input-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Section title row: title text on the left, lock button on the right */
.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}

.section-title-row .section-title {
  margin-bottom: 0; /* title row handles spacing */
}

.lock-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid #45475a;
  border-radius: 4px;
  background: #252535;
  color: #6c7086;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}

.lock-btn:hover:not(:disabled) {
  border-color: #cba6f7;
  color: #cba6f7;
}

.lock-btn.active {
  background: #cba6f7;
  border-color: #cba6f7;
  color: #1e1e2e;
}

.lock-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Dimmed appearance for locked inputs */
.input-wrapper.locked,
.ridge-input-wrapper.locked {
  border-color: #313244;
  opacity: 0.55;
}

/* Price preset selector */
.preset-group {
  display: flex;
  gap: 0.4rem;
}

.preset-btn {
  flex: 1;
  background: #252535;
  border: 1px solid #45475a;
  border-radius: 5px;
  color: #a6adc8;
  font-size: 0.75rem;
  padding: 0.32rem 0.4rem;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.preset-btn:hover {
  background: #313150;
  color: #cdd6f4;
}

.preset-btn.active {
  background: #313150;
  border-color: #cba6f7;
  color: #cba6f7;
  font-weight: 600;
}

/* Template selector */
.template-select {
  width: 100%;
  background: #1e1e2e;
  border: 1px solid #45475a;
  border-radius: 4px;
  color: #cdd6f4;
  font-size: 0.8rem;
  padding: 0.32rem 0.5rem;
  cursor: pointer;
}

.template-select:focus {
  outline: none;
  border-color: #cba6f7;
}

/* Client input fields */
.client-input {
  width: 100%;
  background: #1e1e2e;
  border: 1px solid #45475a;
  border-radius: 4px;
  color: #cdd6f4;
  font-size: 0.82rem;
  padding: 0.3rem 0.5rem;
}

.client-input:focus {
  outline: none;
  border-color: #cba6f7;
}

.client-input::placeholder {
  color: #45475a;
}

/* Grand total */
.grand-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #252535;
  border: 1px solid #45475a;
  border-radius: 6px;
  padding: 0.5rem 0.7rem;
  margin-top: 0.2rem;
}

.grand-total-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: #cdd6f4;
}

.grand-total-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: #a6e3a1;
}

/* Extra work items */
.extra-add-btn {
  width: 100%;
  margin-top: 0.35rem;
  background: transparent;
  border: 1px dashed #45475a;
  border-radius: 4px;
  color: #6c7086;
  font-size: 0.72rem;
  padding: 0.28rem 0;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
}

.extra-add-btn:hover {
  color: #cba6f7;
  border-color: #cba6f7;
}

.extra-remove-btn {
  background: transparent;
  border: none;
  color: #f38ba8;
  font-size: 0.7rem;
  cursor: pointer;
  padding: 0 0 0 0.3rem;
  flex-shrink: 0;
}

/* Estimate & Materials panels */
.estimate-list {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

/* ── Materials accordion ─────────────────────────────────────────────────── */

.mat-accordion {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.mat-cat {
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #45475a;
}

.mat-cat-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.6rem;
  cursor: pointer;
  user-select: none;
  background: #313244;
  min-height: 36px;
}

.mat-cat-header:hover {
  background: #3a3a56;
}

.mat-cat-arrow {
  font-size: 0.6rem;
  color: #6c7086;
  flex-shrink: 0;
  width: 12px;
}

.mat-cat-name {
  font-size: 0.82rem;
  font-weight: 600;
  flex: 1;
}

.mat-cat-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mat-cat-total {
  font-size: 0.82rem;
  font-weight: 600;
  color: #cba6f7;
}

.mat-cat-body {
  padding: 0.4rem 0.5rem 0.5rem;
  background: #1e1e2e;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

/* Eilutė: tiek rankinio įvedimo, tiek difūzinės plėvelės */
.mat-item-row {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: nowrap;
  min-height: 30px;
}

/* Difūzinė plėvelė — statinis pavadinimas */
.mat-item-label {
  font-size: 0.8rem;
  color: #cdd6f4;
  flex: 1;
  white-space: nowrap;
}

/* Rankinio įvedimo eilutė — pavadinimo įvestis */
.mat-item-name {
  flex: 1;
  min-width: 0;
  padding: 0.15rem 0.3rem;
  font-size: 0.8rem;
  border: 1px solid #45475a;
  border-radius: 4px;
  background: #313244;
  color: #cdd6f4;
}

.mat-item-name:focus {
  outline: none;
  border-color: #7c3aed;
}

.mat-item-qty,
.mat-item-price {
  width: 58px;
  padding: 0.15rem 0.3rem;
  font-size: 0.8rem;
  border: 1px solid #45475a;
  border-radius: 4px;
  background: #313244;
  color: #cdd6f4;
  text-align: right;
}

.mat-item-unit {
  width: 48px;
  padding: 0.15rem 0.3rem;
  font-size: 0.8rem;
  border: 1px solid #45475a;
  border-radius: 4px;
  background: #313244;
  color: #cdd6f4;
  text-align: center;
}

.mat-item-qty:focus,
.mat-item-price:focus,
.mat-item-unit:focus {
  outline: none;
  border-color: #7c3aed;
}

.mat-item-controls {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.78rem;
  color: #6c7086;
}

.mat-item-total {
  font-size: 0.8rem;
  font-weight: 600;
  color: #cba6f7;
  text-align: right;
  min-width: 70px;
  white-space: nowrap;
}

.mat-item-row--disabled .estimate-toggle,
.mat-item-row--disabled .mat-item-qty,
.mat-item-row--disabled .mat-item-unit,
.mat-item-row--disabled .mat-item-price,
.mat-item-row--disabled .mat-item-total {
  opacity: 0.35;
}

.mat-item-remove {
  background: none;
  border: none;
  color: #6c7086;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0.2rem;
  border-radius: 3px;
  flex-shrink: 0;
}

.mat-item-remove:hover {
  color: #f38ba8;
  background: rgba(243, 139, 168, 0.12);
}

/* Sub-elementų grupė (pvz. Šiferis variantai) */
.mat-subitem-group {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.mat-subitems {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-top: 0.15rem;
  padding: 0.35rem 0.5rem 0.35rem 1.6rem;
  border-left: 2px solid #45475a;
  border-radius: 0 0 4px 4px;
}

.mat-subitem-row {
  font-size: 0.78rem;
}

.mat-subitem-row .mat-item-label {
  font-size: 0.78rem;
  color: #a6adc8;
}

/* Statinis vieneto tekstas subItem eilutėje (ne input) */
.mat-item-unit--static {
  width: 48px;
  font-size: 0.8rem;
  color: #6c7086;
  text-align: center;
  padding: 0.15rem 0.3rem;
  flex-shrink: 0;
}

.mat-add-btn {
  align-self: flex-start;
  margin-top: 0.2rem;
  padding: 0.25rem 0.6rem;
  font-size: 0.78rem;
  border: 1px dashed #45475a;
  border-radius: 4px;
  background: none;
  color: #6c7086;
  cursor: pointer;
}

.mat-add-btn:hover {
  border-color: #7c3aed;
  color: #cba6f7;
}

/* Difūzinė plėvelė — 2 eilučių išdėstymas */
.mat-difuzine-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.mat-difuzine-bottom {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
  font-size: 0.78rem;
}

.mat-difuzine-auto {
  color: #6c7086;
  font-size: 0.75rem;
  white-space: nowrap;
}

.mat-difuzine-area-info {
  font-size: 0.78rem;
  color: #a6adc8;
  white-space: nowrap;
}

/* Materials table — timber category */

.estimate-category {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #cba6f7;
  padding: 0.75rem 0 0.25rem;
  border-top: 1px solid #45475a;
  margin-top: 0.5rem;
}

.mat-timber-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mat-timber-header-price {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: #a6adc8;
}

.mat-timber-price-input {
  width: 52px;
  padding: 0.1rem 0.3rem;
  background: #1e1e2e;
  border: 1px solid #45475a;
  border-radius: 4px;
  color: #cdd6f4;
  font-size: 0.72rem;
  text-align: center;
}

.mat-timber-price-input:focus {
  outline: none;
  border-color: #cba6f7;
}

.mat-timber-row--disabled {
  opacity: 0.4;
}

.mat-timber-row {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid #25253a;
}

.mat-timber-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.mat-timber-name {
  font-size: 0.75rem;
  color: #cdd6f4;
  flex: 1;
}

.mat-timber-dims {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  color: #a6adc8;
}

.mat-dim-input {
  width: 44px;
  padding: 0.15rem 0.3rem;
  background: #1e1e2e;
  border: 1px solid #45475a;
  border-radius: 4px;
  color: #cdd6f4;
  font-size: 0.7rem;
  text-align: center;
}

.mat-dim-input:focus {
  outline: none;
  border-color: #cba6f7;
}

.mat-timber-bottom {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.68rem;
  color: #6c7086;
}

.mat-timber-lm {
  color: #6c7086;
}

.mat-timber-pcs {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  color: #89b4fa;
  font-weight: 600;
}

.mat-pcs-input {
  width: 44px;
  padding: 0.15rem 0.3rem;
  background: #1e1e2e;
  border: 1px solid #45475a;
  border-radius: 4px;
  color: #cdd6f4;
  font-size: 0.7rem;
  font-weight: 600;
  text-align: center;
}

.mat-pcs-input:focus {
  outline: none;
  border-color: #7c3aed;
}

/* Rankinis override — tik kraštinė keičiasi, ne teksto spalva */
.mat-pcs-input--manual {
  border-color: #f9a825;
}

.mat-pcs-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #f3f4f6;
  color: #374151;
  cursor: pointer;
  user-select: none;
}

.mat-pcs-btn:hover {
  background: #e5e7eb;
  border-color: #7c3aed;
  color: #7c3aed;
}

.mat-timber-m3 {
  color: #a6e3a1;
  font-weight: 600;
}

.mat-other-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.mat-other-controls {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 1;
  font-size: 0.85rem;
  color: #6b7280;
}

.mat-other-input {
  width: 64px;
  padding: 0.1rem 0.3rem;
  font-size: 0.85rem;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  text-align: right;
  background: inherit;
  color: inherit;
}

.mat-other-input:focus {
  outline: none;
  border-color: #7c3aed;
}

.mat-timber-price {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  margin-left: auto;
}

.mat-timber-total {
  font-size: 0.75rem;
}

/* VAT breakdown: Be PVM | PVM (21%) | Su PVM */
.mat-vat-breakdown {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.2rem;
  flex-wrap: wrap;
}

.mat-vat-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.05rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: rgba(99, 102, 241, 0.06);
}

.mat-vat-cell--total {
  background: rgba(139, 92, 246, 0.12);
}

.mat-vat-label {
  font-size: 0.62rem;
  color: #6c7086;
  white-space: nowrap;
}

.mat-vat-value {
  font-size: 0.8rem;
  font-weight: 700;
  color: #cba6f7;
}

.mat-vat-cell--total .mat-vat-value {
  color: #f5c2e7;
  font-size: 0.88rem;
}

.stogas-toggles {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.4rem 0 0.5rem 0.5rem;
  border-left: 2px solid #313244;
  margin-left: 0.25rem;
  margin-bottom: 0.25rem;
}

.estimate-notes-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 0.75rem;
}

.estimate-notes-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted, #6b7280);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.estimate-notes-area {
  width: 100%;
  box-sizing: border-box;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border, #313244);
  border-radius: 4px;
  background: var(--input-bg, #1e1e2e);
  color: var(--text, #cdd6f4);
  font-size: 0.8rem;
  font-family: inherit;
  resize: vertical;
  min-height: 3.5rem;
}

.stogas-toggle-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stogas-toggle-row--has-input {
  flex-wrap: wrap;
}

.stogas-note-input {
  flex: 1 1 100%;
  margin-top: 0.25rem;
  margin-left: 2.5rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.78rem;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  background: #f9fafb;
  color: #374151;
  outline: none;
}

.stogas-note-input:focus {
  border-color: #7c3aed;
}

.stogas-note-input:disabled {
  background: #f3f4f6;
  color: #9ca3af;
  cursor: not-allowed;
  border-color: #e5e7eb;
}

.stogas-toggle-label {
  font-size: 0.78rem;
  color: #a6adc8;
}

.estimate-toggle {
  position: relative;
  display: inline-block;
  width: 30px;
  height: 17px;
  flex-shrink: 0;
  margin-top: 0.15rem;
  cursor: pointer;
}

.estimate-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.estimate-toggle-slider {
  position: absolute;
  inset: 0;
  background: #45475a;
  border-radius: 17px;
  transition: background 0.2s;
}

.estimate-toggle-slider::before {
  content: '';
  position: absolute;
  width: 11px;
  height: 11px;
  left: 3px;
  top: 3px;
  background: #cdd6f4;
  border-radius: 50%;
  transition: transform 0.2s;
}

.estimate-toggle input:checked + .estimate-toggle-slider {
  background: #a6e3a1;
}

.estimate-toggle input:checked + .estimate-toggle-slider::before {
  transform: translateX(13px);
}

.estimate-row {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid #25253a;
}

.estimate-name {
  font-size: 0.75rem;
  color: #cdd6f4;
}

.estimate-row--roofwork {
  padding: 0.5rem 0 0.25rem;
}

.estimate-row--roofwork .estimate-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: #cdd6f4;
  letter-spacing: 0.01em;
}

.estimate-meta {
  font-size: 0.68rem;
  color: #6c7086;
}

.estimate-value {
  font-size: 0.75rem;
  color: #cba6f7;
  font-weight: 600;
  text-align: right;
}

.estimate-sum {
  border-top: 1px solid #45475a;
  border-bottom: none;
  margin-top: 0.2rem;
  padding-top: 0.4rem;
}

.estimate-sum .estimate-name {
  font-weight: 700;
  color: #cdd6f4;
}

.estimate-empty {
  font-size: 0.72rem;
  color: #6c7086;
}

/* Editable price input inside estimate rows */
.estimate-meta-price {
  display: flex;
  align-items: center;
  gap: 3px;
}

.estimate-price-input {
  background: #252535;
  border: 1px solid #45475a;
  border-radius: 4px;
  color: #cba6f7;
  font-size: 0.75rem;
  font-family: inherit;
  font-weight: 600;
  width: 52px;
  text-align: right;
  padding: 0.18rem 0.35rem;
  cursor: text;
  transition: border-color 0.12s;
}

.estimate-price-input:hover {
  border-color: #6c7086;
}

.estimate-price-input:focus {
  outline: none;
  border-color: #cba6f7;
  background: #1e1e2e;
}

/* Errors */
.error-list { list-style: none; }

.error-list li {
  background: #2a1525;
  border-left: 3px solid #f38ba8;
  padding: 0.3rem 0.55rem;
  font-size: 0.75rem;
  color: #f38ba8;
  margin-bottom: 0.3rem;
  border-radius: 2px;
  line-height: 1.4;
}

/* ── SVG Viewport ────────────────────────────────────────── */

#viewport {
  flex: 1;
  overflow: hidden;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  position: relative;
}

#roof-svg {
  width: 100%;
  height: 100%;
}

/* ── SVG element classes ─────────────────────────────────── */

.roof-outline {
  fill: #ffffff;
  stroke: #3a3530;
  stroke-width: 12;
}

/* House walls – 200mm thick ring, wood fill, border stroke */
.house-walls {
  fill: #c98d4b;
  stroke: #3a3530;
  stroke-width: 14;
}

/* Centre reference line for end slopes – shows what rafterLengthEnd measures */
.end-centre-line {
  stroke: #000000;
  stroke-width: 20;
  stroke-dasharray: 80 40;
  stroke-linecap: butt;
  opacity: 1;
}

/* Hip rafters (pakalimai) and ridge (kraigė) – 30% tamsesni už paprastąsias */
.hip-rafter {
  stroke: #8c6234;
  stroke-linecap: round;
}

.ridge {
  stroke: #8c6234;
  stroke-linecap: round;
}

.ridge-point {
  fill: #8c6234;
}

/* Common and jack rafters – medienos spalva */
.rafter-border {
  stroke: #3a2a18;
  stroke-linecap: square;
}

.common-rafter {
  stroke: #c98d4b;
  stroke-linecap: square;
}

.jack-rafter {
  stroke: #c98d4b;
  stroke-linecap: square;
}

.batten {
  stroke: #8c6234;
  stroke-linecap: square;
}

.batten-num {
  fill: #3a2000;
  font-family: sans-serif;
  font-weight: 600;
  pointer-events: none;
}

/* Dimensions */
.dim-line {
  stroke: #000;
  stroke-width: 14;
}

.dim-tick {
  stroke: #000;
  stroke-width: 14;
}

.dim-text {
  fill: #000;
  font-family: 'Segoe UI', sans-serif;
  font-weight: 700;
}

.label-text {
  fill: #1a1a2e;
  font-family: 'Segoe UI', sans-serif;
  font-weight: 600;
}

.slope-arrow {
  stroke: #1d6ae5;
  stroke-linecap: round;
}

.slope-arrow-head {
  fill: #1d6ae5;
  stroke: none;
}

/* ── Header print button ─────────────────────────────────────────────────── */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#print-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: #313244;
  border: 1px solid #45475a;
  border-radius: 6px;
  color: #cdd6f4;
  font-size: 0.78rem;
  font-family: inherit;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
  transition: background 0.15s;
}

#print-btn:hover {
  background: #45475a;
}

/* ── Print area (hidden on screen) ──────────────────────────────────────── */

#print-area {
  display: none;
}

/* ── Wizard layout ───────────────────────────────────────────────────────── */

#wizard-progress-bar {
  flex-shrink: 0;
  background: #181825;
  border-bottom: 1px solid #313244;
}

.wizard-progress {
  display: flex;
  align-items: flex-start;
  padding: 0.7rem 2rem 0.4rem;
  gap: 0;
}

.wizard-step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  flex-shrink: 0;
  min-width: 60px;
}

.wizard-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #252535;
  border: 2px solid #45475a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #6c7086;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.wizard-step-item.active .wizard-dot {
  border-color: #cba6f7;
  color: #cba6f7;
}

.wizard-step-item.done .wizard-dot {
  background: #cba6f7;
  border-color: #cba6f7;
  color: #1e1e2e;
}

.wizard-step-label {
  font-size: 0.6rem;
  color: #6c7086;
  text-align: center;
  white-space: nowrap;
}

.wizard-step-item.active .wizard-step-label {
  color: #cba6f7;
  font-weight: 600;
}

.wizard-step-item.done .wizard-step-label {
  color: #a6adc8;
}

.wizard-connector {
  flex: 1;
  height: 2px;
  background: #45475a;
  margin-top: 12px; /* aligns with vertical centre of the 26px dot */
  transition: background 0.2s;
}

.wizard-connector.done {
  background: #cba6f7;
}

/* Wizard content area */

#wizard-content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.wizard-step-page {
  display: none;
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.wizard-step-page.hidden {
  display: none !important;
}

/* Split layout: sidebar + SVG (Step 2) */
.wizard-step-split {
  display: flex;
  flex-direction: row;
}

/* Form layout: centered single-column (Step 1) */
.wizard-step-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  padding: 2rem 1.5rem;
  background: #1e1e2e;
}

.wizard-form-section {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Wide layout: scrollable list (Steps 3, 4, 5) */
.wizard-step-wide {
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  padding: 1.5rem;
  gap: 0;
  background: #1e1e2e;
}

.wizard-step-wide > * {
  width: 100%;
  max-width: 720px;
  margin-bottom: 1.5rem;
}

/* Wizard nav bar */

#wizard-nav-bar {
  flex-shrink: 0;
  background: #181825;
  border-top: 1px solid #313244;
  padding: 0.6rem 1.5rem;
}

.wizard-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.wizard-btn {
  padding: 0.42rem 1.2rem;
  border-radius: 6px;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s, opacity 0.12s;
}

.wizard-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.wizard-btn-back {
  background: transparent;
  border: 1px solid #45475a;
  color: #a6adc8;
}

.wizard-btn-back:not(:disabled):hover {
  background: #252535;
  color: #cdd6f4;
}

.wizard-btn-next {
  background: #cba6f7;
  border: 1px solid #cba6f7;
  color: #1e1e2e;
  font-weight: 700;
}

.wizard-btn-next:not(:disabled):hover {
  background: #b794f4;
  border-color: #b794f4;
}

.wizard-btn-next:disabled {
  background: #45475a;
  border-color: #45475a;
  color: #6c7086;
}

.wizard-btn-print {
  background: #a6e3a1;
  border-color: #a6e3a1;
}

.wizard-btn-print:not(:disabled):hover {
  background: #94d690;
  border-color: #94d690;
}

/* Project scope toggles (Step 1) */

.scope-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.scope-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.scope-toggle {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
  cursor: pointer;
}

.scope-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.scope-toggle-slider {
  position: absolute;
  inset: 0;
  background: #45475a;
  border-radius: 20px;
  transition: background 0.2s;
}

.scope-toggle-slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  left: 3px;
  top: 3px;
  background: #cdd6f4;
  border-radius: 50%;
  transition: transform 0.2s;
}

.scope-toggle input:checked + .scope-toggle-slider {
  background: #cba6f7;
}

.scope-toggle input:checked + .scope-toggle-slider::before {
  transform: translateX(16px);
}

.scope-toggle-label {
  font-size: 0.82rem;
  color: #a6adc8;
  user-select: none;
  cursor: pointer;
}

/* Summary panel (Step 5) */

.summary-info {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.78rem;
  padding: 0.2rem 0;
  border-bottom: 1px solid #25253a;
}

.summary-label {
  color: #a6adc8;
}

.summary-value {
  color: #cba6f7;
  font-weight: 600;
  text-align: right;
}

/* ─────────────────────────────────────────────────────────────────────────
   Light theme — viskas žemiau header (header lieka tamsus)
   Accent: #7c3aed (violet), fono: #ffffff / #f8f9fa, tekstas: #1a1a2e
   ───────────────────────────────────────────────────────────────────────── */

body {
  background: #f8f9fa;
  color: #1a1a2e;
}

/* ── Sidebar ── */
#sidebar {
  background: #ffffff;
  border-right-color: #e5e7eb;
}
.section-title { color: #6b7280; }

/* Roof type selector */
.rts-selected { background: #f9fafb; border-color: #d1d5db; color: #1a1a2e; }
.rts-selected:hover { border-color: #7c3aed; }
.rts-arrow { color: #9ca3af; }
.rts-dropdown { background: #ffffff; border-color: #e5e7eb; box-shadow: 0 6px 20px rgba(0,0,0,0.1); }
.rts-item { border-bottom-color: #f3f4f6; color: #6b7280; }
.rts-item:hover { background: #f3f4f6; color: #1a1a2e; }
.rts-item.active { color: #7c3aed; }

/* Controls / inputs */
.input-group label { color: #6b7280; }
.input-wrapper { border-color: #d1d5db; }
.input-wrapper:focus-within { border-color: #7c3aed; }
.input-group input { background: #ffffff; color: #1a1a2e; }
.input-suffix { color: #9ca3af; }
.input-spinners { border-left-color: #d1d5db; }
.spin-btn { background: #f3f4f6; color: #9ca3af; }
.spin-btn:hover { background: #e5e7eb; color: #1a1a2e; }
.spin-btn:active { background: #7c3aed; color: #ffffff; }

/* Step layers button */
.step-layers-btn { background: #ffffff; border-color: #d1d5db; box-shadow: 0 2px 6px rgba(0,0,0,0.1); }
.step-layers-btn:hover { background: #f3f4f6; }

/* Layers popup */
.layers-popup { background: #ffffff; border-color: #e5e7eb; box-shadow: 0 8px 24px rgba(0,0,0,0.12); }
.layers-popup-header { background: #f9fafb; border-bottom-color: #e5e7eb; color: #1a1a2e; }
.layer-row:hover { background: #f3f4f6; }
.layer-label { color: #6b7280; }
.layer-row:hover .layer-label { color: #1a1a2e; }
.layer-switch { background: #d1d5db; }
.layer-switch.on { background: #7c3aed; }

/* Area panel */
.area-row { color: #6b7280; }
.area-total { border-top-color: #e5e7eb; color: #1a1a2e; }
.area-value { color: #7c3aed; }

/* Ridge panel */
.ridge-label { color: #6b7280; }
.ridge-readonly-val { color: #1a1a2e; }
.ridge-input-wrapper { border-color: #d1d5db; background: #ffffff; }
.ridge-input-wrapper:focus-within { border-color: #7c3aed; }
.ridge-input { color: #1a1a2e; }
.ridge-suffix { color: #9ca3af; }

/* Lock buttons */
.lock-btn { border-color: #d1d5db; background: #f3f4f6; color: #9ca3af; }
.lock-btn:hover:not(:disabled) { border-color: #7c3aed; color: #7c3aed; }
.lock-btn.active { background: #7c3aed; border-color: #7c3aed; color: #ffffff; }
.input-wrapper.locked, .ridge-input-wrapper.locked { border-color: #e5e7eb; }

/* Preset buttons */
.preset-btn { background: #f3f4f6; border-color: #d1d5db; color: #6b7280; }
.preset-btn:hover { background: #ede9ff; color: #1a1a2e; }
.preset-btn.active { background: #ede9ff; border-color: #7c3aed; color: #7c3aed; }

/* Template / client inputs */
.template-select { background: #ffffff; border-color: #d1d5db; color: #1a1a2e; }
.template-select:focus { border-color: #7c3aed; }
.client-input { background: #ffffff; border-color: #d1d5db; color: #1a1a2e; }
.client-input:focus { border-color: #7c3aed; }
.client-input::placeholder { color: #9ca3af; }

/* Grand total */
.grand-total-row { background: #f3f0ff; border-color: #c4b5fd; }
.grand-total-label { color: #1a1a2e; }
.grand-total-value { color: #16a34a; }

/* Extra work */
.extra-add-btn { border-color: #d1d5db; color: #9ca3af; }
.extra-add-btn:hover { color: #7c3aed; border-color: #7c3aed; }
.extra-remove-btn { color: #dc2626; }

/* Estimate & materials tables */
.estimate-category { color: #7c3aed; border-top-color: #e5e7eb; }

/* Accordion — light theme */
.mat-cat              { border-color: #e5e7eb; }
.mat-cat-header       { background: #f3f4f6; }
.mat-cat-header:hover { background: #ede9ff; }
.mat-cat-arrow        { color: #9ca3af; }
.mat-cat-name         { color: #1a1a2e; }
.mat-cat-total        { color: #7c3aed; }
.mat-cat-body         { background: #ffffff; }
.mat-item-name,
.mat-item-qty,
.mat-item-price,
.mat-item-unit        { background: #ffffff; border-color: #d1d5db; color: #1a1a2e; }
.mat-item-name:focus,
.mat-item-qty:focus,
.mat-item-price:focus,
.mat-item-unit:focus  { border-color: #7c3aed; }
.mat-item-label       { color: #374151; }
.mat-item-controls    { color: #6b7280; }
.mat-item-total       { color: #7c3aed; }
.mat-item-remove      { color: #9ca3af; }
.mat-item-remove:hover { color: #dc2626; background: rgba(220,38,38,0.08); }
.mat-add-btn          { border-color: #d1d5db; color: #9ca3af; }
.mat-add-btn:hover    { border-color: #7c3aed; color: #7c3aed; }
.mat-difuzine-auto       { color: #9ca3af; }
.mat-difuzine-area-info  { color: #6b7280; }
.mat-subitems         { border-color: #d1d5db; }
.mat-subitem-row .mat-item-label { color: #4b5563; }

.mat-timber-header-price { color: #6b7280; }
.mat-timber-price-input { background: #ffffff; border-color: #d1d5db; color: #1a1a2e; }
.mat-timber-price-input:focus { border-color: #7c3aed; }
.mat-timber-row { border-bottom-color: #e5e7eb; }
.mat-timber-name { color: #1a1a2e; }
.mat-timber-dims { color: #6b7280; }
.mat-dim-input { background: #ffffff; border-color: #d1d5db; color: #1a1a2e; }
.mat-dim-input:focus { border-color: #7c3aed; }
.mat-timber-bottom, .mat-timber-lm { color: #9ca3af; }
.mat-timber-pcs { color: #374151; }
.mat-pcs-input { background: #ffffff; border-color: #d1d5db; color: #1a1a2e; }
.mat-pcs-input:focus { border-color: #7c3aed; }
.mat-pcs-input--manual { border-color: #f59e0b; }
.mat-timber-m3 { color: #16a34a; }
.mat-vat-cell { background: rgba(99, 102, 241, 0.05); }
.mat-vat-cell--total { background: rgba(124, 58, 237, 0.08); }
.mat-vat-label { color: #9ca3af; }
.mat-vat-value { color: #7c3aed; }
.mat-vat-cell--total .mat-vat-value { color: #7c3aed; }
.stogas-toggles { border-left-color: #e5e7eb; }
.stogas-toggle-label { color: #6b7280; }
.estimate-toggle-slider { background: #d1d5db; }
.estimate-toggle-slider::before { background: #ffffff; }
.estimate-toggle input:checked + .estimate-toggle-slider { background: #16a34a; }
.estimate-row { border-bottom-color: #e5e7eb; }
.estimate-name { color: #1a1a2e; }
.estimate-meta { color: #9ca3af; }
.estimate-value { color: #7c3aed; }
.estimate-sum { border-top-color: #e5e7eb; }
.estimate-sum .estimate-name { color: #1a1a2e; }
.estimate-empty { color: #9ca3af; }
.estimate-price-input { background: #f9fafb; border-color: #d1d5db; color: #7c3aed; }
.estimate-price-input:hover { border-color: #9ca3af; }
.estimate-price-input:focus { border-color: #7c3aed; background: #ffffff; }

/* Errors */
.error-list li { background: #fff1f2; border-left-color: #dc2626; color: #dc2626; }

/* ── Wizard progress bar ── */
#wizard-progress-bar { background: #ffffff; border-bottom-color: #e5e7eb; }
.wizard-dot { background: #f3f4f6; border-color: #d1d5db; color: #9ca3af; }
.wizard-step-item.active .wizard-dot { border-color: #7c3aed; color: #7c3aed; }
.wizard-step-item.done .wizard-dot { background: #7c3aed; border-color: #7c3aed; color: #ffffff; }
.wizard-step-label { color: #9ca3af; }
.wizard-step-item.active .wizard-step-label { color: #7c3aed; }
.wizard-step-item.done .wizard-step-label { color: #6b7280; }
.wizard-connector { background: #e5e7eb; }
.wizard-connector.done { background: #7c3aed; }

/* ── Wizard content ── */
.wizard-step-form { background: #f8f9fa; }
.wizard-step-wide { background: #f8f9fa; }

/* ── Wizard nav bar ── */
#wizard-nav-bar { background: #ffffff; border-top-color: #e5e7eb; }
.wizard-btn-back { border-color: #d1d5db; color: #6b7280; }
.wizard-btn-back:not(:disabled):hover { background: #f3f4f6; color: #1a1a2e; }
.wizard-btn-next { background: #7c3aed; border-color: #7c3aed; color: #ffffff; }
.wizard-btn-next:not(:disabled):hover { background: #6d28d9; border-color: #6d28d9; }
.wizard-btn-next:disabled { background: #d1d5db; border-color: #d1d5db; color: #9ca3af; }
.wizard-btn-print { background: #16a34a; border-color: #16a34a; color: #ffffff; }
.wizard-btn-print:not(:disabled):hover { background: #15803d; border-color: #15803d; }

/* ── Project scope toggles ── */
.scope-toggle-slider { background: #d1d5db; }
.scope-toggle-slider::before { background: #ffffff; }
.scope-toggle input:checked + .scope-toggle-slider { background: #7c3aed; }
.scope-toggle-label { color: #6b7280; }

/* ── Summary ── */
.summary-row { border-bottom-color: #e5e7eb; }
.summary-label { color: #6b7280; }
.summary-value { color: #7c3aed; }

/* ─────────────────────────────────────────────────────────────────────────
   Step 1 — dviejų skilčių forma (Tiekėjas + Užsakovas)
   ───────────────────────────────────────────────────────────────────────── */

/* Platesnė forma Step 1 dviem skilčių */
.wizard-form-section--wide {
  max-width: 900px;
}

/* Sidebar antraštė — švarus Inter, be violetinės linijos */
.sidebar-heading {
  font-size: 0.95rem;
  font-weight: 600;
  color: #111827;
  margin-bottom: 0.75rem;
}

/* Area quick input (virš controls sidebar) */
.area-quick-group {
  padding-bottom: 0.75rem;
  margin-bottom: 0.25rem;
  border-bottom: 1px solid #e5e7eb;
}

/* Dviejų skilčių tinklelis */
.party-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}


@media (max-width: 640px) {
  .party-grid { grid-template-columns: 1fr; }
}

/* Įmonė / Privatus asmuo tipų pasirinkimas */
.party-type-selector {
  display: flex;
  gap: 0;
  margin-bottom: 1rem;
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
}

.party-type-btn {
  flex: 1;
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 500;
  background: #f9fafb;
  color: #6b7280;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.party-type-btn + .party-type-btn {
  border-left: 1.5px solid #e5e7eb;
}

.party-type-btn.active {
  background: #7c3aed;
  color: #fff;
}

.party-type-btn:hover:not(.active) {
  background: #f3f0ff;
  color: #7c3aed;
}

/* Skilties antraštė */
.party-heading {
  font-size: 0.95rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #7c3aed;
}

/* ─────────────────────────────────────────────────────────────────────────
   Tipografija — Inter šriftas, dydžiai ir svoriai pagal screenshot stilių
   ───────────────────────────────────────────────────────────────────────── */

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Header lieka tamsus — jo šriftas atskirai */
header h1 {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

/* Sekcijų antraštės — be UPPERCASE, švari Inter forma */
.section-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0.01em;
}

/* Input etiketės */
.input-group label {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0;
}

/* Input reikšmės */
.input-group input {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.875rem;
  font-weight: 400;
}

/* Ridge / area panel etiketės */
.ridge-label { font-size: 0.75rem; font-weight: 500; }
.ridge-readonly-val { font-size: 0.82rem; font-weight: 500; }
.area-row { font-size: 0.78rem; font-weight: 400; }
.area-total { font-size: 0.85rem; font-weight: 600; }

/* Stogo tipo pasirinkimas */
.rts-selected { font-size: 0.82rem; font-weight: 500; }
.rts-item { font-size: 0.82rem; font-weight: 400; }
.rts-item.active { font-weight: 600; }

/* Estimate / materials lentelės */
.estimate-name { font-size: 0.95rem; font-weight: 600; }
.estimate-row--roofwork .estimate-name { font-size: 1rem; font-weight: 600; }
.estimate-meta { font-size: 0.72rem; font-weight: 400; }
.estimate-value { font-size: 0.82rem; font-weight: 600; }
.estimate-sum .estimate-name { font-size: 0.88rem; font-weight: 700; }
.estimate-category { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; }
.mat-timber-name { font-size: 0.82rem; font-weight: 500; }
.mat-timber-dims { font-size: 0.72rem; }
.mat-timber-bottom { font-size: 0.7rem; }
.stogas-toggle-label { font-size: 0.78rem; font-weight: 400; }

/* Grand total */
.grand-total-label { font-size: 0.88rem; font-weight: 600; }
.grand-total-value { font-size: 1rem; font-weight: 700; }

/* Wizard žingsnių etiketės */
.wizard-step-label { font-size: 0.65rem; font-weight: 500; }
.wizard-dot { font-size: 0.72rem; font-weight: 700; }

/* Wizard mygtukai */
.wizard-btn { font-size: 0.875rem; font-family: 'Inter', system-ui, sans-serif; font-weight: 500; }
.wizard-btn-next { font-weight: 600; }

/* Kiti inputai */
.template-select, .client-input {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.875rem;
}
.ridge-input {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.875rem;
}

/* Scope toggles */
.scope-toggle-label { font-size: 0.875rem; font-weight: 400; }

/* Summary */
.summary-row { font-size: 0.82rem; }
.summary-label { font-weight: 400; }
.summary-value { font-weight: 600; }

/* Layer etiketės */
.layer-label { font-size: 0.82rem; font-weight: 400; }
.layers-popup-header { font-size: 0.82rem; font-weight: 600; letter-spacing: 0.02em; }

/* ─────────────────────────────────────────────────────────────────────────
   Kontrastas — visi tekstai turi būti aiškiai skaitomi ant balto fono
   Hierarchija: #111827 (pagrindinis) > #374151 (antriniai) > #6b7280 (hint)
   ───────────────────────────────────────────────────────────────────────── */

/* Pagrindinis tekstas */
body { color: #111827; }

/* Etiketės ir antraštės — buvo per šviesios */
.section-title          { color: #374151; }
.input-group label      { color: #374151; }
.layer-label            { color: #374151; }
.ridge-label            { color: #374151; }
.area-row               { color: #374151; }
.area-total             { color: #111827; }
.mat-timber-header-price { color: #374151; }
.mat-timber-dims        { color: #374151; }
.mat-timber-name        { color: #111827; }
.stogas-toggle-label    { color: #374151; }
.scope-toggle-label     { color: #374151; }
.summary-label          { color: #374151; }
.wizard-btn-back        { color: #374151; }
.ridge-readonly-val     { color: #111827; }

/* Meta tekstas — šiek tiek šviesesnis bet vis dar skaitomas */
.estimate-meta          { color: #6b7280; }
.mat-timber-bottom,
.mat-timber-lm          { color: #6b7280; }
.estimate-empty         { color: #6b7280; }
.wizard-step-label      { color: #6b7280; }
.rts-item               { color: #374151; }
.rts-arrow              { color: #6b7280; }

/* Unit suffixas ("mm") ir spin mygtukai */
.input-suffix           { color: #6b7280; }
.spin-btn               { color: #6b7280; }

/* Estimate reikšmės ir pavadinimas */
.estimate-name                        { color: #111827; }
.estimate-row--roofwork .estimate-name { color: #111827; }
.estimate-sum .estimate-name           { color: #111827; }

/* Grand total */
.grand-total-label      { color: #111827; }

/* Layers popup header */
.layers-popup-header    { color: #111827; }

/* Wizard neaktyvus mygtukas — placeholder spalva ok */
.wizard-btn-next:disabled { color: #6b7280; }

/* ── Mobile (≤ 640px) ────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  /* Step 2: stack sidebar above SVG instead of side-by-side */
  .wizard-step-split {
    flex-direction: column;
    overflow-y: auto;
  }

  #sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid #e5e7eb;
    /* cap sidebar height so SVG stays visible below */
    max-height: 45vh;
    max-height: 45dvh;
    flex-shrink: 0;
  }

  /* When drawing is hidden — sidebar expands to fill the freed space */
  #step-2.no-drawing #sidebar {
    max-height: none;
    flex: 1;
    overflow-y: auto;
  }

  #viewport {
    flex: 1;
    min-height: 180px;
  }

  /* Compact progress bar — hide text labels, show only dots */
  .wizard-step-label {
    display: none;
  }

  .wizard-progress {
    padding: 0.5rem 0.75rem 0.3rem;
  }

  .wizard-step-item {
    min-width: 28px;
  }

  .wizard-dot {
    width: 24px;
    height: 24px;
    font-size: 0.65rem;
  }

  /* Bigger tap targets for nav buttons */
  #wizard-nav-bar {
    padding: 0.6rem 1rem;
  }

  .wizard-btn {
    padding: 0.65rem 1.4rem;
    font-size: 0.95rem;
  }

  /* Step 1: single-column form */
  .wizard-form-section--wide {
    max-width: 100%;
  }
}

/* ── @media print ────────────────────────────────────────────────────────── */

@media print {
  /* Hide the entire app UI */
  #app { display: none !important; }

  /* Show only the print area */
  #print-area {
    display: block !important;
  }

  /* Page setup */
  @page {
    size: A4 portrait;
    margin: 18mm 16mm 18mm 16mm;
  }

  body {
    background: #fff !important;
    color: #000 !important;
    font-family: 'Segoe UI', Arial, sans-serif;
    font-size: 11pt;
  }

  /* ── Print layout classes ── */

  .p-page {
    width: 100%;
    color: #000;
  }

  .p-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10pt;
  }

  .p-company-name {
    font-size: 15pt;
    font-weight: 700;
    margin-bottom: 3pt;
  }

  .p-company-detail {
    font-size: 9pt;
    color: #444;
    line-height: 1.5;
  }

  .p-meta {
    text-align: right;
  }

  .p-estimate-number {
    font-size: 11pt;
    margin-bottom: 3pt;
  }

  .p-estimate-date {
    font-size: 9pt;
    color: #444;
  }

  .p-divider {
    border: none;
    border-top: 1.5pt solid #000;
    margin: 8pt 0;
  }

  .p-recipient {
    margin-bottom: 8pt;
    font-size: 10pt;
    line-height: 1.6;
  }

  .p-recipient-title {
    font-weight: 700;
    margin-bottom: 2pt;
  }

  .p-roof-summary {
    font-size: 9pt;
    color: #444;
    background: #f5f5f5;
    border-left: 3pt solid #999;
    padding: 4pt 8pt;
    margin-bottom: 12pt;
  }

  .p-section-title {
    font-size: 11pt;
    font-weight: 700;
    margin: 12pt 0 4pt 0;
    border-bottom: 0.75pt solid #ccc;
    padding-bottom: 2pt;
  }

  .p-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 9.5pt;
    margin-bottom: 4pt;
  }

  .p-table thead tr {
    background: #f0f0f0;
  }

  .p-table th {
    border: 0.5pt solid #bbb;
    padding: 4pt 6pt;
    font-weight: 700;
    text-align: left;
  }

  .p-th-num {
    text-align: right !important;
    white-space: nowrap;
  }

  .p-table td {
    border: 0.5pt solid #ddd;
    padding: 3.5pt 6pt;
    vertical-align: top;
  }

  .p-td-name { width: 45%; }

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

  .p-td-total {
    text-align: right;
    white-space: nowrap;
    font-weight: 600;
  }

  .p-table tbody tr:nth-child(even) {
    background: #fafafa;
  }

  .p-subtotal {
    text-align: right;
    font-size: 10pt;
    margin: 4pt 0 2pt 0;
    color: #333;
  }

  .p-grand-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1.5pt solid #000;
    border-bottom: 1.5pt solid #000;
    padding: 6pt 4pt;
    margin: 10pt 0;
    font-size: 13pt;
    font-weight: 700;
  }

  .p-notes {
    min-height: 40pt;
    border: 0.5pt solid #ccc;
    padding: 6pt;
    font-size: 9.5pt;
    color: #333;
    white-space: pre-wrap;
    margin-bottom: 12pt;
  }

  .p-footer {
    font-size: 8.5pt;
    color: #666;
    border-top: 0.5pt solid #ccc;
    padding-top: 6pt;
    margin-top: 8pt;
    text-align: center;
  }

  .p-empty {
    color: #999;
    font-style: italic;
    font-size: 9pt;
  }

  /* ── Drawing page ── */

  .p-page-break {
    page-break-before: always;
  }

  .p-mat-vat-breakdown {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    margin: 4pt 0 2pt 0;
    gap: 1pt;
  }

  .p-mat-vat-row {
    display: flex;
    gap: 16pt;
    font-size: 9.5pt;
    color: #333;
  }

  .p-mat-vat-row span:last-child {
    min-width: 80pt;
    text-align: right;
    font-weight: 600;
  }

  .p-mat-vat-row--total {
    font-size: 10.5pt;
    font-weight: 700;
    color: #000;
    border-top: 0.75pt solid #aaa;
    padding-top: 2pt;
    margin-top: 2pt;
  }

  .p-mat-vat-row--total span:last-child {
    font-weight: 700;
  }

  .p-cat-header-row td {
    background: #e8e8e8;
    font-weight: 700;
    font-size: 8.5pt;
    padding: 3pt 6pt;
    border: 0.5pt solid #bbb;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #333;
  }

  .p-cat-subtotal td {
    background: #f5f5f5;
    border-top: 0.75pt solid #aaa;
    font-weight: 600;
    font-size: 9pt;
    padding: 3pt 6pt;
  }

  .p-area-table {
    width: auto;
    margin-bottom: 8pt;
  }

  .p-area-table td,
  .p-area-table th {
    padding: 2.5pt 8pt;
  }

  .p-area-total td {
    border-top: 1pt solid #000;
    padding-top: 3pt;
  }

  .p-drawing-container {
    margin-top: 6pt;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .p-drawing-container svg {
    width: 100%;
    height: auto;
    max-height: 170mm;
    display: block;
    background: #fff;
  }
}
