﻿:root {
  --accent: #f7941d;
  --accent-soft: rgba(247, 148, 29, 0.14);
  --page-bg: #eef1f5;
  --surface: #ffffff;
  --surface-muted: #f4f6f9;
  --form-bg: #f8f7f4;
  --border: #e2e6ec;
  --border-strong: #cbd2dc;
  --input-border: #d5d3cf;
  --text: #111827;
  --text-2: #4b5563;
  --muted: #6b7280;
  --success: #4caf7d;
  --danger: #e05252;
  --warning: #c47a12;
  --sidebar-w: 300px;
  --section-w: 900px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--page-bg);
  font-family: "DM Sans", Inter, Arial, sans-serif;
  letter-spacing: 0;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 76px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  padding: 16px 22px;
  border-right: 1px solid var(--input-border);
  background: #fff;
}

.brand img {
  display: block;
  width: 188px;
  max-width: 100%;
  height: auto;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 28px;
}

.title-block h1 {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 760;
  line-height: 1.2;
}

.title-block p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.progress-wrap {
  min-width: 250px;
  max-width: 420px;
  flex: 1;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  color: var(--text-2);
  font-size: 0.83rem;
  font-weight: 650;
}

.progress-track {
  height: 8px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 160ms ease;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: calc(100vh - 76px);
}

aside {
  position: sticky;
  top: 76px;
  height: calc(100vh - 76px);
  overflow: auto;
  background: var(--surface);
  border-right: 1px solid var(--input-border);
  box-shadow: 8px 0 32px rgba(17, 24, 39, 0.08), 2px 0 12px rgba(17, 24, 39, 0.05);
  padding: 18px 14px 24px;
}

.nav-label {
  padding: 0 10px 12px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
  text-transform: uppercase;
}

.step-link {
  width: 100%;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 50px;
  margin: 0 0 5px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  text-align: left;
  cursor: pointer;
}

.step-link:hover,
.step-link.active {
  background: var(--accent-soft);
  border-color: rgba(247, 148, 29, 0.34);
  color: var(--text);
}

.step-num {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
}

.step-link.active .step-num {
  color: var(--text);
}

.step-title {
  font-size: 0.88rem;
  font-weight: 730;
  line-height: 1.25;
}

.step-tag {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
}

main {
  padding: 26px 28px 80px;
}

.form-stage {
  max-width: var(--section-w);
  margin: 0 auto;
}

.section {
  display: none;
  animation: fade 140ms ease;
}

.section.active { display: block; }

@keyframes fade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-head {
  margin-bottom: 18px;
  padding: 22px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.section-kicker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 760;
  text-transform: uppercase;
}

.section h2 {
  margin: 0;
  font-size: clamp(1.55rem, 4vw, 2.25rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.section-head p {
  max-width: 68ch;
  margin: 10px 0 0;
  color: var(--text-2);
  line-height: 1.55;
}

.tag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 26px;
  padding: 4px 9px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text-2);
  font-size: 0.72rem;
  font-weight: 760;
  text-transform: none;
  white-space: nowrap;
}

.tag.site { border-color: rgba(76, 175, 125, 0.38); background: rgba(76, 175, 125, 0.12); color: #23734d; }
.tag.later { border-color: rgba(17, 24, 39, 0.14); background: #fff; color: var(--muted); }
.tag.client { border-color: rgba(247, 148, 29, 0.38); background: var(--accent-soft); color: #8a4d07; }
.tag.risk { border-color: rgba(224, 82, 82, 0.32); background: rgba(224, 82, 82, 0.1); color: #9f3030; }

.subsection {
  margin-bottom: 16px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.subsection h3 {
  margin: 0 0 14px;
  font-size: 1.02rem;
}

.subsection > p {
  margin: -5px 0 14px;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.92rem;
}

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

.field-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field {
  min-width: 0;
}

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

label {
  display: block;
  margin: 0 0 6px;
  color: var(--text-2);
  font-size: 0.84rem;
  font-weight: 720;
  line-height: 1.35;
}

.required {
  color: var(--accent);
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 11px;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  background: var(--form-bg);
  color: var(--text);
  outline: none;
}

textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 2px;
}

.choice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  background: var(--form-bg);
  color: var(--text-2);
  font-size: 0.86rem;
  font-weight: 650;
  cursor: pointer;
}

.choice input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--accent);
}

.notice {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid rgba(247, 148, 29, 0.38);
  border-radius: 6px;
  background: var(--accent-soft);
  color: #764306;
  line-height: 1.45;
  font-size: 0.9rem;
}

.notice.danger {
  border-color: rgba(224, 82, 82, 0.28);
  background: rgba(224, 82, 82, 0.09);
  color: #8b2a2a;
}

.repeatable {
  display: grid;
  gap: 12px;
}

.repeat-item {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

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

.repeat-head strong { font-size: 0.9rem; }

.mini-btn,
.ghost-btn,
.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 9px 13px;
  border-radius: 4px;
  border: 1px solid rgba(247, 148, 29, 0.45);
  background: var(--surface-muted);
  color: var(--accent);
  font-weight: 760;
  cursor: pointer;
}

.primary-btn {
  min-height: 44px;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.ghost-btn {
  color: var(--text-2);
  border-color: var(--border-strong);
  background: #fff;
}

.mini-btn {
  min-height: 32px;
  padding: 7px 10px;
  font-size: 0.8rem;
}

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

.photo-slot {
  position: relative;
  display: grid;
  gap: 8px;
  min-height: 124px;
  padding: 13px;
  border: 1px dashed var(--border-strong);
  border-radius: 6px;
  background: #fff;
}

.photo-slot strong {
  font-size: 0.9rem;
  line-height: 1.25;
}

.photo-slot span {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.photo-slot input {
  min-height: 38px;
  padding: 7px;
  background: var(--surface-muted);
}

.photo-slot.complete {
  border-style: solid;
  border-color: rgba(76, 175, 125, 0.52);
  background: rgba(76, 175, 125, 0.08);
}

.doc-table,
.summary-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-size: 0.88rem;
}

.doc-table th,
.doc-table td,
.summary-table th,
.summary-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.doc-table th,
.summary-table th {
  background: var(--surface-muted);
  color: var(--text-2);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.doc-table tr:last-child td,
.summary-table tr:last-child td { border-bottom: 0; }

.doc-table select,
.doc-table input {
  min-height: 36px;
  padding: 7px 8px;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  max-width: var(--section-w);
  margin: 24px auto 0;
  padding: 14px 0 0;
  background: linear-gradient(to top, var(--page-bg) 72%, rgba(238, 241, 245, 0));
}

.hidden { display: none !important; }

.boot-error {
  position: fixed;
  top: 88px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  max-width: min(560px, calc(100vw - 32px));
  padding: 14px 18px;
  border: 1px solid rgba(224, 82, 82, 0.45);
  border-radius: 8px;
  background: #fff5f5;
  color: #8b2a2a;
  font-size: 0.92rem;
  line-height: 1.45;
  box-shadow: 0 12px 32px rgba(17, 24, 39, 0.14);
}

.validation-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.validation-list li {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-2);
}

.warning-item {
  margin-bottom: 8px;
}

.warning-go {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(224, 82, 82, 0.35);
  border-radius: 6px;
  background: rgba(224, 82, 82, 0.08);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.warning-go strong {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 4px;
  color: #9f3030;
}

.warning-go span {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
}

.warning-go:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.warning-advisory {
  padding: 9px 10px;
  border: 1px solid rgba(247, 148, 29, 0.38);
  border-radius: 4px;
  background: var(--accent-soft);
  color: #764306;
  line-height: 1.45;
  font-size: 0.88rem;
}

.warning-ok {
  padding: 9px 10px;
  border: 1px solid rgba(76, 175, 125, 0.38);
  border-radius: 4px;
  background: rgba(76, 175, 125, 0.1);
  color: #23734d;
  font-size: 0.88rem;
}

.field-invalid {
  border-radius: 6px;
  outline: 2px solid rgba(224, 82, 82, 0.55);
  outline-offset: 2px;
  animation: field-pulse 1.2s ease 2;
}

.photo-slot-invalid {
  border-color: rgba(224, 82, 82, 0.75) !important;
  background: rgba(224, 82, 82, 0.08) !important;
  animation: field-pulse 1.2s ease 2;
}

@keyframes field-pulse {
  0%, 100% { outline-color: rgba(224, 82, 82, 0.55); }
  50% { outline-color: rgba(247, 148, 29, 0.85); }
}

@media (max-width: 980px) {
  :root { --sidebar-w: 1fr; }
  .topbar,
  .app-shell {
    display: block;
  }
  .brand {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }
  aside {
    position: relative;
    top: auto;
    height: auto;
    max-height: 280px;
  }
  main {
    padding: 20px 14px 70px;
  }
  .field-grid,
  .field-grid.three,
  .photo-grid {
    grid-template-columns: 1fr;
  }
  .sticky-actions {
    padding-left: 0;
    padding-right: 0;
  }
  .doc-table {
    min-width: 760px;
  }
  .table-scroll {
    overflow-x: auto;
  }
}

.topbar-tools {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-muted);
  border: 1px solid rgba(247, 148, 29, 0.45);
  border-radius: 4px;
  padding: 8px;
  min-width: 42px;
  min-height: 36px;
  color: var(--accent);
  cursor: pointer;
}

.theme-toggle .theme-toggle-icon {
  width: 22px;
  height: 22px;
  display: block;
}

.theme-toggle .theme-toggle-icon path,
.theme-toggle .theme-toggle-icon circle {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.25px;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 12px 20px;
  font-size: 0.88rem;
  color: var(--accent);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  z-index: 999;
  box-shadow: 0 8px 24px rgba(17, 24, 39, 0.12);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.toast.toast-success {
  border-color: rgba(76, 175, 125, 0.65);
  background: rgba(76, 175, 125, 0.12);
  color: #23734d;
  font-weight: 650;
}

.toast.toast-error {
  border-color: rgba(224, 82, 82, 0.55);
  background: rgba(224, 82, 82, 0.1);
  color: #9f3030;
  font-weight: 650;
}

.submit-loading {
  position: fixed;
  inset: 0;
  z-index: 1999;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(17, 24, 39, 0.5);
  backdrop-filter: blur(3px);
}

.submit-loading-card {
  width: min(440px, 100%);
  padding: 26px 24px 22px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 20px 48px rgba(17, 24, 39, 0.22);
}

.submit-loading-card h2 {
  margin: 0 0 8px;
  font-size: 1.2rem;
  color: var(--text);
}

.submit-loading-message {
  margin: 0 0 18px;
  color: var(--text-2);
  font-size: 0.92rem;
  line-height: 1.45;
}

.submit-loading-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--text-2);
  font-size: 0.83rem;
  font-weight: 650;
}

.submit-loading-track {
  height: 10px;
}

.submit-loading-bar {
  width: 0;
  transition: width 180ms ease;
  background: linear-gradient(90deg, var(--accent) 0%, #ffb347 100%);
}

.submit-success {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(17, 24, 39, 0.45);
  backdrop-filter: blur(3px);
}

.submit-success-card {
  width: min(480px, 100%);
  padding: 28px 26px 24px;
  border-radius: 10px;
  border: 1px solid rgba(76, 175, 125, 0.45);
  background: var(--surface);
  text-align: center;
  box-shadow: 0 20px 48px rgba(17, 24, 39, 0.22);
  animation: success-pop 220ms ease;
}

@keyframes success-pop {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.submit-success-icon {
  display: inline-grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 999px;
  background: rgba(76, 175, 125, 0.15);
  border: 2px solid var(--success);
  color: var(--success);
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1;
}

.submit-success-card h2 {
  margin: 0 0 10px;
  font-size: 1.35rem;
  color: var(--text);
}

.submit-success-card p {
  margin: 0 0 8px;
  color: var(--text-2);
  line-height: 1.5;
  font-size: 0.95rem;
}

.submit-success-meta {
  margin-bottom: 18px !important;
  font-size: 0.88rem;
  color: var(--muted);
}

.submit-success-card .primary-btn {
  width: 100%;
  margin-top: 8px;
}

#submitBtn:disabled {
  opacity: 0.72;
  cursor: wait;
}

[data-theme="dark"] {
  --page-bg: #0a0a0a;
  --form-bg: #0f0f0f;
  --input-border: #4a4a4a;
  --surface: #1a1a1a;
  --surface-muted: #2a2a2a;
  --border: #3a3a3a;
  --border-strong: #4a4a4a;
  --text: #f5f2ed;
  --text-2: #a8aeb8;
  --muted: #9ca3af;
  --accent-soft: rgba(247, 148, 29, 0.18);
}

[data-theme="dark"] .brand,
[data-theme="dark"] .repeat-item,
[data-theme="dark"] .photo-slot,
[data-theme="dark"] .validation-list li,
[data-theme="dark"] .doc-table,
[data-theme="dark"] .summary-table {
  background: var(--surface);
}

[data-theme="dark"] .ghost-btn {
  background: var(--surface-muted);
  color: var(--text-2);
}

[data-theme="dark"] .tag.later {
  background: var(--surface-muted);
}

[data-theme="dark"] .sticky-actions {
  background: linear-gradient(to top, var(--page-bg) 72%, rgba(10, 10, 10, 0));
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--page-bg); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
