#nhs-thp-calc, #nhs-thp-calc * { box-sizing: border-box; }
  #nhs-thp-calc {
    /* Surfaces (NHS dark blue family) */
    --surface: #FFFFFF;
    --surface-2: #F3F8FD;
    --surface-3: #E4F0FA;
    --line: rgba(0,48,135,0.14);
    --line-strong: rgba(0,48,135,0.24);

    /* Text */
    --ink: #102A43;
    --ink-soft: #35526F;
    --muted: #58708B;

    /* NHS brand + semantics */
    --brand: #0072CE;        /* NHS Light Blue */
    --brand-deep: #005EB8;   /* NHS Blue */
    --brand-dim: rgba(0,114,206,0.12);
    --good: #00A499;         /* NHS Aqua Green */
    --good-dim: rgba(0,164,153,0.18);
    --warn: #B45309;         /* NHS Orange, lightened for dark background */
    --warn-dim: rgba(180,83,9,0.10);
    --gold: #FFB81C;         /* NHS Warm Yellow */
    --violet: #6D5BD0;       /* NHS Purple, lightened for dark background */
    --slate: #58708B;

    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: transparent;
    max-width: 1060px;
    margin: 0 auto;
    line-height: 1.5;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
  }
  #nhs-thp-calc .nhstc-num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; font-family: 'Space Grotesk', 'Inter', sans-serif; }
  #nhs-thp-calc a { color: var(--brand); }

  #nhs-thp-calc .nhstc-layout { display: grid; grid-template-columns: 1.12fr 0.98fr; gap: 18px; align-items: start; padding: 4px 4px 24px; }
  @media (max-width: 860px) { #nhs-thp-calc .nhstc-layout { grid-template-columns: 1fr; } }

  /* ---- Left panel: form ---- */
  #nhs-thp-calc .nhstc-form-panel {
    background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
  }
  #nhs-thp-calc .nhstc-form-section { padding: 20px 22px; border-bottom: 1px solid var(--line); }
  #nhs-thp-calc .nhstc-form-section:last-child { border-bottom: none; }
  #nhs-thp-calc .nhstc-section-title { font-size: 0.98rem; font-weight: 700; margin: 0 0 14px; color: var(--ink); }
  #nhs-thp-calc .nhstc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
  @media (max-width: 480px) { #nhs-thp-calc .nhstc-grid { grid-template-columns: 1fr; } }
  #nhs-thp-calc .nhstc-field label {
    display: flex; align-items: center; gap: 5px; font-size: 0.82rem; font-weight: 600; margin-bottom: 6px; color: var(--ink-soft);
  }
  #nhs-thp-calc select, #nhs-thp-calc input[type="number"], #nhs-thp-calc input[type="text"] {
    width: 100%; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 9px;
    font-size: 0.92rem; font-family: inherit; color: var(--ink); background: var(--surface-2);
    transition: border-color .12s, box-shadow .12s; height: 42px;
  }
  #nhs-thp-calc select { appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237E8CA0' stroke-width='2'%3e%3cpath d='M6 9l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; padding-right: 34px; cursor: pointer;
  }
  #nhs-thp-calc select:focus, #nhs-thp-calc input:focus {
    outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-dim);
  }
  #nhs-thp-calc .nhstc-hint { font-size: 0.78rem; color: var(--muted); margin-top: 8px; }
  #nhs-thp-calc .nhstc-hint strong { color: var(--ink-soft); font-weight: 600; }
  #nhs-thp-calc .nhstc-hint.nhstc-insight { color: var(--ink-soft); background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; margin-top: 10px; }

  /* Info tooltip */
  #nhs-thp-calc .nhstc-info {
    display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; border-radius: 50%;
    background: var(--surface-3); color: var(--muted); font-size: 0.68rem; font-weight: 700; font-family: 'Inter', sans-serif;
    cursor: help; position: relative; flex-shrink: 0;
  }
  #nhs-thp-calc .nhstc-info::after {
    content: attr(data-tip); position: absolute; bottom: 135%; left: 50%; transform: translateX(-50%) translateY(2px);
    width: max-content; max-width: 220px; background: #08111C; color: var(--ink-soft); font-size: 0.74rem; font-weight: 500;
    line-height: 1.4; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line-strong);
    opacity: 0; pointer-events: none; transition: opacity .12s, transform .12s; z-index: 20; text-align: left;
  }
  #nhs-thp-calc .nhstc-info:hover::after, #nhs-thp-calc .nhstc-info:focus-visible::after { opacity: 1; transform: translateX(-50%) translateY(0); }

  /* ---- Accordion rows for optional sections ---- */
  #nhs-thp-calc .nhstc-accordion-row { padding: 16px 22px; border-bottom: 1px solid var(--line); }
  #nhs-thp-calc .nhstc-accordion-row:last-child { border-bottom: none; }
  #nhs-thp-calc .nhstc-accordion-head {
    display: flex; align-items: center; justify-content: space-between; cursor: pointer; user-select: none;
  }
  #nhs-thp-calc .nhstc-accordion-head .nhstc-atitle { font-size: 0.95rem; font-weight: 700; color: var(--ink); }
  #nhs-thp-calc .nhstc-accordion-head .nhstc-adesc { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
  #nhs-thp-calc .nhstc-switch {
    position: relative; width: 40px; height: 23px; background: var(--surface-3); border-radius: 999px;
    flex-shrink: 0; transition: background .15s; border: 1px solid var(--line); cursor: pointer; margin-left: 14px;
  }
  #nhs-thp-calc .nhstc-switch.on { background: var(--brand); border-color: var(--brand); }
  #nhs-thp-calc .nhstc-switch::after {
    content: ""; position: absolute; top: 2.5px; left: 2.5px; width: 17px; height: 17px;
    background: #fff; border-radius: 50%; transition: left .15s; box-shadow: 0 1px 3px rgba(0,0,0,.4);
  }
  #nhs-thp-calc .nhstc-switch.on::after { left: 19.5px; }
  #nhs-thp-calc .nhstc-collapsible { display: none; margin-top: 16px; }
  #nhs-thp-calc .nhstc-collapsible.open { display: block; }

  #nhs-thp-calc .nhstc-loan-row { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
  #nhs-thp-calc .nhstc-loan-row select { flex: 1; }
  #nhs-thp-calc .nhstc-remove-btn {
    background: var(--surface-2); border: 1.5px solid var(--line); color: var(--muted); width: 40px; height: 40px; flex-shrink: 0;
    border-radius: 8px; cursor: pointer; font-size: 1.1rem; line-height: 1; font-family: inherit;
  }
  #nhs-thp-calc .nhstc-remove-btn:hover { border-color: var(--warn); color: var(--warn); }
  #nhs-thp-calc .nhstc-add-btn {
    background: var(--brand-dim); border: 1px solid transparent; color: #005EB8; padding: 9px 14px;
    border-radius: 8px; font-size: 0.85rem; font-weight: 700; cursor: pointer; font-family: inherit;
  }
  #nhs-thp-calc .nhstc-add-btn:hover { background: rgba(0,114,206,0.14); }

  /* ---- Right panel: results ---- */
  #nhs-thp-calc .nhstc-results {
    background: var(--surface); color: var(--ink); border-radius: 16px; padding: 22px;
    position: sticky; top: 16px; border: 1px solid var(--line); overflow: hidden; isolation: isolate;
  }
  #nhs-thp-calc .nhstc-results::before {
    content: ""; position: absolute; width: 260px; height: 260px; top: -120px; right: -100px; z-index: -1;
    background: radial-gradient(circle, rgba(0,164,153,0.20), transparent 70%);
  }
  #nhs-thp-calc .nhstc-results-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
  #nhs-thp-calc .nhstc-results-title { font-size: 0.85rem; font-weight: 600; color: var(--muted); margin: 0; }
  #nhs-thp-calc .nhstc-tabs { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; border: 1px solid var(--line); }
  #nhs-thp-calc button.nhstc-tab {
    border: none; background: transparent; padding: 6px 13px; font-size: 0.8rem;
    font-weight: 600; cursor: pointer; color: var(--muted); font-family: inherit; border-radius: 7px;
  }
  #nhs-thp-calc button.nhstc-tab.active { background: var(--surface-3); color: var(--ink); }

  #nhs-thp-calc .nhstc-hero .lbl { font-size: 0.85rem; color: var(--muted); margin-bottom: 4px; }
  #nhs-thp-calc .nhstc-hero .val { font-size: 2.6rem; font-weight: 800; letter-spacing: -0.02em; font-family: 'Space Grotesk', sans-serif; }
  #nhs-thp-calc .nhstc-hero .val .nhstc-accent {
    background: linear-gradient(90deg, #2FD9C4, #41B6E6); -webkit-background-clip: text; background-clip: text; color: transparent;
  }
  #nhs-thp-calc .nhstc-hero .nhstc-period-word { font-size: 1.1rem; color: var(--muted); font-weight: 600; margin-left: 4px; }

  #nhs-thp-calc .nhstc-ministats { display: flex; gap: 10px; margin: 14px 0 18px; }
  #nhs-thp-calc .nhstc-ministat { flex: 1; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; }
  #nhs-thp-calc .nhstc-ministat .k { font-size: 0.72rem; color: var(--muted); margin-bottom: 3px; }
  #nhs-thp-calc .nhstc-ministat .v { font-size: 0.95rem; font-weight: 700; color: var(--ink); }

  /* Pay breakdown bar */
  #nhs-thp-calc .nhstc-paybar { display: flex; width: 100%; height: 10px; border-radius: 999px; overflow: hidden; background: var(--surface-2); margin-bottom: 14px; }
  #nhs-thp-calc .nhstc-paybar span { height: 100%; transition: width .2s; }
  #nhs-thp-calc .nhstc-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-bottom: 16px; }
  #nhs-thp-calc .nhstc-legend-item { display: flex; align-items: center; gap: 6px; font-size: 0.75rem; color: var(--muted); }
  #nhs-thp-calc .nhstc-legend-item .sw { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }

  #nhs-thp-calc .nhstc-subrow { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); font-size: 0.88rem; }
  #nhs-thp-calc .nhstc-subrow .k { color: var(--muted); display: flex; align-items: center; gap: 6px; }
  #nhs-thp-calc .nhstc-subrow .v { color: var(--ink); font-weight: 600; }
  #nhs-thp-calc .nhstc-subrow.neg .v { color: var(--warn); }
  #nhs-thp-calc .nhstc-subrow.total { border-top: 1.5px solid var(--line-strong); padding-top: 12px; margin-top: 4px; }
  #nhs-thp-calc .nhstc-subrow.total .v { font-size: 1.02rem; }

  #nhs-thp-calc .nhstc-eff-rate {
    margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line);
    font-size: 0.8rem; color: var(--muted); display: flex; justify-content: space-between;
  }
  #nhs-thp-calc .nhstc-eff-rate .v { color: var(--ink); font-weight: 700; }

  #nhs-thp-calc .nhstc-actions { display: flex; gap: 8px; margin-top: 18px; }
  #nhs-thp-calc .nhstc-action-btn {
    flex: 1; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-soft);
    padding: 10px 12px; border-radius: 9px; font-size: 0.82rem; font-weight: 600; cursor: pointer; font-family: inherit;
    display: flex; align-items: center; justify-content: center; gap: 6px; transition: border-color .12s, color .12s;
  }
  #nhs-thp-calc .nhstc-action-btn:hover { border-color: var(--brand); color: var(--ink); }
  #nhs-thp-calc .nhstc-action-btn.copied { border-color: var(--good); color: var(--good); }

  #nhs-thp-calc .nhstc-disclaimer {
    font-size: 0.78rem; color: var(--muted); padding: 14px 4px 4px; max-width: 72ch; display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  }
  #nhs-thp-calc .nhstc-disclaimer .nhstc-reset { background: none; border: none; color: var(--muted); text-decoration: underline; cursor: pointer; font-family: inherit; font-size: inherit; padding: 0; white-space: nowrap; }
  #nhs-thp-calc .nhstc-disclaimer .nhstc-reset:hover { color: var(--ink-soft); }

  #nhs-thp-calc .nhstc-sticky-bar {
    display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 999;
    background: #003087; color: #fff; padding: 12px 18px; border-top: 1px solid var(--line-strong);
    align-items: center; justify-content: space-between; box-shadow: 0 -4px 20px rgba(0,0,0,.35);
  }
  #nhs-thp-calc .nhstc-sticky-bar .val { font-size: 1.15rem; font-weight: 800; color: #fff; font-family: 'Space Grotesk', sans-serif; }
  #nhs-thp-calc .nhstc-sticky-bar .lbl { font-size: 0.72rem; color: var(--muted); }
  @media (max-width: 640px) {
    #nhs-thp-calc .nhstc-sticky-bar { display: flex; }
    #nhs-thp-calc { padding-bottom: 64px; }
    #nhs-thp-calc .nhstc-results { position: static; }
  }
  @media (prefers-reduced-motion: reduce) {
    #nhs-thp-calc * { transition: none !important; }
  }
  @media print {
    #nhs-thp-calc .nhstc-sticky-bar, #nhs-thp-calc .nhstc-actions, #nhs-thp-calc .nhstc-form-panel { display: none; }
    #nhs-thp-calc .nhstc-layout { grid-template-columns: 1fr; }
  }

/* Accessibility and rendering performance. */
#nhs-thp-calc .nhstc-info:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.nhs-thps-page .nhs-main a, .nhs-thps-page .thps-content-card a { text-decoration: underline; text-underline-offset: .14em; }
.nhs-thps-page .thps-site-footer a { color: #fff; }
.nhs-thps-page .thps-site-footer a:hover, .nhs-thps-page .thps-site-footer a:focus-visible { color: #fff; text-decoration: underline; }
.nhs-thps-page .nhs-hero a { color: #fff !important; text-decoration: underline; text-underline-offset: .14em; }
