:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #1d4ed8;
  --brand-dark: #1e40af;
  --ok: #15803d;
  --err: #b91c1c;
  --warn: #b45309;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

.wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: 0 16px;
}

.app-header {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  padding: 28px 0;
  margin-bottom: 24px;
}
.app-header h1 { margin: 0 0 4px; font-size: 1.6rem; }
.app-header .subtitle { margin: 0; opacity: 0.9; font-size: 0.95rem; }
.version-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  vertical-align: middle;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  padding: 2px 10px;
  margin-left: 8px;
  letter-spacing: 0.02em;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.card h2 {
  margin: 0 0 16px;
  font-size: 1.15rem;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: -6px 0 16px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr; }
}

.field { display: flex; flex-direction: column; margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field label {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink);
}
.req { color: var(--err); }
.sub-hint { font-size: 0.78rem; color: var(--muted); margin: -2px 0 6px; }

.inline-row { display: flex; gap: 10px; align-items: center; }
.inline-row input { flex: 1; }

.btn-secondary {
  background: #eff6ff;
  color: var(--brand-dark);
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 16px;
}
.btn-secondary:hover { background: #dbeafe; }
.btn-link {
  background: none;
  border: none;
  color: var(--err);
  font-size: 0.82rem;
  cursor: pointer;
  padding: 4px 6px;
  white-space: nowrap;
}
.btn-link:hover { text-decoration: underline; }

input[type="text"],
input[type="email"],
input[type="tel"],
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
}
textarea { resize: vertical; }

.field.invalid input,
.field.invalid textarea { border-color: var(--err); }

/* Yes/No questions */
.yesno-group { margin: 4px 0 16px; }
.yesno {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.yesno-label { font-size: 0.9rem; font-weight: 500; }
.yesno-options { display: flex; gap: 16px; }
.yesno-options label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  cursor: pointer;
}
.yesno.invalid .yesno-label { color: var(--err); }

/* Photo slots */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.photo-slot {
  border: 2px dashed var(--line);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: #f8fafc;
  position: relative;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.photo-slot:hover { border-color: var(--brand); background: #eff6ff; }
.photo-slot.dragover { border-color: var(--brand); background: #dbeafe; }
.photo-slot.filled { border-style: solid; border-color: var(--ok); background: #fff; }
.photo-slot.invalid { border-color: var(--err); }
.photo-slot .slot-title {
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 6px;
}
.photo-slot .slot-hint { font-size: 0.72rem; color: var(--muted); }
.photo-slot img.preview {
  max-width: 100%;
  max-height: 120px;
  border-radius: 6px;
  margin-bottom: 6px;
  object-fit: cover;
}
.photo-slot .remove-photo {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(15, 23, 42, 0.75);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
.photo-slot input[type="file"] { display: none; }
.photo-slot .status-pill {
  font-size: 0.7rem;
  margin-top: 4px;
  color: var(--muted);
}

/* Submit */
.submit-card { text-align: center; }
.btn-primary {
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 14px 28px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.progress-container { margin-top: 18px; }
.progress-track {
  background: var(--line);
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}
.progress-bar {
  background: var(--brand);
  height: 100%;
  width: 0%;
  transition: width 0.3s ease;
}
.progress-label { font-size: 0.85rem; color: var(--muted); margin: 8px 0 0; }

.status-log { margin-top: 14px; text-align: left; }
.status-log .log-line { font-size: 0.8rem; margin: 2px 0; }
.status-log .pass { color: var(--ok); }
.status-log .fail { color: var(--err); }
.status-log .info { color: var(--warn); }

.success-msg {
  margin-top: 18px;
  padding: 16px;
  background: #dcfce7;
  border: 1px solid #86efac;
  border-radius: 10px;
  color: var(--ok);
}

.hidden { display: none !important; }
