:root {
  --ink: #11171c;
  --ink-soft: #27313a;
  --muted: #6d7882;
  --paper: #f7f6f2;
  --white: #ffffff;
  --line: #d8dde1;
  --line-dark: #b7c0c7;
  --green: #1b7759;
  --green-soft: #edf5f1;
  --brown: #93674d;
  --red: #9a4740;
  --red-soft: #fbf0ee;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--paper);
  font-family: Arial, Helvetica, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { color: inherit; }
h1, h2, p { margin-top: 0; }

.skip-link {
  position: fixed;
  top: -4rem;
  left: 1rem;
  z-index: 20;
  padding: 0.7rem 1rem;
  color: #fff;
  background: var(--ink);
}

.skip-link:focus { top: 1rem; }

/* Login */
.login-page {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 1.5rem 1.25rem;
  background: #faf9f6;
}

.login-shell {
  width: min(100%, 480px);
  align-self: center;
  text-align: center;
}

.login-brand {
  margin-bottom: clamp(3rem, 7vh, 4.75rem);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3.9rem, 8vw, 5.8rem);
  line-height: 0.9;
  letter-spacing: -0.055em;
}

.login-form { display: grid; gap: 1.15rem; text-align: left; }

.login-field { display: grid; gap: 0.55rem; }

.login-field span {
  font-size: 0.88rem;
  font-weight: 700;
}

.login-field input {
  width: 100%;
  height: 58px;
  padding: 0 1rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  outline: none;
  color: var(--ink);
  background: var(--white);
  font-size: 1rem;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.login-field input::placeholder { color: #92999e; }

.login-field input:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(17, 23, 28, 0.08);
}

.login-error {
  margin: -0.15rem 0 0;
  padding: 0.75rem 0.85rem;
  color: #7d302b;
  background: var(--red-soft);
  border-left: 3px solid var(--red);
  font-size: 0.84rem;
}

.login-button {
  height: 58px;
  margin-top: 1.2rem;
  border: 1px solid var(--ink);
  border-radius: 2px;
  color: #fff;
  background: var(--ink);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 140ms ease, transform 140ms ease;
}

.login-button:hover { background: #222a30; }
.login-button:active { transform: translateY(1px); }

/* Calculator */
.calculator-page { background: var(--white); }

.shipstone-bar {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--line);
  background: #fbfbfa;
}

.mini-brand {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.12rem;
  letter-spacing: -0.025em;
  text-decoration: none;
}

.calculator-header {
  min-height: 90px;
  display: flex;
  align-items: center;
  padding: 1.1rem 1.5rem 1.25rem;
  border-bottom: 1px solid var(--line);
}

.calculator-header h1 {
  margin-bottom: 0.35rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 3vw, 2.7rem);
  font-weight: 400;
  letter-spacing: -0.025em;
  line-height: 1;
}

.calculator-header > div > p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1rem;
}

.logout-button,
.reset-button {
  border: 0;
  border-bottom: 1px solid currentColor;
  color: var(--muted);
  background: transparent;
  font-size: 0.76rem;
  cursor: pointer;
}

.logout-button { padding: 0.25rem 0; }
.logout-button:hover, .reset-button:hover { color: var(--ink); }

.calculator-layout {
  min-height: calc(100vh - 142px);
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
}

.assumptions-panel {
  padding: 1.75rem 1.5rem 2rem;
  border-right: 1px solid var(--line);
  background: #fbfbfa;
}

.panel-heading,
.chart-header,
.utilization-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.panel-heading h2 {
  margin-bottom: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.3rem;
  font-weight: 400;
}

.input-stack {
  display: grid;
  gap: 1rem;
  margin-top: 1.4rem;
}

.field { display: grid; gap: 0.48rem; }

.field > span:first-child,
.utilization-label-row > label:first-child {
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.input-frame {
  height: 50px;
  display: flex;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--white);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.input-frame:focus-within {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(17, 23, 28, 0.06);
}

.input-frame input {
  min-width: 0;
  flex: 1;
  height: 100%;
  padding: 0 0.85rem;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-weight: 700;
}

.currency { padding-left: 0.85rem; color: var(--muted); }
.currency + input { padding-left: 0.35rem; }
.unit { flex: none; padding-right: 0.8rem; color: var(--muted); font-size: 0.76rem; }
.two-up { display: grid; grid-template-columns: 0.8fr 1.2fr; gap: 0.75rem; }

.utilization-control {
  margin-top: 1.65rem;
  padding-top: 1.35rem;
  border-top: 1px solid var(--line);
}

.percent-entry {
  width: 70px;
  height: 38px;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  background: #fff;
}

.percent-entry input {
  width: 49px;
  height: 100%;
  padding-left: 0.55rem;
  border: 0;
  outline: 0;
  background: transparent;
  font-weight: 700;
}

.percent-entry span { color: var(--muted); font-size: 0.8rem; }

.range {
  width: 100%;
  height: 28px;
  margin: 0.95rem 0 0.2rem;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

.range::-webkit-slider-runnable-track {
  height: 5px;
  border: 1px solid #a8afb3;
  border-radius: 5px;
  background: linear-gradient(to right, var(--ink) var(--range-fill, 82%), #ececea var(--range-fill, 82%));
}

.range::-webkit-slider-thumb {
  width: 19px;
  height: 19px;
  margin-top: -8px;
  appearance: none;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
}

.range::-moz-range-track { height: 5px; border: 1px solid #a8afb3; border-radius: 5px; background: #ececea; }
.range::-moz-range-progress { height: 5px; background: var(--ink); }
.range::-moz-range-thumb { width: 19px; height: 19px; border: 0; border-radius: 50%; background: var(--ink); }

.range-scale {
  display: flex;
  justify-content: space-between;
  color: #91999e;
  font-size: 0.65rem;
}

.results-panel { min-width: 0; padding: 1.7rem; }
.kpi-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }

.kpi-card {
  min-width: 0;
  min-height: 126px;
  padding: 1.25rem 1.35rem;
  border: 1px solid var(--line);
  border-right: 0;
  background: #fff;
}

.kpi-card:last-child { border-right: 1px solid var(--line); }

.kpi-card p {
  margin-bottom: 1rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.kpi-card strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: clamp(1.45rem, 2.25vw, 2.25rem);
  letter-spacing: -0.035em;
}

.kpi-card span {
  display: block;
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.82rem;
}

#equilibrium-card strong { color: var(--green); }

.chart-card {
  margin-top: 1.35rem;
  padding: 1.25rem 1.35rem 0;
  border: 1px solid var(--line);
  background: #fff;
}

.chart-header h2 {
  margin-bottom: 0.3rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
  font-weight: 400;
}

.chart-header p { margin-bottom: 0; color: var(--muted); font-size: 0.76rem; }
.legend { display: flex; flex-wrap: wrap; gap: 1rem; color: var(--muted); font-size: 0.72rem; }
.legend span { display: inline-flex; align-items: center; gap: 0.45rem; }
.legend-line { width: 24px; height: 2px; display: block; background: var(--ink); }
.legend-line.tenancy { background: var(--brown); }

.chart-wrap { position: relative; height: min(46vh, 430px); min-height: 310px; margin-top: 0.85rem; }
#cost-chart { width: 100%; height: 100%; display: block; }

.decision-callout {
  min-height: 68px;
  display: grid;
  grid-template-columns: minmax(15rem, 0.9fr) minmax(18rem, 1.1fr) auto;
  align-items: center;
  gap: 1.5rem;
  margin: 0 -1.35rem;
  padding: 0.9rem 1.35rem;
  border-top: 1px solid var(--line);
  background: var(--green-soft);
}

.decision-callout.negative { background: var(--red-soft); }
.decision-callout.neutral { background: #f1f2f1; }
.decision-callout p { margin-bottom: 0; }
.decision-callout strong { display: block; color: var(--green); font-size: 0.98rem; }
.decision-callout.negative strong { color: var(--red); }
.decision-callout.neutral strong { color: var(--muted); }
.decision-callout > p { justify-self: end; max-width: 390px; color: var(--ink-soft); font-size: 0.84rem; line-height: 1.45; }
.decision-icon { color: var(--green); font-size: 1.15rem; font-weight: 700; }
.negative .decision-icon { color: var(--red); }
.neutral .decision-icon { color: var(--muted); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1050px) {
  .calculator-layout { grid-template-columns: 320px minmax(0, 1fr); }
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-card { min-height: 92px; border-right: 1px solid var(--line); border-bottom: 0; }
  .kpi-card:last-child { border-bottom: 1px solid var(--line); }
}

@media (max-width: 760px) {
  .shipstone-bar { padding: 0 1.1rem; }
  .calculator-header { min-height: auto; padding: 1.1rem; }
  .calculator-header > div > p:last-child { font-size: 0.88rem; }
  .calculator-layout { min-height: 0; grid-template-columns: 1fr; }
  .assumptions-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .results-panel { padding: 1rem; }
  .chart-card { padding: 1rem 1rem 0; }
  .chart-header { align-items: flex-start; flex-direction: column; }
  .chart-wrap { height: 330px; min-height: 0; }
  .decision-callout { grid-template-columns: 1fr auto; margin: 0 -1rem; padding: 0.9rem 1rem; }
  .decision-callout > p { grid-column: 1 / -1; grid-row: 2; justify-self: start; }
}

@media (max-width: 480px) {
  .login-brand { margin-bottom: 4rem; }
  .two-up { grid-template-columns: 1fr; }
  .chart-wrap { height: 280px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
