:root{
  --bg: #f0f4f8;
  --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --brand: #4f46e5;
  --brand-700: #4338ca;
  --brand-light: #eef2ff;
  --accent: #10b981;
  --border: #e2e8f0;
  --success: #10b981;
  --danger: #e11d48;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 4px 6px rgba(0,0,0,0.07);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
}

*{ box-sizing: border-box; }
html,body{ height:100%; overflow-x: hidden; max-width: 100%; }
body{
  margin:0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 20% 50%, rgba(102, 126, 234, 0.03) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(118, 75, 162, 0.03) 0%, transparent 50%);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.6;
}

.container{ max-width: 900px; margin: 36px auto; padding: 0 16px; }
.site-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 32px 24px;
  border-radius: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-lg);
}
.title{
  margin:0;
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 0%, #f0f0f0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.subtitle{
  margin:12px 0 0;
  color: rgba(255,255,255,0.9);
  font-size: 15px;
  font-weight: 400;
}
.site-header .row {
  margin-top: 16px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.card{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card:hover {
  box-shadow: var(--shadow-lg);
}

.progress .progress-top{
  display:flex;
  justify-content: space-between;
  align-items:center;
  margin-bottom:12px;
}
.progress .bar{
  width:100%;
  height:12px;
  background:#e5e7eb;
  border-radius: 999px;
  overflow:hidden;
  position: relative;
}
.progress #progressBar{
  height:100%;
  width:0%;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
  transition: width .4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}
.progress #progressBar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  animation: shimmer 2s infinite;
}
@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.grid{ display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.field{ grid-column: span 6; display:flex; flex-direction: column; position: relative; }
.field#purchase_price_field {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.field#purchase_price_field .label {
  display: block;
  width: 100%;
  margin-bottom: 8px;
  text-align: left;
}
.field#purchase_price_field .input {
  width: 100%;
}
.field.full{ grid-column: 1 / -1; }
.field.number-field { grid-column: span 2; }
/* Compact field for yes/no selects */
.field.compact-select {
  grid-column: span 3;
  max-width: 140px;
}
.field.compact-select .label {
  white-space: nowrap;
}

/* Spacing for applicant sections */
.field.number-field {
  grid-column: span 2;
}
.field.number-field .label {
  white-space: nowrap;
}

/* Step 4: Employment fields - narrower widths */
#step4Form .field[id$="_employment_status"] { grid-column: span 4; min-width: 180px; }
#step4Form .field[id$="_employed_employer_field"] { grid-column: span 4; }
#step4Form .field[id$="_employed_job_title_field"] { grid-column: span 4; }
#step4Form .field[id$="_employed_start_field"] { grid-column: span 4; max-width: 260px; }

#step4Form .field[id$="_self_employed_cis_field"] { grid-column: span 2; max-width: 160px; }
#step4Form .field[id$="_self_employed_start_field"] { grid-column: span 3; max-width: 240px; }
#step4Form .field[id$="_self_employed_start_field"] > div { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#step4Form .field[id$="_self_employed_job_title_field"] { grid-column: span 3; min-width: 200px; }

#step4Form .field[id$="_director_company_field"] { grid-column: span 4; }
#step4Form .field[id$="_director_shares_field"] { grid-column: span 2; max-width: 140px; }
#step4Form .field[id$="_employment_status_other_wrap"] { grid-column: span 4; }

#step4Form .field[id$="_employment_notes"] { grid-column: 1 / -1; }
#step4Form .field[id$="_employment_notes"] textarea { min-height: 120px; }

/* Date select group for month/year dropdowns */
.date-select-group {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.date-select {
  flex: 1;
  min-width: 0;
}

/* Style all number inputs (applicants and dependants) */
.field.number-field input[type="number"],
input[type="number"]#depCount {
  width: 80px;
  text-align: center;
  padding-right: 6px; /* Slightly less padding for smaller arrows */
}

/* Number spinner: input with vertical stacked buttons to the right (inline layout) */
.number-spinner{ display:inline-flex; align-items:center; gap:8px; flex-wrap:nowrap; }
.spin-vertical{ display:flex; flex-direction:column; gap:1px; }
.spin-btn{ 
  width: 24px; 
  height: 18px; 
  border-radius: 3px; 
  border: 1px solid rgba(15,23,42,0.15); 
  background: rgba(255,255,255,0.95); 
  color: var(--text); 
  cursor: pointer; 
  display: inline-flex; 
  align-items: center; 
  justify-content: center;
  backdrop-filter: blur(2px);
  font-size: 11px;
  line-height: 1;
}
.spin-btn svg{ display:block; width: 10px; height: 10px; }
.spin-btn:hover{ background: rgba(255,255,255,1); border-color: rgba(15,23,42,0.3); }
.spin-btn:active{ transform: scale(0.95); }
.spin-btn:focus{ outline: 3px solid rgba(79,70,229,0.18); outline-offset: 2px; }
/* no extra rules for spin-up/down; icons handle appearance */

/* Stronger visible focus for keyboard users */
.spin-btn:focus-visible{ outline: 3px solid var(--brand); outline-offset: 3px; box-shadow: 0 4px 14px rgba(67,56,202,0.12); }

/* Make the spinners slightly smaller on narrow screens */
@media (max-width: 520px){
  .spin-vertical{ gap:4px; }
  .spin-btn{ width:34px; height:28px; }
  .number-spinner .input{ padding-right: 6px; }
}

/* Hide custom spinners on fine-pointer devices (desktop with mouse). Show only on coarse-pointer (touch) devices) */
@media (pointer: fine) {
  .spin-vertical{ display:none !important; }
  /* let native browser spin buttons be visible on desktop */
  input[type="number"]::-webkit-outer-spin-button,
  input[type="number"]::-webkit-inner-spin-button{ -webkit-appearance: inner-spin-button; margin: 0; }
}

@media (pointer: coarse) {
  /* keep custom spinners visible on touch devices */
  .spin-vertical{ display:flex !important; }
  /* hide native mobile spinner so we don't get duplicates */
  input[type="number"]::-webkit-outer-spin-button,
  input[type="number"]::-webkit-inner-spin-button{ -webkit-appearance: none; margin: 0; }

  /* Specifically ensure applicants count spinner is visible */
  #applicantsCount {
    -webkit-appearance: none !important;
    -moz-appearance: textfield !important;
  }
}


/* Bigger arrows for number inputs */
.field.number-field input[type="number"]::-webkit-inner-spin-button,
input[type="number"]#depCount::-webkit-inner-spin-button {
  opacity: 1;
  background: transparent;
  height: 1.4em;
  padding: 6px 4px;
  margin: 0;
  position: relative;
  right: 2px;
  cursor: pointer;
}

/* Keep native spin buttons visible where supported; custom mobile spinners were removed */

/* Firefox number input styling */
.field.number-field input[type="number"],
input[type="number"]#depCount {
  -moz-appearance: textfield;
  appearance: textfield;
}
.field.number-field input[type="number"]:hover::-webkit-inner-spin-button,
input[type="number"]#depCount:hover::-webkit-inner-spin-button {
  opacity: 1;
}

/* Immigration status fields (single .field elements moved next to full-country input) */
#a1_immigration_field, #a2_immigration_field {
  grid-column: span 6; /* same width as other .field elements */
}

.label{ font-size: 14px; color: var(--text); margin-bottom: 6px; }
.label.required::after{ content: ' *'; color: #dc2626; }

.input{
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 15px;
  transition: all 0.2s ease;
  background: #fff;
  max-width: 100%;
  min-width: 0;
}
.input:hover {
  border-color: #cbd5e1;
}
.input:focus{
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.error-message {
  color: #dc2626;
  font-size: 13px;
  font-weight: 500;
  margin-top: 6px;
}

.hint{ font-size: 12px; color: var(--muted); margin-top: 6px; }
.hint.sanitize { color: #b45309; font-weight: 600; }

/* Keep small hints on one line where needed */
.hint.single-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Simple tooltip used for short helper hints */
.tooltip{
  display:inline-block;
  margin-left:8px;
  width:18px;height:18px;line-height:18px;text-align:center;border-radius:50%;
  background:#eef2ff;color:var(--brand);font-weight:700;font-size:12px;cursor:help;
  position: relative;
}
.label .tooltip{ margin-left:4px; }
.tooltip:focus{ outline:2px solid var(--brand); }
.tooltip::after{
  content: attr(data-tooltip);
  position: absolute;
  background: #0f172a; color:#fff; padding:8px 10px; border-radius:8px; font-size:13px;
  white-space: normal; left: 100%; top: 50%; transform: translateX(8px) translateY(-50%); opacity:0; pointer-events:none; transition:opacity .12s ease;
  z-index:30;
  max-width: 600px;
  line-height: 1.4;
}
.tooltip:hover::after, .tooltip:focus::after{ opacity:1; }

/* Short tooltips without line breaks */
.short-tooltip::after { white-space: nowrap; }

/* Long tooltips on mobile: preserve newlines so the intro + blank line + English body render correctly */
.tooltip.long-tooltip::after { white-space: pre-line; }

/* Hide the pseudo-element tooltip on mobile to avoid duplication with the overlay */
@media (max-width: 1024px) {
  .tooltip.long-tooltip::after { display: none !important; }
}

/* Mobile tooltip overlay styles (narrower and positioned higher) */
.tooltip-mobile-overlay{
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 100px; /* raised above bottom */
  z-index: 10002;
  background: #0f172a;
  color: #fff;
  padding: 12px 16px;
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(2,6,23,0.6);
  font-size: 14px;
  line-height: 1.5;
  max-width: min(520px, 75vw); /* narrower */
  width: 90vw;
}

/* Extra narrow on small phones */
@media (max-width: 420px) {
  .tooltip-mobile-overlay{
    max-width: 320px !important;
    width: 80vw !important;
    padding: 10px 14px !important;
    bottom: 94px !important; /* slightly higher on small phones */
    display: block !important;
    left: 50% !important; transform: translateX(-50%) !important;
  }
}

.tooltip-mobile-inner{ max-height: 60vh; overflow:auto; }
@media (min-width: 1025px){
  .tooltip-mobile-overlay{ display:none; }
}

/* Long tooltips: position slightly above the icon on desktop */
@media (min-width: 1025px) {
  .tooltip.long-tooltip::after {
    position: fixed !important;
    left: var(--tooltip-left, 50%) !important;
    top: var(--tooltip-top, 50%) !important;
    transform: translate(-50%, calc(-100% - var(--tooltip-offset, 10px))) !important;
    bottom: auto !important;
    /* Prefer per-tooltip computed max width, fall back to calc(80vw) */
    max-width: var(--tooltip-max-width, calc(80vw)) !important;
    /* Preserve line breaks from the data-tooltip attribute so `intro\nbody` shows on separate lines */
    white-space: pre-line !important;
    padding: 12px 16px !important;
    z-index: 10000 !important;
    box-shadow: 0 10px 30px rgba(2,6,23,0.6) !important;
    border-radius: 12px !important;
  }
}

/* Desktop - prevent excessive wrapping on large screens */
@media (min-width: 1025px) {
  .tooltip::after {
    max-width: 650px;
    white-space: normal;
  }
}

/* Short tooltips must stay on one line on desktop (overrides the normal rule above) */
@media (min-width: 1025px) {
  .tooltip.short-tooltip::after {
    white-space: nowrap !important;
  }
}

/* Mobile tooltip improvements */
@media (max-width: 1024px) {
  .tooltip::after {
    min-width: 280px;
    max-width: 90vw;
    white-space: pre-line;
    word-wrap: break-word;
  }
}

@media (max-width: 768px) {
  .tooltip::after {
    min-width: 250px;
    max-width: 90vw;
    white-space: pre-line;
    word-wrap: break-word;
  }
}

@media (max-width: 480px) {
  .tooltip::after {
    min-width: 200px;
    max-width: 85vw;
    font-size: 12px;
    padding: 6px 8px;
  }
}
.legend{
  font-weight: 700;
  margin-bottom: 12px;
  font-size: 18px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
/* Legend icons for different sections */
.legend::before {
  font-size: 20px;
}
fieldset[class*="grid"] > .legend::before {
  content: '👤';
}
fieldset[id*="Address"] > .legend::before,
fieldset[id*="address"] > .legend::before {
  content: '🏠';
}
fieldset:has(#depList) > .legend::before {
  content: '👨‍👩‍👧‍👦';
}

/* Step 3 controls legend icons explicitly in HTML/JS */
form[data-step="3"] .legend::before {
  content: none !important;
  display: none !important;
}
.divider{ border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.hidden{ display:none; }

/* Header elements */
.header-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  gap: 20px;
}

.secure-info {
  font-size: 13px;
  color: rgba(255,255,255,0.85);
}

.language-selector {
  min-width: 160px;
}

/* Header elements */
.header-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  gap: 20px;
}

.secure-info {
  font-size: 13px;
  color: rgba(255,255,255,0.85);
}

/* Progress elements */
.progress-label {
  font-weight: 600;
  color: var(--text);
}

.progress-percent {
  font-weight: 700;
  color: var(--brand);
}

/* Hint text (small format hints like DD/MM/YYYY) */
.hint-small {
  font-size: 13px;
  color: var(--text-light);
}

/* Step placeholder text (Coming soon sections) */
.step-title {
  margin-bottom: 24px;
  color: var(--brand);
}

.step-placeholder {
  color: var(--text-light);
  margin-bottom: 20px;
}

.actions{
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  align-items: center;
}
.actions.between{
  justify-content: space-between;
}
.actions.step3-actions {
  justify-content: space-between;
}
.actions.step3-actions button:first-child {
  margin-right: auto;
}
/* Keep other buttons right-aligned */
.actions.step3-actions button:not(:first-child) {
  margin-left: 0;
}

/* Add extra spacing above actions in form cards so buttons sit below card content */
.card .actions { margin-top: 12px; }

/* Increase spacing on desktop screens */
@media (min-width: 720px) {
  .card .actions { margin-top: 24px; }
}

.btn{
  border-radius: 12px;
  padding: 12px 20px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn.primary{
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}
.btn.primary:hover{
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}
.btn.ghost{
  background: var(--brand-light);
  color: var(--brand);
  border: 1px solid #e0e7ff;
}
.btn.ghost:hover{
  background: #e0e7ff;
  border-color: var(--brand);
}
/* Danger-styled button for destructive/clear actions */
.btn.danger{
  background:#fee2e2;
  color:#b91c1c;
  border:1px solid #fecaca;
}
.btn.danger:hover{
  background:#fecaca;
  color:#991b1b;
  border-color:#fca5a5;
}
/* Secondary button for neutral actions */
.btn.secondary{
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  text-decoration: none;
}
.btn.secondary:hover{
  background: #fde68a;
  border-color: #fcd34d;
}

.dep-card {
  grid-column: 1 / -1;
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
  background: linear-gradient(to bottom right, #ffffff, #fafbfe);
  transition: all 0.2s ease;
}
.dep-card:hover {
  border-color: var(--brand);
  border-style: solid;
  box-shadow: var(--shadow-sm);
}

.dep-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dep-badge {
  color: var(--brand);
  font-size: 15px;
}
.dep-fields {
  display: flex;
  flex-direction: row;
  gap: 12px;
}
.dep-fields .field {
  flex: 1;
  min-width: 0; /* Prevents flex items from overflowing */
}

/* Mobile layout - keep in one row */
@media (max-width: 720px) {
  .dep-fields {
    gap: 8px;
  }
  .dep-fields .field {
    flex: 0 1 33.333%;
    min-width: 0;
  }
  .dep-fields .input {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .dep-fields {
    flex-direction: column;
  }
  .dep-fields .field {
    flex: 1 1 100%;
  }
}

.invalid { outline: 2px solid #ef4444 !important; border-color: #ef4444 !important; background: #fef2f2 !important; }

select.invalid { 
  outline: 2px solid #ef4444 !important; 
  border: 2px solid #ef4444 !important; 
  background: #fef2f2 !important; 
  color: #1e293b !important; 
}

.badge{
  display:inline-block;
  font-size:12px;
  padding:4px 10px;
  border-radius:999px;
  background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
  color:var(--brand);
  font-weight: 600;
  border: 1px solid rgba(102, 126, 234, 0.2);
}

.toast{
  position: fixed; bottom: 16px; right: 16px;
  background: var(--success); color: #fff; padding: 10px 14px; border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0,0,0,.15); display:none;
}
.toast.show{ display:block; }
.toast.err{ background: var(--danger); }
/* Previous address card layout */
.prev-card { border: 1px solid #e5e7eb; border-radius: 14px; padding: 14px; margin-bottom: 12px; background:#fff; }
.prev-card .legend { font-weight: 600; margin-bottom: 8px; }
.grid.two { display:grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.grid.three { display:grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.grid.three > .field, .grid.three .field { grid-column: span 1; }
@media (max-width: 720px){ .grid.three { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 480px){ .grid.three { grid-template-columns: 1fr; } .grid.three .field { grid-column: 1 / -1; } }
.actions.end { display:flex; justify-content:flex-end; margin-top: 8px; }

/* Address history coverage status */
.coverage-status {
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 16px;
  font-size: 0.95rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  position: relative;
}
.coverage-status::before {
  content: '⏳';
  flex: 0 0 auto;
  font-size: 1.1rem;
  line-height: 1;
}
#prevInfo { margin-bottom: 8px; font-size: 0.93rem; }
/* Previous address card layout */
.prev-card{
  border:1px solid #e6e8ef;
  border-radius:14px;
  padding:14px;
  margin-bottom:12px;
  background:#fff;
}
.prev-card .legend{ font-weight:600; margin-bottom:8px; }
.grid.two{ display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.actions.end{ display:flex; justify-content:flex-end; margin-top:8px; }
#prevInfo{ margin-bottom:8px; font-size:.93rem; }
/* Stack previous addresses vertically and full width */
#prevList, #a2_prevList {
  display:flex;
  flex-direction:column;
  gap:14px;
}
.prev-card{
  width:100%;
  border:1px solid #e6e8ef;
  border-radius:14px;
  padding:16px;
  background: linear-gradient(to bottom right, #ffffff, #f8fafc);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}
.prev-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--brand);
}
.prev-card .legend{ font-weight:600; margin-bottom:8px; }

/* same 2-col grid as current address */
.prev-card .grid.two{
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap:12px;
}
.prev-card .actions.end{
  display:flex;
  justify-content:flex-end;
  margin-top:8px;
}


@media (max-width: 720px){
  .field{ grid-column: 1 / -1; }
}

/* ===== Modal ===== */
.modal {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  overflow: auto;
}
.modal.hidden { display: none; }
.modal-content {
  background: var(--card);
  border-radius: 16px;
  max-width: 900px;
  width: 90%;
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,0.3);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 {
  margin: 0;
  font-size: 24px;
}
.btn-close {
  background: none;
  border: none;
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0;
  width: 32px;
  height: 32px;
}
.btn-close:hover { color: var(--text); }
.modal-body {
  padding: 24px;
}
.report-section {
  margin-bottom: 24px;
}
.report-section h3 {
  font-size: 18px;
  margin: 0 0 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.report-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border);
  margin-bottom: 8px;
}
.report-table th,
.report-table td {
  padding: 10px 12px;
  text-align: left;
  border: 1px solid var(--border);
}
.report-table th {
  background: var(--brand);
  color: white;
  font-weight: 600;
}
.report-table tr:nth-child(even) {
  background: #f8fafc;
}
.copy-btn {
  font-size: 13px;
  padding: 4px 12px;
  background: var(--border);
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
}
.copy-btn:hover {
  background: #e2e8f0;
}

/* Copyable cell values */
.copyable {
  cursor: pointer;
  border-bottom: 1px dotted #cbd5e1;
}
.copyable:hover {
  background: #fff8e1;
}

/* Modal styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  max-width: 90vw;
  max-height: 90vh;
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.btn-close {
  background: none;
  border: none;
  font-size: 28px;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.2s;
}

.btn-close:hover {
  background: var(--border);
  color: var(--text);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  max-height: calc(90vh - 80px);
}

/* Language selector styling */
.language-selector select {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-weight: 600;
  font-size: 15px;
}

/* Mobile responsive styles */
@media (max-width: 768px) {
  .container {
    padding: 0 12px;
    margin: 20px auto;
  }

  .card {
    padding: 20px 16px;
  }

  .header-footer {
    flex-wrap: wrap;
    gap: 12px;
  }

  .secure-info {
    width: 100%;
  }

  .site-header {
    padding: 20px 16px;
    margin-bottom: 16px;
  }

  .site-header > div:first-child {
    flex-direction: column;
    align-items: flex-start !important;
  }

  .language-selector {
    width: 100%;
  }

  .language-selector select {
    width: 100% !important;
    min-width: 100% !important;
  }

  .title {
    font-size: 24px;
  }

  .subtitle {
    font-size: 14px;
  }

  /* Tooltip positioning on mobile */
  .tooltip {
    position: relative;
  }

  .field .tooltip::after {
    position: fixed !important;
    left: 50% !important;
    top: 50% !important;
    bottom: auto !important;
    transform: translate(-50%, -50%) !important;
    white-space: normal !important;
    max-width: calc(100vw - 32px) !important;
    z-index: 1000 !important;
  }

  /* Grid - single column on mobile */
  .grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }

  .grid.two {
    grid-template-columns: 1fr !important;
  }

  .field {
    grid-column: span 1 !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  /* Step 4 employment fields */
  #step4Form .field[id$="_employment_status"],
  #step4Form .field[id$="_employed_employer_field"],
  #step4Form .field[id$="_employed_job_title_field"],
  #step4Form .field[id$="_employed_start_field"],
  #step4Form .field[id$="_self_employed_cis_field"],
  #step4Form .field[id$="_self_employed_start_field"],
  #step4Form .field[id$="_self_employed_job_title_field"],
  #step4Form .field[id$="_director_company_field"],
  #step4Form .field[id$="_director_shares_field"],
  #step4Form .field[id$="_employment_status_other_wrap"] {
    grid-column: span 1 !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  /* Allow nowrap labels to wrap on mobile so they don't force width */
  .field.compact-select .label,
  .field.number-field .label {
    white-space: normal !important;
  }

  #step5Form #purchase_price_field,
  #step5Form #property_type_field,
  #step5Form #deposit_country_field {
    grid-column: span 1 !important;
    justify-content: flex-start !important;
    align-items: flex-start;
    flex-direction: column;
  }

  /* Fix label alignment for purchase price and country fields */
  #step5Form #purchase_price_field .label,
  #step5Form #deposit_country_field .label {
    margin-bottom: 6px;
    align-self: flex-start;
    width: 100%;
    display: block;
  }

  #step5Form #purchase_price_field .input,
  #step5Form #property_type_field .input,
  #step5Form #deposit_country_field .input {
    width: 100%;
  }

  /* Ensure consistent label positioning across all step5 fields */
  #step5Form .field .label {
    margin-bottom: 6px;
    align-self: flex-start;
    width: 100%;
    text-align: left;
    display: block;
  }

  /* Ensure field containers are properly aligned */
  #step5Form .field {
    align-items: flex-start;
  }

  /* PDF Modal on mobile */
  .modal {
    padding: 0;
  }

  .modal-content {
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    border-radius: 0;
    margin: 0;
  }

  .modal-header {
    padding: 16px;
  }

  .modal-header h2 {
    font-size: 18px;
  }

  .modal-body {
    padding: 0;
    max-height: calc(100vh - 60px);
  }

  #pdfIframe {
    height: 100% !important;
  }

  /* Buttons */
  .actions {
    flex-direction: column;
    gap: 12px;
  }

  .actions .btn {
    width: 100%;
  }

  /* Form inputs */
  .input,
  .label {
    font-size: 16px; /* Prevents iOS zoom on focus */
  }

  /* Fieldset legend */
  .legend {
    font-size: 18px;
  }

  /* Progress bar */
  .progress {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  /* Dependants grid - single column */
  .dep-fields,
  .dep-fields .grid {
    grid-template-columns: 1fr !important;
  }

  .dep-fields .field {
    grid-column: span 1 !important;
  }

  /* Previous address cards */
  .prev-card .grid {
    grid-template-columns: 1fr !important;
  }

  /* Consent checkboxes on mobile */
  #step5Form fieldset:last-of-type .field {
    flex-direction: row !important;
    align-items: flex-start !important;
  }
}

/* Extra small screens */
@media (max-width: 480px) {
  .container {
    padding: 0 8px;
    margin: 16px auto;
  }

  .card {
    padding: 16px 12px;
    border-radius: 14px;
  }

  .site-header {
    border-radius: 14px;
  }

  .grid {
    gap: 8px;
  }

  .field {
    margin-bottom: 8px;
  }

  .input, select.input, textarea.input {
    max-width: 100%;
  }

  .input {
    padding: 10px 12px;
    font-size: 16px; /* Must be >=16px to prevent iOS auto-zoom on focus */
  }

  .field .tooltip::after {
    max-width: calc(100vw - 24px) !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    bottom: auto !important;
  }
}

/* Скрываем всю форму во время загрузки */
body.loading .container {
  display: none;
}

/* Radio buttons */
.radio-group {
  display: flex;
  gap: 16px;
  margin-top: 8px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 500;
}

.radio-label input[type="radio"] {
  margin: 0;
  width: 16px;
  height: 16px;
}

/* Number input with spinners */
.number-input-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.number-input {
  width: 80px;
  text-align: center;
  -moz-appearance: textfield;
}

.number-input::-webkit-outer-spin-button,
.number-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.spin-up,
.spin-down {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: bold;
  transition: all 0.2s ease;
}

.spin-up:hover,
.spin-down:hover {
  background: var(--brand-light);
  border-color: var(--brand);
  color: var(--brand);
}

.spin-up:active,
.spin-down:active {
  background: var(--brand);
  color: white;
}

/* ===== Step 3: Address History ===== */
.prev-card {
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
  background: #fff;
}

.prev-card .legend {
  font-weight: 600;
  margin-bottom: 8px;
}

.grid.two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.actions.end {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

/* Address history coverage status */
.coverage-status {
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 16px;
  font-size: 0.95rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  position: relative;
  color: #374151;
}

.coverage-status::before {
  content: '⏳';
  flex: 0 0 auto;
  font-size: 1.1rem;
  line-height: 1;
}

#prevInfo {
  margin-bottom: 8px;
  font-size: 0.93rem;
}

/* Stack previous addresses vertically and full width */
#prevList,
#a2_prevList {
  margin-top: 12px;
}

.prev-card {
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
  background: #fff;
}

.prev-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.prev-card .legend {
  font-weight: 600;
  margin-bottom: 8px;
}

/* Same 2-col grid as current address */
.prev-card .grid.two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.prev-card .actions.end {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

/* Mobile layout */
@media (max-width: 720px) {
  .prev-card .grid.two {
    grid-template-columns: 1fr;
  }
}

/* Address suggestions */
.address-suggestions {
  position: absolute;
  bottom: calc(100% + 2px);
  left: 0;
  right: 0;
  background: white;
  border: 2px solid var(--primary);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  z-index: 99999;
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 0;
}

.address-suggestion {
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background-color 0.2s;
  font-size: 0.9rem;
  line-height: 1.4;
  white-space: normal;
  word-wrap: break-word;
}

.address-suggestion:hover {
  background-color: var(--bg);
}

.address-suggestion:last-child {
  border-bottom: none;
}

.address-suggestion.loading {
  color: var(--muted);
  font-style: italic;
}

.address-suggestion.error {
  color: var(--danger);
}

/* Relative positioning for all postcode fields */
.field:has([id$="_pc"]) {
  position: relative;
  z-index: 1;
}

/* PDF Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: #b4cae0;
  border-radius: 45px;
  width: 90vw !important;
  height: 80vh !important;
  max-width: 800px;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  margin: 0;
  color: var(--text);
}

.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--muted);
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s ease;
}

.close-btn:hover {
  background: var(--border);
}

.modal-body {
  padding: 0;
  height: calc(90vh - 80px);
  display: flex;
}

#pdfViewer {
  width: 100%;
  height: 100%;
  display: block;
}

.field:has([id$="_pc"]):has(.address-suggestions[style*="display: block"]),
.field:has([id$="_pc"]):has(.address-suggestions:not([style*="display: none"])) {
  z-index: 100;
}

/* ── Bug-report floating button ──────────────────────────────────────────── */
.bug-report-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9000;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: #1e293b;
  color: #fff;
  border: none;
  border-radius: 50px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  opacity: 0.85;
}
.bug-report-btn:hover {
  background: #4f46e5;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(79,70,229,0.4);
  opacity: 1;
}
.bug-report-btn-icon { font-size: 15px; }
@media (max-width: 480px) {
  .bug-report-btn-label { display: none; }
  .bug-report-btn { padding: 11px 13px; border-radius: 50%; }
  /* Prevent Safari auto-zoom on input focus (triggers when font-size < 16px) */
  .bug-modal-body input,
  .bug-modal-body textarea,
  .bug-modal-body select { font-size: 16px !important; }
}

/* ── Bug-report modal ────────────────────────────────────────────────────── */
.bug-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(3px);
  z-index: 9100;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.bug-modal-content {
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.bug-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}
.bug-modal-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.bug-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}
.bug-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

/* console pre inside modal */
.bug-console-pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  max-height: 130px;
  overflow-y: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 6px 0 0;
  color: var(--muted);
}
.bug-status-text {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

/* ── Toast notifications ─────────────────────────────────────────────────── */
.bug-toast {
  position: fixed;
  bottom: 70px;
  right: 20px;
  z-index: 9200;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
}
.bug-toast.bug-toast-visible {
  opacity: 1;
  transform: translateY(0);
}
.bug-toast-success { background: var(--success); }
.bug-toast-error   { background: var(--danger);  }

/* ── Screenshot lightbox ─────────────────────────────────────────────────── */
.bug-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9300;
  background: rgba(0,0,0,0.92);
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
.bug-lightbox.bug-lightbox-open { display: flex; }
.bug-lightbox img {
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
  cursor: default;
}
.bug-lightbox-close {
  position: absolute;
  top: 14px;
  right: 18px;
  background: none;
  border: none;
  color: #fff;
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.75;
  padding: 4px 8px;
}
.bug-lightbox-close:hover { opacity: 1; }

/* ── Bug modal — mobile bottom sheet ─────────────────────────────────────── */
@media (max-width: 540px) {
  .bug-modal {
    padding: 0;
    align-items: flex-end;
  }
  .bug-modal-content {
    max-width: 100%;
    max-height: 88vh;
    border-radius: 20px 20px 0 0;
  }
  .bug-modal-body {
    padding: 14px 16px;
  }
  .bug-modal-footer {
    flex-direction: column-reverse;
    padding: 12px 16px;
  }
  .bug-modal-footer .btn {
    width: 100%;
    text-align: center;
  }
  #bugDescription { rows: 3; }
  .bug-console-pre { max-height: 80px; }
}

/* ── Submit overlay & spinner ── */
.submit-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
}
.submit-overlay-content {
  background: #fff;
  border-radius: 16px;
  padding: 40px 48px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}
.submit-overlay-content p {
  margin: 16px 0 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}
.spinner.large {
  width: 40px;
  height: 40px;
  border-width: 4px;
  border-color: rgba(79, 70, 229, 0.2);
  border-top-color: var(--brand);
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

