/* ---- Variables ---- */
:root {
  --color-bg: #f8f9fa;
  --color-surface: #fff;
  --color-border: #dee2e6;
  --color-primary: #1a73e8;
  --color-primary-hover: #1557b0;
  --color-text: #202124;
  --color-text-muted: #5f6368;
  --color-required: #c5221f;
  --color-success: #1e8e3e;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  padding: 1.5rem;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  background: var(--color-surface);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

/* ---- Header ---- */
.form-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid var(--color-border);
}
.form-header h1 {
  margin: 0 0 0.25rem 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--color-text);
}
.subtitle {
  margin: 0;
  font-size: 0.95rem;
  color: var(--color-text-muted);
}

/* ---- Sections ---- */
.section {
  margin-bottom: 2rem;
}
.section h2 {
  margin: 0 0 0.75rem 0;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--color-text);
}
.section-desc {
  margin: 0 0 1rem 0;
  color: var(--color-text-muted);
  font-size: 0.95rem;
}
.section-info {
  background: var(--color-bg);
  padding: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
}
.section-info p { margin: 0 0 0.5rem 0; }
.section-info ul {
  margin: 0;
  padding-left: 1.25rem;
}
.mapping-reference {
  margin-top: 1rem;
  font-size: 0.9rem;
}
.mapping-reference summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--color-primary);
}
.table-wrap {
  overflow-x: auto;
  margin-top: 0.5rem;
}
.mapping-reference table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.mapping-reference th,
.mapping-reference td {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  text-align: left;
}
.mapping-reference th {
  background: var(--color-bg);
  font-weight: 600;
}

/* ---- Fields ---- */
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 520px) {
  .field-grid { grid-template-columns: 1fr; }
}
.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.field label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text);
}
.required { color: var(--color-required); }
.field input[type="text"],
.field input[type="email"],
.field input[type="tel"],
.field input[type="date"] {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1rem;
  background: var(--color-surface);
}
.field input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
}

/* ---- Checkbox groups (granular consent - PDPA) ---- */
.checkbox-group {
  margin: 0 0 1.25rem 0;
  padding: 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
}
.checkbox-group legend {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text);
  padding: 0 0.5rem;
  margin-bottom: 0.5rem;
}
.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.4rem 0;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--color-text);
}
.checkbox-label input[type="checkbox"] {
  margin-top: 0.2rem;
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--color-primary);
  flex-shrink: 0;
}
.checkbox-label a {
  color: var(--color-primary);
  text-decoration: none;
}
.checkbox-label a:hover { text-decoration: underline; }
.confirmations .checkbox-label { font-weight: 500; }
.purpose-item span { max-width: 100%; }
.policy-check { margin-bottom: 1rem; }

/* ---- Signature ---- */
.signature-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}
@media (max-width: 520px) {
  .signature-fields { grid-template-columns: 1fr; }
}

/* ---- Submit ---- */
.section-submit {
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}
.btn-submit {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--color-primary);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  box-shadow: var(--shadow);
}
.btn-submit:hover {
  background: var(--color-primary-hover);
}
.btn-submit:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.35);
}
.audit-note {
  margin: 1rem 0 0 0;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* ---- Success ---- */
.success-message {
  margin-top: 1.5rem;
  padding: 1rem;
  background: #e6f4ea;
  border: 1px solid #b7e1cd;
  border-radius: var(--radius);
  color: #137333;
}
.success-message[hidden] { display: none; }

/* ---- A11y ---- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
