:root {
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
  color: #18302b;
  background: #f7f6f2;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --bg: #f7f6f2;
  --surface: #fffefa;
  --ink: #18302b;
  --muted: #6d7672;
  --line: #dddcd5;
  --line-strong: #c9cac3;
  --green: #07835d;
  --green-dark: #056c4c;
  --green-soft: #e8f4ef;
  --red: #e55745;
  --red-soft: #fff0ed;
  --lime: #b7dc4a;
  --shadow: 0 8px 24px rgba(28, 52, 46, 0.06);
}

* { box-sizing: border-box; }

body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--bg); }
button, input { font: inherit; }
button { color: inherit; }

.app-shell { min-height: 100vh; }
.topbar {
  height: 58px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 max(28px, calc((100vw - 1440px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(247, 246, 242, 0.96);
  color: #5e6965;
  font-size: 14px;
}
.brand { color: var(--green-dark); font-size: 23px; font-weight: 800; letter-spacing: -0.06em; }
.brand-divider { width: 1px; height: 20px; background: var(--line-strong); }

.calculator-tabs {
  height: 48px;
  display: flex;
  justify-content: center;
  gap: 42px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 254, 250, 0.46);
}
.calculator-tab {
  position: relative;
  min-width: 96px;
  padding: 0 5px;
  border: 0;
  background: transparent;
  color: #68716d;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.calculator-tab::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  background: var(--green);
  transform: scaleX(0);
  transition: transform 160ms ease;
}
.calculator-tab:hover { color: var(--green-dark); }
.calculator-tab.active { color: var(--green-dark); }
.calculator-tab.active::after { transform: scaleX(1); }
.calculator-view[hidden] { display: none !important; }

main { width: min(1440px, calc(100% - 56px)); margin: 0 auto; padding: 24px 0 34px; }
.intro { display: flex; align-items: stretch; gap: 18px; margin: 0 2px 18px; }
.intro-rail { width: 8px; min-height: 72px; background: var(--green); }
.intro h1 { margin: 1px 0 6px; font-size: clamp(28px, 2.4vw, 38px); line-height: 1.2; letter-spacing: -0.04em; }
.intro p { margin: 0; color: var(--muted); font-size: 16px; line-height: 1.7; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 14px; align-items: stretch; }
.panel { border: 1px solid var(--line); background: rgba(255, 254, 250, 0.72); border-radius: 13px; }
.form-panel, .results-panel { padding: 16px 18px 14px; }
.section-title { display: flex; align-items: center; gap: 10px; margin: 0 0 13px; font-size: 19px; line-height: 1.3; letter-spacing: -0.02em; }
.section-title::before { content: ""; width: 5px; height: 21px; background: var(--green); flex: 0 0 auto; }

.form-grid { display: grid; gap: 8px; }
.form-field { display: grid; grid-template-columns: 150px 1fr; align-items: center; gap: 12px; font-size: 14px; font-weight: 700; }
.input-wrap { position: relative; display: block; }
.input-wrap input, .person-text, .share-input input {
  width: 100%;
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.input-wrap input { padding: 0 48px 0 11px; }
.input-wrap input[name="projectName"] { padding-right: 11px; }
.input-wrap input:focus, .person-text:focus, .share-input:focus-within {
  border-color: var(--green);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(7, 131, 93, 0.12);
}
.input-suffix { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: #707873; font-size: 13px; font-weight: 500; pointer-events: none; }
.section-separator { height: 1px; background: var(--line); margin: 12px 0 10px; }

.mode-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13px; }
.mode-label { min-width: 91px; font-weight: 700; }
.mode-option {
  height: 31px; padding: 0 13px; border: 1px solid var(--line-strong); border-radius: 5px;
  background: transparent; color: #59645f; display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
}
.mode-option i { width: 13px; height: 13px; border: 1px solid var(--line-strong); border-radius: 50%; background: #fff; }
.mode-option.active { color: var(--green-dark); border-color: #90b7aa; background: #f9fdfa; font-weight: 700; }
.mode-option.active i { border: 4px solid var(--green); }

.participant-table { border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.participant-head, .participant-row { display: grid; grid-template-columns: 1.05fr 1.25fr 1fr 66px; align-items: center; column-gap: 8px; padding: 0 10px; }
.participant-head { min-height: 27px; background: rgba(245, 244, 240, 0.8); color: #606964; font-size: 12px; font-weight: 700; }
.participant-row { min-height: 38px; border-top: 1px solid var(--line); transition: background 140ms ease; }
.participant-row:hover { background: rgba(232, 244, 239, 0.42); }
.person-text { height: 29px; padding: 0 6px; border-color: transparent; background: transparent; font-size: 13px; }
.role-input { color: #67706c; }
.share-input { height: 29px; display: flex; align-items: center; border: 1px solid var(--line-strong); border-radius: 5px; background: #fff; overflow: hidden; }
.share-input input { height: 27px; padding: 0 5px 0 8px; border: 0; border-radius: 0; text-align: right; box-shadow: none !important; }
.share-input span { padding-right: 8px; color: #69716d; font-size: 12px; }
.icon-button { width: 30px; height: 30px; display: inline-grid; place-items: center; margin: auto; border: 0; background: transparent; border-radius: 5px; cursor: pointer; }
.icon-button svg, .add-person svg, .disclaimer svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon-button.danger { color: var(--red); }
.icon-button:hover { background: var(--red-soft); }
.locked { color: #8a918e; text-align: center; font-size: 12px; }
.add-person { width: 100%; height: 31px; border: 0; border-top: 1px solid var(--line); background: transparent; color: var(--green-dark); display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 13px; font-weight: 700; cursor: pointer; }
.add-person:hover { background: var(--green-soft); }
.allocation-total { margin-top: 6px; text-align: right; color: var(--green-dark); font-size: 12px; }
.allocation-total.error { color: var(--red); }

.form-actions { display: grid; grid-template-columns: 1.15fr .95fr; gap: 34px; margin-top: 11px; }
.primary-button, .secondary-button { height: 37px; border-radius: 5px; font-size: 14px; font-weight: 800; cursor: pointer; transition: transform 140ms ease, background 140ms ease; }
.primary-button { border: 1px solid var(--green-dark); color: #fff; background: var(--green); box-shadow: inset 0 -2px 0 rgba(0,0,0,.08); }
.secondary-button { border: 1px solid #9ba39f; color: #47544f; background: transparent; }
.primary-button:hover { background: var(--green-dark); transform: translateY(-1px); }
.secondary-button:hover { background: #eeeee9; }

.result-animation { min-width: 0; }
.result-animation .results-panel { height: 100%; animation: resultIn 420ms ease both; }
@keyframes resultIn { from { opacity: .55; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }
.result-hero { min-height: 182px; display: grid; grid-template-columns: 1fr 250px; align-items: center; padding: 22px 28px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.42); box-shadow: var(--shadow); }
.hero-label { display: block; font-size: 17px; font-weight: 700; margin-bottom: 12px; }
.hero-money { display: block; font-size: clamp(36px, 4vw, 55px); line-height: 1.08; letter-spacing: -0.045em; font-variant-numeric: tabular-nums; }
.positive { color: var(--green-dark) !important; }
.negative { color: var(--red) !important; }
.status-line { display: inline-flex; margin-top: 12px; font-size: 13px; font-weight: 700; }
.gauge { position: relative; height: 150px; border-left: 1px solid var(--line); }
.gauge svg { width: 100%; height: 100%; overflow: visible; }
.gauge-track, .gauge-progress { fill: none; stroke-width: 13; stroke-linecap: round; }
.gauge-track { stroke: #e7e5df; }
.gauge-progress { transition: stroke-dasharray 400ms ease; }
.gauge-copy { position: absolute; inset: 43px 0 0; display: flex; flex-direction: column; align-items: center; line-height: 1.15; }
.gauge-copy span { font-size: 14px; font-weight: 700; }
.gauge-copy strong { color: var(--green-dark); font-size: 43px; line-height: 1; margin: 3px 0 2px; font-variant-numeric: tabular-nums; }
.result-list { margin-top: 12px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.result-row { min-height: 38px; padding: 0 14px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); font-size: 14px; }
.result-row:last-child { border-bottom: 0; }
.result-row strong { font-size: 15px; font-variant-numeric: tabular-nums; }
.result-row.emphasized { background: rgba(232, 244, 239, 0.38); font-weight: 800; }
.result-note { margin-top: 10px; padding: 9px 12px; border-radius: 6px; font-size: 12px; font-weight: 700; }
.result-note.success { background: var(--green-soft); color: var(--green-dark); }
.result-note.warning { background: var(--red-soft); color: #a83d2f; }

.insights-grid { display: grid; grid-template-columns: minmax(0, 2.15fr) minmax(300px, 1fr); gap: 12px; margin-top: 12px; }
.chart-panel, .formula-panel { min-width: 0; padding: 14px 16px 12px; }
.chart-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.chart-heading .section-title { margin-bottom: 3px; }
.chart-heading p { margin: 0 0 0 15px; color: var(--muted); font-size: 11px; }
.legend { display: flex; flex-wrap: wrap; gap: 22px; padding-top: 6px; color: #68726e; font-size: 11px; }
.legend span { display: flex; align-items: center; gap: 7px; }
.legend-line { width: 22px; height: 2px; background: currentColor; }
.legend-line.loss { color: var(--red); }
.legend-line.profit { color: var(--green); }
.legend-line.break { height: 1px; color: #66716c; background: repeating-linear-gradient(90deg,currentColor 0 5px,transparent 5px 8px); }
.chart-wrap { width: 100%; overflow: hidden; }
.chart-wrap svg { width: 100%; display: block; }
.grid-line { stroke: #e2e1db; stroke-width: 1; }
.zero-line { stroke: #68716d; stroke-dasharray: 5 4; stroke-width: 1.2; }
.cash-line { stroke: var(--green); stroke-width: 2.3; stroke-linejoin: round; }
.point { stroke: var(--surface); stroke-width: 1.4; }
.point.profit { fill: var(--green); }
.point.loss { fill: var(--red); }
.axis-label, .axis-title { fill: #66706c; font-size: 10px; font-family: inherit; }
.marker-line { stroke: #799187; stroke-dasharray: 3 3; }
.marker-card { fill: #f6faf7; stroke: var(--green); }
.marker-label { fill: #33443e; font-size: 11px; font-weight: 700; }
.marker-value { fill: var(--green-dark); font-size: 14px; font-weight: 800; }
.payback-dot { fill: var(--surface); stroke: var(--green-dark); stroke-width: 3; }
.chart-summary { display: block; text-align: center; font-size: 18px; letter-spacing: .13em; margin-top: -3px; }

.formula-panel .section-title { margin-bottom: 12px; }
.formula-block { padding: 9px 10px; border-bottom: 1px solid var(--line); }
.formula-block:first-of-type { border-top: 1px solid var(--line); }
.formula-block p { margin: 0 0 7px; font-size: 12px; line-height: 1.65; }
.formula-block strong { display: block; margin: 3px 0 0 18px; color: #46544f; font-size: 11px; font-weight: 600; line-height: 1.65; }
.disclaimer { display: flex; align-items: center; gap: 7px; margin: 10px 4px 0; color: #707975; font-size: 10px; }
.disclaimer svg { width: 14px; height: 14px; }

/* 服务器业务计算器 */
.server-workspace { display: grid; grid-template-columns: minmax(0, 1.28fr) minmax(390px, .96fr); gap: 14px; align-items: stretch; }
.server-form-panel { padding: 16px 18px 14px; min-width: 0; }
.server-form-heading, .server-section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.server-form-heading > span, .server-section-heading > span { padding-top: 5px; color: var(--muted); font-size: 11px; }
.server-form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 12px; margin-bottom: 16px; }
.server-form-field { display: grid; gap: 5px; min-width: 0; color: #3f4d48; font-size: 12px; font-weight: 700; }
.server-form-field.wide { grid-column: span 2; }
.server-form-field .input-wrap input { height: 34px; }
.server-section-heading { align-items: center; padding-top: 1px; border-top: 1px solid var(--line); }
.server-section-heading .section-title { margin-top: 12px; }
.server-section-heading > span { padding-top: 12px; }
.allocation-heading { margin-top: 15px; }

.resource-table { border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.resource-head, .resource-row {
  display: grid;
  grid-template-columns: 1.02fr .56fr .92fr .98fr .85fr .85fr 46px;
  align-items: center;
  column-gap: 7px;
  padding: 0 7px;
}
.resource-head { min-height: 30px; background: rgba(245, 244, 240, .82); color: #606964; font-size: 11px; font-weight: 700; text-align: center; }
.resource-row { min-height: 41px; border-top: 1px solid var(--line); font-size: 12px; transition: background 140ms ease; }
.resource-row:hover { background: rgba(232, 244, 239, .38); }
.resource-text, .resource-number, .resource-money {
  width: 100%;
  min-width: 0;
  height: 29px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--ink);
  outline: none;
}
.resource-text { padding: 0 6px; font-weight: 700; }
.resource-number { padding: 0 6px; text-align: center; }
.resource-money { display: flex; align-items: center; border-color: var(--line-strong); background: rgba(255,255,255,.76); overflow: hidden; }
.resource-money span { padding-left: 7px; color: #69716d; }
.resource-money input { width: 100%; min-width: 0; height: 27px; padding: 0 5px; border: 0; background: transparent; color: var(--ink); outline: none; }
.resource-text:focus, .resource-number:focus, .resource-money:focus-within { border-color: var(--green); background: #fff; box-shadow: 0 0 0 3px rgba(7,131,93,.1); }
.resource-row > strong { text-align: right; color: #34433e; font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.resource-add { border-top: 1px solid var(--line); }

.server-participant-head, .server-participant-row {
  display: grid;
  grid-template-columns: 1.08fr .88fr 1fr 52px;
  align-items: center;
  column-gap: 8px;
  padding: 0 9px;
}
.server-participant-head { min-height: 28px; background: rgba(245, 244, 240, .8); color: #606964; font-size: 11px; font-weight: 700; }
.server-participant-row { min-height: 39px; border-top: 1px solid var(--line); }
.participant-estimate { text-align: right; color: var(--green-dark); font-size: 12px; font-variant-numeric: tabular-nums; }
.server-results-panel { height: 100%; }
.server-result-hero { min-height: 153px; display: grid; grid-template-columns: 1fr 180px; align-items: center; gap: 18px; padding: 18px 22px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.4); box-shadow: var(--shadow); }
.server-result-hero .hero-money { font-size: clamp(36px, 3.8vw, 52px); }
.payback-copy { min-height: 102px; display: grid; align-content: center; justify-items: center; border-left: 1px solid var(--line); text-align: center; }
.payback-copy > span { color: #46534f; font-size: 13px; font-weight: 700; }
.payback-copy strong { font-size: 40px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.payback-copy small { color: var(--muted); font-size: 11px; }
.server-result-list { display: grid; grid-template-columns: 1fr 1fr; }
.server-result-list .result-row:nth-child(odd) { border-right: 1px solid var(--line); }
.server-result-list .result-row:nth-last-child(-n+2) { border-bottom: 0; }
.server-result-list .result-row.emphasized { grid-column: 1 / -1; border-right: 0; }
.share-overview { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.share-overview h3 { margin: 0 0 9px; font-size: 14px; }
.share-bar { display: flex; width: 100%; height: 24px; overflow: hidden; border-radius: 4px; background: #e7e5df; }
.share-segment { display: grid; place-items: center; color: #fff; font-size: 11px; font-weight: 800; transition: width 220ms ease; }
.segment-0 { background: var(--green-dark); }
.segment-1 { background: #70ae5d; }
.segment-2 { background: #6a8f83; }
.segment-3 { background: #b9915f; }
.share-legend { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 9px; color: #535f5a; font-size: 11px; }
.share-legend span { display: flex; align-items: center; gap: 6px; }
.share-legend strong { color: var(--ink); }
.share-dot { width: 8px; height: 8px; display: inline-block; }
.server-insights { display: grid; grid-template-columns: minmax(0, 2.55fr) minmax(315px, .92fr); gap: 12px; margin-top: 12px; }

@media (max-width: 1080px) {
  main { width: min(920px, calc(100% - 32px)); }
  .workspace, .insights-grid, .server-workspace, .server-insights { grid-template-columns: 1fr; }
  .result-animation .results-panel { height: auto; }
}

@media (max-width: 680px) {
  .topbar { padding: 0 18px; }
  .calculator-tabs { height: 44px; gap: 22px; }
  main { width: calc(100% - 24px); padding-top: 18px; }
  .intro { gap: 12px; margin-bottom: 14px; }
  .intro-rail { width: 6px; min-height: 64px; }
  .intro h1 { font-size: 27px; }
  .intro p { font-size: 14px; }
  .form-panel, .results-panel { padding: 14px 12px; }
  .form-field { grid-template-columns: 1fr; gap: 5px; }
  .form-grid { gap: 10px; }
  .mode-row { align-items: stretch; flex-wrap: wrap; }
  .mode-label { width: 100%; }
  .mode-option { flex: 1; justify-content: center; padding: 0 8px; }
  .participant-head { display: none; }
  .participant-row { grid-template-columns: 1fr 1fr 50px; padding: 7px 7px; gap: 5px; }
  .participant-row .person-text:first-child { grid-column: 1 / -1; font-weight: 700; }
  .role-input { grid-column: 1; }
  .share-input { grid-column: 2; }
  .participant-row .icon-button, .participant-row .locked { grid-column: 3; grid-row: 2; }
  .form-actions { gap: 10px; }
  .result-hero { grid-template-columns: 1fr; gap: 14px; padding: 22px 18px 8px; text-align: center; }
  .gauge { border-left: 0; border-top: 1px solid var(--line); padding-top: 8px; }
  .chart-heading { flex-direction: column; }
  .legend { gap: 12px; margin-left: 15px; }
  .chart-wrap { max-width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; }
  .chart-wrap svg { min-width: 650px; }
  .chart-summary { font-size: 15px; letter-spacing: .05em; }
  .server-form-panel { padding: 14px 12px; }
  .server-form-grid { grid-template-columns: 1fr 1fr; }
  .server-form-field.wide { grid-column: 1 / -1; }
  .server-form-heading > span, .server-section-heading > span { display: none; }
  .resource-table { overflow-x: auto; overscroll-behavior-inline: contain; }
  .resource-head, .resource-row, .resource-add { min-width: 760px; }
  .server-participant-head { display: none; }
  .server-participant-row { grid-template-columns: 1fr 1fr 44px; padding: 7px; gap: 6px; }
  .server-participant-row .person-text { grid-column: 1 / -1; font-weight: 700; }
  .server-participant-row .share-input { grid-column: 1; }
  .server-participant-row .participant-estimate { grid-column: 2; }
  .server-participant-row .icon-button, .server-participant-row .locked { grid-column: 3; grid-row: 2; }
  .server-result-hero { grid-template-columns: 1fr; padding: 20px 16px 12px; text-align: center; }
  .payback-copy { min-height: 96px; border-left: 0; border-top: 1px solid var(--line); }
  .server-result-list { grid-template-columns: 1fr; }
  .server-result-list .result-row { border-right: 0 !important; border-bottom: 1px solid var(--line) !important; }
  .server-result-list .result-row:last-child { border-bottom: 0 !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
