/* =====================================================
   Swiss Retirement Simulator — jimmysaint.com theme
   ===================================================== */

:root {
  --bg:              #0B1426;
  --bg-card:         #111D33;
  --bg-card-hover:   #162542;
  --gold:            #C9A94E;
  --gold-dim:        rgba(201,169,78,.25);
  --gold-glow:       rgba(201,169,78,.12);
  --white:           #FFF8F0;
  --white-muted:     rgba(255,248,240,.45);
  --white-subtle:    rgba(255,248,240,.12);
  --font-body:       'Inter', sans-serif;
  --font-display:    'Playfair Display', serif;

  /* Layout */
  --sidebar-w:       340px;
  --header-h:        80px;
  --radius:          6px;
  --radius-lg:       14px;
  --transition:      0.18s ease;
}

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

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- GRAIN & AMBIENT OVERLAYS ---- */
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--white);
  line-height: 1.6;
  min-height: 100vh;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.035'/%3E%3C/svg%3E");
  background-size: 200px 200px;
  pointer-events: none;
  z-index: 0;
  opacity: 0.6;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse 80% 60% at 20% 0%, rgba(201,169,78,0.06) 0%, transparent 60%),
              radial-gradient(ellipse 60% 80% at 80% 100%, rgba(91,141,239,0.04) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ---- HEADER ---- */
.site-header {
  background: rgba(11,20,38,0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--white-subtle);
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--header-h);
}

.header-inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 32px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.back-link {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.05em;
  color: var(--gold);
  text-decoration: none;
  opacity: 0.8;
  transition: opacity var(--transition);
  white-space: nowrap;
}

.back-link:hover {
  opacity: 1;
}

/* Gold ornament line */
.header-ornament {
  width: 1px;
  height: 36px;
  background: linear-gradient(to bottom, transparent, var(--gold), transparent);
  opacity: 0.4;
  flex-shrink: 0;
}

.header-titles {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.site-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: var(--white);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.site-subtitle {
  font-family: var(--font-display);
  font-size: 12.5px;
  font-style: italic;
  color: var(--white-muted);
  font-weight: 400;
  line-height: 1.3;
}

/* Gold badge */
.header-badge {
  background: var(--gold-glow);
  border: 1px solid var(--gold-dim);
  border-radius: 20px;
  padding: 5px 14px;
}

.badge-text {
  font-family: var(--font-body);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--gold);
  text-transform: uppercase;
}

/* ---- APP LAYOUT ---- */
.app-layout {
  max-width: 1600px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  align-items: start;
  position: relative;
  z-index: 1;
  min-height: calc(100vh - var(--header-h));
}

/* ---- SIDEBAR ---- */
.sidebar {
  background: var(--bg-card);
  border-right: 1px solid var(--white-subtle);
  min-height: calc(100vh - var(--header-h));
  position: sticky;
  top: var(--header-h);
  max-height: calc(100vh - var(--header-h));
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb {
  background: var(--white-subtle);
  border-radius: 4px;
}

/* Mobile toggle bar */
.sidebar-toggle-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--white-subtle);
  cursor: pointer;
  user-select: none;
}

.toggle-label {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 13px;
  color: var(--white-muted);
  letter-spacing: 0.02em;
}

.toggle-icon {
  width: 18px;
  height: 18px;
  color: var(--white-muted);
  transition: transform var(--transition);
}

.toggle-icon.rotated {
  transform: rotate(180deg);
}

.sidebar-content {
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ---- INPUT GROUPS ---- */
.input-group {
  background: rgba(255,248,240,0.03);
  border: 1px solid var(--white-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 10px;
}

.group-title {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--white-subtle);
}

.group-note {
  font-size: 11px;
  color: var(--white-muted);
  opacity: 0.7;
  margin-top: -8px;
  margin-bottom: 12px;
  line-height: 1.4;
}

.input-row {
  margin-bottom: 12px;
}

.input-row:last-child {
  margin-bottom: 0;
}

.input-row > label {
  display: block;
  font-family: var(--font-body);
  font-size: 11.5px;
  font-weight: 400;
  color: var(--white-muted);
  margin-bottom: 6px;
  line-height: 1.35;
}

.param-hint {
  font-weight: 300;
  color: rgba(255,248,240,0.3);
  font-size: 10.5px;
}

/* ---- SLIDERS ---- */
.slider-with-value {
  display: flex;
  align-items: center;
  gap: 8px;
}

.slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 3px;
  background: var(--white-subtle);
  border-radius: 4px;
  outline: none;
  cursor: pointer;
  transition: background var(--transition);
}

/* Track fill via CSS custom property updated in JS, fallback to gold */
.slider::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 4px;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 15px;
  background: var(--gold);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--gold-dim), 0 2px 6px rgba(0,0,0,0.4);
  transition: transform var(--transition), box-shadow var(--transition);
  margin-top: -6px;
}

.slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 0 3px var(--gold-dim), 0 2px 8px rgba(0,0,0,0.5);
}

.slider::-moz-range-thumb {
  width: 15px;
  height: 15px;
  background: var(--gold);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--gold-dim);
}

.slider::-moz-range-track {
  height: 3px;
  background: var(--white-subtle);
  border-radius: 4px;
}

/* ---- NUMBER INPUTS ---- */
.num-input {
  width: 58px;
  text-align: center;
  padding: 4px 6px;
  border: 1px solid var(--white-subtle);
  border-radius: var(--radius);
  font-size: 12px;
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--white);
  background: var(--bg);
  transition: border-color var(--transition);
}

.num-input:focus {
  outline: none;
  border-color: var(--gold-dim);
}

.num-input.small { width: 52px; }
.num-input.medium { width: 72px; }

.unit-label {
  font-size: 11px;
  color: var(--white-muted);
  opacity: 0.6;
  min-width: 12px;
}

/* Full-width text inputs */
.text-input {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--white-subtle);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--white);
  background: var(--bg);
  transition: border-color var(--transition);
}

.text-input:focus {
  outline: none;
  border-color: var(--gold-dim);
}

/* Select dropdown */
.select-input {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--white-subtle);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--white);
  background: var(--bg);
  cursor: pointer;
  transition: border-color var(--transition);
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='rgba(255,248,240,0.45)' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 28px;
}

.select-input:focus {
  outline: none;
  border-color: var(--gold-dim);
}

.select-input option {
  background: var(--bg-card);
  color: var(--white);
}

/* ---- TOGGLE BUTTONS ---- */
.toggle-group {
  display: flex;
  gap: 4px;
}

.toggle-btn {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid var(--white-subtle);
  background: transparent;
  border-radius: var(--radius);
  font-size: 12px;
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--white-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.toggle-btn:hover {
  background: rgba(201,169,78,0.08);
  border-color: var(--gold-dim);
  color: var(--white);
}

.toggle-btn.active {
  background: var(--gold-dim);
  border-color: var(--gold);
  color: var(--gold);
  font-weight: 500;
}

/* ---- RADIO BUTTONS ---- */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 400;
  color: var(--white-muted);
  cursor: pointer;
}

.radio-label input[type="radio"] {
  accent-color: var(--gold);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

/* ---- RUN BUTTON ---- */
.run-section {
  text-align: center;
  padding: 8px 0 6px;
}

.run-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--gold);
  color: #0B1426;
  border: none;
  border-radius: var(--radius);
  padding: 13px 28px;
  font-size: 13px;
  font-family: var(--font-body);
  font-weight: 500;
  letter-spacing: 0.04em;
  cursor: pointer;
  width: 100%;
  justify-content: center;
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
}

.run-btn:hover {
  background: #d9bc65;
  box-shadow: 0 0 20px var(--gold-dim);
  transform: translateY(-1px);
}

.run-btn:active {
  transform: translateY(0);
}

.run-btn-icon {
  font-size: 11px;
  opacity: 0.8;
}

.run-hint {
  font-size: 10.5px;
  color: rgba(255,248,240,0.25);
  margin-top: 9px;
  line-height: 1.4;
}

/* ---- MAIN PANEL ---- */
.main-panel {
  padding: 28px 32px;
  position: relative;
  min-height: calc(100vh - var(--header-h));
  background: var(--bg);
}

/* ---- LOADING OVERLAY ---- */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(11,20,38,0.88);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300; /* above grain overlays */
  border-radius: 0;
}

.loading-content {
  text-align: center;
}

.spinner {
  width: 38px;
  height: 38px;
  border: 2px solid var(--white-subtle);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  margin: 0 auto 18px;
}

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

.loading-text {
  font-family: var(--font-display);
  font-size: 15px;
  font-style: italic;
  color: var(--white);
  margin-bottom: 6px;
}

.loading-sub {
  font-size: 12px;
  color: var(--white-muted);
}

/* ---- SUMMARY CARDS ---- */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.summary-card {
  background: var(--bg-card);
  border: 1px solid var(--white-subtle);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  transition: border-color var(--transition), background var(--transition);
}

.summary-card:hover {
  border-color: rgba(255,248,240,0.2);
  background: var(--bg-card-hover);
}

/* Highlight card: gold border + glow */
.summary-card.highlight {
  border-color: var(--gold-dim);
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(201,169,78,0.07) 100%);
  box-shadow: 0 0 30px var(--gold-glow), inset 0 1px 0 rgba(201,169,78,0.15);
}

.card-label {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 8px;
  opacity: 0.9;
}

.card-value {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--white);
  line-height: 1.15;
  margin-bottom: 5px;
}

.summary-card.highlight .card-value {
  color: var(--white);
}

.card-sub {
  font-family: var(--font-body);
  font-size: 11px;
  color: var(--white-muted);
  font-weight: 300;
}

/* ---- TABS ---- */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--white-subtle);
  margin-bottom: 24px;
}

.tab-btn {
  padding: 11px 24px;
  background: none;
  border: none;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 400;
  color: var(--white-muted);
  cursor: pointer;
  position: relative;
  transition: color var(--transition);
  letter-spacing: 0.01em;
}

.tab-btn::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: transparent;
  transition: background var(--transition);
}

.tab-btn:hover { color: var(--white); }

.tab-btn.active {
  color: var(--white);
  font-weight: 500;
}

.tab-btn.active::after {
  background: var(--gold);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ---- CHART CARDS ---- */
.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--white-subtle);
  border-radius: var(--radius-lg);
  padding: 22px 26px;
  margin-bottom: 16px;
}

.chart-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 8px;
}

.chart-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  color: var(--white);
  letter-spacing: -0.01em;
}

.chart-note {
  font-family: var(--font-body);
  font-size: 11px;
  color: var(--white-muted);
  font-weight: 300;
  font-style: italic;
}

.chart-wrap {
  position: relative;
  height: 300px;
}

.chart-wrap-short {
  height: 220px;
}

/* ---- RUIN BADGES ---- */
.ruin-badge-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.ruin-badge {
  background: rgba(232,87,74,0.1);
  border: 1px solid rgba(232,87,74,0.3);
  border-radius: var(--radius);
  padding: 6px 14px;
  font-size: 12px;
  color: rgba(255,200,190,0.85);
  font-family: var(--font-body);
  font-weight: 300;
}

.ruin-badge strong {
  font-weight: 500;
  color: #e8a09a;
}

/* ---- INFO PANELS ---- */
.info-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  margin-bottom: 28px;
}

.info-panel {
  background: var(--bg-card);
  border: 1px solid var(--white-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.info-summary {
  padding: 15px 22px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  font-style: italic;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--gold);
  user-select: none;
  transition: color var(--transition);
}

.info-summary:hover {
  color: #d9bc65;
}

.info-summary::-webkit-details-marker { display: none; }

.info-summary::before {
  content: '▸';
  font-size: 11px;
  color: var(--gold);
  opacity: 0.6;
  transition: transform var(--transition);
  font-style: normal;
}

details[open] .info-summary::before {
  transform: rotate(90deg);
}

.info-content {
  padding: 0 22px 22px;
  border-top: 1px solid var(--white-subtle);
}

.params-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  padding-top: 20px;
}

.params-col h4 {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 12px;
  opacity: 0.9;
}

.params-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}

.params-table tr {
  border-bottom: 1px solid var(--white-subtle);
}

.params-table tr:last-child {
  border-bottom: none;
}

.params-table td {
  padding: 6px 0;
  vertical-align: top;
}

.params-table td:first-child {
  color: var(--white-muted);
  font-weight: 300;
  padding-right: 14px;
  width: 55%;
}

.params-table td:last-child {
  font-weight: 400;
  color: var(--white);
}

.info-content p {
  font-family: var(--font-body);
  font-size: 12.5px;
  color: var(--white-muted);
  margin-bottom: 12px;
  line-height: 1.7;
  font-weight: 300;
}

.info-content p:last-child {
  margin-bottom: 0;
}

.info-content strong {
  color: var(--white);
  font-weight: 500;
}

/* ---- DISCLAIMER ---- */
.disclaimer {
  border-top: 1px solid var(--white-subtle);
  padding: 20px 0 32px;
}

.disclaimer p {
  font-family: var(--font-body);
  font-size: 11px;
  color: rgba(255,248,240,0.25);
  line-height: 1.7;
  max-width: 900px;
  font-weight: 300;
}

/* ---- RETIREMENT CARDS ROW ---- */
#retirementCards {
  margin-bottom: 24px;
}

/* ---- NUMBER INPUT SPIN BUTTONS ---- */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  opacity: 0.4;
  filter: invert(1);
}

/* ---- TRANSITIONS ---- */
.card-value {
  transition: opacity 0.2s ease;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 1024px) {
  .summary-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 900px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    max-height: none;
    min-height: auto;
    border-right: none;
    border-bottom: 1px solid var(--white-subtle);
  }

  .sidebar-toggle-bar {
    display: flex;
  }

  .sidebar-content.collapsed {
    display: none;
  }

  .summary-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .params-grid {
    grid-template-columns: 1fr;
  }

  .main-panel {
    padding: 20px;
  }
}

@media (max-width: 640px) {
  .header-inner {
    padding: 0 20px;
  }

  .header-ornament {
    display: none;
  }

  .site-subtitle {
    display: none;
  }

  .header-badge {
    display: none;
  }

  .summary-cards {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .chart-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .tab-btn {
    padding: 10px 16px;
    font-size: 12px;
  }

  .main-panel {
    padding: 16px;
  }

  .site-title {
    font-size: 16px;
  }
}

@media (max-width: 400px) {
  .summary-cards {
    grid-template-columns: 1fr;
  }
}
