:root {
  --bg: radial-gradient(circle at 20% 0%, #ffffff 0%, #f4f6f8 45%, #eef2f6 100%);
  --ink: #1f2a37;
  --muted: #516073;
  --card: #ffffff;
  --accent: #2f7a3d;
  --accent-strong: #1f5d2b;
  --accent-soft: #e7f4ea;
  --line: #d9e0e7;
  --surface: #f6f8fa;
  --shadow: 0 6px 18px rgba(18, 28, 38, 0.08);
  --radius: 10px;
  --mono: "Source Sans 3", "Segoe UI", sans-serif;
  --display: "Merriweather", "Times New Roman", serif;
  --success: #2c9b4e;
  --error: #c53030;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--mono);
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}

a {
  color: var(--accent-strong);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.site-header__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.logo {
  font-weight: 700;
  font-size: 1.35rem;
  color: var(--accent-strong);
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.logo img,
.logo svg {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.logo svg {
  display: block;
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.nav-link {
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 600;
}

.nav-link.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.header-note {
  margin-left: auto;
  font-size: 0.9rem;
  color: var(--muted);
}

.layout {
  max-width: 1200px;
  margin: 1.6rem auto 3rem;
  padding: 0 1rem;
  display: block;
}

.sidebar {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  position: sticky;
  top: 1.5rem;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.sidebar-main,
.sidebar-resources {
  display: flex;
  flex-direction: column;
}

.sidebar-resources {
  margin-top: auto;
}

.sidebar h2 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin: 0 0 0.75rem;
  color: var(--muted);
}

.side-link {
  display: block;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  color: var(--ink);
  margin-bottom: 0.35rem;
}

.side-link.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.side-card {
  margin-top: 1rem;
  padding: 0.75rem 0.85rem;
  border-radius: 8px;
  border: 1px dashed var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.9rem;
}

.content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.page-header {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

.page-header h1 {
  margin: 0 0 0.4rem;
  font-family: var(--display);
  font-size: 1.8rem;
}

.page-header p {
  margin: 0;
  color: var(--muted);
}

.page-actions {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.btn {
  border: 1px solid var(--accent-strong);
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 0.95rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 6px 12px rgba(31, 93, 43, 0.18);
}

.btn.secondary {
  background: #fff;
  color: var(--accent-strong);
  border-color: var(--line);
  box-shadow: none;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled,
.btn.disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.calc-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(360px, 1fr);
  gap: 1.25rem;
  animation: fadeUp 0.4s ease;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem 1.3rem;
  box-shadow: var(--shadow);
}

.card h2,
.card h3 {
  margin: 0 0 1rem;
  font-size: 1.15rem;
}

.table-card {
  grid-column: 1 / -1;
}

.section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 600;
  margin: 0.5rem 0 0.75rem;
}

.field {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.85rem;
}

.field > label {
  font-weight: 600;
}

.field > label.inline {
  grid-column: 1 / -1;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.field > :not(label) {
  grid-column: 2;
}

.down-hint {
  grid-column: 2;
  margin: -0.45rem 0 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
}

label.inline input[type="checkbox"] {
  margin: 0;
}

/* Narrow calculator inputs to match calculator.net style */
.calc-grid .field {
  grid-template-columns: 140px 1fr;
  gap: 0.55rem;
  margin-bottom: 0.7rem;
}

.calc-grid .field > :not(label) {
  max-width: 190px;
}

.calc-grid .down-hint {
  max-width: 190px;
}

.calc-grid input,
.calc-grid select,
.calc-grid textarea {
  max-width: 190px;
  padding: 0.45rem 0.6rem;
  font-size: 0.9rem;
}

.calc-grid .input-suffix {
  width: min(190px, 100%);
}

.calc-grid .segmented-btn {
  padding: 0.25rem 0.55rem;
  font-size: 0.8rem;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border-radius: 6px;
  border: 1px solid #c9d2dc;
  font-size: 0.95rem;
  background: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 122, 61, 0.12);
}

input.valid {
  border-color: var(--success);
}

input.invalid {
  border-color: var(--error);
}

.inline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  overflow: hidden;
}

.segmented-btn {
  border: none;
  background: transparent;
  padding: 0.35rem 0.7rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.segmented-btn.active {
  background: #fff;
  color: var(--accent-strong);
  box-shadow: inset 0 0 0 1px var(--line);
}

.input-suffix {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: min(240px, 100%);
}

.input-suffix input {
  padding-right: 2.2rem;
}

.input-suffix .suffix {
  position: absolute;
  right: 0.6rem;
  font-weight: 700;
  color: var(--muted);
  display: none;
  pointer-events: none;
}

.input-suffix.show .suffix {
  display: inline;
  color: var(--accent-strong);
}

.compare-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.compare-col {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem;
  background: var(--surface);
}

.compare-col .scenario-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.results {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.result {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem 0.85rem;
}

.result.highlight {
  background: var(--accent-soft);
  border-color: rgba(47, 122, 61, 0.25);
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}

.result span {
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.result strong {
  font-size: 1.2rem;
}

.empty-state {
  margin: 0.75rem 0 0;
  padding: 0.75rem 0.85rem;
  border-radius: 8px;
  background: var(--surface);
  border: 1px dashed var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

.amort-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  padding: 0.55rem 0.5rem;
  text-align: right;
  border-bottom: 1px solid var(--line);
}

th:first-child,
td:first-child {
  text-align: left;
}

.table-wrap {
  margin-top: 0.8rem;
  overflow-x: auto;
}

.compare-summary {
  margin-top: 1rem;
  border: 1px solid rgba(47, 122, 61, 0.18);
  border-radius: 10px;
  padding: 0.85rem;
  background: #f7fbf8;
}

.compare-summary .scenario-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 0.5rem;
}

.history-card {
  animation: fadeUp 0.45s ease;
}

.history-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.history-list {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.history-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.85rem;
  background: var(--surface);
}

.history-header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
}

.history-header span {
  color: var(--muted);
  font-size: 0.85rem;
}

.history-section {
  margin-top: 0.75rem;
}

.history-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.history-grid {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.history-card span {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.2rem;
}

.history-card strong {
  font-size: 0.95rem;
}

.faq {
  background: var(--card);
}

.faq-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.faq-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.85rem;
  background: var(--surface);
}

.faq-item h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.faq-item p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.contact-card textarea {
  resize: vertical;
}

.contact-note {
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.disclaimer {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.muted {
  color: var(--muted);
}

.legal h1 {
  margin-top: 0;
}

.legal-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--card);
  padding: 1rem;
}

.footer-links {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.9rem;
}

.legal-button {
  border: none;
  padding: 0;
  background: transparent;
  color: var(--accent-strong);
  font: inherit;
  cursor: pointer;
}

.legal-button:hover {
  text-decoration: underline;
}

.ad-slot {
  margin-top: 1rem;
  padding: 1rem;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.85rem;
  background: #fbfcfd;
  display: grid;
  gap: 0.35rem;
  min-height: 110px;
}

.ad-slot--inline {
  margin: 1rem 0;
}

.ad-slot__label {
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.02em;
}

.ad-slot__note {
  font-size: 0.8rem;
  color: var(--muted);
}

.ad-slot--active {
  border: none;
  background: transparent;
  padding: 0;
  min-height: auto;
}

.ad-slot--placeholder {
  opacity: 0.95;
}

.ad-disclaimer {
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  padding: 0.75rem 0.85rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.callout {
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  padding: 0.85rem;
  border-radius: 6px;
  margin: 1rem 0;
  color: var(--ink);
}

.info-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin: 1rem 0;
}

.info-tile {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.85rem;
  background: var(--surface);
}

.info-tile h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.info-tile p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.checklist {
  margin: 0.75rem 0 0;
  padding-left: 1.1rem;
  color: var(--muted);
}

.checklist li {
  margin-bottom: 0.4rem;
}

.lease-config {
  margin-top: 0.5rem;
  padding: 0.75rem;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fcf7ef;
  color: var(--muted);
  font-size: 0.88rem;
}

.lease-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.5rem;
}

.lease-row label {
  font-weight: 500;
  font-size: 0.9rem;
}

.info-btn {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid rgba(47, 122, 61, 0.25);
  background: var(--surface);
  color: var(--accent-strong);
  font-weight: 700;
  font-size: 0.75rem;
  cursor: pointer;
  flex-shrink: 0;
}

.info-popover {
  position: absolute;
  max-width: 240px;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid rgba(47, 122, 61, 0.2);
  box-shadow: 0 12px 24px rgba(13, 27, 45, 0.12);
  font-size: 0.85rem;
  color: var(--ink);
  z-index: 20;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.info-popover.show {
  opacity: 1;
  transform: translateY(0);
}

.details,
details {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  background: #fff;
  margin-bottom: 1rem;
}

details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent-strong);
}

details summary::marker {
  color: var(--accent-strong);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 999;
}

.modal.open {
  display: flex;
}

.modal-content {
  background: #fff;
  border-radius: 12px;
  max-width: 960px;
  width: min(960px, 92vw);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  box-shadow: 0 24px 60px rgba(15, 26, 44, 0.25);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.modal-body {
  padding: 1rem 1.25rem 1.25rem;
  overflow: auto;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--muted);
}

.cookie-consent {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 1rem 1.5rem;
  box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.08);
  z-index: 1000;
  display: none;
}

.cookie-consent.show {
  display: block;
}

.cookie-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
}

.cookie-text {
  flex: 1;
  min-width: 280px;
}

.cookie-text p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.cookie-buttons {
  display: flex;
  gap: 0.75rem;
}

.download-status {
  font-size: 0.85rem;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.error-page {
  max-width: 800px;
  margin: 2.5rem auto;
  padding: 0 1rem;
  display: flex;
  justify-content: center;
}

.error-card {
  text-align: center;
}

.error-card h1 {
  font-family: var(--display);
  font-size: 3rem;
  margin: 0 0 0.5rem;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1000px) {
  .sidebar {
    display: none;
  }

  .header-note {
    width: 100%;
    margin-left: 0;
  }

  .calc-grid {
    grid-template-columns: 1fr;
  }

  .field {
    grid-template-columns: 1fr;
  }

  .field > :not(label) {
    grid-column: auto;
  }

  .down-hint {
    grid-column: auto;
    margin-top: -0.25rem;
  }

  .page-actions {
    width: 100%;
    margin-left: 0;
  }
}

@media (max-width: 600px) {
  .site-header__inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .top-nav {
    width: 100%;
  }

  .top-nav .nav-link {
    flex: 1 1 auto;
    text-align: center;
  }
}
