/* Retirement Withdrawal Strategy Calculator - Scoped styles */
/* Matches hybrid-pension-calculator styling pattern */

.rws-root {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  box-sizing: border-box !important;
  width: 100% !important;
  max-width: 100% !important;
  display: block !important;
  margin: 0 auto !important;
  padding: 0 !important;
  clear: both !important;
  float: none !important;
}

.rws-app {
  --rws-bg: #fef7ff;
  --rws-card: #ffffff;
  --rws-border: #e9d5ff;
  --rws-text: #0f172a;
  --rws-muted: #475569;
  --rws-primary: #9333ea;
  --rws-primary-hover: #7e22ce;
  --rws-success: #16a34a;
  --rws-danger: #dc2626;
  --rws-warn: #d97706;
  --rws-soft: #f3e8ff;
  --rws-table: #faf5ff;
  --rws-pastel-blue: #e0f2fe;
  --rws-pastel-green: #dcfce7;
  --rws-pastel-yellow: #fef9c3;
  --rws-pastel-pink: #fce7f3;
  --rws-pastel-purple: #f3e8ff;
  
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--rws-text);
  background: var(--rws-bg);
  border: 2px solid var(--rws-border);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(147, 51, 234, 0.08);
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  box-sizing: border-box;
  display: block;
}

.rws-app * { box-sizing: border-box; }

.rws-loading {
  padding: 2rem;
  text-align: center;
  color: var(--rws-muted);
}

/* Hero section */
.rws-hero {
  background: linear-gradient(135deg, var(--rws-pastel-purple), #ffffff);
  border: 2px solid var(--rws-border);
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 6px 20px rgba(147, 51, 234, 0.1);
  margin-bottom: 24px;
}

.rws-title {
  margin: 0 0 12px 0;
  line-height: 1.3;
  font-size: 28px;
  font-weight: 800;
  color: var(--rws-text);
}

.rws-subtitle {
  margin: 0;
  color: var(--rws-muted);
  font-size: 15px;
  line-height: 1.6;
  font-weight: 400;
}

/* Instruction tip */
.rws-inst {
  background: var(--rws-soft);
  border: 2px dashed var(--rws-border);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 14px;
  color: var(--rws-muted);
  margin-bottom: 20px;
  text-align: center;
}

/* Cards - Row-based layout */
.rws-card {
  background: var(--rws-card);
  border: 2px solid var(--rws-border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 4px 12px rgba(147, 51, 234, 0.06);
  margin-bottom: 20px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.rws-card.profile {
  background: linear-gradient(135deg, var(--rws-pastel-blue), #ffffff);
  border-color: #bae6fd;
}

.rws-card.accounts {
  background: linear-gradient(135deg, var(--rws-pastel-green), #ffffff);
  border-color: #86efac;
}

.rws-card.strategy {
  background: linear-gradient(135deg, var(--rws-pastel-yellow), #ffffff);
  border-color: #fde047;
}

.rws-card.results {
  background: linear-gradient(135deg, #ffffff, var(--rws-soft));
  border-color: var(--rws-primary);
  border-width: 3px;
}

/* Section titles */
.rws-card h3 {
  margin: 0 0 16px 0;
  line-height: 1.3;
  font-size: 22px;
  font-weight: 700;
  color: var(--rws-text);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Section descriptions */
.rws-section-desc {
  font-size: 14px;
  color: var(--rws-muted);
  line-height: 1.6;
  margin-bottom: 20px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 12px;
  border-left: 4px solid var(--rws-primary);
}

/* Grid - Row-based (single column) */
.rws-grid {
  display: grid;
  gap: 12px;
}

.rws-grid-2 {
  grid-template-columns: 1fr;
  gap: 16px;
}

/* Fields */
.rws-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.rws-field:last-child {
  margin-bottom: 0;
}

.rws-field label {
  font-size: 14px;
  font-weight: 600;
  color: var(--rws-text);
  margin-bottom: 4px;
}

.rws-input {
  width: 100%;
  border: 2px solid #e9d5ff;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  background: #ffffff;
  color: var(--rws-text);
  outline: none;
  transition: all 0.2s ease;
}

.rws-input:focus {
  border-color: var(--rws-primary);
  box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.1);
}

.rws-hint {
  font-size: 13px;
  color: var(--rws-muted);
  line-height: 1.5;
  margin-top: 4px;
  font-style: italic;
}

/* KPIs / Summary cards */
.rws-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  margin-top: 24px;
  margin-bottom: 32px;
}

@media (max-width: 980px) {
  .rws-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .rws-kpis {
    grid-template-columns: 1fr;
  }
}

.rws-kpi {
  border: 2px solid var(--rws-border);
  border-radius: 16px;
  padding: 20px;
  background: #ffffff;
  transition: all 0.2s ease;
}

.rws-kpi:hover {
  border-color: var(--rws-primary);
  box-shadow: 0 4px 12px rgba(147, 51, 234, 0.1);
}

.rws-kpi-highlight {
  border: 3px solid var(--rws-primary);
  background: linear-gradient(135deg, var(--rws-soft), #ffffff);
  box-shadow: 0 4px 16px rgba(147, 51, 234, 0.15);
}

.rws-kpi-label {
  font-size: 14px;
  color: var(--rws-muted);
  margin-bottom: 12px;
  font-weight: 600;
  text-transform: none;
}

.rws-kpi-highlight .rws-kpi-label {
  color: var(--rws-primary);
  font-weight: 700;
  font-size: 15px;
}

.rws-kpi-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--rws-text);
  line-height: 1.2;
  margin-bottom: 8px;
}

.rws-kpi-highlight .rws-kpi-value {
  font-size: 32px;
  color: var(--rws-primary);
}

.rws-kpi-sub {
  font-size: 13px;
  color: var(--rws-muted);
  margin-top: 8px;
  font-style: italic;
}

/* Table wrapper */
.rws-table-wrapper {
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  margin: 20px 0;
  width: 100%;
  max-width: 100%;
  border-radius: 14px;
  position: relative;
}

.rws-table-wrapper::-webkit-scrollbar {
  height: 10px;
}

.rws-table-wrapper::-webkit-scrollbar-track {
  background: var(--rws-soft);
  border-radius: 5px;
}

.rws-table-wrapper::-webkit-scrollbar-thumb {
  background: var(--rws-primary);
  border-radius: 5px;
}

.rws-table-wrapper::-webkit-scrollbar-thumb:hover {
  background: var(--rws-primary-hover);
}

.rws-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  overflow: hidden;
  border: 1px solid var(--rws-border);
  border-radius: 14px;
  min-width: 1500px;
}

.rws-table th,
.rws-table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--rws-border);
  text-align: right;
  white-space: nowrap;
}

.rws-table th {
  background: var(--rws-table);
  font-weight: 800;
  color: #0f172a;
}

.rws-table th:first-child,
.rws-table td:first-child {
  text-align: left;
}

.rws-table tr:last-child td {
  border-bottom: none;
}

.rws-table tr:nth-child(even) td {
  background: var(--rws-soft);
}

.rws-table tr:hover td {
  background: var(--rws-pastel-blue);
}

/* Export/CSV section - at bottom */
.rws-export-section {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 2px solid var(--rws-border);
  text-align: center;
}

.rws-btn-export {
  appearance: none;
  border: 2px solid var(--rws-primary);
  background: var(--rws-primary);
  color: #ffffff;
  padding: 14px 24px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.rws-btn-export:hover {
  background: var(--rws-primary-hover);
  border-color: var(--rws-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(147, 51, 234, 0.3);
}

.rws-export-help {
  margin-top: 12px;
  font-size: 13px;
  color: var(--rws-muted);
  font-style: italic;
}

/* Responsive */
@media (max-width: 1280px) {
  .rws-app {
    width: 100% !important;
    max-width: 100% !important;
    padding: 16px !important;
  }
}

@media (max-width: 768px) {
  .rws-app {
    padding: 12px !important;
    border-radius: 16px;
  }

  .rws-title {
    font-size: 24px;
  }

  .rws-card h3 {
    font-size: 20px;
  }

  .rws-card {
    padding: 20px;
  }

  .rws-table-wrapper {
    font-size: 12px;
  }

  .rws-table th,
  .rws-table td {
    padding: 8px;
  }
}

/* Print styles */
@media print {
  .rws-app {
    box-shadow: none;
    border-radius: 0;
    border: 1px solid #000;
    max-width: 100%;
    padding: 1rem;
  }

  .rws-root {
    color: #000000;
  }

  .rws-table-wrapper {
    overflow: visible;
  }

  .rws-btn-export {
    display: none;
  }

  .rws-inst {
    display: none;
  }
}
