:root {
  --page: #030a14;
  --ink: #f8fafc;
  --muted: #94a3b8;
  --line: rgba(96, 165, 250, 0.24);
  --panel: rgba(30, 41, 59, 0.68);
  --panel-strong: rgba(15, 23, 42, 0.84);
  --brand: #3b82f6;
  --brand-deep: #2563eb;
  --accent: #8b5cf6;
  --orange: #f97316;
  --blue: #60a5fa;
  --green: #10b981;
  --red: #f87171;
  --teal: #0f766e;
  --shadow: 0 20px 40px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--page);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(59, 130, 246, 0.16), transparent),
    linear-gradient(145deg, #040c1a 0%, #070f20 45%, #0d1a2e 100%);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.page-shell {
  width: min(100%, 520px);
  margin: 0 auto;
  padding: 0 0 36px;
  min-height: 100vh;
}

.site-header {
  min-height: 148px;
  padding: 24px 16px 34px;
  text-align: center;
  color: #ffffff;
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.15), transparent);
}

.brand-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  overflow: hidden;
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.site-header h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.18;
  font-weight: 850;
  letter-spacing: 0;
}

.site-header p {
  margin: 8px 0 0;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 650;
}

.calculator {
  display: grid;
  gap: 14px;
  margin-top: -16px;
}

.calculator > * {
  min-width: 0;
}

.result-card {
  overflow: hidden;
  min-height: 170px;
  margin: 0 16px;
  padding: 22px 20px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  color: #ffffff;
  background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  box-shadow: 0 18px 40px rgba(59, 130, 246, 0.36);
}

.result-eyebrow {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 13px;
  font-weight: 800;
}

.result-label {
  margin-top: 14px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 13px;
  font-weight: 750;
}

.result-money {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin-top: 3px;
}

.result-money span {
  font-size: 22px;
  font-weight: 900;
}

.result-money strong {
  font-size: clamp(42px, 12vw, 58px);
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0;
}

.result-sub {
  margin-top: 12px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 14px;
  font-weight: 800;
}

.control-section,
.price-grid,
.repayment-panel {
  margin: 0 16px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.control-section {
  display: grid;
  gap: 13px;
  padding: 16px;
  min-width: 0;
}

.control-section > * {
  min-width: 0;
}

.field {
  display: grid;
  min-width: 0;
  gap: 7px;
}

.field > span {
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 850;
}

input,
select {
  width: 100%;
  height: 46px;
  min-width: 0;
  border: 2px solid rgba(96, 165, 250, 0.24);
  border-radius: 8px;
  outline: none;
  background: rgba(15, 23, 42, 0.56);
  color: #ffffff;
  padding: 0 12px;
  font-size: 15px;
  font-weight: 700;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

select {
  text-overflow: ellipsis;
}

input::placeholder {
  color: #64748b;
  font-weight: 600;
}

input:focus,
select:focus {
  border-color: var(--brand);
  background: rgba(15, 23, 42, 0.72);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.term-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.choice-btn,
.detail-toggle {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.56);
  color: #e2e8f0;
  cursor: pointer;
  font-weight: 850;
  transition: transform 0.18s ease, border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}

.choice-btn {
  height: 44px;
}

.choice-btn:hover,
.detail-toggle:hover {
  border-color: rgba(96, 165, 250, 0.56);
  background: rgba(30, 41, 59, 0.9);
  color: #ffffff;
}

.choice-btn.active {
  border-color: var(--brand);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.96), rgba(139, 92, 246, 0.96));
  color: #ffffff;
  box-shadow: 0 0 18px rgba(59, 130, 246, 0.32);
}

.quote-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0 16px;
}

.quote-pill {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid rgba(96, 165, 250, 0.24);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.56);
  color: #c7d2fe;
  font-size: 12px;
  font-weight: 850;
}

.quote-pill.product {
  border-color: rgba(16, 185, 129, 0.32);
  background: rgba(6, 78, 59, 0.34);
  color: #bbf7d0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.price-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  background: rgba(96, 165, 250, 0.2);
}

.metric {
  min-width: 0;
  padding: 15px 14px;
  background: rgba(15, 23, 42, 0.58);
}

.metric span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.metric strong {
  display: block;
  color: #ffffff;
  font-size: 22px;
  line-height: 1.15;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.metric.official strong {
  color: #fed7aa;
}

.metric.rent strong {
  color: var(--blue);
}

.metric.cost strong {
  color: var(--green);
}

.metric.residual strong {
  color: var(--red);
}

.repayment-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 72px;
  padding: 15px 16px;
  border-bottom: 1px solid rgba(96, 165, 250, 0.18);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.18), rgba(139, 92, 246, 0.18));
}

.repayment-head h2 {
  margin: 0;
  color: #ffffff;
  font-size: 16px;
  font-weight: 900;
}

.repayment-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.detail-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  gap: 7px;
  min-width: 104px;
  height: 40px;
  padding: 0 12px;
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.chevron {
  display: inline-block;
  font-size: 24px;
  line-height: 1;
  transform: rotate(90deg);
  transition: transform 0.2s ease;
}

.detail-toggle[aria-expanded="true"] .chevron {
  transform: rotate(-90deg);
}

.repayment-content {
  overflow: hidden;
  transition: max-height 0.28s ease, opacity 0.2s ease;
}

.repayment-content.collapsed {
  max-height: 0;
  opacity: 0;
}

.repayment-content:not(.collapsed) {
  max-height: 760px;
  opacity: 1;
}

.table-scroll {
  overflow: hidden;
}

table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 13px;
}

.col-period {
  width: 18%;
}

.col-rent {
  width: 25%;
}

.col-cumulative {
  width: 28%;
}

.col-residual {
  width: 29%;
}

th,
td {
  min-width: 0;
  padding: 12px 8px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
}

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

th {
  color: #94a3b8;
  background: rgba(15, 23, 42, 0.64);
  font-size: 12px;
  font-weight: 900;
}

td {
  color: #e2e8f0;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.down-payment-row td {
  background: rgba(16, 185, 129, 0.12);
  color: #bbf7d0;
  font-weight: 900;
}

.backend-row td {
  background: rgba(59, 130, 246, 0.18);
  color: #bfdbfe;
  font-weight: 900;
}

.backend-row-first td {
  border-top: 2px solid rgba(59, 130, 246, 0.52);
}

.backend-row td:first-child {
  color: #ffffff;
  white-space: normal;
  line-height: 1.25;
}

.backend-row td:last-child {
  color: #60a5fa;
  font-size: 14px;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: rgba(59, 130, 246, 0.12);
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 16px;
  padding: 18px 0 0;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.site-footer a {
  color: inherit;
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--brand-deep);
  text-decoration: underline;
}

@media (min-width: 760px) {
  body {
    background:
      radial-gradient(ellipse 80% 50% at 50% -10%, rgba(59, 130, 246, 0.16), transparent),
      linear-gradient(145deg, #040c1a 0%, #070f20 45%, #0d1a2e 100%);
  }

  .page-shell {
    max-width: 600px;
    padding-top: 20px;
  }

  .control-section {
    grid-template-columns: 1fr 1.35fr;
  }

  .field-search,
  .control-section .field:nth-child(2) {
    grid-column: span 2;
  }
}

@media (max-width: 430px) {
  .page-shell {
    padding-inline: 0;
  }

  .result-card {
    min-height: 164px;
    padding: 20px 16px;
  }

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

  .metric strong {
    font-size: 21px;
  }

  .repayment-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .detail-toggle {
    width: 100%;
  }

  table {
    font-size: 11px;
  }

  th,
  td {
    padding: 10px 4px;
  }

  .down-payment-row td {
    font-size: 11px;
  }

  .backend-row td {
    padding-block: 11px;
  }

  .backend-row td:first-child {
    width: auto;
  }

  .backend-row td:last-child {
    font-size: 12px;
  }
}
