:root {
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-2: #fafbf9;
  --ink: #16312a;
  --ink-2: #4d6058;
  --ink-3: #8a9992;
  --line: #e4e9e3;
  --line-2: #eef2ec;
  --accent: #183d31;
  --up: #cc3b2e;      /* 中国习惯：盈利红 */
  --down: #1a8754;    /* 亏损绿 */
  --chip: #eef3ef;
  --radius: 10px;
}

* { box-sizing: border-box; }

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

#app { max-width: 1180px; margin: 0 auto; padding: 18px 20px 40px; }

/* ---------- 顶栏 ---------- */
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.topbar h1 { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: .2px; }
.topbar .sub { margin-top: 4px; font-size: 12.5px; color: var(--ink-3); }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.conn {
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  background: var(--chip); color: var(--ink-2); white-space: nowrap;
}
.conn-ok   { background: #e6f3ec; color: #1a8754; }
.conn-wait { background: #fdf2e7; color: #a2662a; }
.conn-bad  { background: #fbeceb; color: #cc3b2e; }

.btn-refresh {
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); border-radius: 8px; padding: 5px 13px;
  font-size: 12.5px; cursor: pointer;
}
.btn-refresh:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- 控制条 ---------- */
.bar-controls {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin: 14px 0 16px; flex-wrap: wrap;
}
.sel {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 8px; padding: 6px 10px; font-size: 13px; min-width: 160px;
}
.seg {
  display: inline-flex; border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden; background: var(--surface);
}
.seg button {
  border: 0; background: transparent; color: var(--ink-2);
  padding: 6px 15px; font-size: 13px; cursor: pointer;
  border-left: 1px solid var(--line-2);
}
.seg button:first-child { border-left: 0; }
.seg button:hover { background: var(--surface-2); }
.seg button.on { background: var(--accent); color: #fff; }

/* ---------- 指标卡 ---------- */
.cards {
  display: grid; gap: 10px; margin-bottom: 16px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px;
}
.card .k { font-size: 12px; color: var(--ink-3); margin-bottom: 5px; }
.card .v { font-size: 20px; font-weight: 600; letter-spacing: -.2px; }
.card .v.pos { color: var(--up); }
.card .v.neg { color: var(--down); }
.card .v.na  { color: var(--ink-3); font-size: 16px; font-weight: 500; }

/* ---------- 面板 ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px 12px; margin-bottom: 14px;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; min-height: 22px;
}
.panel-head h2 { margin: 0; font-size: 14.5px; font-weight: 600; }
.count { font-size: 12px; color: var(--ink-3); }

.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); flex-wrap: wrap; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }

.grid-2 { display: grid; grid-template-columns: 1.15fr 1fr; gap: 14px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.chart { width: 100%; }
.chart-main { height: 320px; }
.chart-cal  { height: 240px; }

/* ---------- 表格 ---------- */
.tblwrap   { overflow: auto; max-height: 300px; }
.tblwrap-sm{ max-height: 200px; }
.tblwrap-lg{ max-height: 420px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th {
  position: sticky; top: 0; background: var(--surface-2); z-index: 1;
  text-align: right; font-weight: 500; color: var(--ink-3);
  padding: 7px 9px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tbl td {
  padding: 6px 9px; border-bottom: 1px solid var(--line-2);
  text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl tbody tr:hover td { background: var(--surface-2); }
.tbl .pos { color: var(--up); }
.tbl .neg { color: var(--down); }
.tbl .mut { color: var(--ink-3); }
.tbl .empty { text-align: center; color: var(--ink-3); padding: 22px; }

.pager { display: flex; align-items: center; gap: 12px; justify-content: flex-end; margin-top: 10px; }
.btn-page {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  border-radius: 7px; padding: 4px 12px; font-size: 12.5px; cursor: pointer;
}
.btn-page:disabled { opacity: .45; cursor: default; }
.page-info { font-size: 12px; color: var(--ink-3); }

.foot { margin-top: 16px; font-size: 11.5px; color: var(--ink-3); text-align: center; }

.errbox {
  background: #fbeceb; color: #8f2b21; border: 1px solid #f2cfcb;
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; font-size: 13px;
}
/* 漏传文件的提示：黄色，跟真报错区分开 */
.errbox.warnbox {
  background: #fdf5e3; color: #8a5a10; border-color: #f0dcae;
}
.errbox.warnbox code {
  background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 4px;
}

/* ---------- 成交历史：头部与刷新 ---------- */
.head-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.head-right .upd,
.head-right .tips { font-size: 11.5px; color: var(--ink-3); }
.btn-mini {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  border-radius: 6px; padding: 3px 11px; font-size: 12px; cursor: pointer;
}
.btn-mini:hover { background: var(--surface-2); }
.btn-mini:disabled { opacity: .5; cursor: default; }
#dealsBox { transition: box-shadow .25s; border-radius: var(--radius); }
#dealsBox.flash { box-shadow: 0 0 0 2px rgba(37, 99, 235, .32); }

/* ---------- 利润日历（HTML 月历） ---------- */
.chart-cal { height: auto; max-height: 540px; overflow-y: auto; }
.cal-legend { display: flex; gap: 16px; font-size: 11.5px; color: var(--ink-3); margin-bottom: 10px; }
.cal-lg { display: inline-flex; align-items: center; gap: 5px; }
.cal-i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.cal-i-win  { background: rgba(204, 59, 46, .55); }
.cal-i-loss { background: rgba(26, 135, 84, .55); }
.cal-i-off  { background: #f4f6f3; border: 1px solid var(--line); }

.cal-month { margin-bottom: 14px; }
.cal-title { font-size: 12.5px; color: var(--ink-2); margin-bottom: 6px; font-weight: 500; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-hd { text-align: center; font-size: 11px; color: var(--ink-3); padding: 3px 0; }
.cal-cell {
  border: 1px solid var(--line-2); border-radius: 5px;
  min-height: 44px; padding: 3px 5px; position: relative;
  display: flex; flex-direction: column; justify-content: space-between;
}
.cal-blank { border: 0; background: transparent; }
.cal-off { background: #fafbf9; }
.cal-d { font-size: 10px; color: var(--ink-3); line-height: 1.2; }
.cal-v {
  font-size: 11px; font-weight: 600; text-align: right;
  font-variant-numeric: tabular-nums; line-height: 1.2;
}
.cal-win  .cal-v { color: #8f2b21; }
.cal-loss .cal-v { color: #14663f; }
.cal-v.mut { color: var(--ink-3); font-weight: 400; }
.cal-sum { margin-top: 7px; font-size: 11.5px; color: var(--ink-3); }
.cal-sum b { color: var(--ink); }
.cal-none { padding: 22px; text-align: center; color: var(--ink-3); font-size: 12.5px; }

/* ---------- EA 战绩表 ---------- */
.tblwrap-ea { max-height: 340px; }
.tbl-ea .ea-name { text-align: left; font-weight: 600; white-space: nowrap; }
.tbl-ea .pnl-cell { position: relative; padding-bottom: 9px; font-weight: 600; }
.tbl-ea .pnl-cell .bar {
  position: absolute; right: 8px; bottom: 3px;
  height: 3px; border-radius: 2px; opacity: .5;
  max-width: calc(100% - 16px);
}
.tbl-ea .bar-pos { background: var(--up); }
.tbl-ea .bar-neg { background: var(--down); }
.tbl-ea .dd-cell { color: var(--down); }

/* ============================================================
   栏目密码 · 毛玻璃门禁
   上锁时真数据不出服务端，页面上只有骨架屏 + 磨砂浮层。
   ============================================================ */
.lockwrap { position: relative; }

/* 底下那层：糊掉 + 禁止交互/选中 */
.lockwrap.is-locked > .tblwrap {
  filter: blur(7px) saturate(120%);
  opacity: .72;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

/* 骨架条 */
.sk {
  display: inline-block; height: 9px; border-radius: 5px;
  background: linear-gradient(90deg, var(--line) 0%, var(--line-2) 60%, var(--line) 100%);
}

/* 浮层：整块盖住，中间一张磨砂卡片 */
.lockpanel {
  position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  padding: 14px;
}
.lockpanel[hidden] { display: none; }

.lockcard {
  width: min(360px, 100%);
  padding: 20px 20px 18px;
  text-align: center;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, .85);
  background: rgba(255, 255, 255, .74);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  backdrop-filter: blur(16px) saturate(150%);
  box-shadow: 0 16px 40px rgba(22, 49, 42, .14), 0 2px 6px rgba(22, 49, 42, .06);
}
.lockicon  { font-size: 24px; line-height: 1; margin-bottom: 8px; }
.locktitle { font-size: 14.5px; font-weight: 600; color: var(--ink); }
.lockdesc  { margin-top: 5px; font-size: 12px; line-height: 1.65; color: var(--ink-2); }

.lockinput {
  width: 100%; margin-top: 12px;
  border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 12px; font-size: 13.5px; color: var(--ink);
  background: rgba(255, 255, 255, .92);
  outline: none;
  -webkit-appearance: none;
}
.lockinput:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(24, 61, 49, .10); }
.lockinput.sm { width: auto; max-width: 190px; margin-top: 0; padding: 6px 10px; font-size: 13px; }

.lockerr { min-height: 16px; margin-top: 7px; font-size: 12px; color: #8f2b21; }
.lockcard .lockerr { min-height: 14px; }

.lock-ok {
  margin-top: 2px;
  background: var(--accent); color: #fff; border-color: var(--accent);
  padding: 6px 20px; font-size: 13px;
}
.lock-ok:hover { background: #20493b; }

.lock-btn { font-size: 11.5px; color: var(--ink-2); }

/* 备注列的加密条：像被糊掉的字符，看不出真实长度 */
.tbl .note-mask { padding-left: 9px; padding-right: 9px; }
.tbl .note-mask span {
  display: block; height: 8px; border-radius: 4px;
  background: #d9e0da;
  filter: blur(1.4px);
}
.tbl th.th-note { color: var(--ink-3); }

/* 成交历史上方的解锁条 */
.lockbar {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  margin-bottom: 10px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-2);
}
.lockbar[hidden] { display: none; }
.lockbar-txt  { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.lockbar-tip  { font-size: 11.5px; color: var(--ink-3); }
.lockbar .lockerr { min-height: 0; margin-top: 0; }

/* ---------- 移动端补微调 ---------- */
@media (max-width: 768px) {
  .lockcard { width: 100%; padding: 18px 16px 16px; border-radius: 14px; }
  .lockinput { padding: 10px 12px; font-size: 16px; }   /* <16px 会被 iOS 自动放大 */
  .lockinput.sm { width: 100%; max-width: none; font-size: 16px; }
  .lock-ok { width: 100%; padding: 9px 0; }
  .lockbar { gap: 8px; padding: 10px 12px; }
  .lockbar-tip { display: none; }
}

/* ============================================================
   移动端适配
   站点是嵌在 WordPress 里的 iframe，手机上父容器可能很窄，
   所以按"最窄也要能用"来设计：卡片两列、按钮撑满整行、
   表格横向滚动且首列吸附、图表压缩留白、触摸目标放大到 ≥36px。
   ============================================================ */
@media (max-width: 768px) {
  #app { padding: 12px 12px 28px; }

  /* 顶栏竖排，避免标题和按钮挤在一行 */
  .topbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .topbar h1 { font-size: 17px; line-height: 1.35; }
  .topbar .sub { font-size: 12px; }
  .topbar-right { justify-content: space-between; }
  .conn { flex: 1; text-align: center; }
  .btn-refresh { padding: 7px 16px; }

  /* 控制条：账户选择独占一行，区间按钮均分整行 */
  .bar-controls { gap: 8px; margin: 12px 0 14px; }
  .sel { width: 100%; min-width: 0; padding: 8px 10px; }
  .seg { display: flex; width: 100%; }
  .seg button { flex: 1 1 0; padding: 9px 4px; font-size: 12.5px; }

  /* 指标卡：两列紧凑排布 */
  .cards { grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 12px; }
  .card { padding: 10px 11px; border-radius: 12px; }
  .card .k { font-size: 11px; margin-bottom: 3px; }
  .card .v { font-size: 17px; }
  .card .v.na { font-size: 13px; }

  /* 面板 */
  .panel { padding: 12px 12px 10px; border-radius: 12px; margin-bottom: 12px; }
  .panel-head h2 { font-size: 13.5px; }
  .panel-head .tips { display: none; }   /* 窄屏优先保数据，说明文字让位 */
  .legend { gap: 10px; font-size: 11px; }

  /* 图表：压低高度、加粗滑杆，方便手指拖拽 */
  .chart-main { height: 250px; }
  .chart-cal  { max-height: none; }
  .cal-month  { margin-bottom: 10px; }
  .cal-cell   { min-height: 40px; padding: 2px 3px; }
  .cal-d      { font-size: 9px; }
  .cal-v      { font-size: 9.5px; }
  .cal-grid   { gap: 2px; }

  /* 表格：横向滚动 + 首列吸附，滑到右边也知道在看哪套 EA */
  .tblwrap { -webkit-overflow-scrolling: touch; max-height: 340px; }
  .tblwrap-lg { max-height: 420px; }
  .tbl { font-size: 12px; }
  .tbl th, .tbl td { padding: 7px 9px; }
  .tblwrap-ea { max-height: 320px; }
  .tbl-ea th:first-child,
  .tbl-ea td:first-child {
    position: sticky; left: 0; z-index: 2;
    background: var(--surface);
    box-shadow: 1px 0 0 var(--line);
  }
  .tbl-ea thead th:first-child { z-index: 3; background: var(--surface-2); }

  /* 分页按钮放大触摸面积 */
  .pager { justify-content: space-between; }
  .btn-page { padding: 8px 18px; }
  .btn-mini { padding: 5px 13px; }

  .foot { font-size: 11px; line-height: 1.9; }
}

/* 超窄屏（iPhone SE 这类）：保持两列，但字号再收一档 */
@media (max-width: 380px) {
  .card .v { font-size: 15.5px; }
  .chart-main { height: 220px; }
  .seg button { font-size: 11.5px; padding: 9px 2px; }
}

/* 手机横屏：图表给足高度，观感接近桌面 */
@media (max-width: 900px) and (orientation: landscape) {
  .chart-main { height: 300px; }
}
