:root {
  --color-primary: #0d6efd;
  --color-primary-dark: #0b5ed7;
  --color-danger: #dc3545;
  --color-bg: #f4f6f9;
  --color-card: #ffffff;
  --color-border: #dfe3e8;
  --color-text: #1f2937;
  --color-muted: #6b7280;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
}

/* ---------- Header ---------- */
.app-header {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--color-card);
  border-bottom: 1px solid var(--color-border);
  padding: 10px 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 160px; }
.brand-logo { height: 36px; width: auto; }
.brand-text { display: flex; flex-direction: column; }
.brand-title { font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 12px; color: var(--color-muted); }

.progress-wrap { flex: 1; display: flex; align-items: center; gap: 10px; }
.progress-bar {
  flex: 1;
  height: 8px;
  background: #e9ecef;
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--color-primary), #4dabf7);
  transition: width .25s ease;
}
.progress-label { font-size: 12px; color: var(--color-muted); white-space: nowrap; }

.icon-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--color-text);
  padding: 4px 8px;
}

/* ---------- Layout ---------- */
.app-body {
  display: flex;
  min-height: calc(100vh - 58px);
}

.sidebar {
  position: fixed;
  top: 0;
  left: -320px;
  width: 300px;
  height: 100%;
  background: var(--color-card);
  border-right: 1px solid var(--color-border);
  z-index: 40;
  transition: left .25s ease;
  overflow-y: auto;
}
.sidebar.open { left: 0; }
.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
  font-weight: 600;
}
.toc { padding: 8px 0; }
.toc-section-title {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--color-muted);
  padding: 10px 16px 4px;
  font-weight: 700;
}
.toc-list { list-style: none; margin: 0; padding: 0; }
.toc-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 8px 24px;
  font-size: 14px;
  cursor: pointer;
  border-left: 3px solid transparent;
}
.toc-item:hover { background: #f1f4f8; }
.toc-item.active {
  background: #e7f1ff;
  border-left-color: var(--color-primary);
  font-weight: 600;
}
.toc-status {
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #c9d0d9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #fff;
}
.toc-status.confirmed {
  border-color: #2e7d32;
  background: #2e7d32;
}
.toc-text { flex: 1; }

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 30;
}
.overlay.visible { display: block; }

.main-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 90px;
  width: 100%;
}

/* ---------- Step card ---------- */
.step-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 720px;
  width: 100%;
  box-shadow: 0 2px 6px rgba(0,0,0,.04);
}
.step-breadcrumb {
  font-size: 12px;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: .03em;
  margin-bottom: 6px;
}
.step-title {
  margin: 0 0 14px;
  font-size: 22px;
}
.step-body p { line-height: 1.5; }
.step-body ul { line-height: 1.6; padding-left: 20px; }
.step-body code {
  background: #f1f3f5;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 13px;
}

.warning-box {
  background: #fff8e1;
  border: 1px solid #ffe08a;
  border-radius: 8px;
  padding: 10px 14px;
  margin-top: 12px;
  font-size: 14px;
}

.radio-group { display: flex; gap: 20px; margin: 12px 0; }
.radio-option { display: flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 500; }

.reveal-block {
  background: #f8f9fb;
  border: 1px dashed var(--color-border);
  border-radius: 8px;
  padding: 10px 16px;
  margin-top: 8px;
}

.step-fields {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-top: 1px solid var(--color-border);
  padding-top: 18px;
}
.field-group { display: flex; flex-direction: column; gap: 4px; }
.field-group label { font-size: 13px; font-weight: 600; color: var(--color-muted); }
.field-group input, .field-group select, .field-group textarea {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
}
.field-group textarea { resize: vertical; }

.field-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  cursor: pointer;
}
.field-checkbox input { width: 18px; height: 18px; }

/* ---------- Photos ---------- */
.photo-section {
  margin-top: 20px;
  border-top: 1px solid var(--color-border);
  padding-top: 16px;
}
.photo-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-weight: 700;
  font-size: 13px;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.photo-section-header .btn-sm {
  text-transform: none;
  font-size: 13px;
  padding: 6px 12px;
  letter-spacing: normal;
}
.photo-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.photo-empty { font-size: 13px; color: var(--color-muted); margin: 0; }
.photo-thumb {
  position: relative;
  width: 100px;
  height: 100px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--color-border);
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,.6);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

/* ---------- Confirm bar ---------- */
.confirm-bar {
  margin-top: 20px;
  border: 2px solid var(--color-border);
  border-radius: 10px;
  padding: 14px 18px;
  background: #f8f9fb;
  transition: background .2s ease, border-color .2s ease;
}
.confirm-bar.is-confirmed {
  background: #e9f7ec;
  border-color: #2e7d32;
}
.confirm-checkbox {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
}
.confirm-checkbox input {
  width: 22px;
  height: 22px;
  accent-color: #2e7d32;
  cursor: pointer;
}
.confirm-icon {
  color: #2e7d32;
  font-size: 18px;
  font-weight: 700;
  min-width: 16px;
}
.confirm-label { color: var(--color-text); }
.confirm-bar.is-confirmed .confirm-label { color: #2e7d32; }

/* ---------- Footer nav ---------- */
.nav-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--color-card);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  z-index: 15;
}
.step-counter { font-size: 13px; color: var(--color-muted); }

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--color-primary-dark); }
.btn-secondary { background: #e9ecef; color: var(--color-text); }
.btn-danger { background: var(--color-danger); color: #fff; }

/* ---------- Summary ---------- */
.summary-counter {
  font-weight: 700;
  font-size: 14px;
  padding: 8px 14px;
  background: #eef2f7;
  border-radius: 8px;
  display: inline-block;
}
.summary-container { margin-top: 18px; display: flex; flex-direction: column; gap: 14px; }
.summary-item {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 10px 14px;
  background: #fafbfc;
}
.summary-item.is-confirmed { border-color: #2e7d32; background: #f3faf4; }
.summary-item-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13px; margin-bottom: 6px; }
.summary-status {
  flex: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #c9d0d9;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #fff;
}
.summary-status.confirmed { border-color: #2e7d32; background: #2e7d32; }
.summary-field { font-size: 13px; color: var(--color-text); }
.summary-field span { color: var(--color-muted); font-weight: 600; }
.summary-photos { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.summary-photos img { width: 70px; height: 70px; object-fit: cover; border-radius: 6px; border: 1px solid var(--color-border); }

.final-actions { display: flex; gap: 12px; margin-top: 20px; }

/* ---------- Print ---------- */
.print-area { display: none; }

@media print {
  .app-header, .app-body, .overlay { display: none !important; }

  html, body {
    height: auto !important;
    overflow: visible !important;
    background: #fff !important;
  }

  .print-area {
    display: block !important;
    position: static;
    width: 100%;
    padding: 0;
  }
  .print-logo { height: 80px; margin-bottom: 8px; }
  .print-general { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
  .print-general td { padding: 4px 6px; font-size: 13px; }
  .print-fields { padding-left: 18px; margin: 4px 0 12px; }
  .print-fields li { font-size: 13px; }
  .print-photos { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
  .print-photos img { width: 110px; height: auto; border: 1px solid #ccc; }
  h1 { font-size: 20px; }
  h2 { font-size: 16px; margin-top: 18px; border-bottom: 1px solid #ccc; padding-bottom: 4px; break-after: avoid; }
  h3 { font-size: 14px; margin-bottom: 4px; break-after: avoid; }
  h3, .print-fields, .print-photos { break-inside: avoid; }
}

/* ---------- Responsive ---------- */
@media (min-width: 992px) {
  .sidebar { position: sticky; left: 0; top: 58px; height: calc(100vh - 58px); }
  .sidebar-header { display: none; }
  .overlay { display: none !important; }
  #menuToggle { display: none; }
}
