/* ============================================================
   PAYMENT CALCULATOR — page-specific styles
   Extracted from payment-calculator.html inline <style> block
   to use the immutable 1-year cache on returning visits.
   ============================================================ */

html { scroll-behavior: smooth; }
    body { font-family: var(--font-body); background: var(--cream); color: var(--slate); min-height: 100vh; height: 100dvh; min-height: 100dvh; }

    /* CALCULATOR LAYOUT */
    .calc-section { padding: var(--sp-7) 0 var(--sp-8); }
    .calc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-6); max-width: 1000px; margin: 0 auto; }

    /* INPUT CARD */
    .calc-card { background: var(--white); border-radius: var(--radius-xl); padding: 36px var(--sp-6); box-shadow: var(--shadow-card); border: 1px solid var(--border); /* round 9 — safety hairline so card stays visible on white sections */ }
    .calc-card h2 { font-family: var(--font-heading); font-size: var(--fs-lg); color: var(--slate); margin-bottom: var(--sp-1half); }
    .calc-card .calc-desc { color: var(--ink-2); font-size: var(--fs-sm); line-height: 1.6; margin-bottom: var(--card-pad-lg); }

    /* field-group base → tools.css */

    input[type="text"], input[type="number"] {
      width: 100%; padding: var(--sp-3) 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
      font-family: var(--font-body); font-size: var(--fs-sm-plus); color: var(--slate); background: var(--white);
      transition: border-color var(--duration-fast), box-shadow var(--duration-fast); -webkit-appearance: none; appearance: none;
    }
    /* input focus/error → tools.css */

    .field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }

    /* HST TOGGLE
       Audit round-2 2026-05-07: WCAG 2.5.5 requires a 44×44 hit zone.
       The visual switch is intentionally compact (44×24) but the
       outer .toggle-switch wrapper is now padded so the clickable
       label area (the input + slider) extends to a full 44×44.
       The visual remains unchanged; only the hit zone grows. */
    .hst-toggle { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-5); }
    .hst-toggle label { margin-bottom: 0; font-size: var(--fs-sm); font-weight: 600; color: var(--slate); }
    .toggle-switch {
      position: relative;
      width: 44px;
      min-height: 44px;          /* 44×44 hit zone */
      flex-shrink: 0;
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }
    .toggle-switch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
    .toggle-slider {
      position: relative;
      width: 44px;
      height: 24px;
      background: var(--border);
      border-radius: var(--radius-xl);
      cursor: pointer;
      transition: background var(--duration-fast);
    }
    .toggle-slider::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: var(--white); border-radius: var(--radius-circle); transition: transform var(--duration-fast); }
    .toggle-switch input:checked + .toggle-slider { background: var(--orange); }
    .toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

    /* BUTTON GROUP */
    .btn-group { display: flex; gap: 0; border: 1.5px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
    .btn-group button { flex: 1; padding: var(--sp-3) var(--sp-1half); border: none; background: var(--white); font-family: var(--font-body); font-size: var(--fs-sm); font-weight: 500; color: var(--ink-2); cursor: pointer; transition: var(--transition); border-right: 1px solid var(--border); }
    .btn-group button:last-child { border-right: none; }
    .btn-group button:hover { background: var(--accent-alpha-5); color: var(--orange-text); }
    .btn-group button.selected { background: var(--orange); color: var(--slate); font-weight: 600; }

    /* CALCULATE BUTTON */
    .btn-calculate { width: 100%; background: var(--orange); color: var(--slate); border: none; border-radius: var(--radius-md); padding: var(--sp-4) 28px; font-family: var(--font-body); font-size: var(--fs-base); font-weight: 700; cursor: pointer; transition: var(--transition); margin-top: var(--sp-2); }
    .btn-calculate:hover { background: var(--orange-dark); transform: translateY(-1px); }

    /* ERROR MESSAGE */
    .calc-error { display: none; background: var(--danger-alpha-10); color: var(--danger-deep); font-size: var(--fs-sm); padding: var(--sp-3) var(--sp-4); border-radius: var(--radius-md); margin-top: var(--sp-3); border-left: 3px solid var(--danger-deep); }
    .calc-error.visible { display: block; }

    /* RESULTS PANEL */
    .results-panel { background: var(--white); border-radius: var(--radius-xl); padding: 36px var(--sp-6); box-shadow: var(--shadow-card); opacity: 0; transform: translateY(16px); transition: opacity var(--duration-slow) ease, transform var(--duration-slow) ease; display: flex; flex-direction: column; justify-content: flex-start; border: 1px solid var(--border); /* round 9 — safety hairline so card stays visible on white sections */ }
    .results-panel.visible { opacity: 1; transform: translateY(0); }
    /* results-placeholder base → tools.css */
    .results-placeholder { padding: 60px 20px; }

    .payment-hero { text-align: center; margin-bottom: var(--card-pad-lg); padding-bottom: var(--sp-5); border-bottom: 1px solid var(--border); }
    .payment-label { font-size: var(--fs-sm); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-2); margin-bottom: var(--sp-1); }
    .payment-amount { font-family: var(--font-heading); font-size: clamp(2.2rem, 5vw, 3rem); color: var(--slate); line-height: 1.1; }
    .payment-freq { font-family: var(--font-body); font-size: var(--fs-base); color: var(--ink-2); font-weight: 400; }

    /* STATS GRID */
    .stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); margin-bottom: var(--card-pad-lg); }
    .stat-item { background: var(--cream); border-radius: var(--radius-md); padding: var(--sp-4); }
    .stat-label { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); margin-bottom: var(--sp-1); }
    .stat-value { font-family: var(--font-heading); font-size: var(--fs-md); color: var(--slate); }
    .stat-value.highlight { color: var(--orange-text); }

    /* TERM COMPARISON TABLE */
    .term-comparison { margin-bottom: var(--card-pad-lg); }
    .term-comparison h3 { font-family: var(--font-body); font-size: var(--fs-sm); font-weight: 700; color: var(--slate); margin-bottom: 14px; }
    .term-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
    .term-table th { text-align: left; padding: 10px var(--sp-3); font-weight: 600; color: var(--ink-2); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 2px solid var(--border); }
    .term-table td { padding: 10px var(--sp-3); border-bottom: 1px solid var(--border); color: var(--slate); }
    .term-table tr.current-term { background: var(--accent-alpha-8); }
    .term-table tr.current-term td { font-weight: 600; color: var(--orange-text); }
    .term-table tr:last-child td { border-bottom: none; }

    /* INSIGHT BOX */
    .insight-box { background: var(--slate); border-radius: var(--radius-lg); padding: var(--sp-5) 28px; border-left: 3px solid var(--orange); }
    .insight-box-label { font-size: var(--fs-2xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--orange); margin-bottom: 10px; }
    .insight-box p { margin: 0; font-size: var(--fs-sm); color: var(--on-dark-default); line-height: var(--lh-relaxed); }
    .insight-box strong { color: var(--white); }

    /* CTA trust badges → tools.css */

    /* RESPONSIVE */
    @media (max-width: 768px) {
      .calc-grid { grid-template-columns: 1fr; }
      .calc-card, .results-panel { padding: var(--sp-5) var(--sp-4); }
      .stats-grid { grid-template-columns: 1fr; }
      .field-row { grid-template-columns: 1fr; }
      .btn-group button { font-size: var(--fs-sm); padding: 10px var(--sp-1); }
      .term-table { font-size: var(--fs-xs); }
      .term-table th, .term-table td { padding: var(--sp-2) var(--sp-2); }
    }

    /* OUT-THE-DOOR BREAKDOWN SECTION */
    .otd-details { margin-top: var(--sp-5); border: 1.5px solid var(--border); border-radius: var(--radius-md); }
    .otd-details summary { padding: 14px var(--sp-4); font-size: var(--fs-sm); font-weight: 700; color: var(--slate); cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; }
    .otd-details summary::-webkit-details-marker { display: none; }
    .otd-details summary::after { content: '+'; font-size: var(--fs-md); color: var(--ink-2); transition: transform var(--duration-fast); }
    .otd-details[open] summary::after { content: '\2212'; }
    .otd-details-body { padding: 0 var(--sp-4) var(--sp-4); }
    .otd-province-row { display: flex; gap: var(--sp-3); align-items: flex-end; margin-bottom: var(--sp-4); }
    .otd-province-row select { flex: 1; padding: 10px var(--sp-3); border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-family: var(--font-body); font-size: var(--fs-sm); color: var(--slate); background: var(--white); }
    .otd-province-row .otd-province-label { font-size: var(--fs-xs); font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: var(--sp-1); }
    .otd-row { display: flex; justify-content: space-between; align-items: center; padding: var(--sp-2) 0; border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }
    .otd-row:last-child { border-bottom: none; }
    .otd-row-label { color: var(--ink-2); }
    .otd-row-value { font-weight: 700; color: var(--slate); }
    .otd-row-value.otd-savings { color: var(--success, var(--ok)); }
    .otd-section-label { font-size: var(--fs-2xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-2); margin-top: 14px; margin-bottom: 2px; padding-top: var(--sp-1half); border-top: 2px solid var(--border); }
    .otd-section-label:first-child { border-top: none; margin-top: 0; padding-top: 0; }
    .otd-total-row { display: flex; justify-content: space-between; align-items: center; padding: var(--sp-3) 14px; background: var(--cream); border-radius: var(--radius-sm); margin-top: var(--sp-3); font-size: var(--fs-sm); }
    .otd-total-row .otd-row-label { font-weight: 700; color: var(--slate); }
    .otd-total-row .otd-row-value { font-family: var(--font-heading); font-size: var(--fs-md); color: var(--orange-text); }
    .otd-province-note { font-size: var(--fs-xs); color: var(--ink-2); line-height: 1.5; margin-top: 10px; background: var(--cream); padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-sm); }

    /* TERM IMPACT VISUAL SECTION */
    .term-impact-details { margin-top: var(--sp-5); border: 1.5px solid var(--border); border-radius: var(--radius-md); }
    .term-impact-details summary { padding: 14px var(--sp-4); font-size: var(--fs-sm); font-weight: 700; color: var(--slate); cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; }
    .term-impact-details summary::-webkit-details-marker { display: none; }
    .term-impact-details summary::after { content: '+'; font-size: var(--fs-md); color: var(--ink-2); transition: transform var(--duration-fast); }
    .term-impact-details[open] summary::after { content: '\2212'; }
    .term-impact-body { padding: 0 var(--sp-4) var(--sp-4); }
    .ti-chart-container { position: relative; width: 100%; height: 240px; margin: var(--sp-4) 0 var(--sp-2); }
    .ti-chart-canvas { position: relative; width: 100%; height: 200px; border-left: 2px solid var(--border); border-bottom: 2px solid var(--border); }
    .ti-chart-y-labels { position: absolute; left: 0; top: 0; width: 52px; height: 200px; display: flex; flex-direction: column; justify-content: space-between; }
    .ti-chart-y-label { font-size: var(--fs-2xs); color: var(--ink-2); text-align: right; padding-right: var(--sp-1half); transform: translateY(-50%); }
    .ti-chart-plot { position: absolute; left: 52px; top: 0; right: 0; bottom: 0; overflow: hidden; }
    .ti-chart-zone { position: absolute; top: 0; bottom: 0; }
    /* Chart zone tints — token-disciplined to match the system's
       danger/ok semantics (was raw rgba). */
    .ti-zone-underwater { background: var(--danger-alpha-10); }
    .ti-zone-equity { background: var(--ok-alpha-10); }
    .ti-chart-line { position: absolute; top: 0; left: 0; right: 0; bottom: 0; }
    .ti-chart-line svg { width: 100%; height: 100%; }
    .ti-chart-x-labels { display: flex; justify-content: space-between; padding-left: 52px; margin-top: var(--sp-1); }
    .ti-chart-x-label { font-size: var(--fs-2xs); color: var(--ink-2); }
    .ti-chart-legend { display: flex; gap: var(--sp-4); justify-content: center; margin-top: 10px; flex-wrap: wrap; }
    .ti-chart-legend-item { display: flex; align-items: center; gap: var(--sp-1half); font-size: var(--fs-2xs); color: var(--ink-2); }
    .ti-chart-legend-swatch { width: 14px; height: 3px; border-radius: var(--radius-2xs); }
    .ti-crossover-label { position: absolute; font-size: var(--fs-2xs); font-weight: 700; color: var(--slate); background: var(--white); padding: 2px var(--sp-1half); border-radius: var(--radius-xs); box-shadow: var(--shadow-2); white-space: nowrap; transform: translate(-50%, -100%); pointer-events: none; border: 1px solid var(--border); /* round 9 — safety hairline so card stays visible on white sections */ }
    .ti-stat-row { display: flex; gap: var(--sp-3); margin-top: 14px; }
    .ti-stat { flex: 1; background: var(--cream); border-radius: var(--radius-sm); padding: var(--sp-3); text-align: center; }
    .ti-stat-label { font-size: var(--fs-2xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); margin-bottom: 2px; }
    .ti-stat-value { font-family: var(--font-heading); font-size: var(--fs-md); color: var(--slate); }
    .ti-stat-value.ti-warn { color: var(--danger-deep); } /* was --danger (3.94:1), now 5.63:1 */
    .ti-stat-value.ti-good { color: var(--ok-text); } /* was --success (2.21:1), now 5.14:1 */

    @media (max-width: 768px) {
      .ti-chart-container { height: 220px; }
      .ti-chart-canvas { height: 180px; }
      .ti-stat-row { flex-direction: column; }
      .otd-province-row { flex-direction: column; }
    }

    /* Nav active state */
    