/* ── Reset & Variables ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy:       #1e3a5f;
  --navy-light: #2c5282;
  --gold:       #b8962e;
  --gold-light: #d4b04a;
  --bg:         #f2f1ee;
  --card:       #ffffff;
  --text:       #1a1a1a;
  --text-muted: #5a5a5a;
  --border:     #d4d0c8;
  --border-lt:  #e8e6e0;
  --error:      #b91c1c;
  --error-bg:   #fef2f2;
  --success:    #166534;
  --success-bg: #f0fdf4;
  --step-done:  #166534;
  --radius:     8px;
  --radius-lg:  12px;
  --shadow:     0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md:  0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.portal-header {
  background: var(--navy);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}
.header-logo {
  width: 40px; height: 40px;
  background: rgba(255,255,255,0.12);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #fff;
  letter-spacing: 0.04em; flex-shrink: 0;
}
.header-text h1 {
  font-size: 16px; font-weight: 600; color: #fff;
  letter-spacing: 0.01em;
}
.header-text p {
  font-size: 11px; color: rgba(255,255,255,0.65); margin-top: 1px;
}

/* ── Progress Bar ───────────────────────────────────────────────────────── */
.progress-wrap {
  background: #fff;
  border-bottom: 1px solid var(--border-lt);
  padding: 16px 24px;
  position: sticky; top: 0; z-index: 10;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.progress-steps {
  display: flex; align-items: center;
  max-width: 640px; margin: 0 auto;
}
.progress-step {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px;
  position: relative;
}
.progress-step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 13px; left: 50%; right: -50%;
  height: 1px; background: var(--border);
  z-index: 0;
}
.progress-step.done:not(:last-child)::after { background: var(--step-done); }
.step-dot {
  width: 26px; height: 26px; border-radius: 50%;
  border: 1.5px solid var(--border);
  background: #fff; color: var(--text-muted);
  font-size: 11px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  position: relative; z-index: 1;
  transition: all 0.2s;
}
.progress-step.active .step-dot {
  background: var(--navy); border-color: var(--navy);
  color: #fff;
}
.progress-step.done .step-dot {
  background: var(--step-done); border-color: var(--step-done);
  color: #fff; font-size: 13px;
}
.step-dot.done-dot::before { content: '✓'; font-size: 12px; }
.step-label {
  font-size: 10px; color: var(--text-muted);
  white-space: nowrap;
}
.progress-step.active .step-label { color: var(--navy); font-weight: 600; }
.progress-step.done .step-label  { color: var(--step-done); }

/* ── Main Layout ────────────────────────────────────────────────────────── */
.portal-main {
  max-width: 700px; margin: 32px auto; padding: 0 16px 60px;
}

/* ── Steps ──────────────────────────────────────────────────────────────── */
.step { display: none; }
.step.active { display: block; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.step-header {
  margin-bottom: 24px;
}
.step-eyebrow {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--gold); margin-bottom: 4px;
}
.step-title {
  font-size: 22px; font-weight: 600; color: var(--navy); line-height: 1.3;
}
.step-subtitle {
  font-size: 13px; color: var(--text-muted); margin-top: 4px;
}

/* ── Card ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border-lt);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card-section-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--navy);
  padding-bottom: 10px; margin-bottom: 18px;
  border-bottom: 1.5px solid var(--border-lt);
}

/* ── Step 1 — Client Type Cards ─────────────────────────────────────────── */
.type-cards {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  margin-top: 4px;
}
.type-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}
.type-card:hover { border-color: var(--navy-light); box-shadow: var(--shadow-md); }
.type-card.selected {
  border-color: var(--navy);
  border-width: 2px;
  background: #f0f4f9;
  box-shadow: var(--shadow-md);
}
.type-card-icon {
  font-size: 28px; margin-bottom: 12px; display: block;
}
.type-card h3 {
  font-size: 16px; font-weight: 600; color: var(--navy); margin-bottom: 4px;
}
.type-card p {
  font-size: 12px; color: var(--text-muted);
}
.type-card.selected h3 { color: var(--navy); }

/* ── Form Elements ──────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label {
  font-size: 12px; font-weight: 600; color: var(--navy);
  letter-spacing: 0.01em;
}
.form-group label .req { color: var(--error); margin-left: 2px; }
.form-group label .opt { color: var(--text-muted); font-weight: 400; margin-left: 4px; }

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--navy-light);
  box-shadow: 0 0 0 3px rgba(44, 82, 130, 0.12);
}
input.error, select.error, textarea.error {
  border-color: var(--error);
  background: var(--error-bg);
}
textarea { resize: vertical; min-height: 80px; }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235a5a5a' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.field-hint { font-size: 11px; color: var(--text-muted); }
.field-error { font-size: 11px; color: var(--error); display: none; }
.field-error.visible { display: block; }

/* ── Repeatable entries (directors / shareholders) ──────────────────────── */
.entries-container { display: flex; flex-direction: column; gap: 14px; }
.entry-card {
  border: 1px solid var(--border-lt);
  border-radius: var(--radius);
  padding: 16px 20px;
  background: #fafaf8;
  position: relative;
}
.entry-card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px;
}
.entry-card-header h4 {
  font-size: 13px; font-weight: 600; color: var(--navy-light);
}
.btn-remove-entry {
  background: none; border: none; cursor: pointer;
  font-size: 12px; color: var(--error); padding: 2px 6px;
  border-radius: 4px; transition: background 0.15s;
}
.btn-remove-entry:hover { background: var(--error-bg); }
.btn-add-entry {
  display: flex; align-items: center; gap: 6px;
  background: none;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 13px; font-weight: 500; color: var(--navy-light);
  cursor: pointer; width: 100%;
  transition: all 0.15s; margin-top: 8px;
}
.btn-add-entry:hover { border-color: var(--navy); background: #f0f4f9; }

/* Beneficial owner badges */
.bo-badge {
  display: inline-block;
  background: #fef3c7; border: 1px solid #f59e0b;
  color: #92400e; font-size: 10px; font-weight: 600;
  padding: 2px 8px; border-radius: 20px; margin-top: 8px;
}
.bo-summary {
  background: #fffbeb; border: 1px solid #f59e0b;
  border-radius: var(--radius); padding: 12px 16px;
  margin-top: 16px;
}
.bo-summary-title {
  font-size: 12px; font-weight: 700; color: #92400e; margin-bottom: 6px;
}
.bo-list { font-size: 12px; color: #78350f; list-style: none; }
.bo-list li { padding: 2px 0; }
.bo-list li::before { content: '✓  '; }

.upload-success {
  display: none;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 8px;
  width: 100%;
}
.upload-check-icon { font-size: 22px; }
.upload-fname {
  font-size: 13px; color: var(--success);
  font-weight: 500; word-break: break-all;
  max-width: 240px; text-align: center;
}
.btn-remove-file {
  background: none;
  border: 1px solid var(--error);
  color: var(--error);
  border-radius: 4px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}
.btn-remove-file:hover { background: var(--error-bg); }

/* ── File Upload ────────────────────────────────────────────────────────── */
.upload-group { margin-bottom: 16px; }
.upload-label {
  font-size: 12px; font-weight: 600; color: var(--navy);
  display: flex; align-items: center; gap: 6px; margin-bottom: 6px;
}
.badge-required {
  font-size: 9px; font-weight: 700; text-transform: uppercase;
  background: #fee2e2; color: var(--error);
  padding: 1px 5px; border-radius: 3px;
}
.badge-optional {
  font-size: 9px; font-weight: 600; text-transform: uppercase;
  background: var(--border-lt); color: var(--text-muted);
  padding: 1px 5px; border-radius: 3px;
}
.upload-zone {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  background: #fafaf8;
  position: relative;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--navy); background: #f0f4f9;
}
.upload-zone.has-file { border-color: var(--step-done); background: var(--success-bg); }
.upload-zone .upload-zone input[type="file"] { display: none; }
.upload-icon { font-size: 22px; margin-bottom: 4px; }
.upload-text { font-size: 12px; color: var(--text-muted); }
.upload-text strong { color: var(--navy); }
.upload-filename {
  font-size: 12px; color: var(--step-done); font-weight: 500;
  display: none; margin-top: 4px;
}
.upload-zone.has-file .upload-filename { display: block; }
.upload-zone.has-file .upload-prompt { display: none; }
.upload-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ── Signature Pad ──────────────────────────────────────────────────────── */
.signature-wrap {
  border: 1.5px solid var(--border); border-radius: var(--radius);
  background: #fff; overflow: hidden;
}
.signature-wrap canvas { display: block; width: 100%; height: 150px; cursor: crosshair; }
.signature-actions {
  display: flex; justify-content: flex-end; padding: 6px 10px;
  background: #fafaf8; border-top: 1px solid var(--border-lt);
}
.btn-clear-sig {
  font-size: 12px; color: var(--text-muted); background: none;
  border: 1px solid var(--border); border-radius: 4px;
  padding: 4px 10px; cursor: pointer;
}
.btn-clear-sig:hover { border-color: var(--error); color: var(--error); }
.sig-hint { font-size: 11px; color: var(--text-muted); margin-top: 6px; }

/* ── PDPA Notice ────────────────────────────────────────────────────────── */
.pdpa-box {
  height: 280px; overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  background: #fafaf8;
  font-size: 12px; line-height: 1.7; color: var(--text-muted);
}
.pdpa-box h3 { font-size: 13px; color: var(--navy); margin-bottom: 10px; }
.pdpa-box p  { margin-bottom: 10px; }
.pdpa-box ol { padding-left: 20px; margin-bottom: 10px; }
.pdpa-box li { margin-bottom: 6px; }

.pdpa-consent {
  display: flex; align-items: flex-start; gap: 10px;
  background: #f0f4f9; border: 1px solid #bed1e8;
  border-radius: var(--radius); padding: 14px 16px;
  margin-top: 14px; cursor: pointer;
}
.pdpa-consent input[type="checkbox"] { width: 16px; height: 16px; margin-top: 2px; flex-shrink: 0; cursor: pointer; }
.pdpa-consent label { font-size: 13px; color: var(--navy); cursor: pointer; line-height: 1.5; }

/* ── Matter Type Dropdowns ──────────────────────────────────────────────── */
.matter-cascade { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 28px;
}
.btn {
  padding: 11px 28px;
  border-radius: var(--radius);
  font-size: 14px; font-weight: 600;
  cursor: pointer; border: none; transition: all 0.15s;
  font-family: inherit;
}
.btn-primary {
  background: var(--navy); color: #fff;
}
.btn-primary:hover { background: var(--navy-light); }
.btn-primary:disabled {
  background: #94a3b8; cursor: not-allowed;
}
.btn-secondary {
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--navy); color: var(--navy); }
.btn-submit {
  background: var(--step-done); color: #fff; padding: 12px 36px; font-size: 15px;
}
.btn-submit:hover { background: #14532d; }
.btn-submit:disabled { background: #94a3b8; cursor: not-allowed; }

/* ── Alert ──────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: var(--radius);
  font-size: 13px; display: none; margin-top: 16px;
}
.alert.error   { background: var(--error-bg);   color: var(--error);   border: 1px solid #fca5a5; }
.alert.success { background: var(--success-bg); color: var(--success); border: 1px solid #86efac; }
.alert.visible { display: block; }

/* ── Success Screen ─────────────────────────────────────────────────────── */
.success-screen {
  text-align: center; padding: 48px 32px;
  background: var(--card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.success-icon { font-size: 52px; margin-bottom: 16px; }
.success-screen h2 { font-size: 24px; font-weight: 600; color: var(--step-done); margin-bottom: 8px; }
.success-screen p  { color: var(--text-muted); font-size: 14px; max-width: 420px; margin: 0 auto 16px; }
.ref-box {
  background: #f0f4f9; border: 1px solid #bed1e8;
  border-radius: var(--radius); padding: 14px 20px;
  display: inline-block; margin: 12px 0 24px;
}
.ref-box p { font-size: 12px; color: var(--text-muted); margin-bottom: 2px; }
.ref-box strong { font-size: 20px; color: var(--navy); letter-spacing: 0.04em; }

/* ── Footer ─────────────────────────────────────────────────────────────── */
.portal-footer {
  text-align: center; padding: 24px;
  font-size: 11px; color: #9ca3af;
  border-top: 1px solid var(--border-lt);
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .portal-main { margin: 16px auto; }
  .card { padding: 20px 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: 1; }
  .type-cards { grid-template-columns: 1fr; }
  .matter-cascade { grid-template-columns: 1fr; }
  .btn-row { flex-direction: column-reverse; gap: 10px; }
  .btn { width: 100%; text-align: center; }
  .progress-wrap { padding: 12px 16px; }
  .step-label { display: none; }
}
