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

:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-hover: #f0f0f2;
  --border: #d5d5d8;
  --border-focus: #E4192C;
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-muted: #aeaeb2;
  --accent: #E4192C;
  --accent-hover: #c81526;
  --accent-subtle: rgba(228, 25, 44, 0.08);
  --gold: #b8860b;
  --success: #248a3d;
  --danger: #d70015;
  --radius: 8px;
  --radius-lg: 12px;
  --transition: 150ms ease;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
}

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* Layout */

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}

/* Header */

.header {
  text-align: center;
  margin-bottom: 40px;
}

.logo {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  margin-bottom: 16px;
}

.header h1 {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.header p {
  color: var(--text-secondary);
  font-size: 0.87rem;
}

/* Encryption badge */

.encryption-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.encryption-badge svg {
  width: 14px;
  height: 14px;
  fill: var(--success);
}

/* Sections */

.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  overflow: hidden;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
}

.section-header:hover {
  background: var(--surface-hover);
}

.section-header h2 {
  font-size: 0.93rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-header .count {
  font-size: 0.73rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-subtle);
  padding: 2px 8px;
  border-radius: 10px;
}

.section-chevron {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  transition: transform var(--transition);
}

.section.open .section-chevron {
  transform: rotate(180deg);
}

.section-body {
  display: none;
  padding: 0 20px 20px;
}

.section.open .section-body {
  display: block;
}

/* Form elements */

.field {
  margin-bottom: 16px;
}

.field:last-child {
  margin-bottom: 0;
}

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

label .required {
  color: var(--accent);
}

textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.87rem;
  line-height: 1.5;
  transition: border-color var(--transition);
  outline: none;
  resize: vertical;
  min-height: 80px;
}

textarea::placeholder {
  color: var(--text-muted);
}

textarea:focus {
  border-color: var(--border-focus);
}

input,
select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.87rem;
  transition: border-color var(--transition);
  outline: none;
}

input::placeholder {
  color: var(--text-muted);
}

input:focus,
select:focus {
  border-color: var(--border-focus);
}

input[type="date"] {
  color-scheme: light;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%23888' 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;
  cursor: pointer;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

/* Sensitive field indicator */

input.sensitive {
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
}

/* Repeatable groups */

.group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  position: relative;
}

.group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.group-title {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--gold);
}

.btn-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: all var(--transition);
}

.btn-remove:hover {
  color: var(--danger);
  background: rgba(248, 81, 73, 0.1);
}

.btn-add {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 10px;
  background: none;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-add:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-subtle);
}

/* Passport sub-group inside traveler */

.passport-group {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-top: 12px;
  margin-bottom: 8px;
}

.passport-group .group-title {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* Submit */

.submit-area {
  margin-top: 32px;
}

.btn-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 24px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-family: var(--font);
  font-size: 0.93rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-submit:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-submit:active:not(:disabled) {
  transform: translateY(0);
}

.btn-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-submit .spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.btn-submit.loading .spinner {
  display: block;
}

.btn-submit.loading .btn-label {
  display: none;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.submit-note {
  text-align: center;
  margin-top: 12px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Status pages */

.status-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  text-align: center;
  padding: 20px;
}

.status-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 20px;
}

.status-page h1 {
  font-size: 1.3rem;
  margin-bottom: 8px;
}

.status-page p {
  color: var(--text-secondary);
  max-width: 400px;
  font-size: 0.87rem;
}

/* Error state */

.error-banner {
  display: none;
  padding: 12px 16px;
  background: rgba(248, 81, 73, 0.1);
  border: 1px solid rgba(248, 81, 73, 0.3);
  border-radius: var(--radius);
  color: var(--danger);
  font-size: 0.83rem;
  margin-bottom: 16px;
}

.error-banner.visible {
  display: block;
}

/* Loading overlay */

.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
  z-index: 100;
  justify-content: center;
  align-items: center;
}

.loading-overlay.visible {
  display: flex;
}

.loading-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 40px;
  text-align: center;
}

.loading-card .spinner-large {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

.loading-card p {
  font-size: 0.87rem;
  color: var(--text-secondary);
}

/* Custom autocomplete */

.ac-list {
  display: none;
  position: absolute;
  top: auto;
  left: 0;
  right: 0;
  z-index: 50;
  max-height: 200px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.ac-list.open {
  display: block;
}

.ac-item {
  padding: 8px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text);
}

.ac-item:hover,
.ac-item.active {
  background: var(--surface-hover);
}

.ac-item .ac-type {
  float: right;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Responsive */

@media (max-width: 480px) {
  html { font-size: 14px; }
  .container { padding: 24px 16px 60px; }
  .field-row, .field-row-3 { grid-template-columns: 1fr; }
  .section-header { padding: 14px 16px; }
  .section-body { padding: 0 16px 16px; }
}
