.percentage-shell {
  width: min(1120px, calc(100% - 32px));
}

.percentage-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.92fr);
  gap: 16px;
  align-items: start;
}

.percentage-tool,
.percentage-results,
.percentage-reference,
.percentage-related {
  border: 1px solid rgba(20, 24, 30, 0.1);
  border-radius: 14px;
  box-shadow: 0 18px 34px -30px rgba(15, 23, 42, 0.7);
}

.percentage-tool > h1 {
  margin: 0 0 12px;
  font-size: 32px;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: #101828;
}

.percentage-intro,
.percentage-related > p {
  margin: 0 0 14px;
  color: #374151;
  font-size: 15px;
  line-height: 1.6;
}

.percentage-mode-bar {
  margin: 0 0 18px;
  border: 1px solid #d6e2f2;
  border-radius: 12px;
  background: linear-gradient(180deg, #fbfdff 0%, #f7f9ff 100%);
  padding: 10px;
}

.percentage-mode-title {
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #475569;
  font-weight: 700;
}

.percentage-mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.percentage-mode-tab {
  border: 1px solid #bfd1ef;
  background: #ffffff;
  color: #1f3f82;
  border-radius: 999px;
  min-height: 36px;
  padding: 0 14px;
  font-size: clamp(11px, 1.2vw, 13px);
  line-height: 1.2;
  font-weight: 700;
  cursor: pointer;
}

.percentage-mode-tab.is-active {
  border-color: #1b56c0;
  background: #1b56c0;
  color: #ffffff;
}

.percentage-mode-description {
  margin: 10px 0 0;
  font-size: 13px;
  color: #334155;
}

.percentage-form {
  display: grid;
  gap: 12px;
}

.percentage-mode-form[hidden] {
  display: none;
}

.percentage-inline-form {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.percentage-inline-field {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.percentage-inline-field-value {
  width: 220px;
}

.percentage-inline-field-percent {
  width: 200px;
}

.percentage-inline-field-select {
  width: 160px;
}

.percentage-inline-copy {
  color: #111827;
  font-size: 18px;
  font-weight: 500;
  line-height: 44px;
  white-space: nowrap;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.percentage-inline-field input,
.percentage-select-input select {
  width: 100%;
  min-height: 44px;
  border: 1px solid #c8d3e7;
  border-radius: 10px;
  background: #ffffff;
  color: #111827;
  font-size: 15px;
  padding: 0 12px;
  box-sizing: border-box;
}

.percentage-inline-field input:focus,
.percentage-select-input select:focus,
.percentage-affix-input:focus-within {
  outline: none;
  border-color: #2f6fdf;
  box-shadow: 0 18px 34px -30px rgba(15, 23, 42, 0.7);
}

.percentage-affix-input {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: stretch;
  border: 1px solid #c8d3e7;
  border-radius: 10px;
  overflow: hidden;
  background: #ffffff;
}

.percentage-affix-input input {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.percentage-affix {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  padding: 0 12px;
  color: #0f2454;
  font-weight: 700;
  border-left: 1px solid #bcc8df;
  background: #f4f7fd;
}

.percentage-select-input select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--rp-select-chevron-color, #334155) 50%),
    linear-gradient(135deg, var(--rp-select-chevron-color, #334155) 50%, transparent 50%);
  background-repeat: no-repeat;
  background-position:
    calc(100% - var(--rp-select-chevron-right, 18px)) 50%,
    calc(100% - var(--rp-select-chevron-right-inner, 13px)) 50%;
  background-size:
    var(--rp-select-chevron-size, 5px) var(--rp-select-chevron-size, 5px),
    var(--rp-select-chevron-size, 5px) var(--rp-select-chevron-size, 5px);
  padding-right: var(--rp-select-padding-right, 36px);
}

.percentage-feedback {
  min-height: 1.4em;
  margin: 0;
  color: #b42318;
  font-size: 13px;
}

.percentage-feedback.is-success {
  color: #166534;
}

.percentage-results > h2 {
  margin: 0 0 12px;
  font-size: 22px;
  color: #101828;
  min-width: 0;
}

.percentage-kpis {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  min-width: 0;
}

.percentage-kpis article {
  border: 1px solid #d6e2f2;
  border-radius: 12px;
  background: #ffffff;
  padding: 12px;
  min-width: 0;
  max-width: 100%;
  overflow: visible;
}

.percentage-kpis h3 {
  margin: 0 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #667085;
}

.percentage-result-display {
  position: relative;
  margin: 0;
  min-width: 0;
  max-width: 100%;
  overflow: visible;
}

.percentage-result-display .calc-display-text {
  display: block;
  margin: 0;
  max-width: 100%;
  min-width: 0;
  width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: clip;
  line-height: 1.1;
  font-size: clamp(28px, 4vw, 38px);
  color: #101828;
  padding-right: 56px;
  box-sizing: border-box;
  cursor: pointer;
}

.percentage-result-display .calc-display-toggle {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(20, 24, 30, 0.12);
  background: #f3f4f6;
  color: #3c4651;
  font-size: 12px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 999px;
  cursor: pointer;
  z-index: 6;
}

.percentage-result-display .calc-display-text.has-toggle + .calc-display-toggle,
.percentage-result-display.is-expanded .calc-display-toggle {
  display: inline-flex;
}

.percentage-result-display .calc-display-popover {
  position: absolute;
  right: 0;
  left: 0;
  top: calc(100% + 8px);
  background: #ffffff;
  border: 1px solid rgba(20, 24, 30, 0.12);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
  color: #151a1f;
  box-shadow: 0 18px 34px -30px rgba(15, 23, 42, 0.7);
  display: none;
  max-height: 220px;
  overflow: auto;
  word-break: break-word;
  overflow-wrap: anywhere;
  z-index: 5;
  white-space: pre-wrap;
  cursor: pointer;
  box-sizing: border-box;
  z-index: 12;
}

.percentage-result-display.is-expanded .calc-display-popover {
  display: block;
}

.percentage-result-display .calc-copy-toast {
  position: absolute;
  right: 0;
  bottom: -36px;
  background: rgba(32, 37, 44, 0.92);
  color: #f8fafc;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.percentage-result-display .calc-copy-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.percentage-result-sentence {
  margin: 12px 0 0;
  color: #334155;
  line-height: 1.6;
}

.percentage-reference {
  margin-top: 18px;
  background: #ffffff;
  padding: 18px;
}

.percentage-reference h2,
.percentage-related h2 {
  margin: 0 0 14px;
  font-size: 22px;
  color: #101828;
}

.percentage-reference p {
  margin: 0 0 14px;
  color: #334155;
  line-height: 1.72;
}

.percentage-equation,
.percentage-example {
  font-weight: 800;
  color: #0f172a;
  text-align: center;
}

.percentage-related {
  margin-top: 18px;
}

.percentage-related-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.percentage-related-card {
  display: grid;
  gap: 6px;
  min-height: 118px;
  padding: 16px;
  border: 1px solid #dbe5f4;
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  text-decoration: none;
  box-shadow: 0 16px 34px -30px rgba(15, 23, 42, 0.65);
}

.percentage-related-card strong {
  color: #0f172a;
  font-size: 1rem;
}

.percentage-related-card span {
  color: #475569;
  line-height: 1.55;
}

.percentage-related-card:hover,
.percentage-related-card:focus-visible {
  border-color: #1b56c0;
  box-shadow: 0 20px 38px -28px rgba(27, 86, 192, 0.38);
}

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

  .percentage-related-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .percentage-shell {
    width: min(100% - 16px, 1120px);
  }

  .percentage-tool > h1 {
    font-size: 28px;
  }

  .percentage-intro {
    font-size: 14px;
  }

  .percentage-kpis {
    grid-template-columns: 1fr;
  }

  .percentage-result-display .calc-display-text {
    font-size: clamp(24px, 8vw, 34px);
  }

  .percentage-related-grid {
    grid-template-columns: 1fr;
  }

  .percentage-inline-form {
    align-items: stretch;
  }

  .percentage-inline-field-value,
  .percentage-inline-field-percent,
  .percentage-inline-field-select {
    width: 100%;
  }

  .percentage-inline-copy {
    line-height: 1.4;
  }

  .percentage-reference {
    padding: 14px;
  }
}
