:root{
  --bg: #eef2f6;
  --card: #ffffff;
  --text: #0f1428;
  --muted: rgba(15,20,40,.65);
  --line: rgba(15,20,40,.12);
  --shadow: 0 10px 30px rgba(15,20,40,.08);
  --radius: 18px;
}

*{ box-sizing: border-box; }
body{ background: var(--bg); color: var(--text); }

.mc-title-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.h1{ font-size: 28px; margin: 0; }
.h2{ font-size: 18px; margin: 0 0 10px; }
.muted{ color: var(--muted); }
.tiny{ font-size: 12px; }
.small-link{ text-decoration: none; color: rgba(15,20,40,.8); }
.small-link:hover{ text-decoration: underline; }

.card{
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

/* Keep same page width as your site-main.css .wrap (max 980) */
.cc-head{
  margin: 16px 0 10px;
}
.cc-title-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.pill{
  display:inline-flex;
  background:#fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow:hidden;
}
.pill input{ position:absolute; opacity:0; pointer-events:none; }
.pill label{
  font-weight: 900;
  font-size: 14px;
  padding: 10px 12px;
  cursor:pointer;
  user-select:none;
}
.pill input:checked + label{
  background: rgba(15,79,168,.10);
  border-left: 1px solid rgba(15,79,168,.18);
  border-right: 1px solid rgba(15,79,168,.18);
}

.cc-grid{
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-items: start;
}
@media (min-width: 980px){
  .cc-grid{
    grid-template-columns: 1.05fr .95fr;
  }
  .cc-right{ position: sticky; top: 12px; }
}

.cc-card{ margin-bottom: 14px; }

.cc-actions-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.cc-actions{ display:flex; gap:10px; flex-wrap:wrap; }

.field{ margin-top: 14px; }
.label-inline{
  display:flex;
  align-items:center;
  gap: 10px;
  margin-bottom: 8px;
}
label{ font-weight: 800; font-size: 20px; }

.help{ margin-top: 6px; }

.input-row{
  display:flex;
  gap: 10px;
  align-items: center;
}

.input-wrap{
  display:flex;
  align-items:center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
}

.pretty-input{
  border: 0;
  outline: none;
  width: 100%;
  font-size: 18px;
  padding: 14px 14px;
  background: transparent;
}

.affix{
  padding: 0 12px;
  font-weight: 800;
  color: rgba(15,20,40,.75);
  white-space: nowrap;
  border-right: 1px solid var(--line);
}
.affix.right{
  border-right: 0;
  border-left: 1px solid var(--line);
}

.unit-select{
  border: 0;
  outline: none;
  padding: 14px 12px;
  font-weight: 800;
  background: #fff;
  border-left: 1px solid var(--line);
  min-width: 72px;
}

.preset-select{
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 14px;
  font-weight: 800;
  font-size: 16px;
  background: #fff;
}

.date-input{
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 14px;
  font-size: 16px;
  background: #fff;
}

.two{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 520px){
  .two{ grid-template-columns: 1fr; }
}

.btn{
  width: 100%;
  border: 0;
  border-radius: 16px;
  padding: 14px 14px;
  font-weight: 900;
  font-size: 16px;
  cursor: pointer;
}
.btn.primary{
  background: #0f4fa8;
  color: #fff;
}

.mini-btn{
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 16px;
  padding: 12px 14px;
  font-weight: 900;
  cursor: pointer;
}
.mini-btn:hover{ background: rgba(15,20,40,.04); }

.icon-btn{
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  width: 38px;
  height: 38px;
  font-weight: 900;
  cursor: pointer;
}

.tip-btn{
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  width: 34px;
  height: 34px;
  font-weight: 900;
  cursor: pointer;
}

.divider{
  height: 1px;
  background: var(--line);
  margin: 14px 0;
}

.results-top{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items:start;
}
@media (max-width: 520px){
  .results-top{ grid-template-columns: 1fr; }
}

.total-big{
  font-size: 40px;
  font-weight: 1000;
  letter-spacing: -0.5px;
  margin: 2px 0 4px;
}

.mini-lines{
  margin-top: 10px;
  display: grid;
  gap: 6px;
}
.mini-line{
  display:flex;
  justify-content:space-between;
  gap: 10px;
}
.mini-strong{ font-weight: 900; }

.btn-row{
  display:flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.btn-row .mini-btn{
  flex: 1;
  min-width: 220px;
}
@media (max-width: 520px){
  .btn-row .mini-btn{ min-width: 100%; }
}

.breakdown{
  border-top: 1px solid rgba(15,20,40,.06);
}
.b-row{
  display:flex;
  justify-content:space-between;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(15,20,40,.06);
}
.b-name{ color: rgba(15,20,40,.75); }
.b-val{ font-weight: 900; white-space: nowrap; }

/* Donut */
.pie-block{
  display:flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}
.donut-wrap{
  position: relative;
  width: 170px;
  height: 170px;
}
.donut{
  position: relative;
  width: 170px;
  height: 170px;
}
.donutSvg{ width: 170px; height: 170px; transform: rotate(-90deg); }
.donutBg{ fill: none; stroke: rgba(15,20,40,.08); }
.donutSeg{
  fill: none;
  stroke-linecap: butt;
  cursor: pointer;
  opacity: .95;
}
.donutSeg.isHot{ opacity: 1; filter: saturate(1.1); }

/* segment colors */
.donutSeg.s0{ stroke: #0f4fa8; } /* P&I / Down / Loan */
.donutSeg.s1{ stroke: #8b5cf6; } /* Taxes / Prepaids / Taxes */
.donutSeg.s2{ stroke: #10b981; } /* Insurance / Fixed / Costs */
.donutSeg.s3{ stroke: #f97316; } /* HOA (if used) */

.donutCenter{
  position:absolute;
  inset: 0;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  text-align:center;
  pointer-events:none;
}
.donutValue{ font-weight: 1000; font-size: 16px; color: rgba(15,20,40,.85); }
.donutSub{ font-weight: 900; font-size: 14px; color: rgba(15,20,40,.70); margin-top: 2px; }

.pie-legend{
  display: grid;
  gap: 8px;
  width: 100%;
  max-width: 240px;
}
.pie-legend-row{
  display:flex;
  align-items:center;
  gap: 10px;
}
.pie-swatch{
  width: 16px;
  height: 16px;
  border-radius: 6px;
  border: 1px solid rgba(15,20,40,.15);
}
.pie-swatch.s0{ background:#0f4fa8; }
.pie-swatch.s1{ background:#8b5cf6; }
.pie-swatch.s2{ background:#10b981; }
.pie-swatch.s3{ background:#f97316; }
.pie-label{ font-weight: 900; }

/* Fee rows */
.fee-list{ display: grid; gap: 10px; }
.fee-row{
  display:grid;
  grid-template-columns: 1fr 1fr 42px;
  gap: 10px;
  align-items:center;
}
@media (max-width: 520px){
  .fee-row{ grid-template-columns: 1fr; }
  .fee-row .icon-btn{ width: 100%; border-radius: 16px; height: 44px; }
}

.other-name{
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 14px;
  font-weight: 800;
  background: #fff;
}
.other-amt{ width: 100%; }

.fee-add{ width: 100%; justify-content: center; }

/* Modal / Tooltip overlay */
.tip-overlay{
  position: fixed;
  inset: 0;
  background: rgba(15,20,40,.25);
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 14px;
  z-index: 9999;
}
.tip-popup{
  width: min(620px, 100%);
  background: #fff;
  border-radius: 18px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;

  /* ✅ keep within viewport */
  max-height: calc(100vh - 28px);
  display: flex;
  flex-direction: column;
}
.tip-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding: 14px 14px;
  border-bottom: 1px solid var(--line);
}
.tip-title{ font-weight: 1000; font-size: 18px; }
.tip-body{
  padding: 14px 14px;
  color: rgba(15,20,40,.8);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

/* Explanation section */
.cc-explain{ margin: 16px 0 18px; }
.explain-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.lang-toggle{
  display:flex;
  gap: 10px;
  flex-wrap: wrap;
}
.lang-btn{
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 900;
  cursor: pointer;
}
.lang-btn.active{
  background: rgba(15,79,168,.10);
  border-color: rgba(15,79,168,.35);
}
.explain-list{
  margin: 0;
  padding-left: 18px;
}
.explain-list li{ margin: 6px 0; }

/* ✅ tooltip must NEVER show when hidden */
#tipOverlay[hidden], #titleModal[hidden], #taxModal[hidden] { display: none !important; }


/* ===============================
   Buyer / Seller Segmented Toggle
   (LOCKED – matches mortgage.php)
================================ */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0;
  background: rgba(15,20,40,.08);
  border-radius: 999px;
  padding: 4px;
}

.pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.pill label {
  padding: 8px 18px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 14px;
  cursor: pointer;
  color: rgba(15,20,40,.55);
  transition: background .18s ease, color .18s ease, box-shadow .18s ease;
  user-select: none;
}

/* Active tab */
.pill input:checked + label {
  background: #ffffff;
  color: #0f1428;
  box-shadow: 0 4px 10px rgba(15,20,40,.12);
}

/* Hover on inactive */
.pill label:hover {
  color: #0f1428;
}
/* ✅ Explanation toggle must NEVER show when hidden */
#explainEN[hidden],
#explainMM[hidden] { display: none !important; }

/* ===== Closing Costs: Closing Date mobile overflow fix ===== */

/* allow flex/grid children to shrink */
.cc-card .field,
.cc-card .two,
.cc-card .two > *,
.cc-card .input-row {
  min-width: 0;
}

/* force date input to respect container width */
.cc-card input#closing_date.date-input{
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  inline-size: 100%;
  min-inline-size: 0;
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
}

/* safety guard */
.cc-card {
  overflow: hidden;
}

/* =========================================================
   Title Fees Modal — SINGLE ROW FIX (FINAL)
   Fee Name | Amount | X
========================================================= */

#titleModal .fee-row{
  display: grid !important;
  grid-template-columns: minmax(0,1fr) auto !important;
  align-items: center !important;
  gap: 10px !important;
}

/* fee name */
#titleModal .fee-row .fee-name,
#titleModal .fee-row .other-name{
  min-width: 0 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

/* amount + X wrapper */
#titleModal .fee-row .fee-bottom{
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  flex-wrap: nowrap !important;
}

/* amount field */
#titleModal .fee-row .other-amt{
  width: 130px !important;
  min-width: 130px !important;
}

/* X button */
#titleModal .fee-row .fee-x{
  width: 44px !important;
  height: 44px !important;
  flex: 0 0 44px !important;
  margin: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

/* very small phones */
@media (max-width: 520px){
  #titleModal .fee-row .other-amt{
    width: 105px !important;
    min-width: 105px !important;
  }
  #titleModal .fee-row .fee-x{
    width: 40px !important;
    height: 40px !important;
    flex-basis: 40px !important;
  }
}
