/* CS2 饰品记账本 —— 样式 */

:root {
  --bg: #080b11;
  --surface: #11161f;
  --surface-2: #1a2130;
  --line: #232c3d;
  --text: #e8edf7;
  --muted: #8b97ad;
  --dim: #5d687d;
  --accent: #ff9f43;
  --accent-2: #4d9dff;
  --green: #35d07f;
  --red: #ff5f6d;
  --radius: 18px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  background-image:
    radial-gradient(900px 420px at 12% -8%, rgba(255, 159, 67, 0.10), transparent 70%),
    radial-gradient(800px 400px at 92% 4%, rgba(77, 157, 255, 0.09), transparent 72%);
  background-attachment: fixed;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

a { color: inherit; text-decoration: none; }

.hidden { display: none !important; }
[hidden] { display: none !important; }

#view {
  max-width: 720px;
  margin: 0 auto;
  padding-bottom: 148px;
  min-height: 60dvh;
}

/* ---------- 顶栏 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 12px;
  background: linear-gradient(to bottom, rgba(8, 11, 17, 0.96) 60%, rgba(8, 11, 17, 0));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.topbar h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.topbar-l { min-width: 0; }

.eyebrow {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.02em;
  margin-bottom: 2px;
}

.topbar-r { width: 40px; }

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 18px;
  color: var(--text);
}

.ghost-btn {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

/* ---------- 余额卡 ---------- */

.balances {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 4px 16px 0;
}

.balance-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 14px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  text-align: left;
  overflow: hidden;
  transition: transform 0.15s ease;
}

.balance-card:active { transform: scale(0.985); }

.balance-card.otc {
  background: linear-gradient(150deg, rgba(255, 159, 67, 0.20), rgba(255, 159, 67, 0.03) 70%);
  border-color: rgba(255, 159, 67, 0.28);
}

.balance-card.steam {
  background: linear-gradient(150deg, rgba(77, 157, 255, 0.20), rgba(77, 157, 255, 0.03) 70%);
  border-color: rgba(77, 157, 255, 0.28);
}

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

.bc-chev {
  position: absolute;
  top: 10px;
  right: 14px;
  font-size: 18px;
  line-height: 1;
  color: rgba(255, 255, 255, 0.22);
}

.bc-value {
  font-size: clamp(19px, 5.4vw, 26px);
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.bc-delta {
  font-size: 12px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

/* ---------- 卡片 ---------- */

.card {
  margin: 14px 16px 0;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.card-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.link {
  font-size: 13px;
  color: var(--accent);
}

.mini-btn {
  flex: none;
  padding: 7px 13px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 14px 12px;
}

.metric {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
}

.metric span { font-size: 11px; color: var(--muted); }
.metric b {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.metric small { font-size: 10px; color: var(--dim); }

.up { color: var(--green) !important; }
.down { color: var(--red) !important; }

.badge {
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: rgba(255, 159, 67, 0.18);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
}

.badge.warn { background: rgba(53, 208, 127, 0.16); color: var(--green); }

.tag {
  flex: none;
  padding: 3px 8px;
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.tag.ok { background: rgba(53, 208, 127, 0.15); color: var(--green); }
.tag.warn { background: rgba(255, 159, 67, 0.15); color: var(--accent); }

/* ---------- 行 ---------- */

.rows { display: flex; flex-direction: column; }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid rgba(35, 44, 61, 0.6);
  text-align: left;
  width: 100%;
}

.row:last-child { border-bottom: none; }
.row-btn { width: 100%; }

.row-main { flex: 1; min-width: 0; }

.row-title {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-sub.dim { color: var(--dim); }

.amount {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.amount.in { color: var(--green); }
.amount.out { color: var(--text); }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
  background: var(--dim);
}

.dot.buy { background: #6f7d94; }
.dot.sell { background: var(--green); }
.dot.deposit { background: var(--accent-2); }
.dot.withdraw { background: var(--red); }
.dot.move { background: #b18cff; }
.dot.adjust { background: var(--accent); }

.empty {
  margin: 6px 0 2px;
  font-size: 13px;
  color: var(--dim);
}

.empty.big { padding: 40px 0; text-align: center; }

/* ---------- 底部导航 ---------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(10, 13, 19, 0.92);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.tab {
  flex: 1;
  max-width: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 0;
  color: var(--dim);
  border-radius: 12px;
}

.tab.on { color: var(--accent); }
.tab-icon { width: 22px; height: 22px; display: block; }
.tab-icon svg { width: 100%; height: 100%; display: block; }
.tab-label { font-size: 11px; }

.fab {
  position: fixed;
  right: 18px;
  bottom: calc(74px + env(safe-area-inset-bottom));
  z-index: 31;
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: linear-gradient(140deg, #ffb457, #ff8a1f);
  color: #1a1205;
  font-size: 30px;
  font-weight: 300;
  line-height: 1;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 26px rgba(255, 138, 31, 0.35);
  transition: transform 0.15s ease;
}

.fab:active { transform: scale(0.94); }

/* ---------- 表单 ---------- */

.form { padding: 4px 16px 40px; }

.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border-radius: 14px;
  margin-top: 4px;
}

.seg button {
  padding: 10px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease;
}

.seg button.on {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.field { margin-top: 18px; }

.field > label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 7px;
}

.field input {
  width: 100%;
  padding: 13px 14px;
  background: #0d121b;
  border: 1px solid var(--line);
  border-radius: 13px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.15s ease;
}

.field input:focus { border-color: rgba(255, 159, 67, 0.55); }

/* 日期 + 小时 */
.dt-row {
  display: grid;
  grid-template-columns: 1fr 92px;
  gap: 10px;
}

.dt-row select {
  width: 100%;
  padding: 13px 10px;
  background: #0d121b;
  border: 1px solid var(--line);
  border-radius: 13px;
  font-size: 16px;
  outline: none;
  text-align: center;
}

.dt-row select:focus { border-color: rgba(255, 159, 67, 0.55); }

/* 输入联想 */
.ac { position: relative; }

.ac-list {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 60;
  max-height: 264px;
  overflow-y: auto;
  background: #141a25;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
}

.ac-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  text-align: left;
  font-size: 14px;
  color: var(--text);
  border-bottom: 1px solid rgba(35, 44, 61, 0.6);
}

.ac-item:last-child { border-bottom: none; }
.ac-item:active { background: var(--surface-2); }
.ac-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-item small { flex: none; font-size: 11px; color: var(--dim); }

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

.hint {
  margin: 7px 2px 0;
  font-size: 12px;
  color: var(--dim);
}

.hint.warn { color: var(--accent); }

.calc {
  margin-top: 12px;
  padding: 11px 14px;
  background: var(--surface-2);
  border-radius: 13px;
  font-size: 13px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.calc b { color: var(--text); }
.calc .op { color: var(--dim); }
.calc .muted { color: var(--dim); }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 9px 14px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.chip.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a1205;
  font-weight: 600;
}

.chip.small { padding: 6px 11px; font-size: 12px; }

.chip.wide {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  border-radius: 14px;
  padding: 12px 14px;
  width: 100%;
  white-space: normal;
}

.chip.wide b { font-size: 14px; }
.chip.wide small { font-size: 11px; color: var(--dim); }
.chip.wide.on small { color: rgba(26, 18, 5, 0.65); }

.chips.stack { flex-direction: column; }

.filter { padding: 4px 0 2px; }

.form-actions {
  margin-top: 28px;
  display: grid;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 18px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
}

.btn.primary {
  background: linear-gradient(140deg, #ffb457, #ff8a1f);
  border: none;
  color: #1a1205;
}

.btn:disabled { opacity: 0.6; }

/* 卡片里直接放的按钮撑满一行（比如设置页的「保存」） */
.card > .btn { width: 100%; margin-top: 14px; }

.btn.danger-ghost {
  background: transparent;
  color: var(--red);
  border-color: rgba(255, 95, 109, 0.3);
}

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 8px 0 12px;
}

.pad { padding: 4px 16px 0; }
.pad .card { margin-left: 0; margin-right: 0; }

.search {
  width: 100%;
  margin: 10px 0 4px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 13px;
  font-size: 15px;
  outline: none;
}

/* ---------- 流水 / 持仓 ---------- */

.day-group { margin-top: 14px; }

.day-head {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  padding: 6px 4px;
  position: sticky;
  top: 62px;
  background: linear-gradient(to bottom, var(--bg) 70%, rgba(8, 11, 17, 0));
  z-index: 5;
}

.day-head .muted { color: var(--dim); }

.entry-line { border-bottom: 1px solid rgba(35, 44, 61, 0.45); }
.entry-line .row { border-bottom: none; }

.lot-group { padding-top: 14px; }

.lot-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.lot-line {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid rgba(35, 44, 61, 0.45);
}

.lot-line:last-child { border-bottom: none; }
.lot-line.sold { opacity: 0.45; }

.lot-remain {
  flex: none;
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.lot-remain small { font-size: 12px; color: var(--dim); font-weight: 400; }

/* ---------- 图表 ---------- */

.chart-wrap { margin-top: 6px; }

.chart-box {
  position: relative;
  height: 190px;
  margin-top: 6px;
}

.chart-box-sm { height: 150px; }

.chart-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.chart-svg .grid {
  stroke: #232c3d;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.chart-svg .zero {
  stroke: #3b475c;
  stroke-width: 1;
  stroke-dasharray: 4 4;
  vector-effect: non-scaling-stroke;
}

.chart-y span {
  position: absolute;
  left: 0;
  width: 11.6%;
  transform: translateY(-50%);
  text-align: right;
  font-size: 11px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
}

.chart-x span {
  position: absolute;
  bottom: -2px;
  font-size: 11px;
  color: var(--dim);
  white-space: nowrap;
}

.chart-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 3px rgba(8, 11, 17, 0.9);
}

.chart-empty {
  padding: 34px 0;
  text-align: center;
  font-size: 13px;
  color: var(--dim);
}

/* ---------- 设置 ---------- */

.kv {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 18px;
  margin: 10px 0 0;
}

.kv > div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.kv .wide { grid-column: 1 / -1; }
.kv dt { color: var(--muted); margin: 0; }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }
.kv.compact { grid-template-columns: 1fr; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 6px;
}

.table th {
  text-align: left;
  font-weight: 500;
  color: var(--dim);
  font-size: 11px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

.table td { padding: 9px 0; border-bottom: 1px solid rgba(35, 44, 61, 0.45); }
.table tr:last-child td { border-bottom: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

.backup-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  font-size: 12px;
}

.backup-list li {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid rgba(35, 44, 61, 0.45);
  color: var(--muted);
}

.footnote {
  text-align: center;
  font-size: 12px;
  color: var(--dim);
  margin: 28px 0 8px;
}

/* ---------- 提示 / 登录 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 100;
  transform: translate(-50%, 12px);
  padding: 12px 20px;
  border-radius: 14px;
  background: #1e2633;
  border: 1px solid var(--line);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: 80vw;
  text-align: center;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { border-color: rgba(255, 95, 109, 0.5); }
.toast.ok { border-color: rgba(53, 208, 127, 0.5); }

.login-mask {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  background: rgba(4, 6, 10, 0.82);
  backdrop-filter: blur(8px);
}

.login-box {
  width: min(340px, 88vw);
  display: grid;
  gap: 12px;
  padding: 24px;
  margin: 0;
}

.login-box h2 { margin: 0; font-size: 20px; }
.login-box input {
  padding: 13px 14px;
  background: #0d121b;
  border: 1px solid var(--line);
  border-radius: 13px;
  font-size: 16px;
  outline: none;
}

.loading { display: grid; place-items: center; padding: 90px 0; }

.spinner {
  width: 26px;
  height: 26px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.error-card { margin: 40px 16px; }
.error-card h2 { margin: 0 0 8px; font-size: 17px; }

/* ---------- 宽屏 ---------- */

@media (min-width: 760px) {
  body { font-size: 16px; }
  .topbar, .pad, .form, .balances { padding-left: 8px; padding-right: 8px; }
  .card { margin-left: 8px; margin-right: 8px; }
  .tabbar { border-top: none; background: transparent; backdrop-filter: none; bottom: 12px; pointer-events: none; }
  .tab { pointer-events: auto; background: rgba(17, 22, 31, 0.9); border: 1px solid var(--line); border-radius: 14px; }
  .tab.on { background: rgba(255, 159, 67, 0.12); }
  #view { padding-bottom: 120px; }
}

@media (max-width: 360px) {
  .balances { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metrics .metric:last-child { grid-column: 1 / -1; }
}

/* 备份提醒 */
.warn-card {
  display: grid;
  gap: 4px;
  width: calc(100% - 32px);
  text-align: left;
  background: rgba(255, 159, 67, 0.08);
  border-color: rgba(255, 159, 67, 0.35);
}
.warn-card b { color: var(--accent); font-size: 14px; }
.warn-card span { font-size: 12px; color: var(--muted); line-height: 1.45; }
