/* Capital Gains Harvesting / Bed-and-ISA Calculator (UK) */

:root {
  --cghbi-ink: #0f172a;
  --cghbi-muted: #475569;
  --cghbi-navy: #083141;
}

#cghbi-root.cghbi-app,
.cghbi-root.cghbi-app {
  width: auto;
  max-width: none;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  padding: 0 14px;
  box-sizing: border-box;
  overflow-x: hidden;
}

.cghbi-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 18px 30px;
  border: 2px solid rgba(8, 49, 65, 0.18);
  border-radius: 22px;
  box-shadow: 0 20px 60px rgba(2, 6, 23, 0.1);
  background: #fff;
  color: var(--cghbi-ink);
}

.cghbi-hero {
  border: 1px solid rgba(8, 49, 65, 0.2);
  border-radius: 18px;
  padding: 22px;
  background: linear-gradient(135deg, #fff 0%, #f0f9ff 52%, #e0f2fe 100%);
}

.cghbi-title {
  margin: 0 0 8px;
  font-size: clamp(1.4rem, 3.4vw, 2rem);
  font-weight: 950;
  color: var(--cghbi-navy);
}

.cghbi-sub {
  margin: 0;
  color: var(--cghbi-muted);
  font-weight: 650;
  line-height: 1.55;
}

.cghbi-hero-context {
  margin: 12px 0 0;
  color: #0c4a6e;
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.5;
}

.cghbi-card {
  margin-top: 16px;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 18px;
  background: #fff;
}

.cghbi-card--inputs {
  border: 2px solid rgba(8, 49, 65, 0.2);
  border-left: 5px solid var(--cghbi-navy);
  background: linear-gradient(165deg, #f1f5f9 0%, #fff 42%);
}

.cghbi-h3 {
  margin: 0 0 10px;
  font-size: 1.2rem;
  font-weight: 950;
  color: var(--cghbi-navy);
}

.cghbi-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

@media (min-width: 700px) {
  .cghbi-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.cghbi-field {
  display: grid;
  gap: 6px;
}

.cghbi-field--full {
  grid-column: 1 / -1;
}

.cghbi-label {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--cghbi-navy);
}

.cghbi-hint {
  margin: 0;
  color: #64748b;
  font-size: 0.8rem;
  line-height: 1.4;
}

.cghbi-input {
  width: 100%;
  padding: 12px;
  border: 2px solid rgba(8, 49, 65, 0.2);
  border-radius: 12px;
  box-sizing: border-box;
  font-size: max(16px, 1rem);
}

.cghbi-input:focus {
  outline: none;
  border-color: rgba(14, 116, 144, 0.55);
  box-shadow: 0 0 0 5px rgba(14, 116, 144, 0.12);
}

.cghbi-scenario-options {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 2px solid rgba(8, 49, 65, 0.12);
  display: grid;
  gap: 16px;
}

.cghbi-scenario-block {
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid rgba(8, 49, 65, 0.16);
  background: rgba(255, 255, 255, 0.92);
}

.cghbi-scenario-block--spouse {
  background: linear-gradient(145deg, #f8fafc 0%, #fff 100%);
}

.cghbi-scenario-block-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 900;
  color: var(--cghbi-navy);
  margin: 0 0 6px;
}

.cghbi-scenario-block-hint {
  margin: 0 0 14px;
  font-size: 0.82rem;
  font-weight: 650;
  color: #64748b;
  line-height: 1.45;
  max-width: 52rem;
}

.cghbi-radio-group {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
}

@media (min-width: 560px) {
  .cghbi-radio-group {
    grid-template-columns: 1fr 1fr;
  }
}

.cghbi-radio-pill {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px 14px 44px;
  border-radius: 12px;
  border: 2px solid rgba(8, 49, 65, 0.18);
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.cghbi-radio-pill:hover {
  border-color: rgba(14, 116, 144, 0.45);
  background: #f8fafc;
}

.cghbi-radio-pill input {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 1.15rem;
  height: 1.15rem;
  margin: 0;
  accent-color: #0e7490;
  cursor: pointer;
}

.cghbi-radio-pill:has(input:checked) {
  border-color: rgba(14, 116, 144, 0.55);
  background: linear-gradient(145deg, #ecfeff 0%, #fff 70%);
  box-shadow: 0 4px 14px rgba(14, 116, 144, 0.12);
}

.cghbi-radio-pill:has(input:focus-visible) {
  outline: 3px solid rgba(56, 189, 248, 0.45);
  outline-offset: 2px;
}

.cghbi-radio-pill-title {
  font-size: 0.92rem;
  font-weight: 900;
  color: var(--cghbi-navy);
  line-height: 1.3;
}

.cghbi-radio-pill-note {
  font-size: 0.78rem;
  font-weight: 650;
  color: #64748b;
  line-height: 1.35;
}

.cghbi-check-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  cursor: pointer;
  margin: 0;
}

.cghbi-check-card-input {
  flex-shrink: 0;
  width: 1.2rem;
  height: 1.2rem;
  margin: 2px 0 0;
  accent-color: #0e7490;
  cursor: pointer;
}

.cghbi-check-card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.cghbi-check-card-title {
  font-size: 0.92rem;
  font-weight: 900;
  color: var(--cghbi-navy);
  line-height: 1.35;
}

.cghbi-check-card-hint {
  font-size: 0.82rem;
  font-weight: 650;
  color: #64748b;
  line-height: 1.45;
}

.cghbi-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;
}

.cghbi-results {
  margin-top: 20px;
  padding: 20px 16px 10px;
  border-radius: 18px;
  background: #f8fafc;
  border: 1px solid rgba(8, 49, 65, 0.12);
}

.cghbi-results-header {
  margin: 0 0 18px;
  padding: 0 0 14px;
  border-bottom: 3px solid rgba(8, 49, 65, 0.22);
}

.cghbi-results-heading.cghbi-h3 {
  margin: 0 0 8px;
}

.cghbi-results-lead {
  margin: 0;
  color: var(--cghbi-muted);
  font-size: 0.95rem;
  font-weight: 650;
  line-height: 1.55;
}

.cghbi-results-section {
  margin: 0 0 16px;
  padding: 16px 14px;
  border-radius: 16px;
  border: 2px solid transparent;
}

.cghbi-results-section--capacity {
  border-color: rgba(14, 116, 144, 0.28);
  background: linear-gradient(145deg, #ecfeff 0%, #f0f9ff 42%, #fff 100%);
}

.cghbi-results-section--tax {
  border-color: rgba(217, 119, 6, 0.32);
  background: linear-gradient(145deg, #fffbeb 0%, #fff 55%);
}

.cghbi-results-section--compare {
  border-color: rgba(8, 49, 65, 0.2);
  background: linear-gradient(145deg, #f1f5f9 0%, #fff 60%);
}

.cghbi-section-head {
  margin: 0 0 14px;
}

.cghbi-section-kicker {
  display: block;
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cghbi-results-section--capacity .cghbi-section-kicker {
  color: #0e7490;
}

.cghbi-results-section--tax .cghbi-section-kicker {
  color: #b45309;
}

.cghbi-results-section--compare .cghbi-section-kicker {
  color: var(--cghbi-navy);
}

.cghbi-section-title {
  margin: 0 0 6px;
  font-size: 1.05rem;
  font-weight: 950;
  color: var(--cghbi-navy);
}

.cghbi-section-lead {
  margin: 0;
  color: #475569;
  font-size: 0.88rem;
  font-weight: 650;
  line-height: 1.5;
}

.cghbi-pay-hero {
  margin: 0 0 14px;
  padding: 18px 16px;
  border-radius: 14px;
  text-align: center;
  border: 2px solid transparent;
}

.cghbi-pay-hero--zero {
  border-color: rgba(22, 163, 74, 0.35);
  background: linear-gradient(145deg, #ecfdf5 0%, #fff 60%);
}

.cghbi-pay-hero--due {
  border-color: rgba(217, 119, 6, 0.4);
  background: linear-gradient(145deg, #fff7ed 0%, #fff 55%);
}

.cghbi-pay-hero-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
}

.cghbi-pay-hero-amount {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.6rem, 4.5vw, 2.1rem);
  font-weight: 950;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.cghbi-pay-hero--zero .cghbi-pay-hero-amount {
  color: #15803d;
}

.cghbi-pay-hero--due .cghbi-pay-hero-amount {
  color: #c2410c;
}

.cghbi-pay-hero-sub {
  margin: 10px auto 0;
  max-width: 40rem;
  color: #334155;
  font-size: 0.88rem;
  font-weight: 650;
  line-height: 1.5;
}

.cghbi-walk-title {
  margin: 4px 0 10px;
  font-size: 0.92rem;
  font-weight: 900;
  color: #78350f;
}

.cghbi-walkthrough {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.cghbi-walk-step {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(217, 119, 6, 0.2);
  font-size: 0.85rem;
  color: #334155;
  line-height: 1.45;
}

.cghbi-walk-step-num {
  flex-shrink: 0;
  width: 1.6rem;
  height: 1.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #b45309;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 900;
}

.cghbi-walk-step-title {
  color: #78350f;
}

.cghbi-compare-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

@media (min-width: 720px) {
  .cghbi-compare-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.cghbi-compare-card {
  padding: 14px 16px;
  border-radius: 14px;
  border: 2px solid #e2e8f0;
  background: #fff;
  text-align: center;
}

.cghbi-compare-card--passive {
  border-top: 4px solid #94a3b8;
}

.cghbi-compare-card--active {
  border-top: 4px solid #0e7490;
  background: linear-gradient(180deg, #ecfeff 0%, #fff 70%);
}

.cghbi-compare-card--saving {
  border-top: 4px solid #15803d;
  background: linear-gradient(180deg, #ecfdf5 0%, #fff 70%);
}

.cghbi-compare-card-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #64748b;
}

.cghbi-compare-card-value {
  display: block;
  margin-top: 6px;
  font-size: clamp(1.1rem, 2.8vw, 1.35rem);
  font-weight: 950;
  color: var(--cghbi-navy);
  font-variant-numeric: tabular-nums;
}

.cghbi-compare-card-note {
  margin: 8px 0 0;
  font-size: 0.8rem;
  color: #64748b;
  line-height: 1.4;
}

.cghbi-detail-panel {
  margin-top: 14px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.cghbi-detail-summary {
  cursor: pointer;
  padding: 12px 16px;
  background: #f8fafc;
  font-weight: 850;
  color: var(--cghbi-navy);
}

.cghbi-results-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

@media (min-width: 620px) {
  .cghbi-results-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.cghbi-tile {
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 14px 16px;
  background: #fff;
  border-top: 3px solid rgba(8, 49, 65, 0.2);
}

.cghbi-tile--lead {
  grid-column: 1 / -1;
  border-top-color: #0e7490;
  background: linear-gradient(135deg, #fff 0%, #ecfeff 55%, #f0fdfa 100%);
}

.cghbi-tile--capacity {
  border-top-color: #0e7490;
  background: rgba(255, 255, 255, 0.85);
}

.cghbi-tile--zero {
  border-top-color: #16a34a;
  background: linear-gradient(135deg, #fff 0%, #ecfdf5 100%);
}

.cghbi-tile--zero .cghbi-tile-value {
  color: #15803d;
}

.cghbi-tile--due {
  border-top-color: #ea580c;
  background: linear-gradient(135deg, #fff 0%, #fff7ed 100%);
}

.cghbi-tile--due .cghbi-tile-value {
  color: #c2410c;
}

.cghbi-tile-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #64748b;
}

.cghbi-tile-value {
  display: block;
  margin-top: 6px;
  font-size: clamp(1.05rem, 2.6vw, 1.3rem);
  font-weight: 950;
  color: var(--cghbi-navy);
}

.cghbi-tile-note {
  margin: 8px 0 0;
  color: #64748b;
  font-size: 0.8rem;
  line-height: 1.4;
}

.cghbi-warning-box {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 2px solid rgba(180, 83, 9, 0.32);
  background: #fffbeb;
}

.cghbi-warning-list {
  margin: 8px 0 0;
  padding-left: 1.1rem;
}

.cghbi-warning-list li {
  margin: 0 0 6px;
  color: #78350f;
  font-size: 0.85rem;
}

.cghbi-table-wrap {
  margin-top: 14px;
  overflow-x: auto;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
}

.cghbi-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  background: #fff;
}

.cghbi-table th,
.cghbi-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: top;
}

.cghbi-table thead th {
  background: #f1f5f9;
  color: var(--cghbi-navy);
  font-weight: 850;
}

.cghbi-table tbody th {
  color: #334155;
  font-weight: 700;
  width: 52%;
}

.cghbi-export {
  margin-top: 20px;
  padding: 20px;
  border-radius: 16px;
  border: 2px solid rgba(21, 94, 117, 0.3);
  background: linear-gradient(135deg, #fff 0%, #ecfeff 100%);
  text-align: center;
}

.cghbi-export-title {
  margin: 0 0 8px;
  color: var(--cghbi-navy);
  font-size: clamp(1.22rem, 3.25vw, 1.58rem);
  font-weight: 950;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.cghbi-export-sub {
  margin: 0 auto 14px;
  max-width: 42rem;
  color: var(--cghbi-muted);
  font-weight: 650;
  font-size: 0.92rem;
  line-height: 1.5;
}

.cghbi-export-btn {
  width: 100%;
  max-width: 420px;
  padding: 17px 18px;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 950;
  letter-spacing: 0.02em;
  font-family: inherit;
  background: linear-gradient(180deg, #0e7490 0%, #155e75 55%, #164e63 100%);
  box-shadow: 0 6px 0 #0c4a5f, 0 16px 34px rgba(21, 94, 117, 0.35);
  transition: filter 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.cghbi-export-btn:hover {
  filter: brightness(1.03);
}

.cghbi-export-btn:active {
  transform: translateY(2px);
  box-shadow: 0 3px 0 #0c4a5f, 0 8px 20px rgba(21, 94, 117, 0.28);
}

.cghbi-export-btn:focus-visible {
  outline: 3px solid #38bdf8;
  outline-offset: 3px;
}

.cghbi-methodology {
  margin-top: 16px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
}

.cghbi-methodology-summary {
  cursor: pointer;
  padding: 12px 16px;
  background: #f8fafc;
  font-weight: 850;
  color: var(--cghbi-navy);
}

.cghbi-methodology-body {
  padding: 0 16px 12px;
}

.cghbi-methodology-list {
  margin: 0;
  padding-left: 1.2rem;
  color: #334155;
  font-size: 0.85rem;
}

.cghbi-methodology-list li {
  margin: 0 0 6px;
}

.cghbi-results-error {
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 2px solid rgba(185, 28, 28, 0.45);
  background: #fef2f2;
  color: #991b1b;
  font-size: 0.9rem;
  font-weight: 700;
}

.cghbi-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999999;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  box-sizing: border-box;
  overflow-y: auto;
}

.cghbi-modal {
  width: 100%;
  max-width: 560px;
  max-height: min(92vh, calc(100dvh - 32px));
  background: #fff;
  border: 3px solid var(--cghbi-navy);
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  box-shadow: 0 24px 80px rgba(2, 6, 23, 0.25);
}

.cghbi-modal-header {
  padding: 22px;
  background: linear-gradient(135deg, var(--cghbi-navy), #0a4a5f);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.cghbi-modal-header-text {
  flex: 1;
  min-width: 0;
}

.cghbi-modal-header h3 {
  margin: 0;
  color: #fff;
  font-size: clamp(1.22rem, 4.2vw, 1.55rem);
  font-weight: 950;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.cghbi-modal-header-sub {
  margin: 10px 0 0;
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.875rem;
  font-weight: 550;
  line-height: 1.45;
}

.cghbi-modal-close {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.cghbi-modal-body {
  padding: 22px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.cghbi-modal-lead {
  margin: 0 0 14px;
  color: #1e293b;
  font-weight: 650;
  font-size: clamp(0.95rem, 2.2vw, 1.05rem);
  line-height: 1.55;
}

.cghbi-modal-label {
  display: block;
  margin: 10px 0 7px;
  font-weight: 900;
  color: #0f172a;
  font-size: 0.95rem;
}

.cghbi-modal-input {
  width: 100%;
  padding: 12px;
  border: 2px solid rgba(8, 49, 65, 0.28);
  border-radius: 12px;
  box-sizing: border-box;
  font-size: max(16px, 1rem);
  margin: 0;
}

.cghbi-modal-error {
  margin-top: 10px;
  color: #b91c1c;
  font-weight: 700;
  font-size: 0.92rem;
}

.cghbi-modal-footer {
  padding: 18px 22px;
  background: #ecfeff;
  border-top: 2px solid rgba(21, 94, 117, 0.22);
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.cghbi-modal-submit {
  flex: 1 1 auto;
  min-width: min(100%, 240px);
  min-height: 54px;
  border-radius: 14px;
  border: 2px solid #0c4a5f;
  background: linear-gradient(180deg, #0e7490 0%, #155e75 55%, #164e63 100%);
  color: #fff;
  font-weight: 950;
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
}

.cghbi-modal-secondary {
  border: 2px solid rgba(8, 49, 65, 0.25);
  background: #fff;
  color: var(--cghbi-navy);
  border-radius: 14px;
  padding: 14px 18px;
  font-weight: 850;
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
  min-height: 54px;
}

.cghbi-modal-success {
  margin: 0;
  padding: 8px 0;
  text-align: center;
  color: #059669;
  font-weight: 800;
  font-size: 1.05rem;
  line-height: 1.5;
}

@media (max-width: 520px) {
  .cghbi-modal-overlay {
    align-items: flex-start;
    padding-top: max(12px, env(safe-area-inset-top));
  }

  .cghbi-modal-footer {
    flex-direction: column;
    align-items: stretch;
  }

  #cghbi-root.cghbi-app,
  .cghbi-root.cghbi-app {
    padding: 0 10px;
  }

  .cghbi-shell {
    padding: 16px 12px 22px;
    border-radius: 16px;
  }

  .cghbi-hero,
  .cghbi-card {
    padding: 14px;
  }

}

@media print {
  #cghbi-root.cghbi-app,
  .cghbi-root.cghbi-app {
    margin: 0;
    padding: 0;
  }

  .cghbi-shell {
    max-width: none;
    border: none;
    box-shadow: none;
    padding: 0;
  }

  .cghbi-export,
  .cghbi-modal-overlay {
    display: none !important;
  }

  .cghbi-card,
  .cghbi-hero,
  .cghbi-results,
  .cghbi-results-section,
  .cghbi-pay-hero,
  .cghbi-tile,
  .cghbi-warning-box,
  .cghbi-table-wrap,
  .cghbi-compare-card {
    break-inside: avoid;
    box-shadow: none;
  }
}
