:root{
  --max: 820px;
  --pad: 20px;
  --border: #e6e6e6;
  --text: #111;
  --muted: #555;
  --bg: #fff;
  --bg-soft: #fafafa;
  --danger: #b00020;
  --radius: 12px;
  --primary: #1a73e8;
  --success: #2e7d32;
  --success-light: #4caf50;
}

*{ box-sizing: border-box; }
html{ -webkit-text-size-adjust: 100%; }
body{
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
}

/* === HEADER === */
.site-header{
  max-width: var(--max);
  margin: 0 auto;
  padding: 16px var(--pad) 0;
}

.site-logo{
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
}

.site-logo:hover{
  opacity: 0.8;
}

main{
  max-width: var(--max);
  margin: 0 auto;
  padding: 28px var(--pad) 48px;
}

h1{ font-size: 2rem; margin: 0 0 0.75rem; letter-spacing: -0.02em; }
h2{ font-size: 1.35rem; margin: 2rem 0 0.75rem; letter-spacing: -0.01em; }
h3{ font-size: 1.1rem; margin: 1.25rem 0 0.5rem; }

p{ margin: 0.75rem 0; color: var(--text); }
p small{ color: var(--muted); }

a{ color: inherit; text-decoration: underline; text-underline-offset: 3px; }
a:hover{ opacity: 0.85; }

hr{
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2rem 0 1rem;
}

/* Rechner-Card */
.card{
  border: 1px solid var(--border);
  background: var(--bg-soft);
  border-radius: var(--radius);
  padding: 16px;
  margin: 1rem 0 1.25rem;
}

label{ font-weight: 600; }
input[type="text"], input[type="number"]{
  width: min(360px, 100%);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 1rem;
  margin-top: 8px;
}

.row{
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 10px;
}

button{
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 1rem;
}
button:hover{ background: #f3f3f3; }

.btn-primary{
  border-color: #cfcfcf;
  font-weight: 600;
}

.chips button{
  padding: 8px 10px;
  font-size: 0.95rem;
}

.error{
  color: var(--danger);
  margin: 10px 0 0;
}

.result{
  border: 1px solid var(--border);
  background: #fff;
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 12px;
}

.hidden{ display: none; }

ul{ margin: 0.5rem 0 0.25rem 1.2rem; }
li{ margin: 0.25rem 0; }

.muted {
  font-size: 0.9rem;
  color: #666;
  margin: 1.2rem 0 2rem;
}

footer{
  margin-top: 28px;
  font-size: 0.95rem;
  color: var(--muted);
}

/* === SLIDER KOMPONENTE === */

.slider-value-display{
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 20px;
}

.value-label{
  font-size: 0.95rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.value-amount{
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.02em;
}

.slider-container{
  margin: 20px 0;
}

input[type="range"]{
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 8px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

input[type="range"]::-webkit-slider-thumb{
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 3px solid white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

input[type="range"]::-moz-range-thumb{
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 3px solid white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

input[type="range"]:focus{
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.slider-labels{
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 8px;
}

/* === BEISPIEL-BUTTONS === */

.example-buttons{
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 16px 0;
}

.btn-example{
  flex: 1;
  min-width: 140px;
  padding: 12px 16px;
  font-size: 0.95rem;
  background: white;
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.btn-example:hover{
  border-color: var(--primary);
  background: #f8f9fa;
}

.btn-example:active{
  transform: scale(0.98);
}

@media (max-width: 480px){
  .btn-example{
    flex-basis: 100%;
  }
}

/* === MONATE-DROPDOWN === */

.months-selector{
  margin: 16px 0;
}

.months-selector label{
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 8px;
}

.months-selector select{
  width: 100%;
  max-width: 360px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 1rem;
  cursor: pointer;
}

.months-hint{
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 8px;
  margin-bottom: 0;
}

/* === EXPORT BUTTONS === */

.export-buttons {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.btn-email,
.btn-print {
  flex: 1;
  min-width: 200px;
  padding: 12px 20px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid;
}

.btn-email {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.btn-email:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.btn-print {
  background: white;
  border-color: var(--primary);
  color: var(--primary);
}

.btn-print:hover {
  background: var(--primary);
  color: white;
}

@media (max-width: 480px) {
  .export-buttons {
    flex-direction: column;
  }

  .btn-email,
  .btn-print {
    min-width: 100%;
  }
}

/* === COMPARISON GRID === */

.comparison-results{
  margin-top: 24px;
}

.period-toggle{
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}

.toggle-switch{
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.toggle-switch input[type="checkbox"]{
  position: absolute;
  opacity: 0;
}

.toggle-label{
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
}

.toggle-label span{
  padding: 8px 16px;
  border-radius: 8px;
  transition: all 0.3s;
  color: var(--muted);
}

.toggle-switch input:not(:checked) ~ .toggle-label .monthly-label{
  background: var(--primary);
  color: white;
}

.toggle-switch input:checked ~ .toggle-label .annual-label{
  background: var(--primary);
  color: white;
}

.comparison-grid{
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

@media (min-width: 768px){
  .comparison-grid{
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
  }
}

/* === SZENARIO-CARDS === */

.scenario-card{
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  background: white;
}

.scenario-old{
  border-color: #ddd;
}

.scenario-new{
  border-color: var(--primary);
  background: #f8fbff;
}

.scenario-header{
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.scenario-header h3{
  margin: 0 0 4px;
  font-size: 1.25rem;
}

.scenario-subtitle{
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

/* === BREAKDOWN ITEMS === */

.breakdown{
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.breakdown-item{
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
}

.breakdown-item .label{
  font-size: 0.95rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 4px;
}

.breakdown-item .value{
  font-weight: 600;
  font-size: 1rem;
}

.breakdown-item.deduction .value{
  color: #d32f2f;
}

.breakdown-item.highlight-positive{
  background: #e8f5e9;
  padding: 8px 12px;
  border-radius: 8px;
  margin: 4px -12px;
}

.breakdown-item.highlight-positive .value{
  color: var(--success);
}

.breakdown-total{
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 2px solid var(--border);
}

.breakdown-total .label{
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.model-note{
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--muted);
  font-style: italic;
}

.breakdown-total .value{
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

/* === MODEL CALCULATION HINT === */

.model-hint{
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 20px 0;
  font-style: italic;
}

/* === SAVINGS BANNER === */

.savings-banner{
  background: linear-gradient(135deg, var(--success) 0%, var(--success-light) 100%);
  color: white;
  padding: 20px;
  border-radius: var(--radius);
  text-align: center;
  margin-bottom: 24px;
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.savings-content{
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

@media (min-width: 640px){
  .savings-content{
    flex-direction: row;
    justify-content: center;
    gap: 12px;
  }
}

.savings-label{
  font-size: 1rem;
  font-weight: 500;
}

.savings-amount{
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.savings-percent{
  font-size: 1.25rem;
  font-weight: 600;
  opacity: 0.9;
}

/* === INFO-ICONS (TOOLTIPS) === */

.info-icon{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--muted);
  color: white;
  font-size: 0.75rem;
  cursor: help;
  margin-left: 4px;
  position: relative;
  font-style: normal;
}

.info-icon:hover::after,
.info-icon:active::after{
  content: attr(title);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 12px;
  background: #333;
  color: white;
  font-size: 0.85rem;
  line-height: 1.4;
  border-radius: 6px;
  white-space: normal;
  max-width: 280px;
  z-index: 10;
  margin-bottom: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  text-align: center;
}

/* Mobile: Prevent overflow at viewport edges */
@media (max-width: 768px) {
  .info-icon:hover::after,
  .info-icon:active::after {
    max-width: calc(100vw - 40px);
    left: auto;
    right: auto;
    transform: translateX(-50%);
  }

  /* Wenn Icon am rechten Rand: Tooltip nach links ausrichten */
  .breakdown-item:last-child .info-icon:hover::after,
  .breakdown-item:last-child .info-icon:active::after {
    left: auto;
    right: 0;
    transform: translateX(0);
  }
}

/* === BALKENDIAGRAMM === */

.comparison-chart{
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  background: var(--bg-soft);
  border-radius: var(--radius);
  margin-bottom: 24px;
}

.chart-bar{
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chart-label{
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.bar-container{
  display: flex;
  align-items: center;
  gap: 12px;
}

.bar{
  height: 32px;
  border-radius: 6px;
  transition: width 0.5s ease;
  min-width: 40px;
}

.bar-old{
  background: linear-gradient(90deg, #bdbdbd 0%, #9e9e9e 100%);
}

.bar-new{
  background: linear-gradient(90deg, var(--success-light) 0%, var(--success) 100%);
}

.bar-value{
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
}

/* Mobile: Balkendiagramm optimieren */
@media (max-width: 768px) {
  .comparison-chart {
    gap: 24px; /* Mehr Abstand zwischen Balken */
    padding: 24px 16px;
  }

  .chart-bar {
    gap: 10px;
  }

  .chart-label {
    font-size: 0.95rem;
  }

  .bar {
    height: 48px; /* Doppelt so hoch wie Desktop */
    min-width: 60px; /* Größere Mindestbreite */
  }

  .bar-value {
    font-size: 1.05rem; /* Größere Schrift */
    font-weight: 700;
  }

  .bar-container {
    gap: 8px;
  }
}

/* === DISCLAIMER === */

.disclaimer{
  padding: 16px;
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.disclaimer p{
  margin: 0;
}

/* === INFO CARDS === */

.info-cards{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin: 24px 0;
}

.info-card{
  padding: 20px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.2s;
}

.info-card:hover{
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(26, 115, 232, 0.1);
  transform: translateY(-2px);
}

.info-card h3{
  margin: 0 0 8px 0;
  font-size: 1.1rem;
}

.info-card h3 a{
  color: var(--primary);
  text-decoration: none;
}

.info-card h3 a:hover{
  text-decoration: underline;
}

.info-card p{
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.5;
}

/* === CTA BOX === */

.cta-box{
  padding: 16px 20px;
  background: linear-gradient(135deg, #f0f7ff 0%, #e8f4f8 100%);
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  margin: 20px 0;
}

.cta-box a{
  color: var(--primary);
  text-decoration: none;
  font-size: 1.05rem;
}

.cta-box a:hover{
  text-decoration: underline;
}

/* === RESULT CTA === */

.result-cta{
  text-align: center;
  padding: 24px 20px;
  margin-top: 24px;
  background: var(--bg-soft);
  border-radius: var(--radius);
}

.result-cta p{
  margin: 8px 0;
}

.result-cta p:first-child{
  font-size: 1.1rem;
  color: var(--text);
}

.result-cta a{
  color: var(--primary);
  font-weight: 500;
  text-decoration: none;
  padding: 0 8px;
}

.result-cta a:hover{
  text-decoration: underline;
}

/* === PRINT STYLES === */

@media print{
  .slider-container,
  .example-buttons,
  .period-toggle,
  .export-buttons,
  .btn-print,
  .btn-email,
  .months-selector,
  .result-cta,
  .cta-box,
  .info-cards{
    display: none !important;
  }

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

  .scenario-card{
    break-inside: avoid;
  }

  .savings-banner{
    break-inside: avoid;
  }

  .comparison-chart{
    break-inside: avoid;
  }

  footer{
    display: none;
  }
}
