/* ===========================================================================
   SHARED STYLESHEET

   Contains no brand values. Every colour and typeface is a CSS custom property
   supplied by the tenant's brand.css, which the build loads first — so this
   file styles both sites and neither one owns it.

   Two structural rules the components below assume, and which both brands
   happen to share: no border-radius, and no shadows. Separation comes from
   hairline rules.
   =========================================================================== */
:root {
  /* 4px spacing scale — layout, not brand. */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 26px;
  font-weight: 400;
  color: var(--body);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Layout ---------- */

.layout { display: flex; min-height: 100%; }

.sidebar {
  width: 264px;
  flex: 0 0 264px;
  background: var(--navy);
  color: var(--on-navy);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

/* Clear space around the lockup is 1x the cap height of the A in the mark;
   the padding here holds that at the rendered logo size. */
.brand {
  padding: var(--s5) var(--s5) var(--s6);
  border-bottom: 1px solid var(--rule-dark);
}

.brand-logo { display: block; width: var(--logo-width); height: auto; }

.brand-sub {
  display: block;
  margin-top: var(--s4);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--on-navy-muted);
}

.nav {
  padding: var(--s5) var(--s3);
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  flex: 1;
}

.nav-heading {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--on-navy-muted);
  padding: var(--s4) var(--s3) var(--s2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 11px var(--s3);
  color: var(--on-navy);
  text-decoration: none;
  border: none;
  border-left: 2px solid transparent;
  background: transparent;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  width: 100%;
}

.nav-item:hover { background: rgba(255, 255, 255, 0.05); color: var(--white); }

.nav-item.is-active {
  background: rgba(255, 255, 255, 0.06);
  border-left-color: var(--sand);
  color: var(--white);
}

/* With the sand lockup above them, sand icons on every row would spend the
   accent on decoration. Sand is kept for the logo and the active row. */
.nav-icon { width: 16px; text-align: center; color: var(--on-navy-muted); font-size: 13px; }
.nav-item.is-active .nav-icon { color: var(--sand); }

.sidebar-footer {
  padding: var(--s4) var(--s5);
  border-top: 1px solid var(--rule-dark);
  font-size: 12px;
  color: var(--on-navy-muted);
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--rule);
  padding: var(--s5) var(--s6);
  display: flex;
  align-items: center;
  gap: var(--s4);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar-titles h1 {
  margin: 0;
  font-size: 26px;
  line-height: 32px;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.topbar-titles p { margin: var(--s1) 0 0; font-size: 14px; color: var(--body); }

.menu-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--rule);
  padding: var(--s2) var(--s3);
  font-size: 16px;
  cursor: pointer;
  color: var(--ink);
}

.content { padding: var(--s6); flex: 1; }

/* ---------- Cards ---------- */

.card {
  background: var(--white);
  border: 1px solid var(--rule);
  padding: var(--s5);
}

.card + .card { margin-top: var(--s5); }

.card-title {
  margin: 0 0 var(--s1);
  font-size: 21px;
  line-height: 28px;
  font-weight: 500;
  color: var(--ink);
}

.card-note { margin: 0 0 var(--s5); font-size: 14px; color: var(--body); }

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--s5);
  align-items: start;
}

/* ---------- Forms ---------- */

.field { margin-bottom: var(--s5); }
.field:last-child { margin-bottom: 0; }

.label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--label);
  margin-bottom: var(--s2);
}

.hint { font-size: 12px; line-height: 19px; color: var(--grey); margin-top: var(--s2); }

.hint code {
  background: var(--bone);
  padding: 1px 5px;
  font-size: 11.5px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

.input-wrap { position: relative; display: flex; align-items: center; }

.input-prefix {
  position: absolute;
  left: var(--s3);
  color: var(--grey);
  font-size: 15px;
  pointer-events: none;
}

.input {
  width: 100%;
  padding: 12px var(--s3);
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
  border: 1px solid var(--rule);
  background: var(--white);
  transition: border-color 0.15s;
}

.input.has-prefix { padding-left: 28px; }

.input:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: inset 0 0 0 1px var(--navy);
}

.input::placeholder { color: #b6bcc4; }

.select {
  padding: 12px var(--s2);
  font-size: 14px;
  font-family: inherit;
  border: 1px solid var(--rule);
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
}
.select:focus { outline: none; border-color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy); }

.checkbox-row { display: flex; align-items: center; gap: var(--s2); font-size: 14px; color: var(--ink); }
.checkbox-row input { width: 15px; height: 15px; accent-color: var(--navy); }

/* ---------- Buttons ---------- */

.btn {
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 0.06em;
  padding: 12px 25px;
  border: 1px solid var(--navy);
  background: transparent;
  color: var(--navy);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.btn:hover { background: var(--navy); color: var(--white); }

.btn-primary { background: var(--navy); color: var(--white); }
.btn-primary:hover { background: var(--navy-hover); border-color: var(--navy-hover); }

.btn:focus-visible { outline: 2px solid var(--sand); outline-offset: 2px; }

/* ---------- Result panel ---------- */

.result-panel { background: var(--navy); color: var(--on-navy); padding: var(--s5); }

.result-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--on-navy-muted);
  margin: 0 0 var(--s3);
}

.result-value {
  font-family: var(--serif);
  font-size: 44px;
  line-height: 50px;
  font-weight: var(--serif-weight);
  letter-spacing: -0.02em;
  color: var(--white);
  margin: 0;
  font-variant-numeric: tabular-nums;
}

/* Sand rule under the headline figure — the accent's main job on this page. */
.result-value::after {
  content: "";
  display: block;
  width: 44px;
  height: 2px;
  background: var(--sand);
  margin-top: var(--s4);
}

.result-sub { margin: var(--s3) 0 0; font-size: 13px; color: var(--on-navy-muted); }

.result-split {
  margin-top: var(--s5);
  padding-top: var(--s4);
  border-top: 1px solid var(--rule-dark);
  display: grid;
  gap: var(--s3);
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 14px;
  gap: var(--s4);
}
.result-row span:first-child { color: var(--on-navy-muted); }
.result-row span:last-child { font-variant-numeric: tabular-nums; }
.result-row.is-total { font-weight: 600; }
.result-row.is-total span { color: var(--white); }
.result-row.is-discount span:last-child { color: var(--sand); }

/* ---------- Tables ---------- */

.table { width: 100%; border-collapse: collapse; font-size: 14px; }

.table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--navy);
  padding: 0 var(--s3) var(--s3) 0;
  border-bottom: 2px solid var(--navy);
}

.table td {
  padding: var(--s4) var(--s3) var(--s4) 0;
  border-bottom: 1px solid var(--rule);
  color: var(--body);
}

.table td:first-child { color: var(--ink); }
.table th:last-child, .table td:last-child { padding-right: 0; }

.table td.num, .table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table tr.is-inactive td, .table tr.is-inactive td:first-child { color: #b0b6bd; }

/* ---------- Entities ---------- */

.entity-list { display: grid; gap: var(--s2); }

.entity-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px 34px;
  gap: var(--s2);
  align-items: center;
}

/* Tenants whose documents need to state where a fee is drawn from get an
   extra column; everyone else keeps the two-field row. */
.entity-row.has-account,
.entity-head.has-account {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 150px 34px;
}

.entity-row .input { padding: 10px var(--s3); font-size: 14px; }
.entity-row .input.has-prefix { padding-left: 26px; }
.entity-row .input-prefix { left: 10px; font-size: 14px; }

.signatory-row {
  display: grid;
  grid-template-columns: minmax(0, 150px) minmax(0, 1fr);
  gap: var(--s3);
  align-items: center;
  margin-bottom: var(--s2);
}

.signatory-for {
  font-size: 13px;
  color: var(--body);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.signatory-row .input { padding: 10px var(--s3); font-size: 14px; }

.agreement-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--s4);
}
.agreement-grid .select { width: 100%; }

/* Rendered only when an agreement is exported, and only visible to the
   printer — on screen the calculator stays as it was. */
.agreement-doc { display: none; }

.entity-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px 34px;
  gap: var(--s2);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--label);
  margin-bottom: var(--s3);
}

.btn-icon {
  width: 34px;
  height: 34px;
  border: 1px solid var(--rule);
  background: var(--white);
  color: var(--grey);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  display: grid;
  place-items: center;
  font-family: inherit;
}
.btn-icon:hover { border-color: #b4453a; color: #b4453a; }
.btn-icon[hidden] { visibility: hidden; }

.btn-add {
  margin-top: var(--s3);
  width: 100%;
  padding: 11px;
  border: 1px solid var(--rule);
  color: var(--body);
}
.btn-add:hover { background: var(--bone); color: var(--navy); border-color: var(--navy); }

.row-total {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  padding-top: var(--s3);
  margin-top: var(--s3);
  border-top: 1px solid var(--rule);
  font-variant-numeric: tabular-nums;
}
.row-total strong { font-weight: 600; color: var(--ink); }

/* ---------- Fee by entity: rounding + manual override ---------- */

.card-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  flex-wrap: wrap;
  margin-bottom: var(--s5);
}

.control-inline { display: flex; align-items: center; gap: var(--s2); }

.control-inline .label { margin-bottom: 0; white-space: nowrap; }

.control-inline .select { padding: 7px var(--s2); font-size: 13px; }

.btn-quiet {
  border-color: var(--rule);
  color: var(--body);
  padding: 7px var(--s3);
  font-size: 12px;
}
.btn-quiet:hover { background: var(--bone); color: var(--navy); border-color: var(--navy); }
.btn-quiet[hidden] { display: none; }

.fee-input {
  width: 118px;
  padding: 6px var(--s2);
  font-size: 14px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--rule);
  background: var(--white);
  color: var(--ink);
  font-family: inherit;
}
.fee-input:focus { outline: none; border-color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy); }

/* A sand left edge marks a row the adviser has typed over, so an overridden
   figure is never mistaken for a calculated one. */
.fee-input.is-overridden { border-left: 3px solid var(--sand); }

.table td.fee-cell { padding-top: var(--s2); padding-bottom: var(--s2); }

.variance-note {
  font-size: 12px;
  line-height: 19px;
  color: var(--grey);
  margin: var(--s3) 0 0;
}
.variance-note strong { color: var(--ink); font-weight: 600; }

/* ---------- Discount ---------- */

.discount-row { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: var(--s2); }

/* ---------- Export ---------- */

.export-row { display: flex; gap: var(--s2); flex-wrap: wrap; }
.export-row .btn { flex: 1; min-width: 130px; text-align: center; }

.toast {
  position: fixed;
  bottom: var(--s5);
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--ink);
  color: var(--white);
  padding: var(--s3) var(--s5);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  z-index: 50;
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Overview ---------- */

.lede { font-size: 15px; line-height: 26px; color: var(--body); max-width: 65ch; margin: 0; }

.section-heading {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--label);
  margin: 0 0 var(--s4);
}

.tool-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--s4);
}

.tool-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--white);
  border: 1px solid var(--rule);
  border-top: 2px solid var(--navy);
  padding: var(--s5);
  transition: background-color 0.15s;
}

.tool-card:hover { background: var(--bone); }
.tool-card-icon { font-size: 18px; color: var(--sand); }
.tool-card h3 {
  margin: var(--s3) 0 var(--s2);
  font-size: 21px;
  line-height: 28px;
  font-weight: 500;
  color: var(--ink);
}
.tool-card p { margin: 0; font-size: 14px; line-height: 24px; color: var(--body); }

/* ---------- Print ----------
   Printing renders a purpose-built document (.print-doc) rather than the
   interactive form. Restyling live inputs into something presentable is
   fragile — they print their raw text ("1.2m") rather than the parsed value —
   so the screen UI is hidden wholesale and the document is built from the
   same numbers the panel shows. */

.print-header, .print-doc { display: none; }

.print-doc section + section { margin-top: var(--s6); }

.print-doc h2 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--label);
  margin: 0 0 var(--s3);
}

.print-doc .table tr.is-total td {
  font-weight: 600;
  color: var(--ink);
  border-top: 2px solid var(--navy);
  border-bottom: none;
}

.print-doc .basis {
  font-size: 12px;
  line-height: 19px;
  color: var(--grey);
  margin: var(--s3) 0 0;
}

@media print {
  .sidebar, .topbar, .grid-2 { display: none !important; }
  .layout { display: block; }
  .content { padding: 0; }
  body { background: var(--white); color: var(--body); }

  .print-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--s5);
    margin-bottom: var(--s6);
    padding-bottom: var(--s4);
    border-bottom: 2px solid var(--navy);
  }
  .print-logo { width: var(--print-logo-width); height: auto; }
  .print-header .print-titles { text-align: right; }
  .print-header h1 {
    font-family: var(--serif);
    font-weight: var(--serif-weight);
    font-size: 30px;
    line-height: 34px;
    letter-spacing: -0.02em;
    color: var(--ink);
    margin: 0;
  }
  .print-header p {
    margin: var(--s2) 0 0;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--label);
  }

  .print-doc { display: block; }
  .print-doc section { break-inside: avoid; page-break-inside: avoid; }

  /* Printing an agreement replaces the page entirely: the calculator's own
     header and working are not part of a client-facing document. */
  body.printing-agreement .print-header,
  body.printing-agreement .print-doc,
  body.printing-agreement .card { display: none !important; }
  body.printing-agreement .agreement-doc { display: block; }
}

@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 20;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .sidebar.is-open { transform: translateX(0); }
  .menu-toggle { display: block; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .content, .topbar { padding-left: var(--s4); padding-right: var(--s4); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
