/* Sutarties generatoriaus įrankio stiliai — tik šio įrankio išdėstymas.
   Bendras reset, spalvų tokenai, mygtukai ir kortelės: ../../assets/css/shared.css

   Antraštės, wizard, šalių formų ir peržiūros blokai perkelti iš
   tools/roof-estimator/styles.css PAŽODŽIAI (su tomis pačiomis hex reikšmėmis ir
   body:not(.dark) perrašymais), kad chrome atrodytų identiškai kaip sąmatos
   skaičiuoklėje. Naujos, šiam įrankiui sukurtos taisyklės naudoja shared.css
   var() tokenus — jos pažymėtos komentaru „NAUJA". */

/* ── Puslapio karkasas ──────────────────────────────────────────────────────── */

body {
  background: #1e1e2e;
  color: #cdd6f4;
  font-size: 14px;
  height: 100vh;
  height: 100dvh; /* mobile: įskaito naršyklės chrome */
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* ── Antraštė ───────────────────────────────────────────────────────────────── */

header {
  background: #181825;
  padding: 0.384rem 1.2rem;
  border-bottom: 1px solid #313244;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header h1 {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  color: #cba6f7;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.header-back {
  font-size: 0.75rem;
  color: #6c7086;
  text-decoration: none;
  margin-right: 0.75rem;
  transition: color 0.12s;
}

.header-back:hover {
  color: #cba6f7;
}

/* ── Spausdinimo zona (ekrane nematoma) ─────────────────────────────────────── */

#print-area {
  display: none;
}

/* ── Wizard: žingsnių juosta ────────────────────────────────────────────────── */

#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; /* sutampa su 26px rutuliuko vertikaliu centru */
  transition: background 0.2s;
}

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

/* ── Wizard: turinio zona ───────────────────────────────────────────────────── */

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

/* Bazinis display:none — kiekvienas žingsnis privalo turėti išdėstymo klasę
   (--form / --wide / --split), kuri jį atidaro. .hidden su !important nustelbia. */
.wizard-step-page {
  display: none;
  position: absolute;
  inset: 0;
  overflow: hidden;
}

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

/* Centruota forma (žingsniai 1, 2) */
.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;
}

.wizard-form-section--wide {
  max-width: 900px;
}

/* Platus slankiojantis sąrašas (žingsniai 3, 4) */
.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;
}

/* Dviejų skilčių išdėstymas (žingsnis 5: dokumentų sąrašas + peržiūra) */
.wizard-step-split {
  display: flex;
  flex-direction: row;
}

/* ── Wizard: navigacijos juosta ─────────────────────────────────────────────── */

#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;
}

/* ── Žingsnio antraštė (NAUJA) ──────────────────────────────────────────────────
   Fokusuojama perjungus žingsnį (tabindex="-1"), todėl ekrano skaitytuvas
   perskaito žingsnio pavadinimą ir padėtį — žingsnių juostos jam nereikia. */

.step-heading {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--accent);
}

.step-heading-pos {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* Laikinas paaiškinimas tuščiose sekcijose — pašalinamas užpildžius sekciją */
.step-placeholder {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ── Žingsnis 5: dokumentų skiltis + peržiūros zona (NAUJA) ─────────────────── */

.docs-column {
  width: 300px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem 1.25rem 2rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.preview-pane {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1rem;
  background: var(--bg-overlay);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

/* Gyva peržiūra: kiekvienas dokumentas — atskiras baltas A4 lapas.
   Dokumentas visada „popierius", nepriklausomai nuo temos. */
#doc-preview {
  width: 100%;
  max-width: 210mm;
  margin: 0 auto;
}

#doc-preview .p-page {
  padding: 14mm 12mm;
  margin-bottom: 1.25rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* ── Šalių formos (Rangovas / Užsakovas) ────────────────────────────────────── */

.party-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

.party-heading {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #7c3aed;
}

.party-type-selector {
  display: flex;
  gap: 0;
  margin-bottom: 1rem;
  border-radius: 8px;
  overflow: hidden;
}

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

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

/* ── Formų laukai ───────────────────────────────────────────────────────────── */

.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.75rem;
  font-weight: 500;
  color: #a6adc8;
  display: block;
  margin-bottom: 0.18rem;
}

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

/* Sąmatos skaičiuoklėje čia buvo „outline: none" — čia jo NEDEDAME, nes
   klaviatūros fokusas turi likti matomas (žr. :focus-visible žemiau). */
.client-input:focus {
  border-color: #cba6f7;
}

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

/* ── Jungiklis (perkelta PAŽODŽIAI iš roof-estimator) ───────────────────────── */

.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);
}

/* Klaviatūros fokusas ant paslėpto checkbox — matomas per jungiklio rėmelį */
.scope-toggle input:focus-visible + .scope-toggle-slider {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── F2 komponentai: laukai, sekcijos, eilutės (NAUJA, per var() tokenus) ───── */

/* Tik ekrano skaitytuvui — naudojama segmentuotų radio įvesčių paslėpimui */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.field > label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}

.field-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* Klaida žymima tekstu IR ikona — ne vien spalva */
.field-error {
  font-size: 0.72rem;
  line-height: 1.4;
}
.field-error.is-error   { color: var(--danger); }
.field-error.is-warning { color: var(--warning); }
.field-error.is-error::before,
.field-error.is-warning::before { content: '⚠ '; }

[aria-invalid="true"] { border-color: var(--danger); }

.client-textarea {
  min-height: 68px;
  resize: vertical;
  line-height: 1.45;
}

.client-input--num { text-align: right; }

.num-with-suffix {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.num-with-suffix .client-input { flex: 1; min-width: 0; }

.num-suffix {
  font-size: 0.78rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.75rem 1rem;
}

/* Sekcijos — kortelės ant žingsnio fono */
.form-section {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1.1rem 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.form-section-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.section-note {
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.5;
}

#contract-type-section,
#works-panel,
#payments-panel,
#options-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Radio grupės ir varnelės — tikri input elementai fieldset viduje */
.radio-set,
.segmented-set,
.stage-works {
  border: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.radio-set legend,
.segmented-set legend,
.stage-works legend {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0 0 0.35rem;
}

.radio-set--inline {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
}
.radio-set--inline legend { width: 100%; }

.radio-row,
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px; /* touch target */
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.radio-row input,
.checkbox-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

/* Segmentuotas pasirinkimas: radio įvestis paslėpta, matomas .party-type-btn */
.party-type-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  min-height: 44px;
  background: var(--bg-overlay);
  color: var(--text-muted);
}
.party-type-btn.active::before {
  content: '✓';
  font-weight: 700;
}
.party-type-selector:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Jungiklių eilutės */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 44px;
}
.toggle-row.is-locked { opacity: 0.85; }

.toggle-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.toggle-lock {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

/* Darbų ir etapų eilutės */
.work-rows,
.stage-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.work-row,
.stage-row {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.75rem 0.9rem 0.9rem;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.work-row-legend,
.stage-row-legend {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 0.3rem;
}

.work-row-top {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
}
.work-row-top .field { flex: 1; }

.work-row-remove { flex-shrink: 0; }

/* Eilutės vidaus mygtukai (pvz. „Ištrinti etapą") — natūralaus pločio, ne per visą eilutę */
.stage-row > .btn,
.work-row > .btn { align-self: flex-start; }

.work-row-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
}

.stage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.6rem;
}

/* Suma — akcento spalva; kiekiai ir įkainiai lieka neutralūs (.client-input) */
.field--readonly { justify-content: flex-end; }

.row-total-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.row-total {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent);
  text-align: right;
  padding: 0.3rem 0;
}

.totals-block {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.9rem 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.totals-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.totals-value {
  font-weight: 600;
  color: var(--text-primary);
}

.totals-row--grand {
  border-top: 1px solid var(--border);
  padding-top: 0.5rem;
  margin-top: 0.15rem;
  font-size: 0.95rem;
}
.totals-row--grand .totals-value {
  color: var(--accent);
  font-weight: 700;
  font-size: 1.05rem;
}

/* Mokėjimų etapų valdymas */
.stage-count {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.stage-count-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.stage-count-btns {
  display: flex;
  gap: 0.4rem;
}

.btn.is-active {
  border-color: var(--accent);
  color: var(--accent);
}

.balance-line {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Užrakinta įstatyminė garantija */
.locked-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.locked-icon { opacity: 0.7; }

.locked-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.info-list {
  list-style: disc;
  padding-left: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* Tik rodoma reikšmė (pvz. objekto adresas 2 žingsnyje) */
.readonly-row {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding-top: 0.35rem;
}
.readonly-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
}
.readonly-value {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* Sulankstoma sekcija */
.collapsible {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.collapsible-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 40px;
  padding: 0.35rem 0;
  background: none;
  border: none;
  font: inherit;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: left;
  cursor: pointer;
}
.collapsible-btn:hover { color: var(--accent); }

.collapsible-caret {
  display: inline-block;
  transition: transform 0.2s;
}
.collapsible-btn[aria-expanded="true"] .collapsible-caret {
  transform: rotate(90deg);
}

.collapsible-body {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* Pranešimų juosta ir klaidų suvestinė */
.notice-bar {
  flex-shrink: 0;
  padding: 0.55rem 1.5rem;
  font-size: 0.8rem;
  background: var(--bg-overlay);
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}
.notice-bar--warning { color: var(--warning); font-weight: 600; }
.notice-bar--success { color: var(--success); font-weight: 600; }

.issue-summary {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.7rem 0.9rem;
  background: var(--bg-surface);
  border: 1px solid var(--danger);
  border-left-width: 3px;
  border-radius: var(--radius-md);
}

/* Fokusas čia atkeliauja programiškai (paspaudus „Toliau"), o pati suvestinė jau
   akivaizdžiai raudona — antro, violetinio kontūro nebereikia. */
.issue-summary:focus { outline: none; }

.issue-summary-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--danger);
}

.issue-summary ul {
  list-style: disc;
  padding-left: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* ── Sąmatos importas (F3.5, NAUJA) ─────────────────────────────────────────── */

.import-meta,
.import-offer {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.6rem 0.8rem;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
}

.import-offer {
  align-items: flex-start;
  gap: 0.5rem;
}

.import-meta-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-primary);
}

.import-meta-value {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* ── Fokuso matomumas (NAUJA) ───────────────────────────────────────────────── */

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Fokusuota žingsnio antraštė yra programinis fokusas (ne vartotojo Tab),
   todėl kontūro nerodome — tai tik prieigos taškas ekrano skaitytuvui. */
.step-heading:focus {
  outline: none;
}

/* ── Šviesi tema ────────────────────────────────────────────────────────────────
   Akcentas #7c3aed, fonai #ffffff / #f8f9fa, tekstas #1a1a2e.
   Visos taisyklės apribotos body:not(.dark), kad neperrašytų tamsios temos. */

body:not(.dark) {
  background: #f8f9fa;
  color: #1a1a2e;
}

body:not(.dark) header             { background: #ffffff; border-bottom-color: #e5e7eb; }
body:not(.dark) header h1          { color: #7c3aed; }
body:not(.dark) .header-back       { color: #6b7280; }
body:not(.dark) .header-back:hover { color: #7c3aed; }

/* Žingsnių juosta */
body:not(.dark) #wizard-progress-bar { background: #ffffff; border-bottom-color: #e5e7eb; }
body:not(.dark) .wizard-dot { background: #f3f4f6; border-color: #d1d5db; color: #9ca3af; }
body:not(.dark) .wizard-step-item.active .wizard-dot { border-color: #7c3aed; color: #7c3aed; }
body:not(.dark) .wizard-step-item.done .wizard-dot { background: #7c3aed; border-color: #7c3aed; color: #ffffff; }
body:not(.dark) .wizard-step-label { color: #9ca3af; }
body:not(.dark) .wizard-step-item.active .wizard-step-label { color: #7c3aed; }
body:not(.dark) .wizard-step-item.done .wizard-step-label { color: #6b7280; }
body:not(.dark) .wizard-connector { background: #e5e7eb; }
body:not(.dark) .wizard-connector.done { background: #7c3aed; }

/* Turinio zona */
body:not(.dark) .wizard-step-form { background: #f8f9fa; }
body:not(.dark) .wizard-step-wide { background: #f8f9fa; }

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

/* Šalių formos */
body:not(.dark) .party-heading { color: #111827; }
body:not(.dark) .party-type-selector { border: 1.5px solid #e5e7eb; }
body:not(.dark) .party-type-btn { background: #f9fafb; color: #6b7280; }
body:not(.dark) .party-type-btn + .party-type-btn { border-left: 1.5px solid #e5e7eb; }
/* Bendra „body:not(.dark) .party-type-btn" taisyklė (specifiškumas 0,2,1) nustelbdavo
   aktyvaus mygtuko foną (.active — 0,2,0), tad pasirinkimas nesimatydavo. Ši temai
   priskirta taisyklė (0,3,1) grąžina ryškų akcentą. */
body:not(.dark) .party-type-btn.active { background: #7c3aed; color: #fff; }
body:not(.dark) .party-type-btn:hover:not(.active) { background: #f3f0ff; color: #7c3aed; }

/* Formų laukai */
body:not(.dark) .input-group label { color: #6b7280; }
body:not(.dark) .client-input { background: #ffffff; border-color: #d1d5db; color: #1a1a2e; }
body:not(.dark) .client-input:focus { border-color: #7c3aed; }
body:not(.dark) .client-input::placeholder { color: #9ca3af; }

/* Jungiklis (perkelta pažodžiai iš roof-estimator) */
body:not(.dark) .scope-toggle-slider { background: #d1d5db; }
body:not(.dark) .scope-toggle-slider::before { background: #ffffff; }
body:not(.dark) .scope-toggle input:checked + .scope-toggle-slider { background: #7c3aed; }

/* F2 komponentai: eilučių fonas šviesioje temoje turi atsiskirti nuo kortelės */
body:not(.dark) .work-row,
body:not(.dark) .stage-row { background: #f9fafb; }

/* ── Šablono redakcijos juosta ir spausdinimo būsena (F3, NAUJA) ────────────── */

.template-banner {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.6rem 1.5rem;
  background: var(--bg-overlay);
  border-bottom: 2px solid var(--warning);
}

.template-banner-text {
  flex: 1;
  min-width: 260px;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.print-block-note {
  font-size: 0.78rem;
  line-height: 1.5;
}
.print-block-note.is-ready   { color: var(--success); }

.doc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

/* ── Dokumentų maketas (p-* klasės perkeltos iš roof-estimator) ─────────────── */

.p-page {
  width: 100%;
  color: #000;
  background: #fff;
  font-family: 'Segoe UI', Arial, sans-serif;
  font-size: 11pt;
  line-height: 1.45;
}

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

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

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

.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-empty {
  color: #999;
  font-style: italic;
  font-size: 9pt;
}

.p-vat-summary {
  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;
}

/* ── Sutarties dokumento specifika (NAUJA) ──────────────────────────────────── */

.p-doc-head {
  text-align: center;
  margin-bottom: 12pt;
}

.p-doc-title {
  font-size: 14pt;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.p-doc-meta {
  font-size: 9.5pt;
  color: #444;
  margin-top: 2pt;
}

.p-parties {
  font-size: 10pt;
  line-height: 1.6;
  margin-bottom: 6pt;
}
.p-parties p { margin-bottom: 3pt; }

.p-party-role { font-weight: 700; }

/* Antraštė niekada nelieka viena puslapio apačioje */
.p-section {
  break-inside: auto;
  page-break-inside: auto;
}

.p-section-title {
  break-after: avoid;
  page-break-after: avoid;
}

.p-clause {
  font-size: 10pt;
  margin: 3pt 0;
  text-align: justify;
  break-inside: avoid;
  page-break-inside: avoid;
}

.p-clause-no {
  font-weight: 700;
  margin-right: 3pt;
}

.p-clause--plain { font-style: italic; }

.p-body-text {
  font-size: 10pt;
  line-height: 1.6;
  margin: 6pt 0;
  white-space: normal;
}

/* Aktų pastabų ir pildymo vietos */
.p-check-block {
  margin: 8pt 0;
  break-inside: avoid;
  page-break-inside: avoid;
}

.p-check-line {
  font-size: 10pt;
  margin: 3pt 0;
}

.p-fill-line {
  border-bottom: 0.5pt solid #999;
  height: 14pt;
  margin: 2pt 0;
}

/* Parašų blokas NIEKADA nelaužomas per du puslapius */
.p-sign-block {
  display: flex;
  gap: 24pt;
  margin-top: 18pt;
  break-inside: avoid;
  page-break-inside: avoid;
}

.p-sign-col { flex: 1; }

.p-sign-role {
  font-size: 9pt;
  font-weight: 700;
  letter-spacing: 0.06em;
  margin-bottom: 3pt;
}

.p-sign-name {
  font-size: 10pt;
  margin-bottom: 18pt;
}

.p-sign-rule {
  border-bottom: 0.5pt solid #000;
  margin-bottom: 3pt;
}

.p-sign-hint {
  font-size: 8.5pt;
  color: #555;
}

.p-legal-note {
  font-size: 8.5pt;
  color: #555;
  border-top: 0.5pt solid #ccc;
  padding-top: 6pt;
  margin-top: 12pt;
  font-style: italic;
}

/* ── Peržiūros modalas ──────────────────────────────────────────────────────── */

#preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  background: #181825;
}

#preview-overlay.hidden {
  display: none;
}

#preview-toolbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: #181825;
  border-bottom: 1px solid #313244;
}

#preview-title {
  flex: 1;
  color: #cdd6f4;
  font-size: 0.9rem;
  font-weight: 600;
}

#preview-actions {
  display: flex;
  gap: 0.5rem;
}

#preview-close,
#preview-save-doc {
  background: #313244;
  border: 1px solid #45475a;
  border-radius: 6px;
  color: #cdd6f4;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
}

#preview-close:hover,
#preview-save-doc:hover {
  background: #45475a;
}

/* Neaktyvus išsaugojimas (neužpildyti laukai / nepatvirtinta šablono redakcija) */
#preview-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#preview-save {
  background: #16a34a;
  border: 1px solid #16a34a;
  border-radius: 6px;
  color: #fff;
  padding: 0.35rem 0.9rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
}

#preview-save:hover {
  background: #15803d;
}

#preview-body {
  flex: 1;
  overflow-y: auto;
  background: #313244;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

#preview-body .p-page {
  width: 100%;
  max-width: 210mm;
  padding: 18mm 16mm;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

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

@media (max-width: 640px) {

  /* Ilgas pavadinimas turi tilpti tarp „Grįžti" ir temos mygtuko */
  header h1 {
    font-size: 0.7rem;
    letter-spacing: 0.03em;
  }

  /* Kompaktiška žingsnių juosta — tik rutuliukai, be tekstinių etikečių */
  .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;
  }

  /* Didesni tap targets navigacijos mygtukams */
  #wizard-nav-bar {
    padding: 0.6rem 1rem;
  }

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

  .wizard-form-section--wide {
    max-width: 100%;
  }

  .wizard-step-form {
    padding: 1.25rem 1rem;
  }

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

  /* F2: laukai ir eilutės vienu stulpeliu, sekcijos su mažesniu paraštėmis */
  .field-grid {
    grid-template-columns: 1fr;
  }

  .work-row-grid {
    grid-template-columns: 1fr 1fr;
  }

  .form-section {
    padding: 0.9rem 1rem;
  }

  .notice-bar {
    padding: 0.55rem 1rem;
  }

  /* Žingsnis 5: dokumentų sąrašas virš peržiūros, ne šalia */
  .wizard-step-split {
    flex-direction: column;
    overflow-y: auto;
  }

  .docs-column {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-y: visible;
    flex-shrink: 0;
  }
}

/* ── @media print ───────────────────────────────────────────────────────────────
   Bazė: ekrano UI paslepiamas, spausdinama tik #print-area.
   Dokumentų p-* klasės atsiras F3 etape. */

@media print {
  #app { display: none !important; }
  #preview-overlay { display: none !important; }
  #print-area { display: block !important; }

  @page {
    size: A4 portrait;
    margin: 15mm;
  }

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

  /* Spausdinant lapo paraštes duoda @page, todėl vidinių nebereikia */
  #print-area .p-page {
    padding: 0;
    margin: 0;
    box-shadow: none;
  }

  /* Lentelės antraštė kartojasi kiekviename puslapyje, eilutės nelūžta */
  .p-table thead { display: table-header-group; }
  .p-table tfoot { display: table-footer-group; }
  .p-table tr    { break-inside: avoid; page-break-inside: avoid; }

  /* Antraštės nekabo puslapio apačioje */
  .p-doc-title,
  .p-section-title { break-after: avoid; page-break-after: avoid; }

  /* Parašų ir pastabų blokai nedalomi */
  .p-sign-block,
  .p-check-block { break-inside: avoid; page-break-inside: avoid; }
}
