/* ============================================================
   DeepSeek 调价成本计算器 · 深色主题 · 零外部依赖
   ============================================================ */

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0b0f17;
  --panel: #121826;
  --panel-2: #182132;
  --border: #1e2a3e;
  --text: #e8ecf4;
  --muted: #8b96a8;
  --accent: #4d6bfe;
  --accent-soft: rgba(77, 107, 254, 0.14);
  --before: #59b8ff;
  --after: #ffb454;
  --danger: #ff6b6b;
  --radius: 14px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC",
    sans-serif;
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(1000px 620px at 88% -10%, rgba(77, 107, 254, 0.18), transparent 60%),
    radial-gradient(820px 520px at -8% 30%, rgba(89, 184, 255, 0.10), transparent 55%),
    var(--bg);
}

[hidden] {
  display: none !important;
}

/* ---------- 页面容器 ---------- */
.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 30px 20px 48px;
}

/* ---------- Hero ---------- */
.hero {
  text-align: center;
  padding: 14px 0 30px;
}

.hero-badge {
  display: inline-block;
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--accent);
  border: 1px solid rgba(77, 107, 254, 0.45);
  background: var(--accent-soft);
  padding: 4px 14px;
  border-radius: 999px;
}

.hero h1 {
  margin: 16px 0 8px;
  font-size: clamp(26px, 4.4vw, 40px);
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.hero .accent {
  color: var(--after);
}

.hero .sub {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

/* ---------- 布局 ---------- */
.layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
  align-items: start;
}

.layout > * {
  min-width: 0; /* 防止网格子项把内容撑爆 */
}

/* ---------- 面板 ---------- */
.panel {
  background: linear-gradient(180deg, rgba(21, 29, 46, 0.92), rgba(14, 20, 32, 0.94));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.28);
}

.panel h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 18px;
  font-size: 16px;
  letter-spacing: 0.02em;
}

.panel h2::before {
  content: "";
  width: 4px;
  height: 16px;
  border-radius: 2px;
  background: var(--accent);
  flex: none;
}

/* ---------- 输入字段 ---------- */
.field {
  margin-bottom: 16px;
}

.field label,
.field .label-text {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.input-wrap {
  position: relative;
}

.input-wrap input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input-wrap input::placeholder {
  color: #566074;
}

.input-wrap input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input-wrap.with-unit input {
  padding-right: 42px;
}

.input-wrap .unit {
  position: absolute;
  right: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 14px;
  pointer-events: none;
}

.field.error input {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.12);
}

.field-error {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--danger);
}

.field-error:empty {
  display: none;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

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

/* ---------- 预设按钮 ---------- */
.presets {
  margin-bottom: 20px;
}

.presets-label {
  font-size: 12px;
  color: var(--muted);
}

.preset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.preset-btn {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, transform 0.05s;
}

.preset-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.preset-btn:active {
  transform: scale(0.97);
}

.preset-btn.ghost {
  color: var(--muted);
}

/* ---------- 档位切换 ---------- */
.seg {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
}

.seg-btn {
  flex: 1;
  padding: 9px 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.seg-btn.active {
  background: var(--accent);
  color: #fff;
}

/* ---------- 结果：统计卡 ---------- */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.stat-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  min-width: 0;
}

.stat-label {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}

.tier-tag {
  font-size: 10px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

.stat-value {
  margin-top: 6px;
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  word-break: break-word;
}

.stat-card.after .stat-value {
  color: var(--after);
}

.stat-card.highlight {
  border-color: rgba(255, 180, 84, 0.45);
  background: linear-gradient(180deg, rgba(255, 180, 84, 0.10), rgba(255, 180, 84, 0.03));
}

.stat-card.highlight .stat-value {
  color: var(--after);
}

.unit-suffix {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  margin-left: 4px;
}

.delta {
  margin-top: 5px;
  font-size: 12px;
  color: var(--after);
  font-variant-numeric: tabular-nums;
}

/* ---------- 每日成本 ---------- */
.daily {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.daily-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.daily-label {
  font-size: 12px;
  color: var(--muted);
}

.daily-value {
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- 可视化对比 ---------- */
.chart {
  margin-top: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.chart-title {
  margin: 0 0 14px;
  font-size: 12px;
  color: var(--muted);
}

.chart-bar-row {
  display: grid;
  grid-template-columns: 56px 1fr 96px;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.chart-bar-row:last-child {
  margin-bottom: 0;
}

.bar-label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.bar-track {
  height: 18px;
  background: #0a0f1a;
  border-radius: 9px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 9px;
  min-width: 0;
  transition: width 0.35s ease;
}

.bar-fill.before {
  background: linear-gradient(90deg, #3aa2ff, #59b8ff);
}

.bar-fill.after {
  background: linear-gradient(90deg, #ff9f43, #ffc97a);
}

.bar-value {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

/* ---------- 费用构成 ---------- */
.breakdown {
  margin-top: 16px;
}

.breakdown h3 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.breakdown table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.breakdown th,
.breakdown td {
  text-align: right;
  padding: 7px 8px;
  border-bottom: 1px solid var(--border);
}

.breakdown th {
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
}

.breakdown td:first-child,
.breakdown th:first-child {
  text-align: left;
  color: var(--muted);
  font-variant-numeric: normal;
}

.breakdown tbody tr:last-child td {
  border-bottom: 0;
}

/* ---------- 单价表 ---------- */
.price-panel {
  margin-top: 20px;
}

.price-panel .muted {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  margin-left: 8px;
}

.table-scroll {
  overflow-x: auto;
}

.price-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.price-table th,
.price-table td {
  text-align: right;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.price-table th:first-child,
.price-table td:first-child {
  text-align: left;
}

.price-table thead th {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.price-table tbody tr:last-child td {
  border-bottom: 0;
}

.price-table th.col-idle.active,
.price-table th.col-peak.active {
  color: var(--accent);
}

.price-table td.col-idle.active,
.price-table td.col-peak.active {
  background: var(--accent-soft);
}

/* ---------- 非法输入提示 ---------- */
.invalid-banner {
  border: 1px dashed var(--danger);
  color: var(--danger);
  background: rgba(255, 107, 107, 0.08);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 13px;
}

/* ---------- 页脚 ---------- */
footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin-top: 28px;
}

footer p {
  margin: 0;
}

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .field-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .page {
    padding: 18px 14px 36px;
  }

  .panel {
    padding: 16px;
  }

  .stat-cards {
    grid-template-columns: 1fr;
  }

  .chart-bar-row {
    grid-template-columns: 48px 1fr 88px;
    gap: 8px;
  }
}
