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

:root {
  --bg: #f0f2f5;
  --card: #ffffff;
  --primary: #1a3a5c;
  --primary-light: #2c5f8a;
  --accent: #c8a45a;
  --accent-glow: #e8c96a;
  --text: #1a1a1a;
  --text-muted: #666;
  --border: #dde1e6;
  --success: #2ecc71;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.08);
}

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}
html { overflow-x: hidden; }

/* === PROGRESS BAR === */
.progress-bar {
  position: sticky; top: 0; z-index: 100;
  background: var(--primary);
  padding: 12px 20px 8px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}
.progress-track {
  width: 100%; height: 3px;
  background: rgba(255,255,255,0.15);
  border-radius: 4px; margin-bottom: 10px;
}
.progress-fill {
  height: 100%; width: 25%;
  background: linear-gradient(90deg, var(--accent), var(--accent-glow));
  border-radius: 4px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.steps {
  display: flex; justify-content: center; gap: 32px;
}
.step {
  display: flex; flex-direction: column; align-items: center;
  opacity: 0.4; transition: all 0.3s;
}
.step.active { opacity: 1; }
.step.done { opacity: 0.7; }
.step span {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff;
  border: 2px solid rgba(255,255,255,0.3);
  transition: all 0.3s;
}
.step.active span {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(200,164,90,0.5);
}
.step.done span {
  background: var(--success);
  border-color: var(--success);
}
.step small { color: rgba(255,255,255,0.7); font-size: 10px; margin-top: 3px; }
.step.active small { color: #fff; }

/* === HERO === */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, #0d2137 100%);
  color: #fff; text-align: center;
  padding: 36px 20px 28px;
  position: relative; overflow: hidden;
}
.hero::after {
  content: ''; position: absolute;
  top: 50%; left: 50%; width: 400px; height: 400px;
  transform: translate(-50%, -50%) rotate(-15deg);
  background: url('assets/logo_rms.png') center/contain no-repeat;
  opacity: 0.04; pointer-events: none;
}
.hero-inner { position: relative; z-index: 1; }
.logo {
  font-size: 28px; font-weight: 300; letter-spacing: 6px;
  color: var(--accent); margin-bottom: 8px;
}
.logo span { font-weight: 700; }
.hero h1 {
  font-family: 'EB Garamond', serif;
  font-size: 26px; font-weight: 600; margin-bottom: 4px;
}
.subtitle {
  font-size: 13px; color: rgba(255,255,255,0.65);
  font-weight: 300; letter-spacing: 0.5px;
}

/* === CLIENT TYPE TOGGLE === */
.client-type-toggle {
  display: flex; gap: 8px; margin-bottom: 18px;
}
.toggle-btn {
  flex: 1; padding: 10px 16px;
  font-family: 'Inter', sans-serif;
  font-size: 13px; font-weight: 600;
  border: 2px solid var(--border); border-radius: 8px;
  background: #fafbfc; color: var(--text-muted);
  cursor: pointer; transition: all 0.25s;
}
.toggle-btn.active {
  border-color: var(--primary); background: rgba(26,58,92,0.06);
  color: var(--primary);
}
.toggle-btn:hover:not(.active) { border-color: #bbb; }
.hidden { display: none !important; }
.field-note {
  font-size: 11px; color: var(--text-muted);
  margin-top: 14px; padding: 8px 12px;
  background: #f8f9fa; border-radius: 6px;
  border-left: 3px solid var(--accent);
}

/* === PERSON BLOCKS === */
.person-block {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 20px; margin-bottom: 14px;
  background: #fafbfc;
  transition: all 0.3s;
}
.person-block:hover { border-color: #ccc; }
.person-header {
  font-size: 14px; font-weight: 700;
  color: var(--primary); margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
}
.person-badge {
  font-size: 10px; font-weight: 600;
  padding: 2px 8px; border-radius: 4px;
  background: rgba(200,164,90,0.15); color: var(--accent);
}
.person-badge.primary {
  background: var(--primary); color: #fff;
}
.person-count-row {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 18px; padding: 12px 16px;
  background: #f8f9fa; border-radius: 8px;
  border: 1px solid var(--border);
}
.person-count-row label {
  font-size: 13px; font-weight: 600; color: var(--text);
}
.person-count-btns { display: flex; gap: 6px; }
.count-btn {
  width: 36px; height: 36px; border-radius: 8px;
  border: 2px solid var(--border); background: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 15px; font-weight: 700;
  color: var(--text-muted); cursor: pointer;
  transition: all 0.2s;
}
.count-btn.active {
  border-color: var(--primary); background: var(--primary);
  color: #fff;
}
.count-btn:hover:not(.active) { border-color: #aaa; }
.checkbox-label {
  display: flex !important; align-items: center; gap: 8px;
  font-size: 12px !important; font-weight: 500 !important;
  color: var(--text-muted) !important;
  cursor: pointer; text-transform: none !important;
  letter-spacing: 0 !important;
}
.checkbox-label input[type="checkbox"] {
  accent-color: var(--primary); width: 16px; height: 16px;
}

/* === CONTAINER === */
.container {
  max-width: 720px; margin: -16px auto 40px;
  padding: 0 16px; position: relative; z-index: 2;
}

/* === CARD === */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.card h2 {
  font-size: 20px; font-weight: 700;
  color: var(--primary); margin-bottom: 4px;
}
.card h2 .num {
  display: inline-block;
  color: var(--accent); font-size: 14px; font-weight: 600;
  background: rgba(200,164,90,0.1);
  width: 32px; height: 32px; border-radius: 8px;
  text-align: center; line-height: 32px;
  margin-right: 8px; vertical-align: middle;
}
.desc { color: var(--text-muted); font-size: 13px; margin-bottom: 20px; }

/* === STEP VISIBILITY === */
.step-section { display: none; }
.step-section.active {
  display: block;
  animation: fadeIn 0.4s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === FORM === */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.field { display: flex; flex-direction: column; }
.field.full { grid-column: 1 / -1; }
.field label {
  font-size: 12px; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.field input, .field select, .field textarea {
  font-family: 'Inter', sans-serif;
  font-size: 14px; padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px; background: #fafbfc;
  color: var(--text);
  transition: all 0.2s;
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary-light);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(44,95,138,0.1);
}
.field textarea { resize: vertical; }
.field input.error, .field select.error, .field textarea.error {
  border-color: #e74c3c !important;
  background: #fef5f5 !important;
  box-shadow: 0 0 0 3px rgba(231,76,60,0.12) !important;
}

/* === BUTTONS === */
.nav-buttons {
  display: flex; justify-content: space-between;
  margin-top: 24px; gap: 12px;
}
.btn {
  font-family: 'Inter', sans-serif;
  font-size: 14px; font-weight: 600;
  padding: 12px 28px;
  border-radius: 8px; border: none;
  cursor: pointer; transition: all 0.25s;
  letter-spacing: 0.3px;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(26,58,92,0.35);
}
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover { background: #f5f5f5; }
.btn-sign {
  background: linear-gradient(135deg, var(--accent), #b8943a);
  color: #fff; font-size: 16px;
  padding: 14px 36px;
}
.btn-sign:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(200,164,90,0.45);
}
.btn-sign:disabled {
  opacity: 0.5; cursor: not-allowed;
  transform: none; box-shadow: none;
}

/* === CONTRACT PREVIEW === */
.contract-preview {
  font-family: 'EB Garamond', serif;
  font-size: 10px; line-height: 1.4;
  background: #fff; border: 1px solid #ddd;
  padding: 24px; border-radius: 8px;
  max-height: 500px; overflow-y: auto;
  margin-bottom: 16px;
  color: #222;
}
.contract-preview h3 {
  text-align: center; font-size: 12px;
  margin: 10px 0 4px; color: var(--primary);
}
.contract-preview .c-header {
  text-align: center; border-bottom: 1.5px solid var(--primary);
  padding-bottom: 8px; margin-bottom: 10px;
}
.contract-preview .c-firm { font-size: 14px; font-weight: 700; letter-spacing: 1px; color: var(--primary); }
.contract-preview .c-details { font-size: 8px; color: #777; margin-top: 2px; }
.contract-preview .c-title { font-size: 16px; font-weight: 700; margin-top: 8px; color: var(--primary); }
.contract-preview .c-subtitle { font-size: 11px; color: #555; }
.contract-preview .c-data { background: #f8f6f0; padding: 4px 8px; border-radius: 4px; font-weight: 500; }
.contract-preview ol { padding-left: 16px; margin: 3px 0; }
.contract-preview li { margin-bottom: 2px; text-align: justify; }
.contract-preview p { text-align: justify; margin: 3px 0; }

/* === SIGNATURE === */
.sig-area {
  text-align: center; margin: 16px 0;
}
#sigCanvas {
  border: 2px dashed var(--border);
  border-radius: 8px; background: #fefefe;
  cursor: crosshair; max-width: 100%;
  touch-action: none;
}
.btn-clear {
  display: inline-block; margin-top: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 12px; color: var(--text-muted);
  background: none; border: 1px solid var(--border);
  padding: 5px 16px; border-radius: 6px;
  cursor: pointer; transition: all 0.2s;
}
.btn-clear:hover { background: #fafafa; color: #e74c3c; border-color: #e74c3c; }

/* === CONSENT === */
.consent {
  margin: 16px 0; display: flex; flex-direction: column; gap: 8px;
}
.consent label {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 12px; color: var(--text-muted);
  cursor: pointer; line-height: 1.4;
}
.consent input[type="checkbox"] {
  margin-top: 2px; accent-color: var(--primary);
  width: 16px; height: 16px; flex-shrink: 0;
}
.rodo-consent { margin-top: 16px; }
.rodo-box {
  max-height: 400px; overflow-y: auto;
  background: #fafbfc; border: 1px solid var(--border);
  border-radius: 8px; padding: 20px 24px;
  font-size: 12px; line-height: 1.6; color: #333;
}
.rodo-box h3 {
  font-size: 14px; color: var(--primary);
  margin-bottom: 10px; text-align: center;
}
.rodo-box ol { padding-left: 20px; }
.rodo-box li { margin-bottom: 6px; text-align: justify; }
.rodo-box ul { padding-left: 16px; margin: 4px 0; }
.rodo-box ul li { margin-bottom: 2px; }

/* === SUCCESS === */
.success-icon {
  width: 72px; height: 72px; border-radius: 50%;
  background: linear-gradient(135deg, var(--success), #27ae60);
  color: #fff; font-size: 36px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes popIn {
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}
#step6 { text-align: center; }
.success-actions { margin: 20px 0; }
.small-note { font-size: 11px; color: #aaa; margin-top: 12px; }
.email-summary {
  background: #f8f9fa; border-radius: 8px;
  padding: 14px 20px; margin: 16px auto;
  max-width: 400px; text-align: left;
}
.email-row {
  padding: 6px 0; font-size: 13px;
  display: flex; align-items: center; gap: 8px;
}
.email-row + .email-row { border-top: 1px solid #eee; }
.email-tag {
  font-size: 10px; background: var(--primary);
  color: #fff; padding: 2px 8px; border-radius: 4px;
  margin-left: auto; font-weight: 600;
}

/* === FOOTER === */
footer {
  text-align: center; padding: 20px;
  font-size: 11px; color: #999;
}

/* === SMS OTP === */
.sms-area { text-align: center; margin: 20px 0; }
.code-inputs {
  display: flex; justify-content: center; align-items: center; gap: 8px;
}
.code-digit {
  width: 48px; height: 56px; text-align: center;
  font-family: 'Inter', sans-serif;
  font-size: 24px; font-weight: 700;
  border: 2px solid var(--border); border-radius: 10px;
  background: #fafbfc; color: var(--primary);
  outline: none; transition: all 0.2s;
}
.code-digit:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(200,164,90,0.2);
  background: #fff;
}
.code-digit.filled { border-color: var(--primary-light); background: #f0f4f8; }
.code-dash { font-size: 20px; color: #ccc; margin: 0 2px; }
.sms-status {
  font-size: 12px; margin-top: 10px; color: var(--text-muted);
  min-height: 18px;
}
.sms-status.success { color: var(--success); font-weight: 600; }
.sms-status.error { color: #e74c3c; font-weight: 600; }

/* === TRUST/SALES DESCRIPTION BLOCKS === */
.data-trust-block {
  background: linear-gradient(135deg, #f0faf4 0%, #e8f5ee 100%);
  border: 1px solid #b8e6c8;
  border-left: 4px solid #27ae60;
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 20px;
  animation: fadeIn 0.4s ease;
}
.data-trust-block .trust-title {
  font-size: 14px;
  font-weight: 700;
  color: #1a6b3a;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.data-trust-block .trust-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.data-trust-block .trust-item {
  font-size: 12px;
  color: #2d5a3d;
  line-height: 1.5;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.data-trust-block .trust-item .ti-icon {
  flex-shrink: 0;
  font-size: 14px;
  margin-top: 1px;
}

/* === PESEL TRUST ELEMENTS === */
.pesel-label-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.pesel-help-btn {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid #a0b4c8;
  background: #f0f4f8;
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-family: 'Inter', sans-serif;
  line-height: 1;
  padding: 0;
}
.pesel-help-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  transform: scale(1.1);
}
.pesel-hint {
  font-size: 11px;
  color: #7a9a88;
  margin-top: 4px;
  font-style: italic;
}

/* PESEL Modal */
.pesel-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.3s ease;
}
.pesel-modal-overlay.active {
  display: flex;
}
.pesel-modal {
  background: #fff;
  border-radius: 16px;
  max-width: 520px;
  width: 100%;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  position: relative;
  max-height: 85vh;
  overflow-y: auto;
}
.pesel-modal .pm-close {
  position: absolute;
  top: 12px; right: 16px;
  background: none; border: none;
  font-size: 24px; color: #999;
  cursor: pointer;
  transition: color 0.2s;
}
.pesel-modal .pm-close:hover { color: #333; }
.pesel-modal h3 {
  font-size: 18px;
  color: var(--primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.pesel-modal .pm-section {
  margin-bottom: 16px;
  padding: 12px 14px;
  background: #f8f9fa;
  border-radius: 8px;
  border-left: 3px solid var(--primary);
}
.pesel-modal .pm-section h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}
.pesel-modal .pm-section p {
  font-size: 12px;
  color: #444;
  line-height: 1.6;
  text-align: left;
}
.pesel-modal .pm-highlight {
  background: linear-gradient(135deg, #f0faf4, #e8f5ee);
  border-left-color: #27ae60;
}
.pesel-modal .pm-footer {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #eee;
  font-size: 11px;
  color: #999;
  text-align: center;
}
.pesel-modal .pm-footer a {
  color: var(--primary);
  text-decoration: underline;
}

/* === RESPONSIVE === */
@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
  .card { padding: 20px; }
  .hero h1 { font-size: 20px; }
  .code-digit { width: 40px; height: 48px; font-size: 20px; }
  .steps { gap: 16px; }
  .nav-buttons { flex-direction: column; }
  .nav-buttons .btn { width: 100%; text-align: center; }
}
