/* =========================================================
   GLOBAL BASE STYLES
   ========================================================= */
   * { box-sizing: border-box; }

   body {
     margin: 0;
     font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
     background: #f4f6f9;
     color: #333;
   }
   
   h1, h2, h3, h4, h5, h6 { color: #2c3e50; margin: .5em 0; }
   p { color: #555; line-height: 1.6; margin-bottom: 1em; }
   
   .container {
     max-width: 820px;
     background: #fff;
     margin: 20px auto;
     padding: 20px;
     border-radius: 8px;
     box-shadow: 0 2px 12px rgba(0,0,0,.06);
   }
   
   label { display: block; margin: .5em 0 .2em; font-weight: 600; }
   input[type=text], input[type=number] {
     width: 100%; padding: .55em .6em; font-size: 1em; margin-bottom: 1em;
     border: 1px solid #c9cdd2; border-radius: 6px; background: #fff;
   }
   input[type=number]::-webkit-outer-spin-button,
   input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
   
   button {
     background: #2c3e50; color: #fff; border: none;
     padding: .55em 1.1em; font-size: 1em; border-radius: 6px; cursor: pointer;
   }
   button:hover { background: #1f2d3a; }
   button:active { background: #16222c; }
   button + button { margin-left: .5em; }
   
   .result { margin-top: 1em; font-weight: 700; font-size: 1.1em; color: #2c3e50; }
   ul.calc-list { list-style: none; padding: 0; }
   ul.calc-list li { margin: .5em 0; }
   
   @media (max-width:560px) {
     .container { margin: 12px; padding: 16px; }
   }
   
   /* Ensure [hidden] works properly */
   [hidden] { display: none !important; }
   
   /* =========================================================
      HEADER
      ========================================================= */
   .qc-header {
     position: sticky; top: 0; z-index: 50;
     background: #2f3e4b; color: #fff;
     display: grid; grid-template-columns: 1fr auto 1fr;
     align-items: center; padding: 12px 16px;
   }
   
   .qc-brand {
     justify-self: center;
     display: flex; align-items: center; gap: 0.25rem;
     color: #fff; text-decoration: none;
   }
   
   .qc-title-wrap { display: flex; flex-direction: column; line-height: 1.2; }
   .qc-title { font-size: 2rem; font-weight: 700; }
   .qc-subtitle { font-size: 1rem; font-weight: 400; opacity: 0.85; text-decoration: none; }
   
   .qc-logo { height: 3em; width: auto; }
   
   .qc-nav-btn {
     justify-self: end;
     font-size: 1.5rem; line-height: 1;
     background: transparent; color: #fff;
     border: 0; cursor: pointer; padding: 6px 8px;
   }
   
   /* Do not underline the brand link */
   .qc-header .qc-brand,
   .qc-header .qc-brand:hover,
   .qc-header .qc-brand:visited,
   .qc-header .qc-brand.active { text-decoration: none; }
   
   /* ===========================
   NAV / Drawer + Backdrop
   =========================== */

    /* lock scroll when drawer open */
    .qc-no-scroll { overflow: hidden; }

    /* backdrop */
    .qc-backdrop{
    position: fixed; inset: 0;
    background: rgba(17,24,39,.55); /* slate-900/55 */
    opacity: 0; pointer-events: none;
    transition: opacity .2s ease;
    z-index: 999; /* below drawer */
    }
    .qc-backdrop.open{ opacity:1; pointer-events:auto; }

    /* drawer container that was #qcNavPanel */
    #qcNavPanel{
    position: fixed; top: 0; right: 0;
    height: 100dvh;
    width: min(300px, 35vw);
    background: #f8fafc;            /* slate-50 */
    box-shadow: -8px 0 24px rgba(0,0,0,.18);
    transform: translateX(100%);
    transition: transform .22s ease;
    z-index: 1000;                   /* above backdrop */
    display: flex; flex-direction: column;
    border-left: 1px solid rgba(15,23,42,.08);
    border-top-left-radius: 10px; border-bottom-left-radius: 10px;
    }
    #qcNavPanel.open{ transform: translateX(0); }

    .qc-nav-inner{ display:flex; flex-direction:column; gap:12px; height:100%; padding:16px; }

    /* top row: search + X */
    .qc-nav-top{ display:flex; gap:10px; align-items:center; }
    /* Keep your existing search input styling */
    #qcSearch {
        flex: 1;
        height: 40px;
        padding: 0 12px;
        border: 1px solid rgba(15,23,42,.15);
        border-radius: 8px;
        outline: none;
        background: #fff;
        color: #0f172a;
    }
    
    /* Correct placement: hide browser’s built-in clear (x) */
    #qcSearch::-webkit-search-cancel-button {
        -webkit-appearance: none;
        appearance: none;
        display: none;
    }
    
    #qcSearch::-ms-clear {
        display: none;   /* old Edge/IE */
    }
    
    #qcSearch::-ms-reveal {
        display: none;   /* old Edge */
    }
  
    #qcSearch:focus{ border-color:#2563eb; box-shadow:0 0 0 3px rgba(37,99,235,.18); }

    #qcNavClose {
        background: none;
        border: none;
        font-size: 1.5rem;   /* makes the × bigger */
        font-weight: bold;
        color: #333;         /* adjust to match your theme */
        cursor: pointer;
      
        position: absolute;
        top: 12px;           /* vertical alignment */
        right: 12px;         /* spacing from edge */
        line-height: 1;      /* remove weird text spacing */
      }
      
      .qc-nav-close:hover,
      .qc-nav-close:focus {
        background: none;   /* prevent hover highlight */
        color: #000;        /* subtle darker color if you want feedback */
        outline: none;
        box-shadow: none;
      }

    /* categories accordion */
    .qc-cats{ overflow:auto; padding-top:6px; }
    .qc-acc{ border-radius:10px; background:#ffffff; border:1px solid rgba(15,23,42,.12); margin-bottom:10px; }
    .qc-acc-btn{
    display:flex; align-items:center; justify-content:space-between;
    padding:12px 14px; cursor:pointer; list-style:none; font-weight:600; color:#0f172a;
    }
    .qc-acc-btn::-webkit-details-marker{ display:none; }
    .qc-acc-btn svg{ width:18px; height:18px; stroke:#334155; fill:none; stroke-width:2; transition:transform .18s; }
    .qc-acc[open] .qc-acc-btn svg{ transform:rotate(180deg); }

    .qc-acc-list{ margin:0; padding: 4px 10px 10px 10px; list-style:none; }
    .qc-acc-list li a{
    display:block; padding:10px 10px; border-radius:8px;
    color:#0f172a; text-decoration:none;
    }
    .qc-acc-list li a:hover{ background:#eef2ff; color:#1d4ed8; }

    /* search results list */
    .qc-results{ overflow:auto; }
    .qc-results ul{ list-style:none; margin:0; padding:0; }
    .qc-results li a{
    display:block; padding:12px 14px; margin-bottom:8px;
    background:#ffffff; border:1px solid rgba(15,23,42,.12);
    border-radius:10px; color:#0f172a; text-decoration:none;
    }
    .qc-results li a:hover{ background:#eef2ff; border-color:#c7d2fe; color:#1d4ed8; }
    .qc-results .qc-empty{ color:#64748b; padding:10px 2px; }

    /* hamburger button alignment already in header styles;
    ensure it sits on the right and above backdrop */
    .qc-nav-btn{ z-index: 1001; }

    /* small screens: drawer uses full width */
    @media (max-width: 640px){
    #qcNavPanel{ width: 100vw; border-radius: 0; }
    }

   
   /* =========================================================
      FOOTER
      ========================================================= */
   footer {
     background: #2c3e50; color: #fff;
     text-align: center; padding: 8px 10px;
     font-size: .9em;
   }
   
   /* =========================================================
      UTILITIES
      ========================================================= */
   .qc-header a.active { text-decoration: underline; }
   .qc-lock { overflow: hidden; }
   
  /* =========================================================
    MORTGAGE
    ========================================================= */
/* Container spacing and typography */
.calculator-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 1em;
}
.calculator-container h1 {
  font-size: 1.5em;
  margin-bottom: 0.5em;
}
.calculator-container p {
  font-size: 1em;
  line-height: 1.4;
}

/* Field grid layout */
.fields-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5em; /* space between field groups */
}
.field-group {
  flex: 1 1 48%;  /* two columns: each ~48% */
  display: flex;
  flex-direction: column;
}
.field-group label {
  font-weight: 600;
  margin-bottom: 0.3em;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.field-group label .unit-toggle {
  /* Ensure the unit toggle group is on the same line as label text */
  display: inline-block;
  margin-left: 0.5em;
}
.field-group input {
  padding: 0.4em;
  font-size: 1em;
  max-width: 100%;
  box-sizing: border-box;
}
.field-group small.alt-value {
  margin-top: 0.2em;
  color: #555;
  font-style: italic;
  display: inline-block;
}

/* Unit toggle buttons ($ vs %) */
.unit-toggle {
  border: 1px solid #aaa;
  border-radius: 3px;
  overflow: hidden;
  font-size: 0.9em;
}
.unit-toggle .unit-btn {
  background: #f0f0f0;
  border: none;
  padding: 0.2em 0.5em;
  cursor: pointer;
  color: #333;
}
.unit-toggle .unit-btn.active {
  background: #333;
  color: #fff;
}
.unit-toggle .unit-btn:not(:last-child) {
  border-right: 1px solid #aaa;
}
.unit-toggle .unit-btn:focus {
  outline: none;
}

/* Additional costs toggle switch */
.additional-toggle {
  display: flex;
  align-items: center;
  margin: 0.5em 0 1em 0;
}
.toggle-label {
  margin-left: 0.5em;
  cursor: pointer;
  user-select: none;
  font-size: 1em;
}
/* Switch (slider) container */
.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 20px;
}
/* Hide default checkbox */
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
/* Slider track */
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #ccc;
  transition: 0.4s;
  border-radius: 20px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
}
/* Checked (ON) state */
input:checked + .slider {
  background-color: #2196F3; /* blue accent for ON */
}
input:checked + .slider:before {
  transform: translateX(20px);
}
/* Focus outline for accessibility */
input:focus + .slider {
  box-shadow: 0 0 2px #2196F3;
}

/* Results section styling */
#results {
  margin: 1em 0;
}
#results p {
  font-size: 1.1em;
  margin: 0.3em 0;
}
#results span {
  font-weight: 600;
}

/* Amortization toggle button style */
.toggle-btn {
  background: none;
  border: none;
  color: #0066cc;
  font-size: 1em;
  cursor: pointer;
  margin: 0.5em 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
}
.toggle-btn .arrow {
  display: inline-block;
  transition: transform 0.2s;
  margin-left: 0.3em;
  font-size: 0.9em;
}
.toggle-btn:hover {
  text-decoration: underline;
}
.toggle-btn:hover .arrow {
  /* subtle nudge on hover */
  transform: translateY(2px);
}

/* Amortization table */
#amortizationTable {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5em;
  font-size: 0.95em;
}
#amortizationTable th, #amortizationTable td {
  border: 1px solid #ddd;
  padding: 0.5em;
  text-align: right;
}
#amortizationTable th {
  background: #f9f9f9;
  text-align: center;
}
#amortizationTable tr:nth-child(even) {
  background: #fcfcfc;
}
#amortizationTable tr:hover {
  background: #f1f1f1;
}
#amortizationTable td:first-child, #amortizationTable th:first-child {
  text-align: center;
}

/* Responsive adjustments */
@media (max-width: 600px) {
  .field-group {
    flex: 1 1 100%;
  }
  .field-group label {
    justify-content: space-between;
  }
}
