/* vps.mcixs.com — VPS 剩余价值计算器
   配色：白底 / 淡灰块 / 深灰字（三级灰阶，无彩色）
   布局：左输入 396px + 右结果（结果卡 / 明细卡 / 汇率卡），一屏无滚动 */
:root {
  --bg: #f1f2f4;
  --panel: #ffffff;
  --tile: #f7f8fa;

  --line: #e4e6ea;
  --line-2: #eef0f3;

  --ink: #15181c;      /* 深灰：主数字、正文 */
  --ink-2: #3f4650;    /* 中深灰：次级文字 */
  --ink-3: #6b7280;    /* 灰：标签 */
  --muted: #9aa1ab;    /* 淡灰：注释 */

  --dark: #24282e;     /* 深灰块（最终价格） */
  --btn: #4b5563;      /* 按钮：中深灰 */
  --btn-hover: #3f4956;
  --btn-active: #363f4a;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 16px 36px -32px rgba(16, 24, 40, .4);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 18px 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC",
    "PingFang SC", "Microsoft YaHei", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app {
  width: min(1280px, 100% - 48px);
  display: flex;
  flex-direction: column;
  gap: 13px;
}

/* ---------------- 顶栏 ---------------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 2px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 28px; height: 28px; flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--dark);
  color: #fff;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text strong { font-size: 15px; font-weight: 600; color: var(--ink-2); white-space: nowrap; letter-spacing: .01em; }
.brand-text small { font-size: 10.5px; color: var(--muted); letter-spacing: .05em; }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--ink-3);
  background: #fff; border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 10px; white-space: nowrap;
}
.dot-live { width: 5px; height: 5px; border-radius: 50%; background: #b8bec7; display: inline-block; }
.link-btn {
  font: inherit; font-size: 12px; color: var(--ink-2);
  background: none; border: none; padding: 3px 2px; cursor: pointer;
  border-bottom: 1px solid #d2d6dc;
}
.link-btn:hover { color: var(--ink); border-bottom-color: var(--ink-2); }

/* ---------------- 布局 ---------------- */
.board {
  display: grid;
  grid-template-columns: 396px minmax(0, 1fr);
  gap: 13px;
  align-items: stretch;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}

/* ---------------- 左：输入 ---------------- */
.panel-input { display: flex; flex-direction: column; padding: 2px 20px 16px; }
.pane { padding: 12px 0; border-bottom: 1px solid var(--line-2); }
.pane:last-of-type { border-bottom: none; padding-bottom: 0; }

.pane-title {
  margin: 0 0 11px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .1em; color: var(--ink-3);
  display: flex; align-items: center; gap: 8px;
}
.idx {
  font-size: 10px; font-variant-numeric: tabular-nums; letter-spacing: .06em;
  color: var(--muted); border: 1px solid var(--line); border-radius: 4px;
  padding: 0 4px; line-height: 15px;
}

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-3 { grid-template-columns: minmax(0, 1.35fr) minmax(0, .78fr) minmax(0, 1fr); gap: 8px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 9px; min-width: 0; }
.field:last-child { margin-bottom: 0; }
label, span.label {
  font-size: 12px; color: var(--ink-3);
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-height: 17px;
}

input, select {
  width: 100%; min-width: 0; height: 38px; padding: 0 11px;
  font: inherit; font-size: 14px; color: var(--ink);
  background: #fff; border: 1px solid #dcdfe4; border-radius: 9px;
  outline: none; transition: border-color .14s, box-shadow .14s;
  appearance: none;
}
input::placeholder { color: #b6bcc5; }
input:focus, select:focus { border-color: #a4adb9; box-shadow: 0 0 0 3px rgba(75, 85, 99, .1); }
select { cursor: pointer; }
input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { appearance: none; margin: 0; }
input[type="date"]::-webkit-calendar-picker-indicator { opacity: .45; cursor: pointer; }
input:disabled { color: var(--muted); background: #f7f8fa; }

.inline { display: flex; gap: 7px; align-items: center; }
.inline > input { flex: 1 1 auto; }
.mini { flex: 0 0 74px; width: 74px; font-size: 13px; padding-inline: 7px; }

.unit {
  font-size: 10.5px; color: var(--muted); background: var(--tile);
  border: 1px solid var(--line-2); border-radius: 4px;
  padding: 0 5px; line-height: 16px; white-space: nowrap;
}
.unit-lg { font-size: 12px; padding: 0 8px; line-height: 22px; color: var(--ink-3); background: var(--tile); }

/* ---------------- chips ---------------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: inherit; font-size: 13px; color: var(--ink-2);
  background: #fff; border: 1px solid #e1e4e8; border-radius: 8px;
  padding: 6px 11px; cursor: pointer; white-space: nowrap;
  transition: color .14s, background .14s, border-color .14s;
}
.chip:hover { border-color: #c8ced6; background: #fbfcfd; }
.chip.is-on { background: var(--btn); border-color: var(--btn); color: #fff; font-weight: 600; }

.seg { flex: 0 0 auto; gap: 4px; }
.seg .chip { font-size: 11.5px; padding: 5px 8px; border-radius: 7px; }

.pin, .switch {
  font: inherit; font-size: 10.5px; color: var(--muted);
  background: #fff; border: 1px solid #e1e4e8; border-radius: 999px;
  padding: 1px 7px; cursor: pointer; line-height: 15px; transition: all .14s;
}
.pin.is-on, .switch.is-on {
  color: var(--ink); border-color: #b3bac4; background: var(--tile); font-weight: 600;
}

.primary {
  width: 100%; height: 42px; margin-top: 6px;
  font: inherit; font-size: 14px; font-weight: 600; letter-spacing: .02em;
  color: #fff; background: var(--btn); border: none; border-radius: 10px;
  cursor: pointer; transition: background .14s;
}
.primary:hover { background: var(--btn-hover); }
.primary:active { background: var(--btn-active); }

.hint { margin: 7px 0 0; font-size: 11px; color: var(--muted); }

/* ---------------- 右：结果 ---------------- */
.col-result {
  display: flex;
  flex-direction: column;
  gap: 13px;
  justify-content: flex-start;
  min-width: 0;
}

.panel-result { display: flex; flex-direction: column; gap: 14px; padding: 20px 22px 16px; }

/* 两个核心数字 */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr);
  gap: 18px;
  align-items: stretch;
}
.hero-primary {
  display: flex; flex-direction: column; justify-content: center;
  gap: 1px; min-width: 0; padding: 2px 0;
}
.kicker { font-size: 11.5px; letter-spacing: .08em; color: var(--ink-3); }
.hero-primary strong {
  font-size: clamp(48px, 5vw, 68px);
  line-height: 1.03;
  letter-spacing: -.035em;
  font-weight: 650;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}
.hero-sub { font-size: 11.5px; color: var(--muted); }

.hero-total {
  background: var(--dark);
  border-radius: 12px;
  padding: 14px 18px;
  display: flex; flex-direction: column; justify-content: center;
  gap: 1px; min-width: 0;
}
.hero-total .kicker { color: #a9b0ba; }
.hero-total b {
  font-size: clamp(30px, 2.9vw, 44px);
  line-height: 1.06;
  letter-spacing: -.02em;
  font-weight: 650;
  color: #fff;
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}
.hero-total .hero-sub { color: #8f97a1; }

/* 构成条 */
.split { display: flex; flex-direction: column; gap: 6px; }
.split-bar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: #eceef1; }
.split-bar i { display: block; height: 100%; transition: width .25s ease; }
.split-bar i#barValue { background: #4b5563; }
.split-bar i#barPremium { background: #cdd1d7; }
.split-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 11.5px; color: var(--ink-3); }
.split-legend b { color: var(--ink-2); font-variant-numeric: tabular-nums; font-weight: 600; }
.dot { width: 7px; height: 7px; border-radius: 2px; display: inline-block; margin-right: 6px; }
.dot.value { background: #4b5563; }
.dot.premium { background: #cdd1d7; }

.result-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  border-top: 1px solid var(--line-2); padding-top: 13px;
}
.actions { display: flex; gap: 8px; }
.ghost {
  font: inherit; font-size: 12.5px; color: var(--ink-2);
  background: #fff; border: 1px solid #e1e4e8; border-radius: 8px;
  padding: 7px 12px; cursor: pointer; white-space: nowrap; transition: all .14s;
}
.ghost:hover { background: var(--tile); border-color: #c8ced6; color: var(--ink); }
.result-note { margin: 0; font-size: 11.5px; color: #a1600f; }

/* 明细 / 汇率卡 */
.panel-detail, .panel-rates { padding: 16px 20px 18px; }

.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.block-head h3 {
  margin: 0; font-size: 11.5px; font-weight: 600; letter-spacing: .1em; color: var(--ink-3);
  display: flex; align-items: center; gap: 7px;
}
.muted { font-size: 11px; color: var(--muted); }

.stats { margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.stat {
  border: 1px solid var(--line-2);
  background: var(--tile);
  border-radius: 10px;
  padding: 11px 13px;
  min-width: 0;
}
.stat dt { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat dd {
  margin: 2px 0 0; font-size: 15px; font-variant-numeric: tabular-nums;
  color: var(--ink-2); word-break: break-all;
}
.stat.is-strong { background: #eef0f3; border-color: #e2e5e9; }
.stat.is-strong dd { color: var(--ink); font-weight: 650; }
.stat.is-warn dd { color: #a1600f; }

.rate-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.rate-cell {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  border: 1px solid var(--line-2); background: var(--tile); border-radius: 8px;
  padding: 9px 11px; min-width: 0;
}
.rate-cell span { font-size: 11px; color: var(--muted); }
.rate-cell b { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink-2); }

/* ---------------- 页脚 ---------------- */
.foot { text-align: center; font-size: 11px; color: var(--muted); }

/* ---------------- 弹窗 ---------------- */
.help-dialog {
  width: min(580px, calc(100% - 28px));
  max-height: 82vh; overflow: auto;
  border: 1px solid var(--line); border-radius: 14px;
  background: #fff; color: var(--ink);
  padding: 22px 24px 24px;
  box-shadow: 0 30px 70px -24px rgba(16, 24, 40, .4);
}
.help-dialog::backdrop { background: rgba(21, 24, 28, .3); }
.help-dialog h3 { margin: 0 0 12px; font-size: 16px; font-weight: 650; }
.help-dialog h4 { margin: 18px 0 6px; font-size: 12px; color: var(--ink-3); letter-spacing: .08em; }
.help-close {
  position: absolute; top: 10px; right: 12px;
  width: 28px; height: 28px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  font-size: 17px; line-height: 1; cursor: pointer;
}
.help-close:hover { color: var(--ink); background: var(--tile); }
.formula {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px; color: var(--ink-2);
  background: var(--tile); border: 1px solid var(--line-2);
  border-radius: 9px; padding: 9px 11px; word-break: break-word;
}
.steps { font-size: 13px; color: var(--ink-2); margin: 13px 0 0; padding-left: 17px; }
.steps li { margin-bottom: 6px; }
.steps b { color: var(--ink); }
.help-dialog details { border-top: 1px solid var(--line-2); padding: 9px 0; font-size: 13px; }
.help-dialog details:last-of-type { border-bottom: 1px solid var(--line-2); }
.help-dialog summary { cursor: pointer; color: var(--ink); }
.help-dialog p { margin: 5px 0 0; color: var(--ink-3); }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------- 自适应 ---------------- */
@media (max-height: 860px) and (min-width: 1001px) {
  body { padding: 12px 0; }
  .app { gap: 10px; }
  .pane { padding: 10px 0; }
  .pane-title { margin-bottom: 9px; }
  .field { margin-bottom: 7px; }
  .panel-result { padding: 18px 20px 14px; gap: 12px; }
  .hero-primary strong { font-size: 52px; }
  .hero-total b { font-size: 34px; }
  .hero-total { padding: 12px 16px; }
  .panel-detail, .panel-rates { padding: 16px 18px 17px; }
  .block-head { margin-bottom: 11px; }
  .stat { padding: 9px 11px; }
  .stat dd { font-size: 14.5px; }
  .rate-cell { padding: 8px 10px; }
  .result-foot { padding-top: 11px; }
  .primary { height: 40px; margin-top: 4px; }
  input, select { height: 36px; }
  .chip { padding: 5px 10px; }
}

@media (min-height: 980px) and (min-width: 1001px) {
  .app { width: min(1380px, 100% - 56px); }
  .board { grid-template-columns: 424px minmax(0, 1fr); gap: 16px; }
  .app { gap: 16px; }
  .pane { padding: 17px 0; }
  .hero-primary strong { font-size: 72px; }
  .hero-total b { font-size: 46px; }
  .panel-result { padding: 24px 26px 18px; gap: 18px; }
  .panel-detail, .panel-rates { padding: 20px 24px 22px; }
  .stat { padding: 11px 14px; }
  .stat dd { font-size: 16px; }
  .rate-cell { padding: 9px 12px; }
  .rate-cell b { font-size: 13px; }
  .col-result { gap: 16px; }
}

@media (max-width: 1000px) {
  body { display: block; padding: 16px 0 22px; }
  .app { width: calc(100% - 30px); margin: 0 auto; gap: 12px; }
  .board { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .col-result { gap: 12px; }
  .hero { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .hero-primary strong { font-size: 46px; }
  .hero-total b { font-size: 34px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rate-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .row, .row-3 { grid-template-columns: 1fr; gap: 0; }
  .inline { flex-wrap: wrap; }
  .seg { width: 100%; }
}

@media (max-width: 460px) {
  .pill { display: none; }
}
