:root {
  --ink: #17211d;
  --muted: #4f5b55;
  --paper: #f3f0e8;
  --card: #fffdf8;
  --green: #174f3d;
  --lime: #d6f36b;
  --line: #d9ddd4;
  --danger: #b84638;
  --profit: #d43f32;
  --loss: #24a86b;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 80% 5%, rgba(214,243,107,.25), transparent 28rem),
    var(--paper);
  font-family: "Microsoft YaHei UI", "PingFang SC", sans-serif;
}

button, input, select { font: inherit; }
.shell { width: min(1180px, calc(100% - 36px)); margin: 0 auto; padding: 54px 0; }
.site-switcher { display: flex; justify-content: flex-end; gap: 8px; margin-bottom: 18px; }
.site-switch { position: relative; display: inline-flex; min-height: 34px; align-items: center; gap: 6px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--green); background: rgba(255,255,255,.55); text-decoration: none; font-size: 12px; font-weight: 900; transition: .2s; }
.site-switch svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.site-switch:hover, .site-switch.active { color: white; background: var(--green); border-color: var(--green); box-shadow: 0 8px 20px rgba(23,79,61,.14); }
.site-switch::after { content: attr(data-tip); position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; width: max-content; max-width: 220px; padding: 7px 10px; border-radius: 8px; color: white; background: rgba(23,33,29,.92); font-size: 12px; font-weight: 700; opacity: 0; pointer-events: none; transform: translateY(-3px); transition: .18s; }
.site-switch:hover::after { opacity: 1; transform: translateY(0); }
.theme-toggle { display: grid; width: 34px; height: 34px; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 50%; color: var(--green); background: rgba(255,255,255,.55); cursor: pointer; transition: .2s; }
.theme-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle:hover, .theme-toggle.active { color: white; background: var(--green); border-color: var(--green); box-shadow: 0 8px 20px rgba(23,79,61,.14); }
.hero { margin-bottom: 36px; }
.eyebrow { margin: 0 0 12px; color: var(--green); font-size: 12px; font-weight: 800; letter-spacing: .18em; }
h1 { margin: 0; font-size: clamp(21px, 2.9vw, 35px); line-height: 1; letter-spacing: -.04em; }
h1 span { color: var(--green); }
.intro { margin: 20px 0 0; color: var(--muted); }
.direction { display: flex; flex-shrink: 0; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.55); }
.direction-btn { min-width: 84px; padding: 9px 14px; border: 0; border-radius: 9px; color: var(--muted); background: transparent; cursor: pointer; font-size: 12px; font-weight: 800; }
.direction-btn small { display: block; margin-top: 2px; font-size: 9px; letter-spacing: .16em; }
.direction-btn.active { color: white; background: var(--green); box-shadow: 0 8px 20px rgba(23,79,61,.18); }

.grid { display: grid; grid-template-columns: 1fr; gap: 20px; }
.panel { border: 1px solid rgba(23,33,29,.09); border-radius: 22px; background: var(--card); box-shadow: 0 20px 55px rgba(36,49,42,.08); }
.inputs-panel { padding: 30px; }
.section-title { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; }
.price-plan-title { justify-content: space-between; gap: 16px; }
.title-left { display: flex; align-items: center; gap: 11px; }
.price-plan-product { display: inline-flex; align-items: center; gap: 2px; min-height: 30px; color: var(--green); font-size: 16px; font-weight: 900; }
.price-plan-code { color: #d56a1f; font-size: 16px; }
.section-title > span,
.title-left > span:first-child { display: grid; width: 29px; height: 29px; place-items: center; border-radius: 50%; color: var(--green); background: var(--lime); font-size: 11px; font-weight: 900; }
.section-title h2 { margin: 0; font-size: 18px; }
.section-title.light h2 { color: white; }
.spaced { margin-top: 34px; }
.fields { display: grid; gap: 18px; }
.two-cols { grid-template-columns: repeat(2, minmax(0,1fr)); }
.three-cols { grid-template-columns: repeat(3, minmax(0,1fr)); }
label { display: flex; flex-direction: column; gap: 8px; color: #34413b; font-size: 13px; font-weight: 700; }
label small { color: var(--muted); font-size: 11px; font-weight: 500; }
input, select { width: 100%; height: 46px; padding: 0 13px; border: 1px solid var(--line); border-radius: 10px; outline: none; color: var(--ink); background: #faf9f4; transition: .2s; }
input::placeholder { color: #5b6760; opacity: 1; }
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23,79,61,.09); }
.ratio-row { display: flex; gap: 8px; }
.ratio-row input { min-width: 0; }
.lock-btn { display: flex; min-width: 104px; height: 46px; align-items: center; justify-content: center; gap: 6px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: #faf9f4; cursor: pointer; font-size: 12px; font-weight: 800; white-space: nowrap; }
.lock-btn.locked { border-color: var(--green); color: white; background: var(--green); box-shadow: 0 5px 14px rgba(23,79,61,.16); }
.lock-icon { font-size: 14px; }
.product-field { margin-top: 22px; }
.bottom-product-field { padding-top: 22px; border-top: 1px solid var(--line); }
.field-heading { margin-bottom: 10px; color: #34413b; font-size: 13px; font-weight: 700; }
.product-heading { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 12px; }
.product-heading .name-mode-toggle { margin-left: auto; }
.name-mode-toggle { display: flex; flex-shrink: 0; padding: 2px; border: 1px solid var(--line); border-radius: 999px; background: #faf9f4; }
.name-mode-toggle button { width: 28px; height: 24px; border: 0; border-radius: 999px; color: var(--muted); background: transparent; cursor: pointer; font-size: 12px; font-weight: 900; }
.name-mode-toggle button.active { color: white; background: var(--green); }
.product-picker { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: #faf9f4; }
.exchange-row { display: grid; grid-template-columns: 145px 1fr; gap: 10px; align-items: start; padding: 9px 12px; border-bottom: 1px dashed var(--line); }
.exchange-row:last-child { border-bottom: 0; }
.exchange-row > span { padding-top: 5px; color: var(--muted); font-size: 12px; }
.exchange-row > div { display: flex; flex-wrap: wrap; gap: 3px 5px; }
.product-chip { padding: 4px 7px; border: 1px solid transparent; border-radius: 6px; color: var(--green); background: transparent; cursor: pointer; font-size: 12px; font-weight: 700; }
.product-code { margin-left: 2px; color: #d56a1f; }
.product-chip:hover { background: #eef1e8; }
.product-chip.active { border-color: var(--green); color: white; background: var(--green); box-shadow: 0 5px 12px rgba(23,79,61,.15); }
.product-chip.active .product-code { color: white; }
.hidden { display: none !important; }
.product-info { margin-top: 14px; padding: 14px; border-radius: 12px; color: #52615a; background: #eef1e8; }
.product-info-head { display: flex; align-items: center; gap: 9px; margin-bottom: 11px; font-size: 12px; }
.product-info-head strong { color: var(--green); font-size: 15px; }
.product-data { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.product-data > span { display: flex; flex-direction: column; gap: 4px; padding: 9px 10px; border-radius: 8px; color: var(--muted); background: rgba(255,255,255,.62); font-size: 11px; }
.product-data strong { color: #839088; font-size: 12px; }
.product-data strong.money-highlight { color: #d56a1f; }
.product-info p { margin: 11px 0 0; font-size: 11px; }
.stop-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; gap: 18px; margin-top: 18px; }
.clear-button-group { grid-column: 3; justify-self: end; display: flex; gap: 8px; align-items: center; padding-right: 2px; }
.clear-price-btn { display: grid; width: 34px; height: 34px; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 50%; color: #7d8982; background: #faf9f4; cursor: pointer; line-height: 1; transition: .2s; }
.clear-price-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.clear-price-btn:hover { border-color: rgba(190,62,48,.32); color: var(--danger); background: #fff5f2; }
.clear-price-btn:active { transform: translateY(1px); }
.inline-lots { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 14px; padding: 12px 14px; border: 1px solid rgba(23,79,61,.1); border-radius: 12px; background: #eef1e8; }
.inline-lots span { color: var(--muted); font-size: 12px; font-weight: 700; }
.inline-lots strong { color: var(--green); font-size: 18px; font-weight: 900; }
.inline-lots-right { display: flex; align-items: center; gap: 10px; }
.manual-lots-toggle { display: grid; width: 28px; height: 28px; place-items: center; padding: 0; border: 1px solid rgba(23,79,61,.15); border-radius: 50%; color: var(--green); background: rgba(255,255,255,.62); cursor: pointer; transition: .2s; }
.manual-lots-toggle svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.manual-lots-toggle.active { color: white; background: var(--green); }
.manual-lots-panel { margin-top: 8px; padding: 12px; border: 1px solid rgba(23,79,61,.1); border-radius: 12px; background: rgba(238,241,232,.72); }
.lots-mode-row { display: grid; grid-template-columns: minmax(180px, 1fr) auto minmax(110px, 180px); align-items: center; gap: 10px; }
.lots-mode-toggle { min-height: 40px; padding: 0 13px; border: 1px solid rgba(23,79,61,.12); border-radius: 10px; color: var(--muted); background: rgba(255,255,255,.55); cursor: pointer; font-size: 12px; font-weight: 800; transition: .2s; }
.lots-mode-toggle strong { color: inherit; font-size: 18px; }
.lots-mode-toggle span { font-size: 12px; }
.lots-mode-toggle.active { border-color: var(--green); color: white; background: var(--green); box-shadow: 0 8px 20px rgba(23,79,61,.14); }
.lots-mode-toggle.recommended.inactive { color: #98a39d; background: rgba(255,255,255,.36); }
.manual-lots-field { display: block; font-size: 11px; }
.manual-lots-panel input { height: 34px; font-size: 12px; }
.manual-lots-results { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.manual-lots-results span { display: flex; flex-direction: column; gap: 3px; padding: 7px 8px; border-radius: 8px; color: var(--muted); background: rgba(255,255,255,.58); font-size: 10px; }
.manual-lots-results strong { color: var(--green); font-size: 11px; }
.profit-value { color: var(--profit) !important; }
.loss-value { color: var(--loss) !important; }
.message { min-height: 19px; margin: 12px 0 0; color: var(--danger); font-size: 12px; }


body.dark-mode {
  --ink: #eef5ef;
  --muted: #b8c4bd;
  --paper: #0f1511;
  --card: #18221c;
  --green: #4ec391;
  --lime: #c7f064;
  --line: #344238;
  --danger: #ff8f7f;
  --profit: #ff6b5c;
  --loss: #55d88f;
  background:
    radial-gradient(circle at 80% 5%, rgba(78,195,145,.18), transparent 28rem),
    #0f1511;
}
body.dark-mode .site-switch,
body.dark-mode .theme-toggle,
body.dark-mode .direction,
body.dark-mode .lock-btn,
body.dark-mode input,
body.dark-mode select,
body.dark-mode .product-picker,
body.dark-mode .name-mode-toggle,
body.dark-mode .clear-price-btn {
  background: #111a15;
}
body.dark-mode .site-switch:hover,
body.dark-mode .site-switch.active,
body.dark-mode .theme-toggle:hover,
body.dark-mode .theme-toggle.active,
body.dark-mode .direction-btn.active,
body.dark-mode .lock-btn.locked,
body.dark-mode .name-mode-toggle button.active,
body.dark-mode .manual-lots-toggle.active,
body.dark-mode .lots-mode-toggle.active {
  color: #07110d;
  background: var(--lime);
  border-color: var(--lime);
}
body.dark-mode .panel { border-color: rgba(255,255,255,.08); box-shadow: 0 20px 55px rgba(0,0,0,.24); }
body.dark-mode input,
body.dark-mode select { color: var(--ink); border-color: var(--line); }
body.dark-mode input::placeholder { color: #a9b5ae; }
body.dark-mode input:focus,
body.dark-mode select:focus { box-shadow: 0 0 0 3px rgba(78,195,145,.13); }
body.dark-mode label,
body.dark-mode .field-heading { color: #dfe9e3; }
body.dark-mode .section-title > span,
body.dark-mode .title-left > span:first-child { color: #07110d; }
body.dark-mode .product-chip:hover,
body.dark-mode .product-info,
body.dark-mode .inline-lots,
body.dark-mode .manual-lots-panel { background: #16231c; }
body.dark-mode .product-data > span,
body.dark-mode .manual-lots-results span,
body.dark-mode .manual-lots-toggle,
body.dark-mode .lots-mode-toggle { background: rgba(255,255,255,.06); }
body.dark-mode .lots-mode-toggle.recommended.inactive { color: #7c8a82; background: rgba(255,255,255,.04); }
body.dark-mode .product-data strong { color: #cad6ce; }
body.dark-mode .product-data strong.money-highlight,
body.dark-mode .product-code,
body.dark-mode .price-plan-code,
body.dark-mode .manual-lots-results strong { color: #f0a85a; }
body.dark-mode .product-chip.active .product-code { color: #07110d; }
body.dark-mode .clear-price-btn:hover { color: #ffd3cb; background: rgba(255,143,127,.12); }

@media (max-width: 820px) {
  .shell { padding: 28px 0; }
  .grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .shell { width: min(100% - 20px, 1180px); }
  .inputs-panel { padding: 21px; border-radius: 16px; }
  .two-cols, .three-cols, .stop-row { grid-template-columns: 1fr; }
  .clear-button-group { grid-column: auto; justify-self: end; }
  .clear-price-btn { width: 34px; }
  .exchange-row { grid-template-columns: 1fr; gap: 7px; }
  .product-data { grid-template-columns: 1fr; }
  .lots-mode-row, .manual-lots-field, .manual-lots-results { grid-template-columns: 1fr; }
  h1 { font-size: 23px; }
  .price-plan-title { align-items: flex-start; flex-direction: column; }
  .direction { width: 100%; }
  .direction-btn { flex: 1; min-width: 0; }
}
