/* Trigger Scanner dashboard 样式。
   布局：左侧固定分组导航 + 右侧内容区；内容区按"页头 → 汇总 → 条件 → 明细"排列。只做浅色主题。
   颜色约定：红涨绿跌（A 股习惯）——正增长、上涨、正现金流用 --up（红），下跌、负值用 --down（绿）；
   品牌主色 --accent 只用于导航选中、主按钮、链接，不承载涨跌含义。 */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --hover: #fafbfd;
  --line: #e3e7ee;
  --line-strong: #cfd6e1;
  --text: #18202e;
  --text-2: #536074;
  --text-3: #8892a3;
  --accent: #2350c4;
  --accent-hover: #1c43a8;
  --accent-soft: #eaf0fd;
  --up: #d6372b;
  --up-soft: #fdeeec;
  --down: #0d8a5b;
  --down-soft: #e5f4ed;
  --warn: #a86400;
  --warn-soft: #fdf3e0;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Segoe UI", "Noto Sans CJK SC", sans-serif;
  --mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, "Microsoft YaHei", monospace;
  --r: 8px;
  --sidebar-w: 216px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 14px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.up { color: var(--up); } .down { color: var(--down); } .muted { color: var(--text-3); } .warn-text { color: var(--warn); }
code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }

/* ---------- 骨架 ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 18px 12px 14px;
}
.brand { display: flex; align-items: center; gap: 9px; padding: 2px 8px 18px; font-weight: 650; font-size: 14.5px; letter-spacing: .2px; color: var(--text); }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); position: relative; flex: none; }
.brand-mark::after {
  content: ""; position: absolute; left: 6px; right: 6px; top: 5px; bottom: 5px;
  border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: skewX(-12deg);
}
.nav-group { margin-top: 6px; }
.nav-label { font-size: 12px; color: var(--text-3); letter-spacing: .08em; padding: 10px 10px 4px; }
.nav-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 10px; border-radius: 6px; color: var(--text-2); font-size: 14px;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-count { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.nav-item.active .nav-count { color: var(--accent); }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding: 12px 10px 0; font-size: 13px; color: var(--text-2); display: grid; gap: 6px; }
.sidebar-foot .row { display: flex; justify-content: space-between; gap: 8px; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; flex: none; }
.dot.ok { background: var(--down); } .dot.idle { background: var(--text-3); } .dot.bad { background: var(--up); }

.main { min-width: 0; padding-block: 20px 48px; padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px)); }
.mobile-bar { display: none; }

/* ---------- 页头 ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: .2px; }
.page-head p { margin: 4px 0 0; color: var(--text-2); max-width: 72ch; }
.status { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 13px; color: var(--text-2); white-space: nowrap;
}
.chip b { color: var(--text); font-weight: 600; }

/* ---------- 提示 ---------- */
.msg { padding: 10px 14px; border-radius: var(--r); margin-bottom: 14px; font-size: 14px; border: 1px solid; }
.msg.error { background: var(--up-soft); color: #a8261d; border-color: #f6c9c4; }
.msg.info { background: var(--accent-soft); color: var(--accent); border-color: #cfdcfa; }
.hint { color: var(--text-3); font-size: 13px; }

/* ---------- 卡片 ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 14px; min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 11px 16px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 650; }
.panel-head .meta { color: var(--text-3); font-size: 13px; }
.panel-body { padding: 14px 16px; }
.empty { padding: 22px 16px; color: var(--text-3); text-align: center; }

.tiles { display: grid; grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr)); }
.tile { padding: 14px 16px; border-left: 1px solid var(--line); min-width: 0; }
.tile:first-child { border-left: 0; }
.tile .k { color: var(--text-3); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.tile .v { font-size: 24px; font-weight: 650; margin-top: 2px; letter-spacing: .3px; font-variant-numeric: tabular-nums; }
.tile .v.sm { font-size: 17px; }
.tile .s { color: var(--text-3); font-size: 12.5px; }
.tile.hl .v { color: var(--accent); }
.arrow { color: var(--line-strong); }
.excl { display: flex; gap: 6px 14px; flex-wrap: wrap; padding: 10px 16px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r) var(--r); font-size: 13px; color: var(--text-2); }
.excl b { color: var(--text); font-weight: 600; margin-left: 3px; font-variant-numeric: tabular-nums; }
.two-col { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 14px; align-items: start; }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: repeat(var(--cols, 6), minmax(0, 1fr)); gap: 12px 14px; }
.field { display: grid; gap: 4px; min-width: 0; align-content: start; }
.field.span2 { grid-column: span 2; } .field.span3 { grid-column: span 3; } .field.full { grid-column: 1 / -1; }
.field > label, .label { font-size: 13px; color: var(--text-2); }
.input, .select, .textarea {
  height: 34px; width: 100%; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface);
}
.textarea { height: auto; min-height: 60px; padding: 8px 10px; resize: vertical; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-3); }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 56px; }
.input-wrap .unit { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: 13px; pointer-events: none; }

/* 分段单选：用真的 radio，提交表单时能带上值 */
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 6px; overflow: hidden; height: 34px; width: max-content; max-width: 100%; }
.seg label { display: flex; align-items: center; cursor: pointer; }
.seg label + label { border-left: 1px solid var(--line-strong); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { padding: 0 13px; color: var(--text-2); height: 100%; display: flex; align-items: center; white-space: nowrap; }
.seg input:checked + span { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text); font-size: 14px; min-height: 34px; }
.switch input {
  appearance: none; -webkit-appearance: none; width: 30px; height: 18px; border-radius: 999px; background: var(--line-strong);
  position: relative; cursor: pointer; margin: 0; flex: none; transition: background .15s;
}
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(16,24,40,.2); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(12px); }

/* 可多选的胶囊（提醒节点、通知渠道） */
.pills { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pill-check { cursor: pointer; }
.pill-check input { position: absolute; opacity: 0; pointer-events: none; }
.pill-check span { display: inline-flex; align-items: center; height: 30px; padding: 0 13px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-2); white-space: nowrap; }
.pill-check input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.pill-check input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.form-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.rule-note { color: var(--text-3); font-size: 13px; max-width: 80ch; }

.btn {
  height: 34px; padding: 0 15px; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--surface);
  cursor: pointer; font-weight: 500; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; color: var(--text);
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.danger { color: var(--up); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn-row form { margin: 0; display: contents; }
.inline-form { display: inline-flex; gap: 8px; margin: 0; }

/* ---------- 表格 ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.toolbar .left { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.toolbar .left b { font-size: 15px; }
.search { width: 200px; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th {
  position: sticky; top: 0; z-index: 1; background: var(--surface-2); color: var(--text-3);
  font-size: 12.5px; font-weight: 500; text-align: right; padding: 9px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
th .sub { font-weight: 400; margin-left: 4px; }
td { padding: 11px 14px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: top; white-space: nowrap; font-variant-numeric: tabular-nums; }
th.l, td.l, th:first-child, td:first-child { text-align: left; }
td.wrap { white-space: normal; }
tbody tr:hover td { background: var(--hover); }
tbody tr:last-child td { border-bottom: 0; }
.tk { font-family: var(--mono); font-weight: 700; font-size: 15px; letter-spacing: .3px; color: var(--text); }
.ex { font-family: var(--font); font-weight: 500; font-size: 11.5px; color: var(--text-3); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; margin-left: 5px; vertical-align: 1px; letter-spacing: 0; }
.nm { color: var(--text-2); font-size: 13px; max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.v1 { font-weight: 650; font-size: 16px; }
.sub { color: var(--text-3); font-size: 13px; margin-top: 1px; }
.sub b { color: var(--text-2); font-weight: 600; }

.badge { display: inline-flex; align-items: center; height: 23px; padding: 0 8px; border-radius: 4px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.badge.good { background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.up { background: var(--up-soft); color: var(--up); }
.badge.down { background: var(--down-soft); color: var(--down); }
.badge.neutral { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line); }

/* 成长股：各期增速小格 */
.periods { display: inline-grid; grid-auto-flow: column; gap: 4px; }
.pd { min-width: 76px; padding: 5px 8px; border-radius: 5px; background: var(--up-soft); text-align: center; }
.pd .pv { font-weight: 650; font-size: 14px; color: var(--up); }
.pd .pl { font-size: 12px; color: var(--text-3); }
.pd.neg { background: var(--down-soft); } .pd.neg .pv { color: var(--down); }
.pd.fail { background: var(--surface-2); } .pd.fail .pv { color: var(--text-3); text-decoration: line-through; }
.r40 { display: inline-flex; align-items: center; gap: 6px; }
.r40 .bar { width: 46px; height: 5px; border-radius: 3px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.r40 .bar i { display: block; height: 100%; background: var(--accent); }

/* 成长股：详情并入各列——展开时每列主数字下多两行，收起时只看主数字 */
.ext { margin-top: 7px; padding-top: 7px; border-top: 1px dashed var(--line); display: grid; gap: 2px; }
.ext .sub { margin: 0; }
tr.main-row { cursor: pointer; }
tr.main-row:not(.open) .ext { display: none; }
.more { border: 0; background: none; color: var(--accent); cursor: pointer; font-size: 13px; padding: 2px 0; white-space: nowrap; }
.more .caret { display: inline-block; transition: transform .15s; }
tr.open .more .caret { transform: rotate(180deg); }

/* 实时监控 */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 12px; }
.tab { padding: 10px 10px 9px; border: 0; background: none; color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.countdown { font-weight: 650; font-size: 15px; }
.countdown.soon { color: var(--warn); }
.ladder { display: flex; gap: 3px; margin-top: 5px; }
.ladder i { width: 14px; height: 4px; border-radius: 2px; background: var(--line); }
.ladder.up i.on { background: var(--up); }
.ladder.down i.on { background: var(--down); }
.node { display: inline-flex; align-items: center; height: 23px; padding: 0 8px; border-radius: 999px; font-size: 12.5px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line); margin: 1px 2px 1px 0; white-space: nowrap; }
.node.sent { background: var(--down-soft); color: var(--down); border-color: transparent; }

/* 行内弹层（笔记、编辑） */
details.pop { display: inline-block; position: relative; }
details.pop > summary { list-style: none; }
details.pop > summary::-webkit-details-marker { display: none; }
details.pop[open] > summary { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.pop-body {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 5; width: 320px; max-width: 80vw;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r); padding: 12px;
  box-shadow: 0 12px 28px rgba(16,24,40,.12); text-align: left; white-space: normal;
}
.note { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.note small { display: block; color: var(--text-3); font-size: 12px; }
.badge-n { display: inline-block; min-width: 17px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 11px; line-height: 17px; text-align: center; }

/* ---------- 登录 ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding-block: 24px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.login-box { width: 100%; max-width: 360px; }
.login-box .brand { padding: 0 0 6px; font-size: 18px; }
.login-box p { color: var(--text-2); margin: 0 0 18px; }
.login-box .panel-body { display: grid; gap: 12px; padding: 20px; }

/* ---------- 窄屏 ---------- */
@media (max-width: 1100px) {
  .form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .two-col { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; z-index: 20; left: 0; top: 0; width: 240px; transform: translateX(-100%); transition: transform .2s;
    padding-top: calc(18px + env(safe-area-inset-top, 0px)); padding-left: max(12px, env(safe-area-inset-left, 0px));
    box-shadow: 0 10px 30px rgba(16,24,40,.12);
  }
  .sidebar.open { transform: none; }
  .mobile-bar {
    display: flex; align-items: center; justify-content: space-between; position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10;
    background: var(--surface); border-bottom: 1px solid var(--line); padding-block: 10px;
    padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  }
  .mobile-bar .brand { padding: 0; }
  .main { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile:nth-child(odd) { border-left: 0; }
  .tile:nth-child(n+3) { border-top: 1px solid var(--line); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field.span3 { grid-column: span 2; }
  .search { width: 100%; }
  .pop-body { right: auto; left: 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
