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

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --success-dark: #15803d;
  --danger: #dc2626;
  --warning: #d97706;
  --gray-50:  #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-400: #9ca3af;
  --gray-600: #4b5563;
  --gray-800: #1f2937;
  --radius: 14px;
  --shadow: 0 2px 8px rgba(0,0,0,0.10);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
header {
  background: var(--primary);
  color: white;
  padding: 20px 16px 14px;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
header h1 { font-size: 1.5rem; letter-spacing: -0.5px; }
#header-subtitle { font-size: 0.85rem; opacity: 0.8; margin-top: 2px; }

.step-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
  flex-wrap: wrap;
  padding: 0 8px;
}
.step-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
  transition: background 0.2s, transform 0.2s;
  cursor: pointer;
}
.step-dot.visited  { background: rgba(255,255,255,0.65); }
.step-dot.active   { background: white; transform: scale(1.4); }
.step-dot.complete { background: #86efac; }

/* ── Main ── */
main {
  flex: 1;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 16px 120px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.screen { width: 100%; }

/* ── Card ── */
.card {
  background: white;
  border-radius: var(--radius);
  padding: 22px 20px;
  box-shadow: var(--shadow);
}
.step-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--primary);
  margin-bottom: 6px;
}
.card-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 4px;
}
.card-hint {
  font-size: 0.88rem;
  color: var(--gray-400);
  margin-bottom: 18px;
}

.section-progress-bar {
  height: 4px;
  background: var(--gray-200);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 18px;
}
.section-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 99px;
  transition: width 0.3s ease;
  width: 0%;
}

/* ── Form fields ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field.full { grid-column: 1 / -1; }
.field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--gray-600);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field input {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s;
}
.field input:focus { border-color: var(--primary); }

/* ── Item rows ── */
.item-wrap {
  border-bottom: 1px solid var(--gray-100);
  padding-bottom: 4px;
  margin-bottom: 4px;
  animation: fadeIn 0.18s ease;
}
.item-wrap:last-child { border-bottom: none; }

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

.item-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
}
.item-label {
  flex: 1;
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--gray-800);
}
.status-btns { display: flex; gap: 6px; flex-shrink: 0; }
.status-btn {
  border: none;
  cursor: pointer;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 7px 11px;
  transition: all 0.15s;
  opacity: 0.35;
  white-space: nowrap;
}
.status-btn:hover  { opacity: 0.75; }
.status-btn.active { opacity: 1; }
.status-btn.ok   { background: #dcfce7; color: var(--success); }
.status-btn.ok.active   { background: var(--success); color: white; }
.status-btn.fail { background: #fee2e2; color: var(--danger); }
.status-btn.fail.active { background: var(--danger); color: white; }
.status-btn.na   { background: var(--gray-100); color: var(--gray-600); }
.status-btn.na.active   { background: var(--gray-400); color: white; }

/* ── Problems ── */
.problems-container {
  padding: 0 0 10px 8px;
  border-left: 3px solid #fee2e2;
  margin-left: 4px;
}
.problem-entry {
  background: var(--gray-50);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.problem-header {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--danger);
  margin-bottom: 6px;
}
.item-note {
  width: 100%;
  font-size: 0.85rem;
  padding: 8px 10px;
  border: 1.5px solid var(--gray-200);
  border-radius: 7px;
  resize: none;
  outline: none;
  font-family: inherit;
  color: var(--gray-800);
  background: white;
}
.item-note:focus { border-color: var(--warning); }

.btn-add-problem {
  background: none;
  border: 1.5px dashed var(--gray-400);
  color: var(--gray-600);
  border-radius: 7px;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  margin-top: 4px;
  transition: border-color 0.15s, color 0.15s;
}
.btn-add-problem:hover { border-color: var(--danger); color: var(--danger); }

/* ── Photos ── */
.photo-section {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.btn-photo {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: white;
  border: 1.5px solid var(--gray-200);
  border-radius: 7px;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--gray-600);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn-photo:hover { border-color: var(--primary); color: var(--primary); }

.photo-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.thumb-wrap {
  position: relative;
  display: inline-block;
}
.photo-thumb {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 6px;
  border: 1.5px solid var(--gray-200);
  display: block;
}
.thumb-del {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--danger);
  color: white;
  border: none;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 12px;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
  padding: 0;
  font-weight: 700;
}

/* ── Step navigation ── */
.step-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: white;
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  position: sticky;
  bottom: 16px;
}
#nav-center { flex: 1; }
.section-select {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-800);
  background: var(--gray-50);
  outline: none;
  cursor: pointer;
  appearance: auto;
}
.section-select:focus { border-color: var(--primary); }

/* ── Buttons ── */
.btn {
  padding: 11px 20px;
  border: none;
  border-radius: 9px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
  white-space: nowrap;
}
.btn:active   { transform: scale(0.97); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-primary   { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled)   { background: var(--primary-dark); }
.btn-success   { background: var(--success); color: white; }
.btn-success:hover:not(:disabled)   { background: var(--success-dark); }
.btn-secondary { background: var(--gray-200); color: var(--gray-800); }
.btn-secondary:hover:not(:disabled) { background: var(--gray-400); color: white; }
.btn-outline   { background: white; color: var(--primary); border: 2px solid var(--primary); }
.btn-outline:hover:not(:disabled)   { background: var(--primary); color: white; }

/* ── Final actions ── */
.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.actions .btn { flex: 1; min-width: 120px; text-align: center; }

/* ── Summary ── */
.summary-score {
  text-align: center;
  padding: 20px 0 16px;
}
.score-value { font-size: 3rem; font-weight: 800; line-height: 1; }
.score-label {
  font-size: 1rem;
  font-weight: 700;
  margin-top: 6px;
  padding: 5px 20px;
  border-radius: 99px;
  display: inline-block;
}
.score-meta { font-size: 0.82rem; color: var(--gray-400); margin-top: 8px; }
.score-manual { font-size: 0.78rem; color: var(--danger); margin-top: 4px; font-style: italic; }

/* Approval buttons */
.approval-btns {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  padding: 14px 0;
  border-top: 1px solid var(--gray-200);
  border-bottom: 1px solid var(--gray-200);
  margin-bottom: 20px;
}
.btn-approve {
  padding: 10px 24px;
  border: 2px solid var(--success);
  border-radius: 9px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  background: white;
  color: var(--success);
  transition: all 0.15s;
}
.btn-approve:hover, .btn-approve.active { background: var(--success); color: white; }
.btn-reject {
  padding: 10px 24px;
  border: 2px solid var(--danger);
  border-radius: 9px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  background: white;
  color: var(--danger);
  transition: all 0.15s;
}
.btn-reject:hover, .btn-reject.active { background: var(--danger); color: white; }
.approval-auto-hint { font-size: 0.78rem; color: var(--gray-400); }

.summary-body { margin-top: 4px; }
.summary-section { margin-bottom: 16px; }
.summary-section-title {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-600);
  margin-bottom: 6px;
}
.summary-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.88rem;
  padding: 4px 0;
  line-height: 1.4;
}
.dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.dot-ok   { background: var(--success); }
.dot-fail { background: var(--danger); }
.dot-na   { background: var(--gray-400); }

/* ── Save button ── */
.btn-save { background: #7c3aed; color: white; }
.btn-save:hover:not(:disabled) { background: #6d28d9; }
.btn-save.saved { background: var(--success); }

/* ── History nav button ── */
.btn-history-nav {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  border-radius: 7px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-history-nav:hover { background: rgba(255,255,255,0.25); }
header { position: relative; }

/* ── History ── */
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.btn-sm { padding: 7px 14px; font-size: 0.82rem; }
.history-empty { color: var(--gray-400); font-size: 0.9rem; text-align: center; padding: 24px 0; }

.history-card {
  border: 1.5px solid var(--gray-200);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
  transition: border-color 0.15s;
}
.history-card:hover { border-color: var(--gray-400); }
.hc-main { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.hc-address { font-weight: 700; font-size: 0.95rem; }
.hc-meta { font-size: 0.8rem; color: var(--gray-400); margin-top: 2px; }
.hc-score { font-size: 1.6rem; font-weight: 800; flex-shrink: 0; }
.hc-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.hc-badge { font-size: 0.72rem; font-weight: 700; padding: 3px 10px; border-radius: 99px; }
.hc-actions { display: flex; gap: 8px; }
.btn-hc {
  border: none;
  border-radius: 6px;
  padding: 5px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-hc:hover { opacity: 0.8; }
.btn-hc-load { background: #f3e8ff; color: #7c3aed; }
.btn-hc-pdf  { background: #dbeafe; color: var(--primary); }
.btn-hc-del  { background: #fee2e2; color: var(--danger); }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 16px;
}
.modal {
  background: white;
  border-radius: var(--radius);
  padding: 28px 24px;
  width: 100%; max-width: 400px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}
.modal h3 { margin-bottom: 18px; font-size: 1.1rem; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.email-status { margin-top: 12px; font-size: 0.88rem; text-align: center; min-height: 18px; }
.email-status.ok    { color: var(--success); font-weight: 600; }
.email-status.error { color: var(--danger);  font-weight: 600; }

/* ── Responsive ── */
@media (max-width: 480px) {
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: 1; }
  .item-row { flex-wrap: wrap; }
  .item-label { width: 100%; }
  .status-btns { width: 100%; justify-content: space-between; }
  .status-btn { flex: 1; text-align: center; padding: 9px 4px; font-size: 0.75rem; }
  .step-nav { border-radius: 0; position: fixed; bottom: 0; left: 0; right: 0; border-top: 1px solid var(--gray-200); }
  .actions { flex-direction: column; }
  .btn { width: 100%; text-align: center; }
  .approval-btns { flex-direction: column; }
  .btn-approve, .btn-reject { width: 100%; text-align: center; }
}
