/* Include both calculator roots: the mobile layout and the legal example. */
:where(.refi-mobile-scope, .refi-mobile-scope *, .refi-calculator, .refi-calculator *) {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.refi-mobile-scope,
.refi-calculator {
  color: #333;
}

.refi-mobile-scope :where(button, input, select, textarea) {
  font-family: inherit;
}

.refi-calculator span[id^="repre-"] {
  font-weight: 700;
}

.refi-mobile-scope h2 {
  font-size: 24px;
  font-weight: 700;
  color: #333;
  margin-bottom: 0;
}

.refi-calculator {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 24px;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.refi-mobile-scope .container-refi,
.refi-mobile-scope .result-container {
  min-width: 0;
  max-width: 400px;
  margin: 0 auto;
  padding: 4px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.refi-mobile-scope .result-container {
  flex: 1;
  width: 100%;
  max-width: none;
}

.refi-calculator canvas {
  max-width: 100%;
}

.refi-mobile-scope .legal-text,
.refi-calculator .legal-text {
  font-size: 12px;
  color: #555;
  line-height: 1.4;
}

.refi-mobile-scope p.legal-text {
  margin: 8px 0 0;
}

.refi-calculator .legal-text summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: #333;
}

.refi-calculator .legal-text summary::-webkit-details-marker {
  display: none;
}

.refi-calculator .legal-text summary::before {
  content: '';
  width: 8px;
  height: 8px;
  border-right: 2px solid #1a56db;
  border-bottom: 2px solid #1a56db;
  transform: rotate(-45deg);
  transition: transform 0.2s ease;
  margin-top: -1px;
}

.refi-calculator .legal-text[open] summary::before {
  transform: rotate(45deg);
}

.refi-calculator .legal-text p {
  margin-top: 10px;
}

.refi-mobile-scope #legal-count {
  font-size: 14px;
  color: #555;
  line-height: 1.4;
}

.refi-mobile-scope .container-group,
.refi-calculator .container-group {
  margin: 0 auto 4px;
  padding: 20px;
  background: #fff;
  border: 1px solid #c5c6d1;
  border-radius: 10px;
}

.refi-mobile-scope .container-group.cta {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
}

.refi-mobile-scope .container-group.legal,
.refi-calculator .container-group.legal {
  width: 100%;
  border-radius: 12px;
}

.refi-mobile-scope .refi-calculator .input-group {
  display: block;
}

.refi-mobile-scope .refi-calculator .input-group,
.refi-mobile-scope .refi-calculator .select-group {
  margin-bottom: 16px;
  padding-top: 16px;
}

.refi-mobile-scope .select-group:first-child,
.refi-mobile-scope .refi-calculator .input-group:first-child {
  padding-top: 0;
}

.refi-mobile-scope .refi-calculator .input-group:last-child,
.refi-mobile-scope .refi-calculator .select-group:last-child {
  margin-bottom: 0;
}

.refi-mobile-scope .result-block {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.refi-mobile-scope .result-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  border-right: 1px solid #e0e0e0;
}

.refi-mobile-scope .result-item:last-child {
  border-right: none;
}

.refi-mobile-scope .container-group.tb {
  border-color: #1a56db;
  color: #1a56db;
  background: #f0f5ff;
}

.refi-mobile-scope .cta-button {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-height: 48px;
  border: 1px solid #1a56db;
  border-radius: 50px;
  background: #1a56db;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.refi-mobile-scope .result-container .container-group {
  border: none;
}

.refi-mobile-scope .chart-wrap,
.refi-mobile-scope .container-group.top-result {
  position: relative;
}

.refi-mobile-scope .chart-overlay,
.refi-mobile-scope .top-result-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  border-radius: 10px;
  font-weight: 700;
}

.refi-mobile-scope .chart-overlay {
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 18px;
  z-index: 2;
}

.refi-mobile-scope .top-result-overlay {
  background: rgba(255, 255, 255, 0.8);
  color: #1f2937;
  font-size: 16px;
  z-index: 3;
}

.refi-mobile-scope .chart-overlay.is-visible,
.refi-mobile-scope .top-result-overlay.is-visible {
  display: flex;
}

.refi-mobile-scope .cta-button:hover {
  background: #1443b0;
  border-color: #1443b0;
}

.refi-mobile-scope .cta-button.secondary {
  background: #333;
}

.refi-mobile-scope .cta-button.secondary:hover {
  background: #000;
}

.refi-mobile-scope .cta-button:active {
  transform: translateY(1px);
}

.refi-mobile-scope .relust-number {
  font-size: 32px;
  font-weight: 700;
  color: #1a56db;
  margin-bottom: 0;
}

.refi-mobile-scope #aktualna-splatka {
  color: #50525b;
}

.refi-mobile-scope .relust-number.is-negative {
  color: #dc2626;
}

.refi-mobile-scope .input-label,
.refi-mobile-scope .result-name {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: #333;
  margin-bottom: 12px;
}

.refi-mobile-scope .input-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 22px;
}

.refi-mobile-scope .btn-adjust {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: 1px solid #e0e0e0;
  background: #fff;
  border-radius: 8px;
  font-size: 24px;
  font-weight: 300;
  color: #666;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.refi-mobile-scope .btn-adjust:hover {
  border-color: #1a56db;
  color: #1a56db;
}

.refi-mobile-scope .btn-adjust:active {
  background: #f0f5ff;
}

.refi-mobile-scope .btn-adjust:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.refi-mobile-scope .input-value {
  flex: 1;
  min-width: 0;
  height: 48px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  color: #333;
  outline: none;
  transition: border-color 0.2s ease;
}

.refi-mobile-scope .input-value:focus {
  border-color: #1a56db;
}

.refi-mobile-scope .input-slider {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: linear-gradient(to right, #1a56db 0%, #1a56db var(--progress, 50%), #e0e0e0 var(--progress, 50%), #e0e0e0 100%);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
  touch-action: pan-y;
}

.refi-mobile-scope .input-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  background: #1a56db;
  border-radius: 50%;
  cursor: pointer;
  border: 4px solid #fff;
  box-shadow: 0 2px 6px rgba(26, 86, 219, 0.4);
  transition: transform 0.2s ease;
}

.refi-mobile-scope .input-slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

.refi-mobile-scope .input-slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  background: #1a56db;
  border-radius: 50%;
  cursor: pointer;
  border: 4px solid #fff;
  box-shadow: 0 2px 6px rgba(26, 86, 219, 0.4);
}

.refi-mobile-scope .select-value {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  color: #333;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23666' d='M1.41.59L6 5.17 10.59.59 12 2l-6 6-6-6z'/%3E%3C/svg%3E") no-repeat right 16px center;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s ease;
}

.refi-mobile-scope .select-value:focus,
.refi-mobile-scope .select-value:hover {
  border-color: #1a56db;
}

.refi-mobile-scope .toggle-group {
  margin-top: 16px;
  margin-bottom: 16px;
}

.refi-mobile-scope .diff-duration-option {
  margin-bottom: 12px;
}

.refi-mobile-scope .diff-duration-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: #333;
  cursor: pointer;
}

.refi-mobile-scope .diff-duration-input {
  width: 16px;
  height: 16px;
}

.refi-mobile-scope .additional-loan-period,
.refi-mobile-scope .toggle-content {
  display: none;
}

.refi-mobile-scope .additional-loan-period.is-visible,
.refi-mobile-scope .toggle-content.is-active {
  display: block;
}

.refi-mobile-scope .group-divider {
  border-top: 1px solid #e0e0e0;
}

.refi-mobile-scope .toggle-options {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.refi-mobile-scope .toggle-option {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: #666;
  background: #fff;
}

.refi-mobile-scope .toggle-option-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.refi-mobile-scope .toggle-option:has(.toggle-option-input:checked) {
  border-color: #1a56db;
  color: #1a56db;
  background: #f0f5ff;
}

.refi-mobile-scope .mb-0 {
  margin-bottom: 0;
}

.refi-mobile-scope .mobile-nav-btn,
.refi-mobile-scope .mobile-back-btn {
  display: none;
}

.refi-mobile-scope .result-container .container-group.top-result {
  border: 1px solid #c5c6d1;
}

.refi-mobile-scope .container-group.chart-group {
  margin: 0 auto 4px;
  padding: 0;
  background: #fff;
  border-radius: 10px;
  border: 1px solid #c5c6d1;
}

@media (max-width: 1024px) {
  .refi-mobile-scope .result-block {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .refi-mobile-scope .result-item {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    border-right: none;
  }

  .refi-mobile-scope .container-group.cta {
    flex-direction: column;
  }

  .refi-mobile-scope .relust-number {
    font-size: 24px;
  }

  .refi-mobile-scope .result-name {
    margin: 0;
  }
}

@media (max-width: 768px) {
  .refi-mobile-scope {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    max-width: 100%;
    scroll-snap-type: x mandatory;
  }

  .refi-mobile-scope .btn-adjust {
    width: 40px;
    height: 40px;
  }

  .refi-mobile-scope .input-value,
  .refi-mobile-scope .select-value {
    height: 40px;
  }

  .refi-mobile-scope .container-group,
  .refi-calculator .container-group {
    padding: 16px;
    margin-bottom: 4px;
  }

  .refi-mobile-scope .container-group.top-result {
    margin-bottom: 4px;
    padding: 20px;
    border-radius: 10px;
    border: 1px solid #c5c6d1;
  }

  .refi-mobile-scope .refi-calculator.main-layout {
    flex-direction: row;
    align-items: flex-start;
    gap: 0;
    max-width: none;
    width: 100%;
    overflow-x: visible;
  }

  .refi-calculator {
    padding: 0;
  }

  .refi-mobile-scope .refi-calculator.main-layout > .container-refi,
  .refi-mobile-scope .refi-calculator.main-layout > .result-container {
    width: 100%;
    max-width: 100%;
    flex: 0 0 100%;
    margin: 0;
    border-radius: 0;
    overflow-x: visible;
    scroll-snap-align: start;
  }

  .refi-mobile-scope .refi-calculator.main-layout > .container-refi {
    padding-bottom: 72px;
  }

  .refi-mobile-scope .mobile-nav-btn {
    display: inline-flex;
    width: calc(100% - 32px);
    min-height: 48px;
    margin: 16px;
    align-items: center;
    justify-content: center;
    border: 1px solid #1a56db;
    border-radius: 50px;
    background: #1a56db;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
  }

  .refi-mobile-scope .mobile-back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    margin: 0 12px;
    border: none;
    border-radius: 0;
    background: #fff;
    color: #1f2937;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    width: calc(100% - 24px);
    min-height: 16px;
    transition: all 0.2s ease;
  }

  .refi-mobile-scope .mobile-back-btn:hover {
    background: #fff;
  }

  .refi-mobile-scope .container-refi,
  .refi-mobile-scope .result-container {
    box-shadow: none;
  }
}
