:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #1c2430;
  --muted: #6b7480;
  --line: #dfe3e8;
  --accent: #2f6f4e;
  --loss: #b42318;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.brand { font-weight: 700; }

.logout { color: var(--muted); text-decoration: none; }
.logout:hover { color: var(--ink); }

.wrap { max-width: 960px; margin: 0 auto; padding: 20px; }

h1 { font-size: 20px; margin: 0 0 16px; }

table.positions {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

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

table.positions th:nth-child(1),
table.positions th:nth-child(2),
table.positions th:nth-child(3),
table.positions td:nth-child(1),
table.positions td:nth-child(2),
table.positions td:nth-child(3) { text-align: left; }

table.positions thead th {
  background: #eef1f4;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
}

table.positions tbody tr:last-child td { border-bottom: none; }

td[data-label="浮盈亏"] { color: var(--accent); }

.note, .empty { color: var(--muted); font-size: 13px; }

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  width: 100%;
  max-width: 340px;
  padding: 24px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.login-form { display: flex; flex-direction: column; gap: 8px; }

.login-form input {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 15px;
}

.login-form button {
  padding: 10px 12px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
}

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

/* 窄屏：表格转卡片。 */
@media (max-width: 639px) {
  .wrap { padding: 12px; }

  table.positions thead { display: none; }

  table.positions,
  table.positions tbody,
  table.positions tr,
  table.positions td { display: block; width: 100%; }

  table.positions tr {
    margin-bottom: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--card);
  }

  table.positions td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px;
    text-align: right;
    border-bottom: 1px solid var(--line);
  }

  table.positions tr td:last-child { border-bottom: none; }

  table.positions td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 600;
    text-align: left;
  }
}

/* 录入表单 */
.form-title { margin-top: 28px; font-size: 18px; }

.entry-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.entry-form .field { display: flex; flex-direction: column; gap: 4px; }

.entry-form label { color: var(--muted); font-size: 13px; font-weight: 600; }

.entry-form input,
.entry-form select {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.entry-form input:focus,
.entry-form select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.entry-form .actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.entry-form button {
  padding: 10px 18px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  cursor: pointer;
}

.warn {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--loss);
  border-radius: 6px;
  color: var(--loss);
  font-size: 13px;
}

@media (max-width: 639px) {
  .entry-form { grid-template-columns: 1fr; }
}

/* 公共 chrome：导航 / 页头 / 页脚 */
.tabs { display: flex; gap: 4px; overflow-x: auto; padding: 0 0 10px; margin: 0 0 10px;
        border-bottom: 1px solid #e5e7eb; -webkit-overflow-scrolling: touch; }
.tabs .tab { flex: 0 0 auto; padding: 8px 14px; border-radius: 8px; font-size: 14px;
             color: #57606a; text-decoration: none; white-space: nowrap; }
.tabs .tab:hover { background: #f3f4f6; }
.tabs .tab.active { background: #1f2328; color: #fff; font-weight: 600; }
.topbar { display: flex; align-items: center; justify-content: space-between;
          gap: 12px; padding: 6px 0 10px; }
.topbar .brand { font-weight: 700; color: #1f2328; text-decoration: none; }
.topbar .tb-right { display: flex; gap: 14px; align-items: center; }
.topbar a { color: #57606a; text-decoration: none; font-size: 14px; }
.topbar a:hover { text-decoration: underline; }
.foot { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between;
        margin: 28px 16px 18px; padding-top: 12px; border-top: 1px solid #e5e7eb;
        color: #8b949e; font-size: 12px; }
@media (min-width: 760px) { .tabs { gap: 8px; } .tabs .tab { padding: 8px 18px; } }


/* ============================================================
   统一基线（2026-11-14 归并）：此前 11 个模板各自内联了一整套
   body / .card / h1 / table 样式，导致同名类在不同页面表现不一致。
   现在只允许这一份。模板内不允许再出现 <style>。
   ============================================================ */
body { font-family: -apple-system, system-ui, "PingFang SC", "Microsoft YaHei", sans-serif;
       margin: 0; padding: 16px; background: #f7f7f8; color: #1f2328; }
h1 { font-size: 18px; margin: 0 0 8px; }
h2 { font-size: 15px; margin: 18px 0 6px; }
h3 { font-size: 14px; margin: 14px 0 6px; }
.card { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
        padding: 14px; margin-top: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
th, td { border-bottom: 1px solid #eee; padding: 8px 4px; text-align: left; vertical-align: middle; }
p.note { color: #57606a; font-size: 13px; line-height: 1.6; margin: 6px 0; }
.warn { color: #9a6700; font-size: 13px; }
.hint { color: #666; font-size: 13px; }
.actions { margin-top: 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
button { background: #1f883d; color: #fff; border: 0; border-radius: 6px;
         padding: 9px 18px; font-size: 14px; cursor: pointer; }
button:hover { background: #1a7f37; }
button.danger { background: #c0392b; }
button.danger:hover { background: #a93226; }
input[type=text], input[type=password], input[type=number], select {
  padding: 4px 6px; border: 1px solid #d0d7de; border-radius: 6px; font-size: 14px; }
label.chk { display: inline-block; margin-right: 14px; font-size: 13px; }
pre { background: #0d1117; color: #c9d1d9; padding: 10px; border-radius: 8px;
      font-size: 12px; overflow-x: auto; }
.on { color: #1a7f37; font-weight: 600; }
.off { color: #9a6700; font-weight: 600; }
.long { color: #1a7f37; font-weight: 600; }
.short { color: #c0392b; font-weight: 600; }
.flat { color: #8b949e; }
.tag { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 4px;
       background: #eef; color: #4a5568; }
a.toggle { color: #0969da; font-size: 13px; text-decoration: none; }
.badge { padding: 2px 8px; border-radius: 10px; background: #eee; font-size: 12px; }
.badge-validated { background: #d7f5dd; }
.badge-dryrun { background: #fff4d6; }
.badge-live { background: #bfe9c8; }
.badge-retired { background: #eee; color: #999; }
.badge-idea, .badge-coded, .badge-backtested { background: #f3f3f3; }
tr.ok td { background: #f6fdf7; }
tr.bad td { background: #fdf3f3; }
.badge-pass { background: #d7f5dd; color: #1a7f37; }
.badge-fail { background: #fde2e1; color: #c0392b; }
#chart { width: 100%; height: 68vh; min-height: 420px; }
