:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #101c2e;
  --ink-2: #37475f;
  --muted: #6b7a92;
  --line: #e5eaf1;
  --line-soft: #eef2f7;
  --accent: #1f57d6;
  --accent-soft: #eef2fd;
  --up: #d92b45;
  --down: #12855b;
  --warn: #b26a00;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 28, 46, .04), 0 10px 28px rgba(16, 28, 46, .05);
  --mono: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0; }
button { font-family: inherit; cursor: pointer; }
code {
  font-family: var(--mono);
  font-size: .92em;
  background: #eef2f7;
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--ink-2);
}
.hidden, [hidden] { display: none !important; }

/* ---------------- 数字排版 ---------------- */
.num, td.num, th.num, .stat-val, .kpi-val {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* ---------------- 登录 ---------------- */
.auth-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  background:
    radial-gradient(900px 460px at 15% -10%, #e8eefc 0%, transparent 60%),
    radial-gradient(700px 400px at 100% 100%, #eef4f1 0%, transparent 55%),
    var(--bg);
}

/* 访客模式下从看板点「登录」：登录页盖在上面，不做整页跳转 */
body.auth-overlay { overflow: hidden; }
body.auth-overlay .auth-screen {
  position: fixed;
  inset: 0;
  z-index: 60;
  overflow-y: auto;
  /* safe center：放得下就居中，放不下（注册态 + 手机键盘）就从顶部开始滚 */
  justify-content: safe center;
  animation: fade .18s ease;
}

.auth-card {
  width: 100%;
  max-width: 392px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 30px 28px 24px;
  box-shadow: var(--shadow);
}

.auth-brand { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 22px; }
.auth-brand h1 { font-size: 21px; margin-bottom: 4px; }
.auth-brand p { color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.brand-mark { flex: 0 0 auto; line-height: 0; }
.brand-img {
  display: block;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: #0b0b0b;
  object-fit: cover;
}
.brand-img.lg { width: 44px; height: 44px; border-radius: 12px; }

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: #f1f4f8;
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 18px;
}
.auth-tab {
  border: 0;
  background: transparent;
  padding: 8px 0;
  border-radius: 7px;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  transition: .18s;
}
.auth-tab.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(16, 28, 46, .1); }

.field { display: block; margin-bottom: 14px; }
.field > span, .field > label {
  display: block;
  font-size: 12.5px;
  color: var(--ink-2);
  font-weight: 600;
  margin-bottom: 6px;
}
.field-hint {
  display: block;
  font-style: normal;
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 5px;
  line-height: 1.4;
  min-height: 14px;
}

/* 合约：自制下拉。原生 datalist 的箭头在部分浏览器里点不开，
   而且会把「代码」和「代码·年化」分两行重复显示，所以改成自己画。 */
.combo { position: relative; }
#fCode { padding-right: 32px; background-color: #fff; }
.combo-btn {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; padding: 0;
  border: 0; border-radius: 7px; background: transparent;
  color: var(--muted);
}
.combo-btn:hover { background: #f1f4f8; color: var(--ink-2); }
.combo-btn svg { transition: transform .16s ease; }
.combo-btn.open svg { transform: rotate(180deg); }
.combo-panel {
  position: absolute; z-index: 40; left: 0; top: calc(100% + 5px);
  width: max-content; min-width: 100%; max-width: 268px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 30px rgba(16, 28, 46, .14);
  padding: 4px; max-height: 232px; overflow-y: auto;
}
.combo-panel[hidden] { display: none; }
.combo-item {
  display: flex; align-items: baseline; justify-content: space-between;
  flex-wrap: nowrap; gap: 10px;
  padding: 7px 9px; border-radius: 7px; cursor: pointer;
  font-size: 13px; color: var(--ink-2); white-space: nowrap;
}
.combo-item:hover { background: #f4f7fc; }
.combo-item.active { background: var(--accent-soft); color: var(--ink); }
.ci-code { font-weight: 600; letter-spacing: .01em; }
.ci-code em {
  font-style: normal; font-size: 10px; font-weight: 500; color: var(--accent);
  background: var(--accent-soft); border-radius: 4px; padding: 1px 4px; margin-left: 5px;
}
.ci-meta { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.combo-empty { padding: 8px 9px; font-size: 11.5px; color: var(--muted); line-height: 1.5; }

input[type="text"], input[type="password"], input[type="number"],
input[type="date"], input[type="datetime-local"], select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: #9db4e8;
  box-shadow: 0 0 0 3px rgba(31, 87, 214, .1);
}
textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font-size: 13.5px;
  font-family: inherit;
  line-height: 1.65;
  min-height: 58px;
  resize: vertical;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236b7a92' stroke-width='1.4' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; padding-right: 28px; }

.btn {
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 9px 14px;
  font-size: 13.5px;
  font-weight: 600;
  transition: .16s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #1b2c45; }
.btn-primary:active { transform: translateY(1px); }
.btn-ghost { background: #fff; border-color: #dde4ee; color: var(--ink-2); }
.btn-ghost:hover { border-color: #c2d0e2; background: #f7fafd; color: var(--ink); }
.btn-block { width: 100%; justify-content: center; padding: 11px; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.link-btn {
  border: 0; background: none; color: var(--muted); font-size: 12.5px; padding: 2px 4px;
  white-space: nowrap;
}
.link-btn:hover { color: var(--up); }

.auth-error, .form-error {
  color: var(--up);
  font-size: 12.5px;
  margin: -4px 0 12px;
  line-height: 1.5;
}
/* 「需要登录才能用」这类说明不是错误，别用红字吓人 */
.auth-error.hint { color: var(--muted); }
.auth-guest {
  display: block;
  width: 100%;
  margin-top: 14px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 12.5px;
  padding: 6px 0;
  transition: .16s;
}
.auth-guest:hover { color: var(--ink-2); }
.auth-note {
  margin-top: 16px;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--muted);
  border-top: 1px dashed var(--line);
  padding-top: 12px;
}
.auth-disclaimer {
  font-size: 11.5px;
  color: var(--muted);
  max-width: 392px;
  text-align: center;
  line-height: 1.6;
}

/* ---------------- 顶栏 ---------------- */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px;
  height: 58px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 12px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 14.5px; letter-spacing: -.01em; }
.stamp { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--ink-2);
  font-weight: 600;
}

/* ---------------- 标签页 ---------------- */
.tabs {
  display: flex;
  gap: 2px;
  padding: 0 28px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 58px;
  z-index: 25;
}
.tab {
  border: 0;
  background: none;
  padding: 12px 14px 11px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: .16s;
}
.tab:hover { color: var(--ink-2); }
.tab.active { color: var(--ink); border-bottom-color: var(--ink); }
/* 访客看到的不可用标签：仍可点，点了给登录入口 */
.tab.locked { opacity: .5; }
.tab.locked::after {
  content: '';
  display: inline-block;
  width: 9px; height: 9px;
  margin-left: 5px;
  vertical-align: 1px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1a3.2 3.2 0 0 0-3.2 3.2V6H4a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1h-.8V4.2A3.2 3.2 0 0 0 8 1zm0 1.6c.9 0 1.6.7 1.6 1.6V6H6.4V4.2c0-.9.7-1.6 1.6-1.6z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1a3.2 3.2 0 0 0-3.2 3.2V6H4a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1h-.8V4.2A3.2 3.2 0 0 0 8 1zm0 1.6c.9 0 1.6.7 1.6 1.6V6H6.4V4.2c0-.9.7-1.6 1.6-1.6z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.content { flex: 1; width: 100%; max-width: 1340px; margin: 0 auto; padding: 22px 28px 40px; }
.view { display: none; }
.view.active { display: block; animation: fade .22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------------- 卡片 / 面板 ---------------- */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px 16px;
  margin-bottom: 18px;
}
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.panel-head.wrap { flex-wrap: wrap; }
.panel-head h2 { font-size: 15.5px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.panel-sub { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.5; }
.count-badge {
  font-size: 11.5px;
  font-weight: 600;
  background: #eef2f7;
  color: var(--ink-2);
  border-radius: 20px;
  padding: 1px 8px;
}

/* ---------------- 品种卡 ---------------- */
.variety-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
.vcard {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 15px 16px 12px;
  cursor: pointer;
  transition: .18s;
  position: relative;
  overflow: hidden;
}
.vcard:hover { border-color: #cfdaea; transform: translateY(-1px); }
.vcard.active { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink), var(--shadow); }
.vcard-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.vcard-name { font-size: 12.5px; font-weight: 700; color: var(--ink-2); letter-spacing: .02em; }
.vcard-name em { font-style: normal; color: var(--muted); font-weight: 500; margin-left: 5px; }
.vcard-spot { font-size: 20px; font-weight: 650; margin: 8px 0 2px; letter-spacing: -.02em; }
.vcard-chg { font-size: 11.5px; font-weight: 600; }
.vcard-ann-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}
.vcard-label { font-size: 11px; color: var(--muted); }
.vcard-ann { font-size: 17px; font-weight: 700; letter-spacing: -.02em; }
.spark { display: block; }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}
.data-table th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
  position: sticky;
  top: 0;
  white-space: nowrap;
}
.data-table th.num, .data-table td.num { text-align: right; }
.data-table td {
  padding: 10px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink-2);
  vertical-align: middle;
}
.data-table tbody tr:hover td { background: #fafcff; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table.compact td { padding: 9px 10px; }

.code-cell { display: flex; align-items: center; gap: 8px; }
.code-main { font-weight: 650; color: var(--ink); font-family: var(--mono); font-size: 12.5px; }
.tag-main {
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: var(--ink);
  border-radius: 4px;
  padding: 1px 5px;
  letter-spacing: .02em;
}
.tag-variety {
  font-size: 10.5px;
  color: var(--muted);
  background: #f1f4f8;
  border-radius: 4px;
  padding: 1px 6px;
}

.pos { color: var(--up); }
.neg { color: var(--down); }
.flat { color: var(--muted); }
.strong { font-weight: 650; color: var(--ink); }
.mono { font-family: var(--mono); }
.dim { color: var(--muted); }

.pctile-bar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}
.pctile-track {
  display: block;
  width: 38px;
  height: 4px;
  background: #eef2f7;
  border-radius: 3px;
  overflow: hidden;
}
.pctile-fill { display: block; height: 100%; background: var(--ink); border-radius: 3px; }
.pctile-fill.hot { background: var(--up); }

.seg {
  display: inline-flex;
  background: #f1f4f8;
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.seg-btn {
  border: 0;
  background: none;
  padding: 5px 11px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  border-radius: 6px;
  white-space: nowrap;
}
.seg-btn.active { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(16,28,46,.1); }

.footnote {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.65;
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px dashed var(--line);
}

/* ---------------- 记账 ---------------- */
.trade-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.form-panel { position: sticky; top: 118px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.trade-form { margin-top: 2px; }

.dir-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.dir-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9px;
  padding: 9px 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  transition: .16s;
}
.dir-btn:hover { border-color: #c9d5e6; }
.dir-btn.active { border-color: var(--ink); background: var(--ink); color: #fff; }
.dir-btn.active[data-dir="-1"] { background: var(--down); border-color: var(--down); }

.preview {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  background: #f8fafd;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 4px 0 14px;
}
.preview > div { display: flex; flex-direction: column; gap: 3px; }
.preview span { font-size: 10.5px; color: var(--muted); }
.preview b { font-size: 13.5px; font-weight: 650; font-variant-numeric: tabular-nums; }

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

.trade-list { display: flex; flex-direction: column; gap: 10px; }
.empty {
  padding: 26px 14px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  background: #fbfcfe;
  border: 1px dashed var(--line);
  border-radius: 10px;
  line-height: 1.6;
}

.trade-item {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 12px 14px 13px;
  background: #fff;
  transition: .16s;
}
.trade-item:hover { border-color: #cfdaea; background: #fcfdff; }
.ti-head-row {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  margin-bottom: 11px;
}
.ti-code { font-family: var(--mono); font-weight: 650; font-size: 13px; color: var(--ink); }
.ti-lots {
  font-size: 11.5px; font-weight: 600; color: var(--ink-2);
  background: #f1f4f8; border-radius: 4px; padding: 1px 6px;
}
.badge-dir {
  font-size: 10.5px;
  font-weight: 700;
  border-radius: 4px;
  padding: 1px 6px;
  color: #fff;
}
.badge-dir.long { background: var(--up); }
.badge-dir.short { background: var(--down); }
.ti-meta { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ti-metrics {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  border-top: 1px dashed var(--line);
  padding-top: 10px;
}
.metric { display: flex; flex-direction: column; gap: 3px; }
.metric .k { font-size: 10.5px; color: var(--muted); }
.metric .v { font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; }
.metric .v small { font-size: 10.5px; font-weight: 500; color: var(--muted); }
.metric .v.warn { color: var(--warn); }
.metric .v.danger { color: var(--up); }
.ti-actions { display: flex; gap: 6px; margin-left: auto; }
.icon-btn { padding: 5px 8px; color: var(--muted); }
.icon-btn:hover { color: var(--up); border-color: #f2c4cc; }

.pos-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  background: #f8fafd;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  padding: 8px 12px;
  margin-bottom: 11px;
  font-size: 11.5px;
  color: var(--muted);
}
.pos-summary b { font-size: 12.5px; color: var(--ink); font-variant-numeric: tabular-nums; }
.pos-summary .dim { color: var(--muted); font-weight: 500; }

/* 强平预警条 */
.risk-banner {
  background: #fff8ec;
  border: 1px solid #f2ddb4;
  border-radius: 9px;
  padding: 8px 12px;
  margin-bottom: 11px;
  font-size: 11.5px;
  line-height: 1.6;
  color: #7d5100;
}
.risk-banner.hot {
  background: #fdf1f3;
  border-color: #f2c3cb;
  color: #9c1b2d;
}
.risk-banner b { font-variant-numeric: tabular-nums; }
.risk-banner[hidden] { display: none; }

/* 保证金设置弹窗里的即时提示 */
.pref-note {
  background: #f8fafd;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--ink-2);
  margin: 2px 0 12px;
}
.pref-note b { font-variant-numeric: tabular-nums; color: var(--ink); }
.pref-note .hi { color: var(--up); font-weight: 650; }

/* ---------------- 复盘 ---------------- */
.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chips { display: inline-flex; gap: 4px; background: #f1f4f8; border-radius: 8px; padding: 3px; }
.chip {
  border: 0; background: none; padding: 5px 10px; font-size: 12.5px;
  font-weight: 600; color: var(--muted); border-radius: 6px;
}
.chip.active { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(16,28,46,.1); }
.filters .date-input { width: 136px; padding: 6px 8px; font-size: 12.5px; }
.filters .mini-select { width: auto; padding: 6px 26px 6px 9px; font-size: 12.5px; }
.dash { color: var(--muted); font-size: 12px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin: 4px 0 18px;
}
.kpi {
  background: #fbfcfe;
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  padding: 12px 13px;
}
.kpi-label { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.kpi-val { font-size: 19px; font-weight: 700; letter-spacing: -.02em; }
.kpi-val small { font-size: 12px; font-weight: 600; margin-left: 2px; }
.kpi-hint { font-size: 10.5px; color: var(--muted); margin-top: 4px; }

.chart-block { margin: 4px 0 20px; }
.chart-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; gap: 10px; flex-wrap: wrap; }
.chart-head h3 { font-size: 13px; color: var(--ink-2); }
.chart-hint { font-size: 11px; color: var(--muted); }
.chart-area { min-height: 150px; }
.chart-area.is-empty { min-height: 0; }

/* ---------------- 口径说明 ---------------- */
.calc-notes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.calc-note {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  background: #fbfcfe;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 10px 12px;
}
.calc-note p { font-size: 11.5px; line-height: 1.65; color: var(--ink-2); }
.cn-tag {
  flex: 0 0 auto;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--ink-2);
  background: #eef2f7;
  border-radius: 4px;
  padding: 2px 6px;
  margin-top: 1px;
}
.calc-note.warn { background: #fffbf4; border-color: #f5e6cb; }
.calc-note.warn .cn-tag { background: #fbeed6; color: #8a5a00; }

/* ---------------- 平仓弹窗 ---------------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(12, 22, 38, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 90;
  animation: fade .16s ease;
}
.modal {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(16, 28, 46, .22);
  padding: 18px 20px 16px;
  /* 管理弹窗字段变多后，小屏必须能滚，否则底部的「保存」点不到 */
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h3 { font-size: 15px; font-family: var(--mono); letter-spacing: .01em; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* ---------------- 提示 ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(16, 28, 46, .25);
  z-index: 100;
  animation: rise .2s ease;
}
.toast.err { background: #a81f33; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

.site-footer {
  padding: 16px 28px 26px;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.7;
  max-width: 1340px;
  margin: 0 auto;
  border-top: 1px solid var(--line);
  width: 100%;
}
.footer-risk { margin: 0; }
.footer-copy {
  margin: 8px 0 0;
  font-size: 11px;
  letter-spacing: .03em;
  color: var(--muted);
  opacity: .85;
}

/* ---------------- 响应式 ---------------- */
@media (max-width: 1080px) {
  .variety-grid { grid-template-columns: repeat(2, 1fr); }
  .trade-grid { grid-template-columns: 1fr; }
  .form-panel { position: static; }
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .ti-metrics { grid-template-columns: repeat(2, 1fr); }
}

/* 平板 / 手机：表格转卡片，顶栏与筛选栏压缩 */
@media (max-width: 760px) {
  html { -webkit-text-size-adjust: 100%; }
  body { overflow-x: hidden; }

  .content, .topbar, .tabs, .site-footer { padding-left: 14px; padding-right: 14px; }
  .content { padding-top: 14px; padding-bottom: 28px; }

  /* 顶栏：不再吸顶，把空间让给标签栏 */
  .topbar {
    position: static;
    height: auto;
    padding-top: 10px;
    padding-bottom: 10px;
    gap: 10px;
    flex-wrap: nowrap;
  }
  .topbar-left, .topbar-right { gap: 8px; min-width: 0; }
  .brand-text { min-width: 0; }
  .brand-text strong { font-size: 14px; white-space: nowrap; }
  .stamp {
    font-size: 10px;
    max-width: 44vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .user-chip { padding-left: 8px; gap: 6px; font-size: 12px; white-space: nowrap; }
  .user-chip span {
    max-width: 76px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  /* 移动端刷新按钮只留图标，避免文字竖排 */
  #refreshBtn { padding: 8px 10px; font-size: 0; gap: 0; }
  #refreshBtn svg { width: 15px; height: 15px; }

  .tabs {
    top: 0;
    padding: 0 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: 1 0 auto; padding: 12px 12px 11px; text-align: center; }

  /* 面板与卡片 */
  .panel { padding: 14px 14px 12px; border-radius: 12px; margin-bottom: 12px; }
  .panel-head {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    margin-bottom: 10px;
  }
  .panel-head .seg { align-self: flex-start; }
  .panel-head h2 { font-size: 14.5px; }
  .panel-sub { font-size: 11.5px; }
  .variety-grid { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
  .vcard { padding: 12px 12px 10px; }
  .vcard-spot { font-size: 17px; margin: 6px 0 2px; }
  .vcard-ann { font-size: 15px; }
  .vcard-ann-row { margin-top: 8px; padding-top: 8px; }
  .vcard-name { font-size: 11.5px; }
  .spark { display: none; }

  /* 表格 → 卡片。所有 .data-table 在窄屏下改为两列栅格 */
  .table-wrap { overflow: visible; margin: 0; }
  .data-table { display: block; white-space: normal; font-size: 12.5px; }
  .data-table thead { display: none; }
  .data-table tbody { display: block; }
  .data-table tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px 14px;
    padding: 10px 12px;
    margin-bottom: 8px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
  }
  .data-table tr:last-child { margin-bottom: 0; }
  .data-table tbody tr:hover td { background: transparent; }
  .data-table td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    padding: 3px 0;
    border: 0;
    text-align: left;
  }
  .data-table td.num { text-align: right; }
  .data-table td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    font-size: 11px;
    font-weight: 500;
    color: var(--muted);
  }
  .data-table td.cell-code {
    grid-column: 1 / -1;
    padding: 0 0 7px;
    margin-bottom: 4px;
    border-bottom: 1px dashed var(--line-soft);
  }
  .data-table td.cell-code::before { display: none; }
  .data-table td.cell-wide { grid-column: 1 / -1; }
  .data-table td.cell-act { grid-column: 1 / -1; padding-top: 8px; }
  .data-table td.cell-act .btn { width: 100%; justify-content: center; }
  .data-table td[colspan] {
    grid-column: 1 / -1;
    justify-content: center;
    text-align: center;
    padding: 14px 4px;
  }

  /* 记账 */
  .row-2 { gap: 10px; }
  .preview { grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 9px 10px; }
  .preview b { font-size: 12.5px; }
  .trade-item { padding: 11px 12px 12px; }
  .ti-head-row { gap: 7px; margin-bottom: 9px; }
  .ti-meta { font-size: 10.5px; }
  .ti-actions { width: 100%; margin-left: 0; }
  .ti-actions .btn { flex: 1; justify-content: center; }
  .ti-metrics { gap: 10px 8px; }
  .metric .v { font-size: 13.5px; }
  .pos-summary { gap: 4px 14px; font-size: 11px; padding: 7px 10px; }
  .calc-notes { grid-template-columns: 1fr; }

  /* 复盘 */
  .filters { width: 100%; gap: 8px; }
  .chips { width: 100%; justify-content: space-between; }
  .chip { flex: 1; text-align: center; }
  .filters .date-input { flex: 1 1 calc(50% - 20px); width: auto; min-width: 0; }
  .filters .mini-select { flex: 1 1 calc(50% - 4px); width: auto; min-width: 0; }
  .dash { display: none; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 10px 11px; }
  .kpi-val { font-size: 17px; }
  .kpi-hint { font-size: 10px; }

  /* 表单：16px 防止 iOS 聚焦时自动放大 */
  input[type="text"], input[type="password"], input[type="number"],
  input[type="date"], input[type="datetime-local"], select { font-size: 16px; }
  .filters .date-input, .filters .mini-select { font-size: 16px; }
  .field-hint { font-size: 11px; }

  /* 弹窗从底部弹出 */
  .modal-mask { align-items: flex-end; padding: 0; }
  .modal {
    max-width: none;
    width: 100%;
    border-radius: 16px 16px 0 0;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
    animation: sheet .2s ease;
  }
  @keyframes sheet { from { transform: translateY(16px); opacity: .6; } to { transform: none; opacity: 1; } }

  .toast {
    left: 14px;
    right: 14px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    transform: none;
    text-align: center;
    animation: none;
  }

  .auth-card { padding: 24px 18px 20px; }
  .auth-screen { padding: 18px 14px; }
  .site-footer { font-size: 11px; padding-bottom: 20px; }
}

/* 小屏（iPhone SE 等）：品种卡回到单列，KPI 仍两列 */
@media (max-width: 360px) {
  .variety-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr; }
}

/* ---------------- 数据源切换 ---------------- */
.head-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.source-pick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.source-pick select { min-width: 92px; }
.source-note {
  margin: -2px 0 10px;
  font-size: 11.5px;
  color: var(--muted);
  background: #f6f9fe;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  line-height: 1.5;
}

/* 自检弹窗比平仓弹窗宽 */
.modal-wide { max-width: 660px; }
.modal-wide .table-wrap { max-height: 46vh; }

@media (max-width: 760px) {
  .head-tools { width: 100%; justify-content: space-between; }
  .source-pick { flex: 1; }
  .source-pick select { flex: 1; min-width: 0; }
  .modal-wide { max-width: none; }
}


/* ---------------- 管理后台 ---------------- */
.admin-modal .modal-body { padding-top: 0; }
.admin-tabs {
  display: flex;
  gap: 4px;
  background: #f1f4f8;
  padding: 4px;
  border-radius: 10px;
  margin: 0 0 16px;
}
.admin-tab {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 7px 0;
  border-radius: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  transition: .18s;
}
.admin-tab.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(16, 28, 46, .1); }

.admin-pane .field { margin-bottom: 12px; }

/* 开关：注册开放 / 关闭 */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafcff;
  margin: 12px 0 8px;
}
.switch-text { min-width: 0; }
.switch-text strong { display: block; font-size: 13px; color: var(--ink); margin-bottom: 3px; }
.switch-text span { display: block; font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.switch {
  flex: 0 0 auto;
  width: 42px;
  height: 24px;
  border-radius: 12px;
  border: 1px solid #d3dce8;
  background: #e6ecf4;
  padding: 0;
  position: relative;
  transition: .18s;
}
.switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(16, 28, 46, .25);
  transition: .18s;
}
.switch[aria-checked="true"] { background: #1f7a4d; border-color: #1f7a4d; }
.switch[aria-checked="true"] .switch-knob { transform: translateX(18px); }
.switch:focus-visible { outline: 2px solid #9db4e8; outline-offset: 2px; }

.logo-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafcff;
  margin-bottom: 4px;
}
.logo-row img {
  flex: 0 0 auto;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  object-fit: contain;
}
.logo-actions { min-width: 0; }
.logo-btns { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.logo-actions .footnote { margin: 6px 0 0; }

.row-acts {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  align-items: center;
}
/* 用户表列不多，不让日期和按钮折行，窄屏交给 .table-wrap 横向滚动 */
#userTable th,
#userTable td { white-space: nowrap; }
/* 删除属危险操作，用红字（与涨跌配色无关） */
.link-btn.danger { color: #d92b45; }
.link-btn.danger:hover { color: #b31f37; text-decoration: underline; }
.link-btn[disabled] { opacity: .35; cursor: not-allowed; }
.link-btn[disabled]:hover { color: var(--muted); text-decoration: none; }

@media (max-width: 760px) {
  .logo-row { flex-direction: column; align-items: center; text-align: center; }
  .logo-btns { justify-content: center; }
  .row-acts { gap: 4px 8px; }
}
