:root {
  color-scheme: light;
  --bg: #f4f6f7;
  --surface: #ffffff;
  --surface-quiet: #eef3f2;
  --ink: #20252a;
  --muted: #687078;
  --line: #d9e0df;
  --teal: #0e8f83;
  --teal-deep: #096d64;
  --coral: #d95f4c;
  --amber: #bd8728;
  --steel: #3c6f8d;
  --good: #127a4a;
  --bad: #b44135;
  --shadow: 0 18px 42px rgba(22, 36, 42, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(14, 143, 131, 0.08), rgba(244, 246, 247, 0) 320px),
    var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1480px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px;
}

.tool-layout {
  display: grid;
  grid-template-columns: minmax(360px, 470px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.input-panel,
.output-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.input-panel {
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 18px;
}

.output-panel {
  min-height: calc(100vh - 40px);
  padding: 22px;
}

.brand-row,
.result-header,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand-row > div:last-child,
.result-header > div:first-child,
.section-heading > div:first-child {
  min-width: 0;
}

.brand-row {
  align-items: flex-start;
  justify-content: space-between;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.brand-identity {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  gap: 14px;
}

.brand-mark {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border: 2px solid var(--teal);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(14, 143, 131, 0.12) 0 50%, transparent 51%),
    linear-gradient(45deg, transparent 0 44%, var(--coral) 45% 55%, transparent 56%);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.2;
}

.brand-row p,
.section-heading p,
.result-header .eyebrow,
.metric-card span,
.metric-card small,
.disclaimer {
  color: var(--muted);
}

.brand-row p {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.planner-form {
  display: grid;
  gap: 18px;
  padding-top: 18px;
}

.form-section {
  display: grid;
  gap: 12px;
}

.section-heading h2 {
  font-size: 15px;
  line-height: 1.3;
}

.minor-heading {
  margin-top: 2px;
  justify-content: flex-start;
}

.section-heading p {
  font-size: 12px;
}

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

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

label span {
  color: #4e565d;
  font-size: 12px;
  line-height: 1.25;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
  padding: 0 11px;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(14, 143, 131, 0.13);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  min-height: 42px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-quiet);
}

.segmented.two-option {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.segmented label {
  display: block;
  position: relative;
  min-width: 0;
}

.segmented input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.segmented span {
  display: grid;
  min-height: 32px;
  place-items: center;
  border-radius: 6px;
  color: #4a545b;
  font-size: 12px;
  text-align: center;
  cursor: pointer;
  white-space: nowrap;
}

.segmented input:checked + span {
  background: var(--surface);
  color: var(--teal-deep);
  box-shadow: 0 1px 4px rgba(21, 34, 38, 0.12);
}

.result-header {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--teal-deep);
  font-size: 12px;
  font-weight: 700;
}

.result-header h2 {
  font-size: clamp(22px, 3vw, 36px);
  line-height: 1.12;
}

.icon-button {
  display: grid;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--teal);
  color: var(--teal-deep);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.metric-card {
  display: grid;
  align-content: space-between;
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
}

.metric-card-primary {
  border-color: rgba(14, 143, 131, 0.45);
  background: linear-gradient(180deg, rgba(14, 143, 131, 0.1), rgba(255, 255, 255, 0.95));
}

.metric-card span {
  font-size: 13px;
}

.metric-card strong {
  margin: 10px 0 4px;
  color: var(--ink);
  font-size: clamp(25px, 3vw, 40px);
  line-height: 1;
}

.metric-card small {
  min-height: 18px;
  font-size: 12px;
  line-height: 1.35;
}

.tax-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.tax-strip div {
  display: grid;
  gap: 5px;
  min-height: 74px;
  align-content: center;
  background: #f9fbfb;
  padding: 12px 14px;
}

.tax-strip span {
  color: var(--muted);
  font-size: 12px;
}

.tax-strip strong {
  overflow-wrap: anywhere;
  color: #263038;
  font-size: 18px;
  line-height: 1.15;
}

.cost-section {
  display: grid;
  gap: 14px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  overflow: visible;
}

.cost-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.cost-grid article {
  position: relative;
  display: grid;
  gap: 6px;
  min-height: 104px;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  padding: 13px 14px;
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
  cursor: help;
}

.cost-grid article:hover,
.cost-grid article:focus,
.cost-grid article:focus-visible {
  z-index: 3;
  border-color: rgba(14, 143, 131, 0.5);
  box-shadow: 0 12px 28px rgba(22, 36, 42, 0.12);
  transform: translateY(-1px);
}

.floating-tooltip {
  position: fixed;
  z-index: 100;
  display: none;
  max-width: min(360px, calc(100vw - 32px));
  border: 1px solid rgba(14, 143, 131, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 42px rgba(22, 36, 42, 0.16);
  color: #2f383d;
  font-size: 12px;
  line-height: 1.55;
  padding: 12px 13px;
  pointer-events: none;
  white-space: pre-line;
}

.floating-tooltip.visible {
  display: block;
}

.cost-grid span,
.cost-grid small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.cost-grid strong {
  color: #20252a;
  font-size: 24px;
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.cost-inline-edit {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.cost-inline-edit input {
  width: min(100%, 130px);
  min-height: 30px;
  border-radius: 6px;
  padding: 0 8px;
  font-size: 13px;
}

.cost-inline-edit span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
}

.visual-section,
.insight-section {
  display: grid;
  gap: 14px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.canvas-wrap {
  width: 100%;
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(60, 111, 141, 0.06), rgba(255, 255, 255, 0)),
    var(--surface);
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  height: 340px;
}

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

.scenario-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
}

.scenario-name {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scenario-sub {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.scenario-age {
  color: var(--teal-deep);
  font-size: 21px;
  font-weight: 800;
  white-space: nowrap;
}

.scenario-age.warn {
  color: var(--bad);
}

.insight-list {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.insight-list li {
  border-left: 4px solid var(--teal);
  border-radius: 6px;
  background: #f7faf9;
  padding: 11px 12px;
  color: #384046;
  font-size: 14px;
  line-height: 1.6;
}

.insight-list li:nth-child(2) {
  border-left-color: var(--coral);
}

.insight-list li:nth-child(3) {
  border-left-color: var(--amber);
}

.offer-section {
  display: grid;
  gap: 14px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.offer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.offer-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 156px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  padding: 16px;
}

.offer-card-accent {
  border-color: rgba(14, 143, 131, 0.38);
  background: linear-gradient(180deg, rgba(14, 143, 131, 0.08), rgba(255, 255, 255, 0.96));
}

.offer-card-primary {
  border-color: rgba(14, 143, 131, 0.42);
  background:
    linear-gradient(180deg, rgba(14, 143, 131, 0.08), rgba(255, 255, 255, 0.98)),
    var(--surface);
}

.offer-tag {
  display: inline-flex;
  width: fit-content;
  border: 1px solid rgba(14, 143, 131, 0.25);
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--teal-deep);
  font-size: 12px;
  font-weight: 700;
}

.offer-card h3 {
  margin: 10px 0 7px;
  color: var(--ink);
  font-size: 17px;
  line-height: 1.28;
}

.offer-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.offer-price {
  color: var(--ink);
  font-size: 28px;
  font-weight: 850;
  line-height: 1;
  white-space: nowrap;
}

.primary-action,
.secondary-action,
.text-action {
  min-height: 38px;
  border-radius: 8px;
  cursor: pointer;
}

.primary-action {
  grid-column: 1 / -1;
  border: 1px solid var(--teal);
  background: var(--teal);
  color: #ffffff;
  font-weight: 800;
}

.primary-action:hover {
  background: var(--teal-deep);
  border-color: var(--teal-deep);
}

.secondary-action {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
}

.secondary-action:hover,
.text-action:hover {
  border-color: var(--teal);
  color: var(--teal-deep);
}

.text-action {
  border: 1px solid transparent;
  background: transparent;
  color: var(--teal-deep);
  padding: 0 8px;
}

.experiment-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px dashed rgba(14, 143, 131, 0.35);
  border-radius: 8px;
  background: rgba(14, 143, 131, 0.05);
  padding: 9px 12px;
  color: var(--muted);
  font-size: 12px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: rgba(17, 28, 32, 0.42);
  padding: 18px;
}

.modal-backdrop[hidden] {
  display: none;
}

.conversion-modal {
  width: min(620px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 30px 70px rgba(14, 30, 36, 0.24);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 18px;
}

.modal-header h2 {
  font-size: 22px;
  line-height: 1.25;
}

.modal-body {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.order-summary {
  display: grid;
  gap: 6px;
  border: 1px solid rgba(14, 143, 131, 0.25);
  border-radius: 8px;
  background: rgba(14, 143, 131, 0.06);
  padding: 13px 14px;
}

.order-summary span {
  color: var(--teal-deep);
  font-size: 30px;
  font-weight: 850;
  line-height: 1;
}

.order-summary p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.conversion-form {
  display: grid;
  gap: 12px;
}

.field-label {
  display: block;
  margin-bottom: 7px;
  color: #4e565d;
  font-size: 12px;
  line-height: 1.25;
}

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

.payment-methods label {
  display: block;
  position: relative;
}

.payment-methods input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.payment-methods span {
  display: grid;
  min-height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: #4a545b;
  font-size: 14px;
  font-weight: 750;
  cursor: pointer;
}

.payment-methods input:checked + span {
  border-color: var(--teal);
  background: rgba(14, 143, 131, 0.08);
  color: var(--teal-deep);
  box-shadow: 0 0 0 3px rgba(14, 143, 131, 0.1);
}

.conversion-form[hidden],
.conversion-result[hidden] {
  display: none;
}

textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  outline: none;
  padding: 10px 11px;
  resize: vertical;
}

textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(14, 143, 131, 0.13);
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.check-row input {
  flex: 0 0 16px;
  width: 16px;
  min-height: 16px;
  margin-top: 2px;
}

.check-row span {
  color: var(--muted);
  line-height: 1.5;
}

.conversion-result {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.conversion-result h3 {
  margin: 0;
  font-size: 16px;
}

.conversion-result pre {
  max-height: 220px;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf9;
  padding: 12px;
  color: #314047;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.disclaimer {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  font-size: 12px;
  line-height: 1.6;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 5;
  border: 1px solid rgba(14, 143, 131, 0.3);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 10px 14px;
  color: var(--teal-deep);
  font-size: 13px;
}

@media (max-width: 1180px) {
  .tool-layout {
    grid-template-columns: 1fr;
  }

  .input-panel {
    position: static;
    max-height: none;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 10px;
  }

  .input-panel,
  .output-panel {
    padding: 14px;
  }

  .field-grid,
  .metric-grid,
  .tax-strip,
  .cost-grid,
  .offer-grid,
  .scenario-list,
  .payment-methods {
    grid-template-columns: 1fr;
  }

  .offer-card {
    grid-template-columns: 1fr;
  }

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

  .result-header {
    align-items: flex-start;
  }

  .metric-card {
    min-height: 112px;
  }

  .experiment-strip,
  .modal-actions {
    align-items: stretch;
    flex-direction: column;
  }
}
