/* Move Abroad Retirement Affordability Calculator (MARAC) - Standardized Styles */
.marac-root{max-width:100% !important;width:100% !important;box-sizing:border-box;overflow-x:hidden}
.marac-root *{box-sizing:border-box}
.marac-wrap{
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  max-width: 1400px !important;
  width: 100% !important;
  margin: 24px auto 32px !important;
  padding: 24px;
  color: #083141;
  background: #ffffff;
  border: 2px solid #083141;
  border-radius: 16px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.04);
  box-sizing: border-box;
}
.marac-card{
  border: 1px solid #d5e4eb;
  background: #ffffff;
  border-radius: 12px;
  padding: 20px 24px;
  margin: 20px 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
  transition: box-shadow 0.2s ease;
}
.marac-card:hover{box-shadow: 0 4px 12px rgba(0,0,0,0.06)}
.marac-head{
  display:flex;
  gap:12px;
  align-items:flex-start;
  justify-content:space-between;
  flex-wrap:wrap;
}
.marac-title{
  font-size: 1.8rem;
  font-weight: 700;
  color: #083141;
  line-height: 1.2;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}
.marac-sub{
  margin: 0;
  color: #526b75;
  font-size: 0.95rem;
  line-height: 1.6;
}
.marac-badges{display:flex; gap:8px; flex-wrap:wrap; align-items:center; margin-top:12px}
.marac-badge{
  display:inline-flex; align-items:center; gap:8px;
  padding:8px 12px;
  border-radius:10px;
  border:1px solid #cbd5e1;
  background:#f8fafc;
  font-weight:600;
  font-size:0.85rem;
  color:#0f172a;
}
.marac-badge--good{border-color:#35a56b;background:#e5f6ef;color:#123828}
.marac-badge--bad{border-color:#ef4444;background:#fff1f2;color:#b91c1c}
.marac-grid{display:grid; gap:12px}
.marac-grid-2{grid-template-columns: repeat(2, minmax(0, 1fr));}
.marac-grid-3{grid-template-columns: repeat(3, minmax(0, 1fr));}
@media (max-width: 1024px){
  .marac-grid-2,.marac-grid-3{grid-template-columns:1fr;gap:12px}
  .marac-responsive-grid{grid-template-columns:1fr !important}
}
.marac-field{display:flex;flex-direction:column;gap:4px;min-width:0}
.marac-field label{
  display:block;
  font-weight:600;
  font-size:0.9rem;
  color:#0f172a;
  margin-bottom:0;
  line-height:1.4;
}
.marac-field input,.marac-field select{
  width:100%;
  border:1px solid #cbd5e1;
  border-radius:8px;
  padding:0.5rem 0.75rem;
  font-size:0.9rem;
  background:#ffffff;
  color:#0f172a;
  transition:border-color 0.2s,box-shadow 0.2s,background-color 0.2s;
  outline:none;
  min-height:38px;
  font-family:inherit;
  line-height:1.5;
  box-sizing:border-box;
}
.marac-field input:focus,.marac-field select:focus{
  outline:none;
  border-color:#59747c;
  box-shadow:0 0 0 2px rgba(89,116,124,0.2);
  background:#f8fafc;
}
/* Ensure focus is visible for keyboard navigation */
.marac-btn:focus-visible{
  outline:2px solid #59747c;
  outline-offset:2px;
}
.marac-field input:focus-visible,.marac-field select:focus-visible{
  outline:2px solid #59747c;
  outline-offset:2px;
}
/* Ensure focus is visible for keyboard navigation */
.marac-btn:focus-visible{
  outline:2px solid #59747c;
  outline-offset:2px;
}
.marac-field input:focus-visible,.marac-field select:focus-visible{
  outline:2px solid #59747c;
  outline-offset:2px;
}
.marac-help{font-size:0.9rem;color:#526b75;margin-top:6px;line-height:1.5}
.marac-checkbox-field{display:flex;align-items:center;gap:10px;padding:12px;border:1px solid #e3edf2;border-radius:8px;background:#fff;transition:all 0.2s ease;cursor:pointer}
.marac-checkbox-field:hover{background:#f8fafc;border-color:#d5e4eb}
.marac-checkbox-field input[type="checkbox"]{width:20px;height:20px;min-height:20px;margin:0;padding:0;border-radius:4px;border:2px solid #59747c;background:#ffffff;cursor:pointer;appearance:none;position:relative;flex-shrink:0;transition:all 0.2s ease}
.marac-checkbox-field input[type="checkbox"]:checked{background-color:#59747c;border-color:#59747c}
.marac-checkbox-field input[type="checkbox"]:checked::after{content:'';position:absolute;left:6px;top:2px;width:5px;height:10px;border:solid #fff;border-width:0 2px 2px 0;transform:rotate(45deg)}
.marac-checkbox-field input[type="checkbox"]:not(:checked){background-color:#ffffff;border-color:#cbd5e1}
.marac-checkbox-field input[type="checkbox"]:hover{border-color:#4a5f66;box-shadow:0 0 0 2px rgba(89,116,124,0.1)}
.marac-checkbox-field label{cursor:pointer;font-weight:600;font-size:0.95rem;color:#083141;margin:0;user-select:none}
.marac-step-title{margin:0 0 10px 0;font-size:1.3rem;font-weight:800;color:#083141;letter-spacing:-0.01em}
.marac-step-desc{margin:0 0 16px 0;color:#526b75;font-size:0.9rem;line-height:1.5}
.marac-btnrow{display:flex; gap:10px; flex-wrap:wrap; align-items:center}
.marac-btn{
  appearance:none;
  border:2px solid #59747c;
  background:#59747c;
  color:#ffffff;
  border-radius:8px;
  padding:0.75rem 1.5rem;
  font-weight:700;
  font-size:0.95rem;
  cursor:pointer;
  transition:all 0.2s ease;
  box-shadow:0 2px 4px rgba(89,116,124,0.2);
}
.marac-btn:hover{
  background:#4a5f66;
  border-color:#4a5f66;
  box-shadow:0 4px 8px rgba(89,116,124,0.3);
  transform:translateY(-1px);
}
.marac-btn:active{transform:translateY(0);box-shadow:0 1px 2px rgba(89,116,124,0.2)}
.marac-btn--primary{background:#59747c;border-color:#59747c;color:#ffffff}
.marac-btn--primary:hover{background:#4a5f66;border-color:#4a5f66}
.marac-btn--secondary{background:#ffffff;border-color:#59747c;color:#59747c}
.marac-btn--secondary:hover{background:#f8fafc;border-color:#4a5f66;color:#4a5f66}
.marac-btn:disabled{opacity:0.55;cursor:not-allowed;pointer-events:none;transform:none}
.marac-btn--danger{border-color:#ef4444;background:#fff;color:#b91c1c}
.marac-btn--danger:hover{background:#fff1f2;border-color:#dc2626;color:#991b1b}
.marac-mini{font-size:12px;color:#475569}
.marac-tablewrap{overflow:auto;border:1px solid #d5e4eb;border-radius:8px;margin:16px 0}
.marac-table{border-collapse:collapse;width:100%;min-width:1000px;background:#fff}
.marac-table th{
  background:#EBF2F4;
  color:#083141;
  text-align:left;
  font-weight:700;
  font-size:0.85rem;
  padding:12px;
  border-bottom:1px solid #d5e4eb;
  white-space:nowrap;
}
.marac-table td{
  padding:12px;
  border-bottom:1px solid #e3edf2;
  color:#083141;
  font-size:0.9rem;
  white-space:nowrap;
}
.marac-table tr:last-child td{border-bottom:none}
.marac-table .num{text-align:right;font-variant-numeric:tabular-nums}
/* Allow phase column to wrap on mobile */
@media (max-width:768px){
  .marac-table td:nth-child(2){
    white-space:normal;
    min-width:60px;
  }
}
.marac-kpis{display:grid;gap:16px;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));margin:20px 0}
.marac-kpi{
  border:1px solid #d5e4eb;
  background:#f8fafc;
  border-radius:8px;
  padding:14px 16px;
  margin-bottom:12px;
}
.marac-kpi .k{font-weight:600;color:#083141;font-size:0.85rem;margin-bottom:6px}
.marac-kpi .v{font-weight:700;color:#083141;font-size:1.5rem;margin-top:4px;line-height:1.2}
.marac-footnote{font-size:0.9rem;color:#526b75;line-height:1.5;margin-top:16px}
.marac-divider{height:1px;background:#e3edf2;margin:20px 0}
.marac-rowhead{display:flex;justify-content:space-between;align-items:center;gap:10px;flex-wrap:wrap}
.marac-pill{
  display:inline-flex;align-items:center;gap:8px;
  padding:6px 10px;border-radius:999px;
  border:1px solid #d5e4eb;background:#f0f7fa;font-size:0.85rem;color:#083141;
}
.marac-note{
  border:1px solid #d5e4eb;
  background:#f8fafc;
  border-radius:8px;
  padding:12px 16px;
  color:#083141;
  font-size:0.9rem;
  margin-top:16px;
  line-height:1.5;
}
.marac-note strong{color:#083141;font-weight:700}
.marac-num-badge{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;border-radius:999px;background:#083141;color:#fff;font-weight:800;font-size:0.9rem;margin-right:10px;flex-shrink:0}
.marac-inst{background:#f0f7fa;border:1px solid #d5e4eb;border-radius:8px;padding:12px 16px;font-size:0.9rem;color:#083141;margin:16px 0;line-height:1.5}

/* Charts */
.marac-chart-container{
  border:1px solid #d5e4eb;
  background:#ffffff;
  border-radius:8px;
  padding:20px;
  margin:20px 0;
  box-shadow:0 2px 4px rgba(0,0,0,0.03);
}
.marac-chart-title{
  font-weight:700;
  color:#083141;
  font-size:1.05rem;
  margin-bottom:16px;
}
.marac-chart-canvas{
  width:100%;
  height:350px;
  display:block;
  max-width:100%;
}
@media (max-width:768px){.marac-chart-canvas{height:250px}}
.marac-chart-legend{
  display:flex;
  gap:20px;
  flex-wrap:wrap;
  margin-top:16px;
  justify-content:center;
}
.marac-chart-legend-item{
  display:flex;
  align-items:center;
  gap:8px;
  font-size:0.85rem;
  color:#526b75;
  font-weight:500;
}
.marac-chart-legend-color{
  width:16px;
  height:16px;
  border-radius:4px;
  flex-shrink:0;
}
.marac-charts-grid{
  display:grid;
  grid-template-columns:repeat(2,1fr);
  gap:20px;
  margin-top:20px;
}
@media (max-width:1024px){.marac-charts-grid{grid-template-columns:1fr;gap:16px}}

/* Print */
@media print{
  body *{visibility:hidden}
  .marac-noprint{display:none !important}
  .marac-wrap{max-width:none;border:none;box-shadow:none;padding:20px}
  .marac-card{box-shadow:none;border:1px solid #d5e4eb}
  .marac-table{min-width:0}
  .marac-chart-container{display:none !important}
  @page{size:A4; margin:12mm;}
}

/* Tablet and below (1024px) */
@media (max-width:1024px){
  .marac-wrap{padding:20px}
  .marac-title{font-size:1.5rem}
  .marac-card{padding:18px 20px}
  /* Ensure all inline grids collapse */
  [style*="grid-template-columns:repeat(2"]{
    grid-template-columns:1fr !important;
  }
  [style*="grid-template-columns:repeat(3"]{
    grid-template-columns:1fr !important;
  }
}

/* Mobile (768px and below) */
@media (max-width:768px){
  .marac-wrap{padding:12px;margin:12px auto 20px;border-width:1px}
  .marac-title{font-size:1.3rem;line-height:1.3}
  .marac-sub{font-size:0.9rem;line-height:1.5}
  .marac-card{padding:14px 16px;margin:14px 0}
  .marac-step-title{font-size:1rem}
  .marac-kpi .v{font-size:1.2rem}
  .marac-kpi .k{font-size:0.8rem}
  .marac-tablewrap{overflow-x:auto;-webkit-overflow-scrolling:touch;margin:12px 0}
  .marac-table{font-size:0.8rem;min-width:800px}
  .marac-table th,.marac-table td{padding:6px 8px}
  /* Allow table cells to wrap on very small screens if needed */
  .marac-table td:not(.num){white-space:normal}
  .marac-field input,.marac-field select{font-size:1rem;min-height:44px;padding:10px 12px}
  .marac-btn{padding:0.875rem 1.25rem;font-size:0.9rem;min-height:44px}
  .marac-badge{font-size:0.8rem;padding:6px 10px}
  .marac-note{font-size:0.85rem;padding:10px 14px}
  .marac-help{font-size:0.85rem}
  /* Force single column for all grids on mobile */
  [style*="grid-template-columns"]{
    grid-template-columns:1fr !important;
  }
  [style*="min-width:250px"]{
    min-width:0 !important;
  }
  /* Ensure flex items wrap */
  [style*="display:flex"]{
    flex-wrap:wrap !important;
  }
  /* Destination card title adjustments */
  h3{font-size:1.1rem !important}
}

/* Small mobile (480px and below) */
@media (max-width:480px){
  .marac-wrap{padding:10px;margin:8px auto 16px}
  .marac-title{font-size:1.15rem}
  .marac-card{padding:12px 14px;margin:12px 0}
  .marac-step-title{font-size:0.95rem}
  .marac-kpi .v{font-size:1.1rem}
  .marac-field label{font-size:0.85rem}
  .marac-table{font-size:0.75rem;min-width:700px}
  .marac-table th,.marac-table td{padding:4px 6px}
  .marac-table td:not(.num){white-space:normal}
  /* Ensure destination card headers wrap */
  h3{font-size:1rem !important;word-break:break-word}
}

/* Touch-friendly improvements for all mobile */
@media (max-width:768px){
  /* Ensure buttons and inputs are touch-friendly */
  .marac-btn,.marac-field input,.marac-field select{
    min-height:44px;
    touch-action:manipulation;
  }
  /* Improve text wrapping */
  .marac-card *{word-wrap:break-word;overflow-wrap:break-word}
  /* Destination card header improvements */
  .marac-card h3{flex-wrap:wrap;gap:8px;word-break:break-word}
  /* Ensure badges don't overflow */
  .marac-badges{flex-wrap:wrap}
  /* Preference score badge adjustments */
  [style*="background:linear-gradient"][style*="padding:6px 12px"]{
    font-size:0.8rem !important;
    padding:6px 10px !important;
  }
  /* Large button text adjustments */
  [style*="font-size:1.05rem"][style*="padding:1rem 1.5rem"]{
    font-size:0.95rem !important;
    padding:0.875rem 1.25rem !important;
  }
  /* Ensure all flex containers wrap */
  [style*="display:flex"][style*="justify-content:space-between"]{
    flex-wrap:wrap !important;
  }
  /* Table improvements for mobile */
  .marac-table th,.marac-table td{
    padding:6px 4px;
  }
  .marac-table th:first-child,.marac-table td:first-child{
    padding-left:8px;
  }
  .marac-table th:last-child,.marac-table td:last-child{
    padding-right:8px;
  }
  /* Make withdrawal text more compact on mobile */
  .marac-table td[style*="color:#f59e0b"]{
    font-size:0.75rem;
    white-space:normal;
    word-break:break-word;
  }
}

/* Legacy compatibility */
.marac{max-width:100% !important;width:100% !important}
.marac .card{background:#ffffff;border:1px solid #d5e4eb;border-radius:12px;padding:20px 24px;margin:20px 0;box-shadow:0 2px 8px rgba(0,0,0,0.03)}
.marac h2{font-size:1.8rem;font-weight:700;color:#083141;margin:0 0 8px}
.marac h3{font-size:1.3rem;font-weight:800;color:#083141;margin:0 0 10px}
.marac p{margin:6px 0 10px;line-height:1.5;color:#526b75}
.marac .grid{display:grid;gap:12px}
.marac .grid-2{grid-template-columns:repeat(2,minmax(0,1fr))}
.marac .row{display:flex;gap:10px;align-items:center;flex-wrap:wrap}
.marac .btn{appearance:none;border:2px solid #59747c;background:#59747c;color:#ffffff;border-radius:8px;padding:0.75rem 1.5rem;font-weight:700;font-size:0.95rem;cursor:pointer;transition:all 0.2s ease;box-shadow:0 2px 4px rgba(89,116,124,0.2)}
.marac .btn:hover{background:#4a5f66;border-color:#4a5f66;box-shadow:0 4px 8px rgba(89,116,124,0.3);transform:translateY(-1px)}
.marac .btn--primary{background:#59747c;border-color:#59747c;color:#ffffff}
.marac .btn--danger{border-color:#ef4444;background:#fff;color:#b91c1c}
.marac .btn--danger:hover{background:#fff1f2;border-color:#dc2626;color:#991b1b}
.marac .muted{color:#526b75;font-size:0.9rem}
.marac .inst{background:#f0f7fa;border:1px solid #d5e4eb;border-radius:8px;padding:12px 16px;font-size:0.9rem;color:#083141;margin:16px 0;line-height:1.5}
.marac .badge{display:inline-flex;align-items:center;gap:8px;padding:8px 12px;border-radius:10px;border:1px solid #cbd5e1;background:#f8fafc;font-weight:600;font-size:0.85rem;color:#0f172a}
.marac .badge.ok{border-color:#35a56b;background:#e5f6ef;color:#123828}
.marac .badge.bad{border-color:#ef4444;background:#fff1f2;color:#b91c1c}
.marac table{width:100%;border-collapse:collapse;font-size:0.9rem;background:#fff;border:1px solid #d5e4eb;border-radius:8px;overflow:hidden}
.marac th,.marac td{padding:12px;border-bottom:1px solid #e3edf2;text-align:right}
.marac th:first-child,.marac td:first-child{text-align:left}
.marac th{background:#EBF2F4;color:#083141;font-weight:700;font-size:0.85rem}
.marac .table-wrap{overflow:auto;border:1px solid #d5e4eb;border-radius:8px;margin:16px 0}
.marac .summary{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:16px;margin:20px 0}
.marac .metric{background:#f8fafc;border:1px solid #d5e4eb;border-radius:8px;padding:14px 16px}
.marac .metric .k{font-weight:600;color:#083141;font-size:0.85rem;margin-bottom:6px}
.marac .metric .v{font-weight:700;color:#083141;font-size:1.5rem;margin-top:4px;line-height:1.2}
.marac .num-badge{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;border-radius:999px;background:#083141;color:#fff;font-weight:800;font-size:0.9rem;margin-right:10px;flex-shrink:0}
.marac .step-title{display:flex;align-items:center;gap:8px;margin-bottom:10px;font-size:1.3rem;font-weight:800;color:#083141}
.marac .note{background:#f8fafc;border:1px solid #d5e4eb;border-radius:8px;padding:12px 16px;color:#083141;font-size:0.9rem;margin-top:16px;line-height:1.5}
.marac .note strong{color:#083141;font-weight:700}
.marac .hr{height:1px;background:#e3edf2;margin:20px 0}

/* Preference Sliders */
input[type="range"]{
  -webkit-appearance:none;
  appearance:none;
  width:100%;
  height:12px;
  border-radius:6px;
  background:#d5e4eb;
  outline:none;
  transition:background 0.2s ease;
  cursor:grab;
}
input[type="range"]:hover{background:#c0d4de}
input[type="range"]:active{cursor:grabbing}
input[type="range"]::-webkit-slider-thumb{
  -webkit-appearance:none;
  appearance:none;
  width:24px;
  height:24px;
  border-radius:50%;
  background:#083141;
  cursor:grab;
  box-shadow:0 2px 8px rgba(8,49,65,0.4);
  transition:all 0.15s ease;
  border:3px solid #ffffff;
}
input[type="range"]::-webkit-slider-thumb:hover{
  background:#59747c;
  transform:scale(1.15);
  box-shadow:0 4px 12px rgba(8,49,65,0.5);
}
input[type="range"]::-webkit-slider-thumb:active{
  cursor:grabbing;
  transform:scale(1.2);
  background:#4a5f66;
}
input[type="range"]::-moz-range-thumb{
  width:24px;
  height:24px;
  border-radius:50%;
  background:#083141;
  cursor:grab;
  border:3px solid #ffffff;
  box-shadow:0 2px 8px rgba(8,49,65,0.4);
  transition:all 0.15s ease;
}
input[type="range"]::-moz-range-thumb:hover{
  background:#59747c;
  transform:scale(1.15);
  box-shadow:0 4px 12px rgba(8,49,65,0.5);
}
input[type="range"]::-moz-range-thumb:active{
  cursor:grabbing;
  transform:scale(1.2);
  background:#4a5f66;
}
