:root {
  --bg: #090806;
  --bg-soft: #0f0e0b;
  --panel: rgba(21, 19, 15, 0.92);
  --panel-strong: #181510;
  --line: rgba(218, 184, 102, 0.18);
  --line-strong: rgba(218, 184, 102, 0.42);
  --gold: #dab866;
  --gold-bright: #f3d98f;
  --gold-muted: #947842;
  --cream: #f7f0df;
  --text: #eee9dc;
  --muted: #999184;
  --green: #75b993;
  --red: #d27d74;
  --blue: #7898cc;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
  --radius: 18px;
}

* { box-sizing: border-box; }

html { color-scheme: dark; scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(rgba(218, 184, 102, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(218, 184, 102, 0.025) 1px, transparent 1px),
    var(--bg);
  background-size: 48px 48px;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
}

/* 与皇嘉 ERP 一致的玉玺鼠标，仅在精细指针设备启用 */
.hj-jade-cursor { display: none; }
@media (pointer: fine) {
  html.hj-cursor-ready body,
  html.hj-cursor-ready body * { cursor: none !important; }
  .hj-jade-cursor {
    display: block;
    position: fixed;
    left: 0;
    top: 0;
    width: 56px;
    height: 56px;
    z-index: 2147483647;
    opacity: 0;
    pointer-events: none;
    will-change: transform;
  }
  .hj-jade-cursor.is-visible { opacity: 1; }
  .hj-jade-seal {
    width: 52px;
    height: auto;
    overflow: visible;
    transform-origin: 45% 15%;
    filter: drop-shadow(0 5px 5px rgba(0,0,0,.48)) drop-shadow(0 0 5px rgba(130,221,174,.23));
  }
}

.page-glow {
  position: fixed;
  z-index: -1;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(40px);
}

.page-glow--one {
  top: -260px;
  left: -180px;
  background: radial-gradient(circle, rgba(180, 126, 35, 0.13), transparent 68%);
}

.page-glow--two {
  right: -260px;
  top: 340px;
  background: radial-gradient(circle, rgba(112, 141, 121, 0.08), transparent 70%);
}

.topbar {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 74px;
  padding: 10px max(24px, calc((100vw - 1240px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(9, 8, 6, 0.84);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 15px;
  color: inherit;
  text-decoration: none;
}

.brand img {
  display: block;
  width: 134px;
  height: 45px;
  object-fit: cover;
  object-position: center;
}

.brand-divider { width: 1px; height: 32px; background: var(--line-strong); }
.brand-product { display: grid; gap: 2px; }
.brand-product strong { font-family: "STKaiti", "KaiTi", serif; font-size: 18px; letter-spacing: .12em; }
.brand-product small { color: var(--gold-muted); font: 9px/1.2 Arial, sans-serif; letter-spacing: .18em; }

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 12px;
}

.topbar-actions { display: flex; align-items: center; gap: 16px; }

.bz-music-toggle {
  min-height: 34px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(218, 184, 102, .035);
  box-shadow: none;
  font-size: 11px;
  text-align: left;
  cursor: pointer;
}

.bz-music-toggle:hover { color: var(--text); border-color: var(--line-strong); background: rgba(218, 184, 102, .08); transform: none; }
.bz-music-toggle svg { width: 17px; height: 17px; flex: none; color: var(--gold); }
.bz-music-toggle > span { flex: 1; white-space: nowrap; }
.bz-music-toggle.is-playing { color: #e8c978; border-color: rgba(218, 184, 102, .35); background: rgba(218, 184, 102, .08); }
.bz-music-bars { height: 14px; display: flex; align-items: flex-end; gap: 2px; }
.bz-music-bars b { width: 2px; height: 4px; border-radius: 2px; background: currentColor; opacity: .45; }
.bz-music-toggle.is-playing .bz-music-bars b { animation: bzMusicBar .9s ease-in-out infinite alternate; opacity: .9; }
.bz-music-toggle.is-playing .bz-music-bars b:nth-child(2) { animation-delay: -.35s; }
.bz-music-toggle.is-playing .bz-music-bars b:nth-child(3) { animation-delay: -.65s; }
@keyframes bzMusicBar { from { height: 4px; } to { height: 13px; } }

.logout-link {
  display: grid;
  place-items: center;
  min-width: 42px;
  min-height: 32px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 11px;
  text-decoration: none;
  transition: .18s ease;
}
.logout-link:hover { border-color: rgba(210, 125, 116, .38); background: rgba(210, 125, 116, .07); color: #e4a29a; }

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(117, 185, 147, 0.08);
}

.shell { width: min(1240px, calc(100% - 40px)); margin: 0 auto; }

.hero {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 270px;
  padding: 58px 12px 42px;
  overflow: hidden;
}

.hero::after {
  content: "HUANGJIA · QUOTATION";
  position: absolute;
  right: 112px;
  bottom: 30px;
  color: rgba(218, 184, 102, 0.04);
  font: 700 64px/1 Arial, sans-serif;
  letter-spacing: .06em;
  white-space: nowrap;
}

.eyebrow, .panel-kicker {
  color: var(--gold);
  font: 600 11px/1.2 Arial, sans-serif;
  letter-spacing: .2em;
}

.eyebrow { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.eyebrow span { width: 28px; height: 1px; background: var(--gold); }

.hero h1 {
  margin: 0 0 15px;
  color: var(--cream);
  font-family: "STKaiti", "KaiTi", serif;
  font-size: clamp(38px, 5vw, 62px);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: .04em;
}

.hero p { margin: 0; max-width: 620px; color: var(--muted); font-size: 15px; line-height: 1.8; }

.hero-seal {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  margin-right: 25px;
  border: 2px solid #963a2c;
  color: #b94d3c;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 48px;
  transform: rotate(-5deg);
  opacity: .84;
  box-shadow: inset 0 0 0 4px var(--bg), inset 0 0 0 5px #963a2c;
}

.panel {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(27, 24, 18, .96), rgba(15, 14, 11, .96));
  box-shadow: var(--shadow);
}

.calculator-grid { display: grid; grid-template-columns: minmax(340px, .88fr) minmax(460px, 1.3fr); gap: 18px; }
.input-panel, .result-panel { padding: 28px; }

.panel-heading, .result-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.panel-heading h2, .result-topline h2 { margin: 7px 0 0; color: var(--cream); font-size: 22px; letter-spacing: .05em; }

.text-button, .icon-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.icon-button:disabled { opacity: .42; cursor: not-allowed; }

.text-button { padding: 5px 0; font-size: 12px; }
.text-button:hover, .icon-button:hover { color: var(--gold-bright); }

.scenario-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin-bottom: 24px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0e0d0a;
}

.scenario-switch button {
  min-height: 38px;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: .2s ease;
}

.scenario-switch button:hover { color: var(--text); }
.scenario-switch button.is-active { border-color: rgba(218, 184, 102, .24); background: rgba(218, 184, 102, .1); color: var(--gold-bright); }

.field-list { display: grid; gap: 17px; }
.field { display: grid; gap: 8px; }
.field-label-row { display: flex; align-items: center; justify-content: space-between; }
.field-label { color: #c6beb0; font-size: 13px; }
.field output { color: var(--gold-bright); font-size: 12px; }
.field small { color: #777166; font-size: 11px; line-height: 1.5; }

.field-control {
  display: flex;
  align-items: center;
  min-height: 50px;
  padding: 0 15px;
  border: 1px solid rgba(218, 184, 102, .2);
  border-radius: 11px;
  background: rgba(8, 8, 6, .7);
  transition: border-color .2s, box-shadow .2s;
}

.field-control:focus-within { border-color: var(--gold-muted); box-shadow: 0 0 0 3px rgba(218, 184, 102, .07); }
.field-control input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--cream); font-size: 20px; font-variant-numeric: tabular-nums; }
.field-prefix { margin-right: 8px; color: var(--gold); font-size: 19px; }
.field-suffix { margin-left: 8px; color: var(--muted); font-size: 12px; }
.field-control--percent { width: 116px; flex: 0 0 116px; }
.field-control--percent input { text-align: right; }

.range-control { display: flex; align-items: center; gap: 14px; }
input[type="range"] { width: 100%; height: 4px; accent-color: var(--gold); cursor: pointer; }
input[type="number"]::-webkit-inner-spin-button { opacity: .35; }

.conditional-field[hidden], .conditional-metric[hidden] { display: none; }

.validation {
  margin-top: 18px;
  padding: 11px 13px;
  border: 1px solid rgba(210, 125, 116, .28);
  border-radius: 9px;
  background: rgba(210, 125, 116, .08);
  color: #e5a29b;
  font-size: 12px;
  line-height: 1.5;
}

.scenario-badge {
  padding: 7px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--gold-bright);
  background: rgba(218, 184, 102, .06);
  font-size: 11px;
  white-space: nowrap;
}

.primary-result {
  display: grid;
  justify-items: start;
  min-height: 164px;
  margin: 0 -4px 21px;
  padding: 28px 30px;
  border: 1px solid rgba(218, 184, 102, .26);
  border-radius: 15px;
  background:
    linear-gradient(115deg, rgba(218, 184, 102, .1), transparent 60%),
    #100f0c;
}

.primary-result > span { color: var(--muted); font-size: 12px; }
.primary-result strong { margin: 8px 0 5px; color: var(--gold-bright); font: 600 clamp(38px, 5vw, 56px)/1.1 Georgia, "Times New Roman", serif; letter-spacing: -.025em; font-variant-numeric: tabular-nums; }
.primary-result small { color: #716b61; font-size: 11px; }

.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.metric { min-height: 83px; padding: 15px; border: 1px solid rgba(218, 184, 102, .12); border-radius: 12px; background: rgba(7, 7, 5, .33); }
.metric span { display: block; margin-bottom: 8px; color: var(--muted); font-size: 11px; }
.metric strong { color: #ddd6c8; font-size: 17px; font-variant-numeric: tabular-nums; }

.formula-box { margin-top: 18px; padding: 17px 18px; border-left: 2px solid var(--gold-muted); background: rgba(218, 184, 102, .035); }
.formula-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; color: var(--muted); font-size: 11px; }
.icon-button { display: flex; align-items: center; gap: 6px; padding: 0; font-size: 11px; }
.icon-button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.formula-box code { display: block; margin-top: 12px; color: var(--gold-bright); font-family: "Microsoft YaHei", sans-serif; font-size: 13px; line-height: 1.65; }
.formula-substitution { margin-top: 7px; color: #827c71; font: 11px/1.6 Consolas, "Microsoft YaHei", monospace; }

.check-box {
  margin-top: 14px;
  padding: 15px 18px;
  border: 1px solid rgba(117, 185, 147, .16);
  border-radius: 11px;
  background: rgba(117, 185, 147, .035);
}

.check-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; color: #b9b1a4; font-size: 11px; }
.check-summary { color: var(--green); }
.check-summary.is-warning { color: var(--gold-bright); }
.check-summary.is-error { color: var(--red); }
.check-list { display: grid; gap: 8px; margin: 12px 0 0; padding: 0; list-style: none; }
.check-list li { display: grid; grid-template-columns: 9px 1fr auto; align-items: center; gap: 9px; color: #8e877d; font-size: 11px; }
.check-list small { color: var(--green); }
.check-icon { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(117, 185, 147, .07); }
.check-list li.is-warning .check-icon { background: var(--gold); box-shadow: 0 0 0 4px rgba(218, 184, 102, .07); }
.check-list li.is-warning small { color: var(--gold); }
.check-list li.is-error .check-icon { background: var(--red); box-shadow: 0 0 0 4px rgba(210, 125, 116, .07); }
.check-list li.is-error small { color: var(--red); }

.breakdown-panel, .lookup-panel { margin-top: 18px; padding: 28px; }
.panel-heading--wide { align-items: center; }
.panel-note { color: var(--muted); font-size: 11px; }

.breakdown-bar { display: flex; width: 100%; height: 15px; overflow: hidden; border-radius: 99px; background: #080806; box-shadow: inset 0 0 0 1px rgba(255,255,255,.03); }
.breakdown-segment { min-width: 2px; height: 100%; transition: width .35s ease; }
.breakdown-segment--cost { background: #8d7240; }
.breakdown-segment--profit { background: var(--green); }
.breakdown-segment--tax { background: #7898cc; }
.breakdown-segment--commission { background: #8e6d94; }

.breakdown-legend { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 17px; }
.breakdown-empty { grid-column: 1 / -1; color: #777066; font-size: 12px; }
.legend-item { display: grid; grid-template-columns: auto 1fr; gap: 3px 9px; align-items: center; }
.legend-dot { grid-row: 1 / 3; width: 8px; height: 8px; border-radius: 2px; }
.legend-label { color: var(--muted); font-size: 11px; }
.legend-value { color: #d9d2c5; font-size: 14px; font-variant-numeric: tabular-nums; }

.table-wrap { overflow: auto; border: 1px solid rgba(218, 184, 102, .13); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; min-width: 650px; font-variant-numeric: tabular-nums; }
th, td { height: 50px; padding: 0 18px; text-align: right; border-bottom: 1px solid rgba(218, 184, 102, .09); }
th:first-child, td:first-child { text-align: left; }
th { position: sticky; top: 0; background: #181510; color: var(--gold-muted); font-size: 11px; font-weight: 500; letter-spacing: .05em; }
td { color: #bbb3a6; font-size: 13px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(218, 184, 102, .035); }
tbody tr.is-current td { color: var(--gold-bright); background: rgba(218, 184, 102, .075); }
tbody tr.is-current td:first-child::after { content: "当前"; margin-left: 8px; padding: 2px 5px; border-radius: 4px; background: rgba(218, 184, 102, .14); color: var(--gold); font-size: 9px; }
.table-footnote { margin: 13px 0 0; color: #736d63; font-size: 11px; }

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  width: min(1240px, calc(100% - 40px));
  margin: 34px auto 0;
  padding: 22px 3px 30px;
  border-top: 1px solid rgba(218, 184, 102, .1);
  color: #625d55;
  font-size: 10px;
}

.toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: 28px;
  padding: 11px 17px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: #1b1812;
  color: var(--gold-bright);
  font-size: 12px;
  box-shadow: var(--shadow);
  transform: translate(-50%, 30px);
  opacity: 0;
  pointer-events: none;
  transition: .25s ease;
}

.toast.is-visible { transform: translate(-50%, 0); opacity: 1; }

.qa-launcher {
  position: fixed;
  z-index: 18;
  right: 24px;
  bottom: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 17px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: linear-gradient(135deg, #2a2418, #15120d);
  color: var(--gold-bright);
  box-shadow: 0 14px 45px rgba(0, 0, 0, .4);
  cursor: pointer;
  transition: transform .2s ease, border-color .2s ease;
}

.qa-launcher:hover { transform: translateY(-2px); border-color: var(--gold); }
.qa-launcher svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.qa-launcher span { font-size: 12px; }

.qa-overlay {
  position: fixed;
  z-index: 30;
  inset: 0;
  background: rgba(0, 0, 0, .58);
  backdrop-filter: blur(5px);
}

.qa-overlay[hidden] { display: none; }
.qa-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(430px, 100%);
  height: 100%;
  padding: 28px;
  overflow-y: auto;
  border-left: 1px solid var(--line-strong);
  background: linear-gradient(150deg, #1a1711, #0e0d0a 72%);
  box-shadow: -28px 0 80px rgba(0, 0, 0, .42);
  animation: qaSlideIn .24s ease both;
}

@keyframes qaSlideIn { from { transform: translateX(28px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.qa-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.qa-header h2 { margin: 7px 0 0; color: var(--cream); font-size: 23px; }
.qa-close { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--muted); font-size: 23px; cursor: pointer; }
.qa-close:hover { color: var(--gold-bright); border-color: var(--line-strong); }
.qa-intro { margin: 24px 0 14px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.qa-questions { display: grid; gap: 8px; }
.qa-questions button { padding: 12px 14px; border: 1px solid rgba(218, 184, 102, .14); border-radius: 9px; background: rgba(8, 8, 6, .42); color: #bdb5a7; text-align: left; font-size: 12px; line-height: 1.5; cursor: pointer; transition: .18s ease; }
.qa-questions button:hover, .qa-questions button.is-active { border-color: var(--line-strong); background: rgba(218, 184, 102, .08); color: var(--gold-bright); }
.qa-answer { min-height: 142px; margin-top: 16px; padding: 18px; border: 1px solid var(--line); border-radius: 11px; background: #0c0b09; }
.qa-answer > span { color: var(--gold); font-size: 11px; letter-spacing: .08em; }
.qa-answer p { margin: 10px 0 0; color: #c7c0b3; font-size: 13px; line-height: 1.8; }
.qa-note { margin: 14px 0 0; color: #6f695f; font-size: 10px; line-height: 1.6; }
body.qa-open { overflow: hidden; }

@media (max-width: 900px) {
  .calculator-grid { grid-template-columns: 1fr; }
  .hero::after { right: 0; font-size: 48px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .topbar { min-height: 66px; padding: 9px 16px; }
  .brand { gap: 10px; }
  .brand img { width: 102px; height: 34px; }
  .brand-divider, .topbar-meta { display: none; }
  .topbar-actions { margin-left: auto; gap: 0; }
  .bz-music-toggle { width: 38px; min-height: 38px; padding: 0; justify-content: center; border-radius: 50%; }
  .bz-music-toggle .music-label, .bz-music-toggle .bz-music-bars { display: none; }
  .logout-link { min-width: 38px; min-height: 38px; margin-left: 7px; padding: 0 7px; border-radius: 50%; font-size: 10px; }
  .brand-product strong { font-size: 15px; }
  .brand-product small { font-size: 7px; }
  .shell { width: min(100% - 24px, 1240px); }
  .hero { min-height: 210px; padding: 42px 5px 28px; }
  .hero h1 { font-size: 40px; }
  .hero p { font-size: 13px; }
  .hero-seal { display: none; }
  .hero::after { display: none; }
  .input-panel, .result-panel, .breakdown-panel, .lookup-panel { padding: 20px; border-radius: 14px; }
  .scenario-switch { grid-template-columns: 1fr; }
  .scenario-switch button { min-height: 34px; }
  .range-control { align-items: stretch; flex-direction: column; }
  .field-control--percent { width: 100%; flex-basis: auto; }
  .primary-result { min-height: 145px; padding: 23px 20px; }
  .primary-result strong { font-size: 36px; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric { padding: 13px; }
  .metric strong { font-size: 15px; }
  .breakdown-legend { grid-template-columns: 1fr 1fr; }
  .panel-note { display: none; }
  .qa-launcher { right: 14px; bottom: 14px; min-height: 43px; padding: 0 14px; }
  .qa-panel { padding: 22px 18px; }
  footer { width: calc(100% - 24px); flex-direction: column; gap: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; }
}

@media print {
  .topbar, .text-button, .scenario-switch, .icon-button, footer, .toast, .qa-launcher, .qa-overlay { display: none !important; }
  body { color: #222; background: #fff; }
  .shell { width: 100%; }
  .hero { min-height: auto; padding: 20px 0; }
  .hero h1, .panel-heading h2, .result-topline h2 { color: #111; }
  .hero p, .field-label, .panel-note, .metric span { color: #555; }
  .panel { border-color: #ccc; background: #fff; box-shadow: none; }
  .calculator-grid { grid-template-columns: .8fr 1.2fr; }
  .field-control { border-color: #ccc; background: #fff; }
  .field-control input, .metric strong { color: #111; }
  .primary-result { border-color: #c6a85f; background: #f8f5ec; }
  .primary-result strong, .formula-box code { color: #7d642e; }
}
