:root {
  --blue: #8faadc;
  --blue-dark: #7292c7;
  --yellow: #fff200;
  --red: #ff1e13;
  --grid: #171717;
  --text: #0c0c0c;
  --paper: #ffffff;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: #f5f7f9;
  color: var(--text);
}
button, input, select { font: inherit; }
.page-shell { min-height: 100vh; padding: 24px 14px 60px; }
.sheet-card {
  width: min(1080px, 100%);
  margin: 0 auto;
  background: var(--paper);
  padding: 14px 20px 24px;
  box-shadow: 0 2px 16px rgba(0,0,0,.08);
}
.utility-bar {
  min-height: 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  color: #667085;
}
.utility-actions { display: flex; gap: 6px; }
.utility-actions button {
  border: 1px solid #d0d5dd;
  background: #fff;
  border-radius: 5px;
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
}
.top-area {
  display: grid;
  grid-template-columns: 310px 1fr;
  align-items: center;
  gap: 50px;
}
.client-table, .calc-table { border-collapse: collapse; width: 100%; table-layout: fixed; }
.client-table th, .client-table td {
  border: 1px solid var(--grid);
  height: 28px;
  padding: 2px 8px;
  font-size: 14px;
}
.client-table th { width: 61%; font-weight: 700; text-align: center; }
.client-table td { text-align: center; }
.brand-wrap { display:flex; align-items:center; justify-content:flex-start; height: 180px; }
.brand-wrap img { width: 460px; max-width: 100%; height: auto; display:block; }
.client-table input, .client-table select, .left-table input, .left-table select {
  width: 100%; border: 0; outline: 0; background: transparent; text-align: center; padding: 0;
}
.inline-number { display:flex; justify-content:center; align-items:center; gap:2px; }
.inline-number input { width: 70px; }
.market-cell { position: relative; padding-right: 53px !important; }
.market-input { width:100%; border:0; background:transparent; text-align:center; outline:0; font:inherit; }
.market-input:disabled { color:#000; opacity:1; }
.same-check { position:absolute; right:4px; top:50%; transform:translateY(-50%); font-size:10px; color:#555; display:flex; gap:2px; align-items:center; }
.same-check input { width:12px; height:12px; }
.calculator-grid { display:grid; grid-template-columns: 310px 1fr; gap:0; }
.calc-table th, .calc-table td {
  border: 1px solid var(--grid);
  height: 30px;
  padding: 4px 8px;
  font-size: 13px;
  line-height: 1.12;
}
.left-table th { width: 61%; font-weight: 600; text-align:center; }
.left-table td { text-align:center; }
.left-table .section-title th, .section-title th {
  background: var(--blue);
  font-weight: 700;
  text-align: center;
  font-size: 14px;
}
.strong { font-weight: 700; font-size: 14px !important; }
.calc-value { font-weight: 500; }
.stress th, .stress td { background: var(--yellow); font-weight: 700; }
.dbr-cell { font-weight: 700; color: #000; }
.dbr-cell.dbr-high { background: #ff6b63 !important; }
.dbr-cell.dbr-ok { background: #93c47d !important; }
.right-panel { margin-left:0; }
.cost-table .label-col { width: 52%; }
.cost-table td:first-child { text-align:center; }
.cost-table td:not(:first-child), .cost-table th:not(:first-child) { text-align:right; }
.bank-head th:first-child { text-align:center !important; }
.bank-select {
  width:100%; border:0; outline:0; padding:2px 5px; border-radius:8px; background:#f7f8fb; font-weight:700; text-align:center;
}
.total-row th { background: var(--blue); font-size:14px; }
.total-row th:first-child { text-align:center; }
.status-line { text-align:right; margin-top:8px; font-size:11px; color:#667085; min-height:14px; }

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(245,247,249,.97);
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-overlay[hidden] { display: none; }
.login-card {
  width: min(390px, 100%);
  background: #fff;
  border: 1px solid #e4e7ec;
  box-shadow: 0 12px 40px rgba(16,24,40,.12);
  border-radius: 12px;
  padding: 30px;
  text-align: center;
}
.login-card img { width: 260px; max-width: 100%; margin-bottom: 12px; }
.login-card h1 { margin: 0; font-size: 22px; }
.login-card p { margin: 7px 0 20px; color: #667085; font-size: 13px; }
.login-card input {
  width: 100%; border: 1px solid #d0d5dd; border-radius: 7px; padding: 11px 12px; outline: none; text-align: left;
}
.login-card button {
  width: 100%; margin-top: 10px; border: 0; background: #244f4a; color: #fff; border-radius: 7px; padding: 11px 12px; font-weight: 700; cursor: pointer;
}
.login-error { min-height: 18px; color: #b42318; font-size: 12px; margin-top: 8px; }

@media (max-width: 900px) {
  .page-shell { padding: 8px 0 40px; }
  .sheet-card { padding: 10px; overflow-x:auto; box-shadow:none; }
  .utility-bar { width: 1020px; }
  .top-area, .calculator-grid { width:1020px; grid-template-columns:310px 710px; }
  .brand-wrap img { width:430px; }
}

/* V4 transaction-specific calculation rows */
.highlight-green th,
.highlight-green td { background: #93c47d !important; }
[hidden] { display: none !important; }

/* V4.1 deployment/UI fixes */
.brand-area { display:flex; align-items:center; justify-content:center; height:180px; overflow:hidden; }
.brand-area img { width:460px; max-width:94%; height:auto; display:block; }
.client-table td { min-width:120px; }
.client-table input, .client-table select { min-width:0; }
@media (max-width:900px) { .brand-area img { width:430px; } }


/* V4.2 alignment and currency-input improvements */
.top-area, .calculator-grid {
  grid-template-columns: 330px minmax(0, 1fr);
}
.client-table, .mortgage-table, .cost-table {
  font-variant-numeric: tabular-nums;
}
.client-table th { width: 58%; }
.client-table td { width: 42%; min-width: 0; overflow: hidden; }
.mortgage-table th { width: 58%; font-weight: 600; text-align: center; }
.mortgage-table td { width: 42%; text-align: center; overflow: hidden; }
.client-table input, .client-table select,
.mortgage-table input, .mortgage-table select {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 100%;
  margin: 0;
  border: 0;
  outline: 0;
  background: transparent;
  text-align: center;
  padding: 0 5px;
  line-height: 1.2;
}
.mortgage-table input:focus, .client-table input:focus,
.mortgage-table select:focus, .client-table select:focus {
  background: #f8fbff;
  box-shadow: inset 0 0 0 1px #7aa2d8;
}
.money-input {
  font-variant-numeric: tabular-nums;
}
.inline-number {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20px;
  align-items: center;
  gap: 2px;
}
.inline-number input { width: 100%; min-width: 0; }
.market-cell { padding-right: 58px !important; overflow: hidden; }
.market-input, #marketValue {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  text-align: center;
  outline: 0;
}
.same-wrap {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 10px;
  color: #555;
  white-space: nowrap;
}
.same-wrap input { width: 12px; height: 12px; margin: 0; }
.cost-table td, .cost-table th { vertical-align: middle; }
.cost-table td:not(:first-child), .cost-table th:not(:first-child) {
  padding-left: 7px;
  padding-right: 7px;
  white-space: nowrap;
}
.bank-select { min-width: 0; max-width: 100%; }
.brand-area { justify-content: center; }
.brand-area img { width: 390px; max-width: 88%; }
@media (max-width: 900px) {
  .utility-bar { width: 1040px; }
  .top-area, .calculator-grid { width: 1040px; grid-template-columns: 330px 710px; }
  .brand-area img { width: 380px; }
}

/* V4.3 manual processing fee inputs */
.cost-table .processing-input {
  width: 100%;
  min-width: 0;
  height: 24px;
  border: 0;
  outline: none;
  background: #fff;
  text-align: right;
  padding: 2px 6px;
  font-size: 13px;
}
.cost-table .processing-input:focus {
  box-shadow: inset 0 0 0 2px #7aa2e3;
  background: #fffef4;
}


/* V4.4 editable transaction-charge inputs */
.cost-table .charge-input {
  width: 100%;
  min-width: 0;
  height: 24px;
  border: 0;
  outline: none;
  background: #fff;
  text-align: right;
  padding: 2px 6px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.cost-table .charge-input:focus {
  box-shadow: inset 0 0 0 2px #7aa2e3;
  background: #fffef4;
}

/* V4.5 customer PDF/share actions and mobile PWA controls */
.share-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.action-button {
  min-height: 40px;
  border-radius: 7px;
  padding: 9px 16px;
  border: 1px solid #174b47;
  font-weight: 700;
  cursor: pointer;
  font-size: 13px;
}
.action-button.primary { background: #174b47; color: #fff; }
.action-button.secondary { background: #fff; color: #174b47; }
.action-button.ghost { background: #fff; color: #4b5563; border-color: #cfd4dc; }
.action-button:disabled { opacity: .55; cursor: wait; }
.action-button:focus-visible,
.utility-actions button:focus-visible {
  outline: 3px solid rgba(23,75,71,.22);
  outline-offset: 2px;
}
@media (max-width: 900px) {
  .share-actions {
    width: 1040px;
    justify-content: flex-start;
    padding: 4px 0 2px;
  }
  .action-button {
    min-height: 44px;
    padding: 10px 18px;
    font-size: 14px;
  }
  .utility-actions button { min-height: 34px; }
}

/* V4.9 simple income-vs-LTV eligibility model */
.limit-red-row th,
.limit-red-row td {
  background: #ff6b63 !important;
  font-weight: 700;
}
.limit-red-row input,
.limit-red-row select {
  font-weight: 700;
  color: #8a120d;
}
.limit-reason {
  margin-top: 2px;
  font-size: 9px;
  line-height: 1.05;
  font-weight: 600;
  color: #2f5f34;
  white-space: normal;
}
#eligibleLoanRow td { padding-top: 3px; padding-bottom: 3px; }


/* V5.0 two-way Handover / Resale calculation */
.property-input:disabled {
  color: #000;
  opacity: 1;
  background: #f6f7f9 !important;
  font-weight: 700;
}
#calculationMode { font-weight: 700; }
#loanRequirementRow.limit-red-row th,
#loanRequirementRow.limit-red-row td,
#shortfallRow th, #shortfallRow td { background: #ff6b63 !important; }
